@remix-run/node 1.7.6 → 1.8.0-pre.0
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/CHANGELOG.md +17 -0
- package/dist/base64.js +1 -1
- package/dist/crypto.js +1 -1
- package/dist/fetch.js +1 -7
- package/dist/globals.js +1 -1
- package/dist/implementations.js +1 -1
- package/dist/index.js +1 -1
- package/dist/magicExports/esm/remix.js +33 -2
- package/dist/magicExports/remix.d.ts +33 -3
- package/dist/magicExports/remix.js +39 -33
- package/dist/sessions/fileStorage.js +5 -15
- package/dist/stream.js +3 -26
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/upload/fileUploadHandler.js +1 -32
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# `@remix-run/node`
|
|
2
2
|
|
|
3
|
+
## 1.8.0-pre.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Importing functions and types from the `remix` package is deprecated, and all ([#3284](https://github.com/remix-run/remix/pull/3284))
|
|
8
|
+
exported modules will be removed in the next major release. For more details,
|
|
9
|
+
[see the release notes for 1.4.0](https://github.com/remix-run/remix/releases/tag/v1.4.0)
|
|
10
|
+
where these changes were first announced.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Update `@remix-run/web-fetch`. This addresses two bugs: ([#4644](https://github.com/remix-run/remix/pull/4644))
|
|
15
|
+
- It fixes a memory leak caused by unregistered listeners
|
|
16
|
+
- It adds support for custom `"credentials"` values (Remix does nothing with these at the moment, but they pass through for the consumer of the request to access if needed)
|
|
17
|
+
- Updated dependencies:
|
|
18
|
+
- `@remix-run/server-runtime@1.8.0-pre.0`
|
|
19
|
+
|
|
3
20
|
## 1.7.6
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/base64.js
CHANGED
package/dist/crypto.js
CHANGED
package/dist/fetch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -19,26 +19,20 @@ class NodeRequest extends webFetch.Request {
|
|
|
19
19
|
constructor(info, init) {
|
|
20
20
|
super(info, init);
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
get headers() {
|
|
24
23
|
return super.headers;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
clone() {
|
|
28
26
|
return super.clone();
|
|
29
27
|
}
|
|
30
|
-
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
class NodeResponse extends webFetch.Response {
|
|
34
30
|
get headers() {
|
|
35
31
|
return super.headers;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
33
|
clone() {
|
|
39
34
|
return super.clone();
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
}
|
|
43
37
|
const fetch = (info, init) => {
|
|
44
38
|
init = {
|
package/dist/globals.js
CHANGED
package/dist/implementations.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,4 +8,35 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
import * as node from '@remix-run/node';
|
|
12
|
+
const getDeprecatedMessage = (symbol, packageName) => `All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${symbol}\` from \`${packageName}\` instead. Run \`npx @remix-run/dev@latest codemod replace-remix-magic-imports\` to automatically migrate your code.`;
|
|
13
|
+
const warn = (fn, message) => (...args) => {
|
|
14
|
+
console.warn(message);
|
|
15
|
+
return fn(...args);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** @deprecated Import `createCookie` from `@remix-run/node` instead. */
|
|
19
|
+
const createCookie = warn(node.createCookie, getDeprecatedMessage('createCookie', '@remix-run/node'));
|
|
20
|
+
|
|
21
|
+
/** @deprecated Import `createCookieSessionStorage` from `@remix-run/node` instead. */
|
|
22
|
+
const createCookieSessionStorage = warn(node.createCookieSessionStorage, getDeprecatedMessage('createCookieSessionStorage', '@remix-run/node'));
|
|
23
|
+
|
|
24
|
+
/** @deprecated Import `createFileSessionStorage` from `@remix-run/node` instead. */
|
|
25
|
+
const createFileSessionStorage = warn(node.createFileSessionStorage, getDeprecatedMessage('createFileSessionStorage', '@remix-run/node'));
|
|
26
|
+
|
|
27
|
+
/** @deprecated Import `createMemorySessionStorage` from `@remix-run/node` instead. */
|
|
28
|
+
const createMemorySessionStorage = warn(node.createMemorySessionStorage, getDeprecatedMessage('createMemorySessionStorage', '@remix-run/node'));
|
|
29
|
+
|
|
30
|
+
/** @deprecated Import `createSessionStorage` from `@remix-run/node` instead. */
|
|
31
|
+
const createSessionStorage = warn(node.createSessionStorage, getDeprecatedMessage('createSessionStorage', '@remix-run/node'));
|
|
32
|
+
|
|
33
|
+
/** @deprecated Import `unstable_createFileUploadHandler` from `@remix-run/node` instead. */
|
|
34
|
+
const unstable_createFileUploadHandler = warn(node.unstable_createFileUploadHandler, getDeprecatedMessage('unstable_createFileUploadHandler', '@remix-run/node'));
|
|
35
|
+
|
|
36
|
+
/** @deprecated Import `unstable_createMemoryUploadHandler` from `@remix-run/node` instead. */
|
|
37
|
+
const unstable_createMemoryUploadHandler = warn(node.unstable_createMemoryUploadHandler, getDeprecatedMessage('unstable_createMemoryUploadHandler', '@remix-run/node'));
|
|
38
|
+
|
|
39
|
+
/** @deprecated Import `unstable_parseMultipartFormData` from `@remix-run/node` instead. */
|
|
40
|
+
const unstable_parseMultipartFormData = warn(node.unstable_parseMultipartFormData, getDeprecatedMessage('unstable_parseMultipartFormData', '@remix-run/node'));
|
|
41
|
+
|
|
42
|
+
export { createCookie, createCookieSessionStorage, createFileSessionStorage, createMemorySessionStorage, createSessionStorage, unstable_createFileUploadHandler, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,5 +8,35 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
import * as node from '@remix-run/node';
|
|
12
|
+
|
|
13
|
+
/** @deprecated Import `createCookie` from `@remix-run/node` instead. */
|
|
14
|
+
export declare const createCookie: typeof node.createCookie;
|
|
15
|
+
|
|
16
|
+
/** @deprecated Import `createCookieSessionStorage` from `@remix-run/node` instead. */
|
|
17
|
+
export declare const createCookieSessionStorage: typeof node.createCookieSessionStorage;
|
|
18
|
+
|
|
19
|
+
/** @deprecated Import `createFileSessionStorage` from `@remix-run/node` instead. */
|
|
20
|
+
export declare const createFileSessionStorage: typeof node.createFileSessionStorage;
|
|
21
|
+
|
|
22
|
+
/** @deprecated Import `createMemorySessionStorage` from `@remix-run/node` instead. */
|
|
23
|
+
export declare const createMemorySessionStorage: typeof node.createMemorySessionStorage;
|
|
24
|
+
|
|
25
|
+
/** @deprecated Import `createSessionStorage` from `@remix-run/node` instead. */
|
|
26
|
+
export declare const createSessionStorage: typeof node.createSessionStorage;
|
|
27
|
+
|
|
28
|
+
/** @deprecated Import `unstable_createFileUploadHandler` from `@remix-run/node` instead. */
|
|
29
|
+
export declare const unstable_createFileUploadHandler: typeof node.unstable_createFileUploadHandler;
|
|
30
|
+
|
|
31
|
+
/** @deprecated Import `unstable_createMemoryUploadHandler` from `@remix-run/node` instead. */
|
|
32
|
+
export declare const unstable_createMemoryUploadHandler: typeof node.unstable_createMemoryUploadHandler;
|
|
33
|
+
|
|
34
|
+
/** @deprecated Import `unstable_parseMultipartFormData` from `@remix-run/node` instead. */
|
|
35
|
+
export declare const unstable_parseMultipartFormData: typeof node.unstable_parseMultipartFormData;
|
|
36
|
+
import * as NodeTypes from '@remix-run/node';
|
|
37
|
+
|
|
38
|
+
/** @deprecated Import type `UploadHandler` from `@remix-run/node` instead. */
|
|
39
|
+
export declare type UploadHandler = NodeTypes.UploadHandler;
|
|
40
|
+
|
|
41
|
+
/** @deprecated Import type `UploadHandlerPart` from `@remix-run/node` instead. */
|
|
42
|
+
export declare type UploadHandlerPart = NodeTypes.UploadHandlerPart;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -10,36 +10,42 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
13
|
+
|
|
13
14
|
var node = require('@remix-run/node');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
15
|
+
const getDeprecatedMessage = (symbol, packageName) => `All \`remix\` exports are considered deprecated as of v1.3.3. Please import \`${symbol}\` from \`${packageName}\` instead. Run \`npx @remix-run/dev@latest codemod replace-remix-magic-imports\` to automatically migrate your code.`;
|
|
16
|
+
const warn = (fn, message) => (...args) => {
|
|
17
|
+
console.warn(message);
|
|
18
|
+
return fn(...args);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @deprecated Import `createCookie` from `@remix-run/node` instead. */
|
|
22
|
+
const createCookie = warn(node.createCookie, getDeprecatedMessage('createCookie', '@remix-run/node'));
|
|
23
|
+
exports.createCookie = createCookie;
|
|
24
|
+
|
|
25
|
+
/** @deprecated Import `createCookieSessionStorage` from `@remix-run/node` instead. */
|
|
26
|
+
const createCookieSessionStorage = warn(node.createCookieSessionStorage, getDeprecatedMessage('createCookieSessionStorage', '@remix-run/node'));
|
|
27
|
+
exports.createCookieSessionStorage = createCookieSessionStorage;
|
|
28
|
+
|
|
29
|
+
/** @deprecated Import `createFileSessionStorage` from `@remix-run/node` instead. */
|
|
30
|
+
const createFileSessionStorage = warn(node.createFileSessionStorage, getDeprecatedMessage('createFileSessionStorage', '@remix-run/node'));
|
|
31
|
+
exports.createFileSessionStorage = createFileSessionStorage;
|
|
32
|
+
|
|
33
|
+
/** @deprecated Import `createMemorySessionStorage` from `@remix-run/node` instead. */
|
|
34
|
+
const createMemorySessionStorage = warn(node.createMemorySessionStorage, getDeprecatedMessage('createMemorySessionStorage', '@remix-run/node'));
|
|
35
|
+
exports.createMemorySessionStorage = createMemorySessionStorage;
|
|
36
|
+
|
|
37
|
+
/** @deprecated Import `createSessionStorage` from `@remix-run/node` instead. */
|
|
38
|
+
const createSessionStorage = warn(node.createSessionStorage, getDeprecatedMessage('createSessionStorage', '@remix-run/node'));
|
|
39
|
+
exports.createSessionStorage = createSessionStorage;
|
|
40
|
+
|
|
41
|
+
/** @deprecated Import `unstable_createFileUploadHandler` from `@remix-run/node` instead. */
|
|
42
|
+
const unstable_createFileUploadHandler = warn(node.unstable_createFileUploadHandler, getDeprecatedMessage('unstable_createFileUploadHandler', '@remix-run/node'));
|
|
43
|
+
exports.unstable_createFileUploadHandler = unstable_createFileUploadHandler;
|
|
44
|
+
|
|
45
|
+
/** @deprecated Import `unstable_createMemoryUploadHandler` from `@remix-run/node` instead. */
|
|
46
|
+
const unstable_createMemoryUploadHandler = warn(node.unstable_createMemoryUploadHandler, getDeprecatedMessage('unstable_createMemoryUploadHandler', '@remix-run/node'));
|
|
47
|
+
exports.unstable_createMemoryUploadHandler = unstable_createMemoryUploadHandler;
|
|
48
|
+
|
|
49
|
+
/** @deprecated Import `unstable_parseMultipartFormData` from `@remix-run/node` instead. */
|
|
50
|
+
const unstable_parseMultipartFormData = warn(node.unstable_parseMultipartFormData, getDeprecatedMessage('unstable_parseMultipartFormData', '@remix-run/node'));
|
|
51
|
+
exports.unstable_parseMultipartFormData = unstable_parseMultipartFormData;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -52,23 +52,20 @@ function createFileSessionStorage({
|
|
|
52
52
|
}) {
|
|
53
53
|
return implementations.createSessionStorage({
|
|
54
54
|
cookie,
|
|
55
|
-
|
|
56
55
|
async createData(data, expires) {
|
|
57
56
|
let content = JSON.stringify({
|
|
58
57
|
data,
|
|
59
58
|
expires
|
|
60
59
|
});
|
|
61
|
-
|
|
62
60
|
while (true) {
|
|
63
61
|
// TODO: Once node v16 is available on AWS we should use the webcrypto
|
|
64
62
|
// API's crypto.getRandomValues() function here instead.
|
|
65
|
-
let randomBytes = crypto__namespace.randomBytes(8);
|
|
63
|
+
let randomBytes = crypto__namespace.randomBytes(8);
|
|
64
|
+
// This storage manages an id space of 2^64 ids, which is far greater
|
|
66
65
|
// than the maximum number of files allowed on an NTFS or ext4 volume
|
|
67
66
|
// (2^32). However, the larger id space should help to avoid collisions
|
|
68
67
|
// with existing ids when creating new sessions, which speeds things up.
|
|
69
|
-
|
|
70
68
|
let id = Buffer.from(randomBytes).toString("hex");
|
|
71
|
-
|
|
72
69
|
try {
|
|
73
70
|
let file = getFile(dir, id);
|
|
74
71
|
await fs.promises.mkdir(path__namespace.dirname(file), {
|
|
@@ -84,19 +81,17 @@ function createFileSessionStorage({
|
|
|
84
81
|
}
|
|
85
82
|
}
|
|
86
83
|
},
|
|
87
|
-
|
|
88
84
|
async readData(id) {
|
|
89
85
|
try {
|
|
90
86
|
let file = getFile(dir, id);
|
|
91
87
|
let content = JSON.parse(await fs.promises.readFile(file, "utf-8"));
|
|
92
88
|
let data = content.data;
|
|
93
89
|
let expires = typeof content.expires === "string" ? new Date(content.expires) : null;
|
|
94
|
-
|
|
95
90
|
if (!expires || expires > new Date()) {
|
|
96
91
|
return data;
|
|
97
|
-
}
|
|
98
|
-
|
|
92
|
+
}
|
|
99
93
|
|
|
94
|
+
// Remove expired session data.
|
|
100
95
|
if (expires) await fs.promises.unlink(file);
|
|
101
96
|
return null;
|
|
102
97
|
} catch (error) {
|
|
@@ -104,7 +99,6 @@ function createFileSessionStorage({
|
|
|
104
99
|
return null;
|
|
105
100
|
}
|
|
106
101
|
},
|
|
107
|
-
|
|
108
102
|
async updateData(id, data, expires) {
|
|
109
103
|
let content = JSON.stringify({
|
|
110
104
|
data,
|
|
@@ -116,24 +110,20 @@ function createFileSessionStorage({
|
|
|
116
110
|
});
|
|
117
111
|
await fs.promises.writeFile(file, content, "utf-8");
|
|
118
112
|
},
|
|
119
|
-
|
|
120
113
|
async deleteData(id) {
|
|
121
114
|
// Return early if the id is empty, otherwise we'll end up trying to
|
|
122
115
|
// unlink the dir, which will cause the EPERM error.
|
|
123
116
|
if (!id) {
|
|
124
117
|
return;
|
|
125
118
|
}
|
|
126
|
-
|
|
127
119
|
try {
|
|
128
120
|
await fs.promises.unlink(getFile(dir, id));
|
|
129
121
|
} catch (error) {
|
|
130
122
|
if (error.code !== "ENOENT") throw error;
|
|
131
123
|
}
|
|
132
124
|
}
|
|
133
|
-
|
|
134
125
|
});
|
|
135
126
|
}
|
|
136
|
-
|
|
137
127
|
function getFile(dir, id) {
|
|
138
128
|
// Divide the session id up into a directory (first 2 bytes) and filename
|
|
139
129
|
// (remaining 6 bytes) to reduce the chance of having very large directories,
|
package/dist/stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/node v1.
|
|
2
|
+
* @remix-run/node v1.8.0-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -16,29 +16,24 @@ var stream = require('stream');
|
|
|
16
16
|
|
|
17
17
|
async function writeReadableStreamToWritable(stream, writable) {
|
|
18
18
|
let reader = stream.getReader();
|
|
19
|
-
|
|
20
19
|
async function read() {
|
|
21
20
|
let {
|
|
22
21
|
done,
|
|
23
22
|
value
|
|
24
23
|
} = await reader.read();
|
|
25
|
-
|
|
26
24
|
if (done) {
|
|
27
25
|
writable.end();
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
28
|
+
writable.write(value);
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// If the stream is flushable, flush it to allow streaming to continue.
|
|
33
31
|
let flushable = writable;
|
|
34
|
-
|
|
35
32
|
if (typeof flushable.flush === "function") {
|
|
36
33
|
flushable.flush();
|
|
37
34
|
}
|
|
38
|
-
|
|
39
35
|
await read();
|
|
40
36
|
}
|
|
41
|
-
|
|
42
37
|
try {
|
|
43
38
|
await read();
|
|
44
39
|
} catch (error) {
|
|
@@ -51,7 +46,6 @@ async function writeAsyncIterableToWritable(iterable, writable) {
|
|
|
51
46
|
for await (let chunk of iterable) {
|
|
52
47
|
writable.write(chunk);
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
writable.end();
|
|
56
50
|
} catch (error) {
|
|
57
51
|
writable.destroy(error);
|
|
@@ -61,22 +55,18 @@ async function writeAsyncIterableToWritable(iterable, writable) {
|
|
|
61
55
|
async function readableStreamToString(stream, encoding) {
|
|
62
56
|
let reader = stream.getReader();
|
|
63
57
|
let chunks = [];
|
|
64
|
-
|
|
65
58
|
async function read() {
|
|
66
59
|
let {
|
|
67
60
|
done,
|
|
68
61
|
value
|
|
69
62
|
} = await reader.read();
|
|
70
|
-
|
|
71
63
|
if (done) {
|
|
72
64
|
return;
|
|
73
65
|
} else if (value) {
|
|
74
66
|
chunks.push(value);
|
|
75
67
|
}
|
|
76
|
-
|
|
77
68
|
await read();
|
|
78
69
|
}
|
|
79
|
-
|
|
80
70
|
await read();
|
|
81
71
|
return Buffer.concat(chunks).toString(encoding);
|
|
82
72
|
}
|
|
@@ -85,7 +75,6 @@ const createReadableStreamFromReadable = source => {
|
|
|
85
75
|
let stream = new ReadableStream(pump, pump);
|
|
86
76
|
return stream;
|
|
87
77
|
};
|
|
88
|
-
|
|
89
78
|
class StreamPump {
|
|
90
79
|
constructor(stream$1) {
|
|
91
80
|
this.highWaterMark = stream$1.readableHighWaterMark || new stream.Stream.Readable().readableHighWaterMark;
|
|
@@ -95,11 +84,9 @@ class StreamPump {
|
|
|
95
84
|
this.error = this.error.bind(this);
|
|
96
85
|
this.close = this.close.bind(this);
|
|
97
86
|
}
|
|
98
|
-
|
|
99
87
|
size(chunk) {
|
|
100
88
|
return (chunk === null || chunk === void 0 ? void 0 : chunk.byteLength) || 0;
|
|
101
89
|
}
|
|
102
|
-
|
|
103
90
|
start(controller) {
|
|
104
91
|
this.controller = controller;
|
|
105
92
|
this.stream.on("data", this.enqueue);
|
|
@@ -107,29 +94,24 @@ class StreamPump {
|
|
|
107
94
|
this.stream.once("end", this.close);
|
|
108
95
|
this.stream.once("close", this.close);
|
|
109
96
|
}
|
|
110
|
-
|
|
111
97
|
pull() {
|
|
112
98
|
this.resume();
|
|
113
99
|
}
|
|
114
|
-
|
|
115
100
|
cancel(reason) {
|
|
116
101
|
if (this.stream.destroy) {
|
|
117
102
|
this.stream.destroy(reason);
|
|
118
103
|
}
|
|
119
|
-
|
|
120
104
|
this.stream.off("data", this.enqueue);
|
|
121
105
|
this.stream.off("error", this.error);
|
|
122
106
|
this.stream.off("end", this.close);
|
|
123
107
|
this.stream.off("close", this.close);
|
|
124
108
|
}
|
|
125
|
-
|
|
126
109
|
enqueue(chunk) {
|
|
127
110
|
if (this.controller) {
|
|
128
111
|
try {
|
|
129
112
|
let bytes = chunk instanceof Uint8Array ? chunk : Buffer.from(chunk);
|
|
130
113
|
let available = (this.controller.desiredSize || 0) - bytes.byteLength;
|
|
131
114
|
this.controller.enqueue(bytes);
|
|
132
|
-
|
|
133
115
|
if (available <= 0) {
|
|
134
116
|
this.pause();
|
|
135
117
|
}
|
|
@@ -139,33 +121,28 @@ class StreamPump {
|
|
|
139
121
|
}
|
|
140
122
|
}
|
|
141
123
|
}
|
|
142
|
-
|
|
143
124
|
pause() {
|
|
144
125
|
if (this.stream.pause) {
|
|
145
126
|
this.stream.pause();
|
|
146
127
|
}
|
|
147
128
|
}
|
|
148
|
-
|
|
149
129
|
resume() {
|
|
150
130
|
if (this.stream.readable && this.stream.resume) {
|
|
151
131
|
this.stream.resume();
|
|
152
132
|
}
|
|
153
133
|
}
|
|
154
|
-
|
|
155
134
|
close() {
|
|
156
135
|
if (this.controller) {
|
|
157
136
|
this.controller.close();
|
|
158
137
|
delete this.controller;
|
|
159
138
|
}
|
|
160
139
|
}
|
|
161
|
-
|
|
162
140
|
error(error) {
|
|
163
141
|
if (this.controller) {
|
|
164
142
|
this.controller.error(error);
|
|
165
143
|
delete this.controller;
|
|
166
144
|
}
|
|
167
145
|
}
|
|
168
|
-
|
|
169
146
|
}
|
|
170
147
|
|
|
171
148
|
exports.createReadableStreamFromReadable = createReadableStreamFromReadable;
|