@whatwg-node/node-fetch 0.5.10-alpha-20240321134843-2ae7764efe55eb7970cab335a048aebb4a6d3b0f → 0.5.10-alpha-20240322103629-07f53b56429d0c2dcdb6dcd240226e0f599203e0
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/Body.js +2 -3
- package/cjs/URL.js +0 -19
- package/cjs/fetch.js +0 -18
- package/cjs/fetchCurl.js +9 -1
- package/esm/Body.js +2 -3
- package/esm/URL.js +0 -19
- package/esm/fetch.js +0 -18
- package/esm/fetchCurl.js +9 -1
- package/package.json +1 -1
- package/typings/URL.d.cts +0 -5
- package/typings/URL.d.ts +0 -5
package/cjs/Body.js
CHANGED
@@ -162,9 +162,8 @@ class PonyfillBody {
|
|
162
162
|
bb.on('close', () => {
|
163
163
|
resolve(formData);
|
164
164
|
});
|
165
|
-
bb.on('error',
|
166
|
-
|
167
|
-
reject(new TypeError(errMessage, err.cause));
|
165
|
+
bb.on('error', err => {
|
166
|
+
reject(err);
|
168
167
|
});
|
169
168
|
_body?.readable.pipe(bb);
|
170
169
|
});
|
package/cjs/URL.js
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.PonyfillURL = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
|
-
const buffer_1 = require("buffer");
|
6
|
-
const crypto_1 = require("crypto");
|
7
5
|
const fast_querystring_1 = tslib_1.__importDefault(require("fast-querystring"));
|
8
6
|
const fast_url_parser_1 = tslib_1.__importDefault(require("@kamilkisiela/fast-url-parser"));
|
9
7
|
const URLSearchParams_js_1 = require("./URLSearchParams.js");
|
@@ -51,22 +49,5 @@ class PonyfillURL extends fast_url_parser_1.default {
|
|
51
49
|
toJSON() {
|
52
50
|
return this.toString();
|
53
51
|
}
|
54
|
-
static createObjectURL(blob) {
|
55
|
-
const blobUrl = `blob:whatwgnode:${(0, crypto_1.randomUUID)()}`;
|
56
|
-
this.blobRegistry.set(blobUrl, blob);
|
57
|
-
return blobUrl;
|
58
|
-
}
|
59
|
-
static resolveObjectURL(url) {
|
60
|
-
if (!this.blobRegistry.has(url)) {
|
61
|
-
URL.revokeObjectURL(url);
|
62
|
-
}
|
63
|
-
else {
|
64
|
-
this.blobRegistry.delete(url);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
static getBlobFromURL(url) {
|
68
|
-
return (this.blobRegistry.get(url) || (0, buffer_1.resolveObjectURL)(url));
|
69
|
-
}
|
70
52
|
}
|
71
53
|
exports.PonyfillURL = PonyfillURL;
|
72
|
-
PonyfillURL.blobRegistry = new Map();
|
package/cjs/fetch.js
CHANGED
@@ -7,7 +7,6 @@ const fetchCurl_js_1 = require("./fetchCurl.js");
|
|
7
7
|
const fetchNodeHttp_js_1 = require("./fetchNodeHttp.js");
|
8
8
|
const Request_js_1 = require("./Request.js");
|
9
9
|
const Response_js_1 = require("./Response.js");
|
10
|
-
const URL_js_1 = require("./URL.js");
|
11
10
|
const utils_js_1 = require("./utils.js");
|
12
11
|
const BASE64_SUFFIX = ';base64';
|
13
12
|
function getResponseForFile(url) {
|
@@ -37,19 +36,6 @@ function getResponseForDataUri(url) {
|
|
37
36
|
},
|
38
37
|
});
|
39
38
|
}
|
40
|
-
function getResponseForBlob(url) {
|
41
|
-
const blob = URL_js_1.PonyfillURL.getBlobFromURL(url);
|
42
|
-
if (!blob) {
|
43
|
-
throw new TypeError('Invalid Blob URL');
|
44
|
-
}
|
45
|
-
return new Response_js_1.PonyfillResponse(blob, {
|
46
|
-
status: 200,
|
47
|
-
headers: {
|
48
|
-
'content-type': blob.type,
|
49
|
-
'content-length': blob.size.toString(),
|
50
|
-
},
|
51
|
-
});
|
52
|
-
}
|
53
39
|
function isURL(obj) {
|
54
40
|
return obj != null && obj.href != null;
|
55
41
|
}
|
@@ -67,10 +53,6 @@ function fetchPonyfill(info, init) {
|
|
67
53
|
const response = getResponseForFile(fetchRequest.url);
|
68
54
|
return (0, utils_js_1.fakePromise)(response);
|
69
55
|
}
|
70
|
-
if (fetchRequest.url.startsWith('blob:')) {
|
71
|
-
const response = getResponseForBlob(fetchRequest.url);
|
72
|
-
return (0, utils_js_1.fakePromise)(response);
|
73
|
-
}
|
74
56
|
if (globalThis.libcurl) {
|
75
57
|
return (0, fetchCurl_js_1.fetchCurl)(fetchRequest);
|
76
58
|
}
|
package/cjs/fetchCurl.js
CHANGED
@@ -56,7 +56,12 @@ function fetchCurl(fetchRequest) {
|
|
56
56
|
if (fetchRequest['_signal']) {
|
57
57
|
fetchRequest['_signal'].onabort = () => {
|
58
58
|
if (curlHandle.isOpen) {
|
59
|
-
|
59
|
+
try {
|
60
|
+
curlHandle.pause(CurlPause.Recv);
|
61
|
+
}
|
62
|
+
catch (e) {
|
63
|
+
reject(e);
|
64
|
+
}
|
60
65
|
}
|
61
66
|
};
|
62
67
|
}
|
@@ -68,6 +73,9 @@ function fetchCurl(fetchRequest) {
|
|
68
73
|
streamResolved.destroy(error);
|
69
74
|
}
|
70
75
|
else {
|
76
|
+
if (error.message === 'Operation was aborted by an application callback') {
|
77
|
+
error.message = 'The operation was aborted.';
|
78
|
+
}
|
71
79
|
reject(error);
|
72
80
|
}
|
73
81
|
curlHandle.close();
|
package/esm/Body.js
CHANGED
@@ -158,9 +158,8 @@ export class PonyfillBody {
|
|
158
158
|
bb.on('close', () => {
|
159
159
|
resolve(formData);
|
160
160
|
});
|
161
|
-
bb.on('error',
|
162
|
-
|
163
|
-
reject(new TypeError(errMessage, err.cause));
|
161
|
+
bb.on('error', err => {
|
162
|
+
reject(err);
|
164
163
|
});
|
165
164
|
_body?.readable.pipe(bb);
|
166
165
|
});
|
package/esm/URL.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
import { resolveObjectURL } from 'buffer';
|
2
|
-
import { randomUUID } from 'crypto';
|
3
1
|
import FastQuerystring from 'fast-querystring';
|
4
2
|
import FastUrl from '@kamilkisiela/fast-url-parser';
|
5
3
|
import { PonyfillURLSearchParams } from './URLSearchParams.js';
|
@@ -47,21 +45,4 @@ export class PonyfillURL extends FastUrl {
|
|
47
45
|
toJSON() {
|
48
46
|
return this.toString();
|
49
47
|
}
|
50
|
-
static createObjectURL(blob) {
|
51
|
-
const blobUrl = `blob:whatwgnode:${randomUUID()}`;
|
52
|
-
this.blobRegistry.set(blobUrl, blob);
|
53
|
-
return blobUrl;
|
54
|
-
}
|
55
|
-
static resolveObjectURL(url) {
|
56
|
-
if (!this.blobRegistry.has(url)) {
|
57
|
-
URL.revokeObjectURL(url);
|
58
|
-
}
|
59
|
-
else {
|
60
|
-
this.blobRegistry.delete(url);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
static getBlobFromURL(url) {
|
64
|
-
return (this.blobRegistry.get(url) || resolveObjectURL(url));
|
65
|
-
}
|
66
48
|
}
|
67
|
-
PonyfillURL.blobRegistry = new Map();
|
package/esm/fetch.js
CHANGED
@@ -4,7 +4,6 @@ import { fetchCurl } from './fetchCurl.js';
|
|
4
4
|
import { fetchNodeHttp } from './fetchNodeHttp.js';
|
5
5
|
import { PonyfillRequest } from './Request.js';
|
6
6
|
import { PonyfillResponse } from './Response.js';
|
7
|
-
import { PonyfillURL } from './URL.js';
|
8
7
|
import { fakePromise } from './utils.js';
|
9
8
|
const BASE64_SUFFIX = ';base64';
|
10
9
|
function getResponseForFile(url) {
|
@@ -34,19 +33,6 @@ function getResponseForDataUri(url) {
|
|
34
33
|
},
|
35
34
|
});
|
36
35
|
}
|
37
|
-
function getResponseForBlob(url) {
|
38
|
-
const blob = PonyfillURL.getBlobFromURL(url);
|
39
|
-
if (!blob) {
|
40
|
-
throw new TypeError('Invalid Blob URL');
|
41
|
-
}
|
42
|
-
return new PonyfillResponse(blob, {
|
43
|
-
status: 200,
|
44
|
-
headers: {
|
45
|
-
'content-type': blob.type,
|
46
|
-
'content-length': blob.size.toString(),
|
47
|
-
},
|
48
|
-
});
|
49
|
-
}
|
50
36
|
function isURL(obj) {
|
51
37
|
return obj != null && obj.href != null;
|
52
38
|
}
|
@@ -64,10 +50,6 @@ export function fetchPonyfill(info, init) {
|
|
64
50
|
const response = getResponseForFile(fetchRequest.url);
|
65
51
|
return fakePromise(response);
|
66
52
|
}
|
67
|
-
if (fetchRequest.url.startsWith('blob:')) {
|
68
|
-
const response = getResponseForBlob(fetchRequest.url);
|
69
|
-
return fakePromise(response);
|
70
|
-
}
|
71
53
|
if (globalThis.libcurl) {
|
72
54
|
return fetchCurl(fetchRequest);
|
73
55
|
}
|
package/esm/fetchCurl.js
CHANGED
@@ -53,7 +53,12 @@ export function fetchCurl(fetchRequest) {
|
|
53
53
|
if (fetchRequest['_signal']) {
|
54
54
|
fetchRequest['_signal'].onabort = () => {
|
55
55
|
if (curlHandle.isOpen) {
|
56
|
-
|
56
|
+
try {
|
57
|
+
curlHandle.pause(CurlPause.Recv);
|
58
|
+
}
|
59
|
+
catch (e) {
|
60
|
+
reject(e);
|
61
|
+
}
|
57
62
|
}
|
58
63
|
};
|
59
64
|
}
|
@@ -65,6 +70,9 @@ export function fetchCurl(fetchRequest) {
|
|
65
70
|
streamResolved.destroy(error);
|
66
71
|
}
|
67
72
|
else {
|
73
|
+
if (error.message === 'Operation was aborted by an application callback') {
|
74
|
+
error.message = 'The operation was aborted.';
|
75
|
+
}
|
68
76
|
reject(error);
|
69
77
|
}
|
70
78
|
curlHandle.close();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@whatwg-node/node-fetch",
|
3
|
-
"version": "0.5.10-alpha-
|
3
|
+
"version": "0.5.10-alpha-20240322103629-07f53b56429d0c2dcdb6dcd240226e0f599203e0",
|
4
4
|
"description": "Fetch API implementation for Node",
|
5
5
|
"sideEffects": false,
|
6
6
|
"dependencies": {
|
package/typings/URL.d.cts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="packages/node-fetch/src/declarations.js" />
|
2
2
|
import FastUrl from '@kamilkisiela/fast-url-parser';
|
3
|
-
import { PonyfillBlob } from './Blob.cjs';
|
4
3
|
import { PonyfillURLSearchParams } from './URLSearchParams.cjs';
|
5
4
|
export declare class PonyfillURL extends FastUrl implements URL {
|
6
5
|
constructor(url: string, base?: string | URL);
|
@@ -13,8 +12,4 @@ export declare class PonyfillURL extends FastUrl implements URL {
|
|
13
12
|
set password(value: string);
|
14
13
|
toString(): string;
|
15
14
|
toJSON(): string;
|
16
|
-
private static blobRegistry;
|
17
|
-
static createObjectURL(blob: Blob): string;
|
18
|
-
static resolveObjectURL(url: string): void;
|
19
|
-
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
20
15
|
}
|
package/typings/URL.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
/// <reference types="packages/node-fetch/src/declarations.js" />
|
2
2
|
import FastUrl from '@kamilkisiela/fast-url-parser';
|
3
|
-
import { PonyfillBlob } from './Blob.js';
|
4
3
|
import { PonyfillURLSearchParams } from './URLSearchParams.js';
|
5
4
|
export declare class PonyfillURL extends FastUrl implements URL {
|
6
5
|
constructor(url: string, base?: string | URL);
|
@@ -13,8 +12,4 @@ export declare class PonyfillURL extends FastUrl implements URL {
|
|
13
12
|
set password(value: string);
|
14
13
|
toString(): string;
|
15
14
|
toJSON(): string;
|
16
|
-
private static blobRegistry;
|
17
|
-
static createObjectURL(blob: Blob): string;
|
18
|
-
static resolveObjectURL(url: string): void;
|
19
|
-
static getBlobFromURL(url: string): Blob | PonyfillBlob | undefined;
|
20
15
|
}
|