@whatwg-node/node-fetch 0.4.0-alpha-20230215090500-a3d0322 → 0.4.0-alpha-20230515121132-c9d0290
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/cjs/FormData.js +13 -0
- package/cjs/Headers.js +6 -0
- package/cjs/Request.js +3 -2
- package/cjs/Response.js +2 -1
- package/cjs/URLSearchParams.js +3 -0
- package/cjs/fetch.js +20 -9
- package/cjs/index.js +1 -7
- package/esm/FormData.js +13 -0
- package/esm/Headers.js +6 -0
- package/esm/Request.js +3 -2
- package/esm/Response.js +2 -1
- package/esm/URLSearchParams.js +3 -0
- package/esm/fetch.js +20 -9
- package/esm/index.js +0 -3
- package/package.json +2 -5
- package/typings/Blob.d.cts +13 -1
- package/typings/Blob.d.ts +13 -1
- package/typings/FormData.d.cts +3 -0
- package/typings/FormData.d.ts +3 -0
- package/typings/Headers.d.cts +2 -0
- package/typings/Headers.d.ts +2 -0
- package/typings/Request.d.cts +4 -0
- package/typings/Request.d.ts +4 -0
- package/typings/URLSearchParams.d.cts +1 -0
- package/typings/URLSearchParams.d.ts +1 -0
- package/typings/index.d.cts +0 -3
- package/typings/index.d.ts +0 -3
- package/cjs/AbortController.js +0 -14
- package/cjs/AbortError.js +0 -20
- package/cjs/AbortSignal.js +0 -37
- package/esm/AbortController.js +0 -10
- package/esm/AbortError.js +0 -16
- package/esm/AbortSignal.js +0 -33
- package/typings/AbortController.d.cts +0 -5
- package/typings/AbortController.d.ts +0 -5
- package/typings/AbortError.d.cts +0 -4
- package/typings/AbortError.d.ts +0 -4
- package/typings/AbortSignal.d.cts +0 -11
- package/typings/AbortSignal.d.ts +0 -11
package/cjs/FormData.js
CHANGED
@@ -44,6 +44,19 @@ class PonyfillFormData {
|
|
44
44
|
}
|
45
45
|
}
|
46
46
|
}
|
47
|
+
entries() {
|
48
|
+
return this[Symbol.iterator]();
|
49
|
+
}
|
50
|
+
keys() {
|
51
|
+
return this.map.keys();
|
52
|
+
}
|
53
|
+
*values() {
|
54
|
+
for (const values of this.map.values()) {
|
55
|
+
for (const value of values) {
|
56
|
+
yield value;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
47
60
|
forEach(callback) {
|
48
61
|
for (const [key, value] of this) {
|
49
62
|
callback(value, key, this);
|
package/cjs/Headers.js
CHANGED
package/cjs/Request.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PonyfillRequest = void 0;
|
4
|
-
const AbortController_js_1 = require("./AbortController.js");
|
5
4
|
const Body_js_1 = require("./Body.js");
|
6
5
|
const Headers_js_1 = require("./Headers.js");
|
6
|
+
const utils_js_1 = require("./utils.js");
|
7
7
|
function isRequest(input) {
|
8
8
|
return input[Symbol.toStringTag] === 'Request';
|
9
9
|
}
|
@@ -41,7 +41,8 @@ class PonyfillRequest extends Body_js_1.PonyfillBody {
|
|
41
41
|
this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
|
42
42
|
this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
|
43
43
|
this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
|
44
|
-
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new
|
44
|
+
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new AbortController().signal;
|
45
|
+
this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || utils_js_1.getHeadersObj;
|
45
46
|
this.url = url || '';
|
46
47
|
const contentTypeInHeaders = this.headers.get('content-type');
|
47
48
|
if (!contentTypeInHeaders) {
|
package/cjs/Response.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PonyfillResponse = void 0;
|
4
|
+
const http_1 = require("http");
|
4
5
|
const Body_js_1 = require("./Body.js");
|
5
6
|
const Headers_js_1 = require("./Headers.js");
|
6
7
|
class PonyfillResponse extends Body_js_1.PonyfillBody {
|
@@ -15,7 +16,7 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
|
|
15
16
|
if (init) {
|
16
17
|
this.headers = new Headers_js_1.PonyfillHeaders(init.headers);
|
17
18
|
this.status = init.status || 200;
|
18
|
-
this.statusText = init.statusText || 'OK';
|
19
|
+
this.statusText = init.statusText || http_1.STATUS_CODES[this.status] || 'OK';
|
19
20
|
this.url = init.url || '';
|
20
21
|
this.redirected = init.redirected || false;
|
21
22
|
this.type = init.type || 'default';
|
package/cjs/URLSearchParams.js
CHANGED
package/cjs/fetch.js
CHANGED
@@ -6,7 +6,7 @@ const http_1 = require("http");
|
|
6
6
|
const https_1 = require("https");
|
7
7
|
const stream_1 = require("stream");
|
8
8
|
const url_1 = require("url");
|
9
|
-
const
|
9
|
+
const zlib_1 = require("zlib");
|
10
10
|
const Blob_js_1 = require("./Blob.js");
|
11
11
|
const Request_js_1 = require("./Request.js");
|
12
12
|
const Response_js_1 = require("./Response.js");
|
@@ -71,19 +71,30 @@ function fetchPonyfill(info, init) {
|
|
71
71
|
? fetchRequest.body
|
72
72
|
: stream_1.Readable.from(fetchRequest.body)
|
73
73
|
: null);
|
74
|
-
const
|
75
|
-
const
|
76
|
-
nodeRequest.destroy();
|
77
|
-
const reason = event.detail;
|
78
|
-
reject(new AbortError_js_1.PonyfillAbortError(reason));
|
79
|
-
};
|
80
|
-
fetchRequest.signal.addEventListener('abort', abortListener);
|
74
|
+
const headersSerializer = fetchRequest.headersSerializer || utils_js_1.getHeadersObj;
|
75
|
+
const nodeHeaders = headersSerializer(fetchRequest.headers);
|
81
76
|
const nodeRequest = requestFn(fetchRequest.url, {
|
82
77
|
// signal: fetchRequest.signal will be added when v14 reaches EOL
|
83
78
|
method: fetchRequest.method,
|
84
79
|
headers: nodeHeaders,
|
80
|
+
signal: fetchRequest.signal,
|
85
81
|
});
|
86
82
|
nodeRequest.once('response', nodeResponse => {
|
83
|
+
let responseBody = nodeResponse;
|
84
|
+
const contentEncoding = nodeResponse.headers['content-encoding'];
|
85
|
+
switch (contentEncoding) {
|
86
|
+
case 'x-gzip':
|
87
|
+
case 'gzip':
|
88
|
+
responseBody = nodeResponse.pipe((0, zlib_1.createGunzip)());
|
89
|
+
break;
|
90
|
+
case 'x-deflate':
|
91
|
+
case 'deflate':
|
92
|
+
responseBody = nodeResponse.pipe((0, zlib_1.createInflate)());
|
93
|
+
break;
|
94
|
+
case 'br':
|
95
|
+
responseBody = nodeResponse.pipe((0, zlib_1.createBrotliDecompress)());
|
96
|
+
break;
|
97
|
+
}
|
87
98
|
if (nodeResponse.headers.location) {
|
88
99
|
if (fetchRequest.redirect === 'error') {
|
89
100
|
const redirectError = new Error('Redirects are not allowed');
|
@@ -103,7 +114,7 @@ function fetchPonyfill(info, init) {
|
|
103
114
|
}
|
104
115
|
}
|
105
116
|
const responseHeaders = nodeResponse.headers;
|
106
|
-
const ponyfillResponse = new Response_js_1.PonyfillResponse(
|
117
|
+
const ponyfillResponse = new Response_js_1.PonyfillResponse(responseBody, {
|
107
118
|
status: nodeResponse.statusCode,
|
108
119
|
statusText: nodeResponse.statusMessage,
|
109
120
|
headers: responseHeaders,
|
package/cjs/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.
|
3
|
+
exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = void 0;
|
4
4
|
var fetch_js_1 = require("./fetch.js");
|
5
5
|
Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } });
|
6
6
|
var Headers_js_1 = require("./Headers.js");
|
@@ -17,12 +17,6 @@ var File_js_1 = require("./File.js");
|
|
17
17
|
Object.defineProperty(exports, "File", { enumerable: true, get: function () { return File_js_1.PonyfillFile; } });
|
18
18
|
var FormData_js_1 = require("./FormData.js");
|
19
19
|
Object.defineProperty(exports, "FormData", { enumerable: true, get: function () { return FormData_js_1.PonyfillFormData; } });
|
20
|
-
var AbortController_js_1 = require("./AbortController.js");
|
21
|
-
Object.defineProperty(exports, "AbortController", { enumerable: true, get: function () { return AbortController_js_1.PonyfillAbortController; } });
|
22
|
-
var AbortSignal_js_1 = require("./AbortSignal.js");
|
23
|
-
Object.defineProperty(exports, "AbortSignal", { enumerable: true, get: function () { return AbortSignal_js_1.PonyfillAbortSignal; } });
|
24
|
-
var AbortError_js_1 = require("./AbortError.js");
|
25
|
-
Object.defineProperty(exports, "AbortError", { enumerable: true, get: function () { return AbortError_js_1.PonyfillAbortError; } });
|
26
20
|
var Blob_js_1 = require("./Blob.js");
|
27
21
|
Object.defineProperty(exports, "Blob", { enumerable: true, get: function () { return Blob_js_1.PonyfillBlob; } });
|
28
22
|
var TextEncoderDecoder_js_1 = require("./TextEncoderDecoder.js");
|
package/esm/FormData.js
CHANGED
@@ -41,6 +41,19 @@ export class PonyfillFormData {
|
|
41
41
|
}
|
42
42
|
}
|
43
43
|
}
|
44
|
+
entries() {
|
45
|
+
return this[Symbol.iterator]();
|
46
|
+
}
|
47
|
+
keys() {
|
48
|
+
return this.map.keys();
|
49
|
+
}
|
50
|
+
*values() {
|
51
|
+
for (const values of this.map.values()) {
|
52
|
+
for (const value of values) {
|
53
|
+
yield value;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
44
57
|
forEach(callback) {
|
45
58
|
for (const [key, value] of this) {
|
46
59
|
callback(value, key, this);
|
package/esm/Headers.js
CHANGED
package/esm/Request.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { PonyfillAbortController } from './AbortController.js';
|
2
1
|
import { PonyfillBody } from './Body.js';
|
3
2
|
import { PonyfillHeaders } from './Headers.js';
|
3
|
+
import { getHeadersObj } from './utils.js';
|
4
4
|
function isRequest(input) {
|
5
5
|
return input[Symbol.toStringTag] === 'Request';
|
6
6
|
}
|
@@ -38,7 +38,8 @@ export class PonyfillRequest extends PonyfillBody {
|
|
38
38
|
this.redirect = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.redirect) || 'follow';
|
39
39
|
this.referrer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrer) || 'about:client';
|
40
40
|
this.referrerPolicy = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.referrerPolicy) || 'no-referrer';
|
41
|
-
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new
|
41
|
+
this.signal = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.signal) || new AbortController().signal;
|
42
|
+
this.headersSerializer = (requestInit === null || requestInit === void 0 ? void 0 : requestInit.headersSerializer) || getHeadersObj;
|
42
43
|
this.url = url || '';
|
43
44
|
const contentTypeInHeaders = this.headers.get('content-type');
|
44
45
|
if (!contentTypeInHeaders) {
|
package/esm/Response.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { STATUS_CODES } from 'http';
|
1
2
|
import { PonyfillBody } from './Body.js';
|
2
3
|
import { PonyfillHeaders } from './Headers.js';
|
3
4
|
export class PonyfillResponse extends PonyfillBody {
|
@@ -12,7 +13,7 @@ export class PonyfillResponse extends PonyfillBody {
|
|
12
13
|
if (init) {
|
13
14
|
this.headers = new PonyfillHeaders(init.headers);
|
14
15
|
this.status = init.status || 200;
|
15
|
-
this.statusText = init.statusText || 'OK';
|
16
|
+
this.statusText = init.statusText || STATUS_CODES[this.status] || 'OK';
|
16
17
|
this.url = init.url || '';
|
17
18
|
this.redirected = init.redirected || false;
|
18
19
|
this.type = init.type || 'default';
|
package/esm/URLSearchParams.js
CHANGED
package/esm/fetch.js
CHANGED
@@ -3,7 +3,7 @@ import { request as httpRequest } from 'http';
|
|
3
3
|
import { request as httpsRequest } from 'https';
|
4
4
|
import { Readable } from 'stream';
|
5
5
|
import { fileURLToPath } from 'url';
|
6
|
-
import {
|
6
|
+
import { createBrotliDecompress, createGunzip, createInflate } from 'zlib';
|
7
7
|
import { PonyfillBlob } from './Blob.js';
|
8
8
|
import { PonyfillRequest } from './Request.js';
|
9
9
|
import { PonyfillResponse } from './Response.js';
|
@@ -68,19 +68,30 @@ export function fetchPonyfill(info, init) {
|
|
68
68
|
? fetchRequest.body
|
69
69
|
: Readable.from(fetchRequest.body)
|
70
70
|
: null);
|
71
|
-
const
|
72
|
-
const
|
73
|
-
nodeRequest.destroy();
|
74
|
-
const reason = event.detail;
|
75
|
-
reject(new PonyfillAbortError(reason));
|
76
|
-
};
|
77
|
-
fetchRequest.signal.addEventListener('abort', abortListener);
|
71
|
+
const headersSerializer = fetchRequest.headersSerializer || getHeadersObj;
|
72
|
+
const nodeHeaders = headersSerializer(fetchRequest.headers);
|
78
73
|
const nodeRequest = requestFn(fetchRequest.url, {
|
79
74
|
// signal: fetchRequest.signal will be added when v14 reaches EOL
|
80
75
|
method: fetchRequest.method,
|
81
76
|
headers: nodeHeaders,
|
77
|
+
signal: fetchRequest.signal,
|
82
78
|
});
|
83
79
|
nodeRequest.once('response', nodeResponse => {
|
80
|
+
let responseBody = nodeResponse;
|
81
|
+
const contentEncoding = nodeResponse.headers['content-encoding'];
|
82
|
+
switch (contentEncoding) {
|
83
|
+
case 'x-gzip':
|
84
|
+
case 'gzip':
|
85
|
+
responseBody = nodeResponse.pipe(createGunzip());
|
86
|
+
break;
|
87
|
+
case 'x-deflate':
|
88
|
+
case 'deflate':
|
89
|
+
responseBody = nodeResponse.pipe(createInflate());
|
90
|
+
break;
|
91
|
+
case 'br':
|
92
|
+
responseBody = nodeResponse.pipe(createBrotliDecompress());
|
93
|
+
break;
|
94
|
+
}
|
84
95
|
if (nodeResponse.headers.location) {
|
85
96
|
if (fetchRequest.redirect === 'error') {
|
86
97
|
const redirectError = new Error('Redirects are not allowed');
|
@@ -100,7 +111,7 @@ export function fetchPonyfill(info, init) {
|
|
100
111
|
}
|
101
112
|
}
|
102
113
|
const responseHeaders = nodeResponse.headers;
|
103
|
-
const ponyfillResponse = new PonyfillResponse(
|
114
|
+
const ponyfillResponse = new PonyfillResponse(responseBody, {
|
104
115
|
status: nodeResponse.statusCode,
|
105
116
|
statusText: nodeResponse.statusMessage,
|
106
117
|
headers: responseHeaders,
|
package/esm/index.js
CHANGED
@@ -6,9 +6,6 @@ export { PonyfillResponse as Response } from './Response.js';
|
|
6
6
|
export { PonyfillReadableStream as ReadableStream } from './ReadableStream.js';
|
7
7
|
export { PonyfillFile as File } from './File.js';
|
8
8
|
export { PonyfillFormData as FormData } from './FormData.js';
|
9
|
-
export { PonyfillAbortController as AbortController } from './AbortController.js';
|
10
|
-
export { PonyfillAbortSignal as AbortSignal } from './AbortSignal.js';
|
11
|
-
export { PonyfillAbortError as AbortError } from './AbortError.js';
|
12
9
|
export { PonyfillBlob as Blob } from './Blob.js';
|
13
10
|
export { PonyfillTextEncoder as TextEncoder, PonyfillTextDecoder as TextDecoder, PonyfillBtoa as btoa, } from './TextEncoderDecoder.js';
|
14
11
|
export { PonyfillURL as URL } from './URL.js';
|
package/package.json
CHANGED
@@ -1,13 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.4.0-alpha-
|
3
|
+
"version": "0.4.0-alpha-20230515121132-c9d0290",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
|
-
"peerDependencies": {
|
7
|
-
"@types/node": "^18.0.6"
|
8
|
-
},
|
9
6
|
"dependencies": {
|
10
|
-
"@whatwg-node/events": "
|
7
|
+
"@whatwg-node/events": "0.1.0-alpha-20230515121132-c9d0290",
|
11
8
|
"busboy": "^1.6.0",
|
12
9
|
"fast-querystring": "^1.1.1",
|
13
10
|
"fast-url-parser": "^1.1.3",
|
package/typings/Blob.d.cts
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
|
2
|
+
interface BlobOptions {
|
3
|
+
/**
|
4
|
+
* @default 'utf8'
|
5
|
+
*/
|
6
|
+
encoding?: BufferEncoding | undefined;
|
7
|
+
/**
|
8
|
+
* The Blob content-type. The intent is for `type` to convey
|
9
|
+
* the MIME media type of the data, however no validation of the type format
|
10
|
+
* is performed.
|
11
|
+
*/
|
12
|
+
type?: string | undefined;
|
13
|
+
}
|
3
14
|
export declare class PonyfillBlob implements Blob {
|
4
15
|
private blobParts;
|
5
16
|
type: string;
|
@@ -16,3 +27,4 @@ export interface PonyfillBlob {
|
|
16
27
|
prototype: Blob;
|
17
28
|
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
18
29
|
}
|
30
|
+
export {};
|
package/typings/Blob.d.ts
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
|
2
|
+
interface BlobOptions {
|
3
|
+
/**
|
4
|
+
* @default 'utf8'
|
5
|
+
*/
|
6
|
+
encoding?: BufferEncoding | undefined;
|
7
|
+
/**
|
8
|
+
* The Blob content-type. The intent is for `type` to convey
|
9
|
+
* the MIME media type of the data, however no validation of the type format
|
10
|
+
* is performed.
|
11
|
+
*/
|
12
|
+
type?: string | undefined;
|
13
|
+
}
|
3
14
|
export declare class PonyfillBlob implements Blob {
|
4
15
|
private blobParts;
|
5
16
|
type: string;
|
@@ -16,3 +27,4 @@ export interface PonyfillBlob {
|
|
16
27
|
prototype: Blob;
|
17
28
|
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
|
18
29
|
}
|
30
|
+
export {};
|
package/typings/FormData.d.cts
CHANGED
@@ -9,6 +9,9 @@ export declare class PonyfillFormData implements FormData {
|
|
9
9
|
has(name: string): boolean;
|
10
10
|
set(name: string, value: PonyfillBlob | string, fileName?: string): void;
|
11
11
|
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
12
|
+
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
13
|
+
keys(): IterableIterator<string>;
|
14
|
+
values(): IterableIterator<FormDataEntryValue>;
|
12
15
|
forEach(callback: (value: FormDataEntryValue, key: string, parent: this) => void): void;
|
13
16
|
}
|
14
17
|
export declare function getStreamFromFormData(formData: FormData, boundary?: string): PonyfillReadableStream<Uint8Array>;
|
package/typings/FormData.d.ts
CHANGED
@@ -9,6 +9,9 @@ export declare class PonyfillFormData implements FormData {
|
|
9
9
|
has(name: string): boolean;
|
10
10
|
set(name: string, value: PonyfillBlob | string, fileName?: string): void;
|
11
11
|
[Symbol.iterator](): IterableIterator<[string, FormDataEntryValue]>;
|
12
|
+
entries(): IterableIterator<[string, FormDataEntryValue]>;
|
13
|
+
keys(): IterableIterator<string>;
|
14
|
+
values(): IterableIterator<FormDataEntryValue>;
|
12
15
|
forEach(callback: (value: FormDataEntryValue, key: string, parent: this) => void): void;
|
13
16
|
}
|
14
17
|
export declare function getStreamFromFormData(formData: FormData, boundary?: string): PonyfillReadableStream<Uint8Array>;
|
package/typings/Headers.d.cts
CHANGED
@@ -14,6 +14,8 @@ export declare class PonyfillHeaders implements Headers {
|
|
14
14
|
set(name: string, value: string): void;
|
15
15
|
delete(name: string): void;
|
16
16
|
forEach(callback: (value: string, key: string, parent: Headers) => void): void;
|
17
|
+
keys(): IterableIterator<string>;
|
18
|
+
values(): IterableIterator<string>;
|
17
19
|
entries(): IterableIterator<[string, string]>;
|
18
20
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
19
21
|
}
|
package/typings/Headers.d.ts
CHANGED
@@ -14,6 +14,8 @@ export declare class PonyfillHeaders implements Headers {
|
|
14
14
|
set(name: string, value: string): void;
|
15
15
|
delete(name: string): void;
|
16
16
|
forEach(callback: (value: string, key: string, parent: Headers) => void): void;
|
17
|
+
keys(): IterableIterator<string>;
|
18
|
+
values(): IterableIterator<string>;
|
17
19
|
entries(): IterableIterator<[string, string]>;
|
18
20
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
19
21
|
}
|
package/typings/Request.d.cts
CHANGED
@@ -3,9 +3,12 @@ import { PonyfillHeadersInit } from './Headers.cjs';
|
|
3
3
|
export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
|
4
4
|
body?: BodyPonyfillInit | null;
|
5
5
|
headers?: PonyfillHeadersInit;
|
6
|
+
headersSerializer?: HeadersSerializer;
|
6
7
|
};
|
8
|
+
type HeadersSerializer = (headers: Headers) => Record<string, string>;
|
7
9
|
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
|
8
10
|
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
|
11
|
+
headersSerializer: HeadersSerializer;
|
9
12
|
cache: RequestCache;
|
10
13
|
credentials: RequestCredentials;
|
11
14
|
destination: RequestDestination;
|
@@ -22,3 +25,4 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
|
|
22
25
|
signal: AbortSignal;
|
23
26
|
clone(): Request;
|
24
27
|
}
|
28
|
+
export {};
|
package/typings/Request.d.ts
CHANGED
@@ -3,9 +3,12 @@ import { PonyfillHeadersInit } from './Headers.js';
|
|
3
3
|
export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
|
4
4
|
body?: BodyPonyfillInit | null;
|
5
5
|
headers?: PonyfillHeadersInit;
|
6
|
+
headersSerializer?: HeadersSerializer;
|
6
7
|
};
|
8
|
+
type HeadersSerializer = (headers: Headers) => Record<string, string>;
|
7
9
|
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
|
8
10
|
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
|
11
|
+
headersSerializer: HeadersSerializer;
|
9
12
|
cache: RequestCache;
|
10
13
|
credentials: RequestCredentials;
|
11
14
|
destination: RequestDestination;
|
@@ -22,3 +25,4 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
|
|
22
25
|
signal: AbortSignal;
|
23
26
|
clone(): Request;
|
24
27
|
}
|
28
|
+
export {};
|
@@ -14,4 +14,5 @@ export declare class PonyfillURLSearchParams implements URLSearchParams {
|
|
14
14
|
values(): IterableIterator<string>;
|
15
15
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
16
16
|
forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
|
17
|
+
get size(): number;
|
17
18
|
}
|
@@ -14,4 +14,5 @@ export declare class PonyfillURLSearchParams implements URLSearchParams {
|
|
14
14
|
values(): IterableIterator<string>;
|
15
15
|
[Symbol.iterator](): IterableIterator<[string, string]>;
|
16
16
|
forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
|
17
|
+
get size(): number;
|
17
18
|
}
|
package/typings/index.d.cts
CHANGED
@@ -6,9 +6,6 @@ export { PonyfillResponse as Response, ResponsePonyfilInit as ResponseInit } fro
|
|
6
6
|
export { PonyfillReadableStream as ReadableStream } from './ReadableStream.cjs';
|
7
7
|
export { PonyfillFile as File } from './File.cjs';
|
8
8
|
export { PonyfillFormData as FormData } from './FormData.cjs';
|
9
|
-
export { PonyfillAbortController as AbortController } from './AbortController.cjs';
|
10
|
-
export { PonyfillAbortSignal as AbortSignal } from './AbortSignal.cjs';
|
11
|
-
export { PonyfillAbortError as AbortError } from './AbortError.cjs';
|
12
9
|
export { PonyfillBlob as Blob } from './Blob.cjs';
|
13
10
|
export { PonyfillTextEncoder as TextEncoder, PonyfillTextDecoder as TextDecoder, PonyfillBtoa as btoa, } from './TextEncoderDecoder.cjs';
|
14
11
|
export { PonyfillURL as URL } from './URL.cjs';
|
package/typings/index.d.ts
CHANGED
@@ -6,9 +6,6 @@ export { PonyfillResponse as Response, ResponsePonyfilInit as ResponseInit } fro
|
|
6
6
|
export { PonyfillReadableStream as ReadableStream } from './ReadableStream.js';
|
7
7
|
export { PonyfillFile as File } from './File.js';
|
8
8
|
export { PonyfillFormData as FormData } from './FormData.js';
|
9
|
-
export { PonyfillAbortController as AbortController } from './AbortController.js';
|
10
|
-
export { PonyfillAbortSignal as AbortSignal } from './AbortSignal.js';
|
11
|
-
export { PonyfillAbortError as AbortError } from './AbortError.js';
|
12
9
|
export { PonyfillBlob as Blob } from './Blob.js';
|
13
10
|
export { PonyfillTextEncoder as TextEncoder, PonyfillTextDecoder as TextDecoder, PonyfillBtoa as btoa, } from './TextEncoderDecoder.js';
|
14
11
|
export { PonyfillURL as URL } from './URL.js';
|
package/cjs/AbortController.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PonyfillAbortController = void 0;
|
4
|
-
const AbortSignal_js_1 = require("./AbortSignal.js");
|
5
|
-
// Will be removed after v14 reaches EOL
|
6
|
-
class PonyfillAbortController {
|
7
|
-
constructor() {
|
8
|
-
this.signal = new AbortSignal_js_1.PonyfillAbortSignal();
|
9
|
-
}
|
10
|
-
abort(reason) {
|
11
|
-
this.signal.abort(reason);
|
12
|
-
}
|
13
|
-
}
|
14
|
-
exports.PonyfillAbortController = PonyfillAbortController;
|
package/cjs/AbortError.js
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PonyfillAbortError = void 0;
|
4
|
-
// Will be removed after v14 reaches EOL
|
5
|
-
class PonyfillAbortError extends Error {
|
6
|
-
constructor(reason) {
|
7
|
-
let message = 'The operation was aborted.';
|
8
|
-
if (reason) {
|
9
|
-
message += ` reason: ${reason}`;
|
10
|
-
}
|
11
|
-
super(message, {
|
12
|
-
cause: reason,
|
13
|
-
});
|
14
|
-
this.name = 'AbortError';
|
15
|
-
}
|
16
|
-
get reason() {
|
17
|
-
return this.cause;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
exports.PonyfillAbortError = PonyfillAbortError;
|
package/cjs/AbortSignal.js
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PonyfillAbortSignal = void 0;
|
4
|
-
// Will be removed after v14 reaches EOL
|
5
|
-
const events_1 = require("@whatwg-node/events");
|
6
|
-
const AbortError_js_1 = require("./AbortError.js");
|
7
|
-
class PonyfillAbortSignal extends events_1.EventTarget {
|
8
|
-
constructor() {
|
9
|
-
super(...arguments);
|
10
|
-
this.aborted = false;
|
11
|
-
this._onabort = null;
|
12
|
-
}
|
13
|
-
throwIfAborted() {
|
14
|
-
if (this.aborted) {
|
15
|
-
throw new AbortError_js_1.PonyfillAbortError();
|
16
|
-
}
|
17
|
-
}
|
18
|
-
get onabort() {
|
19
|
-
return this._onabort;
|
20
|
-
}
|
21
|
-
set onabort(value) {
|
22
|
-
if (this._onabort) {
|
23
|
-
this.removeEventListener('abort', this._onabort);
|
24
|
-
}
|
25
|
-
this.addEventListener('abort', value);
|
26
|
-
}
|
27
|
-
abort(reason) {
|
28
|
-
const abortEvent = new events_1.CustomEvent('abort', { detail: reason });
|
29
|
-
this.dispatchEvent(abortEvent);
|
30
|
-
}
|
31
|
-
static timeout(milliseconds) {
|
32
|
-
const signal = new PonyfillAbortSignal();
|
33
|
-
setTimeout(() => signal.abort(`timeout in ${milliseconds} ms`), milliseconds);
|
34
|
-
return signal;
|
35
|
-
}
|
36
|
-
}
|
37
|
-
exports.PonyfillAbortSignal = PonyfillAbortSignal;
|
package/esm/AbortController.js
DELETED
package/esm/AbortError.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
// Will be removed after v14 reaches EOL
|
2
|
-
export class PonyfillAbortError extends Error {
|
3
|
-
constructor(reason) {
|
4
|
-
let message = 'The operation was aborted.';
|
5
|
-
if (reason) {
|
6
|
-
message += ` reason: ${reason}`;
|
7
|
-
}
|
8
|
-
super(message, {
|
9
|
-
cause: reason,
|
10
|
-
});
|
11
|
-
this.name = 'AbortError';
|
12
|
-
}
|
13
|
-
get reason() {
|
14
|
-
return this.cause;
|
15
|
-
}
|
16
|
-
}
|
package/esm/AbortSignal.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
// Will be removed after v14 reaches EOL
|
2
|
-
import { CustomEvent, EventTarget } from '@whatwg-node/events';
|
3
|
-
import { PonyfillAbortError } from './AbortError.js';
|
4
|
-
export class PonyfillAbortSignal extends EventTarget {
|
5
|
-
constructor() {
|
6
|
-
super(...arguments);
|
7
|
-
this.aborted = false;
|
8
|
-
this._onabort = null;
|
9
|
-
}
|
10
|
-
throwIfAborted() {
|
11
|
-
if (this.aborted) {
|
12
|
-
throw new PonyfillAbortError();
|
13
|
-
}
|
14
|
-
}
|
15
|
-
get onabort() {
|
16
|
-
return this._onabort;
|
17
|
-
}
|
18
|
-
set onabort(value) {
|
19
|
-
if (this._onabort) {
|
20
|
-
this.removeEventListener('abort', this._onabort);
|
21
|
-
}
|
22
|
-
this.addEventListener('abort', value);
|
23
|
-
}
|
24
|
-
abort(reason) {
|
25
|
-
const abortEvent = new CustomEvent('abort', { detail: reason });
|
26
|
-
this.dispatchEvent(abortEvent);
|
27
|
-
}
|
28
|
-
static timeout(milliseconds) {
|
29
|
-
const signal = new PonyfillAbortSignal();
|
30
|
-
setTimeout(() => signal.abort(`timeout in ${milliseconds} ms`), milliseconds);
|
31
|
-
return signal;
|
32
|
-
}
|
33
|
-
}
|
package/typings/AbortError.d.cts
DELETED
package/typings/AbortError.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { EventTarget } from '@whatwg-node/events';
|
2
|
-
export declare class PonyfillAbortSignal extends EventTarget implements AbortSignal {
|
3
|
-
aborted: boolean;
|
4
|
-
_onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
5
|
-
reason: any;
|
6
|
-
throwIfAborted(): void;
|
7
|
-
get onabort(): ((this: AbortSignal, ev: Event) => any) | null;
|
8
|
-
set onabort(value: ((this: AbortSignal, ev: Event) => any) | null);
|
9
|
-
abort(reason?: any): void;
|
10
|
-
static timeout(milliseconds: number): PonyfillAbortSignal;
|
11
|
-
}
|
package/typings/AbortSignal.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { EventTarget } from '@whatwg-node/events';
|
2
|
-
export declare class PonyfillAbortSignal extends EventTarget implements AbortSignal {
|
3
|
-
aborted: boolean;
|
4
|
-
_onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
5
|
-
reason: any;
|
6
|
-
throwIfAborted(): void;
|
7
|
-
get onabort(): ((this: AbortSignal, ev: Event) => any) | null;
|
8
|
-
set onabort(value: ((this: AbortSignal, ev: Event) => any) | null);
|
9
|
-
abort(reason?: any): void;
|
10
|
-
static timeout(milliseconds: number): PonyfillAbortSignal;
|
11
|
-
}
|