@whatwg-node/fetch 0.0.1 → 0.1.1
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 +24 -0
- package/dist/create-node-ponyfill.js +21 -0
- package/dist/deno-ponyfill.ts +4 -0
- package/dist/global-ponyfill.js +2 -0
- package/dist/index.d.ts +7 -1
- package/dist/node-ponyfill.js +4 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @whatwg-node/fetch
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 16aff71: Fix missing TextEncoder and TextDecoder in the default ponyfill
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- b83d7f3: Faster TextEncoder & TextDecoder with Buffer in Node
|
|
14
|
+
- b83d7f3: Ponyfill for WebCrypto API
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b83d7f3: Bump undici version
|
|
19
|
+
- b83d7f3: Now ponyfills Event API
|
|
20
|
+
|
|
21
|
+
## 0.0.2
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 3207383: Fix TS typings
|
|
26
|
+
|
|
3
27
|
## 0.0.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -50,6 +50,22 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
ponyfills.TextEncoder = function TextEncoder() {
|
|
54
|
+
return {
|
|
55
|
+
encode(str) {
|
|
56
|
+
return Buffer.from(str, "utf8");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
ponyfills.TextDecoder = function TextDecoder() {
|
|
62
|
+
return {
|
|
63
|
+
decode(buf) {
|
|
64
|
+
return buf.toString("utf8");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
// ReadableStream doesn't handle aborting properly, so we need to patch it
|
|
54
70
|
ponyfills.ReadableStream = class PonyfillReadableStream extends ponyfills.ReadableStream {
|
|
55
71
|
constructor(underlyingSource, ...opts) {
|
|
@@ -98,6 +114,11 @@ module.exports = function createNodePonyfill(opts = {}) {
|
|
|
98
114
|
ponyfills.crypto = cryptoModule.webcrypto;
|
|
99
115
|
}
|
|
100
116
|
|
|
117
|
+
if (!ponyfills.crypto) {
|
|
118
|
+
const cryptoPonyfill = require('@peculiar/webcrypto');
|
|
119
|
+
ponyfills.crypto = new cryptoPonyfill.Crypto();
|
|
120
|
+
}
|
|
121
|
+
|
|
101
122
|
// If any of classes of Fetch API is missing, we need to ponyfill them.
|
|
102
123
|
if (!ponyfills.fetch ||
|
|
103
124
|
!ponyfills.Request ||
|
package/dist/deno-ponyfill.ts
CHANGED
|
@@ -10,6 +10,8 @@ const TransformStream = globalThis.TransformStream;
|
|
|
10
10
|
const Blob = globalThis.Blob;
|
|
11
11
|
const File = globalThis.File;
|
|
12
12
|
const crypto = globalThis.crypto;
|
|
13
|
+
const TextDecoder = globalThis.TextDecoder;
|
|
14
|
+
const TextEncoder = globalThis.TextEncoder;
|
|
13
15
|
|
|
14
16
|
export const create = () => globalThis;
|
|
15
17
|
export {
|
|
@@ -25,4 +27,6 @@ export {
|
|
|
25
27
|
Blob,
|
|
26
28
|
File,
|
|
27
29
|
crypto,
|
|
30
|
+
TextDecoder,
|
|
31
|
+
TextEncoder,
|
|
28
32
|
};
|
package/dist/global-ponyfill.js
CHANGED
|
@@ -10,4 +10,6 @@ module.exports.TransformStream = globalThis.TransformStream;
|
|
|
10
10
|
module.exports.Blob = globalThis.Blob;
|
|
11
11
|
module.exports.File = globalThis.File;
|
|
12
12
|
module.exports.crypto = globalThis.crypto;
|
|
13
|
+
module.exports.TextEncoder = globalThis.TextEncoder;
|
|
14
|
+
module.exports.TextDecoder = globalThis.TextDecoder;
|
|
13
15
|
module.exports.createFetch = () => globalThis;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ declare const _TransformStream: typeof TransformStream;
|
|
|
12
12
|
declare const _Blob: typeof Blob;
|
|
13
13
|
declare const _File: typeof File;
|
|
14
14
|
declare const _crypto: typeof crypto;
|
|
15
|
+
declare const _TextEncoder: typeof TextEncoder;
|
|
16
|
+
declare const _TextDecoder: typeof TextDecoder;
|
|
15
17
|
|
|
16
18
|
declare module "@whatwg-node/fetch" {
|
|
17
19
|
export const fetch: typeof _fetch;
|
|
@@ -26,6 +28,8 @@ declare module "@whatwg-node/fetch" {
|
|
|
26
28
|
export const Blob: typeof _Blob;
|
|
27
29
|
export const File: typeof _File;
|
|
28
30
|
export const crypto: typeof _crypto;
|
|
31
|
+
export const TextDecoder: typeof _TextDecoder;
|
|
32
|
+
export const TextEncoder: typeof _TextEncoder;
|
|
29
33
|
export interface FormDataLimits {
|
|
30
34
|
/* Max field name size (in bytes). Default: 100. */
|
|
31
35
|
fieldNameSize?: number;
|
|
@@ -42,7 +46,7 @@ declare module "@whatwg-node/fetch" {
|
|
|
42
46
|
/* For multipart forms, the max number of header key-value pairs to parse. Default: 2000. */
|
|
43
47
|
headerSize?: number;
|
|
44
48
|
}
|
|
45
|
-
export const
|
|
49
|
+
export const createFetch: (opts?: { useNodeFetch?: boolean; formDataLimits?: FormDataLimits }) => ({
|
|
46
50
|
fetch: typeof _fetch,
|
|
47
51
|
Request: typeof _Request,
|
|
48
52
|
Response: typeof _Response,
|
|
@@ -55,6 +59,8 @@ declare module "@whatwg-node/fetch" {
|
|
|
55
59
|
Blob: typeof _Blob,
|
|
56
60
|
File: typeof _File,
|
|
57
61
|
crypto: typeof _crypto
|
|
62
|
+
TextEncoder: typeof _TextEncoder,
|
|
63
|
+
TextDecoder: typeof _TextDecoder
|
|
58
64
|
});
|
|
59
65
|
}
|
|
60
66
|
|
package/dist/node-ponyfill.js
CHANGED
|
@@ -14,4 +14,8 @@ module.exports.TransformStream = ponyfills.TransformStream;
|
|
|
14
14
|
module.exports.Blob = ponyfills.Blob;
|
|
15
15
|
module.exports.File = ponyfills.File;
|
|
16
16
|
module.exports.crypto = ponyfills.crypto;
|
|
17
|
+
module.exports.TextEncoder = ponyfills.TextEncoder;
|
|
18
|
+
module.exports.TextDecoder = ponyfills.TextDecoder;
|
|
17
19
|
exports.createFetch = createNodePonyfill;
|
|
20
|
+
|
|
21
|
+
require('event-target-polyfill');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatwg-node/fetch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Cross Platform Smart Fetch Ponyfill",
|
|
5
5
|
"author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
|
|
6
6
|
"repository": {
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
"index": "dist/deno-ponyfill.ts"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@peculiar/webcrypto": "^1.4.0",
|
|
21
22
|
"abort-controller": "^3.0.0",
|
|
22
23
|
"busboy": "^1.6.0",
|
|
24
|
+
"event-target-polyfill": "^0.0.3",
|
|
23
25
|
"form-data-encoder": "^1.7.1",
|
|
24
26
|
"formdata-node": "^4.3.1",
|
|
25
27
|
"node-fetch": "^2.6.7",
|
|
26
|
-
"undici": "5.
|
|
28
|
+
"undici": "^5.8.0",
|
|
27
29
|
"web-streams-polyfill": "^3.2.0"
|
|
28
30
|
},
|
|
29
31
|
"publishConfig": {
|