@comapeo/map-server 1.0.0-pre.0 → 1.0.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/context.d.ts +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/lib/map-share.js +1 -1
  7. package/dist/routes/maps.js +1 -1
  8. package/dist/types.d.ts +5 -5
  9. package/dist/types.js +2 -2
  10. package/node_modules/@fastify/busboy/LICENSE +24 -0
  11. package/node_modules/@fastify/busboy/README.md +270 -0
  12. package/node_modules/@fastify/busboy/deps/dicer/LICENSE +19 -0
  13. package/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js +213 -0
  14. package/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js +100 -0
  15. package/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js +13 -0
  16. package/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts +164 -0
  17. package/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js +230 -0
  18. package/node_modules/@fastify/busboy/lib/main.d.ts +196 -0
  19. package/node_modules/@fastify/busboy/lib/main.js +85 -0
  20. package/node_modules/@fastify/busboy/lib/types/multipart.js +306 -0
  21. package/node_modules/@fastify/busboy/lib/types/urlencoded.js +190 -0
  22. package/node_modules/@fastify/busboy/lib/utils/Decoder.js +54 -0
  23. package/node_modules/@fastify/busboy/lib/utils/basename.js +14 -0
  24. package/node_modules/@fastify/busboy/lib/utils/decodeText.js +114 -0
  25. package/node_modules/@fastify/busboy/lib/utils/getLimit.js +16 -0
  26. package/node_modules/@fastify/busboy/lib/utils/parseParams.js +201 -0
  27. package/node_modules/@fastify/busboy/package.json +81 -0
  28. package/node_modules/@whatwg-node/fetch/CHANGELOG.md +941 -0
  29. package/node_modules/@whatwg-node/fetch/README.md +141 -0
  30. package/node_modules/@whatwg-node/fetch/dist/create-node-ponyfill.js +100 -0
  31. package/node_modules/@whatwg-node/fetch/dist/esm-ponyfill.js +71 -0
  32. package/node_modules/@whatwg-node/fetch/dist/global-ponyfill.js +22 -0
  33. package/node_modules/@whatwg-node/fetch/dist/index.d.ts +73 -0
  34. package/node_modules/@whatwg-node/fetch/dist/node-ponyfill.js +35 -0
  35. package/node_modules/@whatwg-node/fetch/dist/shouldSkipPonyfill.js +17 -0
  36. package/node_modules/@whatwg-node/fetch/package.json +31 -0
  37. package/node_modules/@whatwg-node/node-fetch/cjs/AbortError.js +19 -0
  38. package/node_modules/@whatwg-node/node-fetch/cjs/Blob.js +291 -0
  39. package/node_modules/@whatwg-node/node-fetch/cjs/Body.js +529 -0
  40. package/node_modules/@whatwg-node/node-fetch/cjs/CompressionStream.js +34 -0
  41. package/node_modules/@whatwg-node/node-fetch/cjs/DecompressionStream.js +34 -0
  42. package/node_modules/@whatwg-node/node-fetch/cjs/File.js +15 -0
  43. package/node_modules/@whatwg-node/node-fetch/cjs/FormData.js +150 -0
  44. package/node_modules/@whatwg-node/node-fetch/cjs/Headers.js +309 -0
  45. package/node_modules/@whatwg-node/node-fetch/cjs/IteratorObject.js +134 -0
  46. package/node_modules/@whatwg-node/node-fetch/cjs/ReadableStream.js +245 -0
  47. package/node_modules/@whatwg-node/node-fetch/cjs/Request.js +128 -0
  48. package/node_modules/@whatwg-node/node-fetch/cjs/Response.js +108 -0
  49. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoder.js +49 -0
  50. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoderStream.js +40 -0
  51. package/node_modules/@whatwg-node/node-fetch/cjs/TransformStream.js +79 -0
  52. package/node_modules/@whatwg-node/node-fetch/cjs/URL.js +28 -0
  53. package/node_modules/@whatwg-node/node-fetch/cjs/URLSearchParams.js +4 -0
  54. package/node_modules/@whatwg-node/node-fetch/cjs/WritableStream.js +115 -0
  55. package/node_modules/@whatwg-node/node-fetch/cjs/fetch.js +107 -0
  56. package/node_modules/@whatwg-node/node-fetch/cjs/fetchCurl.js +142 -0
  57. package/node_modules/@whatwg-node/node-fetch/cjs/fetchNodeHttp.js +152 -0
  58. package/node_modules/@whatwg-node/node-fetch/cjs/index.js +42 -0
  59. package/node_modules/@whatwg-node/node-fetch/cjs/package.json +1 -0
  60. package/node_modules/@whatwg-node/node-fetch/cjs/utils.js +125 -0
  61. package/node_modules/@whatwg-node/node-fetch/esm/AbortError.js +15 -0
  62. package/node_modules/@whatwg-node/node-fetch/esm/Blob.js +279 -0
  63. package/node_modules/@whatwg-node/node-fetch/esm/Body.js +525 -0
  64. package/node_modules/@whatwg-node/node-fetch/esm/CompressionStream.js +29 -0
  65. package/node_modules/@whatwg-node/node-fetch/esm/DecompressionStream.js +29 -0
  66. package/node_modules/@whatwg-node/node-fetch/esm/File.js +11 -0
  67. package/node_modules/@whatwg-node/node-fetch/esm/FormData.js +145 -0
  68. package/node_modules/@whatwg-node/node-fetch/esm/Headers.js +304 -0
  69. package/node_modules/@whatwg-node/node-fetch/esm/IteratorObject.js +130 -0
  70. package/node_modules/@whatwg-node/node-fetch/esm/ReadableStream.js +241 -0
  71. package/node_modules/@whatwg-node/node-fetch/esm/Request.js +124 -0
  72. package/node_modules/@whatwg-node/node-fetch/esm/Response.js +104 -0
  73. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoder.js +43 -0
  74. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoderStream.js +35 -0
  75. package/node_modules/@whatwg-node/node-fetch/esm/TransformStream.js +75 -0
  76. package/node_modules/@whatwg-node/node-fetch/esm/URL.js +24 -0
  77. package/node_modules/@whatwg-node/node-fetch/esm/URLSearchParams.js +1 -0
  78. package/node_modules/@whatwg-node/node-fetch/esm/WritableStream.js +111 -0
  79. package/node_modules/@whatwg-node/node-fetch/esm/fetch.js +104 -0
  80. package/node_modules/@whatwg-node/node-fetch/esm/fetchCurl.js +139 -0
  81. package/node_modules/@whatwg-node/node-fetch/esm/fetchNodeHttp.js +148 -0
  82. package/node_modules/@whatwg-node/node-fetch/esm/index.js +18 -0
  83. package/node_modules/@whatwg-node/node-fetch/esm/utils.js +110 -0
  84. package/node_modules/@whatwg-node/node-fetch/package.json +46 -0
  85. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.cts +4 -0
  86. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.ts +4 -0
  87. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.cts +63 -0
  88. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.ts +63 -0
  89. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.cts +54 -0
  90. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.ts +54 -0
  91. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.cts +6 -0
  92. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.ts +6 -0
  93. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.cts +6 -0
  94. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.ts +6 -0
  95. package/node_modules/@whatwg-node/node-fetch/typings/File.d.cts +7 -0
  96. package/node_modules/@whatwg-node/node-fetch/typings/File.d.ts +7 -0
  97. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.cts +22 -0
  98. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.ts +22 -0
  99. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.cts +26 -0
  100. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.ts +26 -0
  101. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.cts +20 -0
  102. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.ts +20 -0
  103. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.cts +27 -0
  104. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.ts +27 -0
  105. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.cts +38 -0
  106. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.ts +38 -0
  107. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.cts +23 -0
  108. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.ts +23 -0
  109. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.cts +15 -0
  110. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.ts +15 -0
  111. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.cts +14 -0
  112. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.ts +14 -0
  113. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.cts +9 -0
  114. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.ts +9 -0
  115. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.cts +16 -0
  116. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.ts +16 -0
  117. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.cts +4 -0
  118. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.ts +4 -0
  119. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.cts +9 -0
  120. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.ts +9 -0
  121. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.cts +3 -0
  122. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.ts +3 -0
  123. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.cts +3 -0
  124. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.ts +3 -0
  125. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.cts +3 -0
  126. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.ts +3 -0
  127. package/node_modules/@whatwg-node/node-fetch/typings/index.d.cts +18 -0
  128. package/node_modules/@whatwg-node/node-fetch/typings/index.d.ts +18 -0
  129. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.cts +21 -0
  130. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.ts +21 -0
  131. package/node_modules/@whatwg-node/server/package.json +2 -1
  132. package/node_modules/urlpattern-polyfill/LICENSE +19 -0
  133. package/node_modules/urlpattern-polyfill/README.md +242 -0
  134. package/node_modules/urlpattern-polyfill/dist/index.d.ts +9 -0
  135. package/node_modules/urlpattern-polyfill/dist/types.d.ts +49 -0
  136. package/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +1 -0
  137. package/node_modules/urlpattern-polyfill/dist/urlpattern.js +1 -0
  138. package/node_modules/urlpattern-polyfill/index.cjs +7 -0
  139. package/node_modules/urlpattern-polyfill/index.js +7 -0
  140. package/node_modules/urlpattern-polyfill/package.json +149 -0
  141. package/package.json +18 -8
  142. package/src/context.ts +1 -1
  143. package/src/index.ts +2 -0
  144. package/src/lib/map-share.ts +1 -1
  145. package/src/routes/maps.ts +1 -1
  146. package/src/types.ts +2 -2
