noahluckyrobots commited on
Commit
74a4153
·
verified ·
1 Parent(s): 64fadb4

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. worker/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  2. worker/node_modules/ufo/LICENSE +21 -0
  3. worker/node_modules/ufo/README.md +582 -0
  4. worker/node_modules/ufo/package.json +48 -0
  5. worker/node_modules/undici/LICENSE +21 -0
  6. worker/node_modules/undici/README.md +443 -0
  7. worker/node_modules/undici/index-fetch.js +15 -0
  8. worker/node_modules/undici/index.d.ts +3 -0
  9. worker/node_modules/undici/index.js +167 -0
  10. worker/node_modules/undici/package.json +167 -0
  11. worker/node_modules/unenv/LICENSE +21 -0
  12. worker/node_modules/unenv/README.md +211 -0
  13. worker/node_modules/unenv/package.json +76 -0
  14. worker/node_modules/workerd/README.md +6 -0
  15. worker/node_modules/workerd/install.js +251 -0
  16. worker/node_modules/workerd/package.json +24 -0
  17. worker/node_modules/workerd/worker.mjs +0 -0
  18. worker/node_modules/workerd/workerd.capnp +1028 -0
  19. worker/node_modules/wrangler/README.md +70 -0
  20. worker/node_modules/wrangler/bin/wrangler.js +93 -0
  21. worker/node_modules/wrangler/config-schema.json +0 -0
  22. worker/node_modules/wrangler/kv-asset-handler.js +1 -0
  23. worker/node_modules/wrangler/package.json +185 -0
  24. worker/node_modules/wrangler/templates/checked-fetch.js +30 -0
  25. worker/node_modules/wrangler/templates/facade.d.ts +19 -0
  26. worker/node_modules/wrangler/templates/gitignore +170 -0
  27. worker/node_modules/wrangler/templates/init-tests/test-jest-new-worker.js +23 -0
  28. worker/node_modules/wrangler/templates/init-tests/test-vitest-new-worker.js +24 -0
  29. worker/node_modules/wrangler/templates/init-tests/test-vitest-new-worker.ts +25 -0
  30. worker/node_modules/wrangler/templates/middleware/common.ts +67 -0
  31. worker/node_modules/wrangler/templates/middleware/loader-modules.ts +134 -0
  32. worker/node_modules/wrangler/templates/middleware/loader-sw.ts +229 -0
  33. worker/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  34. worker/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  35. worker/node_modules/wrangler/templates/middleware/middleware-mock-analytics-engine.d.ts +3 -0
  36. worker/node_modules/wrangler/templates/middleware/middleware-mock-analytics-engine.ts +30 -0
  37. worker/node_modules/wrangler/templates/modules-watch-stub.js +4 -0
  38. worker/node_modules/wrangler/templates/new-worker-scheduled.js +17 -0
  39. worker/node_modules/wrangler/templates/new-worker-scheduled.ts +32 -0
  40. worker/node_modules/wrangler/templates/new-worker.js +15 -0
  41. worker/node_modules/wrangler/templates/new-worker.ts +33 -0
  42. worker/node_modules/wrangler/templates/no-op-worker.js +10 -0
  43. worker/node_modules/wrangler/templates/pages-dev-pipeline.ts +33 -0
  44. worker/node_modules/wrangler/templates/pages-dev-util.ts +55 -0
  45. worker/node_modules/wrangler/templates/pages-shim.ts +9 -0
  46. worker/node_modules/wrangler/templates/pages-template-plugin.ts +190 -0
  47. worker/node_modules/wrangler/templates/pages-template-worker.ts +198 -0
  48. worker/node_modules/wrangler/templates/strip-cf-connecting-ip-header.js +13 -0
  49. worker/node_modules/wrangler/templates/tsconfig-sanity.ts +11 -0
  50. worker/node_modules/wrangler/templates/tsconfig.init.json +22 -0
