@whatwg-node/fetch 0.8.8 → 0.10.13
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.
- package/CHANGELOG.md +507 -5
- package/README.md +10 -1
- package/dist/create-node-ponyfill.js +36 -25
- package/dist/esm-ponyfill.js +71 -0
- package/dist/global-ponyfill.js +5 -3
- package/dist/index.d.ts +9 -5
- package/dist/node-ponyfill.js +12 -2
- package/dist/shouldSkipPonyfill.js +17 -0
- package/package.json +7 -7
- package/dist/deno-ponyfill.ts +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,510 @@
|
|
|
1
1
|
# @whatwg-node/fetch
|
|
2
2
|
|
|
3
|
+
## 0.10.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2910](https://github.com/ardatan/whatwg-node/pull/2910)
|
|
8
|
+
[`0079afd`](https://github.com/ardatan/whatwg-node/commit/0079afdc785c012fad22dd35963800a8199bfe89)
|
|
9
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Zstandard \`zstd\` support
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
[[`0079afd`](https://github.com/ardatan/whatwg-node/commit/0079afdc785c012fad22dd35963800a8199bfe89)]:
|
|
13
|
+
- @whatwg-node/node-fetch@0.8.3
|
|
14
|
+
|
|
15
|
+
## 0.10.12
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`c9b2c87`](https://github.com/ardatan/whatwg-node/commit/c9b2c87bff6f36b71cd1bd97f81f1050efa8dd98)
|
|
20
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Do not override existing \`user-agent\`
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
[[`c9b2c87`](https://github.com/ardatan/whatwg-node/commit/c9b2c87bff6f36b71cd1bd97f81f1050efa8dd98)]:
|
|
24
|
+
- @whatwg-node/node-fetch@0.8.2
|
|
25
|
+
|
|
26
|
+
## 0.10.11
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
[[`60d41d6`](https://github.com/ardatan/whatwg-node/commit/60d41d6df941ca16f733556a3d3586486236a146)]:
|
|
32
|
+
- @whatwg-node/node-fetch@0.8.0
|
|
33
|
+
|
|
34
|
+
## 0.10.10
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [#2656](https://github.com/ardatan/whatwg-node/pull/2656)
|
|
39
|
+
[`d2ef55c`](https://github.com/ardatan/whatwg-node/commit/d2ef55c7735c7127e4ed404dd8bbebe8fd3ebd00)
|
|
40
|
+
Thanks [@renovate](https://github.com/apps/renovate)! - Fix TypeScript issues and bump the version
|
|
41
|
+
to get performance improvements for all dependent packages
|
|
42
|
+
- Updated dependencies
|
|
43
|
+
[[`d2ef55c`](https://github.com/ardatan/whatwg-node/commit/d2ef55c7735c7127e4ed404dd8bbebe8fd3ebd00)]:
|
|
44
|
+
- @whatwg-node/node-fetch@0.7.25
|
|
45
|
+
|
|
46
|
+
## 0.10.9
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- [#2553](https://github.com/ardatan/whatwg-node/pull/2553)
|
|
51
|
+
[`752b0eb`](https://github.com/ardatan/whatwg-node/commit/752b0ebdc88654ef4ae1e13eb860980f437b4110)
|
|
52
|
+
Thanks [@renovate](https://github.com/apps/renovate)! - Fix the conflict of urlpattern-ponyfill
|
|
53
|
+
and \`@types/node\`
|
|
54
|
+
|
|
55
|
+
- Updated dependencies
|
|
56
|
+
[[`b69157b`](https://github.com/ardatan/whatwg-node/commit/b69157bd97aba8fb4c761f8d16afc549c35acfa0)]:
|
|
57
|
+
- @whatwg-node/node-fetch@0.7.22
|
|
58
|
+
|
|
59
|
+
## 0.10.8
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- [#2424](https://github.com/ardatan/whatwg-node/pull/2424)
|
|
64
|
+
[`28c4ad9`](https://github.com/ardatan/whatwg-node/commit/28c4ad98aad3ec95a1f0893c54f5484d8564f675)
|
|
65
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Performance optimizations
|
|
66
|
+
- Avoid creating `AbortController` and `AbortSignal` if not needed with `new Request` because it
|
|
67
|
+
is expensive
|
|
68
|
+
- Avoid creating a map for `Headers` and try to re-use the init object for `Headers` for
|
|
69
|
+
performance with a single-line `writeHead`.
|
|
70
|
+
- Avoid creating `Buffer` for `string` bodies for performance
|
|
71
|
+
- Use `setHeaders` which accepts `Headers` since Node 18 if needed to forward `Headers` to Node
|
|
72
|
+
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
[[`28c4ad9`](https://github.com/ardatan/whatwg-node/commit/28c4ad98aad3ec95a1f0893c54f5484d8564f675)]:
|
|
75
|
+
- @whatwg-node/node-fetch@0.7.21
|
|
76
|
+
|
|
77
|
+
## 0.10.7
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#2383](https://github.com/ardatan/whatwg-node/pull/2383)
|
|
82
|
+
[`9527e8f`](https://github.com/ardatan/whatwg-node/commit/9527e8fe2dc73e362b38060f4a6decbb87a4f597)
|
|
83
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Some implementations like `compression` npm
|
|
84
|
+
package do not implement `response.write(data, callback)` signature, but whatwg-node/server waits
|
|
85
|
+
for it to finish the response stream. Then it causes the response stream hangs when the
|
|
86
|
+
compression package takes the stream over when the response data is larger than its threshold.
|
|
87
|
+
|
|
88
|
+
It is actually a bug in `compression` package;
|
|
89
|
+
[expressjs/compression#46](https://github.com/expressjs/compression/issues/46) But since it is a
|
|
90
|
+
common mistake, we prefer to workaround this on our end.
|
|
91
|
+
|
|
92
|
+
Now after calling `response.write`, it no longer uses callback but first it checks the result;
|
|
93
|
+
|
|
94
|
+
if it is `true`, it means stream is drained and we can call `response.end` immediately. else if it
|
|
95
|
+
is `false`, it means the stream is not drained yet, so we can wait for the `drain` event to call
|
|
96
|
+
`response.end`.
|
|
97
|
+
|
|
98
|
+
- Updated dependencies
|
|
99
|
+
[[`9527e8f`](https://github.com/ardatan/whatwg-node/commit/9527e8fe2dc73e362b38060f4a6decbb87a4f597)]:
|
|
100
|
+
- @whatwg-node/node-fetch@0.7.19
|
|
101
|
+
|
|
102
|
+
## 0.10.6
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- [#2310](https://github.com/ardatan/whatwg-node/pull/2310)
|
|
107
|
+
[`f699a1b`](https://github.com/ardatan/whatwg-node/commit/f699a1ba1558f98406f5844a31c07f77d874eb9b)
|
|
108
|
+
Thanks [@enisdenjo](https://github.com/enisdenjo)! - dependencies updates:
|
|
109
|
+
- Updated dependency
|
|
110
|
+
[`@whatwg-node/node-fetch@^0.7.18` ↗︎](https://www.npmjs.com/package/@whatwg-node/node-fetch/v/0.7.18)
|
|
111
|
+
(from `^0.7.11`, in `dependencies`)
|
|
112
|
+
|
|
113
|
+
## 0.10.5
|
|
114
|
+
|
|
115
|
+
### Patch Changes
|
|
116
|
+
|
|
117
|
+
- [#2093](https://github.com/ardatan/whatwg-node/pull/2093)
|
|
118
|
+
[`31f021a`](https://github.com/ardatan/whatwg-node/commit/31f021ac5df1ddd7f16807d4ed6c5776d250ab29)
|
|
119
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fixes the
|
|
120
|
+
`TypeError: bodyInit.stream is not a function` error thrown when `@whatwg-node/server` is used
|
|
121
|
+
with `node:http2` and attempts the incoming HTTP/2 request to parse with `Request.json`,
|
|
122
|
+
`Request.text`, `Request.formData`, or `Request.blob` methods.
|
|
123
|
+
|
|
124
|
+
- Updated dependencies
|
|
125
|
+
[[`31f021a`](https://github.com/ardatan/whatwg-node/commit/31f021ac5df1ddd7f16807d4ed6c5776d250ab29)]:
|
|
126
|
+
- @whatwg-node/node-fetch@0.7.11
|
|
127
|
+
|
|
128
|
+
## 0.10.4
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- [#2082](https://github.com/ardatan/whatwg-node/pull/2082)
|
|
133
|
+
[`b217e30`](https://github.com/ardatan/whatwg-node/commit/b217e305b5a5d63e164cf83ef45e7d1e95fefa0e)
|
|
134
|
+
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
135
|
+
- Updated dependency
|
|
136
|
+
[`@whatwg-node/node-fetch@^0.7.9` ↗︎](https://www.npmjs.com/package/@whatwg-node/node-fetch/v/0.7.9)
|
|
137
|
+
(from `^0.7.8`, in `dependencies`)
|
|
138
|
+
|
|
139
|
+
- [#2079](https://github.com/ardatan/whatwg-node/pull/2079)
|
|
140
|
+
[`090b4b0`](https://github.com/ardatan/whatwg-node/commit/090b4b0d2aefbf36707fa236395bc6ea99227b9c)
|
|
141
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fix the bug when `set-cookies` given is ignored
|
|
142
|
+
in `HeadersInit`;
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
import { Headers } from '@whatwg-node/fetch'
|
|
146
|
+
|
|
147
|
+
const headers = new Headers([
|
|
148
|
+
['set-cookie', 'a=b'],
|
|
149
|
+
['set-cookie', 'c=d']
|
|
150
|
+
])
|
|
151
|
+
expect(headers.getSetCookie()).toEqual(['a=b', 'c=d']) // Previously it was empty
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- Updated dependencies
|
|
155
|
+
[[`090b4b0`](https://github.com/ardatan/whatwg-node/commit/090b4b0d2aefbf36707fa236395bc6ea99227b9c)]:
|
|
156
|
+
- @whatwg-node/node-fetch@0.7.10
|
|
157
|
+
|
|
158
|
+
## 0.10.3
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- [#1961](https://github.com/ardatan/whatwg-node/pull/1961)
|
|
163
|
+
[`2785c80`](https://github.com/ardatan/whatwg-node/commit/2785c80be2c887c581ef0fac8150befeab306eba)
|
|
164
|
+
Thanks [@ardatan](https://github.com/ardatan)! - `ReadableStream`'s `Symbol.asyncIterator` now
|
|
165
|
+
returns `AsyncIterableIterator` like before even if it is ok to return `AsyncIterator` right now.
|
|
166
|
+
It is safer to return `AsyncIterableIterator` because it is a common mistake to use
|
|
167
|
+
`AsyncIterator` as `AsyncIterable`.
|
|
168
|
+
- Updated dependencies
|
|
169
|
+
[[`2785c80`](https://github.com/ardatan/whatwg-node/commit/2785c80be2c887c581ef0fac8150befeab306eba)]:
|
|
170
|
+
- @whatwg-node/node-fetch@0.7.7
|
|
171
|
+
|
|
172
|
+
## 0.10.2
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- [#1929](https://github.com/ardatan/whatwg-node/pull/1929)
|
|
177
|
+
[`b88b85c`](https://github.com/ardatan/whatwg-node/commit/b88b85c301923719f4722bdfe070728725bcc1b5)
|
|
178
|
+
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
179
|
+
- Updated dependency
|
|
180
|
+
[`@whatwg-node/node-fetch@^0.7.5` ↗︎](https://www.npmjs.com/package/@whatwg-node/node-fetch/v/0.7.5)
|
|
181
|
+
(from `^0.7.1`, in `dependencies`)
|
|
182
|
+
- Updated dependencies
|
|
183
|
+
[[`b88b85c`](https://github.com/ardatan/whatwg-node/commit/b88b85c301923719f4722bdfe070728725bcc1b5),
|
|
184
|
+
[`9b39c3e`](https://github.com/ardatan/whatwg-node/commit/9b39c3e5db616a60e6dd8472fbd651f4905f3673),
|
|
185
|
+
[`b88b85c`](https://github.com/ardatan/whatwg-node/commit/b88b85c301923719f4722bdfe070728725bcc1b5)]:
|
|
186
|
+
- @whatwg-node/node-fetch@0.7.6
|
|
187
|
+
|
|
188
|
+
## 0.10.1
|
|
189
|
+
|
|
190
|
+
### Patch Changes
|
|
191
|
+
|
|
192
|
+
- [`c68f5ad`](https://github.com/ardatan/whatwg-node/commit/c68f5ad0782476b4b4facf490600b5f3341a4886)
|
|
193
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Pass errors to ReadableStream's cancel method
|
|
194
|
+
properly when it is piped, and piped stream is cancelled
|
|
195
|
+
|
|
196
|
+
Implement `ReadableStream.from`
|
|
197
|
+
|
|
198
|
+
- Updated dependencies
|
|
199
|
+
[[`c68f5ad`](https://github.com/ardatan/whatwg-node/commit/c68f5ad0782476b4b4facf490600b5f3341a4886)]:
|
|
200
|
+
- @whatwg-node/node-fetch@0.7.1
|
|
201
|
+
|
|
202
|
+
## 0.10.0
|
|
203
|
+
|
|
204
|
+
### Minor Changes
|
|
205
|
+
|
|
206
|
+
- [#1782](https://github.com/ardatan/whatwg-node/pull/1782)
|
|
207
|
+
[`6c006e1`](https://github.com/ardatan/whatwg-node/commit/6c006e12eaa6705cdf20b7b43cccc44a1f7ea185)
|
|
208
|
+
Thanks [@ardatan](https://github.com/ardatan)! - \`TextDecoderStream\` and \`TextEncoderStream\`
|
|
209
|
+
|
|
210
|
+
### Patch Changes
|
|
211
|
+
|
|
212
|
+
- Updated dependencies
|
|
213
|
+
[[`6c006e1`](https://github.com/ardatan/whatwg-node/commit/6c006e12eaa6705cdf20b7b43cccc44a1f7ea185)]:
|
|
214
|
+
- @whatwg-node/node-fetch@0.7.0
|
|
215
|
+
|
|
216
|
+
## 0.9.23
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- Updated dependencies
|
|
221
|
+
[[`637185f`](https://github.com/ardatan/whatwg-node/commit/637185f5c992ccabff13b185d4e14f09680228da)]:
|
|
222
|
+
- @whatwg-node/node-fetch@0.6.0
|
|
223
|
+
|
|
224
|
+
## 0.9.22
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- [`77dd1c3`](https://github.com/ardatan/whatwg-node/commit/77dd1c3acde29aeb828b6eb37b6fbdbb47a16c57)
|
|
229
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Use \`globalThis\` instead of \`window\` for the
|
|
230
|
+
global object reference
|
|
231
|
+
|
|
232
|
+
Fixes the issues with Deno
|
|
233
|
+
|
|
234
|
+
- Updated dependencies
|
|
235
|
+
[[`9281e02`](https://github.com/ardatan/whatwg-node/commit/9281e021282a43a3dda8c8a5c9647d340b28698e)]:
|
|
236
|
+
- @whatwg-node/node-fetch@0.5.27
|
|
237
|
+
|
|
238
|
+
## 0.9.21
|
|
239
|
+
|
|
240
|
+
### Patch Changes
|
|
241
|
+
|
|
242
|
+
- [#1577](https://github.com/ardatan/whatwg-node/pull/1577)
|
|
243
|
+
[`99c4344`](https://github.com/ardatan/whatwg-node/commit/99c4344ec82717be079e725538a532a827fbef82)
|
|
244
|
+
Thanks [@ardatan](https://github.com/ardatan)! - - Improve native ReadableStream handling inside
|
|
245
|
+
ponyfills
|
|
246
|
+
- Use `waitUntil` instead of floating promises
|
|
247
|
+
- Handle early termination in `WritableStream`
|
|
248
|
+
- Handle `waitUntil` correctly within a dummy call of `ServerAdapter.fetch` method
|
|
249
|
+
- Updated dependencies
|
|
250
|
+
[[`99c4344`](https://github.com/ardatan/whatwg-node/commit/99c4344ec82717be079e725538a532a827fbef82)]:
|
|
251
|
+
- @whatwg-node/node-fetch@0.5.23
|
|
252
|
+
|
|
253
|
+
## 0.9.20
|
|
254
|
+
|
|
255
|
+
### Patch Changes
|
|
256
|
+
|
|
257
|
+
- [#1566](https://github.com/ardatan/whatwg-node/pull/1566)
|
|
258
|
+
[`de1e95a`](https://github.com/ardatan/whatwg-node/commit/de1e95a8eb107083e638aa8472089b96b33bbe4a)
|
|
259
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Avoid constructing DecompressionStream to check
|
|
260
|
+
supported encodings
|
|
261
|
+
|
|
262
|
+
- Updated dependencies
|
|
263
|
+
[[`de1e95a`](https://github.com/ardatan/whatwg-node/commit/de1e95a8eb107083e638aa8472089b96b33bbe4a)]:
|
|
264
|
+
- @whatwg-node/node-fetch@0.5.22
|
|
265
|
+
|
|
266
|
+
## 0.9.19
|
|
267
|
+
|
|
268
|
+
### Patch Changes
|
|
269
|
+
|
|
270
|
+
- [#1495](https://github.com/ardatan/whatwg-node/pull/1495)
|
|
271
|
+
[`bebc159`](https://github.com/ardatan/whatwg-node/commit/bebc159e0a470a0ea89a8575f620ead3f1b6b594)
|
|
272
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Implement \`CompressionStream\`,
|
|
273
|
+
\`WritableStream\` and \`TransformStream\`
|
|
274
|
+
|
|
275
|
+
- Updated dependencies
|
|
276
|
+
[[`bebc159`](https://github.com/ardatan/whatwg-node/commit/bebc159e0a470a0ea89a8575f620ead3f1b6b594)]:
|
|
277
|
+
- @whatwg-node/node-fetch@0.5.16
|
|
278
|
+
|
|
279
|
+
## 0.9.18
|
|
280
|
+
|
|
281
|
+
### Patch Changes
|
|
282
|
+
|
|
283
|
+
- [#1328](https://github.com/ardatan/whatwg-node/pull/1328)
|
|
284
|
+
[`36904b4`](https://github.com/ardatan/whatwg-node/commit/36904b46871aaf823055eb05fbd8969453cba9ae)
|
|
285
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Add `skipPonyfill` flag to `createFetch` to skip
|
|
286
|
+
ponyfills and use the native Fetch implementation for Node.js
|
|
287
|
+
|
|
288
|
+
## 0.9.17
|
|
289
|
+
|
|
290
|
+
### Patch Changes
|
|
291
|
+
|
|
292
|
+
- [#1162](https://github.com/ardatan/whatwg-node/pull/1162)
|
|
293
|
+
[`0c6e9ca`](https://github.com/ardatan/whatwg-node/commit/0c6e9ca61ee07b49009b6e4d7d9d5e1d80912450)
|
|
294
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Consume the body with PassThrough
|
|
295
|
+
|
|
296
|
+
- Updated dependencies
|
|
297
|
+
[[`0c6e9ca`](https://github.com/ardatan/whatwg-node/commit/0c6e9ca61ee07b49009b6e4d7d9d5e1d80912450)]:
|
|
298
|
+
- @whatwg-node/node-fetch@0.5.7
|
|
299
|
+
|
|
300
|
+
## 0.9.16
|
|
301
|
+
|
|
302
|
+
### Patch Changes
|
|
303
|
+
|
|
304
|
+
- [#1102](https://github.com/ardatan/whatwg-node/pull/1102)
|
|
305
|
+
[`d9800cc`](https://github.com/ardatan/whatwg-node/commit/d9800cc1693ceae7893e08cf5a3a4bcc49f0f9d5)
|
|
306
|
+
Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
|
|
307
|
+
- Updated dependency
|
|
308
|
+
[`urlpattern-polyfill@^10.0.0` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/10.0.0)
|
|
309
|
+
(from `^9.0.0`, in `dependencies`)
|
|
310
|
+
- Updated dependencies
|
|
311
|
+
[[`45ec735`](https://github.com/ardatan/whatwg-node/commit/45ec735bd3081f42221bdccb70692b420ce16efa),
|
|
312
|
+
[`a129376`](https://github.com/ardatan/whatwg-node/commit/a1293766bcf8d2465844aec1d80957e2af1b16f1)]:
|
|
313
|
+
- @whatwg-node/node-fetch@0.5.5
|
|
314
|
+
|
|
315
|
+
## 0.9.15
|
|
316
|
+
|
|
317
|
+
### Patch Changes
|
|
318
|
+
|
|
319
|
+
- [`772552c`](https://github.com/ardatan/whatwg-node/commit/772552c0521b883c30d8f4d64c8ea093e75a95a0)
|
|
320
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Skip ponyfilling if NextJS
|
|
321
|
+
|
|
322
|
+
## 0.9.14
|
|
323
|
+
|
|
324
|
+
### Patch Changes
|
|
325
|
+
|
|
326
|
+
- [`68ac24c`](https://github.com/ardatan/whatwg-node/commit/68ac24c342bf2215450bb910c2132f6db0b62993)
|
|
327
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Support TypeScript 5.2.2
|
|
328
|
+
|
|
329
|
+
- Updated dependencies
|
|
330
|
+
[[`f7e507f`](https://github.com/ardatan/whatwg-node/commit/f7e507f6565a1f9cd50fc8c01594ce21205a05dd)]:
|
|
331
|
+
- @whatwg-node/node-fetch@0.5.0
|
|
332
|
+
|
|
333
|
+
## 0.9.13
|
|
334
|
+
|
|
335
|
+
### Patch Changes
|
|
336
|
+
|
|
337
|
+
- [`854b778`](https://github.com/ardatan/whatwg-node/commit/854b7786f4ef134a00a4f8f4df02721a7a4c77bb)
|
|
338
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Do not try to import node-libcurl in Deno and Bun
|
|
339
|
+
|
|
340
|
+
## 0.9.12
|
|
341
|
+
|
|
342
|
+
### Patch Changes
|
|
343
|
+
|
|
344
|
+
- [`a8467ab`](https://github.com/ardatan/whatwg-node/commit/a8467ab9e3e4701eb0d3101ff904597cd9adc438)
|
|
345
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Fake promise's then method may not take a
|
|
346
|
+
callback function
|
|
347
|
+
|
|
348
|
+
- Updated dependencies
|
|
349
|
+
[[`a8467ab`](https://github.com/ardatan/whatwg-node/commit/a8467ab9e3e4701eb0d3101ff904597cd9adc438)]:
|
|
350
|
+
- @whatwg-node/node-fetch@0.4.17
|
|
351
|
+
|
|
352
|
+
## 0.9.11
|
|
353
|
+
|
|
354
|
+
### Patch Changes
|
|
355
|
+
|
|
356
|
+
- [`96efb10`](https://github.com/ardatan/whatwg-node/commit/96efb10a4508fa1b86482f5238d63ec6015e0d74)
|
|
357
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Ignore content-length while reading the request
|
|
358
|
+
body
|
|
359
|
+
|
|
360
|
+
- Updated dependencies
|
|
361
|
+
[[`96efb10`](https://github.com/ardatan/whatwg-node/commit/96efb10a4508fa1b86482f5238d63ec6015e0d74)]:
|
|
362
|
+
- @whatwg-node/node-fetch@0.4.16
|
|
363
|
+
|
|
364
|
+
## 0.9.10
|
|
365
|
+
|
|
366
|
+
### Patch Changes
|
|
367
|
+
|
|
368
|
+
- [#806](https://github.com/ardatan/whatwg-node/pull/806)
|
|
369
|
+
[`9b6911a`](https://github.com/ardatan/whatwg-node/commit/9b6911a8fca0fc046278a8b490e14eb4412da98f)
|
|
370
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Return `Buffer` instead of `ArrayBuffer` in
|
|
371
|
+
`.arrayBuffer` due to a bug in Node.js that returns a bigger ArrayBuffer causing memory overflow
|
|
372
|
+
- Updated dependencies
|
|
373
|
+
[[`9b6911a`](https://github.com/ardatan/whatwg-node/commit/9b6911a8fca0fc046278a8b490e14eb4412da98f)]:
|
|
374
|
+
- @whatwg-node/node-fetch@0.4.15
|
|
375
|
+
|
|
376
|
+
## 0.9.9
|
|
377
|
+
|
|
378
|
+
### Patch Changes
|
|
379
|
+
|
|
380
|
+
- [#567](https://github.com/ardatan/whatwg-node/pull/567)
|
|
381
|
+
[`f8715cd`](https://github.com/ardatan/whatwg-node/commit/f8715cd15175e348169a11fd5531b901fec47e62)
|
|
382
|
+
Thanks [@ardatan](https://github.com/ardatan)! - ### Faster HTTP Client experience in Node.js with
|
|
383
|
+
HTTP/2 support
|
|
384
|
+
|
|
385
|
+
If you install `node-libcurl` seperately, `@whatwg-node/fetch` will select `libcurl` instead of
|
|
386
|
+
`node:http` which is faster.
|
|
387
|
+
|
|
388
|
+
[See benchmarks](https://github.com/JCMais/node-libcurl/tree/develop/benchmark#ubuntu-1910-i7-5500u-24ghz---linux-530-42---node-v12162)
|
|
389
|
+
|
|
390
|
+
- Updated dependencies
|
|
391
|
+
[[`f8715cd`](https://github.com/ardatan/whatwg-node/commit/f8715cd15175e348169a11fd5531b901fec47e62)]:
|
|
392
|
+
- @whatwg-node/node-fetch@0.4.8
|
|
393
|
+
|
|
394
|
+
## 0.9.8
|
|
395
|
+
|
|
396
|
+
### Patch Changes
|
|
397
|
+
|
|
398
|
+
- [`a1c2140`](https://github.com/ardatan/whatwg-node/commit/a1c2140240388ca11a6f4c7bcec2682c47bdc24d)
|
|
399
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Do not use async iterators to consume incoming
|
|
400
|
+
Readable stream
|
|
401
|
+
|
|
402
|
+
- Updated dependencies
|
|
403
|
+
[[`a1c2140`](https://github.com/ardatan/whatwg-node/commit/a1c2140240388ca11a6f4c7bcec2682c47bdc24d)]:
|
|
404
|
+
- @whatwg-node/node-fetch@0.4.7
|
|
405
|
+
|
|
406
|
+
## 0.9.7
|
|
407
|
+
|
|
408
|
+
### Patch Changes
|
|
409
|
+
|
|
410
|
+
- [`124bbe5`](https://github.com/ardatan/whatwg-node/commit/124bbe55f125dc9248fdde9c7e86637d905739fe)
|
|
411
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Implement Headers.getSetCookie and a custom
|
|
412
|
+
serializer for node.inspect
|
|
413
|
+
|
|
414
|
+
- Updated dependencies
|
|
415
|
+
[[`124bbe5`](https://github.com/ardatan/whatwg-node/commit/124bbe55f125dc9248fdde9c7e86637d905739fe)]:
|
|
416
|
+
- @whatwg-node/node-fetch@0.4.6
|
|
417
|
+
|
|
418
|
+
## 0.9.6
|
|
419
|
+
|
|
420
|
+
### Patch Changes
|
|
421
|
+
|
|
422
|
+
- [#614](https://github.com/ardatan/whatwg-node/pull/614)
|
|
423
|
+
[`f07d1c5`](https://github.com/ardatan/whatwg-node/commit/f07d1c5af5d17d64a45162a23a755ae8ce11ac93)
|
|
424
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Performance optimizations
|
|
425
|
+
|
|
426
|
+
- Updated dependencies
|
|
427
|
+
[[`f07d1c5`](https://github.com/ardatan/whatwg-node/commit/f07d1c5af5d17d64a45162a23a755ae8ce11ac93)]:
|
|
428
|
+
- @whatwg-node/node-fetch@0.4.5
|
|
429
|
+
|
|
430
|
+
## 0.9.5
|
|
431
|
+
|
|
432
|
+
### Patch Changes
|
|
433
|
+
|
|
434
|
+
- [#612](https://github.com/ardatan/whatwg-node/pull/612)
|
|
435
|
+
[`273ca94`](https://github.com/ardatan/whatwg-node/commit/273ca94a35e0d4236d932e28f295f405d9adbd4c)
|
|
436
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Performance optimizations
|
|
437
|
+
|
|
438
|
+
- Updated dependencies
|
|
439
|
+
[[`273ca94`](https://github.com/ardatan/whatwg-node/commit/273ca94a35e0d4236d932e28f295f405d9adbd4c)]:
|
|
440
|
+
- @whatwg-node/node-fetch@0.4.4
|
|
441
|
+
|
|
442
|
+
## 0.9.4
|
|
443
|
+
|
|
444
|
+
### Patch Changes
|
|
445
|
+
|
|
446
|
+
- [#597](https://github.com/ardatan/whatwg-node/pull/597)
|
|
447
|
+
[`d118d53`](https://github.com/ardatan/whatwg-node/commit/d118d538f3ab75f87728c4c8373b5b53fb8e1d51)
|
|
448
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Performance optimizations
|
|
449
|
+
|
|
450
|
+
- Updated dependencies
|
|
451
|
+
[[`d118d53`](https://github.com/ardatan/whatwg-node/commit/d118d538f3ab75f87728c4c8373b5b53fb8e1d51)]:
|
|
452
|
+
- @whatwg-node/node-fetch@0.4.3
|
|
453
|
+
|
|
454
|
+
## 0.9.3
|
|
455
|
+
|
|
456
|
+
### Patch Changes
|
|
457
|
+
|
|
458
|
+
- [`d7d9d9f`](https://github.com/ardatan/whatwg-node/commit/d7d9d9ff8903126eb3a346d35dcf621cafff1bd8)
|
|
459
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Bump internal packages
|
|
460
|
+
|
|
461
|
+
- Updated dependencies
|
|
462
|
+
[[`d7d9d9f`](https://github.com/ardatan/whatwg-node/commit/d7d9d9ff8903126eb3a346d35dcf621cafff1bd8)]:
|
|
463
|
+
- @whatwg-node/node-fetch@0.4.2
|
|
464
|
+
|
|
465
|
+
## 0.9.2
|
|
466
|
+
|
|
467
|
+
### Patch Changes
|
|
468
|
+
|
|
469
|
+
- [#577](https://github.com/ardatan/whatwg-node/pull/577)
|
|
470
|
+
[`99f00e8`](https://github.com/ardatan/whatwg-node/commit/99f00e813fbe9cd1986bbf72c40d66df935a4c5b)
|
|
471
|
+
Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
|
|
472
|
+
- Updated dependency
|
|
473
|
+
[`urlpattern-polyfill@^9.0.0` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/9.0.0)
|
|
474
|
+
(from `^8.0.0`, in `dependencies`)
|
|
475
|
+
|
|
476
|
+
## 0.9.1
|
|
477
|
+
|
|
478
|
+
### Patch Changes
|
|
479
|
+
|
|
480
|
+
- [`58b733d`](https://github.com/ardatan/whatwg-node/commit/58b733da41ca913348abd30e2253b332370aa51d)
|
|
481
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Bump node-fetch package
|
|
482
|
+
|
|
483
|
+
## 0.9.0
|
|
484
|
+
|
|
485
|
+
### Minor Changes
|
|
486
|
+
|
|
487
|
+
- [#535](https://github.com/ardatan/whatwg-node/pull/535)
|
|
488
|
+
[`01051f8`](https://github.com/ardatan/whatwg-node/commit/01051f8b3408ac26612b8d8ea2702a3f7e6667af)
|
|
489
|
+
Thanks [@ardatan](https://github.com/ardatan)! - Drop Node 14 support
|
|
490
|
+
|
|
491
|
+
### Patch Changes
|
|
492
|
+
|
|
493
|
+
- [#535](https://github.com/ardatan/whatwg-node/pull/535)
|
|
494
|
+
[`01051f8`](https://github.com/ardatan/whatwg-node/commit/01051f8b3408ac26612b8d8ea2702a3f7e6667af)
|
|
495
|
+
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
496
|
+
- Removed dependency
|
|
497
|
+
[`@peculiar/webcrypto@^1.4.0` ↗︎](https://www.npmjs.com/package/@peculiar/webcrypto/v/1.4.0)
|
|
498
|
+
(from `dependencies`)
|
|
499
|
+
- Removed dependency [`busboy@^1.6.0` ↗︎](https://www.npmjs.com/package/busboy/v/1.6.0) (from
|
|
500
|
+
`dependencies`)
|
|
501
|
+
- Removed dependency
|
|
502
|
+
[`web-streams-polyfill@^3.2.1` ↗︎](https://www.npmjs.com/package/web-streams-polyfill/v/3.2.1)
|
|
503
|
+
(from `dependencies`)
|
|
504
|
+
- Updated dependencies
|
|
505
|
+
[[`01051f8`](https://github.com/ardatan/whatwg-node/commit/01051f8b3408ac26612b8d8ea2702a3f7e6667af)]:
|
|
506
|
+
- @whatwg-node/node-fetch@0.4.0
|
|
507
|
+
|
|
3
508
|
## 0.8.8
|
|
4
509
|
|
|
5
510
|
### Patch Changes
|
|
@@ -14,7 +519,6 @@
|
|
|
14
519
|
- [#495](https://github.com/ardatan/whatwg-node/pull/495)
|
|
15
520
|
[`1a2a92f`](https://github.com/ardatan/whatwg-node/commit/1a2a92fcc4e06342bcc5b18b8c7f2373edfa1552)
|
|
16
521
|
Thanks [@renovate](https://github.com/apps/renovate)! - dependencies updates:
|
|
17
|
-
|
|
18
522
|
- Updated dependency
|
|
19
523
|
[`urlpattern-polyfill@^8.0.0` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/8.0.0)
|
|
20
524
|
(from `^7.0.0`, in `dependencies`)
|
|
@@ -132,7 +636,6 @@
|
|
|
132
636
|
- [#314](https://github.com/ardatan/whatwg-node/pull/314)
|
|
133
637
|
[`3aa1848`](https://github.com/ardatan/whatwg-node/commit/3aa18486d44c507617b25204c3d4a96bc8a4c9e4)
|
|
134
638
|
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
135
|
-
|
|
136
639
|
- Updated dependency
|
|
137
640
|
[`@whatwg-node/node-fetch@^0.0.4` ↗︎](https://www.npmjs.com/package/@whatwg-node/node-fetch/v/0.0.4)
|
|
138
641
|
(from `0.0.4`, in `dependencies`)
|
|
@@ -194,7 +697,6 @@
|
|
|
194
697
|
- [#154](https://github.com/ardatan/whatwg-node/pull/154)
|
|
195
698
|
[`9f4fe48`](https://github.com/ardatan/whatwg-node/commit/9f4fe489ff1d08d873a2dd26c02abc54da08dc48)
|
|
196
699
|
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
197
|
-
|
|
198
700
|
- Updated dependency
|
|
199
701
|
[`web-streams-polyfill@^3.2.1` ↗︎](https://www.npmjs.com/package/web-streams-polyfill/v/3.2.1)
|
|
200
702
|
(from `^3.2.0`, in `dependencies`)
|
|
@@ -255,8 +757,8 @@
|
|
|
255
757
|
[`563cfaa`](https://github.com/ardatan/whatwg-node/commit/563cfaaacf8bb0b08371b7f44887321d7e7c472d)
|
|
256
758
|
Thanks [@ardatan](https://github.com/ardatan)! - dependencies updates:
|
|
257
759
|
- Added dependency
|
|
258
|
-
[`urlpattern-polyfill@^6.0.2` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/6.0.2)
|
|
259
|
-
`dependencies`)
|
|
760
|
+
[`urlpattern-polyfill@^6.0.2` ↗︎](https://www.npmjs.com/package/urlpattern-polyfill/v/6.0.2)
|
|
761
|
+
(to `dependencies`)
|
|
260
762
|
|
|
261
763
|
## 0.5.4
|
|
262
764
|
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Fetch Standard.
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
|
|
12
|
+
npm install @whatwg-node/fetch
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Why Fetch API and why this ponyfill in general?
|
|
@@ -37,6 +37,15 @@ way.
|
|
|
37
37
|
`Buffer` is faster than the native one unfortunately.
|
|
38
38
|
- `Body.formData()` is not implemented by Node.js, so we implement it with `busboy` internally. So
|
|
39
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)
|
|
40
49
|
|
|
41
50
|
### Handling file uploads with Fetch API
|
|
42
51
|
|
|
@@ -1,44 +1,61 @@
|
|
|
1
|
+
const shouldSkipPonyfill = require('./shouldSkipPonyfill');
|
|
2
|
+
let newNodeFetch;
|
|
3
|
+
|
|
1
4
|
module.exports = function createNodePonyfill(opts = {}) {
|
|
2
5
|
const ponyfills = {};
|
|
3
6
|
|
|
7
|
+
ponyfills.URLPattern = globalThis.URLPattern;
|
|
8
|
+
|
|
4
9
|
// We call this previously to patch `Bun`
|
|
5
10
|
if (!ponyfills.URLPattern) {
|
|
6
11
|
const urlPatternModule = require('urlpattern-polyfill');
|
|
7
12
|
ponyfills.URLPattern = urlPatternModule.URLPattern;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
};
|
|
13
39
|
}
|
|
14
40
|
|
|
15
|
-
|
|
41
|
+
newNodeFetch ||= require('@whatwg-node/node-fetch');
|
|
16
42
|
|
|
17
43
|
ponyfills.fetch = newNodeFetch.fetch;
|
|
18
44
|
ponyfills.Request = newNodeFetch.Request;
|
|
19
45
|
ponyfills.Response = newNodeFetch.Response;
|
|
20
46
|
ponyfills.Headers = newNodeFetch.Headers;
|
|
21
47
|
ponyfills.FormData = newNodeFetch.FormData;
|
|
22
|
-
ponyfills.AbortController = newNodeFetch.AbortController;
|
|
23
48
|
ponyfills.ReadableStream = newNodeFetch.ReadableStream;
|
|
24
49
|
|
|
25
50
|
ponyfills.URL = newNodeFetch.URL;
|
|
26
51
|
ponyfills.URLSearchParams = newNodeFetch.URLSearchParams;
|
|
27
52
|
|
|
28
|
-
ponyfills.WritableStream =
|
|
29
|
-
ponyfills.TransformStream =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ponyfills.WritableStream = streamsWeb.WritableStream;
|
|
35
|
-
ponyfills.TransformStream = streamsWeb.TransformStream;
|
|
36
|
-
} catch (e) {
|
|
37
|
-
const streamsWeb = require("web-streams-polyfill/ponyfill");
|
|
38
|
-
ponyfills.WritableStream = streamsWeb.WritableStream;
|
|
39
|
-
ponyfills.TransformStream = streamsWeb.TransformStream;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
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;
|
|
42
59
|
|
|
43
60
|
ponyfills.Blob = newNodeFetch.Blob;
|
|
44
61
|
ponyfills.File = newNodeFetch.File;
|
|
@@ -46,7 +63,6 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
46
63
|
ponyfills.btoa = newNodeFetch.btoa;
|
|
47
64
|
ponyfills.TextEncoder = newNodeFetch.TextEncoder;
|
|
48
65
|
ponyfills.TextDecoder = newNodeFetch.TextDecoder;
|
|
49
|
-
ponyfills.AbortSignal = newNodeFetch.AbortSignal;
|
|
50
66
|
|
|
51
67
|
if (opts.formDataLimits) {
|
|
52
68
|
ponyfills.Body = class Body extends newNodeFetch.Body {
|
|
@@ -80,10 +96,5 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
80
96
|
ponyfills.crypto = cryptoModule.webcrypto;
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
if (!ponyfills.crypto) {
|
|
84
|
-
const cryptoPonyfill = require('@peculiar/webcrypto');
|
|
85
|
-
ponyfills.crypto = new cryptoPonyfill.Crypto();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
99
|
return ponyfills;
|
|
89
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
|
+
}
|
package/dist/global-ponyfill.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
module.exports.fetch = globalThis.fetch;
|
|
1
|
+
module.exports.fetch = globalThis.fetch;
|
|
2
2
|
module.exports.Headers = globalThis.Headers;
|
|
3
3
|
module.exports.Request = globalThis.Request;
|
|
4
4
|
module.exports.Response = globalThis.Response;
|
|
5
5
|
module.exports.FormData = globalThis.FormData;
|
|
6
|
-
module.exports.AbortSignal = globalThis.AbortSignal;
|
|
7
|
-
module.exports.AbortController = globalThis.AbortController;
|
|
8
6
|
module.exports.ReadableStream = globalThis.ReadableStream;
|
|
9
7
|
module.exports.WritableStream = globalThis.WritableStream;
|
|
10
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;
|
|
11
13
|
module.exports.Blob = globalThis.Blob;
|
|
12
14
|
module.exports.File = globalThis.File;
|
|
13
15
|
module.exports.crypto = globalThis.crypto;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
/// <reference lib="dom.iterable" />
|
|
3
|
-
/// <reference types="urlpattern-polyfill" />
|
|
4
3
|
|
|
5
4
|
declare type _URLPattern = typeof URLPattern
|
|
6
5
|
|
|
@@ -12,11 +11,13 @@ declare module '@whatwg-node/fetch' {
|
|
|
12
11
|
};
|
|
13
12
|
export const Headers: typeof globalThis.Headers;
|
|
14
13
|
export const FormData: typeof globalThis.FormData;
|
|
15
|
-
export const AbortSignal: typeof globalThis.AbortSignal;
|
|
16
|
-
export const AbortController: typeof globalThis.AbortController;
|
|
17
14
|
export const ReadableStream: typeof globalThis.ReadableStream;
|
|
18
15
|
export const WritableStream: typeof globalThis.WritableStream;
|
|
19
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;
|
|
20
21
|
export const Blob: typeof globalThis.Blob;
|
|
21
22
|
export const File: typeof globalThis.File;
|
|
22
23
|
export const crypto: typeof globalThis.crypto;
|
|
@@ -45,17 +46,20 @@ declare module '@whatwg-node/fetch' {
|
|
|
45
46
|
export const createFetch: (opts?: {
|
|
46
47
|
useNodeFetch?: boolean;
|
|
47
48
|
formDataLimits?: FormDataLimits;
|
|
49
|
+
skipPonyfill?: boolean;
|
|
48
50
|
}) => {
|
|
49
51
|
fetch: typeof fetch;
|
|
50
52
|
Request: typeof Request;
|
|
51
53
|
Response: typeof Response;
|
|
52
54
|
Headers: typeof Headers;
|
|
53
55
|
FormData: typeof FormData;
|
|
54
|
-
AbortSignal: typeof AbortSignal;
|
|
55
|
-
AbortController: typeof AbortController;
|
|
56
56
|
ReadableStream: typeof ReadableStream;
|
|
57
57
|
WritableStream: typeof WritableStream;
|
|
58
58
|
TransformStream: typeof TransformStream;
|
|
59
|
+
CompressionStream: typeof CompressionStream;
|
|
60
|
+
DecompressionStream: typeof DecompressionStream;
|
|
61
|
+
TextDecoderStream: typeof TextDecoderStream;
|
|
62
|
+
TextEncoderStream: typeof TextEncoderStream;
|
|
59
63
|
Blob: typeof Blob;
|
|
60
64
|
File: typeof File;
|
|
61
65
|
crypto: typeof crypto;
|
package/dist/node-ponyfill.js
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
|
|
2
2
|
const createNodePonyfill = require('./create-node-ponyfill');
|
|
3
|
+
const shouldSkipPonyfill = require('./shouldSkipPonyfill');
|
|
3
4
|
const ponyfills = createNodePonyfill();
|
|
4
5
|
|
|
6
|
+
if (!shouldSkipPonyfill()) {
|
|
7
|
+
try {
|
|
8
|
+
const nodelibcurlName = 'node-libcurl'
|
|
9
|
+
globalThis.libcurl = globalThis.libcurl || require(nodelibcurlName);
|
|
10
|
+
} catch (e) { }
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
module.exports.fetch = ponyfills.fetch;
|
|
6
14
|
module.exports.Headers = ponyfills.Headers;
|
|
7
15
|
module.exports.Request = ponyfills.Request;
|
|
8
16
|
module.exports.Response = ponyfills.Response;
|
|
9
17
|
module.exports.FormData = ponyfills.FormData;
|
|
10
|
-
module.exports.AbortSignal = ponyfills.AbortSignal;
|
|
11
|
-
module.exports.AbortController = ponyfills.AbortController;
|
|
12
18
|
module.exports.ReadableStream = ponyfills.ReadableStream;
|
|
13
19
|
module.exports.WritableStream = ponyfills.WritableStream;
|
|
14
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;
|
|
15
25
|
module.exports.Blob = ponyfills.Blob;
|
|
16
26
|
module.exports.File = ponyfills.File;
|
|
17
27
|
module.exports.crypto = ponyfills.crypto;
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatwg-node/fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"description": "Cross Platform Smart Fetch Ponyfill",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
},
|
|
10
10
|
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
11
11
|
"license": "MIT",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=18.0.0"
|
|
14
|
+
},
|
|
12
15
|
"main": "dist/node-ponyfill.js",
|
|
13
16
|
"browser": "dist/global-ponyfill.js",
|
|
14
17
|
"types": "dist/index.d.ts",
|
|
15
18
|
"dependencies": {
|
|
16
|
-
"@
|
|
17
|
-
"
|
|
18
|
-
"busboy": "^1.6.0",
|
|
19
|
-
"urlpattern-polyfill": "^8.0.0",
|
|
20
|
-
"web-streams-polyfill": "^3.2.1"
|
|
19
|
+
"@whatwg-node/node-fetch": "^0.8.3",
|
|
20
|
+
"urlpattern-polyfill": "^10.0.0"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"bob": false,
|
|
27
27
|
"denoify": {
|
|
28
|
-
"index": "dist/
|
|
28
|
+
"index": "dist/esm-ponyfill.js"
|
|
29
29
|
},
|
|
30
30
|
"react-native": "dist/global-ponyfill.js"
|
|
31
31
|
}
|
package/dist/deno-ponyfill.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const fetch = globalThis.fetch;
|
|
2
|
-
const Request = globalThis.Request;
|
|
3
|
-
const Response = globalThis.Response;
|
|
4
|
-
const Headers = globalThis.Headers;
|
|
5
|
-
const FormData = globalThis.FormData;
|
|
6
|
-
const AbortSignal = globalThis.AbortSignal;
|
|
7
|
-
const AbortController = globalThis.AbortController;
|
|
8
|
-
const ReadableStream = globalThis.ReadableStream;
|
|
9
|
-
const WritableStream = globalThis.WritableStream;
|
|
10
|
-
const TransformStream = globalThis.TransformStream;
|
|
11
|
-
const Blob = globalThis.Blob;
|
|
12
|
-
const File = globalThis.File;
|
|
13
|
-
const crypto = globalThis.crypto;
|
|
14
|
-
const btoa = globalThis.btoa;
|
|
15
|
-
const TextDecoder = globalThis.TextDecoder;
|
|
16
|
-
const TextEncoder = globalThis.TextEncoder;
|
|
17
|
-
const URLPattern = (globalThis as any).URLPattern;
|
|
18
|
-
const URL = globalThis.URL;
|
|
19
|
-
const URLSearchParams = globalThis.URLSearchParams;
|
|
20
|
-
|
|
21
|
-
export const createFetch = () => globalThis;
|
|
22
|
-
export {
|
|
23
|
-
fetch,
|
|
24
|
-
Headers,
|
|
25
|
-
Request,
|
|
26
|
-
Response,
|
|
27
|
-
FormData,
|
|
28
|
-
AbortSignal,
|
|
29
|
-
AbortController,
|
|
30
|
-
ReadableStream,
|
|
31
|
-
WritableStream,
|
|
32
|
-
TransformStream,
|
|
33
|
-
Blob,
|
|
34
|
-
File,
|
|
35
|
-
crypto,
|
|
36
|
-
btoa,
|
|
37
|
-
TextDecoder,
|
|
38
|
-
TextEncoder,
|
|
39
|
-
URLPattern,
|
|
40
|
-
URL,
|
|
41
|
-
URLSearchParams,
|
|
42
|
-
};
|