@whatwg-node/node-fetch 0.7.25-alpha-20250730131423-ec6ed6af785e1ac685b1ff9a330040eb56db0870 → 0.7.25-alpha-20250731231608-1ed5805b7f2d6c45e43801caebb747d50101df7a
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/Blob.js +2 -2
- package/cjs/fetchNodeHttp.js +101 -106
- package/cjs/utils.js +2 -3
- package/esm/Blob.js +2 -2
- package/esm/fetchNodeHttp.js +103 -108
- package/esm/utils.js +2 -3
- package/package.json +1 -1
- package/typings/Blob.d.cts +4 -4
- package/typings/Blob.d.ts +4 -4
- package/typings/Body.d.cts +6 -6
- package/typings/Body.d.ts +6 -6
- package/typings/TextEncoderDecoder.d.cts +1 -1
- package/typings/TextEncoderDecoder.d.ts +1 -1
- package/typings/utils.d.cts +1 -1
- package/typings/utils.d.ts +1 -1
package/cjs/Blob.js
CHANGED
@@ -148,11 +148,11 @@ class PonyfillBlob {
|
|
148
148
|
if (this.blobParts.length === 1) {
|
149
149
|
if (node_buffer_1.Buffer.isBuffer(this.blobParts[0])) {
|
150
150
|
this._buffer = this.blobParts[0];
|
151
|
-
return (0, utils_js_1.fakePromise)(this.
|
151
|
+
return (0, utils_js_1.fakePromise)(this._buffer);
|
152
152
|
}
|
153
153
|
if (this.blobParts[0] instanceof Uint8Array) {
|
154
154
|
this._buffer = node_buffer_1.Buffer.from(this.blobParts[0]);
|
155
|
-
return (0, utils_js_1.fakePromise)(this.
|
155
|
+
return (0, utils_js_1.fakePromise)(this._buffer);
|
156
156
|
}
|
157
157
|
if (hasBytesMethod(this.blobParts[0])) {
|
158
158
|
return this.blobParts[0].bytes();
|
package/cjs/fetchNodeHttp.js
CHANGED
@@ -20,83 +20,79 @@ function getRequestFnForProtocol(url) {
|
|
20
20
|
throw new Error(`Unsupported protocol: ${url.split(':')[0] || url}`);
|
21
21
|
}
|
22
22
|
function fetchNodeHttp(fetchRequest) {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
}
|
56
|
-
nodeRequest.once('error', e => deferred.reject(e));
|
57
|
-
nodeRequest.once('response', nodeResponse => {
|
58
|
-
let outputStream;
|
59
|
-
const contentEncoding = nodeResponse.headers['content-encoding'];
|
60
|
-
switch (contentEncoding) {
|
61
|
-
case 'x-gzip':
|
62
|
-
case 'gzip':
|
63
|
-
outputStream = (0, node_zlib_1.createGunzip)();
|
64
|
-
break;
|
65
|
-
case 'x-deflate':
|
66
|
-
case 'deflate':
|
67
|
-
outputStream = (0, node_zlib_1.createInflate)();
|
68
|
-
break;
|
69
|
-
case 'x-deflate-raw':
|
70
|
-
case 'deflate-raw':
|
71
|
-
outputStream = (0, node_zlib_1.createInflateRaw)();
|
72
|
-
break;
|
73
|
-
case 'br':
|
74
|
-
outputStream = (0, node_zlib_1.createBrotliDecompress)();
|
75
|
-
break;
|
23
|
+
return new Promise((resolve, reject) => {
|
24
|
+
try {
|
25
|
+
const requestFn = getRequestFnForProtocol(fetchRequest.parsedUrl?.protocol || fetchRequest.url);
|
26
|
+
const headersSerializer = fetchRequest.headersSerializer || utils_js_1.getHeadersObj;
|
27
|
+
const nodeHeaders = headersSerializer(fetchRequest.headers);
|
28
|
+
if (nodeHeaders['accept-encoding'] == null) {
|
29
|
+
nodeHeaders['accept-encoding'] = 'gzip, deflate, br';
|
30
|
+
}
|
31
|
+
let signal;
|
32
|
+
if (fetchRequest._signal == null) {
|
33
|
+
signal = undefined;
|
34
|
+
}
|
35
|
+
else if (fetchRequest._signal) {
|
36
|
+
signal = fetchRequest._signal;
|
37
|
+
}
|
38
|
+
let nodeRequest;
|
39
|
+
// If it is our ponyfilled Request, it should have `parsedUrl` which is a `URL` object
|
40
|
+
if (fetchRequest.parsedUrl) {
|
41
|
+
nodeRequest = requestFn(fetchRequest.parsedUrl, {
|
42
|
+
method: fetchRequest.method,
|
43
|
+
headers: nodeHeaders,
|
44
|
+
signal,
|
45
|
+
agent: fetchRequest.agent,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
nodeRequest = requestFn(fetchRequest.url, {
|
50
|
+
method: fetchRequest.method,
|
51
|
+
headers: nodeHeaders,
|
52
|
+
signal,
|
53
|
+
agent: fetchRequest.agent,
|
54
|
+
});
|
76
55
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
56
|
+
nodeRequest.once('error', reject);
|
57
|
+
nodeRequest.once('response', nodeResponse => {
|
58
|
+
let outputStream;
|
59
|
+
const contentEncoding = nodeResponse.headers['content-encoding'];
|
60
|
+
switch (contentEncoding) {
|
61
|
+
case 'x-gzip':
|
62
|
+
case 'gzip':
|
63
|
+
outputStream = (0, node_zlib_1.createGunzip)();
|
64
|
+
break;
|
65
|
+
case 'x-deflate':
|
66
|
+
case 'deflate':
|
67
|
+
outputStream = (0, node_zlib_1.createInflate)();
|
68
|
+
break;
|
69
|
+
case 'x-deflate-raw':
|
70
|
+
case 'deflate-raw':
|
71
|
+
outputStream = (0, node_zlib_1.createInflateRaw)();
|
72
|
+
break;
|
73
|
+
case 'br':
|
74
|
+
outputStream = (0, node_zlib_1.createBrotliDecompress)();
|
75
|
+
break;
|
83
76
|
}
|
84
|
-
if (
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
77
|
+
if (nodeResponse.headers.location && (0, utils_js_1.shouldRedirect)(nodeResponse.statusCode)) {
|
78
|
+
if (fetchRequest.redirect === 'error') {
|
79
|
+
const redirectError = new Error('Redirects are not allowed');
|
80
|
+
reject(redirectError);
|
81
|
+
nodeResponse.resume();
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
if (fetchRequest.redirect === 'follow') {
|
85
|
+
const redirectedUrl = new URL_js_1.PonyfillURL(nodeResponse.headers.location, fetchRequest.parsedUrl || fetchRequest.url);
|
86
|
+
const redirectResponse$ = fetchNodeHttp(new Request_js_1.PonyfillRequest(redirectedUrl, fetchRequest));
|
87
|
+
resolve(redirectResponse$.then(redirectResponse => {
|
88
|
+
redirectResponse.redirected = true;
|
89
|
+
return redirectResponse;
|
90
|
+
}));
|
91
|
+
nodeResponse.resume();
|
92
|
+
return;
|
93
|
+
}
|
97
94
|
}
|
98
|
-
|
99
|
-
if (outputStream) {
|
95
|
+
outputStream ||= new node_stream_1.PassThrough();
|
100
96
|
(0, utils_js_1.pipeThrough)({
|
101
97
|
src: nodeResponse,
|
102
98
|
dest: outputStream,
|
@@ -108,43 +104,42 @@ function fetchNodeHttp(fetchRequest) {
|
|
108
104
|
if (!outputStream.destroyed) {
|
109
105
|
outputStream.destroy(e);
|
110
106
|
}
|
111
|
-
|
107
|
+
reject(e);
|
112
108
|
},
|
113
109
|
});
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
110
|
+
const statusCode = nodeResponse.statusCode || 200;
|
111
|
+
let statusText = nodeResponse.statusMessage || node_http_1.STATUS_CODES[statusCode];
|
112
|
+
if (statusText == null) {
|
113
|
+
statusText = '';
|
114
|
+
}
|
115
|
+
const ponyfillResponse = new Response_js_1.PonyfillResponse(outputStream || nodeResponse, {
|
116
|
+
status: statusCode,
|
117
|
+
statusText,
|
118
|
+
headers: nodeResponse.headers,
|
119
|
+
url: fetchRequest.url,
|
120
|
+
signal,
|
121
|
+
});
|
122
|
+
resolve(ponyfillResponse);
|
126
123
|
});
|
127
|
-
|
128
|
-
|
129
|
-
if (fetchRequest['_buffer'] != null) {
|
130
|
-
(0, promise_helpers_1.handleMaybePromise)(() => (0, utils_js_1.safeWrite)(fetchRequest['_buffer'], nodeRequest), () => (0, utils_js_1.endStream)(nodeRequest), e => deferred.reject(e));
|
131
|
-
}
|
132
|
-
else {
|
133
|
-
const nodeReadable = (fetchRequest.body != null
|
134
|
-
? (0, utils_js_1.isNodeReadable)(fetchRequest.body)
|
135
|
-
? fetchRequest.body
|
136
|
-
: node_stream_1.Readable.from(fetchRequest.body)
|
137
|
-
: null);
|
138
|
-
if (nodeReadable) {
|
139
|
-
nodeReadable.pipe(nodeRequest);
|
124
|
+
if (fetchRequest['_buffer'] != null) {
|
125
|
+
(0, promise_helpers_1.handleMaybePromise)(() => (0, utils_js_1.safeWrite)(fetchRequest['_buffer'], nodeRequest), () => (0, utils_js_1.endStream)(nodeRequest), reject);
|
140
126
|
}
|
141
127
|
else {
|
142
|
-
(
|
128
|
+
const nodeReadable = (fetchRequest.body != null
|
129
|
+
? (0, utils_js_1.isNodeReadable)(fetchRequest.body)
|
130
|
+
? fetchRequest.body
|
131
|
+
: node_stream_1.Readable.from(fetchRequest.body)
|
132
|
+
: null);
|
133
|
+
if (nodeReadable) {
|
134
|
+
nodeReadable.pipe(nodeRequest);
|
135
|
+
}
|
136
|
+
else {
|
137
|
+
(0, utils_js_1.endStream)(nodeRequest);
|
138
|
+
}
|
143
139
|
}
|
144
140
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
}
|
149
|
-
return deferred.promise;
|
141
|
+
catch (e) {
|
142
|
+
reject(e);
|
143
|
+
}
|
144
|
+
});
|
150
145
|
}
|
package/cjs/utils.js
CHANGED
@@ -10,6 +10,7 @@ exports.shouldRedirect = shouldRedirect;
|
|
10
10
|
exports.pipeThrough = pipeThrough;
|
11
11
|
exports.endStream = endStream;
|
12
12
|
exports.safeWrite = safeWrite;
|
13
|
+
const node_events_1 = require("node:events");
|
13
14
|
function isHeadersInstance(obj) {
|
14
15
|
return obj?.forEach != null;
|
15
16
|
}
|
@@ -98,9 +99,7 @@ function endStream(stream) {
|
|
98
99
|
function safeWrite(chunk, stream) {
|
99
100
|
const result = stream.write(chunk);
|
100
101
|
if (!result) {
|
101
|
-
return
|
102
|
-
stream.once('drain', resolve);
|
103
|
-
});
|
102
|
+
return (0, node_events_1.once)(stream, 'drain');
|
104
103
|
}
|
105
104
|
}
|
106
105
|
// https://github.com/nodejs/node/blob/f692878dec6354c0a82241f224906981861bc840/lib/internal/errors.js#L961-L973
|
package/esm/Blob.js
CHANGED
@@ -137,11 +137,11 @@ export class PonyfillBlob {
|
|
137
137
|
if (this.blobParts.length === 1) {
|
138
138
|
if (Buffer.isBuffer(this.blobParts[0])) {
|
139
139
|
this._buffer = this.blobParts[0];
|
140
|
-
return fakePromise(this.
|
140
|
+
return fakePromise(this._buffer);
|
141
141
|
}
|
142
142
|
if (this.blobParts[0] instanceof Uint8Array) {
|
143
143
|
this._buffer = Buffer.from(this.blobParts[0]);
|
144
|
-
return fakePromise(this.
|
144
|
+
return fakePromise(this._buffer);
|
145
145
|
}
|
146
146
|
if (hasBytesMethod(this.blobParts[0])) {
|
147
147
|
return this.blobParts[0].bytes();
|
package/esm/fetchNodeHttp.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { request as httpRequest, STATUS_CODES } from 'node:http';
|
2
2
|
import { request as httpsRequest } from 'node:https';
|
3
|
-
import { Readable } from 'node:stream';
|
3
|
+
import { PassThrough, Readable } from 'node:stream';
|
4
4
|
import { createBrotliDecompress, createGunzip, createInflate, createInflateRaw } from 'node:zlib';
|
5
|
-
import {
|
5
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
6
6
|
import { PonyfillRequest } from './Request.js';
|
7
7
|
import { PonyfillResponse } from './Response.js';
|
8
8
|
import { PonyfillURL } from './URL.js';
|
@@ -17,83 +17,79 @@ function getRequestFnForProtocol(url) {
|
|
17
17
|
throw new Error(`Unsupported protocol: ${url.split(':')[0] || url}`);
|
18
18
|
}
|
19
19
|
export function fetchNodeHttp(fetchRequest) {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
nodeRequest.once('error', e => deferred.reject(e));
|
54
|
-
nodeRequest.once('response', nodeResponse => {
|
55
|
-
let outputStream;
|
56
|
-
const contentEncoding = nodeResponse.headers['content-encoding'];
|
57
|
-
switch (contentEncoding) {
|
58
|
-
case 'x-gzip':
|
59
|
-
case 'gzip':
|
60
|
-
outputStream = createGunzip();
|
61
|
-
break;
|
62
|
-
case 'x-deflate':
|
63
|
-
case 'deflate':
|
64
|
-
outputStream = createInflate();
|
65
|
-
break;
|
66
|
-
case 'x-deflate-raw':
|
67
|
-
case 'deflate-raw':
|
68
|
-
outputStream = createInflateRaw();
|
69
|
-
break;
|
70
|
-
case 'br':
|
71
|
-
outputStream = createBrotliDecompress();
|
72
|
-
break;
|
20
|
+
return new Promise((resolve, reject) => {
|
21
|
+
try {
|
22
|
+
const requestFn = getRequestFnForProtocol(fetchRequest.parsedUrl?.protocol || fetchRequest.url);
|
23
|
+
const headersSerializer = fetchRequest.headersSerializer || getHeadersObj;
|
24
|
+
const nodeHeaders = headersSerializer(fetchRequest.headers);
|
25
|
+
if (nodeHeaders['accept-encoding'] == null) {
|
26
|
+
nodeHeaders['accept-encoding'] = 'gzip, deflate, br';
|
27
|
+
}
|
28
|
+
let signal;
|
29
|
+
if (fetchRequest._signal == null) {
|
30
|
+
signal = undefined;
|
31
|
+
}
|
32
|
+
else if (fetchRequest._signal) {
|
33
|
+
signal = fetchRequest._signal;
|
34
|
+
}
|
35
|
+
let nodeRequest;
|
36
|
+
// If it is our ponyfilled Request, it should have `parsedUrl` which is a `URL` object
|
37
|
+
if (fetchRequest.parsedUrl) {
|
38
|
+
nodeRequest = requestFn(fetchRequest.parsedUrl, {
|
39
|
+
method: fetchRequest.method,
|
40
|
+
headers: nodeHeaders,
|
41
|
+
signal,
|
42
|
+
agent: fetchRequest.agent,
|
43
|
+
});
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
nodeRequest = requestFn(fetchRequest.url, {
|
47
|
+
method: fetchRequest.method,
|
48
|
+
headers: nodeHeaders,
|
49
|
+
signal,
|
50
|
+
agent: fetchRequest.agent,
|
51
|
+
});
|
73
52
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
53
|
+
nodeRequest.once('error', reject);
|
54
|
+
nodeRequest.once('response', nodeResponse => {
|
55
|
+
let outputStream;
|
56
|
+
const contentEncoding = nodeResponse.headers['content-encoding'];
|
57
|
+
switch (contentEncoding) {
|
58
|
+
case 'x-gzip':
|
59
|
+
case 'gzip':
|
60
|
+
outputStream = createGunzip();
|
61
|
+
break;
|
62
|
+
case 'x-deflate':
|
63
|
+
case 'deflate':
|
64
|
+
outputStream = createInflate();
|
65
|
+
break;
|
66
|
+
case 'x-deflate-raw':
|
67
|
+
case 'deflate-raw':
|
68
|
+
outputStream = createInflateRaw();
|
69
|
+
break;
|
70
|
+
case 'br':
|
71
|
+
outputStream = createBrotliDecompress();
|
72
|
+
break;
|
80
73
|
}
|
81
|
-
if (
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
74
|
+
if (nodeResponse.headers.location && shouldRedirect(nodeResponse.statusCode)) {
|
75
|
+
if (fetchRequest.redirect === 'error') {
|
76
|
+
const redirectError = new Error('Redirects are not allowed');
|
77
|
+
reject(redirectError);
|
78
|
+
nodeResponse.resume();
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
if (fetchRequest.redirect === 'follow') {
|
82
|
+
const redirectedUrl = new PonyfillURL(nodeResponse.headers.location, fetchRequest.parsedUrl || fetchRequest.url);
|
83
|
+
const redirectResponse$ = fetchNodeHttp(new PonyfillRequest(redirectedUrl, fetchRequest));
|
84
|
+
resolve(redirectResponse$.then(redirectResponse => {
|
85
|
+
redirectResponse.redirected = true;
|
86
|
+
return redirectResponse;
|
87
|
+
}));
|
88
|
+
nodeResponse.resume();
|
89
|
+
return;
|
90
|
+
}
|
94
91
|
}
|
95
|
-
|
96
|
-
if (outputStream) {
|
92
|
+
outputStream ||= new PassThrough();
|
97
93
|
pipeThrough({
|
98
94
|
src: nodeResponse,
|
99
95
|
dest: outputStream,
|
@@ -105,43 +101,42 @@ export function fetchNodeHttp(fetchRequest) {
|
|
105
101
|
if (!outputStream.destroyed) {
|
106
102
|
outputStream.destroy(e);
|
107
103
|
}
|
108
|
-
|
104
|
+
reject(e);
|
109
105
|
},
|
110
106
|
});
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
107
|
+
const statusCode = nodeResponse.statusCode || 200;
|
108
|
+
let statusText = nodeResponse.statusMessage || STATUS_CODES[statusCode];
|
109
|
+
if (statusText == null) {
|
110
|
+
statusText = '';
|
111
|
+
}
|
112
|
+
const ponyfillResponse = new PonyfillResponse(outputStream || nodeResponse, {
|
113
|
+
status: statusCode,
|
114
|
+
statusText,
|
115
|
+
headers: nodeResponse.headers,
|
116
|
+
url: fetchRequest.url,
|
117
|
+
signal,
|
118
|
+
});
|
119
|
+
resolve(ponyfillResponse);
|
123
120
|
});
|
124
|
-
|
125
|
-
|
126
|
-
if (fetchRequest['_buffer'] != null) {
|
127
|
-
handleMaybePromise(() => safeWrite(fetchRequest['_buffer'], nodeRequest), () => endStream(nodeRequest), e => deferred.reject(e));
|
128
|
-
}
|
129
|
-
else {
|
130
|
-
const nodeReadable = (fetchRequest.body != null
|
131
|
-
? isNodeReadable(fetchRequest.body)
|
132
|
-
? fetchRequest.body
|
133
|
-
: Readable.from(fetchRequest.body)
|
134
|
-
: null);
|
135
|
-
if (nodeReadable) {
|
136
|
-
nodeReadable.pipe(nodeRequest);
|
121
|
+
if (fetchRequest['_buffer'] != null) {
|
122
|
+
handleMaybePromise(() => safeWrite(fetchRequest['_buffer'], nodeRequest), () => endStream(nodeRequest), reject);
|
137
123
|
}
|
138
124
|
else {
|
139
|
-
|
125
|
+
const nodeReadable = (fetchRequest.body != null
|
126
|
+
? isNodeReadable(fetchRequest.body)
|
127
|
+
? fetchRequest.body
|
128
|
+
: Readable.from(fetchRequest.body)
|
129
|
+
: null);
|
130
|
+
if (nodeReadable) {
|
131
|
+
nodeReadable.pipe(nodeRequest);
|
132
|
+
}
|
133
|
+
else {
|
134
|
+
endStream(nodeRequest);
|
135
|
+
}
|
140
136
|
}
|
141
137
|
}
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
}
|
146
|
-
return deferred.promise;
|
138
|
+
catch (e) {
|
139
|
+
reject(e);
|
140
|
+
}
|
141
|
+
});
|
147
142
|
}
|
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
|
}
|
@@ -85,9 +86,7 @@ export function endStream(stream) {
|
|
85
86
|
export function safeWrite(chunk, stream) {
|
86
87
|
const result = stream.write(chunk);
|
87
88
|
if (!result) {
|
88
|
-
return
|
89
|
-
stream.once('drain', resolve);
|
90
|
-
});
|
89
|
+
return once(stream, 'drain');
|
91
90
|
}
|
92
91
|
}
|
93
92
|
// https://github.com/nodejs/node/blob/f692878dec6354c0a82241f224906981861bc840/lib/internal/errors.js#L961-L973
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.7.25-alpha-
|
3
|
+
"version": "0.7.25-alpha-20250731231608-1ed5805b7f2d6c45e43801caebb747d50101df7a",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
package/typings/Blob.d.cts
CHANGED
@@ -16,7 +16,7 @@ interface BlobOptions {
|
|
16
16
|
size?: number | null;
|
17
17
|
}
|
18
18
|
export declare function hasBufferMethod(obj: any): obj is {
|
19
|
-
buffer(): Promise<Buffer
|
19
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
20
20
|
};
|
21
21
|
export declare function hasArrayBufferMethod(obj: any): obj is {
|
22
22
|
arrayBuffer(): Promise<ArrayBuffer>;
|
@@ -42,10 +42,10 @@ export declare class PonyfillBlob implements Blob {
|
|
42
42
|
private encoding;
|
43
43
|
private _size;
|
44
44
|
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
45
|
-
_buffer: Buffer | null;
|
46
|
-
buffer(): Promise<Buffer<
|
45
|
+
_buffer: Buffer<ArrayBuffer> | null;
|
46
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
47
47
|
arrayBuffer(): Promise<ArrayBuffer>;
|
48
|
-
bytes(): Promise<Uint8Array
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
49
49
|
_text: string | null;
|
50
50
|
text(): Promise<string>;
|
51
51
|
_json: any;
|
package/typings/Blob.d.ts
CHANGED
@@ -16,7 +16,7 @@ interface BlobOptions {
|
|
16
16
|
size?: number | null;
|
17
17
|
}
|
18
18
|
export declare function hasBufferMethod(obj: any): obj is {
|
19
|
-
buffer(): Promise<Buffer
|
19
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
20
20
|
};
|
21
21
|
export declare function hasArrayBufferMethod(obj: any): obj is {
|
22
22
|
arrayBuffer(): Promise<ArrayBuffer>;
|
@@ -42,10 +42,10 @@ export declare class PonyfillBlob implements Blob {
|
|
42
42
|
private encoding;
|
43
43
|
private _size;
|
44
44
|
constructor(blobParts?: BlobPart[], options?: BlobOptions);
|
45
|
-
_buffer: Buffer | null;
|
46
|
-
buffer(): Promise<Buffer<
|
45
|
+
_buffer: Buffer<ArrayBuffer> | null;
|
46
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
47
47
|
arrayBuffer(): Promise<ArrayBuffer>;
|
48
|
-
bytes(): Promise<Uint8Array
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
49
49
|
_text: string | null;
|
50
50
|
text(): Promise<string>;
|
51
51
|
_json: any;
|
package/typings/Body.d.cts
CHANGED
@@ -34,18 +34,18 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
34
34
|
protected handleContentLengthHeader(this: PonyfillBody & {
|
35
35
|
headers: Headers;
|
36
36
|
}, forceSet?: boolean): void;
|
37
|
-
get body(): PonyfillReadableStream<Uint8Array
|
38
|
-
_chunks: MaybePromise<Uint8Array[]> | null;
|
39
|
-
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<
|
40
|
-
_collectChunksFromReadable(): MaybePromise<Uint8Array<
|
37
|
+
get body(): PonyfillReadableStream<Uint8Array<ArrayBuffer>> | null;
|
38
|
+
_chunks: MaybePromise<Uint8Array<ArrayBuffer>[]> | null;
|
39
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
40
|
+
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
41
41
|
_blob: PonyfillBlob | null;
|
42
42
|
blob(): Promise<PonyfillBlob>;
|
43
43
|
_formData: PonyfillFormData | null;
|
44
44
|
formData(opts?: {
|
45
45
|
formDataLimits: FormDataLimits;
|
46
46
|
}): Promise<PonyfillFormData>;
|
47
|
-
buffer(): Promise<Buffer
|
48
|
-
bytes(): Promise<Uint8Array
|
47
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
49
49
|
arrayBuffer(): Promise<ArrayBuffer>;
|
50
50
|
_json: TJSON | null;
|
51
51
|
json(): Promise<TJSON>;
|
package/typings/Body.d.ts
CHANGED
@@ -34,18 +34,18 @@ export declare class PonyfillBody<TJSON = any> implements Body {
|
|
34
34
|
protected handleContentLengthHeader(this: PonyfillBody & {
|
35
35
|
headers: Headers;
|
36
36
|
}, forceSet?: boolean): void;
|
37
|
-
get body(): PonyfillReadableStream<Uint8Array
|
38
|
-
_chunks: MaybePromise<Uint8Array[]> | null;
|
39
|
-
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<
|
40
|
-
_collectChunksFromReadable(): MaybePromise<Uint8Array<
|
37
|
+
get body(): PonyfillReadableStream<Uint8Array<ArrayBuffer>> | null;
|
38
|
+
_chunks: MaybePromise<Uint8Array<ArrayBuffer>[]> | null;
|
39
|
+
_doCollectChunksFromReadableJob(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
40
|
+
_collectChunksFromReadable(): MaybePromise<Uint8Array<ArrayBuffer>[]>;
|
41
41
|
_blob: PonyfillBlob | null;
|
42
42
|
blob(): Promise<PonyfillBlob>;
|
43
43
|
_formData: PonyfillFormData | null;
|
44
44
|
formData(opts?: {
|
45
45
|
formDataLimits: FormDataLimits;
|
46
46
|
}): Promise<PonyfillFormData>;
|
47
|
-
buffer(): Promise<Buffer
|
48
|
-
bytes(): Promise<Uint8Array
|
47
|
+
buffer(): Promise<Buffer<ArrayBuffer>>;
|
48
|
+
bytes(): Promise<Uint8Array<ArrayBuffer>>;
|
49
49
|
arrayBuffer(): Promise<ArrayBuffer>;
|
50
50
|
_json: TJSON | null;
|
51
51
|
json(): Promise<TJSON>;
|
@@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer';
|
|
2
2
|
export declare class PonyfillTextEncoder implements TextEncoder {
|
3
3
|
encoding: BufferEncoding;
|
4
4
|
constructor(encoding?: BufferEncoding);
|
5
|
-
encode(input: string): Buffer
|
5
|
+
encode(input: string): Buffer<ArrayBuffer>;
|
6
6
|
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
|
7
7
|
}
|
8
8
|
export declare class PonyfillTextDecoder implements TextDecoder {
|
@@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer';
|
|
2
2
|
export declare class PonyfillTextEncoder implements TextEncoder {
|
3
3
|
encoding: BufferEncoding;
|
4
4
|
constructor(encoding?: BufferEncoding);
|
5
|
-
encode(input: string): Buffer
|
5
|
+
encode(input: string): Buffer<ArrayBuffer>;
|
6
6
|
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
|
7
7
|
}
|
8
8
|
export declare class PonyfillTextDecoder implements TextDecoder {
|
package/typings/utils.d.cts
CHANGED
@@ -15,4 +15,4 @@ export declare function pipeThrough({ src, dest, signal, onError, }: {
|
|
15
15
|
export declare function endStream(stream: {
|
16
16
|
end: () => void;
|
17
17
|
}): void;
|
18
|
-
export declare function safeWrite(chunk: any, stream: Writable): Promise<
|
18
|
+
export declare function safeWrite(chunk: any, stream: Writable): Promise<any[]> | undefined;
|
package/typings/utils.d.ts
CHANGED
@@ -15,4 +15,4 @@ export declare function pipeThrough({ src, dest, signal, onError, }: {
|
|
15
15
|
export declare function endStream(stream: {
|
16
16
|
end: () => void;
|
17
17
|
}): void;
|
18
|
-
export declare function safeWrite(chunk: any, stream: Writable): Promise<
|
18
|
+
export declare function safeWrite(chunk: any, stream: Writable): Promise<any[]> | undefined;
|