@whatwg-node/node-fetch 0.8.2 → 0.8.3-alpha-20251110161950-a399c572806c26a67ae5f1b3dbb21cac7461155a
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/CompressionStream.js +10 -6
- package/cjs/DecompressionStream.js +10 -6
- package/cjs/fetchNodeHttp.js +9 -5
- package/esm/CompressionStream.js +9 -6
- package/esm/DecompressionStream.js +9 -6
- package/esm/fetchNodeHttp.js +8 -5
- package/package.json +1 -1
- package/typings/CompressionStream.d.cts +1 -1
- package/typings/CompressionStream.d.ts +1 -1
package/cjs/CompressionStream.js
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PonyfillCompressionStream = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_zlib_1 = tslib_1.__importDefault(require("node:zlib"));
|
|
5
6
|
const TransformStream_js_1 = require("./TransformStream.js");
|
|
6
7
|
class PonyfillCompressionStream extends TransformStream_js_1.PonyfillTransformStream {
|
|
7
8
|
static supportedFormats = globalThis.process?.version?.startsWith('v2')
|
|
8
|
-
? ['gzip', 'deflate', 'br']
|
|
9
|
+
? ['gzip', 'deflate', 'br', 'zstd']
|
|
9
10
|
: ['gzip', 'deflate', 'deflate-raw', 'br'];
|
|
10
11
|
constructor(compressionFormat) {
|
|
11
12
|
switch (compressionFormat) {
|
|
12
13
|
case 'x-gzip':
|
|
13
14
|
case 'gzip':
|
|
14
|
-
super(
|
|
15
|
+
super(node_zlib_1.default.createGzip());
|
|
15
16
|
break;
|
|
16
17
|
case 'x-deflate':
|
|
17
18
|
case 'deflate':
|
|
18
|
-
super(
|
|
19
|
+
super(node_zlib_1.default.createDeflate());
|
|
19
20
|
break;
|
|
20
21
|
case 'deflate-raw':
|
|
21
|
-
super(
|
|
22
|
+
super(node_zlib_1.default.createDeflateRaw());
|
|
22
23
|
break;
|
|
23
24
|
case 'br':
|
|
24
|
-
super(
|
|
25
|
+
super(node_zlib_1.default.createBrotliCompress());
|
|
26
|
+
break;
|
|
27
|
+
case 'zstd':
|
|
28
|
+
super(node_zlib_1.default.createZstdCompress());
|
|
25
29
|
break;
|
|
26
30
|
default:
|
|
27
31
|
throw new Error(`Unsupported compression format: ${compressionFormat}`);
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PonyfillDecompressionStream = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const node_zlib_1 = tslib_1.__importDefault(require("node:zlib"));
|
|
5
6
|
const TransformStream_js_1 = require("./TransformStream.js");
|
|
6
7
|
class PonyfillDecompressionStream extends TransformStream_js_1.PonyfillTransformStream {
|
|
7
8
|
static supportedFormats = globalThis.process?.version?.startsWith('v2')
|
|
8
|
-
? ['gzip', 'deflate', 'br']
|
|
9
|
+
? ['gzip', 'deflate', 'br', 'zstd']
|
|
9
10
|
: ['gzip', 'deflate', 'deflate-raw', 'br'];
|
|
10
11
|
constructor(compressionFormat) {
|
|
11
12
|
switch (compressionFormat) {
|
|
12
13
|
case 'x-gzip':
|
|
13
14
|
case 'gzip':
|
|
14
|
-
super(
|
|
15
|
+
super(node_zlib_1.default.createGunzip());
|
|
15
16
|
break;
|
|
16
17
|
case 'x-deflate':
|
|
17
18
|
case 'deflate':
|
|
18
|
-
super(
|
|
19
|
+
super(node_zlib_1.default.createInflate());
|
|
19
20
|
break;
|
|
20
21
|
case 'deflate-raw':
|
|
21
|
-
super(
|
|
22
|
+
super(node_zlib_1.default.createInflateRaw());
|
|
22
23
|
break;
|
|
23
24
|
case 'br':
|
|
24
|
-
super(
|
|
25
|
+
super(node_zlib_1.default.createBrotliDecompress());
|
|
26
|
+
break;
|
|
27
|
+
case 'zstd':
|
|
28
|
+
super(node_zlib_1.default.createZstdDecompress());
|
|
25
29
|
break;
|
|
26
30
|
default:
|
|
27
31
|
throw new TypeError(`Unsupported compression format: '${compressionFormat}'`);
|
package/cjs/fetchNodeHttp.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchNodeHttp = fetchNodeHttp;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const node_http_1 = require("node:http");
|
|
5
6
|
const node_https_1 = require("node:https");
|
|
6
7
|
const node_stream_1 = require("node:stream");
|
|
7
|
-
const node_zlib_1 = require("node:zlib");
|
|
8
|
+
const node_zlib_1 = tslib_1.__importDefault(require("node:zlib"));
|
|
8
9
|
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
9
10
|
const Request_js_1 = require("./Request.js");
|
|
10
11
|
const Response_js_1 = require("./Response.js");
|
|
@@ -61,18 +62,21 @@ function fetchNodeHttp(fetchRequest) {
|
|
|
61
62
|
switch (contentEncoding) {
|
|
62
63
|
case 'x-gzip':
|
|
63
64
|
case 'gzip':
|
|
64
|
-
outputStream =
|
|
65
|
+
outputStream = node_zlib_1.default.createGunzip();
|
|
65
66
|
break;
|
|
66
67
|
case 'x-deflate':
|
|
67
68
|
case 'deflate':
|
|
68
|
-
outputStream =
|
|
69
|
+
outputStream = node_zlib_1.default.createInflate();
|
|
69
70
|
break;
|
|
70
71
|
case 'x-deflate-raw':
|
|
71
72
|
case 'deflate-raw':
|
|
72
|
-
outputStream =
|
|
73
|
+
outputStream = node_zlib_1.default.createInflateRaw();
|
|
73
74
|
break;
|
|
74
75
|
case 'br':
|
|
75
|
-
outputStream =
|
|
76
|
+
outputStream = node_zlib_1.default.createBrotliDecompress();
|
|
77
|
+
break;
|
|
78
|
+
case 'zstd':
|
|
79
|
+
outputStream = node_zlib_1.default.createZstdDecompress();
|
|
76
80
|
break;
|
|
77
81
|
}
|
|
78
82
|
if (nodeResponse.headers.location && (0, utils_js_1.shouldRedirect)(nodeResponse.statusCode)) {
|
package/esm/CompressionStream.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import zlib from 'node:zlib';
|
|
2
2
|
import { PonyfillTransformStream } from './TransformStream.js';
|
|
3
3
|
export class PonyfillCompressionStream extends PonyfillTransformStream {
|
|
4
4
|
static supportedFormats = globalThis.process?.version?.startsWith('v2')
|
|
5
|
-
? ['gzip', 'deflate', 'br']
|
|
5
|
+
? ['gzip', 'deflate', 'br', 'zstd']
|
|
6
6
|
: ['gzip', 'deflate', 'deflate-raw', 'br'];
|
|
7
7
|
constructor(compressionFormat) {
|
|
8
8
|
switch (compressionFormat) {
|
|
9
9
|
case 'x-gzip':
|
|
10
10
|
case 'gzip':
|
|
11
|
-
super(createGzip());
|
|
11
|
+
super(zlib.createGzip());
|
|
12
12
|
break;
|
|
13
13
|
case 'x-deflate':
|
|
14
14
|
case 'deflate':
|
|
15
|
-
super(createDeflate());
|
|
15
|
+
super(zlib.createDeflate());
|
|
16
16
|
break;
|
|
17
17
|
case 'deflate-raw':
|
|
18
|
-
super(createDeflateRaw());
|
|
18
|
+
super(zlib.createDeflateRaw());
|
|
19
19
|
break;
|
|
20
20
|
case 'br':
|
|
21
|
-
super(createBrotliCompress());
|
|
21
|
+
super(zlib.createBrotliCompress());
|
|
22
|
+
break;
|
|
23
|
+
case 'zstd':
|
|
24
|
+
super(zlib.createZstdCompress());
|
|
22
25
|
break;
|
|
23
26
|
default:
|
|
24
27
|
throw new Error(`Unsupported compression format: ${compressionFormat}`);
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import zlib from 'node:zlib';
|
|
2
2
|
import { PonyfillTransformStream } from './TransformStream.js';
|
|
3
3
|
export class PonyfillDecompressionStream extends PonyfillTransformStream {
|
|
4
4
|
static supportedFormats = globalThis.process?.version?.startsWith('v2')
|
|
5
|
-
? ['gzip', 'deflate', 'br']
|
|
5
|
+
? ['gzip', 'deflate', 'br', 'zstd']
|
|
6
6
|
: ['gzip', 'deflate', 'deflate-raw', 'br'];
|
|
7
7
|
constructor(compressionFormat) {
|
|
8
8
|
switch (compressionFormat) {
|
|
9
9
|
case 'x-gzip':
|
|
10
10
|
case 'gzip':
|
|
11
|
-
super(createGunzip());
|
|
11
|
+
super(zlib.createGunzip());
|
|
12
12
|
break;
|
|
13
13
|
case 'x-deflate':
|
|
14
14
|
case 'deflate':
|
|
15
|
-
super(createInflate());
|
|
15
|
+
super(zlib.createInflate());
|
|
16
16
|
break;
|
|
17
17
|
case 'deflate-raw':
|
|
18
|
-
super(createInflateRaw());
|
|
18
|
+
super(zlib.createInflateRaw());
|
|
19
19
|
break;
|
|
20
20
|
case 'br':
|
|
21
|
-
super(createBrotliDecompress());
|
|
21
|
+
super(zlib.createBrotliDecompress());
|
|
22
|
+
break;
|
|
23
|
+
case 'zstd':
|
|
24
|
+
super(zlib.createZstdDecompress());
|
|
22
25
|
break;
|
|
23
26
|
default:
|
|
24
27
|
throw new TypeError(`Unsupported compression format: '${compressionFormat}'`);
|
package/esm/fetchNodeHttp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { request as httpRequest, STATUS_CODES } from 'node:http';
|
|
2
2
|
import { request as httpsRequest } from 'node:https';
|
|
3
3
|
import { PassThrough, Readable } from 'node:stream';
|
|
4
|
-
import
|
|
4
|
+
import zlib from 'node:zlib';
|
|
5
5
|
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
6
6
|
import { PonyfillRequest } from './Request.js';
|
|
7
7
|
import { PonyfillResponse } from './Response.js';
|
|
@@ -58,18 +58,21 @@ export function fetchNodeHttp(fetchRequest) {
|
|
|
58
58
|
switch (contentEncoding) {
|
|
59
59
|
case 'x-gzip':
|
|
60
60
|
case 'gzip':
|
|
61
|
-
outputStream = createGunzip();
|
|
61
|
+
outputStream = zlib.createGunzip();
|
|
62
62
|
break;
|
|
63
63
|
case 'x-deflate':
|
|
64
64
|
case 'deflate':
|
|
65
|
-
outputStream = createInflate();
|
|
65
|
+
outputStream = zlib.createInflate();
|
|
66
66
|
break;
|
|
67
67
|
case 'x-deflate-raw':
|
|
68
68
|
case 'deflate-raw':
|
|
69
|
-
outputStream = createInflateRaw();
|
|
69
|
+
outputStream = zlib.createInflateRaw();
|
|
70
70
|
break;
|
|
71
71
|
case 'br':
|
|
72
|
-
outputStream = createBrotliDecompress();
|
|
72
|
+
outputStream = zlib.createBrotliDecompress();
|
|
73
|
+
break;
|
|
74
|
+
case 'zstd':
|
|
75
|
+
outputStream = zlib.createZstdDecompress();
|
|
73
76
|
break;
|
|
74
77
|
}
|
|
75
78
|
if (nodeResponse.headers.location && shouldRedirect(nodeResponse.statusCode)) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PonyfillTransformStream } from './TransformStream.cjs';
|
|
2
|
-
export type PonyfillCompressionFormat = 'x-gzip' | 'gzip' | 'x-deflate' | 'deflate' | 'deflate-raw' | 'br';
|
|
2
|
+
export type PonyfillCompressionFormat = 'x-gzip' | 'gzip' | 'x-deflate' | 'deflate' | 'deflate-raw' | 'br' | 'zstd';
|
|
3
3
|
export declare class PonyfillCompressionStream extends PonyfillTransformStream implements CompressionStream {
|
|
4
4
|
static supportedFormats: PonyfillCompressionFormat[];
|
|
5
5
|
constructor(compressionFormat: PonyfillCompressionFormat);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PonyfillTransformStream } from './TransformStream.js';
|
|
2
|
-
export type PonyfillCompressionFormat = 'x-gzip' | 'gzip' | 'x-deflate' | 'deflate' | 'deflate-raw' | 'br';
|
|
2
|
+
export type PonyfillCompressionFormat = 'x-gzip' | 'gzip' | 'x-deflate' | 'deflate' | 'deflate-raw' | 'br' | 'zstd';
|
|
3
3
|
export declare class PonyfillCompressionStream extends PonyfillTransformStream implements CompressionStream {
|
|
4
4
|
static supportedFormats: PonyfillCompressionFormat[];
|
|
5
5
|
constructor(compressionFormat: PonyfillCompressionFormat);
|