@whatwg-node/node-fetch 0.8.0-alpha-20241212160430-140b66f028923f44368e67598b6b66f47f690454 → 0.8.0-alpha-20250917053118-2dc604e028627df01a83e41a3dd6dd3f89ca0b40
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/AbortError.js +10 -3
- package/cjs/Blob.js +21 -19
- package/cjs/Body.js +146 -76
- package/cjs/FormData.js +54 -41
- package/cjs/Headers.js +54 -15
- package/cjs/ReadableStream.js +62 -26
- package/cjs/Request.js +9 -16
- package/cjs/Response.js +56 -10
- package/cjs/TextEncoderDecoder.js +6 -5
- package/cjs/TextEncoderDecoderStream.js +2 -6
- package/cjs/TransformStream.js +2 -1
- package/cjs/URL.js +10 -66
- package/cjs/URLSearchParams.js +1 -117
- package/cjs/WritableStream.js +35 -111
- package/cjs/fetch.js +37 -8
- package/cjs/fetchCurl.js +30 -61
- package/cjs/fetchNodeHttp.js +60 -64
- package/cjs/index.js +1 -7
- package/cjs/utils.js +76 -55
- package/esm/AbortError.js +10 -3
- package/esm/Blob.js +6 -4
- package/esm/Body.js +134 -63
- package/esm/FormData.js +54 -41
- package/esm/Headers.js +54 -15
- package/esm/ReadableStream.js +57 -21
- package/esm/Request.js +7 -14
- package/esm/Response.js +55 -9
- package/esm/TextEncoderDecoder.js +1 -0
- package/esm/TextEncoderDecoderStream.js +2 -6
- package/esm/TransformStream.js +2 -1
- package/esm/URL.js +9 -64
- package/esm/URLSearchParams.js +1 -115
- package/esm/WritableStream.js +33 -109
- package/esm/fetch.js +35 -6
- package/esm/fetchCurl.js +28 -59
- package/esm/fetchNodeHttp.js +55 -59
- package/esm/index.js +0 -3
- package/esm/utils.js +70 -53
- package/package.json +4 -5
- package/typings/AbortError.d.cts +2 -2
- package/typings/AbortError.d.ts +2 -2
- package/typings/Blob.d.cts +5 -4
- package/typings/Blob.d.ts +5 -4
- package/typings/Body.d.cts +11 -6
- package/typings/Body.d.ts +11 -6
- package/typings/Headers.d.cts +1 -1
- package/typings/Headers.d.ts +1 -1
- package/typings/ReadableStream.d.cts +8 -2
- package/typings/ReadableStream.d.ts +8 -2
- package/typings/Request.d.cts +9 -10
- package/typings/Request.d.ts +9 -10
- package/typings/Response.d.cts +6 -5
- package/typings/Response.d.ts +6 -5
- package/typings/TextEncoderDecoder.d.cts +2 -1
- package/typings/TextEncoderDecoder.d.ts +2 -1
- package/typings/URL.d.cts +12 -16
- package/typings/URL.d.ts +12 -16
- package/typings/URLSearchParams.d.cts +4 -21
- package/typings/URLSearchParams.d.ts +4 -21
- package/typings/WritableStream.d.cts +1 -1
- package/typings/WritableStream.d.ts +1 -1
- package/typings/index.d.cts +0 -3
- package/typings/index.d.ts +0 -3
- package/typings/utils.d.cts +13 -8
- package/typings/utils.d.ts +13 -8
- package/cjs/AbortController.js +0 -18
- package/cjs/AbortSignal.js +0 -92
- package/esm/AbortController.js +0 -14
- package/esm/AbortSignal.js +0 -88
- package/typings/AbortController.d.cts +0 -8
- package/typings/AbortController.d.ts +0 -8
- package/typings/AbortSignal.d.cts +0 -15
- package/typings/AbortSignal.d.ts +0 -15
package/esm/utils.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { once } from 'node:events';
|
|
1
2
|
function isHeadersInstance(obj) {
|
|
2
3
|
return obj?.forEach != null;
|
|
3
4
|
}
|
|
@@ -5,6 +6,11 @@ export function getHeadersObj(headers) {
|
|
|
5
6
|
if (headers == null || !isHeadersInstance(headers)) {
|
|
6
7
|
return headers;
|
|
7
8
|
}
|
|
9
|
+
// @ts-expect-error - `headersInit` is not a public property
|
|
10
|
+
if (headers.headersInit && !headers._map && !isHeadersInstance(headers.headersInit)) {
|
|
11
|
+
// @ts-expect-error - `headersInit` is not a public property
|
|
12
|
+
return headers.headersInit;
|
|
13
|
+
}
|
|
8
14
|
return Object.fromEntries(headers.entries());
|
|
9
15
|
}
|
|
10
16
|
export function defaultHeadersSerializer(headers, onContentLength) {
|
|
@@ -17,65 +23,76 @@ export function defaultHeadersSerializer(headers, onContentLength) {
|
|
|
17
23
|
});
|
|
18
24
|
return headerArray;
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
return val?.then != null;
|
|
22
|
-
}
|
|
23
|
-
export function fakePromise(value) {
|
|
24
|
-
if (isPromise(value)) {
|
|
25
|
-
return value;
|
|
26
|
-
}
|
|
27
|
-
// Write a fake promise to avoid the promise constructor
|
|
28
|
-
// being called with `new Promise` in the browser.
|
|
29
|
-
return {
|
|
30
|
-
then(resolve) {
|
|
31
|
-
if (resolve) {
|
|
32
|
-
const callbackResult = resolve(value);
|
|
33
|
-
if (isPromise(callbackResult)) {
|
|
34
|
-
return callbackResult;
|
|
35
|
-
}
|
|
36
|
-
return fakePromise(callbackResult);
|
|
37
|
-
}
|
|
38
|
-
return this;
|
|
39
|
-
},
|
|
40
|
-
catch() {
|
|
41
|
-
return this;
|
|
42
|
-
},
|
|
43
|
-
finally(cb) {
|
|
44
|
-
if (cb) {
|
|
45
|
-
const callbackResult = cb();
|
|
46
|
-
if (isPromise(callbackResult)) {
|
|
47
|
-
return callbackResult.then(() => value);
|
|
48
|
-
}
|
|
49
|
-
return fakePromise(value);
|
|
50
|
-
}
|
|
51
|
-
return this;
|
|
52
|
-
},
|
|
53
|
-
[Symbol.toStringTag]: 'Promise',
|
|
54
|
-
};
|
|
55
|
-
}
|
|
26
|
+
export { fakePromise } from '@whatwg-node/promise-helpers';
|
|
56
27
|
export function isArrayBufferView(obj) {
|
|
57
28
|
return obj != null && obj.buffer != null && obj.byteLength != null && obj.byteOffset != null;
|
|
58
29
|
}
|
|
59
30
|
export function isNodeReadable(obj) {
|
|
60
31
|
return obj != null && obj.pipe != null;
|
|
61
32
|
}
|
|
62
|
-
export function createDeferredPromise() {
|
|
63
|
-
let resolveFn;
|
|
64
|
-
let rejectFn;
|
|
65
|
-
const promise = new Promise(function deferredPromiseExecutor(resolve, reject) {
|
|
66
|
-
resolveFn = resolve;
|
|
67
|
-
rejectFn = reject;
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
promise,
|
|
71
|
-
get resolve() {
|
|
72
|
-
return resolveFn;
|
|
73
|
-
},
|
|
74
|
-
get reject() {
|
|
75
|
-
return rejectFn;
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
33
|
export function isIterable(value) {
|
|
80
34
|
return value?.[Symbol.iterator] != null;
|
|
81
35
|
}
|
|
36
|
+
export function shouldRedirect(status) {
|
|
37
|
+
return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
|
|
38
|
+
}
|
|
39
|
+
export function pipeThrough({ src, dest, signal, onError, }) {
|
|
40
|
+
if (onError) {
|
|
41
|
+
// listen for errors on the destination stream if necessary. if the readable
|
|
42
|
+
// stream (src) emits an error, the writable destination (dest) will be
|
|
43
|
+
// destroyed with that error (see below)
|
|
44
|
+
dest.once('error', onError);
|
|
45
|
+
}
|
|
46
|
+
src.once('error', (e) => {
|
|
47
|
+
// if the readable stream (src) emits an error during pipe, the writable
|
|
48
|
+
// destination (dest) is not closed automatically. that needs to be
|
|
49
|
+
// done manually. the readable stream is closed when error is emitted,
|
|
50
|
+
// so only the writable destination needs to be destroyed
|
|
51
|
+
dest.destroy(e);
|
|
52
|
+
});
|
|
53
|
+
dest.once('close', () => {
|
|
54
|
+
// if the writable destination (dest) is closed, the readable stream (src)
|
|
55
|
+
// is not closed automatically. that needs to be done manually
|
|
56
|
+
if (!src.destroyed) {
|
|
57
|
+
src.destroy();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (signal) {
|
|
61
|
+
// this is faster than `import('node:signal').addAbortSignal(signal, src)`
|
|
62
|
+
const srcRef = new WeakRef(src);
|
|
63
|
+
const signalRef = new WeakRef(signal);
|
|
64
|
+
function cleanup() {
|
|
65
|
+
signalRef.deref()?.removeEventListener('abort', onAbort);
|
|
66
|
+
srcRef.deref()?.removeListener('end', cleanup);
|
|
67
|
+
srcRef.deref()?.removeListener('error', cleanup);
|
|
68
|
+
srcRef.deref()?.removeListener('close', cleanup);
|
|
69
|
+
}
|
|
70
|
+
function onAbort() {
|
|
71
|
+
srcRef.deref()?.destroy(new AbortError());
|
|
72
|
+
cleanup();
|
|
73
|
+
}
|
|
74
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
75
|
+
// this is faster than `import('node:signal').finished(src, cleanup)`
|
|
76
|
+
src.once('end', cleanup);
|
|
77
|
+
src.once('error', cleanup);
|
|
78
|
+
src.once('close', cleanup);
|
|
79
|
+
}
|
|
80
|
+
src.pipe(dest, { end: true /* already default */ });
|
|
81
|
+
}
|
|
82
|
+
export function endStream(stream) {
|
|
83
|
+
// @ts-expect-error Avoid arguments adaptor trampoline https://v8.dev/blog/adaptor-frame
|
|
84
|
+
return stream.end(null, null, null);
|
|
85
|
+
}
|
|
86
|
+
export function safeWrite(chunk, stream) {
|
|
87
|
+
const result = stream.write(chunk);
|
|
88
|
+
if (!result) {
|
|
89
|
+
return once(stream, 'drain');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// https://github.com/nodejs/node/blob/f692878dec6354c0a82241f224906981861bc840/lib/internal/errors.js#L961-L973
|
|
93
|
+
class AbortError extends Error {
|
|
94
|
+
constructor(message = 'The operation was aborted', options = undefined) {
|
|
95
|
+
super(message, options);
|
|
96
|
+
this.name = 'AbortError';
|
|
97
|
+
}
|
|
98
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
|
3
|
-
"version": "0.8.0-alpha-
|
|
3
|
+
"version": "0.8.0-alpha-20250917053118-2dc604e028627df01a83e41a3dd6dd3f89ca0b40",
|
|
4
4
|
"description": "Fetch API implementation for Node",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
-
"@whatwg-node/disposablestack": "^0.0.
|
|
9
|
-
"
|
|
10
|
-
"fast-querystring": "^1.1.1",
|
|
7
|
+
"@fastify/busboy": "^3.1.1",
|
|
8
|
+
"@whatwg-node/disposablestack": "^0.0.6",
|
|
9
|
+
"@whatwg-node/promise-helpers": "^1.3.2",
|
|
11
10
|
"tslib": "^2.6.3"
|
|
12
11
|
},
|
|
13
12
|
"repository": {
|
package/typings/AbortError.d.cts
CHANGED
package/typings/AbortError.d.ts
CHANGED
package/typings/Blob.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
interface BlobOptions {
|
|
2
3
|
/**
|
|
3
4
|
* @default 'utf8'
|
|
@@ -15,7 +16,7 @@ interface BlobOptions {
|
|
|
15
16
|
size?: number | null;
|
|
16
17
|
}
|
|
17
18
|
export declare function hasBufferMethod(obj: any): obj is {
|
|
18
|
-
buffer(): Promise<Buffer
|
|
19
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
19
20
|
};
|
|
20
21
|
export declare function hasArrayBufferMethod(obj: any): obj is {
|
|
21
22
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
@@ -41,10 +42,10 @@ export declare class PonyfillBlob implements Blob {
|
|
|
41
42
|
private encoding;
|
|
42
43
|
private _size;
|
|
43
44
|
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
|
44
|
-
_buffer: Buffer | null;
|
|
45
|
-
buffer(): Promise<Buffer<
|
|
45
|
+
_buffer: Buffer<ArrayBuffer> | null;
|
|
46
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
46
47
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
47
|
-
bytes(): Promise<Uint8Array
|
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
48
49
|
_text: string | null;
|
|
49
50
|
text(): Promise<string>;
|
|
50
51
|
_json: any;
|
package/typings/Blob.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
interface BlobOptions {
|
|
2
3
|
/**
|
|
3
4
|
* @default 'utf8'
|
|
@@ -15,7 +16,7 @@ interface BlobOptions {
|
|
|
15
16
|
size?: number | null;
|
|
16
17
|
}
|
|
17
18
|
export declare function hasBufferMethod(obj: any): obj is {
|
|
18
|
-
buffer(): Promise<Buffer
|
|
19
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
19
20
|
};
|
|
20
21
|
export declare function hasArrayBufferMethod(obj: any): obj is {
|
|
21
22
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
@@ -41,10 +42,10 @@ export declare class PonyfillBlob implements Blob {
|
|
|
41
42
|
private encoding;
|
|
42
43
|
private _size;
|
|
43
44
|
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
|
44
|
-
_buffer: Buffer | null;
|
|
45
|
-
buffer(): Promise<Buffer<
|
|
45
|
+
_buffer: Buffer<ArrayBuffer> | null;
|
|
46
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
46
47
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
47
|
-
bytes(): Promise<Uint8Array
|
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
48
49
|
_text: string | null;
|
|
49
50
|
text(): Promise<string>;
|
|
50
51
|
_json: any;
|
package/typings/Body.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
2
4
|
import { PonyfillBlob } from './Blob.cjs';
|
|
3
5
|
import { PonyfillFormData } from './FormData.cjs';
|
|
4
6
|
import { PonyfillReadableStream } from './ReadableStream.cjs';
|
|
@@ -14,6 +16,7 @@ export interface FormDataLimits {
|
|
|
14
16
|
}
|
|
15
17
|
export interface PonyfillBodyOptions {
|
|
16
18
|
formDataLimits?: FormDataLimits;
|
|
19
|
+
signal?: AbortSignal | undefined;
|
|
17
20
|
}
|
|
18
21
|
export declare class PonyfillBody<TJSON = any> implements Body {
|
|
19
22
|
private bodyInit;
|
|
@@ -26,21 +29,23 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
|
26
29
|
private _bodyFactory;
|
|
27
30
|
private _generatedBody;
|
|
28
31
|
private _buffer?;
|
|
32
|
+
_signal?: AbortSignal | undefined;
|
|
29
33
|
private generateBody;
|
|
30
34
|
protected handleContentLengthHeader(this: PonyfillBody & {
|
|
31
35
|
headers: Headers;
|
|
32
36
|
}, forceSet?: boolean): void;
|
|
33
|
-
get body(): PonyfillReadableStream<Uint8Array
|
|
34
|
-
_chunks: Uint8Array[] | null;
|
|
35
|
-
|
|
37
|
+
get body(): PonyfillReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
38
|
+
_chunks: MaybePromise<Uint8Array<ArrayBuffer>[]> | null;
|
|
39
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
|
40
|
+
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
|
36
41
|
_blob: PonyfillBlob | null;
|
|
37
42
|
blob(): Promise<PonyfillBlob>;
|
|
38
43
|
_formData: PonyfillFormData | null;
|
|
39
44
|
formData(opts?: {
|
|
40
45
|
formDataLimits: FormDataLimits;
|
|
41
46
|
}): Promise<PonyfillFormData>;
|
|
42
|
-
buffer(): Promise<Buffer
|
|
43
|
-
bytes(): Promise<Uint8Array
|
|
47
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
44
49
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
45
50
|
_json: TJSON | null;
|
|
46
51
|
json(): Promise<TJSON>;
|
package/typings/Body.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
2
4
|
import { PonyfillBlob } from './Blob.js';
|
|
3
5
|
import { PonyfillFormData } from './FormData.js';
|
|
4
6
|
import { PonyfillReadableStream } from './ReadableStream.js';
|
|
@@ -14,6 +16,7 @@ export interface FormDataLimits {
|
|
|
14
16
|
}
|
|
15
17
|
export interface PonyfillBodyOptions {
|
|
16
18
|
formDataLimits?: FormDataLimits;
|
|
19
|
+
signal?: AbortSignal | undefined;
|
|
17
20
|
}
|
|
18
21
|
export declare class PonyfillBody<TJSON = any> implements Body {
|
|
19
22
|
private bodyInit;
|
|
@@ -26,21 +29,23 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
|
26
29
|
private _bodyFactory;
|
|
27
30
|
private _generatedBody;
|
|
28
31
|
private _buffer?;
|
|
32
|
+
_signal?: AbortSignal | undefined;
|
|
29
33
|
private generateBody;
|
|
30
34
|
protected handleContentLengthHeader(this: PonyfillBody & {
|
|
31
35
|
headers: Headers;
|
|
32
36
|
}, forceSet?: boolean): void;
|
|
33
|
-
get body(): PonyfillReadableStream<Uint8Array
|
|
34
|
-
_chunks: Uint8Array[] | null;
|
|
35
|
-
|
|
37
|
+
get body(): PonyfillReadableStream<Uint8Array<ArrayBuffer>> | null;
|
|
38
|
+
_chunks: MaybePromise<Uint8Array<ArrayBuffer>[]> | null;
|
|
39
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
|
40
|
+
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
|
36
41
|
_blob: PonyfillBlob | null;
|
|
37
42
|
blob(): Promise<PonyfillBlob>;
|
|
38
43
|
_formData: PonyfillFormData | null;
|
|
39
44
|
formData(opts?: {
|
|
40
45
|
formDataLimits: FormDataLimits;
|
|
41
46
|
}): Promise<PonyfillFormData>;
|
|
42
|
-
buffer(): Promise<Buffer
|
|
43
|
-
bytes(): Promise<Uint8Array
|
|
47
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
|
44
49
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
45
50
|
_json: TJSON | null;
|
|
46
51
|
json(): Promise<TJSON>;
|
package/typings/Headers.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class PonyfillHeaders implements Headers {
|
|
|
5
5
|
private _map;
|
|
6
6
|
private objectNormalizedKeysOfHeadersInit;
|
|
7
7
|
private objectOriginalKeysOfHeadersInit;
|
|
8
|
-
private _setCookies
|
|
8
|
+
private _setCookies?;
|
|
9
9
|
constructor(headersInit?: PonyfillHeadersInit | undefined);
|
|
10
10
|
private _get;
|
|
11
11
|
private getMap;
|
package/typings/Headers.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class PonyfillHeaders implements Headers {
|
|
|
5
5
|
private _map;
|
|
6
6
|
private objectNormalizedKeysOfHeadersInit;
|
|
7
7
|
private objectOriginalKeysOfHeadersInit;
|
|
8
|
-
private _setCookies
|
|
8
|
+
private _setCookies?;
|
|
9
9
|
constructor(headersInit?: PonyfillHeadersInit | undefined);
|
|
10
10
|
private _get;
|
|
11
11
|
private getMap;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
2
|
export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
3
3
|
readable: Readable;
|
|
4
4
|
constructor(underlyingSource?: UnderlyingSource<T> | Readable | ReadableStream<T> | PonyfillReadableStream<T>);
|
|
@@ -8,7 +8,12 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
|
8
8
|
mode: 'byob';
|
|
9
9
|
}): ReadableStreamBYOBReader;
|
|
10
10
|
getReader(): ReadableStreamDefaultReader<T>;
|
|
11
|
-
[Symbol.asyncIterator]():
|
|
11
|
+
[Symbol.asyncIterator](): {
|
|
12
|
+
[Symbol.asyncIterator](): /*elided*/ any;
|
|
13
|
+
next: () => Promise<IteratorResult<any, undefined>>;
|
|
14
|
+
return: () => Promise<IteratorResult<any, undefined>>;
|
|
15
|
+
throw: (err: Error) => Promise<IteratorResult<any, undefined>>;
|
|
16
|
+
};
|
|
12
17
|
tee(): [ReadableStream<T>, ReadableStream<T>];
|
|
13
18
|
private pipeToWriter;
|
|
14
19
|
pipeTo(destination: WritableStream<T>): Promise<void>;
|
|
@@ -18,4 +23,5 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
|
18
23
|
}): ReadableStream<T2>;
|
|
19
24
|
static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
|
|
20
25
|
static from<T>(iterable: AsyncIterable<T> | Iterable<T>): PonyfillReadableStream<T>;
|
|
26
|
+
[Symbol.toStringTag]: string;
|
|
21
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Readable } from 'stream';
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
2
|
export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
3
3
|
readable: Readable;
|
|
4
4
|
constructor(underlyingSource?: UnderlyingSource<T> | Readable | ReadableStream<T> | PonyfillReadableStream<T>);
|
|
@@ -8,7 +8,12 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
|
8
8
|
mode: 'byob';
|
|
9
9
|
}): ReadableStreamBYOBReader;
|
|
10
10
|
getReader(): ReadableStreamDefaultReader<T>;
|
|
11
|
-
[Symbol.asyncIterator]():
|
|
11
|
+
[Symbol.asyncIterator](): {
|
|
12
|
+
[Symbol.asyncIterator](): /*elided*/ any;
|
|
13
|
+
next: () => Promise<IteratorResult<any, undefined>>;
|
|
14
|
+
return: () => Promise<IteratorResult<any, undefined>>;
|
|
15
|
+
throw: (err: Error) => Promise<IteratorResult<any, undefined>>;
|
|
16
|
+
};
|
|
12
17
|
tee(): [ReadableStream<T>, ReadableStream<T>];
|
|
13
18
|
private pipeToWriter;
|
|
14
19
|
pipeTo(destination: WritableStream<T>): Promise<void>;
|
|
@@ -18,4 +23,5 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
|
|
|
18
23
|
}): ReadableStream<T2>;
|
|
19
24
|
static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
|
|
20
25
|
static from<T>(iterable: AsyncIterable<T> | Iterable<T>): PonyfillReadableStream<T>;
|
|
26
|
+
[Symbol.toStringTag]: string;
|
|
21
27
|
}
|
package/typings/Request.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Agent as HTTPAgent } from 'http';
|
|
2
|
-
import { Agent as HTTPSAgent } from 'https';
|
|
1
|
+
import { Agent as HTTPAgent } from 'node:http';
|
|
2
|
+
import { Agent as HTTPSAgent } from 'node:https';
|
|
3
3
|
import { BodyPonyfillInit, PonyfillBody, PonyfillBodyOptions } from './Body.cjs';
|
|
4
4
|
import { PonyfillHeadersInit } from './Headers.cjs';
|
|
5
5
|
export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
|
|
6
|
-
body?: BodyPonyfillInit | null;
|
|
7
|
-
duplex?: 'half' | 'full';
|
|
8
|
-
headers?: PonyfillHeadersInit;
|
|
9
|
-
headersSerializer?: HeadersSerializer;
|
|
10
|
-
agent?: HTTPAgent | HTTPSAgent | false;
|
|
6
|
+
body?: BodyPonyfillInit | null | undefined;
|
|
7
|
+
duplex?: 'half' | 'full' | undefined;
|
|
8
|
+
headers?: PonyfillHeadersInit | undefined;
|
|
9
|
+
headersSerializer?: HeadersSerializer | undefined;
|
|
10
|
+
agent?: HTTPAgent | HTTPSAgent | false | undefined;
|
|
11
11
|
};
|
|
12
12
|
type HeadersSerializer = (headers: Headers, onContentLength?: (contentLength: string) => void) => string[];
|
|
13
13
|
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
|
|
14
14
|
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
|
|
15
|
-
headersSerializer?: HeadersSerializer;
|
|
15
|
+
headersSerializer?: HeadersSerializer | undefined;
|
|
16
16
|
cache: RequestCache;
|
|
17
17
|
credentials: RequestCredentials;
|
|
18
18
|
destination: RequestDestination;
|
|
@@ -26,13 +26,12 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
|
|
|
26
26
|
referrer: string;
|
|
27
27
|
referrerPolicy: ReferrerPolicy;
|
|
28
28
|
_url: string | undefined;
|
|
29
|
+
get signal(): AbortSignal;
|
|
29
30
|
get url(): string;
|
|
30
31
|
_parsedUrl: URL | undefined;
|
|
31
32
|
get parsedUrl(): URL;
|
|
32
33
|
duplex: 'half' | 'full';
|
|
33
34
|
agent: HTTPAgent | HTTPSAgent | false | undefined;
|
|
34
|
-
private _signal;
|
|
35
|
-
get signal(): AbortSignal;
|
|
36
35
|
clone(): PonyfillRequest<TJSON>;
|
|
37
36
|
[Symbol.toStringTag]: string;
|
|
38
37
|
}
|
package/typings/Request.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Agent as HTTPAgent } from 'http';
|
|
2
|
-
import { Agent as HTTPSAgent } from 'https';
|
|
1
|
+
import { Agent as HTTPAgent } from 'node:http';
|
|
2
|
+
import { Agent as HTTPSAgent } from 'node:https';
|
|
3
3
|
import { BodyPonyfillInit, PonyfillBody, PonyfillBodyOptions } from './Body.js';
|
|
4
4
|
import { PonyfillHeadersInit } from './Headers.js';
|
|
5
5
|
export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body' | 'headers'> & {
|
|
6
|
-
body?: BodyPonyfillInit | null;
|
|
7
|
-
duplex?: 'half' | 'full';
|
|
8
|
-
headers?: PonyfillHeadersInit;
|
|
9
|
-
headersSerializer?: HeadersSerializer;
|
|
10
|
-
agent?: HTTPAgent | HTTPSAgent | false;
|
|
6
|
+
body?: BodyPonyfillInit | null | undefined;
|
|
7
|
+
duplex?: 'half' | 'full' | undefined;
|
|
8
|
+
headers?: PonyfillHeadersInit | undefined;
|
|
9
|
+
headersSerializer?: HeadersSerializer | undefined;
|
|
10
|
+
agent?: HTTPAgent | HTTPSAgent | false | undefined;
|
|
11
11
|
};
|
|
12
12
|
type HeadersSerializer = (headers: Headers, onContentLength?: (contentLength: string) => void) => string[];
|
|
13
13
|
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
|
|
14
14
|
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
|
|
15
|
-
headersSerializer?: HeadersSerializer;
|
|
15
|
+
headersSerializer?: HeadersSerializer | undefined;
|
|
16
16
|
cache: RequestCache;
|
|
17
17
|
credentials: RequestCredentials;
|
|
18
18
|
destination: RequestDestination;
|
|
@@ -26,13 +26,12 @@ export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> im
|
|
|
26
26
|
referrer: string;
|
|
27
27
|
referrerPolicy: ReferrerPolicy;
|
|
28
28
|
_url: string | undefined;
|
|
29
|
+
get signal(): AbortSignal;
|
|
29
30
|
get url(): string;
|
|
30
31
|
_parsedUrl: URL | undefined;
|
|
31
32
|
get parsedUrl(): URL;
|
|
32
33
|
duplex: 'half' | 'full';
|
|
33
34
|
agent: HTTPAgent | HTTPSAgent | false | undefined;
|
|
34
|
-
private _signal;
|
|
35
|
-
get signal(): AbortSignal;
|
|
36
35
|
clone(): PonyfillRequest<TJSON>;
|
|
37
36
|
[Symbol.toStringTag]: string;
|
|
38
37
|
}
|
package/typings/Response.d.cts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BodyPonyfillInit, PonyfillBody, PonyfillBodyOptions } from './Body.cjs';
|
|
2
2
|
import { PonyfillHeadersInit } from './Headers.cjs';
|
|
3
3
|
export type ResponsePonyfilInit = PonyfillBodyOptions & Omit<ResponseInit, 'headers'> & {
|
|
4
|
-
url?: string;
|
|
5
|
-
redirected?: boolean;
|
|
6
|
-
headers?: PonyfillHeadersInit;
|
|
7
|
-
type?: ResponseType;
|
|
4
|
+
url?: string | undefined;
|
|
5
|
+
redirected?: boolean | undefined;
|
|
6
|
+
headers?: PonyfillHeadersInit | undefined;
|
|
7
|
+
type?: ResponseType | undefined;
|
|
8
8
|
};
|
|
9
9
|
export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> implements Response {
|
|
10
10
|
headers: Headers;
|
|
11
|
-
constructor(body?: BodyPonyfillInit | null, init?: ResponsePonyfilInit);
|
|
11
|
+
constructor(body?: BodyPonyfillInit | null | undefined, init?: ResponsePonyfilInit);
|
|
12
12
|
get ok(): boolean;
|
|
13
13
|
status: number;
|
|
14
14
|
statusText: string;
|
|
@@ -19,4 +19,5 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
|
19
19
|
static error(): PonyfillResponse<any>;
|
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
|
21
21
|
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
|
22
|
+
[Symbol.toStringTag]: string;
|
|
22
23
|
}
|
package/typings/Response.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BodyPonyfillInit, PonyfillBody, PonyfillBodyOptions } from './Body.js';
|
|
2
2
|
import { PonyfillHeadersInit } from './Headers.js';
|
|
3
3
|
export type ResponsePonyfilInit = PonyfillBodyOptions & Omit<ResponseInit, 'headers'> & {
|
|
4
|
-
url?: string;
|
|
5
|
-
redirected?: boolean;
|
|
6
|
-
headers?: PonyfillHeadersInit;
|
|
7
|
-
type?: ResponseType;
|
|
4
|
+
url?: string | undefined;
|
|
5
|
+
redirected?: boolean | undefined;
|
|
6
|
+
headers?: PonyfillHeadersInit | undefined;
|
|
7
|
+
type?: ResponseType | undefined;
|
|
8
8
|
};
|
|
9
9
|
export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> implements Response {
|
|
10
10
|
headers: Headers;
|
|
11
|
-
constructor(body?: BodyPonyfillInit | null, init?: ResponsePonyfilInit);
|
|
11
|
+
constructor(body?: BodyPonyfillInit | null | undefined, init?: ResponsePonyfilInit);
|
|
12
12
|
get ok(): boolean;
|
|
13
13
|
status: number;
|
|
14
14
|
statusText: string;
|
|
@@ -19,4 +19,5 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
|
19
19
|
static error(): PonyfillResponse<any>;
|
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
|
21
21
|
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
|
22
|
+
[Symbol.toStringTag]: string;
|
|
22
23
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
export declare class PonyfillTextEncoder implements TextEncoder {
|
|
2
3
|
encoding: BufferEncoding;
|
|
3
4
|
constructor(encoding?: BufferEncoding);
|
|
4
|
-
encode(input: string): Buffer
|
|
5
|
+
encode(input: string): Buffer<ArrayBuffer>;
|
|
5
6
|
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
|
|
6
7
|
}
|
|
7
8
|
export declare class PonyfillTextDecoder implements TextDecoder {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
export declare class PonyfillTextEncoder implements TextEncoder {
|
|
2
3
|
encoding: BufferEncoding;
|
|
3
4
|
constructor(encoding?: BufferEncoding);
|
|
4
|
-
encode(input: string): Buffer
|
|
5
|
+
encode(input: string): Buffer<ArrayBuffer>;
|
|
5
6
|
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
|
|
6
7
|
}
|
|
7
8
|
export declare class PonyfillTextDecoder implements TextDecoder {
|
package/typings/URL.d.cts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import FastUrl from '@kamilkisiela/fast-url-parser';
|
|
2
1
|
import { PonyfillBlob } from './Blob.cjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
toString(): string;
|
|
14
|
-
toJSON(): string;
|
|
15
|
-
private static blobRegistry;
|
|
2
|
+
declare const NativeURL: {
|
|
3
|
+
new (url: string | globalThis.URL, base?: string | globalThis.URL): globalThis.URL;
|
|
4
|
+
prototype: globalThis.URL;
|
|
5
|
+
canParse(url: string | globalThis.URL, base?: string | globalThis.URL): boolean;
|
|
6
|
+
createObjectURL(obj: Blob | MediaSource): string;
|
|
7
|
+
parse(url: string | globalThis.URL, base?: string | globalThis.URL): globalThis.URL | null;
|
|
8
|
+
revokeObjectURL(url: string): void;
|
|
9
|
+
};
|
|
10
|
+
declare class URL extends NativeURL {
|
|
11
|
+
static blobRegistry: Map<string, Blob | PonyfillBlob>;
|
|
16
12
|
static createObjectURL(blob: Blob): string;
|
|
17
|
-
static
|
|
13
|
+
static revokeObjectURL(url: string): void;
|
|
18
14
|
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
|
19
|
-
[Symbol.toStringTag]: string;
|
|
20
15
|
}
|
|
16
|
+
export { URL as PonyfillURL };
|
package/typings/URL.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import FastUrl from '@kamilkisiela/fast-url-parser';
|
|
2
1
|
import { PonyfillBlob } from './Blob.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
toString(): string;
|
|
14
|
-
toJSON(): string;
|
|
15
|
-
private static blobRegistry;
|
|
2
|
+
declare const NativeURL: {
|
|
3
|
+
new (url: string | globalThis.URL, base?: string | globalThis.URL): globalThis.URL;
|
|
4
|
+
prototype: globalThis.URL;
|
|
5
|
+
canParse(url: string | globalThis.URL, base?: string | globalThis.URL): boolean;
|
|
6
|
+
createObjectURL(obj: Blob | MediaSource): string;
|
|
7
|
+
parse(url: string | globalThis.URL, base?: string | globalThis.URL): globalThis.URL | null;
|
|
8
|
+
revokeObjectURL(url: string): void;
|
|
9
|
+
};
|
|
10
|
+
declare class URL extends NativeURL {
|
|
11
|
+
static blobRegistry: Map<string, Blob | PonyfillBlob>;
|
|
16
12
|
static createObjectURL(blob: Blob): string;
|
|
17
|
-
static
|
|
13
|
+
static revokeObjectURL(url: string): void;
|
|
18
14
|
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
|
19
|
-
[Symbol.toStringTag]: string;
|
|
20
15
|
}
|
|
16
|
+
export { URL as PonyfillURL };
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
delete(name: string): void;
|
|
6
|
-
get(name: string): string | null;
|
|
7
|
-
getAll(name: string): string[];
|
|
8
|
-
has(name: string): boolean;
|
|
9
|
-
set(name: string, value: string): void;
|
|
10
|
-
sort(): void;
|
|
11
|
-
toString(): string;
|
|
12
|
-
_keys(): IterableIterator<string>;
|
|
13
|
-
keys(): URLSearchParamsIterator<string>;
|
|
14
|
-
_entries(): IterableIterator<[string, string]>;
|
|
15
|
-
entries(): URLSearchParamsIterator<[string, string]>;
|
|
16
|
-
_values(): IterableIterator<string>;
|
|
17
|
-
values(): URLSearchParamsIterator<string>;
|
|
18
|
-
[Symbol.iterator](): URLSearchParamsIterator<[string, string]>;
|
|
19
|
-
forEach(callback: (value: string, key: string, parent: URLSearchParams) => void): void;
|
|
20
|
-
get size(): number;
|
|
21
|
-
}
|
|
1
|
+
export declare const PonyfillURLSearchParams: {
|
|
2
|
+
new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
|
|
3
|
+
prototype: URLSearchParams;
|
|
4
|
+
};
|