worker/node_modules/typescript/ThirdPartyNoticeText.txt ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!----------------- TypeScript ThirdPartyNotices -------------------------------------------------------
2
+
3
+ The TypeScript software incorporates third party material from the projects listed below. The original copyright notice and the license under which Microsoft received such third party material are set forth below. Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.
4
+
5
+ ---------------------------------------------
6
+ Third Party Code Components
7
+ --------------------------------------------
8
+
9
+ ------------------- DefinitelyTyped --------------------
10
+ This file is based on or incorporates material from the projects listed below (collectively "Third Party Code"). Microsoft is not the original author of the Third Party Code. The original copyright notice and the license, under which Microsoft received such Third Party Code, are set forth below. Such licenses and notices are provided for informational purposes only. Microsoft, not the third party, licenses the Third Party Code to you under the terms set forth in the EULA for the Microsoft Product. Microsoft reserves all other rights not expressly granted under this agreement, whether by implication, estoppel or otherwise.
11
+ DefinitelyTyped
12
+ This project is licensed under the MIT license. Copyrights are respective of each contributor listed at the beginning of each definition file. Provided for Informational Purposes Only
13
+
14
+ MIT License
15
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ --------------------------------------------------------------------------------------
21
+
22
+ ------------------- Unicode --------------------
23
+ UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
24
+
25
+ Unicode Data Files include all data files under the directories
26
+ http://www.unicode.org/Public/, http://www.unicode.org/reports/,
27
+ http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and
28
+ http://www.unicode.org/utility/trac/browser/.
29
+
30
+ Unicode Data Files do not include PDF online code charts under the
31
+ directory http://www.unicode.org/Public/.
32
+
33
+ Software includes any source code published in the Unicode Standard
34
+ or under the directories
35
+ http://www.unicode.org/Public/, http://www.unicode.org/reports/,
36
+ http://www.unicode.org/cldr/data/, http://source.icu-project.org/repos/icu/, and
37
+ http://www.unicode.org/utility/trac/browser/.
38
+
39
+ NOTICE TO USER: Carefully read the following legal agreement.
40
+ BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
41
+ DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
42
+ YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
43
+ TERMS AND CONDITIONS OF THIS AGREEMENT.
44
+ IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
45
+ THE DATA FILES OR SOFTWARE.
46
+
47
+ COPYRIGHT AND PERMISSION NOTICE
48
+
49
+ Copyright (c) 1991-2017 Unicode, Inc. All rights reserved.
50
+ Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
51
+
52
+ Permission is hereby granted, free of charge, to any person obtaining
53
+ a copy of the Unicode data files and any associated documentation
54
+ (the "Data Files") or Unicode software and any associated documentation
55
+ (the "Software") to deal in the Data Files or Software
56
+ without restriction, including without limitation the rights to use,
57
+ copy, modify, merge, publish, distribute, and/or sell copies of
58
+ the Data Files or Software, and to permit persons to whom the Data Files
59
+ or Software are furnished to do so, provided that either
60
+ (a) this copyright and permission notice appear with all copies
61
+ of the Data Files or Software, or
62
+ (b) this copyright and permission notice appear in associated
63
+ Documentation.
64
+
65
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
66
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
67
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
68
+ NONINFRINGEMENT OF THIRD PARTY RIGHTS.
69
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
70
+ NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
71
+ DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
72
+ DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
73
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
74
+ PERFORMANCE OF THE DATA FILES OR SOFTWARE.
75
+
76
+ Except as contained in this notice, the name of a copyright holder
77
+ shall not be used in advertising or otherwise to promote the sale,
78
+ use or other dealings in these Data Files or Software without prior
79
+ written authorization of the copyright holder.
80
+ -------------------------------------------------------------------------------------
81
+
82
+ -------------------Document Object Model-----------------------------
83
+ DOM
84
+
85
+ W3C License
86
+ This work is being provided by the copyright holders under the following license.
87
+ By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
88
+ Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following
89
+ on ALL copies of the work or portions thereof, including modifications:
90
+ * The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
91
+ * Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included.
92
+ * Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived
93
+ from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."
94
+ Disclaimers
95
+ THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR
96
+ FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
97
+ COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
98
+ The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission.
99
+ Title to copyright in this work will at all times remain with copyright holders.
100
+
101
+ ---------
102
+
103
+ DOM
104
+ Copyright © 2018 WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a Creative Commons Attribution 4.0 International License: Attribution 4.0 International
105
+ =======================================================================
106
+ Creative Commons Corporation ("Creative Commons") is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an "as-is" basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. Using Creative Commons Public Licenses Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC- licensed material, or material used under an exception or limitation to copyright. More considerations for licensors:
107
+
108
+ wiki.creativecommons.org/Considerations_for_licensors Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor's permission is not necessary for any reason--for example, because of any applicable exception or limitation to copyright--then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More_considerations for the public: wiki.creativecommons.org/Considerations_for_licensees =======================================================================
109
+ Creative Commons Attribution 4.0 International Public License By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. Section 1 -- Definitions. a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. Section 2 -- Scope. a. License grant. 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: a. reproduce and Share the Licensed Material, in whole or in part; and b. produce, reproduce, and Share Adapted Material. 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 3. Term. The term of this Public License is specified in Section 6(a). 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a) (4) never produces Adapted Material. 5. Downstream recipients. a. Offer from the Licensor -- Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. b. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). b. Other rights. 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 2. Patent and trademark rights are not licensed under this Public License. 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. Section 3 -- License Conditions. Your exercise of the Licensed Rights is expressly made subject to the following conditions. a. Attribution. 1. If You Share the Licensed Material (including in modified form), You must: a. retain the following if it is supplied by the Licensor with the Licensed Material: i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); ii. a copyright notice; iii. a notice that refers to this Public License; iv. a notice that refers to the disclaimer of warranties; v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; b. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and c. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. Section 4 -- Sui Generis Database Rights. Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. Section 5 -- Disclaimer of Warranties and Limitation of Liability. a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. Section 6 -- Term and Termination. a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 2. upon express reinstatement by the Licensor. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. Section 7 -- Other Terms and Conditions. a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. Section 8 -- Interpretation. a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. ======================================================================= Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the "Licensor." Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark "Creative Commons" or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. Creative Commons may be contacted at creativecommons.org.
110
+
111
+ --------------------------------------------------------------------------------
112
+
113
+ ----------------------Web Background Synchronization------------------------------
114
+
115
+ Web Background Synchronization Specification
116
+ Portions of spec © by W3C
117
+
118
+ W3C Community Final Specification Agreement
119
+ To secure commitments from participants for the full text of a Community or Business Group Report, the group may call for voluntary commitments to the following terms; a "summary" is
120
+ available. See also the related "W3C Community Contributor License Agreement".
121
+ 1. The Purpose of this Agreement.
122
+ This Agreement sets forth the terms under which I make certain copyright and patent rights available to you for your implementation of the Specification.
123
+ Any other capitalized terms not specifically defined herein have the same meaning as those terms have in the "W3C Patent Policy", and if not defined there, in the "W3C Process Document".
124
+ 2. Copyrights.
125
+ 2.1. Copyright Grant. I grant to you a perpetual (for the duration of the applicable copyright), worldwide, non-exclusive, no-charge, royalty-free, copyright license, without any obligation for accounting to me, to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, distribute, and implement the Specification to the full extent of my copyright interest in the Specification.
126
+ 2.2. Attribution. As a condition of the copyright grant, you must include an attribution to the Specification in any derivative work you make based on the Specification. That attribution must include, at minimum, the Specification name and version number.
127
+ 3. Patents.
128
+ 3.1. Patent Licensing Commitment. I agree to license my Essential Claims under the W3C Community RF Licensing Requirements. This requirement includes Essential Claims that I own and any that I have the right to license without obligation of payment or other consideration to an unrelated third party. W3C Community RF Licensing Requirements obligations made concerning the Specification and described in this policy are binding on me for the life of the patents in question and encumber the patents containing Essential Claims, regardless of changes in participation status or W3C Membership. I also agree to license my Essential Claims under the W3C Community RF Licensing Requirements in derivative works of the Specification so long as all normative portions of the Specification are maintained and that this licensing commitment does not extend to any portion of the derivative work that was not included in the Specification.
129
+ 3.2. Optional, Additional Patent Grant. In addition to the provisions of Section 3.1, I may also, at my option, make certain intellectual property rights infringed by implementations of the Specification, including Essential Claims, available by providing those terms via the W3C Web site.
130
+ 4. No Other Rights. Except as specifically set forth in this Agreement, no other express or implied patent, trademark, copyright, or other property rights are granted under this Agreement, including by implication, waiver, or estoppel.
131
+ 5. Antitrust Compliance. I acknowledge that I may compete with other participants, that I am under no obligation to implement the Specification, that each participant is free to develop competing technologies and standards, and that each party is free to license its patent rights to third parties, including for the purpose of enabling competing technologies and standards.
132
+ 6. Non-Circumvention. I agree that I will not intentionally take or willfully assist any third party to take any action for the purpose of circumventing my obligations under this Agreement.
133
+ 7. Transition to W3C Recommendation Track. The Specification developed by the Project may transition to the W3C Recommendation Track. The W3C Team is responsible for notifying me that a Corresponding Working Group has been chartered. I have no obligation to join the Corresponding Working Group. If the Specification developed by the Project transitions to the W3C Recommendation Track, the following terms apply:
134
+ 7.1. If I join the Corresponding Working Group. If I join the Corresponding Working Group, I will be subject to all W3C rules, obligations, licensing commitments, and policies that govern that Corresponding Working Group.
135
+ 7.2. If I Do Not Join the Corresponding Working Group.
136
+ 7.2.1. Licensing Obligations to Resulting Specification. If I do not join the Corresponding Working Group, I agree to offer patent licenses according to the W3C Royalty-Free licensing requirements described in Section 5 of the W3C Patent Policy for the portions of the Specification included in the resulting Recommendation. This licensing commitment does not extend to any portion of an implementation of the Recommendation that was not included in the Specification. This licensing commitment may not be revoked but may be modified through the exclusion process defined in Section 4 of the W3C Patent Policy. I am not required to join the Corresponding Working Group to exclude patents from the W3C Royalty-Free licensing commitment, but must otherwise follow the normal exclusion procedures defined by the W3C Patent Policy. The W3C Team will notify me of any Call for Exclusion in the Corresponding Working Group as set forth in Section 4.5 of the W3C Patent Policy.
137
+ 7.2.2. No Disclosure Obligation. If I do not join the Corresponding Working Group, I have no patent disclosure obligations outside of those set forth in Section 6 of the W3C Patent Policy.
138
+ 8. Conflict of Interest. I will disclose significant relationships when those relationships might reasonably be perceived as creating a conflict of interest with my role. I will notify W3C of any change in my affiliation using W3C-provided mechanisms.
139
+ 9. Representations, Warranties and Disclaimers. I represent and warrant that I am legally entitled to grant the rights and promises set forth in this Agreement. IN ALL OTHER RESPECTS THE SPECIFICATION IS PROVIDED “AS IS.” The entire risk as to implementing or otherwise using the Specification is assumed by the implementer and user. Except as stated herein, I expressly disclaim any warranties (express, implied, or otherwise), including implied warranties of merchantability, non-infringement, fitness for a particular purpose, or title, related to the Specification. IN NO EVENT WILL ANY PARTY BE LIABLE TO ANY OTHER PARTY FOR LOST PROFITS OR ANY FORM OF INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER FROM ANY CAUSES OF ACTION OF ANY KIND WITH RESPECT TO THIS AGREEMENT, WHETHER BASED ON BREACH OF CONTRACT, TORT (INCLUDING NEGLIGENCE), OR OTHERWISE, AND WHETHER OR NOT THE OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. All of my obligations under Section 3 regarding the transfer, successors in interest, or assignment of Granted Claims will be satisfied if I notify the transferee or assignee of any patent that I know contains Granted Claims of the obligations under Section 3. Nothing in this Agreement requires me to undertake a patent search.
140
+ 10. Definitions.
141
+ 10.1. Agreement. “Agreement” means this W3C Community Final Specification Agreement.
142
+ 10.2. Corresponding Working Group. “Corresponding Working Group” is a W3C Working Group that is chartered to develop a Recommendation, as defined in the W3C Process Document, that takes the Specification as an input.
143
+ 10.3. Essential Claims. “Essential Claims” shall mean all claims in any patent or patent application in any jurisdiction in the world that would necessarily be infringed by implementation of the Specification. A claim is necessarily infringed hereunder only when it is not possible to avoid infringing it because there is no non-infringing alternative for implementing the normative portions of the Specification. Existence of a non-infringing alternative shall be judged based on the state of the art at the time of the publication of the Specification. The following are expressly excluded from and shall not be deemed to constitute Essential Claims:
144
+ 10.3.1. any claims other than as set forth above even if contained in the same patent as Essential Claims; and
145
+ 10.3.2. claims which would be infringed only by:
146
+ portions of an implementation that are not specified in the normative portions of the Specification, or
147
+ enabling technologies that may be necessary to make or use any product or portion thereof that complies with the Specification and are not themselves expressly set forth in the Specification (e.g., semiconductor manufacturing technology, compiler technology, object-oriented technology, basic operating system technology, and the like); or
148
+ the implementation of technology developed elsewhere and merely incorporated by reference in the body of the Specification.
149
+ 10.3.3. design patents and design registrations.
150
+ For purposes of this definition, the normative portions of the Specification shall be deemed to include only architectural and interoperability requirements. Optional features in the RFC 2119 sense are considered normative unless they are specifically identified as informative. Implementation examples or any other material that merely illustrate the requirements of the Specification are informative, rather than normative.
151
+ 10.4. I, Me, or My. “I,” “me,” or “my” refers to the signatory.
152
+ 10.5 Project. “Project” means the W3C Community Group or Business Group for which I executed this Agreement.
153
+ 10.6. Specification. “Specification” means the Specification identified by the Project as the target of this agreement in a call for Final Specification Commitments. W3C shall provide the authoritative mechanisms for the identification of this Specification.
154
+ 10.7. W3C Community RF Licensing Requirements. “W3C Community RF Licensing Requirements” license shall mean a non-assignable, non-sublicensable license to make, have made, use, sell, have sold, offer to sell, import, and distribute and dispose of implementations of the Specification that:
155
+ 10.7.1. shall be available to all, worldwide, whether or not they are W3C Members;
156
+ 10.7.2. shall extend to all Essential Claims owned or controlled by me;
157
+ 10.7.3. may be limited to implementations of the Specification, and to what is required by the Specification;
158
+ 10.7.4. may be conditioned on a grant of a reciprocal RF license (as defined in this policy) to all Essential Claims owned or controlled by the licensee. A reciprocal license may be required to be available to all, and a reciprocal license may itself be conditioned on a further reciprocal license from all.
159
+ 10.7.5. may not be conditioned on payment of royalties, fees or other consideration;
160
+ 10.7.6. may be suspended with respect to any licensee when licensor issued by licensee for infringement of claims essential to implement the Specification or any W3C Recommendation;
161
+ 10.7.7. may not impose any further conditions or restrictions on the use of any technology, intellectual property rights, or other restrictions on behavior of the licensee, but may include reasonable, customary terms relating to operation or maintenance of the license relationship such as the following: choice of law and dispute resolution;
162
+ 10.7.8. shall not be considered accepted by an implementer who manifests an intent not to accept the terms of the W3C Community RF Licensing Requirements license as offered by the licensor.
163
+ 10.7.9. The RF license conforming to the requirements in this policy shall be made available by the licensor as long as the Specification is in effect. The term of such license shall be for the life of the patents in question.
164
+ I am encouraged to provide a contact from which licensing information can be obtained and other relevant licensing information. Any such information will be made publicly available.
165
+ 10.8. You or Your. “You,” “you,” or “your” means any person or entity who exercises copyright or patent rights granted under this Agreement, and any person that person or entity controls.
166
+
167
+ -------------------------------------------------------------------------------------
168
+
169
+ ------------------- WebGL -----------------------------
170
+ Copyright (c) 2018 The Khronos Group Inc.
171
+
172
+ Permission is hereby granted, free of charge, to any person obtaining a
173
+ copy of this software and/or associated documentation files (the
174
+ "Materials"), to deal in the Materials without restriction, including
175
+ without limitation the rights to use, copy, modify, merge, publish,
176
+ distribute, sublicense, and/or sell copies of the Materials, and to
177
+ permit persons to whom the Materials are furnished to do so, subject to
178
+ the following conditions:
179
+
180
+ The above copyright notice and this permission notice shall be included
181
+ in all copies or substantial portions of the Materials.
182
+
183
+ THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
184
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
185
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
186
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
187
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
188
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
189
+ MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
190
+ ------------------------------------------------------
191
+
192
+ ------------- End of ThirdPartyNotices ------------------------------------------- */
193
+
worker/node_modules/ufo/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
worker/node_modules/ufo/README.md ADDED
@@ -0,0 +1,582 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ufo
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+ [![Codecov][codecov-src]][codecov-href]
7
+
8
+ URL utils for humans.
9
+
10
+ ## Install
11
+
12
+ Install using npm or your favourite package manager:
13
+
14
+ Install package:
15
+
16
+ ```sh
17
+ # npm
18
+ npm install ufo
19
+
20
+ # yarn
21
+ yarn add ufo
22
+
23
+ # pnpm
24
+ pnpm install ufo
25
+
26
+ # bun
27
+ bun install ufo
28
+ ```
29
+
30
+ Import utils:
31
+
32
+ ```js
33
+ // ESM
34
+ import { normalizeURL, joinURL } from "ufo";
35
+
36
+ // CommonJS
37
+ const { normalizeURL, joinURL } = require("ufo");
38
+
39
+ // Deno
40
+ import { parseURL } from "https://unpkg.com/ufo/dist/index.mjs";
41
+ ```
42
+
43
+ <!-- automd:jsdocs src=./src defaultGroup=utils -->
44
+
45
+ ## Encoding Utils
46
+
47
+ ### `decode(text)`
48
+
49
+ Decodes text using `decodeURIComponent`. Returns the original text if it fails.
50
+
51
+ ### `decodePath(text)`
52
+
53
+ Decodes path section of URL (consistent with encodePath for slash encoding).
54
+
55
+ ### `decodeQueryKey(text)`
56
+
57
+ Decodes query key (consistent with `encodeQueryKey` for plus encoding).
58
+
59
+ ### `decodeQueryValue(text)`
60
+
61
+ Decodes query value (consistent with `encodeQueryValue` for plus encoding).
62
+
63
+ ### `encode(text)`
64
+
65
+ Encodes characters that need to be encoded in the path, search and hash sections of the URL.
66
+
67
+ ### `encodeHash(text)`
68
+
69
+ Encodes characters that need to be encoded in the hash section of the URL.
70
+
71
+ ### `encodeHost(name)`
72
+
73
+ Encodes hostname with punycode encoding.
74
+
75
+ ### `encodeParam(text)`
76
+
77
+ Encodes characters that need to be encoded in the path section of the URL as a param. This function encodes everything `encodePath` does plus the slash (`/`) character.
78
+
79
+ ### `encodePath(text)`
80
+
81
+ Encodes characters that need to be encoded in the path section of the URL.
82
+
83
+ ### `encodeQueryKey(text)`
84
+
85
+ Encodes characters that need to be encoded for query values in the query section of the URL and also encodes the `=` character.
86
+
87
+ ### `encodeQueryValue(input)`
88
+
89
+ Encodes characters that need to be encoded for query values in the query section of the URL.
90
+
91
+ ## Parsing Utils
92
+
93
+ ### `parseAuth(input)`
94
+
95
+ Takes a string of the form `username:password` and returns an object with the username and password decoded.
96
+
97
+ ### `parseFilename(input, opts?: { strict? })`
98
+
99
+ Parses a URL and returns last segment in path as filename.
100
+
101
+ If `{ strict: true }` is passed as the second argument, it will only return the last segment only if ending with an extension.
102
+
103
+ **Example:**
104
+
105
+ ```js
106
+ // Result: filename.ext
107
+ parseFilename("http://example.com/path/to/filename.ext");
108
+
109
+ // Result: undefined
110
+ parseFilename("/path/to/.hidden-file", { strict: true });
111
+ ```
112
+
113
+ ### `parseHost(input)`
114
+
115
+ Takes a string, and returns an object with two properties: `hostname` and `port`.
116
+
117
+ **Example:**
118
+
119
+ ```js
120
+ parseHost("foo.com:8080");
121
+ // { hostname: 'foo.com', port: '8080' }
122
+ ```
123
+
124
+ ### `parsePath(input)`
125
+
126
+ Splits the input string into three parts, and returns an object with those three parts.
127
+
128
+ **Example:**
129
+
130
+ ```js
131
+ parsePath("http://foo.com/foo?test=123#token");
132
+ // { pathname: 'http://foo.com/foo', search: '?test=123', hash: '#token' }
133
+ ```
134
+
135
+ ### `parseURL(input, defaultProto?)`
136
+
137
+ Takes a URL string and returns an object with the URL's `protocol`, `auth`, `host`, `pathname`, `search`, and `hash`.
138
+
139
+ **Example:**
140
+
141
+ ```js
142
+ parseURL("http://foo.com/foo?test=123#token");
143
+ // { protocol: 'http:', auth: '', host: 'foo.com', pathname: '/foo', search: '?test=123', hash: '#token' }
144
+
145
+ parseURL("foo.com/foo?test=123#token");
146
+ // { pathname: 'foo.com/foo', search: '?test=123', hash: '#token' }
147
+
148
+ parseURL("foo.com/foo?test=123#token", "https://");
149
+ // { protocol: 'https:', auth: '', host: 'foo.com', pathname: '/foo', search: '?test=123', hash: '#token' }
150
+ ```
151
+
152
+ ### `stringifyParsedURL(parsed)`
153
+
154
+ Takes a `ParsedURL` object and returns the stringified URL.
155
+
156
+ **Example:**
157
+
158
+ ```js
159
+ const obj = parseURL("http://foo.com/foo?test=123#token");
160
+ obj.host = "bar.com";
161
+
162
+ stringifyParsedURL(obj); // "http://bar.com/foo?test=123#token"
163
+ ```
164
+
165
+ ## Query Utils
166
+
167
+ ### `encodeQueryItem(key, value)`
168
+
169
+ Encodes a pair of key and value into a url query string value.
170
+
171
+ If the value is an array, it will be encoded as multiple key-value pairs with the same key.
172
+
173
+ **Example:**
174
+
175
+ ```js
176
+ encodeQueryItem('message', 'Hello World')
177
+ // 'message=Hello+World'
178
+
179
+ encodeQueryItem('tags', ['javascript', 'web', 'dev'])
180
+ // 'tags=javascript&tags=web&tags=dev'
181
+ ```
182
+
183
+ ### `parseQuery(parametersString)`
184
+
185
+ Parses and decodes a query string into an object.
186
+
187
+ The input can be a query string with or without the leading `?`.
188
+
189
+ **Example:**
190
+
191
+ ```js
192
+ parseQuery("?foo=bar&baz=qux");
193
+ // { foo: "bar", baz: "qux" }
194
+
195
+ parseQuery("tags=javascript&tags=web&tags=dev");
196
+ // { tags: ["javascript", "web", "dev"] }
197
+ ```
198
+
199
+ ### `stringifyQuery(query)`
200
+
201
+ Stringfies and encodes a query object into a query string.
202
+
203
+ **Example:**
204
+
205
+ ```js
206
+ stringifyQuery({ foo: 'bar', baz: 'qux' })
207
+ // 'foo=bar&baz=qux'
208
+
209
+ stringifyQuery({ foo: 'bar', baz: undefined })
210
+ // 'foo=bar'
211
+ ```
212
+
213
+ ## Utils
214
+
215
+ ### `$URL()`
216
+
217
+ ### `cleanDoubleSlashes(input)`
218
+
219
+ Removes double slashes from the URL.
220
+
221
+ **Example:**
222
+
223
+ ```js
224
+ cleanDoubleSlashes("//foo//bar//"); // "/foo/bar/"
225
+
226
+ cleanDoubleSlashes("http://example.com/analyze//http://localhost:3000//");
227
+ // Returns "http://example.com/analyze/http://localhost:3000/"
228
+ ```
229
+
230
+ ### `filterQuery(input, predicate)`
231
+
232
+ Removes the query section of the URL.
233
+
234
+ **Example:**
235
+
236
+ ```js
237
+ filterQuery("/foo?bar=1&baz=2", (key) => key !== "bar"); // "/foo?baz=2"
238
+ ```
239
+
240
+ ### `getQuery(input)`
241
+
242
+ Parses and decodes the query object of an input URL into an object.
243
+
244
+ **Example:**
245
+
246
+ ```js
247
+ getQuery("http://foo.com/foo?test=123&unicode=%E5%A5%BD");
248
+ // { test: "123", unicode: "好" }
249
+ ```
250
+
251
+ ### `hasLeadingSlash(input)`
252
+
253
+ Checks if the input has a leading slash (e.g. `/foo`).
254
+
255
+ ### `hasProtocol(inputString, opts)`
256
+
257
+ Checks if the input has a protocol.
258
+
259
+ You can use `{ acceptRelative: true }` to accept relative URLs as valid protocol.
260
+
261
+ **Example:**
262
+
263
+ ```js
264
+ hasProtocol('https://example.com'); // true
265
+
266
+ hasProtocol("//example.com"); // false
267
+
268
+ hasProtocol('//example.com', { acceptRelative: true }); // true
269
+
270
+ hasProtocol("ftp://example.com"); // true
271
+
272
+ hasProtocol('data:text/plain'); // true
273
+
274
+ hasProtocol('data:text/plain', { strict: true }); // false
275
+ ```
276
+
277
+ ### `hasTrailingSlash(input, respectQueryAndFragment?)`
278
+
279
+ Checks if the input has a trailing slash.
280
+
281
+ **Example:**
282
+
283
+ ```js
284
+ hasTrailingSlash("/foo/"); // true
285
+
286
+ hasTrailingSlash("/foo"); // false
287
+
288
+ hasTrailingSlash("/foo?query=true", true); // false
289
+
290
+ hasTrailingSlash("/foo/?query=true", true); // true
291
+ ```
292
+
293
+ ### `isEmptyURL(url)`
294
+
295
+ Checks if the input URL is empty or `/`.
296
+
297
+ ### `isEqual(a, b, options)`
298
+
299
+ Checks if two paths are equal regardless of encoding, trailing slash, and leading slash differences.
300
+
301
+ You can make slash check strict by setting `{ trailingSlash: true, leadingSlash: true }` as options.
302
+
303
+ You can make encoding check strict by setting `{ encoding: true }` as options.
304
+
305
+ **Example:**
306
+
307
+ ```js
308
+ isEqual("/foo", "foo"); // true
309
+ isEqual("foo/", "foo"); // true
310
+ isEqual("/foo bar", "/foo%20bar"); // true
311
+
312
+ // Strict compare
313
+ isEqual("/foo", "foo", { leadingSlash: true }); // false
314
+ isEqual("foo/", "foo", { trailingSlash: true }); // false
315
+ isEqual("/foo bar", "/foo%20bar", { encoding: true }); // false
316
+ ```
317
+
318
+ ### `isNonEmptyURL(url)`
319
+
320
+ Checks if the input URL is neither empty nor `/`.
321
+
322
+ ### `isRelative(inputString)`
323
+
324
+ Check if a path starts with `./` or `../`.
325
+
326
+ **Example:**
327
+
328
+ ```js
329
+ isRelative("./foo"); // true
330
+ ```
331
+
332
+ ### `isSamePath(p1, p2)`
333
+
334
+ Check if two paths are equal or not. Trailing slash and encoding are normalized before comparison.
335
+
336
+ **Example:**
337
+
338
+ ```js
339
+ isSamePath("/foo", "/foo/"); // true
340
+ ```
341
+
342
+ ### `isScriptProtocol(protocol?)`
343
+
344
+ Checks if the input protocol is any of the dangerous `blob:`, `data:`, `javascript`: or `vbscript:` protocols.
345
+
346
+ **Example:**
347
+
348
+ ```js
349
+ isScriptProtocol("javascript:alert(1)"); // true
350
+
351
+ isScriptProtocol("data:text/html,hello"); // true
352
+
353
+ isScriptProtocol("blob:hello"); // true
354
+
355
+ isScriptProtocol("vbscript:alert(1)"); // true
356
+
357
+ isScriptProtocol("https://example.com"); // false
358
+ ```
359
+
360
+ ### `joinRelativeURL()`
361
+
362
+ Joins multiple URL segments into a single URL and also handles relative paths with `./` and `../`.
363
+
364
+ **Example:**
365
+
366
+ ```js
367
+ joinRelativeURL("/a", "../b", "./c"); // "/b/c"
368
+ ```
369
+
370
+ ### `joinURL(base)`
371
+
372
+ Joins multiple URL segments into a single URL.
373
+
374
+ **Example:**
375
+
376
+ ```js
377
+ joinURL("a", "/b", "/c"); // "a/b/c"
378
+ ```
379
+
380
+ ### `normalizeURL(input)`
381
+
382
+ Normalizes the input URL:
383
+
384
+ - Ensures the URL is properly encoded - Ensures pathname starts with a slash - Preserves protocol/host if provided
385
+
386
+ **Example:**
387
+
388
+ ```js
389
+ normalizeURL("test?query=123 123#hash, test");
390
+ // Returns "test?query=123%20123#hash,%20test"
391
+
392
+ normalizeURL("http://localhost:3000");
393
+ // Returns "http://localhost:3000"
394
+ ```
395
+
396
+ ### `resolveURL(base)`
397
+
398
+ Resolves multiple URL segments into a single URL.
399
+
400
+ **Example:**
401
+
402
+ ```js
403
+ resolveURL("http://foo.com/foo?test=123#token", "bar", "baz");
404
+ // Returns "http://foo.com/foo/bar/baz?test=123#token"
405
+ ```
406
+
407
+ ### `withBase(input, base)`
408
+
409
+ Ensures the URL or pathname starts with base.
410
+
411
+ If input already starts with base, it will not be added again.
412
+
413
+ **Example:**
414
+
415
+ ```js
416
+ withBase("/foo/bar", "/foo"); // "/foo/bar"
417
+
418
+ withBase("/foo/bar", "/baz"); // "/baz/foo/bar"
419
+ ```
420
+
421
+ ### `withFragment(input, hash)`
422
+
423
+ Adds or replaces the fragment section of the URL.
424
+
425
+ **Example:**
426
+
427
+ ```js
428
+ withFragment("/foo", "bar"); // "/foo#bar"
429
+ withFragment("/foo#bar", "baz"); // "/foo#baz"
430
+ withFragment("/foo#bar", ""); // "/foo"
431
+ ```
432
+
433
+ ### `withHttp(input)`
434
+
435
+ Adds or replaces the URL protocol to `http://`.
436
+
437
+ **Example:**
438
+
439
+ ```js
440
+ withHttp("https://example.com"); // http://example.com
441
+ ```
442
+
443
+ ### `withHttps(input)`
444
+
445
+ Adds or replaces the URL protocol to `https://`.
446
+
447
+ **Example:**
448
+
449
+ ```js
450
+ withHttps("http://example.com"); // https://example.com
451
+ ```
452
+
453
+ ### `withLeadingSlash(input)`
454
+
455
+ Ensures the URL or pathname has a leading slash.
456
+
457
+ **Example:**
458
+
459
+ ```js
460
+ withLeadingSlash("foo"); // "/foo"
461
+ ```
462
+
463
+ ### `withoutBase(input, base)`
464
+
465
+ Removes the base from the URL or pathname.
466
+
467
+ If input does not start with base, it will not be removed.
468
+
469
+ **Example:**
470
+
471
+ ```js
472
+ withoutBase("/foo/bar", "/foo"); // "/bar"
473
+ ```
474
+
475
+ ### `withoutFragment(input)`
476
+
477
+ Removes the fragment section from the URL.
478
+
479
+ **Example:**
480
+
481
+ ```js
482
+ withoutFragment("http://example.com/foo?q=123#bar")
483
+ // Returns "http://example.com/foo?q=123"
484
+ ```
485
+
486
+ ### `withoutHost(input)`
487
+
488
+ Removes the host from the URL while preserving everything else.
489
+
490
+ **Example:**
491
+
492
+ ```js
493
+ withoutHost("http://example.com/foo?q=123#bar")
494
+ // Returns "/foo?q=123#bar"
495
+ ```
496
+
497
+ ### `withoutLeadingSlash(input)`
498
+
499
+ Removes leading slash from the URL or pathname.
500
+
501
+ **Example:**
502
+
503
+ ```js
504
+ withoutLeadingSlash("/foo"); // "foo"
505
+ ```
506
+
507
+ ### `withoutProtocol(input)`
508
+
509
+ Removes the protocol from the input.
510
+
511
+ **Example:**
512
+
513
+ ```js
514
+ withoutProtocol("http://example.com"); // "example.com"
515
+ ```
516
+
517
+ ### `withoutTrailingSlash(input, respectQueryAndFragment?)`
518
+
519
+ Removes the trailing slash from the URL or pathname.
520
+
521
+ If second argument is `true`, it will only remove the trailing slash if it's not part of the query or fragment with cost of more expensive operations.
522
+
523
+ **Example:**
524
+
525
+ ```js
526
+ withoutTrailingSlash("/foo/"); // "/foo"
527
+
528
+ withoutTrailingSlash("/path/?query=true", true); // "/path?query=true"
529
+ ```
530
+
531
+ ### `withProtocol(input, protocol)`
532
+
533
+ Adds or replaces protocol of the input URL.
534
+
535
+ **Example:**
536
+
537
+ ```js
538
+ withProtocol("http://example.com", "ftp://"); // "ftp://example.com"
539
+ ```
540
+
541
+ ### `withQuery(input, query)`
542
+
543
+ Add/Replace the query section of the URL.
544
+
545
+ **Example:**
546
+
547
+ ```js
548
+ withQuery("/foo?page=a", { token: "secret" }); // "/foo?page=a&token=secret"
549
+ ```
550
+
551
+ ### `withTrailingSlash(input, respectQueryAndFragment?)`
552
+
553
+ Ensures the URL ends with a trailing slash.
554
+
555
+ If second argument is `true`, it will only add the trailing slash if it's not part of the query or fragment with cost of more expensive operation.
556
+
557
+ **Example:**
558
+
559
+ ```js
560
+ withTrailingSlash("/foo"); // "/foo/"
561
+
562
+ withTrailingSlash("/path?query=true", true); // "/path/?query=true"
563
+ ```
564
+
565
+ <!-- /automd -->
566
+
567
+ ## License
568
+
569
+ [MIT](./LICENSE)
570
+
571
+ Special thanks to Eduardo San Martin Morote ([posva](https://github.com/posva)) for [encoding utilities](https://github.com/vuejs/vue-router-next/blob/v4.0.1/src/encoding.ts)
572
+
573
+ <!-- Badges -->
574
+
575
+ [npm-version-src]: https://img.shields.io/npm/v/ufo?style=flat&colorA=18181B&colorB=F0DB4F
576
+ [npm-version-href]: https://npmjs.com/package/ufo
577
+ [npm-downloads-src]: https://img.shields.io/npm/dm/ufo?style=flat&colorA=18181B&colorB=F0DB4F
578
+ [npm-downloads-href]: https://npmjs.com/package/ufo
579
+ [codecov-src]: https://img.shields.io/codecov/c/gh/unjs/ufo/main?style=flat&colorA=18181B&colorB=F0DB4F
580
+ [codecov-href]: https://codecov.io/gh/unjs/ufo
581
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/ufo?style=flat&colorA=18181B&colorB=F0DB4F
582
+ [bundle-href]: https://bundlephobia.com/result?p=ufo
worker/node_modules/ufo/package.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ufo",
3
+ "version": "1.6.3",
4
+ "description": "URL utils for humans",
5
+ "repository": "unjs/ufo",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.cjs",
13
+ "default": "./dist/index.mjs"
14
+ },
15
+ "./*": "./*"
16
+ },
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.mjs",
19
+ "types": "./dist/index.d.ts",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "automd && unbuild",
25
+ "automd": "automd",
26
+ "dev": "vitest",
27
+ "lint": "eslint . && prettier -c src test",
28
+ "lint:fix": "eslint --fix . && prettier -w src test",
29
+ "prepack": "pnpm build",
30
+ "release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
31
+ "test": "pnpm lint && vitest run --typecheck"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^25.0.8",
35
+ "@vitest/coverage-v8": "^4.0.17",
36
+ "automd": "^0.4.2",
37
+ "changelogen": "^0.6.2",
38
+ "eslint": "^9.39.2",
39
+ "eslint-config-unjs": "^0.6.2",
40
+ "jiti": "^2.6.1",
41
+ "prettier": "^3.7.4",
42
+ "typescript": "^5.9.3",
43
+ "unbuild": "^3.6.1",
44
+ "untyped": "^2.0.0",
45
+ "vitest": "^4.0.17"
46
+ },
47
+ "packageManager": "pnpm@10.28.0"
48
+ }
worker/node_modules/undici/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Matteo Collina and Undici contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
worker/node_modules/undici/README.md ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # undici
2
+
3
+ [![Node CI](https://github.com/nodejs/undici/actions/workflows/nodejs.yml/badge.svg)](https://github.com/nodejs/undici/actions/workflows/nodejs.yml) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![npm version](https://badge.fury.io/js/undici.svg)](https://badge.fury.io/js/undici) [![codecov](https://codecov.io/gh/nodejs/undici/branch/main/graph/badge.svg?token=yZL6LtXkOA)](https://codecov.io/gh/nodejs/undici)
4
+
5
+ An HTTP/1.1 client, written from scratch for Node.js.
6
+
7
+ > Undici means eleven in Italian. 1.1 -> 11 -> Eleven -> Undici.
8
+ It is also a Stranger Things reference.
9
+
10
+ Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
11
+
12
+ ## Install
13
+
14
+ ```
15
+ npm i undici
16
+ ```
17
+
18
+ ## Benchmarks
19
+
20
+ The benchmark is a simple `hello world` [example](benchmarks/benchmark.js) using a
21
+ number of unix sockets (connections) with a pipelining depth of 10 running on Node 20.6.0.
22
+
23
+ ### Connections 1
24
+
25
+
26
+ | Tests | Samples | Result | Tolerance | Difference with slowest |
27
+ |---------------------|---------|---------------|-----------|-------------------------|
28
+ | http - no keepalive | 15 | 5.32 req/sec | ± 2.61 % | - |
29
+ | http - keepalive | 10 | 5.35 req/sec | ± 2.47 % | + 0.44 % |
30
+ | undici - fetch | 15 | 41.85 req/sec | ± 2.49 % | + 686.04 % |
31
+ | undici - pipeline | 40 | 50.36 req/sec | ± 2.77 % | + 845.92 % |
32
+ | undici - stream | 15 | 60.58 req/sec | ± 2.75 % | + 1037.72 % |
33
+ | undici - request | 10 | 61.19 req/sec | ± 2.60 % | + 1049.24 % |
34
+ | undici - dispatch | 20 | 64.84 req/sec | ± 2.81 % | + 1117.81 % |
35
+
36
+
37
+ ### Connections 50
38
+
39
+ | Tests | Samples | Result | Tolerance | Difference with slowest |
40
+ |---------------------|---------|------------------|-----------|-------------------------|
41
+ | undici - fetch | 30 | 2107.19 req/sec | ± 2.69 % | - |
42
+ | http - no keepalive | 10 | 2698.90 req/sec | ± 2.68 % | + 28.08 % |
43
+ | http - keepalive | 10 | 4639.49 req/sec | ± 2.55 % | + 120.17 % |
44
+ | undici - pipeline | 40 | 6123.33 req/sec | ± 2.97 % | + 190.59 % |
45
+ | undici - stream | 50 | 9426.51 req/sec | ± 2.92 % | + 347.35 % |
46
+ | undici - request | 10 | 10162.88 req/sec | ± 2.13 % | + 382.29 % |
47
+ | undici - dispatch | 50 | 11191.11 req/sec | ± 2.98 % | + 431.09 % |
48
+
49
+
50
+ ## Quick Start
51
+
52
+ ```js
53
+ import { request } from 'undici'
54
+
55
+ const {
56
+ statusCode,
57
+ headers,
58
+ trailers,
59
+ body
60
+ } = await request('http://localhost:3000/foo')
61
+
62
+ console.log('response received', statusCode)
63
+ console.log('headers', headers)
64
+
65
+ for await (const data of body) {
66
+ console.log('data', data)
67
+ }
68
+
69
+ console.log('trailers', trailers)
70
+ ```
71
+
72
+ ## Body Mixins
73
+
74
+ The `body` mixins are the most common way to format the request/response body. Mixins include:
75
+
76
+ - [`.formData()`](https://fetch.spec.whatwg.org/#dom-body-formdata)
77
+ - [`.json()`](https://fetch.spec.whatwg.org/#dom-body-json)
78
+ - [`.text()`](https://fetch.spec.whatwg.org/#dom-body-text)
79
+
80
+ Example usage:
81
+
82
+ ```js
83
+ import { request } from 'undici'
84
+
85
+ const {
86
+ statusCode,
87
+ headers,
88
+ trailers,
89
+ body
90
+ } = await request('http://localhost:3000/foo')
91
+
92
+ console.log('response received', statusCode)
93
+ console.log('headers', headers)
94
+ console.log('data', await body.json())
95
+ console.log('trailers', trailers)
96
+ ```
97
+
98
+ _Note: Once a mixin has been called then the body cannot be reused, thus calling additional mixins on `.body`, e.g. `.body.json(); .body.text()` will result in an error `TypeError: unusable` being thrown and returned through the `Promise` rejection._
99
+
100
+ Should you need to access the `body` in plain-text after using a mixin, the best practice is to use the `.text()` mixin first and then manually parse the text to the desired format.
101
+
102
+ For more information about their behavior, please reference the body mixin from the [Fetch Standard](https://fetch.spec.whatwg.org/#body-mixin).
103
+
104
+ ## Common API Methods
105
+
106
+ This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [docs](./docs/) folder and are accessible via the navigation list on the left side of the docs site.
107
+
108
+ ### `undici.request([url, options]): Promise`
109
+
110
+ Arguments:
111
+
112
+ * **url** `string | URL | UrlObject`
113
+ * **options** [`RequestOptions`](./docs/api/Dispatcher.md#parameter-requestoptions)
114
+ * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
115
+ * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
116
+ * **maxRedirections** `Integer` - Default: `0`
117
+
118
+ Returns a promise with the result of the `Dispatcher.request` method.
119
+
120
+ Calls `options.dispatcher.request(options)`.
121
+
122
+ See [Dispatcher.request](./docs/api/Dispatcher.md#dispatcherrequestoptions-callback) for more details.
123
+
124
+ ### `undici.stream([url, options, ]factory): Promise`
125
+
126
+ Arguments:
127
+
128
+ * **url** `string | URL | UrlObject`
129
+ * **options** [`StreamOptions`](./docs/api/Dispatcher.md#parameter-streamoptions)
130
+ * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
131
+ * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
132
+ * **maxRedirections** `Integer` - Default: `0`
133
+ * **factory** `Dispatcher.stream.factory`
134
+
135
+ Returns a promise with the result of the `Dispatcher.stream` method.
136
+
137
+ Calls `options.dispatcher.stream(options, factory)`.
138
+
139
+ See [Dispatcher.stream](docs/api/Dispatcher.md#dispatcherstreamoptions-factory-callback) for more details.
140
+
141
+ ### `undici.pipeline([url, options, ]handler): Duplex`
142
+
143
+ Arguments:
144
+
145
+ * **url** `string | URL | UrlObject`
146
+ * **options** [`PipelineOptions`](docs/api/Dispatcher.md#parameter-pipelineoptions)
147
+ * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
148
+ * **method** `String` - Default: `PUT` if `options.body`, otherwise `GET`
149
+ * **maxRedirections** `Integer` - Default: `0`
150
+ * **handler** `Dispatcher.pipeline.handler`
151
+
152
+ Returns: `stream.Duplex`
153
+
154
+ Calls `options.dispatch.pipeline(options, handler)`.
155
+
156
+ See [Dispatcher.pipeline](docs/api/Dispatcher.md#dispatcherpipelineoptions-handler) for more details.
157
+
158
+ ### `undici.connect([url, options]): Promise`
159
+
160
+ Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
161
+
162
+ Arguments:
163
+
164
+ * **url** `string | URL | UrlObject`
165
+ * **options** [`ConnectOptions`](docs/api/Dispatcher.md#parameter-connectoptions)
166
+ * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
167
+ * **maxRedirections** `Integer` - Default: `0`
168
+ * **callback** `(err: Error | null, data: ConnectData | null) => void` (optional)
169
+
170
+ Returns a promise with the result of the `Dispatcher.connect` method.
171
+
172
+ Calls `options.dispatch.connect(options)`.
173
+
174
+ See [Dispatcher.connect](docs/api/Dispatcher.md#dispatcherconnectoptions-callback) for more details.
175
+
176
+ ### `undici.fetch(input[, init]): Promise`
177
+
178
+ Implements [fetch](https://fetch.spec.whatwg.org/#fetch-method).
179
+
180
+ * https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
181
+ * https://fetch.spec.whatwg.org/#fetch-method
182
+
183
+ Only supported on Node 16.8+.
184
+
185
+ Basic usage example:
186
+
187
+ ```js
188
+ import { fetch } from 'undici'
189
+
190
+
191
+ const res = await fetch('https://example.com')
192
+ const json = await res.json()
193
+ console.log(json)
194
+ ```
195
+
196
+ You can pass an optional dispatcher to `fetch` as:
197
+
198
+ ```js
199
+ import { fetch, Agent } from 'undici'
200
+
201
+ const res = await fetch('https://example.com', {
202
+ // Mocks are also supported
203
+ dispatcher: new Agent({
204
+ keepAliveTimeout: 10,
205
+ keepAliveMaxTimeout: 10
206
+ })
207
+ })
208
+ const json = await res.json()
209
+ console.log(json)
210
+ ```
211
+
212
+ #### `request.body`
213
+
214
+ A body can be of the following types:
215
+
216
+ - ArrayBuffer
217
+ - ArrayBufferView
218
+ - AsyncIterables
219
+ - Blob
220
+ - Iterables
221
+ - String
222
+ - URLSearchParams
223
+ - FormData
224
+
225
+ In this implementation of fetch, ```request.body``` now accepts ```Async Iterables```. It is not present in the [Fetch Standard.](https://fetch.spec.whatwg.org)
226
+
227
+ ```js
228
+ import { fetch } from 'undici'
229
+
230
+ const data = {
231
+ async *[Symbol.asyncIterator]() {
232
+ yield 'hello'
233
+ yield 'world'
234
+ },
235
+ }
236
+
237
+ await fetch('https://example.com', { body: data, method: 'POST', duplex: 'half' })
238
+ ```
239
+
240
+ #### `request.duplex`
241
+
242
+ - half
243
+
244
+ In this implementation of fetch, `request.duplex` must be set if `request.body` is `ReadableStream` or `Async Iterables`. And fetch requests are currently always be full duplex. More detail refer to [Fetch Standard.](https://fetch.spec.whatwg.org/#dom-requestinit-duplex)
245
+
246
+ #### `response.body`
247
+
248
+ Nodejs has two kinds of streams: [web streams](https://nodejs.org/dist/latest-v16.x/docs/api/webstreams.html), which follow the API of the WHATWG web standard found in browsers, and an older Node-specific [streams API](https://nodejs.org/api/stream.html). `response.body` returns a readable web stream. If you would prefer to work with a Node stream you can convert a web stream using `.fromWeb()`.
249
+
250
+ ```js
251
+ import { fetch } from 'undici'
252
+ import { Readable } from 'node:stream'
253
+
254
+ const response = await fetch('https://example.com')
255
+ const readableWebStream = response.body
256
+ const readableNodeStream = Readable.fromWeb(readableWebStream)
257
+ ```
258
+
259
+ #### Specification Compliance
260
+
261
+ This section documents parts of the [Fetch Standard](https://fetch.spec.whatwg.org) that Undici does
262
+ not support or does not fully implement.
263
+
264
+ ##### Garbage Collection
265
+
266
+ * https://fetch.spec.whatwg.org/#garbage-collection
267
+
268
+ The [Fetch Standard](https://fetch.spec.whatwg.org) allows users to skip consuming the response body by relying on
269
+ [garbage collection](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management#garbage_collection) to release connection resources. Undici does not do the same. Therefore, it is important to always either consume or cancel the response body.
270
+
271
+ Garbage collection in Node is less aggressive and deterministic
272
+ (due to the lack of clear idle periods that browsers have through the rendering refresh rate)
273
+ which means that leaving the release of connection resources to the garbage collector can lead
274
+ to excessive connection usage, reduced performance (due to less connection re-use), and even
275
+ stalls or deadlocks when running out of connections.
276
+
277
+ ```js
278
+ // Do
279
+ const headers = await fetch(url)
280
+ .then(async res => {
281
+ for await (const chunk of res.body) {
282
+ // force consumption of body
283
+ }
284
+ return res.headers
285
+ })
286
+
287
+ // Do not
288
+ const headers = await fetch(url)
289
+ .then(res => res.headers)
290
+ ```
291
+
292
+ However, if you want to get only headers, it might be better to use `HEAD` request method. Usage of this method will obviate the need for consumption or cancelling of the response body. See [MDN - HTTP - HTTP request methods - HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) for more details.
293
+
294
+ ```js
295
+ const headers = await fetch(url, { method: 'HEAD' })
296
+ .then(res => res.headers)
297
+ ```
298
+
299
+ ##### Forbidden and Safelisted Header Names
300
+
301
+ * https://fetch.spec.whatwg.org/#cors-safelisted-response-header-name
302
+ * https://fetch.spec.whatwg.org/#forbidden-header-name
303
+ * https://fetch.spec.whatwg.org/#forbidden-response-header-name
304
+ * https://github.com/wintercg/fetch/issues/6
305
+
306
+ The [Fetch Standard](https://fetch.spec.whatwg.org) requires implementations to exclude certain headers from requests and responses. In browser environments, some headers are forbidden so the user agent remains in full control over them. In Undici, these constraints are removed to give more control to the user.
307
+
308
+ ### `undici.upgrade([url, options]): Promise`
309
+
310
+ Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
311
+
312
+ Arguments:
313
+
314
+ * **url** `string | URL | UrlObject`
315
+ * **options** [`UpgradeOptions`](docs/api/Dispatcher.md#parameter-upgradeoptions)
316
+ * **dispatcher** `Dispatcher` - Default: [getGlobalDispatcher](#undicigetglobaldispatcher)
317
+ * **maxRedirections** `Integer` - Default: `0`
318
+ * **callback** `(error: Error | null, data: UpgradeData) => void` (optional)
319
+
320
+ Returns a promise with the result of the `Dispatcher.upgrade` method.
321
+
322
+ Calls `options.dispatcher.upgrade(options)`.
323
+
324
+ See [Dispatcher.upgrade](docs/api/Dispatcher.md#dispatcherupgradeoptions-callback) for more details.
325
+
326
+ ### `undici.setGlobalDispatcher(dispatcher)`
327
+
328
+ * dispatcher `Dispatcher`
329
+
330
+ Sets the global dispatcher used by Common API Methods.
331
+
332
+ ### `undici.getGlobalDispatcher()`
333
+
334
+ Gets the global dispatcher used by Common API Methods.
335
+
336
+ Returns: `Dispatcher`
337
+
338
+ ### `undici.setGlobalOrigin(origin)`
339
+
340
+ * origin `string | URL | undefined`
341
+
342
+ Sets the global origin used in `fetch`.
343
+
344
+ If `undefined` is passed, the global origin will be reset. This will cause `Response.redirect`, `new Request()`, and `fetch` to throw an error when a relative path is passed.
345
+
346
+ ```js
347
+ setGlobalOrigin('http://localhost:3000')
348
+
349
+ const response = await fetch('/api/ping')
350
+
351
+ console.log(response.url) // http://localhost:3000/api/ping
352
+ ```
353
+
354
+ ### `undici.getGlobalOrigin()`
355
+
356
+ Gets the global origin used in `fetch`.
357
+
358
+ Returns: `URL`
359
+
360
+ ### `UrlObject`
361
+
362
+ * **port** `string | number` (optional)
363
+ * **path** `string` (optional)
364
+ * **pathname** `string` (optional)
365
+ * **hostname** `string` (optional)
366
+ * **origin** `string` (optional)
367
+ * **protocol** `string` (optional)
368
+ * **search** `string` (optional)
369
+
370
+ ## Specification Compliance
371
+
372
+ This section documents parts of the HTTP/1.1 specification that Undici does
373
+ not support or does not fully implement.
374
+
375
+ ### Expect
376
+
377
+ Undici does not support the `Expect` request header field. The request
378
+ body is always immediately sent and the `100 Continue` response will be
379
+ ignored.
380
+
381
+ Refs: https://tools.ietf.org/html/rfc7231#section-5.1.1
382
+
383
+ ### Pipelining
384
+
385
+ Undici will only use pipelining if configured with a `pipelining` factor
386
+ greater than `1`.
387
+
388
+ Undici always assumes that connections are persistent and will immediately
389
+ pipeline requests, without checking whether the connection is persistent.
390
+ Hence, automatic fallback to HTTP/1.0 or HTTP/1.1 without pipelining is
391
+ not supported.
392
+
393
+ Undici will immediately pipeline when retrying requests after a failed
394
+ connection. However, Undici will not retry the first remaining requests in
395
+ the prior pipeline and instead error the corresponding callback/promise/stream.
396
+
397
+ Undici will abort all running requests in the pipeline when any of them are
398
+ aborted.
399
+
400
+ * Refs: https://tools.ietf.org/html/rfc2616#section-8.1.2.2
401
+ * Refs: https://tools.ietf.org/html/rfc7230#section-6.3.2
402
+
403
+ ### Manual Redirect
404
+
405
+ Since it is not possible to manually follow an HTTP redirect on the server-side,
406
+ Undici returns the actual response instead of an `opaqueredirect` filtered one
407
+ when invoked with a `manual` redirect. This aligns `fetch()` with the other
408
+ implementations in Deno and Cloudflare Workers.
409
+
410
+ Refs: https://fetch.spec.whatwg.org/#atomic-http-redirect-handling
411
+
412
+ ## Workarounds
413
+
414
+ ### Network address family autoselection.
415
+
416
+ If you experience problem when connecting to a remote server that is resolved by your DNS servers to a IPv6 (AAAA record)
417
+ first, there are chances that your local router or ISP might have problem connecting to IPv6 networks. In that case
418
+ undici will throw an error with code `UND_ERR_CONNECT_TIMEOUT`.
419
+
420
+ If the target server resolves to both a IPv6 and IPv4 (A records) address and you are using a compatible Node version
421
+ (18.3.0 and above), you can fix the problem by providing the `autoSelectFamily` option (support by both `undici.request`
422
+ and `undici.Agent`) which will enable the family autoselection algorithm when establishing the connection.
423
+
424
+ ## Collaborators
425
+
426
+ * [__Daniele Belardi__](https://github.com/dnlup), <https://www.npmjs.com/~dnlup>
427
+ * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
428
+ * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
429
+ * [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
430
+ * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
431
+ * [__Szymon Marczak__](https://github.com/szmarczak), <https://www.npmjs.com/~szmarczak>
432
+ * [__Tomas Della Vedova__](https://github.com/delvedor), <https://www.npmjs.com/~delvedor>
433
+
434
+ ### Releasers
435
+
436
+ * [__Ethan Arrowood__](https://github.com/ethan-arrowood), <https://www.npmjs.com/~ethan_arrowood>
437
+ * [__Matteo Collina__](https://github.com/mcollina), <https://www.npmjs.com/~matteo.collina>
438
+ * [__Robert Nagy__](https://github.com/ronag), <https://www.npmjs.com/~ronag>
439
+ * [__Matthew Aitken__](https://github.com/KhafraDev), <https://www.npmjs.com/~khaf>
440
+
441
+ ## License
442
+
443
+ MIT
worker/node_modules/undici/index-fetch.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const fetchImpl = require('./lib/fetch').fetch
4
+
5
+ module.exports.fetch = function fetch (resource, init = undefined) {
6
+ return fetchImpl(resource, init).catch((err) => {
7
+ Error.captureStackTrace(err, this)
8
+ throw err
9
+ })
10
+ }
11
+ module.exports.FormData = require('./lib/fetch/formdata').FormData
12
+ module.exports.Headers = require('./lib/fetch/headers').Headers
13
+ module.exports.Response = require('./lib/fetch/response').Response
14
+ module.exports.Request = require('./lib/fetch/request').Request
15
+ module.exports.WebSocket = require('./lib/websocket/websocket').WebSocket
worker/node_modules/undici/index.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ export * from './types/index'
2
+ import Undici from './types/index'
3
+ export default Undici
worker/node_modules/undici/index.js ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict'
2
+
3
+ const Client = require('./lib/client')
4
+ const Dispatcher = require('./lib/dispatcher')
5
+ const errors = require('./lib/core/errors')
6
+ const Pool = require('./lib/pool')
7
+ const BalancedPool = require('./lib/balanced-pool')
8
+ const Agent = require('./lib/agent')
9
+ const util = require('./lib/core/util')
10
+ const { InvalidArgumentError } = errors
11
+ const api = require('./lib/api')
12
+ const buildConnector = require('./lib/core/connect')
13
+ const MockClient = require('./lib/mock/mock-client')
14
+ const MockAgent = require('./lib/mock/mock-agent')
15
+ const MockPool = require('./lib/mock/mock-pool')
16
+ const mockErrors = require('./lib/mock/mock-errors')
17
+ const ProxyAgent = require('./lib/proxy-agent')
18
+ const RetryHandler = require('./lib/handler/RetryHandler')
19
+ const { getGlobalDispatcher, setGlobalDispatcher } = require('./lib/global')
20
+ const DecoratorHandler = require('./lib/handler/DecoratorHandler')
21
+ const RedirectHandler = require('./lib/handler/RedirectHandler')
22
+ const createRedirectInterceptor = require('./lib/interceptor/redirectInterceptor')
23
+
24
+ let hasCrypto
25
+ try {
26
+ require('crypto')
27
+ hasCrypto = true
28
+ } catch {
29
+ hasCrypto = false
30
+ }
31
+
32
+ Object.assign(Dispatcher.prototype, api)
33
+
34
+ module.exports.Dispatcher = Dispatcher
35
+ module.exports.Client = Client
36
+ module.exports.Pool = Pool
37
+ module.exports.BalancedPool = BalancedPool
38
+ module.exports.Agent = Agent
39
+ module.exports.ProxyAgent = ProxyAgent
40
+ module.exports.RetryHandler = RetryHandler
41
+
42
+ module.exports.DecoratorHandler = DecoratorHandler
43
+ module.exports.RedirectHandler = RedirectHandler
44
+ module.exports.createRedirectInterceptor = createRedirectInterceptor
45
+
46
+ module.exports.buildConnector = buildConnector
47
+ module.exports.errors = errors
48
+
49
+ function makeDispatcher (fn) {
50
+ return (url, opts, handler) => {
51
+ if (typeof opts === 'function') {
52
+ handler = opts
53
+ opts = null
54
+ }
55
+
56
+ if (!url || (typeof url !== 'string' && typeof url !== 'object' && !(url instanceof URL))) {
57
+ throw new InvalidArgumentError('invalid url')
58
+ }
59
+
60
+ if (opts != null && typeof opts !== 'object') {
61
+ throw new InvalidArgumentError('invalid opts')
62
+ }
63
+
64
+ if (opts && opts.path != null) {
65
+ if (typeof opts.path !== 'string') {
66
+ throw new InvalidArgumentError('invalid opts.path')
67
+ }
68
+
69
+ let path = opts.path
70
+ if (!opts.path.startsWith('/')) {
71
+ path = `/${path}`
72
+ }
73
+
74
+ url = new URL(util.parseOrigin(url).origin + path)
75
+ } else {
76
+ if (!opts) {
77
+ opts = typeof url === 'object' ? url : {}
78
+ }
79
+
80
+ url = util.parseURL(url)
81
+ }
82
+
83
+ const { agent, dispatcher = getGlobalDispatcher() } = opts
84
+
85
+ if (agent) {
86
+ throw new InvalidArgumentError('unsupported opts.agent. Did you mean opts.client?')
87
+ }
88
+
89
+ return fn.call(dispatcher, {
90
+ ...opts,
91
+ origin: url.origin,
92
+ path: url.search ? `${url.pathname}${url.search}` : url.pathname,
93
+ method: opts.method || (opts.body ? 'PUT' : 'GET')
94
+ }, handler)
95
+ }
96
+ }
97
+
98
+ module.exports.setGlobalDispatcher = setGlobalDispatcher
99
+ module.exports.getGlobalDispatcher = getGlobalDispatcher
100
+
101
+ if (util.nodeMajor > 16 || (util.nodeMajor === 16 && util.nodeMinor >= 8)) {
102
+ let fetchImpl = null
103
+ module.exports.fetch = async function fetch (resource) {
104
+ if (!fetchImpl) {
105
+ fetchImpl = require('./lib/fetch').fetch
106
+ }
107
+
108
+ try {
109
+ return await fetchImpl(...arguments)
110
+ } catch (err) {
111
+ if (typeof err === 'object') {
112
+ Error.captureStackTrace(err, this)
113
+ }
114
+
115
+ throw err
116
+ }
117
+ }
118
+ module.exports.Headers = require('./lib/fetch/headers').Headers
119
+ module.exports.Response = require('./lib/fetch/response').Response
120
+ module.exports.Request = require('./lib/fetch/request').Request
121
+ module.exports.FormData = require('./lib/fetch/formdata').FormData
122
+ module.exports.File = require('./lib/fetch/file').File
123
+ module.exports.FileReader = require('./lib/fileapi/filereader').FileReader
124
+
125
+ const { setGlobalOrigin, getGlobalOrigin } = require('./lib/fetch/global')
126
+
127
+ module.exports.setGlobalOrigin = setGlobalOrigin
128
+ module.exports.getGlobalOrigin = getGlobalOrigin
129
+
130
+ const { CacheStorage } = require('./lib/cache/cachestorage')
131
+ const { kConstruct } = require('./lib/cache/symbols')
132
+
133
+ // Cache & CacheStorage are tightly coupled with fetch. Even if it may run
134
+ // in an older version of Node, it doesn't have any use without fetch.
135
+ module.exports.caches = new CacheStorage(kConstruct)
136
+ }
137
+
138
+ if (util.nodeMajor >= 16) {
139
+ const { deleteCookie, getCookies, getSetCookies, setCookie } = require('./lib/cookies')
140
+
141
+ module.exports.deleteCookie = deleteCookie
142
+ module.exports.getCookies = getCookies
143
+ module.exports.getSetCookies = getSetCookies
144
+ module.exports.setCookie = setCookie
145
+
146
+ const { parseMIMEType, serializeAMimeType } = require('./lib/fetch/dataURL')
147
+
148
+ module.exports.parseMIMEType = parseMIMEType
149
+ module.exports.serializeAMimeType = serializeAMimeType
150
+ }
151
+
152
+ if (util.nodeMajor >= 18 && hasCrypto) {
153
+ const { WebSocket } = require('./lib/websocket/websocket')
154
+
155
+ module.exports.WebSocket = WebSocket
156
+ }
157
+
158
+ module.exports.request = makeDispatcher(api.request)
159
+ module.exports.stream = makeDispatcher(api.stream)
160
+ module.exports.pipeline = makeDispatcher(api.pipeline)
161
+ module.exports.connect = makeDispatcher(api.connect)
162
+ module.exports.upgrade = makeDispatcher(api.upgrade)
163
+
164
+ module.exports.MockClient = MockClient
165
+ module.exports.MockPool = MockPool
166
+ module.exports.MockAgent = MockAgent
167
+ module.exports.mockErrors = mockErrors
worker/node_modules/undici/package.json ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "undici",
3
+ "version": "5.29.0",
4
+ "description": "An HTTP/1.1 client, written from scratch for Node.js",
5
+ "homepage": "https://undici.nodejs.org",
6
+ "bugs": {
7
+ "url": "https://github.com/nodejs/undici/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nodejs/undici.git"
12
+ },
13
+ "license": "MIT",
14
+ "contributors": [
15
+ {
16
+ "name": "Daniele Belardi",
17
+ "url": "https://github.com/dnlup",
18
+ "author": true
19
+ },
20
+ {
21
+ "name": "Ethan Arrowood",
22
+ "url": "https://github.com/ethan-arrowood",
23
+ "author": true
24
+ },
25
+ {
26
+ "name": "Matteo Collina",
27
+ "url": "https://github.com/mcollina",
28
+ "author": true
29
+ },
30
+ {
31
+ "name": "Matthew Aitken",
32
+ "url": "https://github.com/KhafraDev",
33
+ "author": true
34
+ },
35
+ {
36
+ "name": "Robert Nagy",
37
+ "url": "https://github.com/ronag",
38
+ "author": true
39
+ },
40
+ {
41
+ "name": "Szymon Marczak",
42
+ "url": "https://github.com/szmarczak",
43
+ "author": true
44
+ },
45
+ {
46
+ "name": "Tomas Della Vedova",
47
+ "url": "https://github.com/delvedor",
48
+ "author": true
49
+ }
50
+ ],
51
+ "keywords": [
52
+ "fetch",
53
+ "http",
54
+ "https",
55
+ "promise",
56
+ "request",
57
+ "curl",
58
+ "wget",
59
+ "xhr",
60
+ "whatwg"
61
+ ],
62
+ "main": "index.js",
63
+ "types": "index.d.ts",
64
+ "files": [
65
+ "*.d.ts",
66
+ "index.js",
67
+ "index-fetch.js",
68
+ "lib",
69
+ "types",
70
+ "docs"
71
+ ],
72
+ "scripts": {
73
+ "build:node": "npx esbuild@0.19.4 index-fetch.js --bundle --platform=node --outfile=undici-fetch.js --define:esbuildDetection=1 --keep-names",
74
+ "prebuild:wasm": "node build/wasm.js --prebuild",
75
+ "build:wasm": "node build/wasm.js --docker",
76
+ "lint": "standard | snazzy",
77
+ "lint:fix": "standard --fix | snazzy",
78
+ "test": "node scripts/generate-pem && npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:cookies && npm run test:wpt && npm run test:websocket && npm run test:jest && npm run test:typescript",
79
+ "test:cookies": "node scripts/verifyVersion 16 || tap test/cookie/*.js",
80
+ "test:node-fetch": "node scripts/verifyVersion.js 16 || mocha --exit test/node-fetch",
81
+ "test:fetch": "node scripts/verifyVersion.js 16 || (npm run build:node && tap --expose-gc test/fetch/*.js && tap test/webidl/*.js)",
82
+ "test:jest": "node scripts/verifyVersion.js 14 || jest",
83
+ "test:tap": "tap test/*.js test/diagnostics-channel/*.js",
84
+ "test:tdd": "tap test/*.js test/diagnostics-channel/*.js -w",
85
+ "test:typescript": "node scripts/verifyVersion.js 14 || tsd && tsc --skipLibCheck test/imports/undici-import.ts",
86
+ "test:websocket": "node scripts/verifyVersion.js 18 || tap test/websocket/*.js",
87
+ "test:wpt": "node scripts/verifyVersion 18 || (node test/wpt/start-fetch.mjs && node test/wpt/start-FileAPI.mjs && node test/wpt/start-mimesniff.mjs && node test/wpt/start-xhr.mjs && node test/wpt/start-websockets.mjs)",
88
+ "coverage": "nyc --reporter=text --reporter=html npm run test",
89
+ "coverage:ci": "nyc --reporter=lcov npm run test",
90
+ "bench": "PORT=3042 concurrently -k -s first npm:bench:server npm:bench:run",
91
+ "bench:server": "node benchmarks/server.js",
92
+ "prebench:run": "node benchmarks/wait.js",
93
+ "bench:run": "CONNECTIONS=1 node benchmarks/benchmark.js; CONNECTIONS=50 node benchmarks/benchmark.js",
94
+ "serve:website": "docsify serve .",
95
+ "prepare": "husky install",
96
+ "fuzz": "jsfuzz test/fuzzing/fuzz.js corpus"
97
+ },
98
+ "devDependencies": {
99
+ "@sinonjs/fake-timers": "^11.1.0",
100
+ "@types/node": "^18.0.3",
101
+ "abort-controller": "^3.0.0",
102
+ "atomic-sleep": "^1.0.0",
103
+ "chai": "^4.3.4",
104
+ "chai-as-promised": "^7.1.1",
105
+ "chai-iterator": "^3.0.2",
106
+ "chai-string": "^1.5.0",
107
+ "concurrently": "^8.0.1",
108
+ "cronometro": "^1.0.5",
109
+ "delay": "^5.0.0",
110
+ "dns-packet": "^5.4.0",
111
+ "docsify-cli": "^4.4.3",
112
+ "form-data": "^4.0.0",
113
+ "formdata-node": "^4.3.1",
114
+ "https-pem": "^3.0.0",
115
+ "husky": "^8.0.1",
116
+ "import-fresh": "^3.3.0",
117
+ "jest": "^29.0.2",
118
+ "jsdom": "^23.0.0",
119
+ "jsfuzz": "^1.0.15",
120
+ "mocha": "^10.0.0",
121
+ "mockttp": "^3.9.2",
122
+ "p-timeout": "^3.2.0",
123
+ "pre-commit": "^1.2.2",
124
+ "proxy": "^1.0.2",
125
+ "proxyquire": "^2.1.3",
126
+ "semver": "^7.5.4",
127
+ "sinon": "^17.0.1",
128
+ "snazzy": "^9.0.0",
129
+ "standard": "^17.0.0",
130
+ "table": "^6.8.0",
131
+ "tap": "^16.1.0",
132
+ "tsd": "^0.29.0",
133
+ "typescript": "^5.0.2",
134
+ "wait-on": "^7.0.1",
135
+ "ws": "^8.11.0"
136
+ },
137
+ "engines": {
138
+ "node": ">=14.0"
139
+ },
140
+ "standard": {
141
+ "env": [
142
+ "mocha"
143
+ ],
144
+ "ignore": [
145
+ "lib/llhttp/constants.js",
146
+ "lib/llhttp/utils.js",
147
+ "test/wpt/tests"
148
+ ]
149
+ },
150
+ "tsd": {
151
+ "directory": "test/types",
152
+ "compilerOptions": {
153
+ "esModuleInterop": true,
154
+ "lib": [
155
+ "esnext"
156
+ ]
157
+ }
158
+ },
159
+ "jest": {
160
+ "testMatch": [
161
+ "<rootDir>/test/jest/**"
162
+ ]
163
+ },
164
+ "dependencies": {
165
+ "@fastify/busboy": "^2.0.0"
166
+ }
167
+ }
worker/node_modules/unenv/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Pooya Parsa <pooya@pi0.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
worker/node_modules/unenv/README.md ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🕊️ unenv
2
+
3
+ <!-- automd:badges color=yellow packagephobia -->
4
+
5
+ [![npm version](https://img.shields.io/npm/v/unenv?color=yellow)](https://npmjs.com/package/unenv)
6
+ [![npm downloads](https://img.shields.io/npm/dm/unenv?color=yellow)](https://npm.chart.dev/unenv)
7
+ [![install size](https://badgen.net/packagephobia/install/unenv?color=yellow)](https://packagephobia.com/result?p=unenv)
8
+
9
+ <!-- /automd -->
10
+
11
+ > [!NOTE]
12
+ > You are on the development (v2) branch. Check out [v1](https://github.com/unjs/unenv/tree/v1) for the current release.
13
+
14
+ unenv provides polyfills to add [Node.js](https://nodejs.org/) compatibility for any JavaScript runtime, including browsers and edge workers.
15
+
16
+ ## 🌟 Used by
17
+
18
+ - [Nitro](https://nitro.build/)
19
+ - [Nuxt](https://nuxt.com/)
20
+ - [Cloudflare](https://developers.cloudflare.com/workers/runtime-apis/nodejs/)
21
+ - [ESM.sh](https://esm.sh/)
22
+
23
+ ## Usage
24
+
25
+ The `defineEnv` utility can generate a target environment configuration.
26
+
27
+ ```js
28
+ import { defineEnv } from "unenv";
29
+
30
+ const { env } = defineEnv({
31
+ nodeCompat: true,
32
+ npmShims: true,
33
+ resolve: true,
34
+ overrides: {},
35
+ presets: [],
36
+ });
37
+
38
+ const { alias, inject, external, polyfill } = env;
39
+ ```
40
+
41
+ You can then integrate the env object with your build tool:
42
+
43
+ <details>
44
+
45
+ | Bundler | `alias` | `inject` | `external` |
46
+ | -------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
47
+ | rollup | [`@rollup/plugin-alias`](https://www.npmjs.com/package/@rollup/plugin-alias) | [`@rollup/plugin-inject`](https://www.npmjs.com/package/@rollup/plugin-inject) | [`external`](https://rollupjs.org/configuration-options/#external) |
48
+ | rolldown | [`resolve.alias`](https://rolldown.rs/reference/config-options#resolve-alias) | [`inject`](https://rolldown.rs/reference/config-options#inject) | [`external`](https://rolldown.rs/reference/config-options#external) |
49
+ | vite | [`resolve.alias`](https://vite.dev/config/shared-options#resolve-alias) | [`@rollup/plugin-inject`](https://www.npmjs.com/package/@rollup/plugin-inject) | [`ssr.external`](https://vite.dev/config/ssr-options#ssr-external) |
50
+ | esbuild | [`alias`](https://esbuild.github.io/api/#alias) | [`inject`](https://esbuild.github.io/api/#inject) | [`external`](https://esbuild.github.io/api/#external) |
51
+ | rspack | [`resolve.alias`](https://rspack.dev/config/resolve#resolvealias) | - | [`externals`](https://rspack.dev/config/externals#externals-1) |
52
+ | webpack | [`resolve.alias`](https://webpack.js.org/configuration/resolve/#resolvealias) | [`webpack-plugin-inject`](https://www.npmjs.com/package/webpack-inject-plugin) | [`externals`](https://webpack.js.org/configuration/externals/#externals) |
53
+
54
+ </details>
55
+
56
+ ### Options
57
+
58
+ - `nodeCompat`: (default: `true`)
59
+ - Add `alias` entries for Node.js builtins as `<id>` and `node:<id>`.
60
+ - Add `inject` entries for Node.js globals `global`, `Buffer`, and `process`.
61
+ - `npmShims`: (default: `false`)
62
+ - Add `alias` entries to replace npm packages like `node-fetch` with lighter shims.
63
+ - `resolve`: (default: `false`) Resolve config values to absolute paths.
64
+ - `overrides`: Additional overrides for env config.
65
+ - `presets`: Additional presets (for example [`@cloudflare/unenv-preset`](https://npmjs.com/@cloudflare/unenv-preset/)).
66
+
67
+ ### `unenv/` polyfills
68
+
69
+ You can also directly import `unenv/` polyfills:
70
+
71
+ | Polyfills | Description | Source |
72
+ | ------------------ | ---------------------------------- | -------------------------------------------------------------------------------------- |
73
+ | `unenv/mock/*` | Mocking utils | [`src/runtime/mock`](https://github.com/unjs/unenv/tree/main/src/runtime/mock) |
74
+ | `unenv/node/*` | APIs compatible with `Node.js` API | [`src/runtime/node`](https://github.com/unjs/unenv/tree/main/src/runtime/node) |
75
+ | `unenv/npm/*` | NPM package shims | [`src/runtime/npm`](https://github.com/unjs/unenv/tree/main/src/runtime/npm) |
76
+ | `unenv/polyfill/*` | Global polyfills | [`src/runtime/polyfill`](https://github.com/unjs/unenv/tree/main/src/runtime/polyfill) |
77
+ | `unenv/web/*` | Subset of Web APIs | [`src/runtime/web`](https://github.com/unjs/unenv/tree/main/src/runtime/web) |
78
+
79
+ ## Node.js compatibility
80
+
81
+ `unenv` replaces Node.js built-in modules compatible with any runtime [(view source)](./src/runtime/node).
82
+
83
+ <details>
84
+
85
+ <!-- automd:file src="./coverage/unenv.md" -->
86
+
87
+ - ✅ [node:assert](https://nodejs.org/api/assert.html)
88
+ - ✅ [node:assert/strict](https://nodejs.org/api/assert.html)
89
+ - ✅ [node:async_hooks](https://nodejs.org/api/async_hooks.html)
90
+ - ✅ [node:buffer](https://nodejs.org/api/buffer.html)
91
+ - ✅ [node:child_process](https://nodejs.org/api/child_process.html)
92
+ - ✅ [node:cluster](https://nodejs.org/api/cluster.html)
93
+ - ✅ [node:console](https://nodejs.org/api/console.html)
94
+ - ✅ [node:constants](https://nodejs.org/api/constants.html)
95
+ - ✅ [node:crypto](https://nodejs.org/api/crypto.html)
96
+ - ✅ [node:dgram](https://nodejs.org/api/dgram.html)
97
+ - ✅ [node:diagnostics_channel](https://nodejs.org/api/diagnostics_channel.html)
98
+ - ✅ [node:dns](https://nodejs.org/api/dns.html)
99
+ - ✅ [node:dns/promises](https://nodejs.org/api/dns.html)
100
+ - ✅ [node:domain](https://nodejs.org/api/domain.html)
101
+ - ✅ [node:events](https://nodejs.org/api/events.html)
102
+ - ✅ [node:fs](https://nodejs.org/api/fs.html)
103
+ - ✅ [node:fs/promises](https://nodejs.org/api/fs.html)
104
+ - ✅ [node:http](https://nodejs.org/api/http.html)
105
+ - ✅ [node:http2](https://nodejs.org/api/http2.html)
106
+ - ✅ [node:https](https://nodejs.org/api/https.html)
107
+ - ✅ [node:inspector](https://nodejs.org/api/inspector.html)
108
+ - ✅ [node:inspector/promises](https://nodejs.org/api/inspector.html)
109
+ - ✅ [node:module](https://nodejs.org/api/module.html)
110
+ - ✅ [node:net](https://nodejs.org/api/net.html)
111
+ - ✅ [node:os](https://nodejs.org/api/os.html)
112
+ - ✅ [node:path](https://nodejs.org/api/path.html)
113
+ - ✅ [node:path/posix](https://nodejs.org/api/path.html)
114
+ - ✅ [node:path/win32](https://nodejs.org/api/path.html)
115
+ - ✅ [node:perf_hooks](https://nodejs.org/api/perf_hooks.html)
116
+ - ✅ [node:process](https://nodejs.org/api/process.html)
117
+ - ✅ [node:punycode](https://nodejs.org/api/punycode.html)
118
+ - ✅ [node:querystring](https://nodejs.org/api/querystring.html)
119
+ - ✅ [node:readline](https://nodejs.org/api/readline.html)
120
+ - ✅ [node:readline/promises](https://nodejs.org/api/readline.html)
121
+ - ✅ [node:repl](https://nodejs.org/api/repl.html)
122
+ - ✅ [node:stream](https://nodejs.org/api/stream.html)
123
+ - ✅ [node:stream/consumers](https://nodejs.org/api/stream.html)
124
+ - ✅ [node:stream/promises](https://nodejs.org/api/stream.html)
125
+ - ✅ [node:stream/web](https://nodejs.org/api/stream.html)
126
+ - ✅ [node:string_decoder](https://nodejs.org/api/string_decoder.html)
127
+ - ✅ [node:sys](https://nodejs.org/api/sys.html)
128
+ - ✅ [node:timers](https://nodejs.org/api/timers.html)
129
+ - ✅ [node:timers/promises](https://nodejs.org/api/timers.html)
130
+ - ✅ [node:tls](https://nodejs.org/api/tls.html)
131
+ - ✅ [node:trace_events](https://nodejs.org/api/trace_events.html)
132
+ - ✅ [node:tty](https://nodejs.org/api/tty.html)
133
+ - ✅ [node:url](https://nodejs.org/api/url.html)
134
+ - ✅ [node:util](https://nodejs.org/api/util.html)
135
+ - ✅ [node:util/types](https://nodejs.org/api/util.html)
136
+ - ✅ [node:v8](https://nodejs.org/api/v8.html)
137
+ - ✅ [node:vm](https://nodejs.org/api/vm.html)
138
+ - ✅ [node:wasi](https://nodejs.org/api/wasi.html)
139
+ - ✅ [node:worker_threads](https://nodejs.org/api/worker_threads.html)
140
+ - ✅ [node:zlib](https://nodejs.org/api/zlib.html)
141
+
142
+ <!-- /automd -->
143
+
144
+ </details>
145
+
146
+ ## Manual mocking
147
+
148
+ <details>
149
+
150
+ ```js
151
+ // Magic proxy to replace any unknown API
152
+ import MockProxy from "unenv/mock/proxy";
153
+
154
+ // You can also create named mocks
155
+ const lib = MockProxy.__createMock__("lib", {
156
+ /* overrides */
157
+ });
158
+ ```
159
+
160
+ </details>
161
+
162
+ [(view source)](./src/runtime/mock)
163
+
164
+ ## Nightly release channel
165
+
166
+ You can use the nightly release channel to try the latest changes in the `main` branch via [`unenv-nightly`](https://www.npmjs.com/package/unenv-nightly).
167
+
168
+ <details>
169
+
170
+ If directly using `unenv` in your project:
171
+
172
+ ```json
173
+ {
174
+ "devDependencies": {
175
+ "unenv": "npm:unenv-nightly"
176
+ }
177
+ }
178
+ ```
179
+
180
+ If using `unenv` via another tool (Nuxt or Nitro) in your project:
181
+
182
+ ```json
183
+ {
184
+ "resolutions": {
185
+ "unenv": "npm:unenv-nightly"
186
+ }
187
+ }
188
+ ```
189
+
190
+ </details>
191
+
192
+ ## License
193
+
194
+ <!-- automd:contributors license=MIT author=pi0 -->
195
+
196
+ Published under the [MIT](https://github.com/unjs/unenv/blob/main/LICENSE) license.
197
+ Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/unenv/graphs/contributors) 💛
198
+ <br><br>
199
+ <a href="https://github.com/unjs/unenv/graphs/contributors">
200
+ <img src="https://contrib.rocks/image?repo=unjs/unenv" />
201
+ </a>
202
+
203
+ <!-- /automd -->
204
+
205
+ <!-- automd:with-automd -->
206
+
207
+ ---
208
+
209
+ _🤖 auto updated with [automd](https://automd.unjs.io)_
210
+
211
+ <!-- /automd -->
worker/node_modules/unenv/package.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "unenv",
3
+ "version": "2.0.0-rc.14",
4
+ "description": "",
5
+ "repository": "unjs/unenv",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "./package.json": "./package.json",
15
+ "./mock/proxy-cjs": {
16
+ "types": "./lib/mock.d.cts",
17
+ "default": "./lib/mock.cjs"
18
+ },
19
+ "./mock/proxy-cjs/*": {
20
+ "types": "./lib/mock.d.cts",
21
+ "default": "./lib/mock.cjs"
22
+ },
23
+ "./*": {
24
+ "types": "./dist/runtime/*.d.mts",
25
+ "default": "./dist/runtime/*.mjs"
26
+ }
27
+ },
28
+ "types": "./lib/index.d.mts",
29
+ "files": [
30
+ "dist",
31
+ "lib"
32
+ ],
33
+ "scripts": {
34
+ "build": "pnpm node-ts ./scripts/build.ts",
35
+ "build:watch": "pnpm node-ts --watch ./scripts/build.ts",
36
+ "node-ts": "node --disable-warning=ExperimentalWarning --experimental-strip-types",
37
+ "dev": "vitest",
38
+ "lint": "eslint . && prettier -c src test",
39
+ "lint:fix": "pnpm node-ts ./test/node-coverage.ts && automd && eslint --fix . && prettier -w src test",
40
+ "prepack": "pnpm run build",
41
+ "release": "pnpm test && changelogen --release --push --publish --prerelease --publishTag rc",
42
+ "test": "pnpm lint && pnpm test:types && pnpm vitest --run",
43
+ "test:types": "tsc --noEmit"
44
+ },
45
+ "dependencies": {
46
+ "defu": "^6.1.4",
47
+ "exsolve": "^1.0.1",
48
+ "ohash": "^2.0.10",
49
+ "pathe": "^2.0.3",
50
+ "ufo": "^1.5.4"
51
+ },
52
+ "devDependencies": {
53
+ "@parcel/watcher": "^2.5.1",
54
+ "@types/node": "^22.13.9",
55
+ "@vitest/coverage-v8": "^3.0.7",
56
+ "automd": "^0.4.0",
57
+ "changelogen": "^0.6.1",
58
+ "consola": "^3.4.0",
59
+ "esbuild": "^0.25.0",
60
+ "eslint": "^9.21.0",
61
+ "eslint-config-unjs": "^0.4.2",
62
+ "jiti": "^2.4.2",
63
+ "magic-string": "^0.30.17",
64
+ "oxc-parser": "^0.53.0",
65
+ "oxc-resolver": "^5.0.0",
66
+ "oxc-transform": "^0.53.0",
67
+ "prettier": "^3.5.3",
68
+ "rolldown": "^1.0.0-beta.3",
69
+ "tinyexec": "^0.3.2",
70
+ "typescript": "^5.8.2",
71
+ "vitest": "^3.0.7",
72
+ "workerd": "^1.20250224.0",
73
+ "wrangler": "^3.111.0"
74
+ },
75
+ "packageManager": "pnpm@10.5.2"
76
+ }
worker/node_modules/workerd/README.md ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # 👷 `workerd`, Cloudflare's JavaScript/Wasm Runtime
2
+
3
+ `workerd` is a JavaScript / Wasm server runtime based on the same code that powers
4
+ [Cloudflare Workers](https://workers.dev).
5
+
6
+ See https://github.com/cloudflare/workerd for details.
worker/node_modules/workerd/install.js ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __copyProps = (to, from, except, desc) => {
8
+ if (from && typeof from === "object" || typeof from === "function") {
9
+ for (let key of __getOwnPropNames(from))
10
+ if (!__hasOwnProp.call(to, key) && key !== except)
11
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
+ }
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
23
+
24
+ // npm/lib/node-platform.ts
25
+ var import_os = __toESM(require("os"));
26
+ var import_path = __toESM(require("path"));
27
+ var knownPackages = {
28
+ "darwin arm64 LE": "@cloudflare/workerd-darwin-arm64",
29
+ "darwin x64 LE": "@cloudflare/workerd-darwin-64",
30
+ "linux arm64 LE": "@cloudflare/workerd-linux-arm64",
31
+ "linux x64 LE": "@cloudflare/workerd-linux-64",
32
+ "win32 x64 LE": "@cloudflare/workerd-windows-64"
33
+ };
34
+ var maybeExeExtension = process.platform === "win32" ? ".exe" : "";
35
+ function pkgAndSubpathForCurrentPlatform() {
36
+ let pkg;
37
+ let subpath;
38
+ let platformKey = `${process.platform} ${import_os.default.arch()} ${import_os.default.endianness()}`;
39
+ if (platformKey in knownPackages) {
40
+ pkg = knownPackages[platformKey];
41
+ subpath = `bin/workerd${maybeExeExtension}`;
42
+ } else {
43
+ throw new Error(`Unsupported platform: ${platformKey}`);
44
+ }
45
+ return { pkg, subpath };
46
+ }
47
+ function downloadedBinPath(pkg, subpath) {
48
+ const libDir = import_path.default.dirname(require.resolve("workerd"));
49
+ return import_path.default.join(libDir, `downloaded-${pkg.replace("/", "-")}-${import_path.default.basename(subpath)}${maybeExeExtension}`);
50
+ }
51
+
52
+ // npm/lib/node-install.ts
53
+ var import_fs = __toESM(require("fs"));
54
+ var import_os2 = __toESM(require("os"));
55
+ var import_path2 = __toESM(require("path"));
56
+ var import_zlib = __toESM(require("zlib"));
57
+ var import_https = __toESM(require("https"));
58
+ var import_child_process = __toESM(require("child_process"));
59
+ var toPath = import_path2.default.join(__dirname, "bin", "workerd");
60
+ var isToPathJS = true;
61
+ function validateBinaryVersion(...command) {
62
+ command.push("--version");
63
+ let stdout;
64
+ try {
65
+ stdout = import_child_process.default.execFileSync(command.shift(), command, {
66
+ // Without this, this install script strangely crashes with the error
67
+ // "EACCES: permission denied, write" but only on Ubuntu Linux when node is
68
+ // installed from the Snap Store. This is not a problem when you download
69
+ // the official version of node. The problem appears to be that stderr
70
+ // (i.e. file descriptor 2) isn't writable?
71
+ //
72
+ // More info:
73
+ // - https://snapcraft.io/ (what the Snap Store is)
74
+ // - https://nodejs.org/dist/ (download the official version of node)
75
+ // - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
76
+ //
77
+ stdio: [
78
+ /* stdin */
79
+ "pipe",
80
+ /* stdout */
81
+ "pipe",
82
+ /* stderr */
83
+ "inherit"
84
+ ]
85
+ }).toString().trim();
86
+ } catch (e) {
87
+ let msg = `[workerd] Failed to validate workerd binary
88
+
89
+ Local development will not work. This usually means you're on an unsupported
90
+ operating system, or missing some shared libraries.`;
91
+ if (process.platform === "linux") {
92
+ msg += " On Debian-based systems,\nmake sure you've installed the `libc++1` package.";
93
+ }
94
+ console.error(msg);
95
+ return;
96
+ }
97
+ if (stdout !== `workerd ${"2025-07-18"}`) {
98
+ throw new Error(
99
+ `Expected ${JSON.stringify(
100
+ "2025-07-18"
101
+ )} but got ${JSON.stringify(stdout)}`
102
+ );
103
+ }
104
+ }
105
+ function isYarn() {
106
+ const { npm_config_user_agent } = process.env;
107
+ if (npm_config_user_agent) {
108
+ return /\byarn\//.test(npm_config_user_agent);
109
+ }
110
+ return false;
111
+ }
112
+ function fetch(url) {
113
+ return new Promise((resolve, reject) => {
114
+ import_https.default.get(url, (res) => {
115
+ if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
116
+ return fetch(res.headers.location).then(resolve, reject);
117
+ if (res.statusCode !== 200)
118
+ return reject(new Error(`Server responded with ${res.statusCode}`));
119
+ let chunks = [];
120
+ res.on("data", (chunk) => chunks.push(chunk));
121
+ res.on("end", () => resolve(Buffer.concat(chunks)));
122
+ }).on("error", reject);
123
+ });
124
+ }
125
+ function extractFileFromTarGzip(buffer, subpath) {
126
+ try {
127
+ buffer = import_zlib.default.unzipSync(buffer);
128
+ } catch (err) {
129
+ throw new Error(
130
+ `Invalid gzip data in archive: ${err && err.message || err}`
131
+ );
132
+ }
133
+ let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
134
+ let offset = 0;
135
+ subpath = `package/${subpath}`;
136
+ while (offset < buffer.length) {
137
+ let name = str(offset, 100);
138
+ let size = parseInt(str(offset + 124, 12), 8);
139
+ offset += 512;
140
+ if (!isNaN(size)) {
141
+ if (name === subpath) return buffer.subarray(offset, offset + size);
142
+ offset += size + 511 & ~511;
143
+ }
144
+ }
145
+ throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
146
+ }
147
+ function installUsingNPM(pkg, subpath, binPath) {
148
+ const env = { ...process.env, npm_config_global: void 0 };
149
+ const libDir = import_path2.default.dirname(require.resolve("workerd"));
150
+ const installDir = import_path2.default.join(libDir, "npm-install");
151
+ import_fs.default.mkdirSync(installDir);
152
+ try {
153
+ import_fs.default.writeFileSync(import_path2.default.join(installDir, "package.json"), "{}");
154
+ import_child_process.default.execSync(
155
+ `npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${"1.20250718.0"}`,
156
+ { cwd: installDir, stdio: "pipe", env }
157
+ );
158
+ const installedBinPath = import_path2.default.join(
159
+ installDir,
160
+ "node_modules",
161
+ pkg,
162
+ subpath
163
+ );
164
+ import_fs.default.renameSync(installedBinPath, binPath);
165
+ } finally {
166
+ try {
167
+ removeRecursive(installDir);
168
+ } catch {
169
+ }
170
+ }
171
+ }
172
+ function removeRecursive(dir) {
173
+ for (const entry of import_fs.default.readdirSync(dir)) {
174
+ const entryPath = import_path2.default.join(dir, entry);
175
+ let stats;
176
+ try {
177
+ stats = import_fs.default.lstatSync(entryPath);
178
+ } catch {
179
+ continue;
180
+ }
181
+ if (stats.isDirectory()) removeRecursive(entryPath);
182
+ else import_fs.default.unlinkSync(entryPath);
183
+ }
184
+ import_fs.default.rmdirSync(dir);
185
+ }
186
+ function maybeOptimizePackage(binPath) {
187
+ if (import_os2.default.platform() !== "win32" && !isYarn()) {
188
+ const tempPath = import_path2.default.join(__dirname, "bin-workerd");
189
+ try {
190
+ import_fs.default.linkSync(binPath, tempPath);
191
+ import_fs.default.renameSync(tempPath, toPath);
192
+ isToPathJS = false;
193
+ import_fs.default.unlinkSync(tempPath);
194
+ } catch {
195
+ }
196
+ }
197
+ }
198
+ async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
199
+ const unscopedPkg = pkg.substring(pkg.indexOf("/") + 1);
200
+ const url = `https://registry.npmjs.org/${pkg}/-/${unscopedPkg}-${"1.20250718.0"}.tgz`;
201
+ console.error(`[workerd] Trying to download ${JSON.stringify(url)}`);
202
+ try {
203
+ import_fs.default.writeFileSync(
204
+ binPath,
205
+ extractFileFromTarGzip(await fetch(url), subpath)
206
+ );
207
+ import_fs.default.chmodSync(binPath, 493);
208
+ } catch (e) {
209
+ console.error(
210
+ `[workerd] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`
211
+ );
212
+ throw e;
213
+ }
214
+ }
215
+ async function checkAndPreparePackage() {
216
+ const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
217
+ let binPath;
218
+ try {
219
+ binPath = require.resolve(`${pkg}/${subpath}`);
220
+ } catch (e) {
221
+ console.error(`[workerd] Failed to find package "${pkg}" on the file system
222
+
223
+ This can happen if you use the "--no-optional" flag. The "optionalDependencies"
224
+ package.json feature is used by workerd to install the correct binary executable
225
+ for your current platform. This install script will now attempt to work around
226
+ this. If that fails, you need to remove the "--no-optional" flag to use workerd.
227
+ `);
228
+ binPath = downloadedBinPath(pkg, subpath);
229
+ try {
230
+ console.error(`[workerd] Trying to install package "${pkg}" using npm`);
231
+ installUsingNPM(pkg, subpath, binPath);
232
+ } catch (e2) {
233
+ console.error(
234
+ `[workerd] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`
235
+ );
236
+ try {
237
+ await downloadDirectlyFromNPM(pkg, subpath, binPath);
238
+ } catch (e3) {
239
+ throw new Error(`Failed to install package "${pkg}"`);
240
+ }
241
+ }
242
+ }
243
+ maybeOptimizePackage(binPath);
244
+ }
245
+ checkAndPreparePackage().then(() => {
246
+ if (isToPathJS) {
247
+ validateBinaryVersion(process.execPath, toPath);
248
+ } else {
249
+ validateBinaryVersion(toPath);
250
+ }
251
+ });
worker/node_modules/workerd/package.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "workerd",
3
+ "version": "1.20250718.0",
4
+ "description": "👷 workerd, Cloudflare's JavaScript/Wasm Runtime",
5
+ "repository": "https://github.com/cloudflare/workerd",
6
+ "scripts": {
7
+ "postinstall": "node install.js"
8
+ },
9
+ "main": "lib/main.js",
10
+ "engines": {
11
+ "node": ">=16"
12
+ },
13
+ "bin": {
14
+ "workerd": "bin/workerd"
15
+ },
16
+ "optionalDependencies": {
17
+ "@cloudflare/workerd-darwin-arm64": "1.20250718.0",
18
+ "@cloudflare/workerd-darwin-64": "1.20250718.0",
19
+ "@cloudflare/workerd-linux-arm64": "1.20250718.0",
20
+ "@cloudflare/workerd-linux-64": "1.20250718.0",
21
+ "@cloudflare/workerd-windows-64": "1.20250718.0"
22
+ },
23
+ "license": "Apache-2.0"
24
+ }
worker/node_modules/workerd/worker.mjs ADDED
The diff for this file is too large to render. See raw diff
 
worker/node_modules/workerd/workerd.capnp ADDED
@@ -0,0 +1,1028 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2017-2022 Cloudflare, Inc.
2
+ # Licensed under the Apache 2.0 license found in the LICENSE file or at:
3
+ # https://opensource.org/licenses/Apache-2.0
4
+
5
+ @0xe6afd26682091c01;
6
+ # This file defines the schema for configuring the workerd runtime.
7
+ #
8
+ # A config file can be written as a `.capnp` file that imports this file and then defines a
9
+ # constant of type `Config`. Alternatively, various higher-level tooling (e.g. wrangler) may
10
+ # generate configs for you, outputting a binary Cap'n Proto file.
11
+ #
12
+ # To start a server with a config, do:
13
+ #
14
+ # workerd serve my-config.capnp constantName
15
+ #
16
+ # You can also build a new self-contained binary which combines the `workerd` binary with your
17
+ # configuration and all your source code:
18
+ #
19
+ # workerd compile my-config.capnp constantName -o my-server-bin
20
+ #
21
+ # This binary can then be run stand-alone.
22
+ #
23
+ # A common theme in this configuration is capability-based design. We generally like to avoid
24
+ # giving a Worker the ability to access external resources by name, since this makes it hard
25
+ # to see and restrict what each Worker can access. Instead, the default is that a Worker has
26
+ # access to no privileged resources at all, and you must explicitly declare "bindings" to give
27
+ # it access to specific resources. A binding gives the Worker a JavaScript API object that points
28
+ # to a specific resource. This means that by changing config alone, you can fully control which
29
+ # resources an Worker connects to. (You can even disallow access to the public internet, although
30
+ # public internet access is granted by default.)
31
+ #
32
+ # This config format is fairly powerful, allowing you to do things like define a TLS-terminating
33
+ # reverse proxy server without using any actual JavaScript code. However, you should not be
34
+ # afraid to fall back to code for anything the config cannot express, as Workers are very fast
35
+ # to execute!
36
+
37
+ # Any capnp files imported here must be:
38
+ # 1. embedded into workerd-meta.capnp
39
+ # 2. added to `tryImportBulitin` in workerd.c++ (grep for '"/workerd/workerd.capnp"').
40
+ using Cxx = import "/capnp/c++.capnp";
41
+ $Cxx.namespace("workerd::server::config");
42
+ $Cxx.allowCancellation;
43
+
44
+ struct Config {
45
+ # Top-level configuration for a workerd instance.
46
+
47
+ services @0 :List(Service);
48
+ # List of named services defined by this server. These names are private; they are only used
49
+ # to refer to the services from elsewhere in this config file, as well as for logging and the
50
+ # like. Services are not reachable until you configure some way to make them reachable, such
51
+ # as via a Socket.
52
+ #
53
+ # If you do not define any service called "internet", one is defined implicitly, representing
54
+ # the ability to access public internet servers. An explicit definition would look like:
55
+ #
56
+ # ( name = "internet",
57
+ # network = (
58
+ # allow = ["public"], # Allows connections to publicly-routable addresses only.
59
+ # tlsOptions = (trustBrowserCas = true)
60
+ # )
61
+ # )
62
+ #
63
+ # The "internet" service backs the global `fetch()` function in a Worker, unless that Worker's
64
+ # configuration specifies some other service using the `globalOutbound` setting.
65
+
66
+ sockets @1 :List(Socket);
67
+ # List of sockets on which this server will listen, and the services that will be exposed
68
+ # through them.
69
+
70
+ v8Flags @2 :List(Text);
71
+ # List of "command-line" flags to pass to V8, like "--expose-gc". We put these in the config
72
+ # rather than on the actual command line because for most use cases, managing these via the
73
+ # config file is probably cleaner and easier than passing on the actual CLI.
74
+ #
75
+ # WARNING: Use at your own risk. V8 flags can have all sorts of wild effects including completely
76
+ # breaking everything. V8 flags also generally do not come with any guarantee of stability
77
+ # between V8 versions. Most users should not set any V8 flags.
78
+
79
+ extensions @3 :List(Extension);
80
+ # Extensions provide capabilities to all workers. Extensions are usually prepared separately
81
+ # and are late-linked with the app using this config field.
82
+
83
+ autogates @4 :List(Text);
84
+ # A list of gates which are enabled.
85
+ # These are used to gate features/changes in workerd and in our internal repo. See the equivalent
86
+ # config definition in our internal repo for more details.
87
+
88
+ structuredLogging @5 :Bool = false;
89
+ # If true, logs will be emitted as JSON for structured logging.
90
+ # When false, logs use the traditional human-readable format.
91
+ # This affects the format of logs from KJ_LOG and exception reporting as well as js logs.
92
+ # This won't work for logs coming from service worker syntax workers with the old module registry.
93
+ }
94
+
95
+ # ========================================================================================
96
+ # Sockets
97
+
98
+ struct Socket {
99
+ name @0 :Text;
100
+ # Each socket has a unique name which can be used on the command line to override the socket's
101
+ # address with `--socket-addr <name>=<addr>` or `--socket-fd <name>=<fd>`.
102
+
103
+ address @1 :Text;
104
+ # Address/port on which this socket will listen. Optional; if not specified, then you will be
105
+ # required to specify the socket on the command line with with `--socket-addr <name>=<addr>` or
106
+ # `--socket-fd <name>=<fd>`.
107
+ #
108
+ # Examples:
109
+ # - "*:80": Listen on port 80 on all local IPv4 and IPv6 interfaces.
110
+ # - "1.2.3.4": Listen on the specific IPv4 address on the default port for the protocol.
111
+ # - "1.2.3.4:80": Listen on the specific IPv4 address and port.
112
+ # - "1234:5678::abcd": Listen on the specific IPv6 address on the default port for the protocol.
113
+ # - "[1234:5678::abcd]:80": Listen on the specific IPv6 address and port.
114
+ # - "unix:/path/to/socket": Listen on a Unix socket.
115
+ # - "unix-abstract:name": On Linux, listen on the given "abstract" Unix socket name.
116
+ # - "example.com:80": Perform a DNS lookup to determine the address, and then listen on it. If
117
+ # this resolves to multiple addresses, listen on all of them.
118
+ #
119
+ # (These are the formats supported by KJ's parseAddress().)
120
+
121
+ union {
122
+ http @2 :HttpOptions;
123
+ https :group {
124
+ options @3 :HttpOptions;
125
+ tlsOptions @4 :TlsOptions;
126
+ }
127
+
128
+ # TODO(someday): TCP, TCP proxy, SMTP, Cap'n Proto, ...
129
+ }
130
+
131
+ service @5 :ServiceDesignator;
132
+ # Service name which should handle requests on this socket.
133
+
134
+ # TODO(someday): Support mapping different hostnames to different services? Or should that be
135
+ # done strictly via JavaScript?
136
+ }
137
+
138
+ # ========================================================================================
139
+ # Services
140
+
141
+ struct Service {
142
+ # Defines a named service. Each server has a list of named services. The names are private,
143
+ # used to refer to the services within this same config file.
144
+
145
+ name @0 :Text;
146
+ # Name of the service. Used only to refer to the service from elsewhere in the config file.
147
+ # Services are not accessible unless you explicitly configure them to be, such as through a
148
+ # `Socket` or through a binding from another Worker.
149
+
150
+ union {
151
+ unspecified @1 :Void;
152
+ # (This catches when someone forgets to specify one of the union members. Do not set this.)
153
+
154
+ worker @2 :Worker;
155
+ # A Worker!
156
+
157
+ network @3 :Network;
158
+ # A service that implements access to a network. fetch() requests are routed according to
159
+ # the URL hostname.
160
+
161
+ external @4 :ExternalServer;
162
+ # A service that forwards all requests to a specific remote server. Typically used to
163
+ # connect to a back-end server on your internal network.
164
+
165
+ disk @5 :DiskDirectory;
166
+ # An HTTP service backed by a directory on disk, supporting a basic HTTP GET/PUT. Generally
167
+ # not intended to be exposed directly to the internet; typically you want to bind this into
168
+ # a Worker that adds logic for setting Content-Type and the like.
169
+ }
170
+
171
+ # TODO(someday): Allow defining a list of middlewares to stack on top of the service. This would
172
+ # be a list of Worker names, where each Worker must have a binding called `next`. This
173
+ # implicitly creates an inherited worker that wraps this service, with the `next` binding
174
+ # pointing to the service itself (or to the next middleware in the stack).
175
+ }
176
+
177
+ struct ServiceDesignator {
178
+ # A reference to a service from elsewhere in the config file, e.g. from a service binding in a
179
+ # Worker.
180
+ #
181
+ # In the case that only `name` needs to be specified, then you can provide a raw string wherever
182
+ # `ServiceDesignator` is needed. Cap'n proto automatically assumes the string is intended to be
183
+ # the value for `name`, since that is the first field. In other words, if you would otherwise
184
+ # write something like:
185
+ #
186
+ # bindings = [(service = (name = "foo"))]
187
+ #
188
+ # You can write this instead, which is equivalent:
189
+ #
190
+ # bindings = [(service = "foo")]
191
+
192
+ name @0 :Text;
193
+ # Name of the service in the Config.services list.
194
+
195
+ entrypoint @1 :Text;
196
+ # A modules-syntax Worker can export multiple named entrypoints. `export default {` specifies
197
+ # the default entrypoint, whereas `export let foo = {` defines an entrypoint named `foo`. If
198
+ # `entrypoint` is specified here, it names an alternate entrypoint to use on the target worker,
199
+ # otherwise the default is used.
200
+
201
+ props :union {
202
+ # Value to provide in `ctx.props` in the target worker.
203
+
204
+ empty @2 :Void;
205
+ # Empty object. (This is the default.)
206
+
207
+ json @3 :Text;
208
+ # A JSON-encoded value.
209
+ }
210
+
211
+ # TODO(someday): Options to specify which event types are allowed.
212
+ # TODO(someday): Allow adding an outgoing middleware stack here (see TODO in Service, above).
213
+ }
214
+
215
+ struct Worker {
216
+ union {
217
+ modules @0 :List(Module);
218
+ # The Worker is composed of ES modules that may import each other. The first module in the list
219
+ # is the main module, which exports event handlers.
220
+
221
+ serviceWorkerScript @1 :Text;
222
+ # The Worker is composed of one big script that uses global `addEventListener()` to register
223
+ # event handlers.
224
+ #
225
+ # The value of this field is the raw source code. When using Cap'n Proto text format, use the
226
+ # `embed` directive to read the code from an external file:
227
+ #
228
+ # serviceWorkerScript = embed "worker.js"
229
+
230
+ inherit @2 :Text;
231
+ # Inherit the configuration of some other Worker by its service name. This Worker is a clone
232
+ # of the other worker, but various settings can be modified:
233
+ # * `bindings`, if specified, overrides specific named bindings. (Each binding listed in the
234
+ # derived worker must match the name and type of some binding in the inherited worker.)
235
+ # * `globalOutbound`, if non-null, overrides the one specified in the inherited worker.
236
+ # * `compatibilityDate` and `compatibilityFlags` CANNOT be modified; they must be null.
237
+ # * If the inherited worker defines durable object namespaces, then the derived worker must
238
+ # specify `durableObjectStorage` to specify where its instances should be stored. Each
239
+ # devived worker receives its own namespace of objects. `durableObjectUniqueKeyModifier`
240
+ # must also be specified by derived workers.
241
+ #
242
+ # This can be useful when you want to run the same Worker in multiple configurations or hooked
243
+ # up to different back-ends. Note that all derived workers run in the same isolate as the
244
+ # base worker; they differ in the content of the `env` object passed to them, which contains
245
+ # the bindings. (When using service workers syntax, the global scope contains the bindings;
246
+ # in this case each derived worker runs in its own global scope, though still in the same
247
+ # isolate.)
248
+ }
249
+
250
+ struct Module {
251
+ name @0 :Text;
252
+ # Name (or path) used to import the module.
253
+
254
+ union {
255
+ esModule @1 :Text;
256
+ # An ES module file with imports and exports.
257
+ #
258
+ # As with `serviceWorkerScript`, above, the value is the raw source code.
259
+
260
+ commonJsModule @2 :Text;
261
+ # A common JS module, using require().
262
+
263
+ text @3 :Text;
264
+ # A raw text blob. Importing this will produce a string with the value.
265
+
266
+ data @4 :Data;
267
+ # A raw data blob. Importing this will produce an ArrayBuffer with the value.
268
+
269
+ wasm @5 :Data;
270
+ # A Wasm module. The value is a compiled binary Wasm module file. Importing this will produce
271
+ # a `WebAssembly.Module` object, which you can then instantiate.
272
+
273
+ json @6 :Text;
274
+ # Importing this will produce the result of parsing the given text as JSON.
275
+
276
+ obsolete @7 :Text;
277
+ # This position used to be the nodeJsCompatModule type that has now been
278
+ # obsoleted.
279
+
280
+ pythonModule @8 :Text;
281
+ # A Python module. All bundles containing this value type are converted into a JS/WASM Worker
282
+ # Bundle prior to execution.
283
+
284
+ pythonRequirement @9 :Text;
285
+ # A Python package that is required by this bundle. The package must be supported by
286
+ # Pyodide (https://pyodide.org/en/stable/usage/packages-in-pyodide.html). All packages listed
287
+ # will be installed prior to the execution of the worker.
288
+ #
289
+ # The value of this field is ignored and should always be an empty string. Only the module
290
+ # name matters. The field should have been declared `Void`, but it's difficult to change now.
291
+ }
292
+
293
+ namedExports @10 :List(Text);
294
+ # For commonJsModule modules, this is a list of named exports that the
295
+ # module expects to be exported once the evaluation is complete.
296
+ #
297
+ # (`commonJsModule` should have been a group containing the body and `namedExports`, but it's
298
+ # too late to change now.)
299
+ }
300
+
301
+ compatibilityDate @3 :Text;
302
+ compatibilityFlags @4 :List(Text);
303
+ # See: https://developers.cloudflare.com/workers/platform/compatibility-dates/
304
+ #
305
+ # `compatibilityDate` must be specified, unless the Worker inhits from another worker, in which
306
+ # case it must not be specified. `compatibilityFlags` can optionally be specified when
307
+ # `compatibilityDate` is specified.
308
+
309
+ bindings @5 :List(Binding);
310
+ # List of bindings, which give the Worker access to external resources and configuration
311
+ # settings.
312
+ #
313
+ # For Workers using ES modules syntax, the bindings are delivered via the `env` object. For
314
+ # service workers syntax, each binding shows up as a global variable.
315
+
316
+ struct Binding {
317
+ name @0 :Text;
318
+
319
+ union {
320
+ unspecified @1 :Void;
321
+ # (This catches when someone forgets to specify one of the union members. Do not set this.)
322
+
323
+ parameter :group {
324
+ # Indicates that the Worker requires a binding of the given type, but it won't be specified
325
+ # here. Another Worker can inherit this Worker and fill in this binding.
326
+
327
+ type @2 :Type;
328
+ # Expected type of this parameter.
329
+
330
+ optional @3 :Bool;
331
+ # If true, this binding is optional. Derived workers need not specify it, in which case
332
+ # the binding won't be present in the environment object passed to the worker.
333
+ #
334
+ # When a Worker has any non-optional parameters that haven't been filled in, then it can
335
+ # only be used for inheritance; it cannot be invoked directly.
336
+ }
337
+
338
+ text @4 :Text;
339
+ # A string.
340
+
341
+ data @5 :Data;
342
+ # An ArrayBuffer.
343
+
344
+ json @6 :Text;
345
+ # A value parsed from JSON.
346
+
347
+ wasmModule @7 :Data;
348
+ # A WebAssembly module. The binding will be an instance of `WebAssembly.Module`. Only
349
+ # supported when using Service Workers syntax.
350
+ #
351
+ # DEPRECATED: Please switch to ES modules syntax instead, and embed Wasm modules as modules.
352
+
353
+ cryptoKey @8 :CryptoKey;
354
+ # A CryptoKey instance, for use with the WebCrypto API.
355
+ #
356
+ # Note that by setting `extractable = false`, you can prevent the Worker code from accessing
357
+ # or leaking the raw key material; it will only be able to use the key to perform WebCrypto
358
+ # operations.
359
+
360
+ service @9 :ServiceDesignator;
361
+ # Binding to a named service (possibly, a worker).
362
+
363
+ durableObjectClass @26 :ServiceDesignator;
364
+ # A Durable Object class binding, without an actual storage namespace. This can be used to
365
+ # implement a facet.
366
+
367
+ durableObjectNamespace @10 :DurableObjectNamespaceDesignator;
368
+ # Binding to the durable object namespace implemented by the given class.
369
+ #
370
+ # In the common case that this refers to a class in the same Worker, you can specify just
371
+ # a string, like:
372
+ #
373
+ # durableObjectNamespace = "MyClass"
374
+
375
+ kvNamespace @11 :ServiceDesignator;
376
+ # A KV namespace, implemented by the named service. The Worker sees a KvNamespace-typed
377
+ # binding. Requests to the namespace will be converted into HTTP requests targeting the
378
+ # given service name.
379
+
380
+ r2Bucket @12 :ServiceDesignator;
381
+ r2Admin @13 :ServiceDesignator;
382
+ # R2 bucket and admin API bindings. Similar to KV namespaces, these turn operations into
383
+ # HTTP requests aimed at the named service.
384
+
385
+ wrapped @14 :WrappedBinding;
386
+ # Wraps a collection of inner bindings in a common api functionality.
387
+
388
+ queue @15 :ServiceDesignator;
389
+ # A Queue binding, implemented by the named service. Requests to the
390
+ # namespace will be converted into HTTP requests targeting the given
391
+ # service name.
392
+
393
+ fromEnvironment @16 :Text;
394
+ # Takes the value of an environment variable from the system. The value specified here is
395
+ # the name of a system environment variable. The value of the binding is obtained by invoking
396
+ # `getenv()` with that name. If the environment variable isn't set, the binding value is
397
+ # `null`.
398
+
399
+ analyticsEngine @17 :ServiceDesignator;
400
+ # A binding for Analytics Engine. Allows workers to store information through Analytics Engine Events.
401
+ # workerd will forward AnalyticsEngineEvents to designated service in the body of HTTP requests
402
+ # This binding is subject to change and requires the `--experimental` flag
403
+
404
+ hyperdrive :group {
405
+ designator @18 :ServiceDesignator;
406
+ database @19 :Text;
407
+ user @20 :Text;
408
+ password @21 :Text;
409
+ scheme @22 :Text;
410
+ }
411
+ # A binding for Hyperdrive. Allows workers to use Hyperdrive caching & pooling for Postgres
412
+ # databases.
413
+
414
+ unsafeEval @23 :Void;
415
+ # A simple binding that enables access to the UnsafeEval API.
416
+
417
+ memoryCache :group {
418
+ # A binding representing access to an in-memory cache.
419
+
420
+ id @24 :Text;
421
+ # The identifier associated with this cache. Any number of isolates
422
+ # can access the same in-memory cache (within the same process), and
423
+ # each worker may use any number of in-memory caches.
424
+
425
+ limits @25 :MemoryCacheLimits;
426
+ }
427
+
428
+ workerLoader :group {
429
+ # A binding representing the ability to dynamically load Workers from code presented at
430
+ # runtime.
431
+ #
432
+ # A Worker loader is not just a function that loads a Worker, but also serves as a
433
+ # cache of Workers, automatically unloading Workers that are not in use. To that end, each
434
+ # Worker must have a name, and if a Worker with that name already exists, it'll be reused.
435
+
436
+ id @27 :Text;
437
+ # Optional: The identifier associated with this Worker loader. Multiple Workers can bind to
438
+ # the same ID in order to access the same loader, so that if they request the same name
439
+ # from it, they'll end up sharing the same loaded Worker.
440
+ #
441
+ # (If omitted, the binding will not share a cache with any other binding.)
442
+ }
443
+
444
+ # TODO(someday): dispatch, other new features
445
+ }
446
+
447
+ struct Type {
448
+ # Specifies the type of a parameter binding.
449
+
450
+ union {
451
+ unspecified @0 :Void;
452
+ # (This catches when someone forgets to specify one of the union members. Do not set this.)
453
+
454
+ text @1 :Void;
455
+ data @2 :Void;
456
+ json @3 :Void;
457
+ wasm @4 :Void;
458
+ cryptoKey @5 :List(CryptoKey.Usage);
459
+ service @6 :Void;
460
+ durableObjectNamespace @7 :Void;
461
+ kvNamespace @8 :Void;
462
+ r2Bucket @9 :Void;
463
+ r2Admin @10 :Void;
464
+ queue @11 :Void;
465
+ analyticsEngine @12 : Void;
466
+ hyperdrive @13: Void;
467
+ durableObjectClass @14: Void;
468
+ }
469
+ }
470
+
471
+ struct DurableObjectNamespaceDesignator {
472
+ # The type of a Durable Object namespace binding.
473
+
474
+ className @0 :Text;
475
+ # Exported class name that implements the Durable Object.
476
+
477
+ serviceName @1 :Text;
478
+ # The service name of the worker that defines this class. If omitted, the current worker
479
+ # is assumed.
480
+ #
481
+ # Use of this field is discouraged. Instead, when accessing a different Worker's Durable
482
+ # Objects, specify a `service` binding to that worker, and have the worker implement an
483
+ # appropriate API.
484
+ #
485
+ # (This is intentionally not a ServiceDesignator because you cannot choose an alternate
486
+ # entrypoint here; the class name IS the entrypoint.)
487
+ }
488
+
489
+ struct CryptoKey {
490
+ # Parameters to crypto.subtle.importKey().
491
+
492
+ union {
493
+ raw @0 :Data;
494
+ hex @1 :Text;
495
+ base64 @2 :Text;
496
+ # Raw key material, possibly hex or base64-encoded. Use this for symmetric keys.
497
+ #
498
+ # Hint: `raw` would typically be used with Cap'n Proto's `embed` syntax to embed an
499
+ # external binary key file. `hex` or `base64` could do that too but can also be specified
500
+ # inline.
501
+
502
+ pkcs8 @3 :Text;
503
+ # Private key in PEM-encoded PKCS#8 format.
504
+
505
+ spki @4 :Text;
506
+ # Public key in PEM-encoded SPKI format.
507
+
508
+ jwk @5 :Text;
509
+ # Key in JSON format.
510
+ }
511
+
512
+ algorithm :union {
513
+ # Value for the `algorithm` parameter.
514
+
515
+ name @6 :Text;
516
+ # Just a name, like `AES-GCM`.
517
+
518
+ json @7 :Text;
519
+ # An object, encoded here as JSON.
520
+ }
521
+
522
+ extractable @8 :Bool = false;
523
+ # Is the Worker allowed to export this key to obtain the underlying key material? Setting
524
+ # this false ensures that the key cannot be leaked by errant JavaScript code; the key can
525
+ # only be used in WebCrypto operations.
526
+
527
+ usages @9 :List(Usage);
528
+ # What operations is this key permitted to be used for?
529
+
530
+ enum Usage {
531
+ encrypt @0;
532
+ decrypt @1;
533
+ sign @2;
534
+ verify @3;
535
+ deriveKey @4;
536
+ deriveBits @5;
537
+ wrapKey @6;
538
+ unwrapKey @7;
539
+ }
540
+ }
541
+
542
+ struct MemoryCacheLimits {
543
+ maxKeys @0 :UInt32;
544
+ maxValueSize @1 :UInt32;
545
+ maxTotalValueSize @2 :UInt64;
546
+ }
547
+
548
+ struct WrappedBinding {
549
+ # A binding that wraps a group of (lower-level) bindings in a common API.
550
+
551
+ moduleName @0 :Text;
552
+ # Wrapper module name.
553
+ # The module must be an internal one (provided by extension or registered in the c++ code).
554
+ # Module will be instantitated during binding initialization phase.
555
+
556
+ entrypoint @1 :Text = "default";
557
+ # Module needs to export a function with a given name (default export gets "default" name).
558
+ # The function needs to accept a single `env` argument - a dictionary with inner bindings.
559
+ # Function will be invoked during initialization phase and its return value will be used as
560
+ # resulting binding value.
561
+
562
+ innerBindings @2 :List(Binding);
563
+ # Inner bindings that will be created and passed in the env dictionary.
564
+ # These bindings shall be used to implement end-user api, and are not available to the
565
+ # binding consumers unless "re-exported" in wrapBindings function.
566
+ }
567
+ }
568
+
569
+ globalOutbound @6 :ServiceDesignator = "internet";
570
+ # Where should the global "fetch" go to? The default is the service called "internet", which
571
+ # should usually be configured to talk to the public internet.
572
+
573
+ cacheApiOutbound @11 :ServiceDesignator;
574
+ # Where should cache API (i.e. caches.default and caches.open(...)) requests go?
575
+
576
+ durableObjectNamespaces @7 :List(DurableObjectNamespace);
577
+ # List of durable object namespaces in this Worker.
578
+
579
+ struct DurableObjectNamespace {
580
+ className @0 :Text;
581
+ # Exported class name that implements the Durable Object.
582
+ #
583
+ # Changing the class name will not break compatibility with existing storage, so long as
584
+ # `uniqueKey` stays the same.
585
+
586
+ union {
587
+ uniqueKey @1 :Text;
588
+ # A unique, stable ID associated with this namespace. This could be a GUID, or any other
589
+ # string which does not appear anywhere else in the world.
590
+ #
591
+ # This string is used to ensure that objects of this class have unique identifiers distinct
592
+ # from objects of any other class. Object IDs are cryptographically derived from `uniqueKey`
593
+ # and validated against it. It is impossible to guess or forge a valid object ID without
594
+ # knowing the `uniqueKey`. Hence, if you keep the key secret, you can prevent anyone from
595
+ # forging IDs. However, if you don't care if users can forge valid IDs, then it's not a big
596
+ # deal if the key leaks.
597
+ #
598
+ # DO NOT LOSE this key, otherwise it may be difficult or impossible to recover stored data.
599
+
600
+ ephemeralLocal @2 :Void;
601
+ # Instances of this class are ephemeral -- they have no durable storage at all. The
602
+ # `state.storage` API will not be present. Additionally, this namespace will allow arbitrary
603
+ # strings as IDs. There are no `idFromName()` nor `newUniqueId()` methods; `get()` takes any
604
+ # string as a parameter.
605
+ #
606
+ # Ephemeral objects are NOT globally unique, only "locally" unique, for some definition of
607
+ # "local". For example, on Cloudflare's network, these objects are unique per-colo.
608
+ #
609
+ # WARNING: Cloudflare Workers currently limits this feature to Cloudflare-internal users
610
+ # only, because using them correctly requires deep understanding of Cloudflare network
611
+ # topology. We're working on something better for public consuption. Until then for
612
+ # "ephemeral" use cases we recommend using regular durable objects and just not storing
613
+ # anything. An object that hasn't stored anything will not consume any storage space on
614
+ # disk.
615
+ }
616
+
617
+ preventEviction @3 :Bool;
618
+ # By default, Durable Objects are evicted after 10 seconds of inactivity, and expire 70 seconds
619
+ # after all clients have disconnected. Some applications may want to keep their Durable Objects
620
+ # pinned to memory forever, so we provide this flag to change the default behavior.
621
+ #
622
+ # Note that this is only supported in Workerd; production Durable Objects cannot toggle eviction.
623
+
624
+ enableSql @4 :Bool;
625
+ # Whether or not Durable Objects in this namespace can use the `storage.sql` API to execute SQL
626
+ # queries.
627
+ #
628
+ # workerd uses SQLite to back all Durable Objects, but the SQL API is hidden by default to
629
+ # emulate behavior of traditional DO namespaces on Cloudflare that aren't SQLite-backed. This
630
+ # flag should be enabled when testing code that will run on a SQLite-backed namespace.
631
+
632
+ container @5 :ContainerOptions;
633
+ # If present, Durable Objects in this namespace have attached containers.
634
+ # workerd will talk to the configured container engine to start containers for each
635
+ # Durable Object based on the given image. The Durable Object can access the container via the
636
+ # ctx.container API. TODO(CloudChamber): add link to docs.
637
+
638
+ struct ContainerOptions {
639
+ imageName @0 :Text;
640
+ # Image name to be used to create the container using supported provider.
641
+ # By default, we pull the "latest" tag of this image.
642
+ }
643
+ }
644
+
645
+ durableObjectUniqueKeyModifier @8 :Text;
646
+ # Additional text which is hashed together with `DurableObjectNamespace.uniqueKey`. When using
647
+ # worker inheritance, each derived worker must specify a unique modifier to ensure that its
648
+ # Durable Object instances have unique IDs from all other workers inheriting the same parent.
649
+ #
650
+ # DO NOT LOSE this value, otherwise it may be difficult or impossible to recover stored data.
651
+
652
+ durableObjectStorage :union {
653
+ # Specifies where this worker's Durable Objects are stored.
654
+
655
+ none @9 :Void;
656
+ # Default. The worker has no Durable Objects. `durableObjectNamespaces` must be empty, or
657
+ # define all namespaces as `ephemeralLocal`, or this must be an abstract worker (meant to be
658
+ # inherited by other workers, who will specify `durableObjectStorage`).
659
+
660
+ inMemory @10 :Void;
661
+ # The `state.storage` API stores in-memory only. All stored data will persist for the
662
+ # lifetime of the process, but will be lost upon process exit.
663
+ #
664
+ # Individual objects will still shut down when idle as normal -- only data stored with the
665
+ # `state.storage` interface is persistent for the lifetime of the process.
666
+ #
667
+ # This mode is intended for local testing purposes.
668
+
669
+ localDisk @12 :Text;
670
+ # ** EXPERIMENTAL; SUBJECT TO BACKWARDS-INCOMPATIBLE CHANGE **
671
+ #
672
+ # Durable Object data will be stored in a directory on local disk. This field is the name of
673
+ # a service, which must be a DiskDirectory service. For each Durable Object class, a
674
+ # subdirectory will be created using `uniqueKey` as the name. Within the directory, one or
675
+ # more files are created for each object, with names `<id>.<ext>`, where `.<ext>` may be any of
676
+ # a number of different extensions depending on the storage mode. (Currently, the main storage
677
+ # is a file with the extension `.sqlite`, and in certain situations extra files with the
678
+ # extensions `.sqlite-wal`, and `.sqlite-shm` may also be present.)
679
+ }
680
+
681
+ # TODO(someday): Support distributing objects across a cluster. At present, objects are always
682
+ # local to one instance of the runtime.
683
+
684
+ moduleFallback @13 :Text;
685
+
686
+ tails @14 :List(ServiceDesignator);
687
+ # List of tail worker services that should receive tail events for this worker.
688
+ # See: https://developers.cloudflare.com/workers/observability/logs/tail-workers/
689
+
690
+ streamingTails @15 :List(ServiceDesignator);
691
+ # List of streaming tail worker services that should receive tail events for this worker.
692
+ # NOTE: This will be deleted in a future refactor, do not depend on this.
693
+
694
+ containerEngine :union {
695
+ none @16 :Void;
696
+ # No container engine configured. Container operations will not be available.
697
+
698
+ localDocker @17 :DockerConfiguration;
699
+ # Use local Docker daemon for container operations.
700
+ # Only used for local development and testing purposes.
701
+ }
702
+
703
+ struct DockerConfiguration {
704
+ socketPath @0 :Text;
705
+ # Path to the Docker socket.
706
+ }
707
+ }
708
+
709
+ struct ExternalServer {
710
+ # Describes the ability to talk to a specific server, typically a back-end server available
711
+ # on the internal network.
712
+ #
713
+ # When a Worker contains a service binding that points to an ExternalServer, *all* fetch()
714
+ # calls on that binding will be delivered to that server, regardless of whether the hostname
715
+ # or protocol specified in the URL actually match the hostname or protocol used by the actual
716
+ # server. Typically, a Worker implementing a reverse proxy would use this to forward a request
717
+ # to a back-end application server. Such a back-end typically does not have a real public
718
+ # hostname, since it is only reachable through the proxy, but the requests forwarded to it will
719
+ # keep the hostname that was on the original request.
720
+ #
721
+ # Note that this also implies that regardless of whether the original URL was http: or https:,
722
+ # the request will be delivered to the target server using the protocol specified below. A
723
+ # header like `X-Forwarded-Proto` can be used to pass along the original protocol; see
724
+ # `HttpOptions`.
725
+
726
+ address @0 :Text;
727
+ # Address/port of the server. Optional; if not specified, then you will be required to specify
728
+ # the address on the command line with with `--external-addr <name>=<addr>`.
729
+ #
730
+ # Examples:
731
+ # - "1.2.3.4": Connect to the given IPv4 address on the protocol's default port.
732
+ # - "1.2.3.4:80": Connect to the given IPv4 address and port.
733
+ # - "1234:5678::abcd": Connect to the given IPv6 address on the protocol's default port.
734
+ # - "[1234:5678::abcd]:80": Connect to the given IPv6 address and port.
735
+ # - "unix:/path/to/socket": Connect to the given Unix Domain socket by path.
736
+ # - "unix-abstract:name": On Linux, connect to the given "abstract" Unix socket name.
737
+ # - "example.com:80": Perform a DNS lookup to determine the address, and then connect to it.
738
+ #
739
+ # (These are the formats supported by KJ's parseAddress().)
740
+
741
+ union {
742
+ http @1 :HttpOptions;
743
+ # Talk to the server over unencrypted HTTP.
744
+
745
+ https :group {
746
+ # Talk to the server over encrypted HTTPS.
747
+
748
+ options @2 :HttpOptions;
749
+ tlsOptions @3 :TlsOptions;
750
+
751
+ certificateHost @4 :Text;
752
+ # If present, expect the host to present a certificate authenticating it as this hostname.
753
+ # If `certificateHost` is not provided, then the certificate is checked against `address`.
754
+ }
755
+
756
+ tcp :group {
757
+ # Connect to the server over raw TCP. Bindings to this service will only support the
758
+ # `connect()` method; `fetch()` will throw an exception.
759
+ tlsOptions @5 :TlsOptions;
760
+ certificateHost @6 :Text;
761
+ }
762
+
763
+ # TODO(someday): Cap'n Proto RPC
764
+ }
765
+ }
766
+
767
+ struct Network {
768
+ # Describes the ability to talk to a network.
769
+ #
770
+ # This is commonly used to define the "internet" service which is the default `globalOutbound`
771
+ # for all Workers. To prevent SSRF, by default Workers will not be permitted to reach internal
772
+ # network addresses using global fetch(). It's recommended that you create ExternalServer
773
+ # bindings instead to grant access to specific servers. However, if you really want to, you
774
+ # can configure a service that grants arbitrary internal network access, like:
775
+ #
776
+ # ( name = "internalNetwork",
777
+ # network = (
778
+ # allow = ["public", "private"],
779
+ # )
780
+ # )
781
+
782
+ allow @0 :List(Text) = ["public"];
783
+ deny @1 :List(Text);
784
+ # Specifies which network addresses the Worker will be allowed to connect to, e.g. using fetch().
785
+ # The default allows publicly-routable IP addresses only, in order to prevent SSRF attacks.
786
+ #
787
+ # The allow and deny lists specify network blocks in CIDR notation (IPv4 and IPv6), such as
788
+ # "192.0.2.0/24" or "2001:db8::/32". Traffic will be permitted as long as the address
789
+ # matches at least one entry in the allow list and none in the deny list.
790
+ #
791
+ # In addition to IPv4 and IPv6 CIDR notation, several special strings may be specified:
792
+ # - "private": Matches network addresses that are reserved by standards for private networks,
793
+ # such as "10.0.0.0/8" or "192.168.0.0/16". This is a superset of "local".
794
+ # - "public": Opposite of "private".
795
+ # - "local": Matches network addresses that are defined by standards to only be accessible from
796
+ # the local machine, such as "127.0.0.0/8" or Unix domain addresses.
797
+ # - "network": Opposite of "local".
798
+ # - "unix": Matches all Unix domain socket addresses. (In the future, we may support specifying a
799
+ # glob to narrow this to specific paths.)
800
+ # - "unix-abstract": Matches Linux's "abstract unix domain" addresses. (In the future, we may
801
+ # support specifying a glob.)
802
+ #
803
+ # In the case that the Worker specifies a DNS hostname rather than a raw address, these rules are
804
+ # used to filter the addresses returned by the lookup. If none of the returned addresses turn
805
+ # out to be permitted, then the system will behave as if the DNS entry did not exist.
806
+ #
807
+ # (The above is exactly the format supported by kj::Network::restrictPeers().)
808
+
809
+ tlsOptions @2 :TlsOptions;
810
+ }
811
+
812
+ struct DiskDirectory {
813
+ # Configures access to a directory on disk. This is a type of service which will expose an HTTP
814
+ # interface to the directory content.
815
+ #
816
+ # This is very bare-bones, generally not suitable for serving a web site on its own. In
817
+ # particular, no attempt is made to guess the `Content-Type` header. You normally would wrap
818
+ # this in a Worker that fills in the metadata in the way you want.
819
+ #
820
+ # A GET request targeting a directory (rather than a file) will return a basic JSAN directory
821
+ # listing like:
822
+ #
823
+ # [{"name":"foo","type":"file"},{"name":"bar","type":"directory"}]
824
+ #
825
+ # Possible "type" values are "file", "directory", "symlink", "blockDevice", "characterDevice",
826
+ # "namedPipe", "socket", "other".
827
+ #
828
+ # `Content-Type` will be `application/octet-stream` for files or `application/json` for a
829
+ # directory listing. Files will have a `Content-Length` header, directories will not. Symlinks
830
+ # will be followed (but there is intentionally no way to create one, even if `writable` is
831
+ # `true`), and treated according to the type of file they point to. The other inode types cannot
832
+ # be opened; trying to do so will produce a "406 Not Acceptable" error (on the theory that there
833
+ # is no acceptable format for these, regardless of what the client says it accepts).
834
+ #
835
+ # `HEAD` requests are properly optimized to perform a stat() without actually opening the file.
836
+
837
+ path @0 :Text;
838
+ # The filesystem path of the directory. If not specified, then it must be specified on the
839
+ # command line with `--directory-path <service-name>=<path>`.
840
+ #
841
+ # Relative paths are interpreted relative to the current directory where the server is executed,
842
+ # NOT relative to the config file. So, you should usually use absolute paths in the config file.
843
+
844
+ writable @1 :Bool = false;
845
+ # Whether to support PUT requests for writing. A PUT will write to a temporary file which
846
+ # is atomically moved into place upon successful completion of the upload. Parent directories are
847
+ # created as needed.
848
+
849
+ allowDotfiles @2 :Bool = false;
850
+ # Whether to allow access to files and directories whose name starts with '.'. These are made
851
+ # inaccessible by default since they very often store metadata that is not meant to be served,
852
+ # e.g. a git repository or an `.htaccess` file.
853
+ #
854
+ # Note that the special links "." and ".." will never be accessible regardless of this setting.
855
+ }
856
+
857
+ # ========================================================================================
858
+ # Protocol options
859
+
860
+ struct HttpOptions {
861
+ # Options for using HTTP (as a client or server). In particular, this specifies behavior that is
862
+ # important in the presence of proxy servers, whether forward or reverse.
863
+
864
+ style @0 :Style = host;
865
+
866
+ enum Style {
867
+ host @0;
868
+ # Normal HTTP. The request line contains only the path, and the separate `Host` header
869
+ # specifies the hostname.
870
+
871
+ proxy @1;
872
+ # HTTP proxy protocol. The request line contains a full URL instead of a path. No `Host`
873
+ # header is required. This is the protocol used by HTTP forward proxies. This allows you to
874
+ # implement such a proxy as a Worker.
875
+ }
876
+
877
+ forwardedProtoHeader @1 :Text;
878
+ # If specified, then when the given header is present on a request, it specifies the protocol
879
+ # ("http" or "https") that was used by the original client. The request URL reported to the
880
+ # Worker will reflect this protocol. Otherwise, the URL will reflect the actual physical protocol
881
+ # used by the server in receiving the request.
882
+ #
883
+ # This option is useful when this server sits behind a reverse proxy that performs TLS
884
+ # termination. Typically such proxies forward the original protocol in a header named something
885
+ # like "X-Forwarded-Proto".
886
+ #
887
+ # This setting is ignored when `style` is `proxy`.
888
+
889
+ cfBlobHeader @2 :Text;
890
+ # If set, then the `request.cf` object will be encoded (as JSON) into / parsed from the header
891
+ # with this name. Otherwise, it will be discarded on send / `undefined` on receipt.
892
+
893
+ injectRequestHeaders @3 :List(Header);
894
+ # List of headers which will be automatically injected into all requests. This can be used
895
+ # e.g. to add an authorization token to all requests when using `ExternalServer`. It can also
896
+ # apply to incoming requests received on a `Socket` to modify the headers that will be delivered
897
+ # to the app. Any existing header with the same name is removed.
898
+
899
+ injectResponseHeaders @4 :List(Header);
900
+ # Same as `injectRequestHeaders` but for responses.
901
+
902
+ struct Header {
903
+ name @0 :Text;
904
+ # Case-insensitive.
905
+
906
+ value @1 :Text;
907
+ # If null, the header will be removed.
908
+ }
909
+
910
+ capnpConnectHost @5 :Text;
911
+ # A CONNECT request for this host+port will be treated as a request to form a Cap'n Proto RPC
912
+ # connection. The server will expose a WorkerdBootstrap as the bootstrap interface, allowing
913
+ # events to be delivered to the target worker via capnp. Clients will use capnp for non-HTTP
914
+ # event types (especially JSRPC).
915
+
916
+ # TODO(someday): When we support TCP, include an option to deliver CONNECT requests to the
917
+ # TCP handler.
918
+ }
919
+
920
+ struct TlsOptions {
921
+ # Options that apply when using TLS. Can apply on either the client or the server side, depending
922
+ # on the context.
923
+ #
924
+ # This is based on KJ's TlsContext::Options.
925
+
926
+ keypair @0 :Keypair;
927
+ # The default private key and certificate to use. Optional when acting as a client.
928
+
929
+ struct Keypair {
930
+ privateKey @0 :Text;
931
+ # Private key in PEM format. Supports PKCS8 keys as well as "traditional format" RSA and DSA
932
+ # keys.
933
+ #
934
+ # Remember that you can use Cap'n Proto's `embed` syntax to reference an external file.
935
+
936
+ certificateChain @1 :Text;
937
+ # Certificate chain in PEM format. A chain can be constructed by concatenating multiple
938
+ # PEM-encoded certificates, starting with the leaf certificate.
939
+ }
940
+
941
+ # TODO(someday): Support SNI-based keypair selection? Is a hostname -> keypair map good enough?
942
+ # Does it need to support wildcards? Maybe we should just let you provide a pile of certs and
943
+ # we can figure out which hosts each one matches?
944
+
945
+ requireClientCerts @1 :Bool = false;
946
+ # If true, then when acting as a server, incoming connections will be rejected unless they bear
947
+ # a certificate signed by one of the trusted CAs.
948
+ #
949
+ # Typically, when using this, you'd set `trustBrowserCas = false` and list a specific private CA
950
+ # in `trustedCertificates`.
951
+
952
+ trustBrowserCas @2 :Bool = false;
953
+ # If true, trust certificates which are signed by one of the CAs that browsers normally trust.
954
+ # You should typically set this true when talking to the public internet, but you may want to
955
+ # set it false when talking to servers on your internal network.
956
+
957
+ trustedCertificates @3 :List(Text);
958
+ # Additional CA certificates to trust, in PEM format. Remember that you can use Cap'n Proto's
959
+ # `embed` syntax to read the certificates from other files.
960
+
961
+ minVersion @4 :Version = goodDefault;
962
+ # Minimum TLS version that will be allowed. Generally you should not override this unless you
963
+ # have unusual backwards-compatibility needs.
964
+
965
+ enum Version {
966
+ goodDefault @0;
967
+ # A good default chosen by the code maintainers. May change over time.
968
+
969
+ ssl3 @1;
970
+ tls1Dot0 @2;
971
+ tls1Dot1 @3;
972
+ tls1Dot2 @4;
973
+ tls1Dot3 @5;
974
+ }
975
+
976
+ cipherList @5 :Text;
977
+ # OpenSSL cipher list string. The default is a curated list designed to be compatible with
978
+ # almost all software in current use (specifically, based on Mozilla's "intermediate"
979
+ # recommendations). The defaults will change in future versions of this software to account
980
+ # for the latest cryptanalysis.
981
+ #
982
+ # Generally you should only specify your own `cipherList` if:
983
+ # - You have extreme backwards-compatibility needs and wish to enable obsolete and/or broken
984
+ # algorithms.
985
+ # - You need quickly to disable an algorithm recently discovered to be broken.
986
+ }
987
+
988
+ # ========================================================================================
989
+ # Extensions
990
+
991
+ struct Extension {
992
+ # Additional capabilities for workers.
993
+
994
+ modules @0 :List(Module);
995
+ # List of javascript modules provided by the extension.
996
+ # These modules can either be imported directly as user-level api (if not marked internal)
997
+ # or used to define more complicated workerd constructs such as wrapped bindings and events.
998
+
999
+ struct Module {
1000
+ # A module extending workerd functionality.
1001
+
1002
+ name @0 :Text;
1003
+ # Full js module name.
1004
+
1005
+ internal @1 :Bool = false;
1006
+ # Internal modules can be imported by other extension modules only and not the user code.
1007
+
1008
+ esModule @2 :Text;
1009
+ # Raw source code of ES module.
1010
+ }
1011
+ }
1012
+
1013
+ # ========================================================================================
1014
+ # Fallback Service Request
1015
+ # Used only to define the JSON structure of a request to the fallback service.
1016
+
1017
+ struct FallbackServiceRequest {
1018
+ type @0 :Text;
1019
+ specifier @1 :Text;
1020
+ rawSpecifier @2 :Text;
1021
+ referrer @3 :Text;
1022
+
1023
+ struct Attribute {
1024
+ name @0: Text;
1025
+ value @1: Text;
1026
+ }
1027
+ attributes @4 :List(Attribute);
1028
+ }
worker/node_modules/wrangler/README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h1 align="center"> ⛅️ wrangler </h1>
2
+ <section align="center" id="shieldio-badges">
3
+ <a href="https://www.npmjs.com/package/wrangler"><img alt="npm" src="https://img.shields.io/npm/dw/wrangler?style=flat-square"></a>
4
+ <img alt="GitHub contributors" src="https://img.shields.io/github/contributors/cloudflare/workers-sdk?style=flat-square">
5
+ <img alt="GitHub commit activity (branch)" src="https://img.shields.io/github/commit-activity/w/cloudflare/workers-sdk/main?style=flat-square">
6
+ <a href="https://discord.cloudflare.com"><img alt="Discord" src="https://img.shields.io/discord/595317990191398933?color=%23F48120&style=flat-square"></a>
7
+ </section>
8
+
9
+ `wrangler` is a command line tool for building [Cloudflare Workers](https://workers.cloudflare.com/).
10
+
11
+ > [!WARNING]
12
+ >
13
+ > Wrangler v2 is **only receiving critical security updates.** We recommend you [migrate to Wrangler v3](https://developers.cloudflare.com/workers/wrangler/migration/update-v2-to-v3/) if you can.
14
+
15
+ ## Quick Start
16
+
17
+ To get started quickly with a Hello World worker, run the command below:
18
+
19
+ ```bash
20
+ npx wrangler init my-worker -y
21
+ ```
22
+
23
+ For more info, visit our [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/) guide.
24
+
25
+ ## Documentation
26
+
27
+ For the latest Wrangler documentation, [click here](https://developers.cloudflare.com/workers/wrangler/).
28
+
29
+ To read more about Workers in general:
30
+
31
+ - [Getting Started](https://developers.cloudflare.com/workers/get-started/guide/)
32
+ - [How Workers works](https://developers.cloudflare.com/workers/reference/how-workers-works/)
33
+ - [Observability](https://developers.cloudflare.com/workers/observability/)
34
+ - [Platform](https://developers.cloudflare.com/workers/platform/)
35
+
36
+ ## Configuration
37
+
38
+ Wrangler is configured via a `wrangler.toml` or `wrangler.json` file in the project root. An example configuration generated by `npx wrangler init` or `npx create cloudflare` is as follows:
39
+
40
+ ```toml
41
+ name = "my-worker"
42
+ main = "./src/index.ts"
43
+ compatibility_date = "YYYY-MM-DD"
44
+ ```
45
+
46
+ For more detailed information about configuration, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/configuration/).
47
+
48
+ ## Commands
49
+
50
+ ### Workers
51
+
52
+ #### `wrangler dev`
53
+
54
+ Start a local development server, with live reloading and devtools.
55
+
56
+ #### `wrangler deploy`
57
+
58
+ Publish the given script to Cloudflare's global network.
59
+
60
+ For more commands and options, refer to the [documentation](https://developers.cloudflare.com/workers/wrangler/commands/).
61
+
62
+ ### Pages
63
+
64
+ #### `wrangler pages dev [directory]`
65
+
66
+ Serves a static build asset directory.
67
+
68
+ Builds and runs functions from a `./functions` directory or uses a `_worker.js` file inside the static build asset directory.
69
+
70
+ For more commands and options, refer to the [documentation](https://developers.cloudflare.com/pages/platform/functions#develop-and-preview-locally) or run `wrangler pages dev --help`.
worker/node_modules/wrangler/bin/wrangler.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+ const { spawn } = require("child_process");
3
+ const path = require("path");
4
+
5
+ const MIN_NODE_VERSION = "16.13.0";
6
+
7
+ let wranglerProcess;
8
+
9
+ /**
10
+ * Executes ../wrangler-dist/cli.js
11
+ */
12
+ function runWrangler() {
13
+ if (semiver(process.versions.node, MIN_NODE_VERSION) < 0) {
14
+ // Note Volta and nvm are also recommended in the official docs:
15
+ // https://developers.cloudflare.com/workers/get-started/guide#2-install-the-workers-cli
16
+ console.error(
17
+ `Wrangler requires at least Node.js v${MIN_NODE_VERSION}. You are using v${process.versions.node}. Please update your version of Node.js.
18
+
19
+ Consider using a Node.js version manager such as https://volta.sh/ or https://github.com/nvm-sh/nvm.`
20
+ );
21
+ process.exitCode = 1;
22
+ return;
23
+ }
24
+
25
+ return spawn(
26
+ process.execPath,
27
+ [
28
+ "--no-warnings",
29
+ "--experimental-vm-modules",
30
+ ...process.execArgv,
31
+ path.join(__dirname, "../wrangler-dist/cli.js"),
32
+ ...process.argv.slice(2),
33
+ ],
34
+ {
35
+ stdio: ["inherit", "inherit", "inherit", "ipc"],
36
+ }
37
+ )
38
+ .on("exit", (code) =>
39
+ process.exit(code === undefined || code === null ? 0 : code)
40
+ )
41
+ .on("message", (message) => {
42
+ if (process.send) {
43
+ process.send(message);
44
+ }
45
+ })
46
+ .on("disconnect", () => {
47
+ if (process.disconnect) {
48
+ process.disconnect();
49
+ }
50
+ });
51
+ }
52
+
53
+ // semiver implementation via https://github.com/lukeed/semiver/blob/ae7eebe6053c96be63032b14fb0b68e2553fcac4/src/index.js
54
+
55
+ /**
56
+ MIT License
57
+
58
+ Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
59
+
60
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
61
+
62
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
63
+
64
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
65
+
66
+ */
67
+
68
+ var fn = new Intl.Collator(0, { numeric: 1 }).compare;
69
+
70
+ function semiver(a, b, bool) {
71
+ a = a.split(".");
72
+ b = b.split(".");
73
+
74
+ return (
75
+ fn(a[0], b[0]) ||
76
+ fn(a[1], b[1]) ||
77
+ ((b[2] = b.slice(2).join(".")),
78
+ (bool = /[.-]/.test((a[2] = a.slice(2).join(".")))),
79
+ bool == /[.-]/.test(b[2]) ? fn(a[2], b[2]) : bool ? -1 : 1)
80
+ );
81
+ }
82
+
83
+ // end semiver implementation
84
+
85
+ if (module === require.main) {
86
+ wranglerProcess = runWrangler();
87
+ process.on("SIGINT", () => {
88
+ wranglerProcess && wranglerProcess.kill();
89
+ });
90
+ process.on("SIGTERM", () => {
91
+ wranglerProcess && wranglerProcess.kill();
92
+ });
93
+ }
worker/node_modules/wrangler/config-schema.json ADDED
The diff for this file is too large to render. See raw diff
 
worker/node_modules/wrangler/kv-asset-handler.js ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "@cloudflare/kv-asset-handler";
worker/node_modules/wrangler/package.json ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "wrangler",
3
+ "version": "3.114.17",
4
+ "description": "Command-line interface for all things Cloudflare Workers",
5
+ "keywords": [
6
+ "wrangler",
7
+ "cloudflare",
8
+ "workers",
9
+ "cloudflare workers",
10
+ "edge",
11
+ "compute",
12
+ "serverless",
13
+ "serverless application",
14
+ "serverless module",
15
+ "wasm",
16
+ "web",
17
+ "assembly",
18
+ "webassembly",
19
+ "rust",
20
+ "emscripten",
21
+ "typescript",
22
+ "graphql",
23
+ "router",
24
+ "http",
25
+ "cli"
26
+ ],
27
+ "homepage": "https://github.com/cloudflare/workers-sdk#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/cloudflare/workers-sdk/issues"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/cloudflare/workers-sdk.git",
34
+ "directory": "packages/wrangler"
35
+ },
36
+ "license": "MIT OR Apache-2.0",
37
+ "author": "wrangler@cloudflare.com",
38
+ "main": "wrangler-dist/cli.js",
39
+ "types": "wrangler-dist/cli.d.ts",
40
+ "bin": {
41
+ "wrangler": "./bin/wrangler.js",
42
+ "wrangler2": "./bin/wrangler.js"
43
+ },
44
+ "files": [
45
+ "bin",
46
+ "miniflare-dist",
47
+ "wrangler-dist",
48
+ "templates",
49
+ "kv-asset-handler.js",
50
+ "config-schema.json"
51
+ ],
52
+ "dependencies": {
53
+ "@cloudflare/unenv-preset": "2.0.2",
54
+ "@esbuild-plugins/node-globals-polyfill": "0.2.3",
55
+ "@esbuild-plugins/node-modules-polyfill": "0.2.2",
56
+ "blake3-wasm": "2.1.5",
57
+ "esbuild": "0.17.19",
58
+ "path-to-regexp": "6.3.0",
59
+ "unenv": "2.0.0-rc.14",
60
+ "workerd": "1.20250718.0",
61
+ "@cloudflare/kv-asset-handler": "0.3.4",
62
+ "miniflare": "3.20250718.3"
63
+ },
64
+ "devDependencies": {
65
+ "@aws-sdk/client-s3": "^3.721.0",
66
+ "@cloudflare/types": "6.18.4",
67
+ "@cloudflare/workers-types": "^4.20250408.0",
68
+ "@cspotcode/source-map-support": "0.8.1",
69
+ "@iarna/toml": "^3.0.0",
70
+ "@microsoft/api-extractor": "^7.47.0",
71
+ "@sentry/node": "^7.86.0",
72
+ "@sentry/types": "^7.86.0",
73
+ "@sentry/utils": "^7.86.0",
74
+ "@types/command-exists": "^1.2.0",
75
+ "@types/glob-to-regexp": "^0.4.1",
76
+ "@types/is-ci": "^3.0.0",
77
+ "@types/javascript-time-ago": "^2.0.3",
78
+ "@types/mime": "^3.0.4",
79
+ "@types/minimatch": "^5.1.2",
80
+ "@types/node": "^18.19.75",
81
+ "@types/node-forge": "^1.3.11",
82
+ "@types/prompts": "^2.0.14",
83
+ "@types/resolve": "^1.20.6",
84
+ "@types/shell-quote": "^1.7.2",
85
+ "@types/signal-exit": "^3.0.1",
86
+ "@types/supports-color": "^8.1.1",
87
+ "@types/ws": "^8.5.7",
88
+ "@types/yargs": "^17.0.22",
89
+ "@vitest/ui": "~3.0.5",
90
+ "@webcontainer/env": "^1.1.0",
91
+ "chalk": "^5.2.0",
92
+ "chokidar": "^4.0.1",
93
+ "cli-table3": "^0.6.3",
94
+ "cmd-shim": "^4.1.0",
95
+ "command-exists": "^1.2.9",
96
+ "concurrently": "^8.2.2",
97
+ "date-fns": "^4.1.0",
98
+ "devtools-protocol": "^0.0.1182435",
99
+ "dotenv": "^16.3.1",
100
+ "execa": "^6.1.0",
101
+ "find-up": "^6.3.0",
102
+ "get-port": "^7.0.0",
103
+ "glob-to-regexp": "^0.4.1",
104
+ "https-proxy-agent": "7.0.2",
105
+ "is-ci": "^3.0.1",
106
+ "itty-time": "^1.0.6",
107
+ "javascript-time-ago": "^2.5.4",
108
+ "md5-file": "5.0.0",
109
+ "mime": "^3.0.0",
110
+ "minimatch": "^5.1.0",
111
+ "mock-socket": "^9.3.1",
112
+ "msw": "2.4.3",
113
+ "node-forge": "^1.3.1",
114
+ "open": "^8.4.0",
115
+ "p-queue": "^7.2.0",
116
+ "patch-console": "^1.0.0",
117
+ "pretty-bytes": "^6.0.0",
118
+ "prompts": "^2.4.2",
119
+ "resolve": "^1.22.8",
120
+ "rimraf": "^5.0.10",
121
+ "selfsigned": "^2.0.1",
122
+ "semiver": "^1.1.0",
123
+ "shell-quote": "^1.8.1",
124
+ "signal-exit": "^3.0.7",
125
+ "source-map": "^0.6.1",
126
+ "strip-ansi": "^7.1.0",
127
+ "supports-color": "^9.2.2",
128
+ "timeago.js": "^4.0.2",
129
+ "ts-dedent": "^2.2.0",
130
+ "ts-json-schema-generator": "^1.5.0",
131
+ "typescript": "^5.7.2",
132
+ "undici": "^5.28.5",
133
+ "update-check": "^1.5.4",
134
+ "vitest": "~3.0.5",
135
+ "vitest-websocket-mock": "^0.4.0",
136
+ "ws": "8.18.0",
137
+ "xdg-app-paths": "^8.3.0",
138
+ "xxhash-wasm": "^1.0.1",
139
+ "yargs": "^17.7.2",
140
+ "@cloudflare/cli": "1.1.1",
141
+ "@cloudflare/eslint-config-worker": "1.1.0",
142
+ "@cloudflare/pages-shared": "0.13.22",
143
+ "@cloudflare/workers-shared": "0.15.1",
144
+ "@cloudflare/workers-tsconfig": "0.0.0"
145
+ },
146
+ "peerDependencies": {
147
+ "@cloudflare/workers-types": "^4.20250408.0"
148
+ },
149
+ "peerDependenciesMeta": {
150
+ "@cloudflare/workers-types": {
151
+ "optional": true
152
+ }
153
+ },
154
+ "optionalDependencies": {
155
+ "fsevents": "~2.3.2",
156
+ "sharp": "^0.33.5"
157
+ },
158
+ "engines": {
159
+ "node": ">=16.17.0"
160
+ },
161
+ "volta": {
162
+ "extends": "../../package.json"
163
+ },
164
+ "workers-sdk": {
165
+ "prerelease": true
166
+ },
167
+ "scripts": {
168
+ "assert-git-version": "node -r esbuild-register scripts/assert-git-version.ts",
169
+ "build": "pnpm run clean && pnpm run bundle && pnpm run emit-types && pnpm run generate-json-schema",
170
+ "bundle": "node -r esbuild-register scripts/bundle.ts",
171
+ "check:lint": "eslint . --max-warnings=0",
172
+ "check:type": "tsc -p ./tsconfig.json && tsc -p ./templates/tsconfig.json",
173
+ "clean": "rimraf wrangler-dist miniflare-dist emitted-types",
174
+ "dev": "pnpm run clean && concurrently -c black,blue --kill-others-on-fail false \"pnpm run bundle --watch\" \"pnpm run check:type --watch --preserveWatchOutput\"",
175
+ "emit-types": "tsc -p tsconfig.emit.json && node -r esbuild-register scripts/emit-types.ts",
176
+ "generate-json-schema": "pnpm exec ts-json-schema-generator --no-type-check --path src/config/config.ts --type RawConfig --out config-schema.json",
177
+ "start": "pnpm run bundle && cross-env NODE_OPTIONS=--enable-source-maps ./bin/wrangler.js",
178
+ "test": "dotenv -- pnpm run assert-git-version && dotenv -- vitest",
179
+ "test:ci": "pnpm run test run",
180
+ "test:debug": "pnpm run test --silent=false --verbose=true",
181
+ "test:e2e": "dotenv -- vitest -c ./e2e/vitest.config.mts",
182
+ "test:watch": "pnpm run test --testTimeout=50000 --watch",
183
+ "type:tests": "tsc -p ./src/__tests__/tsconfig.json && tsc -p ./e2e/tsconfig.json"
184
+ }
185
+ }
worker/node_modules/wrangler/templates/checked-fetch.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const urls = new Set();
2
+
3
+ function checkURL(request, init) {
4
+ const url =
5
+ request instanceof URL
6
+ ? request
7
+ : new URL(
8
+ (typeof request === "string"
9
+ ? new Request(request, init)
10
+ : request
11
+ ).url
12
+ );
13
+ if (url.port && url.port !== "443" && url.protocol === "https:") {
14
+ if (!urls.has(url.toString())) {
15
+ urls.add(url.toString());
16
+ console.warn(
17
+ `WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:\n` +
18
+ ` - ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.\n`
19
+ );
20
+ }
21
+ }
22
+ }
23
+
24
+ globalThis.fetch = new Proxy(globalThis.fetch, {
25
+ apply(target, thisArg, argArray) {
26
+ const [request, init] = argArray;
27
+ checkURL(request, init);
28
+ return Reflect.apply(target, thisArg, argArray);
29
+ },
30
+ });
worker/node_modules/wrangler/templates/facade.d.ts ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ declare module "__ENTRY_POINT__" {
2
+ import { Middleware } from "./middleware/common";
3
+ import { WorkerEntrypoint } from "cloudflare:workers";
4
+
5
+ export type WorkerEntrypointConstructor = typeof WorkerEntrypoint;
6
+
7
+ const worker: ExportedHandler | WorkerEntrypointConstructor;
8
+ export default worker;
9
+ export const __INTERNAL_WRANGLER_MIDDLEWARE__: Middleware[];
10
+ }
11
+
12
+ declare module "__KV_ASSET_HANDLER__" {
13
+ export * from "@cloudflare/kv-asset-handler";
14
+ }
15
+
16
+ declare module "__STATIC_CONTENT_MANIFEST" {
17
+ const manifest: string;
18
+ export default manifest;
19
+ }
worker/node_modules/wrangler/templates/gitignore ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Logs
2
+
3
+ logs
4
+ _.log
5
+ npm-debug.log_
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ lerna-debug.log*
9
+ .pnpm-debug.log*
10
+
11
+ # Diagnostic reports (https://nodejs.org/api/report.html)
12
+
13
+ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14
+
15
+ # Runtime data
16
+
17
+ pids
18
+ _.pid
19
+ _.seed
20
+ \*.pid.lock
21
+
22
+ # Directory for instrumented libs generated by jscoverage/JSCover
23
+
24
+ lib-cov
25
+
26
+ # Coverage directory used by tools like istanbul
27
+
28
+ coverage
29
+ \*.lcov
30
+
31
+ # nyc test coverage
32
+
33
+ .nyc_output
34
+
35
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36
+
37
+ .grunt
38
+
39
+ # Bower dependency directory (https://bower.io/)
40
+
41
+ bower_components
42
+
43
+ # node-waf configuration
44
+
45
+ .lock-wscript
46
+
47
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
48
+
49
+ build/Release
50
+
51
+ # Dependency directories
52
+
53
+ node_modules/
54
+ jspm_packages/
55
+
56
+ # Snowpack dependency directory (https://snowpack.dev/)
57
+
58
+ web_modules/
59
+
60
+ # TypeScript cache
61
+
62
+ \*.tsbuildinfo
63
+
64
+ # Optional npm cache directory
65
+
66
+ .npm
67
+
68
+ # Optional eslint cache
69
+
70
+ .eslintcache
71
+
72
+ # Optional stylelint cache
73
+
74
+ .stylelintcache
75
+
76
+ # Microbundle cache
77
+
78
+ .rpt2_cache/
79
+ .rts2_cache_cjs/
80
+ .rts2_cache_es/
81
+ .rts2_cache_umd/
82
+
83
+ # Optional REPL history
84
+
85
+ .node_repl_history
86
+
87
+ # Output of 'npm pack'
88
+
89
+ \*.tgz
90
+
91
+ # Yarn Integrity file
92
+
93
+ .yarn-integrity
94
+
95
+ # dotenv environment variable files
96
+
97
+ .env
98
+ .env.development.local
99
+ .env.test.local
100
+ .env.production.local
101
+ .env.local
102
+
103
+ # parcel-bundler cache (https://parceljs.org/)
104
+
105
+ .cache
106
+ .parcel-cache
107
+
108
+ # Next.js build output
109
+
110
+ .next
111
+ out
112
+
113
+ # Nuxt.js build / generate output
114
+
115
+ .nuxt
116
+ dist
117
+
118
+ # Gatsby files
119
+
120
+ .cache/
121
+
122
+ # Comment in the public line in if your project uses Gatsby and not Next.js
123
+
124
+ # https://nextjs.org/blog/next-9-1#public-directory-support
125
+
126
+ # public
127
+
128
+ # vuepress build output
129
+
130
+ .vuepress/dist
131
+
132
+ # vuepress v2.x temp and cache directory
133
+
134
+ .temp
135
+ .cache
136
+
137
+ # Docusaurus cache and generated files
138
+
139
+ .docusaurus
140
+
141
+ # Serverless directories
142
+
143
+ .serverless/
144
+
145
+ # FuseBox cache
146
+
147
+ .fusebox/
148
+
149
+ # DynamoDB Local files
150
+
151
+ .dynamodb/
152
+
153
+ # TernJS port file
154
+
155
+ .tern-port
156
+
157
+ # Stores VSCode versions used for testing VSCode extensions
158
+
159
+ .vscode-test
160
+
161
+ # yarn v2
162
+
163
+ .yarn/cache
164
+ .yarn/unplugged
165
+ .yarn/build-state.yml
166
+ .yarn/install-state.gz
167
+ .pnp.\*
168
+
169
+ .wrangler
170
+ .DS_Store
worker/node_modules/wrangler/templates/init-tests/test-jest-new-worker.js ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { unstable_dev } = require("wrangler");
2
+
3
+ describe("Worker", () => {
4
+ let worker;
5
+
6
+ beforeAll(async () => {
7
+ worker = await unstable_dev("src/index.js", {
8
+ experimental: { disableExperimentalWarning: true },
9
+ });
10
+ });
11
+
12
+ afterAll(async () => {
13
+ await worker.stop();
14
+ });
15
+
16
+ it("should return Hello World", async () => {
17
+ const resp = await worker.fetch();
18
+ if (resp) {
19
+ const text = await resp.text();
20
+ expect(text).toMatchInlineSnapshot(`"Hello World!"`);
21
+ }
22
+ });
23
+ });
worker/node_modules/wrangler/templates/init-tests/test-vitest-new-worker.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
2
+ import { unstable_dev } from "wrangler";
3
+
4
+ describe("Worker", () => {
5
+ let worker;
6
+
7
+ beforeAll(async () => {
8
+ worker = await unstable_dev("src/index.js", {
9
+ experimental: { disableExperimentalWarning: true },
10
+ });
11
+ });
12
+
13
+ afterAll(async () => {
14
+ await worker.stop();
15
+ });
16
+
17
+ it("should return Hello World", async () => {
18
+ const resp = await worker.fetch();
19
+ if (resp) {
20
+ const text = await resp.text();
21
+ expect(text).toMatchInlineSnapshot(`"Hello World!"`);
22
+ }
23
+ });
24
+ });
worker/node_modules/wrangler/templates/init-tests/test-vitest-new-worker.ts ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
2
+ import { unstable_dev } from "wrangler";
3
+ import type { Unstable_DevWorker } from "wrangler";
4
+
5
+ describe("Worker", () => {
6
+ let worker: Unstable_DevWorker;
7
+
8
+ beforeAll(async () => {
9
+ worker = await unstable_dev("src/index.ts", {
10
+ experimental: { disableExperimentalWarning: true },
11
+ });
12
+ });
13
+
14
+ afterAll(async () => {
15
+ await worker.stop();
16
+ });
17
+
18
+ it("should return Hello World", async () => {
19
+ const resp = await worker.fetch();
20
+ if (resp) {
21
+ const text = await resp.text();
22
+ expect(text).toMatchInlineSnapshot(`"Hello World!"`);
23
+ }
24
+ });
25
+ });
worker/node_modules/wrangler/templates/middleware/common.ts ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export type Awaitable<T> = T | Promise<T>;
2
+ // TODO: allow dispatching more events?
3
+ export type Dispatcher = (
4
+ type: "scheduled",
5
+ init: { cron?: string }
6
+ ) => Awaitable<void>;
7
+
8
+ export type IncomingRequest = Request<
9
+ unknown,
10
+ IncomingRequestCfProperties<unknown>
11
+ >;
12
+
13
+ export interface MiddlewareContext {
14
+ dispatch: Dispatcher;
15
+ next(request: IncomingRequest, env: any): Awaitable<Response>;
16
+ }
17
+
18
+ export type Middleware = (
19
+ request: IncomingRequest,
20
+ env: any,
21
+ ctx: ExecutionContext,
22
+ middlewareCtx: MiddlewareContext
23
+ ) => Awaitable<Response>;
24
+
25
+ const __facade_middleware__: Middleware[] = [];
26
+
27
+ // The register functions allow for the insertion of one or many middleware,
28
+ // We register internal middleware first in the stack, but have no way of controlling
29
+ // the order that addMiddleware is run in service workers so need an internal function.
30
+ export function __facade_register__(...args: (Middleware | Middleware[])[]) {
31
+ __facade_middleware__.push(...args.flat());
32
+ }
33
+ export function __facade_registerInternal__(
34
+ ...args: (Middleware | Middleware[])[]
35
+ ) {
36
+ __facade_middleware__.unshift(...args.flat());
37
+ }
38
+
39
+ function __facade_invokeChain__(
40
+ request: IncomingRequest,
41
+ env: any,
42
+ ctx: ExecutionContext,
43
+ dispatch: Dispatcher,
44
+ middlewareChain: Middleware[]
45
+ ): Awaitable<Response> {
46
+ const [head, ...tail] = middlewareChain;
47
+ const middlewareCtx: MiddlewareContext = {
48
+ dispatch,
49
+ next(newRequest, newEnv) {
50
+ return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);
51
+ },
52
+ };
53
+ return head(request, env, ctx, middlewareCtx);
54
+ }
55
+
56
+ export function __facade_invoke__(
57
+ request: IncomingRequest,
58
+ env: any,
59
+ ctx: ExecutionContext,
60
+ dispatch: Dispatcher,
61
+ finalMiddleware: Middleware
62
+ ): Awaitable<Response> {
63
+ return __facade_invokeChain__(request, env, ctx, dispatch, [
64
+ ...__facade_middleware__,
65
+ finalMiddleware,
66
+ ]);
67
+ }
worker/node_modules/wrangler/templates/middleware/loader-modules.ts ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // This loads all middlewares exposed on the middleware object and then starts
2
+ // the invocation chain. The big idea is that we can add these to the middleware
3
+ // export dynamically through wrangler, or we can potentially let users directly
4
+ // add them as a sort of "plugin" system.
5
+
6
+ import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "__ENTRY_POINT__";
7
+ import { __facade_invoke__, __facade_register__, Dispatcher } from "./common";
8
+ import type { WorkerEntrypointConstructor } from "__ENTRY_POINT__";
9
+
10
+ // Preserve all the exports from the worker
11
+ export * from "__ENTRY_POINT__";
12
+
13
+ class __Facade_ScheduledController__ implements ScheduledController {
14
+ readonly #noRetry: ScheduledController["noRetry"];
15
+
16
+ constructor(
17
+ readonly scheduledTime: number,
18
+ readonly cron: string,
19
+ noRetry: ScheduledController["noRetry"]
20
+ ) {
21
+ this.#noRetry = noRetry;
22
+ }
23
+
24
+ noRetry() {
25
+ if (!(this instanceof __Facade_ScheduledController__)) {
26
+ throw new TypeError("Illegal invocation");
27
+ }
28
+ // Need to call native method immediately in case uncaught error thrown
29
+ this.#noRetry();
30
+ }
31
+ }
32
+
33
+ function wrapExportedHandler(worker: ExportedHandler): ExportedHandler {
34
+ // If we don't have any middleware defined, just return the handler as is
35
+ if (
36
+ __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
37
+ __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
38
+ ) {
39
+ return worker;
40
+ }
41
+ // Otherwise, register all middleware once
42
+ for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
43
+ __facade_register__(middleware);
44
+ }
45
+
46
+ const fetchDispatcher: ExportedHandlerFetchHandler = function (
47
+ request,
48
+ env,
49
+ ctx
50
+ ) {
51
+ if (worker.fetch === undefined) {
52
+ throw new Error("Handler does not export a fetch() function.");
53
+ }
54
+ return worker.fetch(request, env, ctx);
55
+ };
56
+
57
+ return {
58
+ ...worker,
59
+ fetch(request, env, ctx) {
60
+ const dispatcher: Dispatcher = function (type, init) {
61
+ if (type === "scheduled" && worker.scheduled !== undefined) {
62
+ const controller = new __Facade_ScheduledController__(
63
+ Date.now(),
64
+ init.cron ?? "",
65
+ () => {}
66
+ );
67
+ return worker.scheduled(controller, env, ctx);
68
+ }
69
+ };
70
+ return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
71
+ },
72
+ };
73
+ }
74
+
75
+ function wrapWorkerEntrypoint(
76
+ klass: WorkerEntrypointConstructor
77
+ ): WorkerEntrypointConstructor {
78
+ // If we don't have any middleware defined, just return the handler as is
79
+ if (
80
+ __INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
81
+ __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
82
+ ) {
83
+ return klass;
84
+ }
85
+ // Otherwise, register all middleware once
86
+ for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
87
+ __facade_register__(middleware);
88
+ }
89
+
90
+ // `extend`ing `klass` here so other RPC methods remain callable
91
+ return class extends klass {
92
+ #fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (
93
+ request,
94
+ env,
95
+ ctx
96
+ ) => {
97
+ this.env = env;
98
+ this.ctx = ctx;
99
+ if (super.fetch === undefined) {
100
+ throw new Error("Entrypoint class does not define a fetch() function.");
101
+ }
102
+ return super.fetch(request);
103
+ };
104
+
105
+ #dispatcher: Dispatcher = (type, init) => {
106
+ if (type === "scheduled" && super.scheduled !== undefined) {
107
+ const controller = new __Facade_ScheduledController__(
108
+ Date.now(),
109
+ init.cron ?? "",
110
+ () => {}
111
+ );
112
+ return super.scheduled(controller);
113
+ }
114
+ };
115
+
116
+ fetch(request: Request<unknown, IncomingRequestCfProperties>) {
117
+ return __facade_invoke__(
118
+ request,
119
+ this.env,
120
+ this.ctx,
121
+ this.#dispatcher,
122
+ this.#fetchDispatcher
123
+ );
124
+ }
125
+ };
126
+ }
127
+
128
+ let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;
129
+ if (typeof ENTRY === "object") {
130
+ WRAPPED_ENTRY = wrapExportedHandler(ENTRY);
131
+ } else if (typeof ENTRY === "function") {
132
+ WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY);
133
+ }
134
+ export default WRAPPED_ENTRY;
worker/node_modules/wrangler/templates/middleware/loader-sw.ts ADDED
@@ -0,0 +1,229 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import {
2
+ __facade_invoke__,
3
+ __facade_register__,
4
+ __facade_registerInternal__,
5
+ Awaitable,
6
+ Dispatcher,
7
+ IncomingRequest,
8
+ Middleware,
9
+ } from "./common";
10
+
11
+ export { __facade_register__, __facade_registerInternal__ };
12
+
13
+ // Miniflare 2's `EventTarget` follows the spec and doesn't allow exceptions to
14
+ // be caught by `dispatchEvent`. Instead it has a custom `ThrowingEventTarget`
15
+ // class that rethrows errors from event listeners in `dispatchEvent`.
16
+ // We'd like errors to be propagated to the top-level `addEventListener`, so
17
+ // we'd like to use `ThrowingEventTarget`. Unfortunately, `ThrowingEventTarget`
18
+ // isn't exposed on the global scope, but `WorkerGlobalScope` (which extends
19
+ // `ThrowingEventTarget`) is. Therefore, we get at it in this nasty way.
20
+ let __FACADE_EVENT_TARGET__: EventTarget;
21
+ if ((globalThis as any).MINIFLARE) {
22
+ __FACADE_EVENT_TARGET__ = new (Object.getPrototypeOf(WorkerGlobalScope))();
23
+ } else {
24
+ __FACADE_EVENT_TARGET__ = new EventTarget();
25
+ }
26
+
27
+ function __facade_isSpecialEvent__(
28
+ type: string
29
+ ): type is "fetch" | "scheduled" {
30
+ return type === "fetch" || type === "scheduled";
31
+ }
32
+ const __facade__originalAddEventListener__ = globalThis.addEventListener;
33
+ const __facade__originalRemoveEventListener__ = globalThis.removeEventListener;
34
+ const __facade__originalDispatchEvent__ = globalThis.dispatchEvent;
35
+
36
+ globalThis.addEventListener = function (type, listener, options) {
37
+ if (__facade_isSpecialEvent__(type)) {
38
+ __FACADE_EVENT_TARGET__.addEventListener(
39
+ type,
40
+ listener as EventListenerOrEventListenerObject,
41
+ options
42
+ );
43
+ } else {
44
+ __facade__originalAddEventListener__(type, listener, options);
45
+ }
46
+ };
47
+ globalThis.removeEventListener = function (type, listener, options) {
48
+ if (__facade_isSpecialEvent__(type)) {
49
+ __FACADE_EVENT_TARGET__.removeEventListener(
50
+ type,
51
+ listener as EventListenerOrEventListenerObject,
52
+ options
53
+ );
54
+ } else {
55
+ __facade__originalRemoveEventListener__(type, listener, options);
56
+ }
57
+ };
58
+ globalThis.dispatchEvent = function (event) {
59
+ if (__facade_isSpecialEvent__(event.type)) {
60
+ return __FACADE_EVENT_TARGET__.dispatchEvent(event);
61
+ } else {
62
+ return __facade__originalDispatchEvent__(event);
63
+ }
64
+ };
65
+
66
+ declare global {
67
+ var addMiddleware: typeof __facade_register__;
68
+ var addMiddlewareInternal: typeof __facade_registerInternal__;
69
+ }
70
+ globalThis.addMiddleware = __facade_register__;
71
+ globalThis.addMiddlewareInternal = __facade_registerInternal__;
72
+
73
+ const __facade_waitUntil__ = Symbol("__facade_waitUntil__");
74
+ const __facade_response__ = Symbol("__facade_response__");
75
+ const __facade_dispatched__ = Symbol("__facade_dispatched__");
76
+
77
+ class __Facade_ExtendableEvent__ extends Event {
78
+ [__facade_waitUntil__]: Awaitable<unknown>[] = [];
79
+
80
+ waitUntil(promise: Awaitable<any>) {
81
+ if (!(this instanceof __Facade_ExtendableEvent__)) {
82
+ throw new TypeError("Illegal invocation");
83
+ }
84
+ this[__facade_waitUntil__].push(promise);
85
+ }
86
+ }
87
+
88
+ interface FetchEventInit extends EventInit {
89
+ request: Request;
90
+ passThroughOnException: FetchEvent["passThroughOnException"];
91
+ }
92
+
93
+ class __Facade_FetchEvent__ extends __Facade_ExtendableEvent__ {
94
+ #request: Request;
95
+ #passThroughOnException: FetchEvent["passThroughOnException"];
96
+ [__facade_response__]?: Awaitable<Response>;
97
+ [__facade_dispatched__] = false;
98
+
99
+ constructor(type: "fetch", init: FetchEventInit) {
100
+ super(type);
101
+ this.#request = init.request;
102
+ this.#passThroughOnException = init.passThroughOnException;
103
+ }
104
+
105
+ get request() {
106
+ return this.#request;
107
+ }
108
+
109
+ respondWith(response: Awaitable<Response>) {
110
+ if (!(this instanceof __Facade_FetchEvent__)) {
111
+ throw new TypeError("Illegal invocation");
112
+ }
113
+ if (this[__facade_response__] !== undefined) {
114
+ throw new DOMException(
115
+ "FetchEvent.respondWith() has already been called; it can only be called once.",
116
+ "InvalidStateError"
117
+ );
118
+ }
119
+ if (this[__facade_dispatched__]) {
120
+ throw new DOMException(
121
+ "Too late to call FetchEvent.respondWith(). It must be called synchronously in the event handler.",
122
+ "InvalidStateError"
123
+ );
124
+ }
125
+ this.stopImmediatePropagation();
126
+ this[__facade_response__] = response;
127
+ }
128
+
129
+ passThroughOnException() {
130
+ if (!(this instanceof __Facade_FetchEvent__)) {
131
+ throw new TypeError("Illegal invocation");
132
+ }
133
+ // Need to call native method immediately in case uncaught error thrown
134
+ this.#passThroughOnException();
135
+ }
136
+ }
137
+
138
+ interface ScheduledEventInit extends EventInit {
139
+ scheduledTime: number;
140
+ cron: string;
141
+ noRetry: ScheduledEvent["noRetry"];
142
+ }
143
+
144
+ class __Facade_ScheduledEvent__ extends __Facade_ExtendableEvent__ {
145
+ #scheduledTime: number;
146
+ #cron: string;
147
+ #noRetry: ScheduledEvent["noRetry"];
148
+
149
+ constructor(type: "scheduled", init: ScheduledEventInit) {
150
+ super(type);
151
+ this.#scheduledTime = init.scheduledTime;
152
+ this.#cron = init.cron;
153
+ this.#noRetry = init.noRetry;
154
+ }
155
+
156
+ get scheduledTime() {
157
+ return this.#scheduledTime;
158
+ }
159
+
160
+ get cron() {
161
+ return this.#cron;
162
+ }
163
+
164
+ noRetry() {
165
+ if (!(this instanceof __Facade_ScheduledEvent__)) {
166
+ throw new TypeError("Illegal invocation");
167
+ }
168
+ // Need to call native method immediately in case uncaught error thrown
169
+ this.#noRetry();
170
+ }
171
+ }
172
+
173
+ __facade__originalAddEventListener__("fetch", (event) => {
174
+ const ctx: ExecutionContext = {
175
+ waitUntil: event.waitUntil.bind(event),
176
+ passThroughOnException: event.passThroughOnException.bind(event),
177
+ };
178
+
179
+ const __facade_sw_dispatch__: Dispatcher = function (type, init) {
180
+ if (type === "scheduled") {
181
+ const facadeEvent = new __Facade_ScheduledEvent__("scheduled", {
182
+ scheduledTime: Date.now(),
183
+ cron: init.cron ?? "",
184
+ noRetry() {},
185
+ });
186
+
187
+ __FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
188
+ event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
189
+ }
190
+ };
191
+
192
+ const __facade_sw_fetch__: Middleware = function (request, _env, ctx) {
193
+ const facadeEvent = new __Facade_FetchEvent__("fetch", {
194
+ request,
195
+ passThroughOnException: ctx.passThroughOnException,
196
+ });
197
+
198
+ __FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
199
+ facadeEvent[__facade_dispatched__] = true;
200
+ event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
201
+
202
+ const response = facadeEvent[__facade_response__];
203
+ if (response === undefined) {
204
+ throw new Error("No response!"); // TODO: proper error message
205
+ }
206
+ return response;
207
+ };
208
+
209
+ event.respondWith(
210
+ __facade_invoke__(
211
+ event.request as IncomingRequest,
212
+ globalThis,
213
+ ctx,
214
+ __facade_sw_dispatch__,
215
+ __facade_sw_fetch__
216
+ )
217
+ );
218
+ });
219
+
220
+ __facade__originalAddEventListener__("scheduled", (event) => {
221
+ const facadeEvent = new __Facade_ScheduledEvent__("scheduled", {
222
+ scheduledTime: event.scheduledTime,
223
+ cron: event.cron,
224
+ noRetry: event.noRetry.bind(event),
225
+ });
226
+
227
+ __FACADE_EVENT_TARGET__.dispatchEvent(facadeEvent);
228
+ event.waitUntil(Promise.all(facadeEvent[__facade_waitUntil__]));
229
+ });
worker/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Middleware } from "./common";
2
+
3
+ const drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {
4
+ try {
5
+ return await middlewareCtx.next(request, env);
6
+ } finally {
7
+ try {
8
+ if (request.body !== null && !request.bodyUsed) {
9
+ const reader = request.body.getReader();
10
+ while (!(await reader.read()).done) {}
11
+ }
12
+ } catch (e) {
13
+ console.error("Failed to drain the unused request body.", e);
14
+ }
15
+ }
16
+ };
17
+
18
+ export default drainBody;
worker/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Middleware } from "./common";
2
+
3
+ interface JsonError {
4
+ message?: string;
5
+ name?: string;
6
+ stack?: string;
7
+ cause?: JsonError;
8
+ }
9
+
10
+ function reduceError(e: any): JsonError {
11
+ return {
12
+ name: e?.name,
13
+ message: e?.message ?? String(e),
14
+ stack: e?.stack,
15
+ cause: e?.cause === undefined ? undefined : reduceError(e.cause),
16
+ };
17
+ }
18
+
19
+ // See comment in `bundle.ts` for details on why this is needed
20
+ const jsonError: Middleware = async (request, env, _ctx, middlewareCtx) => {
21
+ try {
22
+ return await middlewareCtx.next(request, env);
23
+ } catch (e: any) {
24
+ const error = reduceError(e);
25
+ return Response.json(error, {
26
+ status: 500,
27
+ headers: { "MF-Experimental-Error-Stack": "true" },
28
+ });
29
+ }
30
+ };
31
+
32
+ export default jsonError;
worker/node_modules/wrangler/templates/middleware/middleware-mock-analytics-engine.d.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ declare module "config:middleware/mock-analytics-engine" {
2
+ export const bindings: string[];
3
+ }
worker/node_modules/wrangler/templates/middleware/middleware-mock-analytics-engine.ts ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference path="middleware-mock-analytics-engine.d.ts"/>
2
+
3
+ import { bindings } from "config:middleware/mock-analytics-engine";
4
+ import type { Middleware } from "./common";
5
+
6
+ const bindingsEnv = Object.fromEntries(
7
+ bindings.map((binding) => [
8
+ binding,
9
+ {
10
+ writeDataPoint() {
11
+ // no op in dev
12
+ },
13
+ },
14
+ ])
15
+ ) satisfies Record<string, AnalyticsEngineDataset>;
16
+
17
+ const analyticsEngine: Middleware = async (
18
+ request,
19
+ env,
20
+ _ctx,
21
+ middlewareCtx
22
+ ) => {
23
+ // we're going to directly modify env so it maintains referential equality
24
+ for (const binding of bindings) {
25
+ env[binding] ??= bindingsEnv[binding];
26
+ }
27
+ return await middlewareCtx.next(request, env);
28
+ };
29
+
30
+ export default analyticsEngine;
worker/node_modules/wrangler/templates/modules-watch-stub.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ // `esbuild` doesn't support returning `watch*` options from `onStart()`
2
+ // plugin callbacks. Instead, we define an empty virtual module that is
3
+ // imported by this injected file. Importing the module registers watchers.
4
+ import "wrangler:modules-watch";
worker/node_modules/wrangler/templates/new-worker-scheduled.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Welcome to Cloudflare Workers! This is your first scheduled worker.
3
+ *
4
+ * - Run `wrangler dev --local` in your terminal to start a development server
5
+ * - Run `curl "http://localhost:8787/cdn-cgi/mf/scheduled"` to trigger the scheduled event
6
+ * - Go back to the console to see what your worker has logged
7
+ * - Update the Cron trigger in wrangler.toml (see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers)
8
+ * - Run `wrangler publish --name my-worker` to publish your worker
9
+ *
10
+ * Learn more at https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/
11
+ */
12
+
13
+ export default {
14
+ async scheduled(controller, env, ctx) {
15
+ console.log(`Hello World!`);
16
+ },
17
+ };
worker/node_modules/wrangler/templates/new-worker-scheduled.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Welcome to Cloudflare Workers! This is your first scheduled worker.
3
+ *
4
+ * - Run `wrangler dev --local` in your terminal to start a development server
5
+ * - Run `curl "http://localhost:8787/cdn-cgi/mf/scheduled"` to trigger the scheduled event
6
+ * - Go back to the console to see what your worker has logged
7
+ * - Update the Cron trigger in wrangler.toml (see https://developers.cloudflare.com/workers/wrangler/configuration/#triggers)
8
+ * - Run `wrangler deploy --name my-worker` to deploy your worker
9
+ *
10
+ * Learn more at https://developers.cloudflare.com/workers/runtime-apis/scheduled-event/
11
+ */
12
+
13
+ export interface Env {
14
+ // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
15
+ // MY_KV_NAMESPACE: KVNamespace;
16
+ //
17
+ // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
18
+ // MY_DURABLE_OBJECT: DurableObjectNamespace;
19
+ //
20
+ // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
21
+ // MY_BUCKET: R2Bucket;
22
+ }
23
+
24
+ export default {
25
+ async scheduled(
26
+ controller: ScheduledController,
27
+ env: Env,
28
+ ctx: ExecutionContext
29
+ ): Promise<void> {
30
+ console.log(`Hello World!`);
31
+ },
32
+ };
worker/node_modules/wrangler/templates/new-worker.js ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Welcome to Cloudflare Workers! This is your first worker.
3
+ *
4
+ * - Run `npx wrangler dev src/index.js` in your terminal to start a development server
5
+ * - Open a browser tab at http://localhost:8787/ to see your worker in action
6
+ * - Run `npx wrangler publish src/index.js --name my-worker` to publish your worker
7
+ *
8
+ * Learn more at https://developers.cloudflare.com/workers/
9
+ */
10
+
11
+ export default {
12
+ async fetch(request, env, ctx) {
13
+ return new Response("Hello World!");
14
+ },
15
+ };
worker/node_modules/wrangler/templates/new-worker.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Welcome to Cloudflare Workers! This is your first worker.
3
+ *
4
+ * - Run `wrangler dev src/index.ts` in your terminal to start a development server
5
+ * - Open a browser tab at http://localhost:8787/ to see your worker in action
6
+ * - Run `wrangler deploy src/index.ts --name my-worker` to deploy your worker
7
+ *
8
+ * Learn more at https://developers.cloudflare.com/workers/
9
+ */
10
+
11
+ export interface Env {
12
+ // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
13
+ // MY_KV_NAMESPACE: KVNamespace;
14
+ //
15
+ // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
16
+ // MY_DURABLE_OBJECT: DurableObjectNamespace;
17
+ //
18
+ // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/
19
+ // MY_BUCKET: R2Bucket;
20
+ //
21
+ // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/
22
+ // MY_SERVICE: Fetcher;
23
+ }
24
+
25
+ export default {
26
+ async fetch(
27
+ request: Request,
28
+ env: Env,
29
+ ctx: ExecutionContext
30
+ ): Promise<Response> {
31
+ return new Response("Hello World!");
32
+ },
33
+ };
worker/node_modules/wrangler/templates/no-op-worker.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ export default {
2
+ fetch() {
3
+ return new Response("Not found", {
4
+ status: 404,
5
+ headers: {
6
+ "Content-Type": "text/html",
7
+ },
8
+ });
9
+ },
10
+ };
worker/node_modules/wrangler/templates/pages-dev-pipeline.ts ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-ignore entry point will get replaced
2
+ import worker from "__ENTRY_POINT__";
3
+ import { isRoutingRuleMatch } from "./pages-dev-util";
4
+
5
+ // @ts-ignore entry point will get replaced
6
+ export * from "__ENTRY_POINT__";
7
+
8
+ // @ts-ignore routes are injected
9
+ const routes = __ROUTES__;
10
+
11
+ export default <ExportedHandler<{ ASSETS: Fetcher }>>{
12
+ fetch(request, env, context) {
13
+ const { pathname } = new URL(request.url);
14
+
15
+ for (const exclude of routes.exclude) {
16
+ if (isRoutingRuleMatch(pathname, exclude)) {
17
+ return env.ASSETS.fetch(request);
18
+ }
19
+ }
20
+
21
+ for (const include of routes.include) {
22
+ if (isRoutingRuleMatch(pathname, include)) {
23
+ const workerAsHandler = worker as ExportedHandler;
24
+ if (workerAsHandler.fetch === undefined) {
25
+ throw new TypeError("Entry point missing `fetch` handler");
26
+ }
27
+ return workerAsHandler.fetch(request, env, context);
28
+ }
29
+ }
30
+
31
+ return env.ASSETS.fetch(request);
32
+ },
33
+ };
worker/node_modules/wrangler/templates/pages-dev-util.ts ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @param pathname A pathname string, such as `/foo` or `/foo/bar`
3
+ * @param routingRule The routing rule, such as `/foo/*`
4
+ * @returns True if pathname matches the routing rule
5
+ *
6
+ * / -> /
7
+ * /* -> /*
8
+ * /foo -> /foo
9
+ * /foo* -> /foo, /foo-bar, /foo/*
10
+ * /foo/* -> /foo, /foo/bar
11
+ */
12
+ export function isRoutingRuleMatch(
13
+ pathname: string,
14
+ routingRule: string
15
+ ): boolean {
16
+ // sanity checks
17
+ if (!pathname) {
18
+ throw new Error("Pathname is undefined.");
19
+ }
20
+ if (!routingRule) {
21
+ throw new Error("Routing rule is undefined.");
22
+ }
23
+
24
+ const ruleRegExp = transformRoutingRuleToRegExp(routingRule);
25
+ return pathname.match(ruleRegExp) !== null;
26
+ }
27
+
28
+ function transformRoutingRuleToRegExp(rule: string): RegExp {
29
+ let transformedRule;
30
+
31
+ if (rule === "/" || rule === "/*") {
32
+ transformedRule = rule;
33
+ } else if (rule.endsWith("/*")) {
34
+ // make `/*` an optional group so we can match both /foo/* and /foo
35
+ // /foo/* => /foo(/*)?
36
+ transformedRule = `${rule.substring(0, rule.length - 2)}(/*)?`;
37
+ } else if (rule.endsWith("/")) {
38
+ // make `/` an optional group so we can match both /foo/ and /foo
39
+ // /foo/ => /foo(/)?
40
+ transformedRule = `${rule.substring(0, rule.length - 1)}(/)?`;
41
+ } else if (rule.endsWith("*")) {
42
+ transformedRule = rule;
43
+ } else {
44
+ transformedRule = `${rule}(/)?`;
45
+ }
46
+
47
+ // /foo* => /foo.* => ^/foo.*$
48
+ // /*.* => /*\.* => /.*\..* => ^/.*\..*$
49
+ transformedRule = `^${transformedRule
50
+ .replaceAll(/\./g, "\\.")
51
+ .replaceAll(/\*/g, ".*")}$`;
52
+
53
+ // ^/foo.*$ => /^\/foo.*$/
54
+ return new RegExp(transformedRule);
55
+ }
worker/node_modules/wrangler/templates/pages-shim.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ // This Worker is used as a default when no Pages Functions are present.
2
+ // It proxies the request directly on to the asset server binding.
3
+
4
+ export default <ExportedHandler<{ ASSETS: Fetcher }>>{
5
+ async fetch(request, env, context) {
6
+ const response = await env.ASSETS.fetch(request.url, request);
7
+ return new Response(response.body, response);
8
+ },
9
+ };
worker/node_modules/wrangler/templates/pages-template-plugin.ts ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { match } from "path-to-regexp";
2
+
3
+ //note: this explicitly does not include the * character, as pages requires this
4
+ const escapeRegex = /[.+?^${}()|[\]\\]/g;
5
+
6
+ type HTTPMethod =
7
+ | "HEAD"
8
+ | "OPTIONS"
9
+ | "GET"
10
+ | "POST"
11
+ | "PUT"
12
+ | "PATCH"
13
+ | "DELETE";
14
+
15
+ /* TODO: Grab these from @cloudflare/workers-types instead */
16
+ type Params<P extends string = string> = Record<P, string | string[]>;
17
+
18
+ type EventContext<Env, P extends string, Data> = {
19
+ request: Request;
20
+ functionPath: string;
21
+ waitUntil: (promise: Promise<unknown>) => void;
22
+ passThroughOnException: () => void;
23
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
24
+ env: Env & { ASSETS: { fetch: typeof fetch } };
25
+ params: Params<P>;
26
+ data: Data;
27
+ };
28
+
29
+ type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
30
+ request: Request;
31
+ functionPath: string;
32
+ waitUntil: (promise: Promise<unknown>) => void;
33
+ passThroughOnException: () => void;
34
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
35
+ env: Env & { ASSETS: { fetch: typeof fetch } };
36
+ params: Params<P>;
37
+ data: Data;
38
+ pluginArgs: PluginArgs;
39
+ };
40
+
41
+ declare type PagesFunction<
42
+ Env = unknown,
43
+ P extends string = string,
44
+ Data extends Record<string, unknown> = Record<string, unknown>,
45
+ > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
46
+
47
+ declare type PagesPluginFunction<
48
+ Env = unknown,
49
+ P extends string = string,
50
+ Data extends Record<string, unknown> = Record<string, unknown>,
51
+ PluginArgs = unknown,
52
+ > = (
53
+ context: EventPluginContext<Env, P, Data, PluginArgs>
54
+ ) => Response | Promise<Response>;
55
+ /* end @cloudflare/workers-types */
56
+
57
+ type RouteHandler = {
58
+ routePath: string;
59
+ mountPath: string;
60
+ method?: HTTPMethod;
61
+ modules: PagesFunction[];
62
+ middlewares: PagesFunction[];
63
+ };
64
+
65
+ // inject `routes` via ESBuild
66
+ declare const routes: RouteHandler[];
67
+
68
+ function* executeRequest(request: Request, relativePathname: string) {
69
+ // First, iterate through the routes (backwards) and execute "middlewares" on partial route matches
70
+ for (const route of [...routes].reverse()) {
71
+ if (route.method && route.method !== request.method) {
72
+ continue;
73
+ }
74
+
75
+ // replaces with "\\$&", this prepends a backslash to the matched string, e.g. "[" becomes "\["
76
+ const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
77
+ end: false,
78
+ });
79
+ const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
80
+ end: false,
81
+ });
82
+ const matchResult = routeMatcher(relativePathname);
83
+ const mountMatchResult = mountMatcher(relativePathname);
84
+ if (matchResult && mountMatchResult) {
85
+ for (const handler of route.middlewares.flat()) {
86
+ yield {
87
+ handler,
88
+ params: matchResult.params as Params,
89
+ path: mountMatchResult.path,
90
+ };
91
+ }
92
+ }
93
+ }
94
+
95
+ // Then look for the first exact route match and execute its "modules"
96
+ for (const route of routes) {
97
+ if (route.method && route.method !== request.method) {
98
+ continue;
99
+ }
100
+
101
+ const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
102
+ end: true,
103
+ });
104
+ const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
105
+ end: false,
106
+ });
107
+ const matchResult = routeMatcher(relativePathname);
108
+ const mountMatchResult = mountMatcher(relativePathname);
109
+ if (matchResult && mountMatchResult && route.modules.length) {
110
+ for (const handler of route.modules.flat()) {
111
+ yield {
112
+ handler,
113
+ params: matchResult.params as Params,
114
+ path: matchResult.path,
115
+ };
116
+ }
117
+ break;
118
+ }
119
+ }
120
+ }
121
+
122
+ export default function (pluginArgs: unknown) {
123
+ const onRequest: PagesPluginFunction = async (workerContext) => {
124
+ let { request } = workerContext;
125
+ const { env, next } = workerContext;
126
+ let { data } = workerContext;
127
+
128
+ const url = new URL(request.url);
129
+ // TODO: Replace this with something actually legible.
130
+ const relativePathname = `/${
131
+ url.pathname.replace(workerContext.functionPath, "") || ""
132
+ }`.replace(/^\/\//, "/");
133
+
134
+ const handlerIterator = executeRequest(request, relativePathname);
135
+ const pluginNext = async (input?: RequestInfo, init?: RequestInit) => {
136
+ if (input !== undefined) {
137
+ let url = input;
138
+ if (typeof input === "string") {
139
+ url = new URL(input, request.url).toString();
140
+ }
141
+ request = new Request(url, init);
142
+ }
143
+
144
+ const result = handlerIterator.next();
145
+ // Note we can't use `!result.done` because this doesn't narrow to the correct type
146
+ if (result.done === false) {
147
+ const { handler, params, path } = result.value;
148
+ const context = {
149
+ request: new Request(request.clone()),
150
+ functionPath: workerContext.functionPath + path,
151
+ next: pluginNext,
152
+ params,
153
+ get data() {
154
+ return data;
155
+ },
156
+ set data(value) {
157
+ if (typeof value !== "object" || value === null) {
158
+ throw new Error("context.data must be an object");
159
+ }
160
+ // user has overriden context.data, so we need to merge it with the existing data
161
+ data = value;
162
+ },
163
+ pluginArgs,
164
+ env,
165
+ waitUntil: workerContext.waitUntil.bind(workerContext),
166
+ passThroughOnException:
167
+ workerContext.passThroughOnException.bind(workerContext),
168
+ };
169
+
170
+ const response = await handler(context);
171
+
172
+ return cloneResponse(response);
173
+ } else {
174
+ return next(request);
175
+ }
176
+ };
177
+
178
+ return pluginNext();
179
+ };
180
+
181
+ return onRequest;
182
+ }
183
+
184
+ // This makes a Response mutable
185
+ const cloneResponse = (response: Response) =>
186
+ // https://fetch.spec.whatwg.org/#null-body-status
187
+ new Response(
188
+ [101, 204, 205, 304].includes(response.status) ? null : response.body,
189
+ response
190
+ );
worker/node_modules/wrangler/templates/pages-template-worker.ts ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { match } from "path-to-regexp";
2
+
3
+ //note: this explicitly does not include the * character, as pages requires this
4
+ const escapeRegex = /[.+?^${}()|[\]\\]/g;
5
+
6
+ type HTTPMethod =
7
+ | "HEAD"
8
+ | "OPTIONS"
9
+ | "GET"
10
+ | "POST"
11
+ | "PUT"
12
+ | "PATCH"
13
+ | "DELETE";
14
+
15
+ /* TODO: Grab these from @cloudflare/workers-types instead */
16
+ type Params<P extends string = string> = Record<P, string | string[]>;
17
+
18
+ type EventContext<Env, P extends string, Data> = {
19
+ request: Request;
20
+ functionPath: string;
21
+ waitUntil: (promise: Promise<unknown>) => void;
22
+ passThroughOnException: () => void;
23
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
24
+ env: Env & { ASSETS: { fetch: typeof fetch } };
25
+ params: Params<P>;
26
+ data: Data;
27
+ };
28
+
29
+ declare type PagesFunction<
30
+ Env = unknown,
31
+ P extends string = string,
32
+ Data extends Record<string, unknown> = Record<string, unknown>,
33
+ > = (context: EventContext<Env, P, Data>) => Response | Promise<Response>;
34
+ /* end @cloudflare/workers-types */
35
+
36
+ type RouteHandler = {
37
+ routePath: string;
38
+ mountPath: string;
39
+ method?: HTTPMethod;
40
+ modules: PagesFunction[];
41
+ middlewares: PagesFunction[];
42
+ };
43
+
44
+ // inject `routes` via ESBuild
45
+ declare const routes: RouteHandler[];
46
+ // define `__FALLBACK_SERVICE__` via ESBuild
47
+ declare const __FALLBACK_SERVICE__: string;
48
+
49
+ // expect an ASSETS fetcher binding pointing to the asset-server stage
50
+ type FetchEnv = {
51
+ [name: string]: { fetch: typeof fetch };
52
+ ASSETS: { fetch: typeof fetch };
53
+ };
54
+
55
+ type WorkerContext = {
56
+ waitUntil: (promise: Promise<unknown>) => void;
57
+ passThroughOnException: () => void;
58
+ };
59
+
60
+ function* executeRequest(request: Request) {
61
+ const requestPath = new URL(request.url).pathname;
62
+
63
+ // First, iterate through the routes (backwards) and execute "middlewares" on partial route matches
64
+ for (const route of [...routes].reverse()) {
65
+ if (route.method && route.method !== request.method) {
66
+ continue;
67
+ }
68
+
69
+ // replaces with "\\$&", this prepends a backslash to the matched string, e.g. "[" becomes "\["
70
+ const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
71
+ end: false,
72
+ });
73
+ const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
74
+ end: false,
75
+ });
76
+ const matchResult = routeMatcher(requestPath);
77
+ const mountMatchResult = mountMatcher(requestPath);
78
+ if (matchResult && mountMatchResult) {
79
+ for (const handler of route.middlewares.flat()) {
80
+ yield {
81
+ handler,
82
+ params: matchResult.params as Params,
83
+ path: mountMatchResult.path,
84
+ };
85
+ }
86
+ }
87
+ }
88
+
89
+ // Then look for the first exact route match and execute its "modules"
90
+ for (const route of routes) {
91
+ if (route.method && route.method !== request.method) {
92
+ continue;
93
+ }
94
+ const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
95
+ end: true,
96
+ });
97
+ const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
98
+ end: false,
99
+ });
100
+ const matchResult = routeMatcher(requestPath);
101
+ const mountMatchResult = mountMatcher(requestPath);
102
+ if (matchResult && mountMatchResult && route.modules.length) {
103
+ for (const handler of route.modules.flat()) {
104
+ yield {
105
+ handler,
106
+ params: matchResult.params as Params,
107
+ path: matchResult.path,
108
+ };
109
+ }
110
+ break;
111
+ }
112
+ }
113
+ }
114
+
115
+ export default {
116
+ async fetch(
117
+ originalRequest: Request,
118
+ env: FetchEnv,
119
+ workerContext: WorkerContext
120
+ ) {
121
+ let request = originalRequest;
122
+ const handlerIterator = executeRequest(request);
123
+ let data = {}; // arbitrary data the user can set between functions
124
+ let isFailOpen = false;
125
+
126
+ const next = async (input?: RequestInfo, init?: RequestInit) => {
127
+ if (input !== undefined) {
128
+ let url = input;
129
+ if (typeof input === "string") {
130
+ url = new URL(input, request.url).toString();
131
+ }
132
+ request = new Request(url, init);
133
+ }
134
+
135
+ const result = handlerIterator.next();
136
+ // Note we can't use `!result.done` because this doesn't narrow to the correct type
137
+ if (result.done === false) {
138
+ const { handler, params, path } = result.value;
139
+ const context = {
140
+ request: new Request(request.clone()),
141
+ functionPath: path,
142
+ next,
143
+ params,
144
+ get data() {
145
+ return data;
146
+ },
147
+ set data(value) {
148
+ if (typeof value !== "object" || value === null) {
149
+ throw new Error("context.data must be an object");
150
+ }
151
+ // user has overriden context.data, so we need to merge it with the existing data
152
+ data = value;
153
+ },
154
+ env,
155
+ waitUntil: workerContext.waitUntil.bind(workerContext),
156
+ passThroughOnException: () => {
157
+ isFailOpen = true;
158
+ },
159
+ };
160
+
161
+ const response = await handler(context);
162
+
163
+ if (!(response instanceof Response)) {
164
+ throw new Error("Your Pages function should return a Response");
165
+ }
166
+
167
+ return cloneResponse(response);
168
+ } else if (__FALLBACK_SERVICE__) {
169
+ // There are no more handlers so finish with the fallback service (`env.ASSETS.fetch` in Pages' case)
170
+ const response = await env[__FALLBACK_SERVICE__].fetch(request);
171
+ return cloneResponse(response);
172
+ } else {
173
+ // There was not fallback service so actually make the request to the origin.
174
+ const response = await fetch(request);
175
+ return cloneResponse(response);
176
+ }
177
+ };
178
+
179
+ try {
180
+ return await next();
181
+ } catch (error) {
182
+ if (isFailOpen) {
183
+ const response = await env[__FALLBACK_SERVICE__].fetch(request);
184
+ return cloneResponse(response);
185
+ }
186
+
187
+ throw error;
188
+ }
189
+ },
190
+ };
191
+
192
+ // This makes a Response mutable
193
+ const cloneResponse = (response: Response) =>
194
+ // https://fetch.spec.whatwg.org/#null-body-status
195
+ new Response(
196
+ [101, 204, 205, 304].includes(response.status) ? null : response.body,
197
+ response
198
+ );
worker/node_modules/wrangler/templates/strip-cf-connecting-ip-header.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function stripCfConnectingIPHeader(input, init) {
2
+ const request = new Request(input, init);
3
+ request.headers.delete("CF-Connecting-IP");
4
+ return request;
5
+ }
6
+
7
+ globalThis.fetch = new Proxy(globalThis.fetch, {
8
+ apply(target, thisArg, argArray) {
9
+ return Reflect.apply(target, thisArg, [
10
+ stripCfConnectingIPHeader.apply(null, argArray),
11
+ ]);
12
+ },
13
+ });
worker/node_modules/wrangler/templates/tsconfig-sanity.ts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-nocheck `@types/node` should NOT be included
2
+ Buffer.from("test");
3
+
4
+ // @ts-expect-error `@types/jest` should NOT be included
5
+ test("test");
6
+
7
+ // `@cloudflare/workers-types` should be included
8
+ const _handler: ExportedHandler = {};
9
+ new HTMLRewriter();
10
+
11
+ export {};
worker/node_modules/wrangler/templates/tsconfig.init.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
4
+ "lib": [
5
+ "es2021"
6
+ ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
7
+ "jsx": "react-jsx" /* Specify what JSX code is generated. */,
8
+ "module": "ESNext" /* Specify what module code is generated. */,
9
+ "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
10
+ "types": [
11
+ "@cloudflare/workers-types"
12
+ ] /* Specify type package names to be included without being referenced in a source file. */,
13
+ "resolveJsonModule": true /* Enable importing .json files */,
14
+ "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
15
+ "noEmit": true /* Disable emitting files from a compilation. */,
16
+ "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
17
+ "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
18
+ "strict": true /* Enable all strict type-checking options. */,
19
+ "noUncheckedIndexedAccess": true,
20
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
21
+ }
22
+ }