@@ -0,0 +1,141 @@
1
+ # `@whatwg-node/fetch`
2
+
3
+ A ponyfill package for the [Fetch Standard](https://fetch.spec.whatwg.org/). If your JavaScript
4
+ environment doesn't implement this standard natively, this package automatically ponyfills the
5
+ missing parts, and export them as a module; otherwise it exports the native ones without touching
6
+ the environment's internals. It also exports some additional standard APIs that are required by the
7
+ Fetch Standard.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @whatwg-node/fetch
13
+ ```
14
+
15
+ ## Why Fetch API and why this ponyfill in general?
16
+
17
+ If you are building a JavaScript library, and you want it to support all JavaScript environments not
18
+ only Node.js. Fetch API is the best choice for you. Because it's a standard, and it's implemented by
19
+ the most environments out there expect Node.js :). So you can use Fetch API in your library, and
20
+ your users can use it in their browsers, Deno, Bun, Cloudflare Works, and in Node.js.
21
+
22
+ > This is how we support all JavaScript environments in
23
+ > [GraphQL Yoga](https://the-guild.dev/graphql/yoga-server/docs/integrations/z-other-environments).
24
+ > In GraphQL Yoga, we don't care which JavaScript environment you prefer, we support all of them.
25
+
26
+ ## Why we should still use these for Node.js even if it already implements them natively
27
+
28
+ Even if newer Node.js already implements Fetch API and Data Text Encoding API natively, we still
29
+ recommend to use this package, because this package implements them for Node.js in more efficient
30
+ way.
31
+
32
+ - [See problems with the global fetch/undici in Node.js](https://github.com/nodejs/undici/issues/1203)
33
+ - - We offer a patched version of `node-fetch` that doesn't use `undici` and Node.js streams
34
+ internally, so it's more efficient than the native one.
35
+ - [See problems with text encoding API in Node.js](https://github.com/nodejs/node/issues/39879)
36
+ - - We use [`Buffer`](https://nodejs.org/api/buffer.html) instead of the native one, because
37
+ `Buffer` is faster than the native one unfortunately.
38
+ - `Body.formData()` is not implemented by Node.js, so we implement it with `busboy` internally. So
39
+ you can consume incoming multipart(file uploads) requests with `.formData` in Node.js.
40
+ - `fetch` implementation of Node.js uses `undici` and it doesn't support HTTP 2, our implementation
41
+ supports it natively thanks to `node-libcurl`.
42
+
43
+ ### Faster HTTP Client in Node.js with HTTP/2 support
44
+
45
+ If you install `node-libcurl` seperately, `@whatwg-node/fetch` will select `libcurl` instead of
46
+ `node:http` which is faster.
47
+
48
+ [See benchmarks](https://github.com/JCMais/node-libcurl/tree/develop/benchmark#ubuntu-1910-i7-5500u-24ghz---linux-530-42---node-v12162)
49
+
50
+ ### Handling file uploads with Fetch API
51
+
52
+ ```ts
53
+ import { Request } from '@whatwg-node/fetch'
54
+
55
+ // See how you can handle file uploads with Fetch API
56
+ http.createServer(async (req, res) => {
57
+ const request = new Request(req)
58
+ const formData = await request.formData()
59
+ const file = formData.get('file')
60
+ // ...
61
+ })
62
+ ```
63
+
64
+ > If you want to limit the size of the multipart form data, you can use `createFetch`. See the
65
+ > [API](#api) section for more details.
66
+
67
+ ## API
68
+
69
+ The following are exported by this package:
70
+
71
+ ### WHATWG Fetch Standard
72
+
73
+ - [fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch)
74
+ - [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request)
75
+ - [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
76
+ - [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
77
+ - [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
78
+ - [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController)
79
+
80
+ ### Web Streams API
81
+
82
+ - [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)
83
+ - [WritableStream](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream)
84
+ - [TransformStream](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream)
85
+
86
+ ### URL Standard
87
+
88
+ - [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)
89
+ - [URLSearchParams](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams)
90
+ - [URLPattern](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern)
91
+
92
+ ### Data Types
93
+
94
+ - [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
95
+ - [File](https://developer.mozilla.org/en-US/docs/Web/API/File)
96
+
97
+ ### Data Encoding/Decoding API
98
+
99
+ - [TextEncoder](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
100
+ - [TextDecoder](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
101
+ - [btoa](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/btoa)
102
+
103
+ ### Web Crypto API
104
+
105
+ - [crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
106
+
107
+ ### Create variations of the implementation
108
+
109
+ - `createFetch`
110
+
111
+ `createFetch` allows you to create an API with some specific flags that are not available in the
112
+ actual API.
113
+
114
+ #### Limit the multipart form data size
115
+
116
+ This is useful if you parse the multipart request bodies with `.formData()`.
117
+
118
+ ```ts
119
+ import { createFetch } from '@whatwg-node/fetch'
120
+
121
+ const fetchAPI = createFetch({
122
+ formDataLimits: {
123
+ // Maximum allowed file size (in bytes)
124
+ fileSize: 1000000,
125
+ // Maximum allowed number of files
126
+ files: 10,
127
+ // Maximum allowed size of content (operations, variables etc...)
128
+ fieldSize: 1000000,
129
+ // Maximum allowed header size for form data
130
+ headerSize: 1000000
131
+ }
132
+ })
133
+
134
+ // See how you can handle file uploads with Fetch API
135
+ http.createServer(async (req, res) => {
136
+ const request = new Request(req)
137
+ const formData = await request.formData()
138
+ const file = formData.get('file')
139
+ // ...
140
+ })
141
+ ```
@@ -0,0 +1,100 @@
1
+ const shouldSkipPonyfill = require('./shouldSkipPonyfill');
2
+ let newNodeFetch;
3
+
4
+ module.exports = function createNodePonyfill(opts = {}) {
5
+ const ponyfills = {};
6
+
7
+ ponyfills.URLPattern = globalThis.URLPattern;
8
+
9
+ // We call this previously to patch `Bun`
10
+ if (!ponyfills.URLPattern) {
11
+ const urlPatternModule = require('urlpattern-polyfill');
12
+ ponyfills.URLPattern = urlPatternModule.URLPattern;
13
+ }
14
+
15
+ if (opts.skipPonyfill || shouldSkipPonyfill()) {
16
+ return {
17
+ fetch: globalThis.fetch,
18
+ Headers: globalThis.Headers,
19
+ Request: globalThis.Request,
20
+ Response: globalThis.Response,
21
+ FormData: globalThis.FormData,
22
+ ReadableStream: globalThis.ReadableStream,
23
+ WritableStream: globalThis.WritableStream,
24
+ TransformStream: globalThis.TransformStream,
25
+ CompressionStream: globalThis.CompressionStream,
26
+ DecompressionStream: globalThis.DecompressionStream,
27
+ TextDecoderStream: globalThis.TextDecoderStream,
28
+ TextEncoderStream: globalThis.TextEncoderStream,
29
+ Blob: globalThis.Blob,
30
+ File: globalThis.File,
31
+ crypto: globalThis.crypto,
32
+ btoa: globalThis.btoa,
33
+ TextEncoder: globalThis.TextEncoder,
34
+ TextDecoder: globalThis.TextDecoder,
35
+ URLPattern: ponyfills.URLPattern,
36
+ URL: globalThis.URL,
37
+ URLSearchParams: globalThis.URLSearchParams
38
+ };
39
+ }
40
+
41
+ newNodeFetch ||= require('@whatwg-node/node-fetch');
42
+
43
+ ponyfills.fetch = newNodeFetch.fetch;
44
+ ponyfills.Request = newNodeFetch.Request;
45
+ ponyfills.Response = newNodeFetch.Response;
46
+ ponyfills.Headers = newNodeFetch.Headers;
47
+ ponyfills.FormData = newNodeFetch.FormData;
48
+ ponyfills.ReadableStream = newNodeFetch.ReadableStream;
49
+
50
+ ponyfills.URL = newNodeFetch.URL;
51
+ ponyfills.URLSearchParams = newNodeFetch.URLSearchParams;
52
+
53
+ ponyfills.WritableStream = newNodeFetch.WritableStream;
54
+ ponyfills.TransformStream = newNodeFetch.TransformStream;
55
+ ponyfills.CompressionStream = newNodeFetch.CompressionStream;
56
+ ponyfills.DecompressionStream = newNodeFetch.DecompressionStream;
57
+ ponyfills.TextDecoderStream = newNodeFetch.TextDecoderStream;
58
+ ponyfills.TextEncoderStream = newNodeFetch.TextEncoderStream;
59
+
60
+ ponyfills.Blob = newNodeFetch.Blob;
61
+ ponyfills.File = newNodeFetch.File;
62
+ ponyfills.crypto = globalThis.crypto;
63
+ ponyfills.btoa = newNodeFetch.btoa;
64
+ ponyfills.TextEncoder = newNodeFetch.TextEncoder;
65
+ ponyfills.TextDecoder = newNodeFetch.TextDecoder;
66
+
67
+ if (opts.formDataLimits) {
68
+ ponyfills.Body = class Body extends newNodeFetch.Body {
69
+ constructor(body, userOpts) {
70
+ super(body, {
71
+ formDataLimits: opts.formDataLimits,
72
+ ...userOpts,
73
+ });
74
+ }
75
+ }
76
+ ponyfills.Request = class Request extends newNodeFetch.Request {
77
+ constructor(input, userOpts) {
78
+ super(input, {
79
+ formDataLimits: opts.formDataLimits,
80
+ ...userOpts,
81
+ });
82
+ }
83
+ }
84
+ ponyfills.Response = class Response extends newNodeFetch.Response {
85
+ constructor(body, userOpts) {
86
+ super(body, {
87
+ formDataLimits: opts.formDataLimits,
88
+ ...userOpts,
89
+ });
90
+ }
91
+ }
92
+ }
93
+
94
+ if (!ponyfills.crypto) {
95
+ const cryptoModule = require("crypto");
96
+ ponyfills.crypto = cryptoModule.webcrypto;
97
+ }
98
+
99
+ return ponyfills;
100
+ }
@@ -0,0 +1,71 @@
1
+ const fetch = globalThis.fetch;
2
+ const Headers = globalThis.Headers;
3
+ const Request = globalThis.Request;
4
+ const Response = globalThis.Response;
5
+ const FormData = globalThis.FormData;
6
+ const ReadableStream = globalThis.ReadableStream;
7
+ const WritableStream = globalThis.WritableStream;
8
+ const TransformStream = globalThis.TransformStream;
9
+ const CompressionStream = globalThis.CompressionStream;
10
+ const DecompressionStream = globalThis.DecompressionStream;
11
+ const TextDecoderStream = globalThis.TextDecoderStream;
12
+ const TextEncoderStream = globalThis.TextEncoderStream;
13
+ const Blob = globalThis.Blob;
14
+ const File = globalThis.File;
15
+ const crypto = globalThis.crypto;
16
+ const btoa = globalThis.btoa;
17
+ const TextEncoder = globalThis.TextEncoder;
18
+ const TextDecoder = globalThis.TextDecoder;
19
+ const URLPattern = globalThis.URLPattern;
20
+ const URL = globalThis.URL;
21
+ const URLSearchParams = globalThis.URLSearchParams;
22
+
23
+ export {
24
+ fetch,
25
+ Headers,
26
+ Request,
27
+ Response,
28
+ FormData,
29
+ ReadableStream,
30
+ WritableStream,
31
+ TransformStream,
32
+ CompressionStream,
33
+ DecompressionStream,
34
+ TextDecoderStream,
35
+ TextEncoderStream,
36
+ Blob,
37
+ File,
38
+ crypto,
39
+ btoa,
40
+ TextEncoder,
41
+ TextDecoder,
42
+ URLPattern,
43
+ URL,
44
+ URLSearchParams
45
+ }
46
+
47
+ export function createFetch() {
48
+ return {
49
+ fetch,
50
+ Headers,
51
+ Request,
52
+ Response,
53
+ FormData,
54
+ ReadableStream,
55
+ WritableStream,
56
+ TransformStream,
57
+ CompressionStream,
58
+ DecompressionStream,
59
+ TextDecoderStream,
60
+ TextEncoderStream,
61
+ Blob,
62
+ File,
63
+ crypto,
64
+ btoa,
65
+ TextEncoder,
66
+ TextDecoder,
67
+ URLPattern,
68
+ URL,
69
+ URLSearchParams
70
+ };
71
+ }
@@ -0,0 +1,22 @@
1
+ module.exports.fetch = globalThis.fetch;
2
+ module.exports.Headers = globalThis.Headers;
3
+ module.exports.Request = globalThis.Request;
4
+ module.exports.Response = globalThis.Response;
5
+ module.exports.FormData = globalThis.FormData;
6
+ module.exports.ReadableStream = globalThis.ReadableStream;
7
+ module.exports.WritableStream = globalThis.WritableStream;
8
+ module.exports.TransformStream = globalThis.TransformStream;
9
+ module.exports.CompressionStream = globalThis.CompressionStream;
10
+ module.exports.DecompressionStream = globalThis.DecompressionStream;
11
+ module.exports.TextDecoderStream = globalThis.TextDecoderStream;
12
+ module.exports.TextEncoderStream = globalThis.TextEncoderStream;
13
+ module.exports.Blob = globalThis.Blob;
14
+ module.exports.File = globalThis.File;
15
+ module.exports.crypto = globalThis.crypto;
16
+ module.exports.btoa = globalThis.btoa;
17
+ module.exports.TextEncoder = globalThis.TextEncoder;
18
+ module.exports.TextDecoder = globalThis.TextDecoder;
19
+ module.exports.URLPattern = globalThis.URLPattern;
20
+ module.exports.URL = globalThis.URL;
21
+ module.exports.URLSearchParams = globalThis.URLSearchParams;
22
+ module.exports.createFetch = () => globalThis;
@@ -0,0 +1,73 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="dom.iterable" />
3
+
4
+ declare type _URLPattern = typeof URLPattern
5
+
6
+ declare module '@whatwg-node/fetch' {
7
+ export const fetch: typeof globalThis.fetch;
8
+ export const Request: typeof globalThis.Request;
9
+ export const Response: typeof globalThis.Response & {
10
+ json(data: any, init?: ResponseInit): globalThis.Response;
11
+ };
12
+ export const Headers: typeof globalThis.Headers;
13
+ export const FormData: typeof globalThis.FormData;
14
+ export const ReadableStream: typeof globalThis.ReadableStream;
15
+ export const WritableStream: typeof globalThis.WritableStream;
16
+ export const TransformStream: typeof globalThis.TransformStream;
17
+ export const CompressionStream: typeof globalThis.CompressionStream;
18
+ export const DecompressionStream: typeof globalThis.DecompressionStream;
19
+ export const TextDecoderStream: typeof globalThis.TextDecoderStream;
20
+ export const TextEncoderStream: typeof globalThis.TextEncoderStream;
21
+ export const Blob: typeof globalThis.Blob;
22
+ export const File: typeof globalThis.File;
23
+ export const crypto: typeof globalThis.crypto;
24
+ export const btoa: typeof globalThis.btoa;
25
+ export const TextDecoder: typeof globalThis.TextDecoder;
26
+ export const TextEncoder: typeof globalThis.TextEncoder;
27
+ export const URL: typeof globalThis.URL;
28
+ export const URLSearchParams: typeof globalThis.URLSearchParams;
29
+ export const URLPattern: _URLPattern;
30
+ export interface FormDataLimits {
31
+ /* Max field name size (in bytes). Default: 100. */
32
+ fieldNameSize?: number;
33
+ /* Max field value size (in bytes). Default: 1MB. */
34
+ fieldSize?: number;
35
+ /* Max number of fields. Default: Infinity. */
36
+ fields?: number;
37
+ /* For multipart forms, the max file size (in bytes). Default: Infinity. */
38
+ fileSize?: number;
39
+ /* For multipart forms, the max number of file fields. Default: Infinity. */
40
+ files?: number;
41
+ /* For multipart forms, the max number of parts (fields + files). Default: Infinity. */
42
+ parts?: number;
43
+ /* For multipart forms, the max number of header key-value pairs to parse. Default: 2000. */
44
+ headerSize?: number;
45
+ }
46
+ export const createFetch: (opts?: {
47
+ useNodeFetch?: boolean;
48
+ formDataLimits?: FormDataLimits;
49
+ skipPonyfill?: boolean;
50
+ }) => {
51
+ fetch: typeof fetch;
52
+ Request: typeof Request;
53
+ Response: typeof Response;
54
+ Headers: typeof Headers;
55
+ FormData: typeof FormData;
56
+ ReadableStream: typeof ReadableStream;
57
+ WritableStream: typeof WritableStream;
58
+ TransformStream: typeof TransformStream;
59
+ CompressionStream: typeof CompressionStream;
60
+ DecompressionStream: typeof DecompressionStream;
61
+ TextDecoderStream: typeof TextDecoderStream;
62
+ TextEncoderStream: typeof TextEncoderStream;
63
+ Blob: typeof Blob;
64
+ File: typeof File;
65
+ crypto: typeof crypto;
66
+ btoa: typeof btoa;
67
+ TextEncoder: typeof TextEncoder;
68
+ TextDecoder: typeof TextDecoder;
69
+ URLPattern: typeof URLPattern;
70
+ URL: typeof URL;
71
+ URLSearchParams: typeof URLSearchParams;
72
+ };
73
+ }
@@ -0,0 +1,35 @@
1
+
2
+ const createNodePonyfill = require('./create-node-ponyfill');
3
+ const shouldSkipPonyfill = require('./shouldSkipPonyfill');
4
+ const ponyfills = createNodePonyfill();
5
+
6
+ if (!shouldSkipPonyfill()) {
7
+ try {
8
+ const nodelibcurlName = 'node-libcurl'
9
+ globalThis.libcurl = globalThis.libcurl || require(nodelibcurlName);
10
+ } catch (e) { }
11
+ }
12
+
13
+ module.exports.fetch = ponyfills.fetch;
14
+ module.exports.Headers = ponyfills.Headers;
15
+ module.exports.Request = ponyfills.Request;
16
+ module.exports.Response = ponyfills.Response;
17
+ module.exports.FormData = ponyfills.FormData;
18
+ module.exports.ReadableStream = ponyfills.ReadableStream;
19
+ module.exports.WritableStream = ponyfills.WritableStream;
20
+ module.exports.TransformStream = ponyfills.TransformStream;
21
+ module.exports.CompressionStream = ponyfills.CompressionStream;
22
+ module.exports.DecompressionStream = ponyfills.DecompressionStream;
23
+ module.exports.TextDecoderStream = ponyfills.TextDecoderStream;
24
+ module.exports.TextEncoderStream = ponyfills.TextEncoderStream;
25
+ module.exports.Blob = ponyfills.Blob;
26
+ module.exports.File = ponyfills.File;
27
+ module.exports.crypto = ponyfills.crypto;
28
+ module.exports.btoa = ponyfills.btoa;
29
+ module.exports.TextEncoder = ponyfills.TextEncoder;
30
+ module.exports.TextDecoder = ponyfills.TextDecoder;
31
+ module.exports.URLPattern = ponyfills.URLPattern;
32
+ module.exports.URL = ponyfills.URL;
33
+ module.exports.URLSearchParams = ponyfills.URLSearchParams;
34
+
35
+ exports.createFetch = createNodePonyfill;
@@ -0,0 +1,17 @@
1
+
2
+ function isNextJs() {
3
+ return Object.keys(globalThis).some(key => key.startsWith('__NEXT'))
4
+ }
5
+
6
+ module.exports = function shouldSkipPonyfill() {
7
+ if (globalThis.Deno) {
8
+ return true
9
+ }
10
+ if (globalThis.Bun) {
11
+ return true
12
+ }
13
+ if (isNextJs()) {
14
+ return true
15
+ }
16
+ return false
17
+ }
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@whatwg-node/fetch",
3
+ "version": "0.10.13",
4
+ "description": "Cross Platform Smart Fetch Ponyfill",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "ardatan/whatwg-node",
8
+ "directory": "packages/fetch"
9
+ },
10
+ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
11
+ "license": "MIT",
12
+ "engines": {
13
+ "node": ">=18.0.0"
14
+ },
15
+ "main": "dist/node-ponyfill.js",
16
+ "browser": "dist/global-ponyfill.js",
17
+ "types": "dist/index.d.ts",
18
+ "dependencies": {
19
+ "@whatwg-node/node-fetch": "^0.8.3",
20
+ "urlpattern-polyfill": "^10.0.0"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "sideEffects": false,
26
+ "bob": false,
27
+ "denoify": {
28
+ "index": "dist/esm-ponyfill.js"
29
+ },
30
+ "react-native": "dist/global-ponyfill.js"
31
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PonyfillAbortError = void 0;
4
+ class PonyfillAbortError extends Error {
5
+ constructor(reason) {
6
+ let message = 'The operation was aborted';
7
+ if (reason) {
8
+ message += ` reason: ${reason}`;
9
+ }
10
+ super(message, {
11
+ cause: reason,
12
+ });
13
+ this.name = 'AbortError';
14
+ }
15
+ get reason() {
16
+ return this.cause;
17
+ }
18
+ }
19
+ exports.PonyfillAbortError = PonyfillAbortError;