@shopify/create-app 3.65.2 → 3.66.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/dist/chunk-2RSJVBMF.js +5625 -0
- package/dist/{chunk-Z65QJ5D7.js → chunk-4DRC2PSU.js} +17 -30
- package/dist/chunk-4OD45DDO.js +31508 -0
- package/dist/chunk-522OB3EU.js +45 -0
- package/dist/{chunk-JTKTLA7L.js → chunk-5U24TEX5.js} +5434 -10324
- package/dist/{chunk-GJPZCXGT.js → chunk-6A7MXLVB.js} +159 -405
- package/dist/{chunk-ZYKRTO5P.js → chunk-7ZCQLP5Y.js} +3 -3
- package/dist/{chunk-5LBEKXRW.js → chunk-FIJKOZJF.js} +19 -55
- package/dist/{chunk-QSKQTKTB.js → chunk-FT6PCF6E.js} +2441 -5551
- package/dist/chunk-GIUM5DCQ.js +2144 -0
- package/dist/chunk-HIAKHDLR.js +54 -0
- package/dist/chunk-LLSRDN3T.js +15352 -0
- package/dist/chunk-LTDD2GRL.js +111 -0
- package/dist/{chunk-63QVG2CD.js → chunk-NGBYQF44.js} +9 -9
- package/dist/chunk-NLC7NBUB.js +80 -0
- package/dist/{chunk-FMKVOTQK.js → chunk-O5K4AU7Q.js} +18 -34
- package/dist/chunk-OMDEA7TV.js +10615 -0
- package/dist/chunk-PNN7RS7Y.js +105 -0
- package/dist/{chunk-ZPL24Y2D.js → chunk-POZ5MGPT.js} +13 -18
- package/dist/chunk-T7T35H4F.js +108 -0
- package/dist/chunk-UBB7JKND.js +55 -0
- package/dist/chunk-VSLR7ET4.js +3034 -0
- package/dist/{chunk-SAO7C4LP.js → chunk-VZVGAREJ.js} +46821 -101962
- package/dist/{chunk-KDNBKIH4.js → chunk-WBQF4CSV.js} +12 -22
- package/dist/chunk-XVNW332R.js +524 -0
- package/dist/{chunk-YB6D4XQ7.js → chunk-Y4ECGRAF.js} +13 -23
- package/dist/chunk-ZAUZQLNO.js +3774 -0
- package/dist/chunk-ZULFH3SL.js +1847 -0
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +27 -27
- package/dist/commands/init.test.js +51 -70
- package/dist/{constants-24TFXZKQ.js → constants-WG7I7G3O.js} +5 -5
- package/dist/custom-oclif-loader-JKRJZ56E.js +47 -0
- package/dist/del-NW5KFKFP.js +1820 -0
- package/dist/devtools-UBOREV57.js +2572 -0
- package/dist/error-handler-26SLAJTC.js +35 -0
- package/dist/hooks/postrun.js +35 -42
- package/dist/hooks/prerun.js +58 -36
- package/dist/index.js +7 -7
- package/dist/lib-3K5QYF3J.js +9 -0
- package/dist/{local-3VUKCW4R.js → local-H6TW5MNX.js} +13 -13
- package/dist/magic-string.es-3RXPUXZF.js +843 -0
- package/dist/multipart-parser-QKUAJJP5.js +193 -0
- package/dist/{node-package-manager-HYZRZNU6.js → node-package-manager-QAUN6HGS.js} +16 -14
- package/dist/open-MZGVNFZO.js +197 -0
- package/dist/out-KDGAD475.js +6 -0
- package/dist/{path-CFPIDSWV.js → path-L375JOQ2.js} +4 -4
- package/dist/prompts/init.js +13 -13
- package/dist/prompts/init.test.js +42 -59
- package/dist/services/init.js +20 -20
- package/dist/services/init.test.js +5 -5
- package/dist/system-ZI2HKAKO.js +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/{ui-7NEDEALP.js → ui-727JEZUX.js} +13 -13
- package/dist/utils/template/cleanup.js +13 -13
- package/dist/utils/template/cleanup.test.js +18 -30
- package/dist/utils/template/npm.js +15 -15
- package/dist/utils/template/npm.test.js +48 -87
- package/oclif.manifest.json +1 -1
- package/package.json +3 -4
- package/dist/chunk-3US34ZNP.js +0 -145
- package/dist/chunk-3XYIOBQ2.js +0 -22131
- package/dist/chunk-6IZMEXPW.js +0 -105
- package/dist/chunk-7DRS5WXI.js +0 -7843
- package/dist/chunk-DL3MKXVR.js +0 -4754
- package/dist/chunk-HDVJ5FPK.js +0 -63
- package/dist/chunk-IKO7JBOJ.js +0 -14788
- package/dist/chunk-LSCXQWNO.js +0 -822
- package/dist/chunk-M2VKB6RG.js +0 -146
- package/dist/chunk-MCED27CG.js +0 -5626
- package/dist/chunk-SWNRLCC6.js +0 -61
- package/dist/chunk-T5LLJYYS.js +0 -195
- package/dist/chunk-U5LTJVWL.js +0 -3185
- package/dist/chunk-WR7YKB6H.js +0 -44962
- package/dist/chunk-YC4FLMDD.js +0 -74
- package/dist/chunk-ZRUHMMSQ.js +0 -2477
- package/dist/custom-oclif-loader-5KBN3RSN.js +0 -83
- package/dist/del-ZCPTGWOA.js +0 -2847
- package/dist/devtools-5N4JAP3R.js +0 -3588
- package/dist/error-handler-GTW2KSRC.js +0 -35
- package/dist/lib-CTSCLPNV.js +0 -9
- package/dist/magic-string.es-ATGURXGQ.js +0 -1353
- package/dist/multipart-parser-KYOHF24X.js +0 -360
- package/dist/open-JRS7RW22.js +0 -291
- package/dist/out-OKI3G7I5.js +0 -6
- package/dist/system-4S4YXUXZ.js +0 -26
|
@@ -0,0 +1,3034 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__commonJS,
|
|
3
|
+
__require,
|
|
4
|
+
__toESM,
|
|
5
|
+
init_cjs_shims
|
|
6
|
+
} from "./chunk-POZ5MGPT.js";
|
|
7
|
+
|
|
8
|
+
// ../../node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
|
|
9
|
+
var require_ponyfill_es2018 = __commonJS({
|
|
10
|
+
"../../node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports, module) {
|
|
11
|
+
init_cjs_shims();
|
|
12
|
+
(function(global2, factory) {
|
|
13
|
+
typeof exports == "object" && typeof module < "u" ? factory(exports) : typeof define == "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis < "u" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
|
|
14
|
+
})(exports, function(exports2) {
|
|
15
|
+
"use strict";
|
|
16
|
+
function noop() {
|
|
17
|
+
}
|
|
18
|
+
function typeIsObject(x2) {
|
|
19
|
+
return typeof x2 == "object" && x2 !== null || typeof x2 == "function";
|
|
20
|
+
}
|
|
21
|
+
let rethrowAssertionErrorRejection = noop;
|
|
22
|
+
function setFunctionName(fn, name) {
|
|
23
|
+
try {
|
|
24
|
+
Object.defineProperty(fn, "name", {
|
|
25
|
+
value: name,
|
|
26
|
+
configurable: !0
|
|
27
|
+
});
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
let originalPromise = Promise, originalPromiseThen = Promise.prototype.then, originalPromiseReject = Promise.reject.bind(originalPromise);
|
|
32
|
+
function newPromise(executor) {
|
|
33
|
+
return new originalPromise(executor);
|
|
34
|
+
}
|
|
35
|
+
function promiseResolvedWith(value) {
|
|
36
|
+
return newPromise((resolve) => resolve(value));
|
|
37
|
+
}
|
|
38
|
+
function promiseRejectedWith(reason) {
|
|
39
|
+
return originalPromiseReject(reason);
|
|
40
|
+
}
|
|
41
|
+
function PerformPromiseThen(promise, onFulfilled, onRejected) {
|
|
42
|
+
return originalPromiseThen.call(promise, onFulfilled, onRejected);
|
|
43
|
+
}
|
|
44
|
+
function uponPromise(promise, onFulfilled, onRejected) {
|
|
45
|
+
PerformPromiseThen(PerformPromiseThen(promise, onFulfilled, onRejected), void 0, rethrowAssertionErrorRejection);
|
|
46
|
+
}
|
|
47
|
+
function uponFulfillment(promise, onFulfilled) {
|
|
48
|
+
uponPromise(promise, onFulfilled);
|
|
49
|
+
}
|
|
50
|
+
function uponRejection(promise, onRejected) {
|
|
51
|
+
uponPromise(promise, void 0, onRejected);
|
|
52
|
+
}
|
|
53
|
+
function transformPromiseWith(promise, fulfillmentHandler, rejectionHandler) {
|
|
54
|
+
return PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler);
|
|
55
|
+
}
|
|
56
|
+
function setPromiseIsHandledToTrue(promise) {
|
|
57
|
+
PerformPromiseThen(promise, void 0, rethrowAssertionErrorRejection);
|
|
58
|
+
}
|
|
59
|
+
let _queueMicrotask = (callback) => {
|
|
60
|
+
if (typeof queueMicrotask == "function")
|
|
61
|
+
_queueMicrotask = queueMicrotask;
|
|
62
|
+
else {
|
|
63
|
+
let resolvedPromise = promiseResolvedWith(void 0);
|
|
64
|
+
_queueMicrotask = (cb) => PerformPromiseThen(resolvedPromise, cb);
|
|
65
|
+
}
|
|
66
|
+
return _queueMicrotask(callback);
|
|
67
|
+
};
|
|
68
|
+
function reflectCall(F, V, args) {
|
|
69
|
+
if (typeof F != "function")
|
|
70
|
+
throw new TypeError("Argument is not a function");
|
|
71
|
+
return Function.prototype.apply.call(F, V, args);
|
|
72
|
+
}
|
|
73
|
+
function promiseCall(F, V, args) {
|
|
74
|
+
try {
|
|
75
|
+
return promiseResolvedWith(reflectCall(F, V, args));
|
|
76
|
+
} catch (value) {
|
|
77
|
+
return promiseRejectedWith(value);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
let QUEUE_MAX_ARRAY_SIZE = 16384;
|
|
81
|
+
class SimpleQueue {
|
|
82
|
+
constructor() {
|
|
83
|
+
this._cursor = 0, this._size = 0, this._front = {
|
|
84
|
+
_elements: [],
|
|
85
|
+
_next: void 0
|
|
86
|
+
}, this._back = this._front, this._cursor = 0, this._size = 0;
|
|
87
|
+
}
|
|
88
|
+
get length() {
|
|
89
|
+
return this._size;
|
|
90
|
+
}
|
|
91
|
+
// For exception safety, this method is structured in order:
|
|
92
|
+
// 1. Read state
|
|
93
|
+
// 2. Calculate required state mutations
|
|
94
|
+
// 3. Perform state mutations
|
|
95
|
+
push(element) {
|
|
96
|
+
let oldBack = this._back, newBack = oldBack;
|
|
97
|
+
oldBack._elements.length === QUEUE_MAX_ARRAY_SIZE - 1 && (newBack = {
|
|
98
|
+
_elements: [],
|
|
99
|
+
_next: void 0
|
|
100
|
+
}), oldBack._elements.push(element), newBack !== oldBack && (this._back = newBack, oldBack._next = newBack), ++this._size;
|
|
101
|
+
}
|
|
102
|
+
// Like push(), shift() follows the read -> calculate -> mutate pattern for
|
|
103
|
+
// exception safety.
|
|
104
|
+
shift() {
|
|
105
|
+
let oldFront = this._front, newFront = oldFront, oldCursor = this._cursor, newCursor = oldCursor + 1, elements = oldFront._elements, element = elements[oldCursor];
|
|
106
|
+
return newCursor === QUEUE_MAX_ARRAY_SIZE && (newFront = oldFront._next, newCursor = 0), --this._size, this._cursor = newCursor, oldFront !== newFront && (this._front = newFront), elements[oldCursor] = void 0, element;
|
|
107
|
+
}
|
|
108
|
+
// The tricky thing about forEach() is that it can be called
|
|
109
|
+
// re-entrantly. The queue may be mutated inside the callback. It is easy to
|
|
110
|
+
// see that push() within the callback has no negative effects since the end
|
|
111
|
+
// of the queue is checked for on every iteration. If shift() is called
|
|
112
|
+
// repeatedly within the callback then the next iteration may return an
|
|
113
|
+
// element that has been removed. In this case the callback will be called
|
|
114
|
+
// with undefined values until we either "catch up" with elements that still
|
|
115
|
+
// exist or reach the back of the queue.
|
|
116
|
+
forEach(callback) {
|
|
117
|
+
let i2 = this._cursor, node = this._front, elements = node._elements;
|
|
118
|
+
for (; (i2 !== elements.length || node._next !== void 0) && !(i2 === elements.length && (node = node._next, elements = node._elements, i2 = 0, elements.length === 0)); )
|
|
119
|
+
callback(elements[i2]), ++i2;
|
|
120
|
+
}
|
|
121
|
+
// Return the element that would be returned if shift() was called now,
|
|
122
|
+
// without modifying the queue.
|
|
123
|
+
peek() {
|
|
124
|
+
let front = this._front, cursor = this._cursor;
|
|
125
|
+
return front._elements[cursor];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
let AbortSteps = Symbol("[[AbortSteps]]"), ErrorSteps = Symbol("[[ErrorSteps]]"), CancelSteps = Symbol("[[CancelSteps]]"), PullSteps = Symbol("[[PullSteps]]"), ReleaseSteps = Symbol("[[ReleaseSteps]]");
|
|
129
|
+
function ReadableStreamReaderGenericInitialize(reader, stream) {
|
|
130
|
+
reader._ownerReadableStream = stream, stream._reader = reader, stream._state === "readable" ? defaultReaderClosedPromiseInitialize(reader) : stream._state === "closed" ? defaultReaderClosedPromiseInitializeAsResolved(reader) : defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError);
|
|
131
|
+
}
|
|
132
|
+
function ReadableStreamReaderGenericCancel(reader, reason) {
|
|
133
|
+
let stream = reader._ownerReadableStream;
|
|
134
|
+
return ReadableStreamCancel(stream, reason);
|
|
135
|
+
}
|
|
136
|
+
function ReadableStreamReaderGenericRelease(reader) {
|
|
137
|
+
let stream = reader._ownerReadableStream;
|
|
138
|
+
stream._state === "readable" ? defaultReaderClosedPromiseReject(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : defaultReaderClosedPromiseResetToRejected(reader, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), stream._readableStreamController[ReleaseSteps](), stream._reader = void 0, reader._ownerReadableStream = void 0;
|
|
139
|
+
}
|
|
140
|
+
function readerLockException(name) {
|
|
141
|
+
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
142
|
+
}
|
|
143
|
+
function defaultReaderClosedPromiseInitialize(reader) {
|
|
144
|
+
reader._closedPromise = newPromise((resolve, reject) => {
|
|
145
|
+
reader._closedPromise_resolve = resolve, reader._closedPromise_reject = reject;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) {
|
|
149
|
+
defaultReaderClosedPromiseInitialize(reader), defaultReaderClosedPromiseReject(reader, reason);
|
|
150
|
+
}
|
|
151
|
+
function defaultReaderClosedPromiseInitializeAsResolved(reader) {
|
|
152
|
+
defaultReaderClosedPromiseInitialize(reader), defaultReaderClosedPromiseResolve(reader);
|
|
153
|
+
}
|
|
154
|
+
function defaultReaderClosedPromiseReject(reader, reason) {
|
|
155
|
+
reader._closedPromise_reject !== void 0 && (setPromiseIsHandledToTrue(reader._closedPromise), reader._closedPromise_reject(reason), reader._closedPromise_resolve = void 0, reader._closedPromise_reject = void 0);
|
|
156
|
+
}
|
|
157
|
+
function defaultReaderClosedPromiseResetToRejected(reader, reason) {
|
|
158
|
+
defaultReaderClosedPromiseInitializeAsRejected(reader, reason);
|
|
159
|
+
}
|
|
160
|
+
function defaultReaderClosedPromiseResolve(reader) {
|
|
161
|
+
reader._closedPromise_resolve !== void 0 && (reader._closedPromise_resolve(void 0), reader._closedPromise_resolve = void 0, reader._closedPromise_reject = void 0);
|
|
162
|
+
}
|
|
163
|
+
let NumberIsFinite = Number.isFinite || function(x2) {
|
|
164
|
+
return typeof x2 == "number" && isFinite(x2);
|
|
165
|
+
}, MathTrunc = Math.trunc || function(v) {
|
|
166
|
+
return v < 0 ? Math.ceil(v) : Math.floor(v);
|
|
167
|
+
};
|
|
168
|
+
function isDictionary(x2) {
|
|
169
|
+
return typeof x2 == "object" || typeof x2 == "function";
|
|
170
|
+
}
|
|
171
|
+
function assertDictionary(obj, context) {
|
|
172
|
+
if (obj !== void 0 && !isDictionary(obj))
|
|
173
|
+
throw new TypeError(`${context} is not an object.`);
|
|
174
|
+
}
|
|
175
|
+
function assertFunction(x2, context) {
|
|
176
|
+
if (typeof x2 != "function")
|
|
177
|
+
throw new TypeError(`${context} is not a function.`);
|
|
178
|
+
}
|
|
179
|
+
function isObject(x2) {
|
|
180
|
+
return typeof x2 == "object" && x2 !== null || typeof x2 == "function";
|
|
181
|
+
}
|
|
182
|
+
function assertObject(x2, context) {
|
|
183
|
+
if (!isObject(x2))
|
|
184
|
+
throw new TypeError(`${context} is not an object.`);
|
|
185
|
+
}
|
|
186
|
+
function assertRequiredArgument(x2, position, context) {
|
|
187
|
+
if (x2 === void 0)
|
|
188
|
+
throw new TypeError(`Parameter ${position} is required in '${context}'.`);
|
|
189
|
+
}
|
|
190
|
+
function assertRequiredField(x2, field, context) {
|
|
191
|
+
if (x2 === void 0)
|
|
192
|
+
throw new TypeError(`${field} is required in '${context}'.`);
|
|
193
|
+
}
|
|
194
|
+
function convertUnrestrictedDouble(value) {
|
|
195
|
+
return Number(value);
|
|
196
|
+
}
|
|
197
|
+
function censorNegativeZero(x2) {
|
|
198
|
+
return x2 === 0 ? 0 : x2;
|
|
199
|
+
}
|
|
200
|
+
function integerPart(x2) {
|
|
201
|
+
return censorNegativeZero(MathTrunc(x2));
|
|
202
|
+
}
|
|
203
|
+
function convertUnsignedLongLongWithEnforceRange(value, context) {
|
|
204
|
+
let upperBound = Number.MAX_SAFE_INTEGER, x2 = Number(value);
|
|
205
|
+
if (x2 = censorNegativeZero(x2), !NumberIsFinite(x2))
|
|
206
|
+
throw new TypeError(`${context} is not a finite number`);
|
|
207
|
+
if (x2 = integerPart(x2), x2 < 0 || x2 > upperBound)
|
|
208
|
+
throw new TypeError(`${context} is outside the accepted range of 0 to ${upperBound}, inclusive`);
|
|
209
|
+
return !NumberIsFinite(x2) || x2 === 0 ? 0 : x2;
|
|
210
|
+
}
|
|
211
|
+
function assertReadableStream(x2, context) {
|
|
212
|
+
if (!IsReadableStream(x2))
|
|
213
|
+
throw new TypeError(`${context} is not a ReadableStream.`);
|
|
214
|
+
}
|
|
215
|
+
function AcquireReadableStreamDefaultReader(stream) {
|
|
216
|
+
return new ReadableStreamDefaultReader(stream);
|
|
217
|
+
}
|
|
218
|
+
function ReadableStreamAddReadRequest(stream, readRequest) {
|
|
219
|
+
stream._reader._readRequests.push(readRequest);
|
|
220
|
+
}
|
|
221
|
+
function ReadableStreamFulfillReadRequest(stream, chunk, done) {
|
|
222
|
+
let readRequest = stream._reader._readRequests.shift();
|
|
223
|
+
done ? readRequest._closeSteps() : readRequest._chunkSteps(chunk);
|
|
224
|
+
}
|
|
225
|
+
function ReadableStreamGetNumReadRequests(stream) {
|
|
226
|
+
return stream._reader._readRequests.length;
|
|
227
|
+
}
|
|
228
|
+
function ReadableStreamHasDefaultReader(stream) {
|
|
229
|
+
let reader = stream._reader;
|
|
230
|
+
return !(reader === void 0 || !IsReadableStreamDefaultReader(reader));
|
|
231
|
+
}
|
|
232
|
+
class ReadableStreamDefaultReader {
|
|
233
|
+
constructor(stream) {
|
|
234
|
+
if (assertRequiredArgument(stream, 1, "ReadableStreamDefaultReader"), assertReadableStream(stream, "First parameter"), IsReadableStreamLocked(stream))
|
|
235
|
+
throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
236
|
+
ReadableStreamReaderGenericInitialize(this, stream), this._readRequests = new SimpleQueue();
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Returns a promise that will be fulfilled when the stream becomes closed,
|
|
240
|
+
* or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
|
|
241
|
+
*/
|
|
242
|
+
get closed() {
|
|
243
|
+
return IsReadableStreamDefaultReader(this) ? this._closedPromise : promiseRejectedWith(defaultReaderBrandCheckException("closed"));
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
|
|
247
|
+
*/
|
|
248
|
+
cancel(reason = void 0) {
|
|
249
|
+
return IsReadableStreamDefaultReader(this) ? this._ownerReadableStream === void 0 ? promiseRejectedWith(readerLockException("cancel")) : ReadableStreamReaderGenericCancel(this, reason) : promiseRejectedWith(defaultReaderBrandCheckException("cancel"));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
|
|
253
|
+
*
|
|
254
|
+
* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
|
|
255
|
+
*/
|
|
256
|
+
read() {
|
|
257
|
+
if (!IsReadableStreamDefaultReader(this))
|
|
258
|
+
return promiseRejectedWith(defaultReaderBrandCheckException("read"));
|
|
259
|
+
if (this._ownerReadableStream === void 0)
|
|
260
|
+
return promiseRejectedWith(readerLockException("read from"));
|
|
261
|
+
let resolvePromise, rejectPromise, promise = newPromise((resolve, reject) => {
|
|
262
|
+
resolvePromise = resolve, rejectPromise = reject;
|
|
263
|
+
});
|
|
264
|
+
return ReadableStreamDefaultReaderRead(this, {
|
|
265
|
+
_chunkSteps: (chunk) => resolvePromise({ value: chunk, done: !1 }),
|
|
266
|
+
_closeSteps: () => resolvePromise({ value: void 0, done: !0 }),
|
|
267
|
+
_errorSteps: (e2) => rejectPromise(e2)
|
|
268
|
+
}), promise;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
|
|
272
|
+
* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
|
|
273
|
+
* from now on; otherwise, the reader will appear closed.
|
|
274
|
+
*
|
|
275
|
+
* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
|
|
276
|
+
* the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to
|
|
277
|
+
* do so will throw a `TypeError` and leave the reader locked to the stream.
|
|
278
|
+
*/
|
|
279
|
+
releaseLock() {
|
|
280
|
+
if (!IsReadableStreamDefaultReader(this))
|
|
281
|
+
throw defaultReaderBrandCheckException("releaseLock");
|
|
282
|
+
this._ownerReadableStream !== void 0 && ReadableStreamDefaultReaderRelease(this);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
Object.defineProperties(ReadableStreamDefaultReader.prototype, {
|
|
286
|
+
cancel: { enumerable: !0 },
|
|
287
|
+
read: { enumerable: !0 },
|
|
288
|
+
releaseLock: { enumerable: !0 },
|
|
289
|
+
closed: { enumerable: !0 }
|
|
290
|
+
}), setFunctionName(ReadableStreamDefaultReader.prototype.cancel, "cancel"), setFunctionName(ReadableStreamDefaultReader.prototype.read, "read"), setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
|
|
291
|
+
value: "ReadableStreamDefaultReader",
|
|
292
|
+
configurable: !0
|
|
293
|
+
});
|
|
294
|
+
function IsReadableStreamDefaultReader(x2) {
|
|
295
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_readRequests") ? !1 : x2 instanceof ReadableStreamDefaultReader;
|
|
296
|
+
}
|
|
297
|
+
function ReadableStreamDefaultReaderRead(reader, readRequest) {
|
|
298
|
+
let stream = reader._ownerReadableStream;
|
|
299
|
+
stream._disturbed = !0, stream._state === "closed" ? readRequest._closeSteps() : stream._state === "errored" ? readRequest._errorSteps(stream._storedError) : stream._readableStreamController[PullSteps](readRequest);
|
|
300
|
+
}
|
|
301
|
+
function ReadableStreamDefaultReaderRelease(reader) {
|
|
302
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
303
|
+
let e2 = new TypeError("Reader was released");
|
|
304
|
+
ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
|
|
305
|
+
}
|
|
306
|
+
function ReadableStreamDefaultReaderErrorReadRequests(reader, e2) {
|
|
307
|
+
let readRequests = reader._readRequests;
|
|
308
|
+
reader._readRequests = new SimpleQueue(), readRequests.forEach((readRequest) => {
|
|
309
|
+
readRequest._errorSteps(e2);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
function defaultReaderBrandCheckException(name) {
|
|
313
|
+
return new TypeError(`ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);
|
|
314
|
+
}
|
|
315
|
+
let AsyncIteratorPrototype = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {
|
|
316
|
+
}).prototype);
|
|
317
|
+
class ReadableStreamAsyncIteratorImpl {
|
|
318
|
+
constructor(reader, preventCancel) {
|
|
319
|
+
this._ongoingPromise = void 0, this._isFinished = !1, this._reader = reader, this._preventCancel = preventCancel;
|
|
320
|
+
}
|
|
321
|
+
next() {
|
|
322
|
+
let nextSteps = () => this._nextSteps();
|
|
323
|
+
return this._ongoingPromise = this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, nextSteps, nextSteps) : nextSteps(), this._ongoingPromise;
|
|
324
|
+
}
|
|
325
|
+
return(value) {
|
|
326
|
+
let returnSteps = () => this._returnSteps(value);
|
|
327
|
+
return this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, returnSteps, returnSteps) : returnSteps();
|
|
328
|
+
}
|
|
329
|
+
_nextSteps() {
|
|
330
|
+
if (this._isFinished)
|
|
331
|
+
return Promise.resolve({ value: void 0, done: !0 });
|
|
332
|
+
let reader = this._reader, resolvePromise, rejectPromise, promise = newPromise((resolve, reject) => {
|
|
333
|
+
resolvePromise = resolve, rejectPromise = reject;
|
|
334
|
+
});
|
|
335
|
+
return ReadableStreamDefaultReaderRead(reader, {
|
|
336
|
+
_chunkSteps: (chunk) => {
|
|
337
|
+
this._ongoingPromise = void 0, _queueMicrotask(() => resolvePromise({ value: chunk, done: !1 }));
|
|
338
|
+
},
|
|
339
|
+
_closeSteps: () => {
|
|
340
|
+
this._ongoingPromise = void 0, this._isFinished = !0, ReadableStreamReaderGenericRelease(reader), resolvePromise({ value: void 0, done: !0 });
|
|
341
|
+
},
|
|
342
|
+
_errorSteps: (reason) => {
|
|
343
|
+
this._ongoingPromise = void 0, this._isFinished = !0, ReadableStreamReaderGenericRelease(reader), rejectPromise(reason);
|
|
344
|
+
}
|
|
345
|
+
}), promise;
|
|
346
|
+
}
|
|
347
|
+
_returnSteps(value) {
|
|
348
|
+
if (this._isFinished)
|
|
349
|
+
return Promise.resolve({ value, done: !0 });
|
|
350
|
+
this._isFinished = !0;
|
|
351
|
+
let reader = this._reader;
|
|
352
|
+
if (!this._preventCancel) {
|
|
353
|
+
let result = ReadableStreamReaderGenericCancel(reader, value);
|
|
354
|
+
return ReadableStreamReaderGenericRelease(reader), transformPromiseWith(result, () => ({ value, done: !0 }));
|
|
355
|
+
}
|
|
356
|
+
return ReadableStreamReaderGenericRelease(reader), promiseResolvedWith({ value, done: !0 });
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
let ReadableStreamAsyncIteratorPrototype = {
|
|
360
|
+
next() {
|
|
361
|
+
return IsReadableStreamAsyncIterator(this) ? this._asyncIteratorImpl.next() : promiseRejectedWith(streamAsyncIteratorBrandCheckException("next"));
|
|
362
|
+
},
|
|
363
|
+
return(value) {
|
|
364
|
+
return IsReadableStreamAsyncIterator(this) ? this._asyncIteratorImpl.return(value) : promiseRejectedWith(streamAsyncIteratorBrandCheckException("return"));
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype);
|
|
368
|
+
function AcquireReadableStreamAsyncIterator(stream, preventCancel) {
|
|
369
|
+
let reader = AcquireReadableStreamDefaultReader(stream), impl = new ReadableStreamAsyncIteratorImpl(reader, preventCancel), iterator = Object.create(ReadableStreamAsyncIteratorPrototype);
|
|
370
|
+
return iterator._asyncIteratorImpl = impl, iterator;
|
|
371
|
+
}
|
|
372
|
+
function IsReadableStreamAsyncIterator(x2) {
|
|
373
|
+
if (!typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_asyncIteratorImpl"))
|
|
374
|
+
return !1;
|
|
375
|
+
try {
|
|
376
|
+
return x2._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
|
|
377
|
+
} catch {
|
|
378
|
+
return !1;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function streamAsyncIteratorBrandCheckException(name) {
|
|
382
|
+
return new TypeError(`ReadableStreamAsyncIterator.${name} can only be used on a ReadableSteamAsyncIterator`);
|
|
383
|
+
}
|
|
384
|
+
let NumberIsNaN = Number.isNaN || function(x2) {
|
|
385
|
+
return x2 !== x2;
|
|
386
|
+
};
|
|
387
|
+
var _a, _b, _c;
|
|
388
|
+
function CreateArrayFromList(elements) {
|
|
389
|
+
return elements.slice();
|
|
390
|
+
}
|
|
391
|
+
function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
|
|
392
|
+
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
|
|
393
|
+
}
|
|
394
|
+
let TransferArrayBuffer = (O) => (typeof O.transfer == "function" ? TransferArrayBuffer = (buffer) => buffer.transfer() : typeof structuredClone == "function" ? TransferArrayBuffer = (buffer) => structuredClone(buffer, { transfer: [buffer] }) : TransferArrayBuffer = (buffer) => buffer, TransferArrayBuffer(O)), IsDetachedBuffer = (O) => (typeof O.detached == "boolean" ? IsDetachedBuffer = (buffer) => buffer.detached : IsDetachedBuffer = (buffer) => buffer.byteLength === 0, IsDetachedBuffer(O));
|
|
395
|
+
function ArrayBufferSlice(buffer, begin, end) {
|
|
396
|
+
if (buffer.slice)
|
|
397
|
+
return buffer.slice(begin, end);
|
|
398
|
+
let length = end - begin, slice = new ArrayBuffer(length);
|
|
399
|
+
return CopyDataBlockBytes(slice, 0, buffer, begin, length), slice;
|
|
400
|
+
}
|
|
401
|
+
function GetMethod(receiver, prop) {
|
|
402
|
+
let func = receiver[prop];
|
|
403
|
+
if (func != null) {
|
|
404
|
+
if (typeof func != "function")
|
|
405
|
+
throw new TypeError(`${String(prop)} is not a function`);
|
|
406
|
+
return func;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
function CreateAsyncFromSyncIterator(syncIteratorRecord) {
|
|
410
|
+
let syncIterable = {
|
|
411
|
+
[Symbol.iterator]: () => syncIteratorRecord.iterator
|
|
412
|
+
}, asyncIterator = async function* () {
|
|
413
|
+
return yield* syncIterable;
|
|
414
|
+
}(), nextMethod = asyncIterator.next;
|
|
415
|
+
return { iterator: asyncIterator, nextMethod, done: !1 };
|
|
416
|
+
}
|
|
417
|
+
let SymbolAsyncIterator = (_c = (_a = Symbol.asyncIterator) !== null && _a !== void 0 ? _a : (_b = Symbol.for) === null || _b === void 0 ? void 0 : _b.call(Symbol, "Symbol.asyncIterator")) !== null && _c !== void 0 ? _c : "@@asyncIterator";
|
|
418
|
+
function GetIterator(obj, hint = "sync", method) {
|
|
419
|
+
if (method === void 0)
|
|
420
|
+
if (hint === "async") {
|
|
421
|
+
if (method = GetMethod(obj, SymbolAsyncIterator), method === void 0) {
|
|
422
|
+
let syncMethod = GetMethod(obj, Symbol.iterator), syncIteratorRecord = GetIterator(obj, "sync", syncMethod);
|
|
423
|
+
return CreateAsyncFromSyncIterator(syncIteratorRecord);
|
|
424
|
+
}
|
|
425
|
+
} else
|
|
426
|
+
method = GetMethod(obj, Symbol.iterator);
|
|
427
|
+
if (method === void 0)
|
|
428
|
+
throw new TypeError("The object is not iterable");
|
|
429
|
+
let iterator = reflectCall(method, obj, []);
|
|
430
|
+
if (!typeIsObject(iterator))
|
|
431
|
+
throw new TypeError("The iterator method must return an object");
|
|
432
|
+
let nextMethod = iterator.next;
|
|
433
|
+
return { iterator, nextMethod, done: !1 };
|
|
434
|
+
}
|
|
435
|
+
function IteratorNext(iteratorRecord) {
|
|
436
|
+
let result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
|
|
437
|
+
if (!typeIsObject(result))
|
|
438
|
+
throw new TypeError("The iterator.next() method must return an object");
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
function IteratorComplete(iterResult) {
|
|
442
|
+
return !!iterResult.done;
|
|
443
|
+
}
|
|
444
|
+
function IteratorValue(iterResult) {
|
|
445
|
+
return iterResult.value;
|
|
446
|
+
}
|
|
447
|
+
function IsNonNegativeNumber(v) {
|
|
448
|
+
return !(typeof v != "number" || NumberIsNaN(v) || v < 0);
|
|
449
|
+
}
|
|
450
|
+
function CloneAsUint8Array(O) {
|
|
451
|
+
let buffer = ArrayBufferSlice(O.buffer, O.byteOffset, O.byteOffset + O.byteLength);
|
|
452
|
+
return new Uint8Array(buffer);
|
|
453
|
+
}
|
|
454
|
+
function DequeueValue(container) {
|
|
455
|
+
let pair = container._queue.shift();
|
|
456
|
+
return container._queueTotalSize -= pair.size, container._queueTotalSize < 0 && (container._queueTotalSize = 0), pair.value;
|
|
457
|
+
}
|
|
458
|
+
function EnqueueValueWithSize(container, value, size) {
|
|
459
|
+
if (!IsNonNegativeNumber(size) || size === 1 / 0)
|
|
460
|
+
throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
|
|
461
|
+
container._queue.push({ value, size }), container._queueTotalSize += size;
|
|
462
|
+
}
|
|
463
|
+
function PeekQueueValue(container) {
|
|
464
|
+
return container._queue.peek().value;
|
|
465
|
+
}
|
|
466
|
+
function ResetQueue(container) {
|
|
467
|
+
container._queue = new SimpleQueue(), container._queueTotalSize = 0;
|
|
468
|
+
}
|
|
469
|
+
function isDataViewConstructor(ctor) {
|
|
470
|
+
return ctor === DataView;
|
|
471
|
+
}
|
|
472
|
+
function isDataView(view) {
|
|
473
|
+
return isDataViewConstructor(view.constructor);
|
|
474
|
+
}
|
|
475
|
+
function arrayBufferViewElementSize(ctor) {
|
|
476
|
+
return isDataViewConstructor(ctor) ? 1 : ctor.BYTES_PER_ELEMENT;
|
|
477
|
+
}
|
|
478
|
+
class ReadableStreamBYOBRequest {
|
|
479
|
+
constructor() {
|
|
480
|
+
throw new TypeError("Illegal constructor");
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Returns the view for writing in to, or `null` if the BYOB request has already been responded to.
|
|
484
|
+
*/
|
|
485
|
+
get view() {
|
|
486
|
+
if (!IsReadableStreamBYOBRequest(this))
|
|
487
|
+
throw byobRequestBrandCheckException("view");
|
|
488
|
+
return this._view;
|
|
489
|
+
}
|
|
490
|
+
respond(bytesWritten) {
|
|
491
|
+
if (!IsReadableStreamBYOBRequest(this))
|
|
492
|
+
throw byobRequestBrandCheckException("respond");
|
|
493
|
+
if (assertRequiredArgument(bytesWritten, 1, "respond"), bytesWritten = convertUnsignedLongLongWithEnforceRange(bytesWritten, "First parameter"), this._associatedReadableByteStreamController === void 0)
|
|
494
|
+
throw new TypeError("This BYOB request has been invalidated");
|
|
495
|
+
if (IsDetachedBuffer(this._view.buffer))
|
|
496
|
+
throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
|
|
497
|
+
ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
|
|
498
|
+
}
|
|
499
|
+
respondWithNewView(view) {
|
|
500
|
+
if (!IsReadableStreamBYOBRequest(this))
|
|
501
|
+
throw byobRequestBrandCheckException("respondWithNewView");
|
|
502
|
+
if (assertRequiredArgument(view, 1, "respondWithNewView"), !ArrayBuffer.isView(view))
|
|
503
|
+
throw new TypeError("You can only respond with array buffer views");
|
|
504
|
+
if (this._associatedReadableByteStreamController === void 0)
|
|
505
|
+
throw new TypeError("This BYOB request has been invalidated");
|
|
506
|
+
if (IsDetachedBuffer(view.buffer))
|
|
507
|
+
throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
|
|
508
|
+
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
|
|
512
|
+
respond: { enumerable: !0 },
|
|
513
|
+
respondWithNewView: { enumerable: !0 },
|
|
514
|
+
view: { enumerable: !0 }
|
|
515
|
+
}), setFunctionName(ReadableStreamBYOBRequest.prototype.respond, "respond"), setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
|
|
516
|
+
value: "ReadableStreamBYOBRequest",
|
|
517
|
+
configurable: !0
|
|
518
|
+
});
|
|
519
|
+
class ReadableByteStreamController {
|
|
520
|
+
constructor() {
|
|
521
|
+
throw new TypeError("Illegal constructor");
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Returns the current BYOB pull request, or `null` if there isn't one.
|
|
525
|
+
*/
|
|
526
|
+
get byobRequest() {
|
|
527
|
+
if (!IsReadableByteStreamController(this))
|
|
528
|
+
throw byteStreamControllerBrandCheckException("byobRequest");
|
|
529
|
+
return ReadableByteStreamControllerGetBYOBRequest(this);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
533
|
+
* over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure.
|
|
534
|
+
*/
|
|
535
|
+
get desiredSize() {
|
|
536
|
+
if (!IsReadableByteStreamController(this))
|
|
537
|
+
throw byteStreamControllerBrandCheckException("desiredSize");
|
|
538
|
+
return ReadableByteStreamControllerGetDesiredSize(this);
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
|
|
542
|
+
* the stream, but once those are read, the stream will become closed.
|
|
543
|
+
*/
|
|
544
|
+
close() {
|
|
545
|
+
if (!IsReadableByteStreamController(this))
|
|
546
|
+
throw byteStreamControllerBrandCheckException("close");
|
|
547
|
+
if (this._closeRequested)
|
|
548
|
+
throw new TypeError("The stream has already been closed; do not close it again!");
|
|
549
|
+
let state = this._controlledReadableByteStream._state;
|
|
550
|
+
if (state !== "readable")
|
|
551
|
+
throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be closed`);
|
|
552
|
+
ReadableByteStreamControllerClose(this);
|
|
553
|
+
}
|
|
554
|
+
enqueue(chunk) {
|
|
555
|
+
if (!IsReadableByteStreamController(this))
|
|
556
|
+
throw byteStreamControllerBrandCheckException("enqueue");
|
|
557
|
+
if (assertRequiredArgument(chunk, 1, "enqueue"), !ArrayBuffer.isView(chunk))
|
|
558
|
+
throw new TypeError("chunk must be an array buffer view");
|
|
559
|
+
if (chunk.byteLength === 0)
|
|
560
|
+
throw new TypeError("chunk must have non-zero byteLength");
|
|
561
|
+
if (chunk.buffer.byteLength === 0)
|
|
562
|
+
throw new TypeError("chunk's buffer must have non-zero byteLength");
|
|
563
|
+
if (this._closeRequested)
|
|
564
|
+
throw new TypeError("stream is closed or draining");
|
|
565
|
+
let state = this._controlledReadableByteStream._state;
|
|
566
|
+
if (state !== "readable")
|
|
567
|
+
throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be enqueued to`);
|
|
568
|
+
ReadableByteStreamControllerEnqueue(this, chunk);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
|
|
572
|
+
*/
|
|
573
|
+
error(e2 = void 0) {
|
|
574
|
+
if (!IsReadableByteStreamController(this))
|
|
575
|
+
throw byteStreamControllerBrandCheckException("error");
|
|
576
|
+
ReadableByteStreamControllerError(this, e2);
|
|
577
|
+
}
|
|
578
|
+
/** @internal */
|
|
579
|
+
[CancelSteps](reason) {
|
|
580
|
+
ReadableByteStreamControllerClearPendingPullIntos(this), ResetQueue(this);
|
|
581
|
+
let result = this._cancelAlgorithm(reason);
|
|
582
|
+
return ReadableByteStreamControllerClearAlgorithms(this), result;
|
|
583
|
+
}
|
|
584
|
+
/** @internal */
|
|
585
|
+
[PullSteps](readRequest) {
|
|
586
|
+
let stream = this._controlledReadableByteStream;
|
|
587
|
+
if (this._queueTotalSize > 0) {
|
|
588
|
+
ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest);
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
let autoAllocateChunkSize = this._autoAllocateChunkSize;
|
|
592
|
+
if (autoAllocateChunkSize !== void 0) {
|
|
593
|
+
let buffer;
|
|
594
|
+
try {
|
|
595
|
+
buffer = new ArrayBuffer(autoAllocateChunkSize);
|
|
596
|
+
} catch (bufferE) {
|
|
597
|
+
readRequest._errorSteps(bufferE);
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
let pullIntoDescriptor = {
|
|
601
|
+
buffer,
|
|
602
|
+
bufferByteLength: autoAllocateChunkSize,
|
|
603
|
+
byteOffset: 0,
|
|
604
|
+
byteLength: autoAllocateChunkSize,
|
|
605
|
+
bytesFilled: 0,
|
|
606
|
+
minimumFill: 1,
|
|
607
|
+
elementSize: 1,
|
|
608
|
+
viewConstructor: Uint8Array,
|
|
609
|
+
readerType: "default"
|
|
610
|
+
};
|
|
611
|
+
this._pendingPullIntos.push(pullIntoDescriptor);
|
|
612
|
+
}
|
|
613
|
+
ReadableStreamAddReadRequest(stream, readRequest), ReadableByteStreamControllerCallPullIfNeeded(this);
|
|
614
|
+
}
|
|
615
|
+
/** @internal */
|
|
616
|
+
[ReleaseSteps]() {
|
|
617
|
+
if (this._pendingPullIntos.length > 0) {
|
|
618
|
+
let firstPullInto = this._pendingPullIntos.peek();
|
|
619
|
+
firstPullInto.readerType = "none", this._pendingPullIntos = new SimpleQueue(), this._pendingPullIntos.push(firstPullInto);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
Object.defineProperties(ReadableByteStreamController.prototype, {
|
|
624
|
+
close: { enumerable: !0 },
|
|
625
|
+
enqueue: { enumerable: !0 },
|
|
626
|
+
error: { enumerable: !0 },
|
|
627
|
+
byobRequest: { enumerable: !0 },
|
|
628
|
+
desiredSize: { enumerable: !0 }
|
|
629
|
+
}), setFunctionName(ReadableByteStreamController.prototype.close, "close"), setFunctionName(ReadableByteStreamController.prototype.enqueue, "enqueue"), setFunctionName(ReadableByteStreamController.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
|
|
630
|
+
value: "ReadableByteStreamController",
|
|
631
|
+
configurable: !0
|
|
632
|
+
});
|
|
633
|
+
function IsReadableByteStreamController(x2) {
|
|
634
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_controlledReadableByteStream") ? !1 : x2 instanceof ReadableByteStreamController;
|
|
635
|
+
}
|
|
636
|
+
function IsReadableStreamBYOBRequest(x2) {
|
|
637
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_associatedReadableByteStreamController") ? !1 : x2 instanceof ReadableStreamBYOBRequest;
|
|
638
|
+
}
|
|
639
|
+
function ReadableByteStreamControllerCallPullIfNeeded(controller) {
|
|
640
|
+
if (!ReadableByteStreamControllerShouldCallPull(controller))
|
|
641
|
+
return;
|
|
642
|
+
if (controller._pulling) {
|
|
643
|
+
controller._pullAgain = !0;
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
controller._pulling = !0;
|
|
647
|
+
let pullPromise = controller._pullAlgorithm();
|
|
648
|
+
uponPromise(pullPromise, () => (controller._pulling = !1, controller._pullAgain && (controller._pullAgain = !1, ReadableByteStreamControllerCallPullIfNeeded(controller)), null), (e2) => (ReadableByteStreamControllerError(controller, e2), null));
|
|
649
|
+
}
|
|
650
|
+
function ReadableByteStreamControllerClearPendingPullIntos(controller) {
|
|
651
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller), controller._pendingPullIntos = new SimpleQueue();
|
|
652
|
+
}
|
|
653
|
+
function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) {
|
|
654
|
+
let done = !1;
|
|
655
|
+
stream._state === "closed" && (done = !0);
|
|
656
|
+
let filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
|
|
657
|
+
pullIntoDescriptor.readerType === "default" ? ReadableStreamFulfillReadRequest(stream, filledView, done) : ReadableStreamFulfillReadIntoRequest(stream, filledView, done);
|
|
658
|
+
}
|
|
659
|
+
function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) {
|
|
660
|
+
let bytesFilled = pullIntoDescriptor.bytesFilled, elementSize = pullIntoDescriptor.elementSize;
|
|
661
|
+
return new pullIntoDescriptor.viewConstructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize);
|
|
662
|
+
}
|
|
663
|
+
function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) {
|
|
664
|
+
controller._queue.push({ buffer, byteOffset, byteLength }), controller._queueTotalSize += byteLength;
|
|
665
|
+
}
|
|
666
|
+
function ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, buffer, byteOffset, byteLength) {
|
|
667
|
+
let clonedChunk;
|
|
668
|
+
try {
|
|
669
|
+
clonedChunk = ArrayBufferSlice(buffer, byteOffset, byteOffset + byteLength);
|
|
670
|
+
} catch (cloneE) {
|
|
671
|
+
throw ReadableByteStreamControllerError(controller, cloneE), cloneE;
|
|
672
|
+
}
|
|
673
|
+
ReadableByteStreamControllerEnqueueChunkToQueue(controller, clonedChunk, 0, byteLength);
|
|
674
|
+
}
|
|
675
|
+
function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstDescriptor) {
|
|
676
|
+
firstDescriptor.bytesFilled > 0 && ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, firstDescriptor.buffer, firstDescriptor.byteOffset, firstDescriptor.bytesFilled), ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
677
|
+
}
|
|
678
|
+
function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
|
|
679
|
+
let maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled), maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy, totalBytesToCopyRemaining = maxBytesToCopy, ready = !1, remainderBytes = maxBytesFilled % pullIntoDescriptor.elementSize, maxAlignedBytes = maxBytesFilled - remainderBytes;
|
|
680
|
+
maxAlignedBytes >= pullIntoDescriptor.minimumFill && (totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled, ready = !0);
|
|
681
|
+
let queue = controller._queue;
|
|
682
|
+
for (; totalBytesToCopyRemaining > 0; ) {
|
|
683
|
+
let headOfQueue = queue.peek(), bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength), destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
|
684
|
+
CopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), headOfQueue.byteLength === bytesToCopy ? queue.shift() : (headOfQueue.byteOffset += bytesToCopy, headOfQueue.byteLength -= bytesToCopy), controller._queueTotalSize -= bytesToCopy, ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor), totalBytesToCopyRemaining -= bytesToCopy;
|
|
685
|
+
}
|
|
686
|
+
return ready;
|
|
687
|
+
}
|
|
688
|
+
function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) {
|
|
689
|
+
pullIntoDescriptor.bytesFilled += size;
|
|
690
|
+
}
|
|
691
|
+
function ReadableByteStreamControllerHandleQueueDrain(controller) {
|
|
692
|
+
controller._queueTotalSize === 0 && controller._closeRequested ? (ReadableByteStreamControllerClearAlgorithms(controller), ReadableStreamClose(controller._controlledReadableByteStream)) : ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
693
|
+
}
|
|
694
|
+
function ReadableByteStreamControllerInvalidateBYOBRequest(controller) {
|
|
695
|
+
controller._byobRequest !== null && (controller._byobRequest._associatedReadableByteStreamController = void 0, controller._byobRequest._view = null, controller._byobRequest = null);
|
|
696
|
+
}
|
|
697
|
+
function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) {
|
|
698
|
+
for (; controller._pendingPullIntos.length > 0; ) {
|
|
699
|
+
if (controller._queueTotalSize === 0)
|
|
700
|
+
return;
|
|
701
|
+
let pullIntoDescriptor = controller._pendingPullIntos.peek();
|
|
702
|
+
ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) && (ReadableByteStreamControllerShiftPendingPullInto(controller), ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
|
|
706
|
+
let reader = controller._controlledReadableByteStream._reader;
|
|
707
|
+
for (; reader._readRequests.length > 0; ) {
|
|
708
|
+
if (controller._queueTotalSize === 0)
|
|
709
|
+
return;
|
|
710
|
+
let readRequest = reader._readRequests.shift();
|
|
711
|
+
ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
|
|
715
|
+
let stream = controller._controlledReadableByteStream, ctor = view.constructor, elementSize = arrayBufferViewElementSize(ctor), { byteOffset, byteLength } = view, minimumFill = min * elementSize, buffer;
|
|
716
|
+
try {
|
|
717
|
+
buffer = TransferArrayBuffer(view.buffer);
|
|
718
|
+
} catch (e2) {
|
|
719
|
+
readIntoRequest._errorSteps(e2);
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
let pullIntoDescriptor = {
|
|
723
|
+
buffer,
|
|
724
|
+
bufferByteLength: buffer.byteLength,
|
|
725
|
+
byteOffset,
|
|
726
|
+
byteLength,
|
|
727
|
+
bytesFilled: 0,
|
|
728
|
+
minimumFill,
|
|
729
|
+
elementSize,
|
|
730
|
+
viewConstructor: ctor,
|
|
731
|
+
readerType: "byob"
|
|
732
|
+
};
|
|
733
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
734
|
+
controller._pendingPullIntos.push(pullIntoDescriptor), ReadableStreamAddReadIntoRequest(stream, readIntoRequest);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
if (stream._state === "closed") {
|
|
738
|
+
let emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
|
|
739
|
+
readIntoRequest._closeSteps(emptyView);
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
if (controller._queueTotalSize > 0) {
|
|
743
|
+
if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) {
|
|
744
|
+
let filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor);
|
|
745
|
+
ReadableByteStreamControllerHandleQueueDrain(controller), readIntoRequest._chunkSteps(filledView);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
if (controller._closeRequested) {
|
|
749
|
+
let e2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
750
|
+
ReadableByteStreamControllerError(controller, e2), readIntoRequest._errorSteps(e2);
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
controller._pendingPullIntos.push(pullIntoDescriptor), ReadableStreamAddReadIntoRequest(stream, readIntoRequest), ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
755
|
+
}
|
|
756
|
+
function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
|
|
757
|
+
firstDescriptor.readerType === "none" && ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
758
|
+
let stream = controller._controlledReadableByteStream;
|
|
759
|
+
if (ReadableStreamHasBYOBReader(stream))
|
|
760
|
+
for (; ReadableStreamGetNumReadIntoRequests(stream) > 0; ) {
|
|
761
|
+
let pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
762
|
+
ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
|
|
766
|
+
if (ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor), pullIntoDescriptor.readerType === "none") {
|
|
767
|
+
ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor), ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.minimumFill)
|
|
771
|
+
return;
|
|
772
|
+
ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
773
|
+
let remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
|
|
774
|
+
if (remainderSize > 0) {
|
|
775
|
+
let end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
|
|
776
|
+
ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
|
|
777
|
+
}
|
|
778
|
+
pullIntoDescriptor.bytesFilled -= remainderSize, ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor), ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
|
|
779
|
+
}
|
|
780
|
+
function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) {
|
|
781
|
+
let firstDescriptor = controller._pendingPullIntos.peek();
|
|
782
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller), controller._controlledReadableByteStream._state === "closed" ? ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) : ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor), ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
783
|
+
}
|
|
784
|
+
function ReadableByteStreamControllerShiftPendingPullInto(controller) {
|
|
785
|
+
return controller._pendingPullIntos.shift();
|
|
786
|
+
}
|
|
787
|
+
function ReadableByteStreamControllerShouldCallPull(controller) {
|
|
788
|
+
let stream = controller._controlledReadableByteStream;
|
|
789
|
+
return stream._state !== "readable" || controller._closeRequested || !controller._started ? !1 : !!(ReadableStreamHasDefaultReader(stream) && ReadableStreamGetNumReadRequests(stream) > 0 || ReadableStreamHasBYOBReader(stream) && ReadableStreamGetNumReadIntoRequests(stream) > 0 || ReadableByteStreamControllerGetDesiredSize(controller) > 0);
|
|
790
|
+
}
|
|
791
|
+
function ReadableByteStreamControllerClearAlgorithms(controller) {
|
|
792
|
+
controller._pullAlgorithm = void 0, controller._cancelAlgorithm = void 0;
|
|
793
|
+
}
|
|
794
|
+
function ReadableByteStreamControllerClose(controller) {
|
|
795
|
+
let stream = controller._controlledReadableByteStream;
|
|
796
|
+
if (!(controller._closeRequested || stream._state !== "readable")) {
|
|
797
|
+
if (controller._queueTotalSize > 0) {
|
|
798
|
+
controller._closeRequested = !0;
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
802
|
+
let firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
803
|
+
if (firstPendingPullInto.bytesFilled % firstPendingPullInto.elementSize !== 0) {
|
|
804
|
+
let e2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
805
|
+
throw ReadableByteStreamControllerError(controller, e2), e2;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
ReadableByteStreamControllerClearAlgorithms(controller), ReadableStreamClose(stream);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function ReadableByteStreamControllerEnqueue(controller, chunk) {
|
|
812
|
+
let stream = controller._controlledReadableByteStream;
|
|
813
|
+
if (controller._closeRequested || stream._state !== "readable")
|
|
814
|
+
return;
|
|
815
|
+
let { buffer, byteOffset, byteLength } = chunk;
|
|
816
|
+
if (IsDetachedBuffer(buffer))
|
|
817
|
+
throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
|
|
818
|
+
let transferredBuffer = TransferArrayBuffer(buffer);
|
|
819
|
+
if (controller._pendingPullIntos.length > 0) {
|
|
820
|
+
let firstPendingPullInto = controller._pendingPullIntos.peek();
|
|
821
|
+
if (IsDetachedBuffer(firstPendingPullInto.buffer))
|
|
822
|
+
throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
|
|
823
|
+
ReadableByteStreamControllerInvalidateBYOBRequest(controller), firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer), firstPendingPullInto.readerType === "none" && ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstPendingPullInto);
|
|
824
|
+
}
|
|
825
|
+
if (ReadableStreamHasDefaultReader(stream))
|
|
826
|
+
if (ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller), ReadableStreamGetNumReadRequests(stream) === 0)
|
|
827
|
+
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
|
|
828
|
+
else {
|
|
829
|
+
controller._pendingPullIntos.length > 0 && ReadableByteStreamControllerShiftPendingPullInto(controller);
|
|
830
|
+
let transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength);
|
|
831
|
+
ReadableStreamFulfillReadRequest(stream, transferredView, !1);
|
|
832
|
+
}
|
|
833
|
+
else
|
|
834
|
+
ReadableStreamHasBYOBReader(stream) ? (ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength), ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller)) : ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
|
|
835
|
+
ReadableByteStreamControllerCallPullIfNeeded(controller);
|
|
836
|
+
}
|
|
837
|
+
function ReadableByteStreamControllerError(controller, e2) {
|
|
838
|
+
let stream = controller._controlledReadableByteStream;
|
|
839
|
+
stream._state === "readable" && (ReadableByteStreamControllerClearPendingPullIntos(controller), ResetQueue(controller), ReadableByteStreamControllerClearAlgorithms(controller), ReadableStreamError(stream, e2));
|
|
840
|
+
}
|
|
841
|
+
function ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest) {
|
|
842
|
+
let entry = controller._queue.shift();
|
|
843
|
+
controller._queueTotalSize -= entry.byteLength, ReadableByteStreamControllerHandleQueueDrain(controller);
|
|
844
|
+
let view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
|
|
845
|
+
readRequest._chunkSteps(view);
|
|
846
|
+
}
|
|
847
|
+
function ReadableByteStreamControllerGetBYOBRequest(controller) {
|
|
848
|
+
if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
|
|
849
|
+
let firstDescriptor = controller._pendingPullIntos.peek(), view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled), byobRequest = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
850
|
+
SetUpReadableStreamBYOBRequest(byobRequest, controller, view), controller._byobRequest = byobRequest;
|
|
851
|
+
}
|
|
852
|
+
return controller._byobRequest;
|
|
853
|
+
}
|
|
854
|
+
function ReadableByteStreamControllerGetDesiredSize(controller) {
|
|
855
|
+
let state = controller._controlledReadableByteStream._state;
|
|
856
|
+
return state === "errored" ? null : state === "closed" ? 0 : controller._strategyHWM - controller._queueTotalSize;
|
|
857
|
+
}
|
|
858
|
+
function ReadableByteStreamControllerRespond(controller, bytesWritten) {
|
|
859
|
+
let firstDescriptor = controller._pendingPullIntos.peek();
|
|
860
|
+
if (controller._controlledReadableByteStream._state === "closed") {
|
|
861
|
+
if (bytesWritten !== 0)
|
|
862
|
+
throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
|
|
863
|
+
} else {
|
|
864
|
+
if (bytesWritten === 0)
|
|
865
|
+
throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
|
|
866
|
+
if (firstDescriptor.bytesFilled + bytesWritten > firstDescriptor.byteLength)
|
|
867
|
+
throw new RangeError("bytesWritten out of range");
|
|
868
|
+
}
|
|
869
|
+
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer), ReadableByteStreamControllerRespondInternal(controller, bytesWritten);
|
|
870
|
+
}
|
|
871
|
+
function ReadableByteStreamControllerRespondWithNewView(controller, view) {
|
|
872
|
+
let firstDescriptor = controller._pendingPullIntos.peek();
|
|
873
|
+
if (controller._controlledReadableByteStream._state === "closed") {
|
|
874
|
+
if (view.byteLength !== 0)
|
|
875
|
+
throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
|
|
876
|
+
} else if (view.byteLength === 0)
|
|
877
|
+
throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
|
|
878
|
+
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)
|
|
879
|
+
throw new RangeError("The region specified by view does not match byobRequest");
|
|
880
|
+
if (firstDescriptor.bufferByteLength !== view.buffer.byteLength)
|
|
881
|
+
throw new RangeError("The buffer of view has different capacity than byobRequest");
|
|
882
|
+
if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength)
|
|
883
|
+
throw new RangeError("The region specified by view is larger than byobRequest");
|
|
884
|
+
let viewByteLength = view.byteLength;
|
|
885
|
+
firstDescriptor.buffer = TransferArrayBuffer(view.buffer), ReadableByteStreamControllerRespondInternal(controller, viewByteLength);
|
|
886
|
+
}
|
|
887
|
+
function SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize) {
|
|
888
|
+
controller._controlledReadableByteStream = stream, controller._pullAgain = !1, controller._pulling = !1, controller._byobRequest = null, controller._queue = controller._queueTotalSize = void 0, ResetQueue(controller), controller._closeRequested = !1, controller._started = !1, controller._strategyHWM = highWaterMark, controller._pullAlgorithm = pullAlgorithm, controller._cancelAlgorithm = cancelAlgorithm, controller._autoAllocateChunkSize = autoAllocateChunkSize, controller._pendingPullIntos = new SimpleQueue(), stream._readableStreamController = controller;
|
|
889
|
+
let startResult = startAlgorithm();
|
|
890
|
+
uponPromise(promiseResolvedWith(startResult), () => (controller._started = !0, ReadableByteStreamControllerCallPullIfNeeded(controller), null), (r2) => (ReadableByteStreamControllerError(controller, r2), null));
|
|
891
|
+
}
|
|
892
|
+
function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
|
|
893
|
+
let controller = Object.create(ReadableByteStreamController.prototype), startAlgorithm, pullAlgorithm, cancelAlgorithm;
|
|
894
|
+
underlyingByteSource.start !== void 0 ? startAlgorithm = () => underlyingByteSource.start(controller) : startAlgorithm = () => {
|
|
895
|
+
}, underlyingByteSource.pull !== void 0 ? pullAlgorithm = () => underlyingByteSource.pull(controller) : pullAlgorithm = () => promiseResolvedWith(void 0), underlyingByteSource.cancel !== void 0 ? cancelAlgorithm = (reason) => underlyingByteSource.cancel(reason) : cancelAlgorithm = () => promiseResolvedWith(void 0);
|
|
896
|
+
let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
|
|
897
|
+
if (autoAllocateChunkSize === 0)
|
|
898
|
+
throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
|
899
|
+
SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize);
|
|
900
|
+
}
|
|
901
|
+
function SetUpReadableStreamBYOBRequest(request, controller, view) {
|
|
902
|
+
request._associatedReadableByteStreamController = controller, request._view = view;
|
|
903
|
+
}
|
|
904
|
+
function byobRequestBrandCheckException(name) {
|
|
905
|
+
return new TypeError(`ReadableStreamBYOBRequest.prototype.${name} can only be used on a ReadableStreamBYOBRequest`);
|
|
906
|
+
}
|
|
907
|
+
function byteStreamControllerBrandCheckException(name) {
|
|
908
|
+
return new TypeError(`ReadableByteStreamController.prototype.${name} can only be used on a ReadableByteStreamController`);
|
|
909
|
+
}
|
|
910
|
+
function convertReaderOptions(options, context) {
|
|
911
|
+
assertDictionary(options, context);
|
|
912
|
+
let mode = options?.mode;
|
|
913
|
+
return {
|
|
914
|
+
mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function convertReadableStreamReaderMode(mode, context) {
|
|
918
|
+
if (mode = `${mode}`, mode !== "byob")
|
|
919
|
+
throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
|
|
920
|
+
return mode;
|
|
921
|
+
}
|
|
922
|
+
function convertByobReadOptions(options, context) {
|
|
923
|
+
var _a2;
|
|
924
|
+
assertDictionary(options, context);
|
|
925
|
+
let min = (_a2 = options?.min) !== null && _a2 !== void 0 ? _a2 : 1;
|
|
926
|
+
return {
|
|
927
|
+
min: convertUnsignedLongLongWithEnforceRange(min, `${context} has member 'min' that`)
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function AcquireReadableStreamBYOBReader(stream) {
|
|
931
|
+
return new ReadableStreamBYOBReader(stream);
|
|
932
|
+
}
|
|
933
|
+
function ReadableStreamAddReadIntoRequest(stream, readIntoRequest) {
|
|
934
|
+
stream._reader._readIntoRequests.push(readIntoRequest);
|
|
935
|
+
}
|
|
936
|
+
function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) {
|
|
937
|
+
let readIntoRequest = stream._reader._readIntoRequests.shift();
|
|
938
|
+
done ? readIntoRequest._closeSteps(chunk) : readIntoRequest._chunkSteps(chunk);
|
|
939
|
+
}
|
|
940
|
+
function ReadableStreamGetNumReadIntoRequests(stream) {
|
|
941
|
+
return stream._reader._readIntoRequests.length;
|
|
942
|
+
}
|
|
943
|
+
function ReadableStreamHasBYOBReader(stream) {
|
|
944
|
+
let reader = stream._reader;
|
|
945
|
+
return !(reader === void 0 || !IsReadableStreamBYOBReader(reader));
|
|
946
|
+
}
|
|
947
|
+
class ReadableStreamBYOBReader {
|
|
948
|
+
constructor(stream) {
|
|
949
|
+
if (assertRequiredArgument(stream, 1, "ReadableStreamBYOBReader"), assertReadableStream(stream, "First parameter"), IsReadableStreamLocked(stream))
|
|
950
|
+
throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
951
|
+
if (!IsReadableByteStreamController(stream._readableStreamController))
|
|
952
|
+
throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
|
|
953
|
+
ReadableStreamReaderGenericInitialize(this, stream), this._readIntoRequests = new SimpleQueue();
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
|
|
957
|
+
* the reader's lock is released before the stream finishes closing.
|
|
958
|
+
*/
|
|
959
|
+
get closed() {
|
|
960
|
+
return IsReadableStreamBYOBReader(this) ? this._closedPromise : promiseRejectedWith(byobReaderBrandCheckException("closed"));
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
|
|
964
|
+
*/
|
|
965
|
+
cancel(reason = void 0) {
|
|
966
|
+
return IsReadableStreamBYOBReader(this) ? this._ownerReadableStream === void 0 ? promiseRejectedWith(readerLockException("cancel")) : ReadableStreamReaderGenericCancel(this, reason) : promiseRejectedWith(byobReaderBrandCheckException("cancel"));
|
|
967
|
+
}
|
|
968
|
+
read(view, rawOptions = {}) {
|
|
969
|
+
if (!IsReadableStreamBYOBReader(this))
|
|
970
|
+
return promiseRejectedWith(byobReaderBrandCheckException("read"));
|
|
971
|
+
if (!ArrayBuffer.isView(view))
|
|
972
|
+
return promiseRejectedWith(new TypeError("view must be an array buffer view"));
|
|
973
|
+
if (view.byteLength === 0)
|
|
974
|
+
return promiseRejectedWith(new TypeError("view must have non-zero byteLength"));
|
|
975
|
+
if (view.buffer.byteLength === 0)
|
|
976
|
+
return promiseRejectedWith(new TypeError("view's buffer must have non-zero byteLength"));
|
|
977
|
+
if (IsDetachedBuffer(view.buffer))
|
|
978
|
+
return promiseRejectedWith(new TypeError("view's buffer has been detached"));
|
|
979
|
+
let options;
|
|
980
|
+
try {
|
|
981
|
+
options = convertByobReadOptions(rawOptions, "options");
|
|
982
|
+
} catch (e2) {
|
|
983
|
+
return promiseRejectedWith(e2);
|
|
984
|
+
}
|
|
985
|
+
let min = options.min;
|
|
986
|
+
if (min === 0)
|
|
987
|
+
return promiseRejectedWith(new TypeError("options.min must be greater than 0"));
|
|
988
|
+
if (isDataView(view)) {
|
|
989
|
+
if (min > view.byteLength)
|
|
990
|
+
return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's byteLength"));
|
|
991
|
+
} else if (min > view.length)
|
|
992
|
+
return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's length"));
|
|
993
|
+
if (this._ownerReadableStream === void 0)
|
|
994
|
+
return promiseRejectedWith(readerLockException("read from"));
|
|
995
|
+
let resolvePromise, rejectPromise, promise = newPromise((resolve, reject) => {
|
|
996
|
+
resolvePromise = resolve, rejectPromise = reject;
|
|
997
|
+
});
|
|
998
|
+
return ReadableStreamBYOBReaderRead(this, view, min, {
|
|
999
|
+
_chunkSteps: (chunk) => resolvePromise({ value: chunk, done: !1 }),
|
|
1000
|
+
_closeSteps: (chunk) => resolvePromise({ value: chunk, done: !0 }),
|
|
1001
|
+
_errorSteps: (e2) => rejectPromise(e2)
|
|
1002
|
+
}), promise;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
|
|
1006
|
+
* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
|
|
1007
|
+
* from now on; otherwise, the reader will appear closed.
|
|
1008
|
+
*
|
|
1009
|
+
* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
|
|
1010
|
+
* the reader's {@link ReadableStreamBYOBReader.read | read()} method has not yet been settled. Attempting to
|
|
1011
|
+
* do so will throw a `TypeError` and leave the reader locked to the stream.
|
|
1012
|
+
*/
|
|
1013
|
+
releaseLock() {
|
|
1014
|
+
if (!IsReadableStreamBYOBReader(this))
|
|
1015
|
+
throw byobReaderBrandCheckException("releaseLock");
|
|
1016
|
+
this._ownerReadableStream !== void 0 && ReadableStreamBYOBReaderRelease(this);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
Object.defineProperties(ReadableStreamBYOBReader.prototype, {
|
|
1020
|
+
cancel: { enumerable: !0 },
|
|
1021
|
+
read: { enumerable: !0 },
|
|
1022
|
+
releaseLock: { enumerable: !0 },
|
|
1023
|
+
closed: { enumerable: !0 }
|
|
1024
|
+
}), setFunctionName(ReadableStreamBYOBReader.prototype.cancel, "cancel"), setFunctionName(ReadableStreamBYOBReader.prototype.read, "read"), setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
|
|
1025
|
+
value: "ReadableStreamBYOBReader",
|
|
1026
|
+
configurable: !0
|
|
1027
|
+
});
|
|
1028
|
+
function IsReadableStreamBYOBReader(x2) {
|
|
1029
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_readIntoRequests") ? !1 : x2 instanceof ReadableStreamBYOBReader;
|
|
1030
|
+
}
|
|
1031
|
+
function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
|
|
1032
|
+
let stream = reader._ownerReadableStream;
|
|
1033
|
+
stream._disturbed = !0, stream._state === "errored" ? readIntoRequest._errorSteps(stream._storedError) : ReadableByteStreamControllerPullInto(stream._readableStreamController, view, min, readIntoRequest);
|
|
1034
|
+
}
|
|
1035
|
+
function ReadableStreamBYOBReaderRelease(reader) {
|
|
1036
|
+
ReadableStreamReaderGenericRelease(reader);
|
|
1037
|
+
let e2 = new TypeError("Reader was released");
|
|
1038
|
+
ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
|
|
1039
|
+
}
|
|
1040
|
+
function ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2) {
|
|
1041
|
+
let readIntoRequests = reader._readIntoRequests;
|
|
1042
|
+
reader._readIntoRequests = new SimpleQueue(), readIntoRequests.forEach((readIntoRequest) => {
|
|
1043
|
+
readIntoRequest._errorSteps(e2);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
function byobReaderBrandCheckException(name) {
|
|
1047
|
+
return new TypeError(`ReadableStreamBYOBReader.prototype.${name} can only be used on a ReadableStreamBYOBReader`);
|
|
1048
|
+
}
|
|
1049
|
+
function ExtractHighWaterMark(strategy, defaultHWM) {
|
|
1050
|
+
let { highWaterMark } = strategy;
|
|
1051
|
+
if (highWaterMark === void 0)
|
|
1052
|
+
return defaultHWM;
|
|
1053
|
+
if (NumberIsNaN(highWaterMark) || highWaterMark < 0)
|
|
1054
|
+
throw new RangeError("Invalid highWaterMark");
|
|
1055
|
+
return highWaterMark;
|
|
1056
|
+
}
|
|
1057
|
+
function ExtractSizeAlgorithm(strategy) {
|
|
1058
|
+
let { size } = strategy;
|
|
1059
|
+
return size || (() => 1);
|
|
1060
|
+
}
|
|
1061
|
+
function convertQueuingStrategy(init, context) {
|
|
1062
|
+
assertDictionary(init, context);
|
|
1063
|
+
let highWaterMark = init?.highWaterMark, size = init?.size;
|
|
1064
|
+
return {
|
|
1065
|
+
highWaterMark: highWaterMark === void 0 ? void 0 : convertUnrestrictedDouble(highWaterMark),
|
|
1066
|
+
size: size === void 0 ? void 0 : convertQueuingStrategySize(size, `${context} has member 'size' that`)
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
function convertQueuingStrategySize(fn, context) {
|
|
1070
|
+
return assertFunction(fn, context), (chunk) => convertUnrestrictedDouble(fn(chunk));
|
|
1071
|
+
}
|
|
1072
|
+
function convertUnderlyingSink(original, context) {
|
|
1073
|
+
assertDictionary(original, context);
|
|
1074
|
+
let abort = original?.abort, close = original?.close, start = original?.start, type = original?.type, write = original?.write;
|
|
1075
|
+
return {
|
|
1076
|
+
abort: abort === void 0 ? void 0 : convertUnderlyingSinkAbortCallback(abort, original, `${context} has member 'abort' that`),
|
|
1077
|
+
close: close === void 0 ? void 0 : convertUnderlyingSinkCloseCallback(close, original, `${context} has member 'close' that`),
|
|
1078
|
+
start: start === void 0 ? void 0 : convertUnderlyingSinkStartCallback(start, original, `${context} has member 'start' that`),
|
|
1079
|
+
write: write === void 0 ? void 0 : convertUnderlyingSinkWriteCallback(write, original, `${context} has member 'write' that`),
|
|
1080
|
+
type
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
function convertUnderlyingSinkAbortCallback(fn, original, context) {
|
|
1084
|
+
return assertFunction(fn, context), (reason) => promiseCall(fn, original, [reason]);
|
|
1085
|
+
}
|
|
1086
|
+
function convertUnderlyingSinkCloseCallback(fn, original, context) {
|
|
1087
|
+
return assertFunction(fn, context), () => promiseCall(fn, original, []);
|
|
1088
|
+
}
|
|
1089
|
+
function convertUnderlyingSinkStartCallback(fn, original, context) {
|
|
1090
|
+
return assertFunction(fn, context), (controller) => reflectCall(fn, original, [controller]);
|
|
1091
|
+
}
|
|
1092
|
+
function convertUnderlyingSinkWriteCallback(fn, original, context) {
|
|
1093
|
+
return assertFunction(fn, context), (chunk, controller) => promiseCall(fn, original, [chunk, controller]);
|
|
1094
|
+
}
|
|
1095
|
+
function assertWritableStream(x2, context) {
|
|
1096
|
+
if (!IsWritableStream(x2))
|
|
1097
|
+
throw new TypeError(`${context} is not a WritableStream.`);
|
|
1098
|
+
}
|
|
1099
|
+
function isAbortSignal(value) {
|
|
1100
|
+
if (typeof value != "object" || value === null)
|
|
1101
|
+
return !1;
|
|
1102
|
+
try {
|
|
1103
|
+
return typeof value.aborted == "boolean";
|
|
1104
|
+
} catch {
|
|
1105
|
+
return !1;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
let supportsAbortController = typeof AbortController == "function";
|
|
1109
|
+
function createAbortController() {
|
|
1110
|
+
if (supportsAbortController)
|
|
1111
|
+
return new AbortController();
|
|
1112
|
+
}
|
|
1113
|
+
class WritableStream {
|
|
1114
|
+
constructor(rawUnderlyingSink = {}, rawStrategy = {}) {
|
|
1115
|
+
rawUnderlyingSink === void 0 ? rawUnderlyingSink = null : assertObject(rawUnderlyingSink, "First parameter");
|
|
1116
|
+
let strategy = convertQueuingStrategy(rawStrategy, "Second parameter"), underlyingSink = convertUnderlyingSink(rawUnderlyingSink, "First parameter");
|
|
1117
|
+
if (InitializeWritableStream(this), underlyingSink.type !== void 0)
|
|
1118
|
+
throw new RangeError("Invalid type is specified");
|
|
1119
|
+
let sizeAlgorithm = ExtractSizeAlgorithm(strategy), highWaterMark = ExtractHighWaterMark(strategy, 1);
|
|
1120
|
+
SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, highWaterMark, sizeAlgorithm);
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Returns whether or not the writable stream is locked to a writer.
|
|
1124
|
+
*/
|
|
1125
|
+
get locked() {
|
|
1126
|
+
if (!IsWritableStream(this))
|
|
1127
|
+
throw streamBrandCheckException$2("locked");
|
|
1128
|
+
return IsWritableStreamLocked(this);
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be
|
|
1132
|
+
* immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort
|
|
1133
|
+
* mechanism of the underlying sink.
|
|
1134
|
+
*
|
|
1135
|
+
* The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled
|
|
1136
|
+
* that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
|
|
1137
|
+
* the stream) if the stream is currently locked.
|
|
1138
|
+
*/
|
|
1139
|
+
abort(reason = void 0) {
|
|
1140
|
+
return IsWritableStream(this) ? IsWritableStreamLocked(this) ? promiseRejectedWith(new TypeError("Cannot abort a stream that already has a writer")) : WritableStreamAbort(this, reason) : promiseRejectedWith(streamBrandCheckException$2("abort"));
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
|
|
1144
|
+
* close behavior. During this time any further attempts to write will fail (without erroring the stream).
|
|
1145
|
+
*
|
|
1146
|
+
* The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream
|
|
1147
|
+
* successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
|
|
1148
|
+
* a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
|
|
1149
|
+
*/
|
|
1150
|
+
close() {
|
|
1151
|
+
return IsWritableStream(this) ? IsWritableStreamLocked(this) ? promiseRejectedWith(new TypeError("Cannot close a stream that already has a writer")) : WritableStreamCloseQueuedOrInFlight(this) ? promiseRejectedWith(new TypeError("Cannot close an already-closing stream")) : WritableStreamClose(this) : promiseRejectedWith(streamBrandCheckException$2("close"));
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
|
|
1155
|
+
* is locked, no other writer can be acquired until this one is released.
|
|
1156
|
+
*
|
|
1157
|
+
* This functionality is especially useful for creating abstractions that desire the ability to write to a stream
|
|
1158
|
+
* without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at
|
|
1159
|
+
* the same time, which would cause the resulting written data to be unpredictable and probably useless.
|
|
1160
|
+
*/
|
|
1161
|
+
getWriter() {
|
|
1162
|
+
if (!IsWritableStream(this))
|
|
1163
|
+
throw streamBrandCheckException$2("getWriter");
|
|
1164
|
+
return AcquireWritableStreamDefaultWriter(this);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
Object.defineProperties(WritableStream.prototype, {
|
|
1168
|
+
abort: { enumerable: !0 },
|
|
1169
|
+
close: { enumerable: !0 },
|
|
1170
|
+
getWriter: { enumerable: !0 },
|
|
1171
|
+
locked: { enumerable: !0 }
|
|
1172
|
+
}), setFunctionName(WritableStream.prototype.abort, "abort"), setFunctionName(WritableStream.prototype.close, "close"), setFunctionName(WritableStream.prototype.getWriter, "getWriter"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
|
|
1173
|
+
value: "WritableStream",
|
|
1174
|
+
configurable: !0
|
|
1175
|
+
});
|
|
1176
|
+
function AcquireWritableStreamDefaultWriter(stream) {
|
|
1177
|
+
return new WritableStreamDefaultWriter(stream);
|
|
1178
|
+
}
|
|
1179
|
+
function CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark = 1, sizeAlgorithm = () => 1) {
|
|
1180
|
+
let stream = Object.create(WritableStream.prototype);
|
|
1181
|
+
InitializeWritableStream(stream);
|
|
1182
|
+
let controller = Object.create(WritableStreamDefaultController.prototype);
|
|
1183
|
+
return SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm), stream;
|
|
1184
|
+
}
|
|
1185
|
+
function InitializeWritableStream(stream) {
|
|
1186
|
+
stream._state = "writable", stream._storedError = void 0, stream._writer = void 0, stream._writableStreamController = void 0, stream._writeRequests = new SimpleQueue(), stream._inFlightWriteRequest = void 0, stream._closeRequest = void 0, stream._inFlightCloseRequest = void 0, stream._pendingAbortRequest = void 0, stream._backpressure = !1;
|
|
1187
|
+
}
|
|
1188
|
+
function IsWritableStream(x2) {
|
|
1189
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_writableStreamController") ? !1 : x2 instanceof WritableStream;
|
|
1190
|
+
}
|
|
1191
|
+
function IsWritableStreamLocked(stream) {
|
|
1192
|
+
return stream._writer !== void 0;
|
|
1193
|
+
}
|
|
1194
|
+
function WritableStreamAbort(stream, reason) {
|
|
1195
|
+
var _a2;
|
|
1196
|
+
if (stream._state === "closed" || stream._state === "errored")
|
|
1197
|
+
return promiseResolvedWith(void 0);
|
|
1198
|
+
stream._writableStreamController._abortReason = reason, (_a2 = stream._writableStreamController._abortController) === null || _a2 === void 0 || _a2.abort(reason);
|
|
1199
|
+
let state = stream._state;
|
|
1200
|
+
if (state === "closed" || state === "errored")
|
|
1201
|
+
return promiseResolvedWith(void 0);
|
|
1202
|
+
if (stream._pendingAbortRequest !== void 0)
|
|
1203
|
+
return stream._pendingAbortRequest._promise;
|
|
1204
|
+
let wasAlreadyErroring = !1;
|
|
1205
|
+
state === "erroring" && (wasAlreadyErroring = !0, reason = void 0);
|
|
1206
|
+
let promise = newPromise((resolve, reject) => {
|
|
1207
|
+
stream._pendingAbortRequest = {
|
|
1208
|
+
_promise: void 0,
|
|
1209
|
+
_resolve: resolve,
|
|
1210
|
+
_reject: reject,
|
|
1211
|
+
_reason: reason,
|
|
1212
|
+
_wasAlreadyErroring: wasAlreadyErroring
|
|
1213
|
+
};
|
|
1214
|
+
});
|
|
1215
|
+
return stream._pendingAbortRequest._promise = promise, wasAlreadyErroring || WritableStreamStartErroring(stream, reason), promise;
|
|
1216
|
+
}
|
|
1217
|
+
function WritableStreamClose(stream) {
|
|
1218
|
+
let state = stream._state;
|
|
1219
|
+
if (state === "closed" || state === "errored")
|
|
1220
|
+
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
1221
|
+
let promise = newPromise((resolve, reject) => {
|
|
1222
|
+
let closeRequest = {
|
|
1223
|
+
_resolve: resolve,
|
|
1224
|
+
_reject: reject
|
|
1225
|
+
};
|
|
1226
|
+
stream._closeRequest = closeRequest;
|
|
1227
|
+
}), writer = stream._writer;
|
|
1228
|
+
return writer !== void 0 && stream._backpressure && state === "writable" && defaultWriterReadyPromiseResolve(writer), WritableStreamDefaultControllerClose(stream._writableStreamController), promise;
|
|
1229
|
+
}
|
|
1230
|
+
function WritableStreamAddWriteRequest(stream) {
|
|
1231
|
+
return newPromise((resolve, reject) => {
|
|
1232
|
+
let writeRequest = {
|
|
1233
|
+
_resolve: resolve,
|
|
1234
|
+
_reject: reject
|
|
1235
|
+
};
|
|
1236
|
+
stream._writeRequests.push(writeRequest);
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
function WritableStreamDealWithRejection(stream, error) {
|
|
1240
|
+
if (stream._state === "writable") {
|
|
1241
|
+
WritableStreamStartErroring(stream, error);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
WritableStreamFinishErroring(stream);
|
|
1245
|
+
}
|
|
1246
|
+
function WritableStreamStartErroring(stream, reason) {
|
|
1247
|
+
let controller = stream._writableStreamController;
|
|
1248
|
+
stream._state = "erroring", stream._storedError = reason;
|
|
1249
|
+
let writer = stream._writer;
|
|
1250
|
+
writer !== void 0 && WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason), !WritableStreamHasOperationMarkedInFlight(stream) && controller._started && WritableStreamFinishErroring(stream);
|
|
1251
|
+
}
|
|
1252
|
+
function WritableStreamFinishErroring(stream) {
|
|
1253
|
+
stream._state = "errored", stream._writableStreamController[ErrorSteps]();
|
|
1254
|
+
let storedError = stream._storedError;
|
|
1255
|
+
if (stream._writeRequests.forEach((writeRequest) => {
|
|
1256
|
+
writeRequest._reject(storedError);
|
|
1257
|
+
}), stream._writeRequests = new SimpleQueue(), stream._pendingAbortRequest === void 0) {
|
|
1258
|
+
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
let abortRequest = stream._pendingAbortRequest;
|
|
1262
|
+
if (stream._pendingAbortRequest = void 0, abortRequest._wasAlreadyErroring) {
|
|
1263
|
+
abortRequest._reject(storedError), WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
let promise = stream._writableStreamController[AbortSteps](abortRequest._reason);
|
|
1267
|
+
uponPromise(promise, () => (abortRequest._resolve(), WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream), null), (reason) => (abortRequest._reject(reason), WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream), null));
|
|
1268
|
+
}
|
|
1269
|
+
function WritableStreamFinishInFlightWrite(stream) {
|
|
1270
|
+
stream._inFlightWriteRequest._resolve(void 0), stream._inFlightWriteRequest = void 0;
|
|
1271
|
+
}
|
|
1272
|
+
function WritableStreamFinishInFlightWriteWithError(stream, error) {
|
|
1273
|
+
stream._inFlightWriteRequest._reject(error), stream._inFlightWriteRequest = void 0, WritableStreamDealWithRejection(stream, error);
|
|
1274
|
+
}
|
|
1275
|
+
function WritableStreamFinishInFlightClose(stream) {
|
|
1276
|
+
stream._inFlightCloseRequest._resolve(void 0), stream._inFlightCloseRequest = void 0, stream._state === "erroring" && (stream._storedError = void 0, stream._pendingAbortRequest !== void 0 && (stream._pendingAbortRequest._resolve(), stream._pendingAbortRequest = void 0)), stream._state = "closed";
|
|
1277
|
+
let writer = stream._writer;
|
|
1278
|
+
writer !== void 0 && defaultWriterClosedPromiseResolve(writer);
|
|
1279
|
+
}
|
|
1280
|
+
function WritableStreamFinishInFlightCloseWithError(stream, error) {
|
|
1281
|
+
stream._inFlightCloseRequest._reject(error), stream._inFlightCloseRequest = void 0, stream._pendingAbortRequest !== void 0 && (stream._pendingAbortRequest._reject(error), stream._pendingAbortRequest = void 0), WritableStreamDealWithRejection(stream, error);
|
|
1282
|
+
}
|
|
1283
|
+
function WritableStreamCloseQueuedOrInFlight(stream) {
|
|
1284
|
+
return !(stream._closeRequest === void 0 && stream._inFlightCloseRequest === void 0);
|
|
1285
|
+
}
|
|
1286
|
+
function WritableStreamHasOperationMarkedInFlight(stream) {
|
|
1287
|
+
return !(stream._inFlightWriteRequest === void 0 && stream._inFlightCloseRequest === void 0);
|
|
1288
|
+
}
|
|
1289
|
+
function WritableStreamMarkCloseRequestInFlight(stream) {
|
|
1290
|
+
stream._inFlightCloseRequest = stream._closeRequest, stream._closeRequest = void 0;
|
|
1291
|
+
}
|
|
1292
|
+
function WritableStreamMarkFirstWriteRequestInFlight(stream) {
|
|
1293
|
+
stream._inFlightWriteRequest = stream._writeRequests.shift();
|
|
1294
|
+
}
|
|
1295
|
+
function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) {
|
|
1296
|
+
stream._closeRequest !== void 0 && (stream._closeRequest._reject(stream._storedError), stream._closeRequest = void 0);
|
|
1297
|
+
let writer = stream._writer;
|
|
1298
|
+
writer !== void 0 && defaultWriterClosedPromiseReject(writer, stream._storedError);
|
|
1299
|
+
}
|
|
1300
|
+
function WritableStreamUpdateBackpressure(stream, backpressure) {
|
|
1301
|
+
let writer = stream._writer;
|
|
1302
|
+
writer !== void 0 && backpressure !== stream._backpressure && (backpressure ? defaultWriterReadyPromiseReset(writer) : defaultWriterReadyPromiseResolve(writer)), stream._backpressure = backpressure;
|
|
1303
|
+
}
|
|
1304
|
+
class WritableStreamDefaultWriter {
|
|
1305
|
+
constructor(stream) {
|
|
1306
|
+
if (assertRequiredArgument(stream, 1, "WritableStreamDefaultWriter"), assertWritableStream(stream, "First parameter"), IsWritableStreamLocked(stream))
|
|
1307
|
+
throw new TypeError("This stream has already been locked for exclusive writing by another writer");
|
|
1308
|
+
this._ownerWritableStream = stream, stream._writer = this;
|
|
1309
|
+
let state = stream._state;
|
|
1310
|
+
if (state === "writable")
|
|
1311
|
+
!WritableStreamCloseQueuedOrInFlight(stream) && stream._backpressure ? defaultWriterReadyPromiseInitialize(this) : defaultWriterReadyPromiseInitializeAsResolved(this), defaultWriterClosedPromiseInitialize(this);
|
|
1312
|
+
else if (state === "erroring")
|
|
1313
|
+
defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError), defaultWriterClosedPromiseInitialize(this);
|
|
1314
|
+
else if (state === "closed")
|
|
1315
|
+
defaultWriterReadyPromiseInitializeAsResolved(this), defaultWriterClosedPromiseInitializeAsResolved(this);
|
|
1316
|
+
else {
|
|
1317
|
+
let storedError = stream._storedError;
|
|
1318
|
+
defaultWriterReadyPromiseInitializeAsRejected(this, storedError), defaultWriterClosedPromiseInitializeAsRejected(this, storedError);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
|
|
1323
|
+
* the writer’s lock is released before the stream finishes closing.
|
|
1324
|
+
*/
|
|
1325
|
+
get closed() {
|
|
1326
|
+
return IsWritableStreamDefaultWriter(this) ? this._closedPromise : promiseRejectedWith(defaultWriterBrandCheckException("closed"));
|
|
1327
|
+
}
|
|
1328
|
+
/**
|
|
1329
|
+
* Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
|
|
1330
|
+
* A producer can use this information to determine the right amount of data to write.
|
|
1331
|
+
*
|
|
1332
|
+
* It will be `null` if the stream cannot be successfully written to (due to either being errored, or having an abort
|
|
1333
|
+
* queued up). It will return zero if the stream is closed. And the getter will throw an exception if invoked when
|
|
1334
|
+
* the writer’s lock is released.
|
|
1335
|
+
*/
|
|
1336
|
+
get desiredSize() {
|
|
1337
|
+
if (!IsWritableStreamDefaultWriter(this))
|
|
1338
|
+
throw defaultWriterBrandCheckException("desiredSize");
|
|
1339
|
+
if (this._ownerWritableStream === void 0)
|
|
1340
|
+
throw defaultWriterLockException("desiredSize");
|
|
1341
|
+
return WritableStreamDefaultWriterGetDesiredSize(this);
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Returns a promise that will be fulfilled when the desired size to fill the stream’s internal queue transitions
|
|
1345
|
+
* from non-positive to positive, signaling that it is no longer applying backpressure. Once the desired size dips
|
|
1346
|
+
* back to zero or below, the getter will return a new promise that stays pending until the next transition.
|
|
1347
|
+
*
|
|
1348
|
+
* If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
|
|
1349
|
+
* rejected.
|
|
1350
|
+
*/
|
|
1351
|
+
get ready() {
|
|
1352
|
+
return IsWritableStreamDefaultWriter(this) ? this._readyPromise : promiseRejectedWith(defaultWriterBrandCheckException("ready"));
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
* If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
|
|
1356
|
+
*/
|
|
1357
|
+
abort(reason = void 0) {
|
|
1358
|
+
return IsWritableStreamDefaultWriter(this) ? this._ownerWritableStream === void 0 ? promiseRejectedWith(defaultWriterLockException("abort")) : WritableStreamDefaultWriterAbort(this, reason) : promiseRejectedWith(defaultWriterBrandCheckException("abort"));
|
|
1359
|
+
}
|
|
1360
|
+
/**
|
|
1361
|
+
* If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
|
|
1362
|
+
*/
|
|
1363
|
+
close() {
|
|
1364
|
+
if (!IsWritableStreamDefaultWriter(this))
|
|
1365
|
+
return promiseRejectedWith(defaultWriterBrandCheckException("close"));
|
|
1366
|
+
let stream = this._ownerWritableStream;
|
|
1367
|
+
return stream === void 0 ? promiseRejectedWith(defaultWriterLockException("close")) : WritableStreamCloseQueuedOrInFlight(stream) ? promiseRejectedWith(new TypeError("Cannot close an already-closing stream")) : WritableStreamDefaultWriterClose(this);
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
|
|
1371
|
+
* If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
|
|
1372
|
+
* now on; otherwise, the writer will appear closed.
|
|
1373
|
+
*
|
|
1374
|
+
* Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the
|
|
1375
|
+
* promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled).
|
|
1376
|
+
* It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents
|
|
1377
|
+
* other producers from writing in an interleaved manner.
|
|
1378
|
+
*/
|
|
1379
|
+
releaseLock() {
|
|
1380
|
+
if (!IsWritableStreamDefaultWriter(this))
|
|
1381
|
+
throw defaultWriterBrandCheckException("releaseLock");
|
|
1382
|
+
this._ownerWritableStream !== void 0 && WritableStreamDefaultWriterRelease(this);
|
|
1383
|
+
}
|
|
1384
|
+
write(chunk = void 0) {
|
|
1385
|
+
return IsWritableStreamDefaultWriter(this) ? this._ownerWritableStream === void 0 ? promiseRejectedWith(defaultWriterLockException("write to")) : WritableStreamDefaultWriterWrite(this, chunk) : promiseRejectedWith(defaultWriterBrandCheckException("write"));
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
Object.defineProperties(WritableStreamDefaultWriter.prototype, {
|
|
1389
|
+
abort: { enumerable: !0 },
|
|
1390
|
+
close: { enumerable: !0 },
|
|
1391
|
+
releaseLock: { enumerable: !0 },
|
|
1392
|
+
write: { enumerable: !0 },
|
|
1393
|
+
closed: { enumerable: !0 },
|
|
1394
|
+
desiredSize: { enumerable: !0 },
|
|
1395
|
+
ready: { enumerable: !0 }
|
|
1396
|
+
}), setFunctionName(WritableStreamDefaultWriter.prototype.abort, "abort"), setFunctionName(WritableStreamDefaultWriter.prototype.close, "close"), setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock"), setFunctionName(WritableStreamDefaultWriter.prototype.write, "write"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
|
|
1397
|
+
value: "WritableStreamDefaultWriter",
|
|
1398
|
+
configurable: !0
|
|
1399
|
+
});
|
|
1400
|
+
function IsWritableStreamDefaultWriter(x2) {
|
|
1401
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_ownerWritableStream") ? !1 : x2 instanceof WritableStreamDefaultWriter;
|
|
1402
|
+
}
|
|
1403
|
+
function WritableStreamDefaultWriterAbort(writer, reason) {
|
|
1404
|
+
let stream = writer._ownerWritableStream;
|
|
1405
|
+
return WritableStreamAbort(stream, reason);
|
|
1406
|
+
}
|
|
1407
|
+
function WritableStreamDefaultWriterClose(writer) {
|
|
1408
|
+
let stream = writer._ownerWritableStream;
|
|
1409
|
+
return WritableStreamClose(stream);
|
|
1410
|
+
}
|
|
1411
|
+
function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) {
|
|
1412
|
+
let stream = writer._ownerWritableStream, state = stream._state;
|
|
1413
|
+
return WritableStreamCloseQueuedOrInFlight(stream) || state === "closed" ? promiseResolvedWith(void 0) : state === "errored" ? promiseRejectedWith(stream._storedError) : WritableStreamDefaultWriterClose(writer);
|
|
1414
|
+
}
|
|
1415
|
+
function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
|
|
1416
|
+
writer._closedPromiseState === "pending" ? defaultWriterClosedPromiseReject(writer, error) : defaultWriterClosedPromiseResetToRejected(writer, error);
|
|
1417
|
+
}
|
|
1418
|
+
function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
|
|
1419
|
+
writer._readyPromiseState === "pending" ? defaultWriterReadyPromiseReject(writer, error) : defaultWriterReadyPromiseResetToRejected(writer, error);
|
|
1420
|
+
}
|
|
1421
|
+
function WritableStreamDefaultWriterGetDesiredSize(writer) {
|
|
1422
|
+
let stream = writer._ownerWritableStream, state = stream._state;
|
|
1423
|
+
return state === "errored" || state === "erroring" ? null : state === "closed" ? 0 : WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController);
|
|
1424
|
+
}
|
|
1425
|
+
function WritableStreamDefaultWriterRelease(writer) {
|
|
1426
|
+
let stream = writer._ownerWritableStream, releasedError = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
|
|
1427
|
+
WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError), WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError), stream._writer = void 0, writer._ownerWritableStream = void 0;
|
|
1428
|
+
}
|
|
1429
|
+
function WritableStreamDefaultWriterWrite(writer, chunk) {
|
|
1430
|
+
let stream = writer._ownerWritableStream, controller = stream._writableStreamController, chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk);
|
|
1431
|
+
if (stream !== writer._ownerWritableStream)
|
|
1432
|
+
return promiseRejectedWith(defaultWriterLockException("write to"));
|
|
1433
|
+
let state = stream._state;
|
|
1434
|
+
if (state === "errored")
|
|
1435
|
+
return promiseRejectedWith(stream._storedError);
|
|
1436
|
+
if (WritableStreamCloseQueuedOrInFlight(stream) || state === "closed")
|
|
1437
|
+
return promiseRejectedWith(new TypeError("The stream is closing or closed and cannot be written to"));
|
|
1438
|
+
if (state === "erroring")
|
|
1439
|
+
return promiseRejectedWith(stream._storedError);
|
|
1440
|
+
let promise = WritableStreamAddWriteRequest(stream);
|
|
1441
|
+
return WritableStreamDefaultControllerWrite(controller, chunk, chunkSize), promise;
|
|
1442
|
+
}
|
|
1443
|
+
let closeSentinel = {};
|
|
1444
|
+
class WritableStreamDefaultController {
|
|
1445
|
+
constructor() {
|
|
1446
|
+
throw new TypeError("Illegal constructor");
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
|
|
1450
|
+
*
|
|
1451
|
+
* @deprecated
|
|
1452
|
+
* This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
|
|
1453
|
+
* Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
|
|
1454
|
+
*/
|
|
1455
|
+
get abortReason() {
|
|
1456
|
+
if (!IsWritableStreamDefaultController(this))
|
|
1457
|
+
throw defaultControllerBrandCheckException$2("abortReason");
|
|
1458
|
+
return this._abortReason;
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
|
|
1462
|
+
*/
|
|
1463
|
+
get signal() {
|
|
1464
|
+
if (!IsWritableStreamDefaultController(this))
|
|
1465
|
+
throw defaultControllerBrandCheckException$2("signal");
|
|
1466
|
+
if (this._abortController === void 0)
|
|
1467
|
+
throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
|
|
1468
|
+
return this._abortController.signal;
|
|
1469
|
+
}
|
|
1470
|
+
/**
|
|
1471
|
+
* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
|
|
1472
|
+
*
|
|
1473
|
+
* This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying
|
|
1474
|
+
* sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the
|
|
1475
|
+
* normal lifecycle of interactions with the underlying sink.
|
|
1476
|
+
*/
|
|
1477
|
+
error(e2 = void 0) {
|
|
1478
|
+
if (!IsWritableStreamDefaultController(this))
|
|
1479
|
+
throw defaultControllerBrandCheckException$2("error");
|
|
1480
|
+
this._controlledWritableStream._state === "writable" && WritableStreamDefaultControllerError(this, e2);
|
|
1481
|
+
}
|
|
1482
|
+
/** @internal */
|
|
1483
|
+
[AbortSteps](reason) {
|
|
1484
|
+
let result = this._abortAlgorithm(reason);
|
|
1485
|
+
return WritableStreamDefaultControllerClearAlgorithms(this), result;
|
|
1486
|
+
}
|
|
1487
|
+
/** @internal */
|
|
1488
|
+
[ErrorSteps]() {
|
|
1489
|
+
ResetQueue(this);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
Object.defineProperties(WritableStreamDefaultController.prototype, {
|
|
1493
|
+
abortReason: { enumerable: !0 },
|
|
1494
|
+
signal: { enumerable: !0 },
|
|
1495
|
+
error: { enumerable: !0 }
|
|
1496
|
+
}), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
1497
|
+
value: "WritableStreamDefaultController",
|
|
1498
|
+
configurable: !0
|
|
1499
|
+
});
|
|
1500
|
+
function IsWritableStreamDefaultController(x2) {
|
|
1501
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_controlledWritableStream") ? !1 : x2 instanceof WritableStreamDefaultController;
|
|
1502
|
+
}
|
|
1503
|
+
function SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm) {
|
|
1504
|
+
controller._controlledWritableStream = stream, stream._writableStreamController = controller, controller._queue = void 0, controller._queueTotalSize = void 0, ResetQueue(controller), controller._abortReason = void 0, controller._abortController = createAbortController(), controller._started = !1, controller._strategySizeAlgorithm = sizeAlgorithm, controller._strategyHWM = highWaterMark, controller._writeAlgorithm = writeAlgorithm, controller._closeAlgorithm = closeAlgorithm, controller._abortAlgorithm = abortAlgorithm;
|
|
1505
|
+
let backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
|
|
1506
|
+
WritableStreamUpdateBackpressure(stream, backpressure);
|
|
1507
|
+
let startResult = startAlgorithm(), startPromise = promiseResolvedWith(startResult);
|
|
1508
|
+
uponPromise(startPromise, () => (controller._started = !0, WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller), null), (r2) => (controller._started = !0, WritableStreamDealWithRejection(stream, r2), null));
|
|
1509
|
+
}
|
|
1510
|
+
function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
|
|
1511
|
+
let controller = Object.create(WritableStreamDefaultController.prototype), startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm;
|
|
1512
|
+
underlyingSink.start !== void 0 ? startAlgorithm = () => underlyingSink.start(controller) : startAlgorithm = () => {
|
|
1513
|
+
}, underlyingSink.write !== void 0 ? writeAlgorithm = (chunk) => underlyingSink.write(chunk, controller) : writeAlgorithm = () => promiseResolvedWith(void 0), underlyingSink.close !== void 0 ? closeAlgorithm = () => underlyingSink.close() : closeAlgorithm = () => promiseResolvedWith(void 0), underlyingSink.abort !== void 0 ? abortAlgorithm = (reason) => underlyingSink.abort(reason) : abortAlgorithm = () => promiseResolvedWith(void 0), SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
|
|
1514
|
+
}
|
|
1515
|
+
function WritableStreamDefaultControllerClearAlgorithms(controller) {
|
|
1516
|
+
controller._writeAlgorithm = void 0, controller._closeAlgorithm = void 0, controller._abortAlgorithm = void 0, controller._strategySizeAlgorithm = void 0;
|
|
1517
|
+
}
|
|
1518
|
+
function WritableStreamDefaultControllerClose(controller) {
|
|
1519
|
+
EnqueueValueWithSize(controller, closeSentinel, 0), WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
|
|
1520
|
+
}
|
|
1521
|
+
function WritableStreamDefaultControllerGetChunkSize(controller, chunk) {
|
|
1522
|
+
try {
|
|
1523
|
+
return controller._strategySizeAlgorithm(chunk);
|
|
1524
|
+
} catch (chunkSizeE) {
|
|
1525
|
+
return WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE), 1;
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
function WritableStreamDefaultControllerGetDesiredSize(controller) {
|
|
1529
|
+
return controller._strategyHWM - controller._queueTotalSize;
|
|
1530
|
+
}
|
|
1531
|
+
function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) {
|
|
1532
|
+
try {
|
|
1533
|
+
EnqueueValueWithSize(controller, chunk, chunkSize);
|
|
1534
|
+
} catch (enqueueE) {
|
|
1535
|
+
WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE);
|
|
1536
|
+
return;
|
|
1537
|
+
}
|
|
1538
|
+
let stream = controller._controlledWritableStream;
|
|
1539
|
+
if (!WritableStreamCloseQueuedOrInFlight(stream) && stream._state === "writable") {
|
|
1540
|
+
let backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
|
|
1541
|
+
WritableStreamUpdateBackpressure(stream, backpressure);
|
|
1542
|
+
}
|
|
1543
|
+
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
|
|
1544
|
+
}
|
|
1545
|
+
function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) {
|
|
1546
|
+
let stream = controller._controlledWritableStream;
|
|
1547
|
+
if (!controller._started || stream._inFlightWriteRequest !== void 0)
|
|
1548
|
+
return;
|
|
1549
|
+
if (stream._state === "erroring") {
|
|
1550
|
+
WritableStreamFinishErroring(stream);
|
|
1551
|
+
return;
|
|
1552
|
+
}
|
|
1553
|
+
if (controller._queue.length === 0)
|
|
1554
|
+
return;
|
|
1555
|
+
let value = PeekQueueValue(controller);
|
|
1556
|
+
value === closeSentinel ? WritableStreamDefaultControllerProcessClose(controller) : WritableStreamDefaultControllerProcessWrite(controller, value);
|
|
1557
|
+
}
|
|
1558
|
+
function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
|
|
1559
|
+
controller._controlledWritableStream._state === "writable" && WritableStreamDefaultControllerError(controller, error);
|
|
1560
|
+
}
|
|
1561
|
+
function WritableStreamDefaultControllerProcessClose(controller) {
|
|
1562
|
+
let stream = controller._controlledWritableStream;
|
|
1563
|
+
WritableStreamMarkCloseRequestInFlight(stream), DequeueValue(controller);
|
|
1564
|
+
let sinkClosePromise = controller._closeAlgorithm();
|
|
1565
|
+
WritableStreamDefaultControllerClearAlgorithms(controller), uponPromise(sinkClosePromise, () => (WritableStreamFinishInFlightClose(stream), null), (reason) => (WritableStreamFinishInFlightCloseWithError(stream, reason), null));
|
|
1566
|
+
}
|
|
1567
|
+
function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
|
|
1568
|
+
let stream = controller._controlledWritableStream;
|
|
1569
|
+
WritableStreamMarkFirstWriteRequestInFlight(stream);
|
|
1570
|
+
let sinkWritePromise = controller._writeAlgorithm(chunk);
|
|
1571
|
+
uponPromise(sinkWritePromise, () => {
|
|
1572
|
+
WritableStreamFinishInFlightWrite(stream);
|
|
1573
|
+
let state = stream._state;
|
|
1574
|
+
if (DequeueValue(controller), !WritableStreamCloseQueuedOrInFlight(stream) && state === "writable") {
|
|
1575
|
+
let backpressure = WritableStreamDefaultControllerGetBackpressure(controller);
|
|
1576
|
+
WritableStreamUpdateBackpressure(stream, backpressure);
|
|
1577
|
+
}
|
|
1578
|
+
return WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller), null;
|
|
1579
|
+
}, (reason) => (stream._state === "writable" && WritableStreamDefaultControllerClearAlgorithms(controller), WritableStreamFinishInFlightWriteWithError(stream, reason), null));
|
|
1580
|
+
}
|
|
1581
|
+
function WritableStreamDefaultControllerGetBackpressure(controller) {
|
|
1582
|
+
return WritableStreamDefaultControllerGetDesiredSize(controller) <= 0;
|
|
1583
|
+
}
|
|
1584
|
+
function WritableStreamDefaultControllerError(controller, error) {
|
|
1585
|
+
let stream = controller._controlledWritableStream;
|
|
1586
|
+
WritableStreamDefaultControllerClearAlgorithms(controller), WritableStreamStartErroring(stream, error);
|
|
1587
|
+
}
|
|
1588
|
+
function streamBrandCheckException$2(name) {
|
|
1589
|
+
return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`);
|
|
1590
|
+
}
|
|
1591
|
+
function defaultControllerBrandCheckException$2(name) {
|
|
1592
|
+
return new TypeError(`WritableStreamDefaultController.prototype.${name} can only be used on a WritableStreamDefaultController`);
|
|
1593
|
+
}
|
|
1594
|
+
function defaultWriterBrandCheckException(name) {
|
|
1595
|
+
return new TypeError(`WritableStreamDefaultWriter.prototype.${name} can only be used on a WritableStreamDefaultWriter`);
|
|
1596
|
+
}
|
|
1597
|
+
function defaultWriterLockException(name) {
|
|
1598
|
+
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
1599
|
+
}
|
|
1600
|
+
function defaultWriterClosedPromiseInitialize(writer) {
|
|
1601
|
+
writer._closedPromise = newPromise((resolve, reject) => {
|
|
1602
|
+
writer._closedPromise_resolve = resolve, writer._closedPromise_reject = reject, writer._closedPromiseState = "pending";
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) {
|
|
1606
|
+
defaultWriterClosedPromiseInitialize(writer), defaultWriterClosedPromiseReject(writer, reason);
|
|
1607
|
+
}
|
|
1608
|
+
function defaultWriterClosedPromiseInitializeAsResolved(writer) {
|
|
1609
|
+
defaultWriterClosedPromiseInitialize(writer), defaultWriterClosedPromiseResolve(writer);
|
|
1610
|
+
}
|
|
1611
|
+
function defaultWriterClosedPromiseReject(writer, reason) {
|
|
1612
|
+
writer._closedPromise_reject !== void 0 && (setPromiseIsHandledToTrue(writer._closedPromise), writer._closedPromise_reject(reason), writer._closedPromise_resolve = void 0, writer._closedPromise_reject = void 0, writer._closedPromiseState = "rejected");
|
|
1613
|
+
}
|
|
1614
|
+
function defaultWriterClosedPromiseResetToRejected(writer, reason) {
|
|
1615
|
+
defaultWriterClosedPromiseInitializeAsRejected(writer, reason);
|
|
1616
|
+
}
|
|
1617
|
+
function defaultWriterClosedPromiseResolve(writer) {
|
|
1618
|
+
writer._closedPromise_resolve !== void 0 && (writer._closedPromise_resolve(void 0), writer._closedPromise_resolve = void 0, writer._closedPromise_reject = void 0, writer._closedPromiseState = "resolved");
|
|
1619
|
+
}
|
|
1620
|
+
function defaultWriterReadyPromiseInitialize(writer) {
|
|
1621
|
+
writer._readyPromise = newPromise((resolve, reject) => {
|
|
1622
|
+
writer._readyPromise_resolve = resolve, writer._readyPromise_reject = reject;
|
|
1623
|
+
}), writer._readyPromiseState = "pending";
|
|
1624
|
+
}
|
|
1625
|
+
function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) {
|
|
1626
|
+
defaultWriterReadyPromiseInitialize(writer), defaultWriterReadyPromiseReject(writer, reason);
|
|
1627
|
+
}
|
|
1628
|
+
function defaultWriterReadyPromiseInitializeAsResolved(writer) {
|
|
1629
|
+
defaultWriterReadyPromiseInitialize(writer), defaultWriterReadyPromiseResolve(writer);
|
|
1630
|
+
}
|
|
1631
|
+
function defaultWriterReadyPromiseReject(writer, reason) {
|
|
1632
|
+
writer._readyPromise_reject !== void 0 && (setPromiseIsHandledToTrue(writer._readyPromise), writer._readyPromise_reject(reason), writer._readyPromise_resolve = void 0, writer._readyPromise_reject = void 0, writer._readyPromiseState = "rejected");
|
|
1633
|
+
}
|
|
1634
|
+
function defaultWriterReadyPromiseReset(writer) {
|
|
1635
|
+
defaultWriterReadyPromiseInitialize(writer);
|
|
1636
|
+
}
|
|
1637
|
+
function defaultWriterReadyPromiseResetToRejected(writer, reason) {
|
|
1638
|
+
defaultWriterReadyPromiseInitializeAsRejected(writer, reason);
|
|
1639
|
+
}
|
|
1640
|
+
function defaultWriterReadyPromiseResolve(writer) {
|
|
1641
|
+
writer._readyPromise_resolve !== void 0 && (writer._readyPromise_resolve(void 0), writer._readyPromise_resolve = void 0, writer._readyPromise_reject = void 0, writer._readyPromiseState = "fulfilled");
|
|
1642
|
+
}
|
|
1643
|
+
function getGlobals() {
|
|
1644
|
+
if (typeof globalThis < "u")
|
|
1645
|
+
return globalThis;
|
|
1646
|
+
if (typeof self < "u")
|
|
1647
|
+
return self;
|
|
1648
|
+
if (typeof global < "u")
|
|
1649
|
+
return global;
|
|
1650
|
+
}
|
|
1651
|
+
let globals = getGlobals();
|
|
1652
|
+
function isDOMExceptionConstructor(ctor) {
|
|
1653
|
+
if (!(typeof ctor == "function" || typeof ctor == "object") || ctor.name !== "DOMException")
|
|
1654
|
+
return !1;
|
|
1655
|
+
try {
|
|
1656
|
+
return new ctor(), !0;
|
|
1657
|
+
} catch {
|
|
1658
|
+
return !1;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
function getFromGlobal() {
|
|
1662
|
+
let ctor = globals?.DOMException;
|
|
1663
|
+
return isDOMExceptionConstructor(ctor) ? ctor : void 0;
|
|
1664
|
+
}
|
|
1665
|
+
function createPolyfill() {
|
|
1666
|
+
let ctor = function(message, name) {
|
|
1667
|
+
this.message = message || "", this.name = name || "Error", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
1668
|
+
};
|
|
1669
|
+
return setFunctionName(ctor, "DOMException"), ctor.prototype = Object.create(Error.prototype), Object.defineProperty(ctor.prototype, "constructor", { value: ctor, writable: !0, configurable: !0 }), ctor;
|
|
1670
|
+
}
|
|
1671
|
+
let DOMException2 = getFromGlobal() || createPolyfill();
|
|
1672
|
+
function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
|
|
1673
|
+
let reader = AcquireReadableStreamDefaultReader(source), writer = AcquireWritableStreamDefaultWriter(dest);
|
|
1674
|
+
source._disturbed = !0;
|
|
1675
|
+
let shuttingDown = !1, currentWrite = promiseResolvedWith(void 0);
|
|
1676
|
+
return newPromise((resolve, reject) => {
|
|
1677
|
+
let abortAlgorithm;
|
|
1678
|
+
if (signal !== void 0) {
|
|
1679
|
+
if (abortAlgorithm = () => {
|
|
1680
|
+
let error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError"), actions = [];
|
|
1681
|
+
preventAbort || actions.push(() => dest._state === "writable" ? WritableStreamAbort(dest, error) : promiseResolvedWith(void 0)), preventCancel || actions.push(() => source._state === "readable" ? ReadableStreamCancel(source, error) : promiseResolvedWith(void 0)), shutdownWithAction(() => Promise.all(actions.map((action) => action())), !0, error);
|
|
1682
|
+
}, signal.aborted) {
|
|
1683
|
+
abortAlgorithm();
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1686
|
+
signal.addEventListener("abort", abortAlgorithm);
|
|
1687
|
+
}
|
|
1688
|
+
function pipeLoop() {
|
|
1689
|
+
return newPromise((resolveLoop, rejectLoop) => {
|
|
1690
|
+
function next(done) {
|
|
1691
|
+
done ? resolveLoop() : PerformPromiseThen(pipeStep(), next, rejectLoop);
|
|
1692
|
+
}
|
|
1693
|
+
next(!1);
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
function pipeStep() {
|
|
1697
|
+
return shuttingDown ? promiseResolvedWith(!0) : PerformPromiseThen(writer._readyPromise, () => newPromise((resolveRead, rejectRead) => {
|
|
1698
|
+
ReadableStreamDefaultReaderRead(reader, {
|
|
1699
|
+
_chunkSteps: (chunk) => {
|
|
1700
|
+
currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, chunk), void 0, noop), resolveRead(!1);
|
|
1701
|
+
},
|
|
1702
|
+
_closeSteps: () => resolveRead(!0),
|
|
1703
|
+
_errorSteps: rejectRead
|
|
1704
|
+
});
|
|
1705
|
+
}));
|
|
1706
|
+
}
|
|
1707
|
+
if (isOrBecomesErrored(source, reader._closedPromise, (storedError) => (preventAbort ? shutdown(!0, storedError) : shutdownWithAction(() => WritableStreamAbort(dest, storedError), !0, storedError), null)), isOrBecomesErrored(dest, writer._closedPromise, (storedError) => (preventCancel ? shutdown(!0, storedError) : shutdownWithAction(() => ReadableStreamCancel(source, storedError), !0, storedError), null)), isOrBecomesClosed(source, reader._closedPromise, () => (preventClose ? shutdown() : shutdownWithAction(() => WritableStreamDefaultWriterCloseWithErrorPropagation(writer)), null)), WritableStreamCloseQueuedOrInFlight(dest) || dest._state === "closed") {
|
|
1708
|
+
let destClosed = new TypeError("the destination writable stream closed before all data could be piped to it");
|
|
1709
|
+
preventCancel ? shutdown(!0, destClosed) : shutdownWithAction(() => ReadableStreamCancel(source, destClosed), !0, destClosed);
|
|
1710
|
+
}
|
|
1711
|
+
setPromiseIsHandledToTrue(pipeLoop());
|
|
1712
|
+
function waitForWritesToFinish() {
|
|
1713
|
+
let oldCurrentWrite = currentWrite;
|
|
1714
|
+
return PerformPromiseThen(currentWrite, () => oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : void 0);
|
|
1715
|
+
}
|
|
1716
|
+
function isOrBecomesErrored(stream, promise, action) {
|
|
1717
|
+
stream._state === "errored" ? action(stream._storedError) : uponRejection(promise, action);
|
|
1718
|
+
}
|
|
1719
|
+
function isOrBecomesClosed(stream, promise, action) {
|
|
1720
|
+
stream._state === "closed" ? action() : uponFulfillment(promise, action);
|
|
1721
|
+
}
|
|
1722
|
+
function shutdownWithAction(action, originalIsError, originalError) {
|
|
1723
|
+
if (shuttingDown)
|
|
1724
|
+
return;
|
|
1725
|
+
shuttingDown = !0, dest._state === "writable" && !WritableStreamCloseQueuedOrInFlight(dest) ? uponFulfillment(waitForWritesToFinish(), doTheRest) : doTheRest();
|
|
1726
|
+
function doTheRest() {
|
|
1727
|
+
return uponPromise(action(), () => finalize(originalIsError, originalError), (newError) => finalize(!0, newError)), null;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
function shutdown(isError, error) {
|
|
1731
|
+
shuttingDown || (shuttingDown = !0, dest._state === "writable" && !WritableStreamCloseQueuedOrInFlight(dest) ? uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error)) : finalize(isError, error));
|
|
1732
|
+
}
|
|
1733
|
+
function finalize(isError, error) {
|
|
1734
|
+
return WritableStreamDefaultWriterRelease(writer), ReadableStreamReaderGenericRelease(reader), signal !== void 0 && signal.removeEventListener("abort", abortAlgorithm), isError ? reject(error) : resolve(void 0), null;
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
class ReadableStreamDefaultController {
|
|
1739
|
+
constructor() {
|
|
1740
|
+
throw new TypeError("Illegal constructor");
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
|
|
1744
|
+
* over-full. An underlying source ought to use this information to determine when and how to apply backpressure.
|
|
1745
|
+
*/
|
|
1746
|
+
get desiredSize() {
|
|
1747
|
+
if (!IsReadableStreamDefaultController(this))
|
|
1748
|
+
throw defaultControllerBrandCheckException$1("desiredSize");
|
|
1749
|
+
return ReadableStreamDefaultControllerGetDesiredSize(this);
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
|
|
1753
|
+
* the stream, but once those are read, the stream will become closed.
|
|
1754
|
+
*/
|
|
1755
|
+
close() {
|
|
1756
|
+
if (!IsReadableStreamDefaultController(this))
|
|
1757
|
+
throw defaultControllerBrandCheckException$1("close");
|
|
1758
|
+
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this))
|
|
1759
|
+
throw new TypeError("The stream is not in a state that permits close");
|
|
1760
|
+
ReadableStreamDefaultControllerClose(this);
|
|
1761
|
+
}
|
|
1762
|
+
enqueue(chunk = void 0) {
|
|
1763
|
+
if (!IsReadableStreamDefaultController(this))
|
|
1764
|
+
throw defaultControllerBrandCheckException$1("enqueue");
|
|
1765
|
+
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this))
|
|
1766
|
+
throw new TypeError("The stream is not in a state that permits enqueue");
|
|
1767
|
+
return ReadableStreamDefaultControllerEnqueue(this, chunk);
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
|
|
1771
|
+
*/
|
|
1772
|
+
error(e2 = void 0) {
|
|
1773
|
+
if (!IsReadableStreamDefaultController(this))
|
|
1774
|
+
throw defaultControllerBrandCheckException$1("error");
|
|
1775
|
+
ReadableStreamDefaultControllerError(this, e2);
|
|
1776
|
+
}
|
|
1777
|
+
/** @internal */
|
|
1778
|
+
[CancelSteps](reason) {
|
|
1779
|
+
ResetQueue(this);
|
|
1780
|
+
let result = this._cancelAlgorithm(reason);
|
|
1781
|
+
return ReadableStreamDefaultControllerClearAlgorithms(this), result;
|
|
1782
|
+
}
|
|
1783
|
+
/** @internal */
|
|
1784
|
+
[PullSteps](readRequest) {
|
|
1785
|
+
let stream = this._controlledReadableStream;
|
|
1786
|
+
if (this._queue.length > 0) {
|
|
1787
|
+
let chunk = DequeueValue(this);
|
|
1788
|
+
this._closeRequested && this._queue.length === 0 ? (ReadableStreamDefaultControllerClearAlgorithms(this), ReadableStreamClose(stream)) : ReadableStreamDefaultControllerCallPullIfNeeded(this), readRequest._chunkSteps(chunk);
|
|
1789
|
+
} else
|
|
1790
|
+
ReadableStreamAddReadRequest(stream, readRequest), ReadableStreamDefaultControllerCallPullIfNeeded(this);
|
|
1791
|
+
}
|
|
1792
|
+
/** @internal */
|
|
1793
|
+
[ReleaseSteps]() {
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
Object.defineProperties(ReadableStreamDefaultController.prototype, {
|
|
1797
|
+
close: { enumerable: !0 },
|
|
1798
|
+
enqueue: { enumerable: !0 },
|
|
1799
|
+
error: { enumerable: !0 },
|
|
1800
|
+
desiredSize: { enumerable: !0 }
|
|
1801
|
+
}), setFunctionName(ReadableStreamDefaultController.prototype.close, "close"), setFunctionName(ReadableStreamDefaultController.prototype.enqueue, "enqueue"), setFunctionName(ReadableStreamDefaultController.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
1802
|
+
value: "ReadableStreamDefaultController",
|
|
1803
|
+
configurable: !0
|
|
1804
|
+
});
|
|
1805
|
+
function IsReadableStreamDefaultController(x2) {
|
|
1806
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_controlledReadableStream") ? !1 : x2 instanceof ReadableStreamDefaultController;
|
|
1807
|
+
}
|
|
1808
|
+
function ReadableStreamDefaultControllerCallPullIfNeeded(controller) {
|
|
1809
|
+
if (!ReadableStreamDefaultControllerShouldCallPull(controller))
|
|
1810
|
+
return;
|
|
1811
|
+
if (controller._pulling) {
|
|
1812
|
+
controller._pullAgain = !0;
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
controller._pulling = !0;
|
|
1816
|
+
let pullPromise = controller._pullAlgorithm();
|
|
1817
|
+
uponPromise(pullPromise, () => (controller._pulling = !1, controller._pullAgain && (controller._pullAgain = !1, ReadableStreamDefaultControllerCallPullIfNeeded(controller)), null), (e2) => (ReadableStreamDefaultControllerError(controller, e2), null));
|
|
1818
|
+
}
|
|
1819
|
+
function ReadableStreamDefaultControllerShouldCallPull(controller) {
|
|
1820
|
+
let stream = controller._controlledReadableStream;
|
|
1821
|
+
return !ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) || !controller._started ? !1 : !!(IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0 || ReadableStreamDefaultControllerGetDesiredSize(controller) > 0);
|
|
1822
|
+
}
|
|
1823
|
+
function ReadableStreamDefaultControllerClearAlgorithms(controller) {
|
|
1824
|
+
controller._pullAlgorithm = void 0, controller._cancelAlgorithm = void 0, controller._strategySizeAlgorithm = void 0;
|
|
1825
|
+
}
|
|
1826
|
+
function ReadableStreamDefaultControllerClose(controller) {
|
|
1827
|
+
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller))
|
|
1828
|
+
return;
|
|
1829
|
+
let stream = controller._controlledReadableStream;
|
|
1830
|
+
controller._closeRequested = !0, controller._queue.length === 0 && (ReadableStreamDefaultControllerClearAlgorithms(controller), ReadableStreamClose(stream));
|
|
1831
|
+
}
|
|
1832
|
+
function ReadableStreamDefaultControllerEnqueue(controller, chunk) {
|
|
1833
|
+
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller))
|
|
1834
|
+
return;
|
|
1835
|
+
let stream = controller._controlledReadableStream;
|
|
1836
|
+
if (IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0)
|
|
1837
|
+
ReadableStreamFulfillReadRequest(stream, chunk, !1);
|
|
1838
|
+
else {
|
|
1839
|
+
let chunkSize;
|
|
1840
|
+
try {
|
|
1841
|
+
chunkSize = controller._strategySizeAlgorithm(chunk);
|
|
1842
|
+
} catch (chunkSizeE) {
|
|
1843
|
+
throw ReadableStreamDefaultControllerError(controller, chunkSizeE), chunkSizeE;
|
|
1844
|
+
}
|
|
1845
|
+
try {
|
|
1846
|
+
EnqueueValueWithSize(controller, chunk, chunkSize);
|
|
1847
|
+
} catch (enqueueE) {
|
|
1848
|
+
throw ReadableStreamDefaultControllerError(controller, enqueueE), enqueueE;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
ReadableStreamDefaultControllerCallPullIfNeeded(controller);
|
|
1852
|
+
}
|
|
1853
|
+
function ReadableStreamDefaultControllerError(controller, e2) {
|
|
1854
|
+
let stream = controller._controlledReadableStream;
|
|
1855
|
+
stream._state === "readable" && (ResetQueue(controller), ReadableStreamDefaultControllerClearAlgorithms(controller), ReadableStreamError(stream, e2));
|
|
1856
|
+
}
|
|
1857
|
+
function ReadableStreamDefaultControllerGetDesiredSize(controller) {
|
|
1858
|
+
let state = controller._controlledReadableStream._state;
|
|
1859
|
+
return state === "errored" ? null : state === "closed" ? 0 : controller._strategyHWM - controller._queueTotalSize;
|
|
1860
|
+
}
|
|
1861
|
+
function ReadableStreamDefaultControllerHasBackpressure(controller) {
|
|
1862
|
+
return !ReadableStreamDefaultControllerShouldCallPull(controller);
|
|
1863
|
+
}
|
|
1864
|
+
function ReadableStreamDefaultControllerCanCloseOrEnqueue(controller) {
|
|
1865
|
+
let state = controller._controlledReadableStream._state;
|
|
1866
|
+
return !controller._closeRequested && state === "readable";
|
|
1867
|
+
}
|
|
1868
|
+
function SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm) {
|
|
1869
|
+
controller._controlledReadableStream = stream, controller._queue = void 0, controller._queueTotalSize = void 0, ResetQueue(controller), controller._started = !1, controller._closeRequested = !1, controller._pullAgain = !1, controller._pulling = !1, controller._strategySizeAlgorithm = sizeAlgorithm, controller._strategyHWM = highWaterMark, controller._pullAlgorithm = pullAlgorithm, controller._cancelAlgorithm = cancelAlgorithm, stream._readableStreamController = controller;
|
|
1870
|
+
let startResult = startAlgorithm();
|
|
1871
|
+
uponPromise(promiseResolvedWith(startResult), () => (controller._started = !0, ReadableStreamDefaultControllerCallPullIfNeeded(controller), null), (r2) => (ReadableStreamDefaultControllerError(controller, r2), null));
|
|
1872
|
+
}
|
|
1873
|
+
function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
|
|
1874
|
+
let controller = Object.create(ReadableStreamDefaultController.prototype), startAlgorithm, pullAlgorithm, cancelAlgorithm;
|
|
1875
|
+
underlyingSource.start !== void 0 ? startAlgorithm = () => underlyingSource.start(controller) : startAlgorithm = () => {
|
|
1876
|
+
}, underlyingSource.pull !== void 0 ? pullAlgorithm = () => underlyingSource.pull(controller) : pullAlgorithm = () => promiseResolvedWith(void 0), underlyingSource.cancel !== void 0 ? cancelAlgorithm = (reason) => underlyingSource.cancel(reason) : cancelAlgorithm = () => promiseResolvedWith(void 0), SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
|
|
1877
|
+
}
|
|
1878
|
+
function defaultControllerBrandCheckException$1(name) {
|
|
1879
|
+
return new TypeError(`ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`);
|
|
1880
|
+
}
|
|
1881
|
+
function ReadableStreamTee(stream, cloneForBranch2) {
|
|
1882
|
+
return IsReadableByteStreamController(stream._readableStreamController) ? ReadableByteStreamTee(stream) : ReadableStreamDefaultTee(stream);
|
|
1883
|
+
}
|
|
1884
|
+
function ReadableStreamDefaultTee(stream, cloneForBranch2) {
|
|
1885
|
+
let reader = AcquireReadableStreamDefaultReader(stream), reading = !1, readAgain = !1, canceled1 = !1, canceled2 = !1, reason1, reason2, branch1, branch2, resolveCancelPromise, cancelPromise = newPromise((resolve) => {
|
|
1886
|
+
resolveCancelPromise = resolve;
|
|
1887
|
+
});
|
|
1888
|
+
function pullAlgorithm() {
|
|
1889
|
+
return reading ? (readAgain = !0, promiseResolvedWith(void 0)) : (reading = !0, ReadableStreamDefaultReaderRead(reader, {
|
|
1890
|
+
_chunkSteps: (chunk) => {
|
|
1891
|
+
_queueMicrotask(() => {
|
|
1892
|
+
readAgain = !1;
|
|
1893
|
+
let chunk1 = chunk, chunk2 = chunk;
|
|
1894
|
+
canceled1 || ReadableStreamDefaultControllerEnqueue(branch1._readableStreamController, chunk1), canceled2 || ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, chunk2), reading = !1, readAgain && pullAlgorithm();
|
|
1895
|
+
});
|
|
1896
|
+
},
|
|
1897
|
+
_closeSteps: () => {
|
|
1898
|
+
reading = !1, canceled1 || ReadableStreamDefaultControllerClose(branch1._readableStreamController), canceled2 || ReadableStreamDefaultControllerClose(branch2._readableStreamController), (!canceled1 || !canceled2) && resolveCancelPromise(void 0);
|
|
1899
|
+
},
|
|
1900
|
+
_errorSteps: () => {
|
|
1901
|
+
reading = !1;
|
|
1902
|
+
}
|
|
1903
|
+
}), promiseResolvedWith(void 0));
|
|
1904
|
+
}
|
|
1905
|
+
function cancel1Algorithm(reason) {
|
|
1906
|
+
if (canceled1 = !0, reason1 = reason, canceled2) {
|
|
1907
|
+
let compositeReason = CreateArrayFromList([reason1, reason2]), cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
1908
|
+
resolveCancelPromise(cancelResult);
|
|
1909
|
+
}
|
|
1910
|
+
return cancelPromise;
|
|
1911
|
+
}
|
|
1912
|
+
function cancel2Algorithm(reason) {
|
|
1913
|
+
if (canceled2 = !0, reason2 = reason, canceled1) {
|
|
1914
|
+
let compositeReason = CreateArrayFromList([reason1, reason2]), cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
1915
|
+
resolveCancelPromise(cancelResult);
|
|
1916
|
+
}
|
|
1917
|
+
return cancelPromise;
|
|
1918
|
+
}
|
|
1919
|
+
function startAlgorithm() {
|
|
1920
|
+
}
|
|
1921
|
+
return branch1 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm), branch2 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm), uponRejection(reader._closedPromise, (r2) => (ReadableStreamDefaultControllerError(branch1._readableStreamController, r2), ReadableStreamDefaultControllerError(branch2._readableStreamController, r2), (!canceled1 || !canceled2) && resolveCancelPromise(void 0), null)), [branch1, branch2];
|
|
1922
|
+
}
|
|
1923
|
+
function ReadableByteStreamTee(stream) {
|
|
1924
|
+
let reader = AcquireReadableStreamDefaultReader(stream), reading = !1, readAgainForBranch1 = !1, readAgainForBranch2 = !1, canceled1 = !1, canceled2 = !1, reason1, reason2, branch1, branch2, resolveCancelPromise, cancelPromise = newPromise((resolve) => {
|
|
1925
|
+
resolveCancelPromise = resolve;
|
|
1926
|
+
});
|
|
1927
|
+
function forwardReaderError(thisReader) {
|
|
1928
|
+
uponRejection(thisReader._closedPromise, (r2) => (thisReader !== reader || (ReadableByteStreamControllerError(branch1._readableStreamController, r2), ReadableByteStreamControllerError(branch2._readableStreamController, r2), (!canceled1 || !canceled2) && resolveCancelPromise(void 0)), null));
|
|
1929
|
+
}
|
|
1930
|
+
function pullWithDefaultReader() {
|
|
1931
|
+
IsReadableStreamBYOBReader(reader) && (ReadableStreamReaderGenericRelease(reader), reader = AcquireReadableStreamDefaultReader(stream), forwardReaderError(reader)), ReadableStreamDefaultReaderRead(reader, {
|
|
1932
|
+
_chunkSteps: (chunk) => {
|
|
1933
|
+
_queueMicrotask(() => {
|
|
1934
|
+
readAgainForBranch1 = !1, readAgainForBranch2 = !1;
|
|
1935
|
+
let chunk1 = chunk, chunk2 = chunk;
|
|
1936
|
+
if (!canceled1 && !canceled2)
|
|
1937
|
+
try {
|
|
1938
|
+
chunk2 = CloneAsUint8Array(chunk);
|
|
1939
|
+
} catch (cloneE) {
|
|
1940
|
+
ReadableByteStreamControllerError(branch1._readableStreamController, cloneE), ReadableByteStreamControllerError(branch2._readableStreamController, cloneE), resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
canceled1 || ReadableByteStreamControllerEnqueue(branch1._readableStreamController, chunk1), canceled2 || ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2), reading = !1, readAgainForBranch1 ? pull1Algorithm() : readAgainForBranch2 && pull2Algorithm();
|
|
1944
|
+
});
|
|
1945
|
+
},
|
|
1946
|
+
_closeSteps: () => {
|
|
1947
|
+
reading = !1, canceled1 || ReadableByteStreamControllerClose(branch1._readableStreamController), canceled2 || ReadableByteStreamControllerClose(branch2._readableStreamController), branch1._readableStreamController._pendingPullIntos.length > 0 && ReadableByteStreamControllerRespond(branch1._readableStreamController, 0), branch2._readableStreamController._pendingPullIntos.length > 0 && ReadableByteStreamControllerRespond(branch2._readableStreamController, 0), (!canceled1 || !canceled2) && resolveCancelPromise(void 0);
|
|
1948
|
+
},
|
|
1949
|
+
_errorSteps: () => {
|
|
1950
|
+
reading = !1;
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
function pullWithBYOBReader(view, forBranch2) {
|
|
1955
|
+
IsReadableStreamDefaultReader(reader) && (ReadableStreamReaderGenericRelease(reader), reader = AcquireReadableStreamBYOBReader(stream), forwardReaderError(reader));
|
|
1956
|
+
let byobBranch = forBranch2 ? branch2 : branch1, otherBranch = forBranch2 ? branch1 : branch2;
|
|
1957
|
+
ReadableStreamBYOBReaderRead(reader, view, 1, {
|
|
1958
|
+
_chunkSteps: (chunk) => {
|
|
1959
|
+
_queueMicrotask(() => {
|
|
1960
|
+
readAgainForBranch1 = !1, readAgainForBranch2 = !1;
|
|
1961
|
+
let byobCanceled = forBranch2 ? canceled2 : canceled1;
|
|
1962
|
+
if (forBranch2 ? canceled1 : canceled2)
|
|
1963
|
+
byobCanceled || ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk);
|
|
1964
|
+
else {
|
|
1965
|
+
let clonedChunk;
|
|
1966
|
+
try {
|
|
1967
|
+
clonedChunk = CloneAsUint8Array(chunk);
|
|
1968
|
+
} catch (cloneE) {
|
|
1969
|
+
ReadableByteStreamControllerError(byobBranch._readableStreamController, cloneE), ReadableByteStreamControllerError(otherBranch._readableStreamController, cloneE), resolveCancelPromise(ReadableStreamCancel(stream, cloneE));
|
|
1970
|
+
return;
|
|
1971
|
+
}
|
|
1972
|
+
byobCanceled || ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk), ReadableByteStreamControllerEnqueue(otherBranch._readableStreamController, clonedChunk);
|
|
1973
|
+
}
|
|
1974
|
+
reading = !1, readAgainForBranch1 ? pull1Algorithm() : readAgainForBranch2 && pull2Algorithm();
|
|
1975
|
+
});
|
|
1976
|
+
},
|
|
1977
|
+
_closeSteps: (chunk) => {
|
|
1978
|
+
reading = !1;
|
|
1979
|
+
let byobCanceled = forBranch2 ? canceled2 : canceled1, otherCanceled = forBranch2 ? canceled1 : canceled2;
|
|
1980
|
+
byobCanceled || ReadableByteStreamControllerClose(byobBranch._readableStreamController), otherCanceled || ReadableByteStreamControllerClose(otherBranch._readableStreamController), chunk !== void 0 && (byobCanceled || ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk), !otherCanceled && otherBranch._readableStreamController._pendingPullIntos.length > 0 && ReadableByteStreamControllerRespond(otherBranch._readableStreamController, 0)), (!byobCanceled || !otherCanceled) && resolveCancelPromise(void 0);
|
|
1981
|
+
},
|
|
1982
|
+
_errorSteps: () => {
|
|
1983
|
+
reading = !1;
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
function pull1Algorithm() {
|
|
1988
|
+
if (reading)
|
|
1989
|
+
return readAgainForBranch1 = !0, promiseResolvedWith(void 0);
|
|
1990
|
+
reading = !0;
|
|
1991
|
+
let byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch1._readableStreamController);
|
|
1992
|
+
return byobRequest === null ? pullWithDefaultReader() : pullWithBYOBReader(byobRequest._view, !1), promiseResolvedWith(void 0);
|
|
1993
|
+
}
|
|
1994
|
+
function pull2Algorithm() {
|
|
1995
|
+
if (reading)
|
|
1996
|
+
return readAgainForBranch2 = !0, promiseResolvedWith(void 0);
|
|
1997
|
+
reading = !0;
|
|
1998
|
+
let byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch2._readableStreamController);
|
|
1999
|
+
return byobRequest === null ? pullWithDefaultReader() : pullWithBYOBReader(byobRequest._view, !0), promiseResolvedWith(void 0);
|
|
2000
|
+
}
|
|
2001
|
+
function cancel1Algorithm(reason) {
|
|
2002
|
+
if (canceled1 = !0, reason1 = reason, canceled2) {
|
|
2003
|
+
let compositeReason = CreateArrayFromList([reason1, reason2]), cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
2004
|
+
resolveCancelPromise(cancelResult);
|
|
2005
|
+
}
|
|
2006
|
+
return cancelPromise;
|
|
2007
|
+
}
|
|
2008
|
+
function cancel2Algorithm(reason) {
|
|
2009
|
+
if (canceled2 = !0, reason2 = reason, canceled1) {
|
|
2010
|
+
let compositeReason = CreateArrayFromList([reason1, reason2]), cancelResult = ReadableStreamCancel(stream, compositeReason);
|
|
2011
|
+
resolveCancelPromise(cancelResult);
|
|
2012
|
+
}
|
|
2013
|
+
return cancelPromise;
|
|
2014
|
+
}
|
|
2015
|
+
function startAlgorithm() {
|
|
2016
|
+
}
|
|
2017
|
+
return branch1 = CreateReadableByteStream(startAlgorithm, pull1Algorithm, cancel1Algorithm), branch2 = CreateReadableByteStream(startAlgorithm, pull2Algorithm, cancel2Algorithm), forwardReaderError(reader), [branch1, branch2];
|
|
2018
|
+
}
|
|
2019
|
+
function isReadableStreamLike(stream) {
|
|
2020
|
+
return typeIsObject(stream) && typeof stream.getReader < "u";
|
|
2021
|
+
}
|
|
2022
|
+
function ReadableStreamFrom(source) {
|
|
2023
|
+
return isReadableStreamLike(source) ? ReadableStreamFromDefaultReader(source.getReader()) : ReadableStreamFromIterable(source);
|
|
2024
|
+
}
|
|
2025
|
+
function ReadableStreamFromIterable(asyncIterable) {
|
|
2026
|
+
let stream, iteratorRecord = GetIterator(asyncIterable, "async"), startAlgorithm = noop;
|
|
2027
|
+
function pullAlgorithm() {
|
|
2028
|
+
let nextResult;
|
|
2029
|
+
try {
|
|
2030
|
+
nextResult = IteratorNext(iteratorRecord);
|
|
2031
|
+
} catch (e2) {
|
|
2032
|
+
return promiseRejectedWith(e2);
|
|
2033
|
+
}
|
|
2034
|
+
let nextPromise = promiseResolvedWith(nextResult);
|
|
2035
|
+
return transformPromiseWith(nextPromise, (iterResult) => {
|
|
2036
|
+
if (!typeIsObject(iterResult))
|
|
2037
|
+
throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
|
|
2038
|
+
if (IteratorComplete(iterResult))
|
|
2039
|
+
ReadableStreamDefaultControllerClose(stream._readableStreamController);
|
|
2040
|
+
else {
|
|
2041
|
+
let value = IteratorValue(iterResult);
|
|
2042
|
+
ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
function cancelAlgorithm(reason) {
|
|
2047
|
+
let iterator = iteratorRecord.iterator, returnMethod;
|
|
2048
|
+
try {
|
|
2049
|
+
returnMethod = GetMethod(iterator, "return");
|
|
2050
|
+
} catch (e2) {
|
|
2051
|
+
return promiseRejectedWith(e2);
|
|
2052
|
+
}
|
|
2053
|
+
if (returnMethod === void 0)
|
|
2054
|
+
return promiseResolvedWith(void 0);
|
|
2055
|
+
let returnResult;
|
|
2056
|
+
try {
|
|
2057
|
+
returnResult = reflectCall(returnMethod, iterator, [reason]);
|
|
2058
|
+
} catch (e2) {
|
|
2059
|
+
return promiseRejectedWith(e2);
|
|
2060
|
+
}
|
|
2061
|
+
let returnPromise = promiseResolvedWith(returnResult);
|
|
2062
|
+
return transformPromiseWith(returnPromise, (iterResult) => {
|
|
2063
|
+
if (!typeIsObject(iterResult))
|
|
2064
|
+
throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
return stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0), stream;
|
|
2068
|
+
}
|
|
2069
|
+
function ReadableStreamFromDefaultReader(reader) {
|
|
2070
|
+
let stream, startAlgorithm = noop;
|
|
2071
|
+
function pullAlgorithm() {
|
|
2072
|
+
let readPromise;
|
|
2073
|
+
try {
|
|
2074
|
+
readPromise = reader.read();
|
|
2075
|
+
} catch (e2) {
|
|
2076
|
+
return promiseRejectedWith(e2);
|
|
2077
|
+
}
|
|
2078
|
+
return transformPromiseWith(readPromise, (readResult) => {
|
|
2079
|
+
if (!typeIsObject(readResult))
|
|
2080
|
+
throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
|
|
2081
|
+
if (readResult.done)
|
|
2082
|
+
ReadableStreamDefaultControllerClose(stream._readableStreamController);
|
|
2083
|
+
else {
|
|
2084
|
+
let value = readResult.value;
|
|
2085
|
+
ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
function cancelAlgorithm(reason) {
|
|
2090
|
+
try {
|
|
2091
|
+
return promiseResolvedWith(reader.cancel(reason));
|
|
2092
|
+
} catch (e2) {
|
|
2093
|
+
return promiseRejectedWith(e2);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
return stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0), stream;
|
|
2097
|
+
}
|
|
2098
|
+
function convertUnderlyingDefaultOrByteSource(source, context) {
|
|
2099
|
+
assertDictionary(source, context);
|
|
2100
|
+
let original = source, autoAllocateChunkSize = original?.autoAllocateChunkSize, cancel = original?.cancel, pull = original?.pull, start = original?.start, type = original?.type;
|
|
2101
|
+
return {
|
|
2102
|
+
autoAllocateChunkSize: autoAllocateChunkSize === void 0 ? void 0 : convertUnsignedLongLongWithEnforceRange(autoAllocateChunkSize, `${context} has member 'autoAllocateChunkSize' that`),
|
|
2103
|
+
cancel: cancel === void 0 ? void 0 : convertUnderlyingSourceCancelCallback(cancel, original, `${context} has member 'cancel' that`),
|
|
2104
|
+
pull: pull === void 0 ? void 0 : convertUnderlyingSourcePullCallback(pull, original, `${context} has member 'pull' that`),
|
|
2105
|
+
start: start === void 0 ? void 0 : convertUnderlyingSourceStartCallback(start, original, `${context} has member 'start' that`),
|
|
2106
|
+
type: type === void 0 ? void 0 : convertReadableStreamType(type, `${context} has member 'type' that`)
|
|
2107
|
+
};
|
|
2108
|
+
}
|
|
2109
|
+
function convertUnderlyingSourceCancelCallback(fn, original, context) {
|
|
2110
|
+
return assertFunction(fn, context), (reason) => promiseCall(fn, original, [reason]);
|
|
2111
|
+
}
|
|
2112
|
+
function convertUnderlyingSourcePullCallback(fn, original, context) {
|
|
2113
|
+
return assertFunction(fn, context), (controller) => promiseCall(fn, original, [controller]);
|
|
2114
|
+
}
|
|
2115
|
+
function convertUnderlyingSourceStartCallback(fn, original, context) {
|
|
2116
|
+
return assertFunction(fn, context), (controller) => reflectCall(fn, original, [controller]);
|
|
2117
|
+
}
|
|
2118
|
+
function convertReadableStreamType(type, context) {
|
|
2119
|
+
if (type = `${type}`, type !== "bytes")
|
|
2120
|
+
throw new TypeError(`${context} '${type}' is not a valid enumeration value for ReadableStreamType`);
|
|
2121
|
+
return type;
|
|
2122
|
+
}
|
|
2123
|
+
function convertIteratorOptions(options, context) {
|
|
2124
|
+
return assertDictionary(options, context), { preventCancel: !!options?.preventCancel };
|
|
2125
|
+
}
|
|
2126
|
+
function convertPipeOptions(options, context) {
|
|
2127
|
+
assertDictionary(options, context);
|
|
2128
|
+
let preventAbort = options?.preventAbort, preventCancel = options?.preventCancel, preventClose = options?.preventClose, signal = options?.signal;
|
|
2129
|
+
return signal !== void 0 && assertAbortSignal(signal, `${context} has member 'signal' that`), {
|
|
2130
|
+
preventAbort: !!preventAbort,
|
|
2131
|
+
preventCancel: !!preventCancel,
|
|
2132
|
+
preventClose: !!preventClose,
|
|
2133
|
+
signal
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
function assertAbortSignal(signal, context) {
|
|
2137
|
+
if (!isAbortSignal(signal))
|
|
2138
|
+
throw new TypeError(`${context} is not an AbortSignal.`);
|
|
2139
|
+
}
|
|
2140
|
+
function convertReadableWritablePair(pair, context) {
|
|
2141
|
+
assertDictionary(pair, context);
|
|
2142
|
+
let readable = pair?.readable;
|
|
2143
|
+
assertRequiredField(readable, "readable", "ReadableWritablePair"), assertReadableStream(readable, `${context} has member 'readable' that`);
|
|
2144
|
+
let writable = pair?.writable;
|
|
2145
|
+
return assertRequiredField(writable, "writable", "ReadableWritablePair"), assertWritableStream(writable, `${context} has member 'writable' that`), { readable, writable };
|
|
2146
|
+
}
|
|
2147
|
+
class ReadableStream2 {
|
|
2148
|
+
constructor(rawUnderlyingSource = {}, rawStrategy = {}) {
|
|
2149
|
+
rawUnderlyingSource === void 0 ? rawUnderlyingSource = null : assertObject(rawUnderlyingSource, "First parameter");
|
|
2150
|
+
let strategy = convertQueuingStrategy(rawStrategy, "Second parameter"), underlyingSource = convertUnderlyingDefaultOrByteSource(rawUnderlyingSource, "First parameter");
|
|
2151
|
+
if (InitializeReadableStream(this), underlyingSource.type === "bytes") {
|
|
2152
|
+
if (strategy.size !== void 0)
|
|
2153
|
+
throw new RangeError("The strategy for a byte stream cannot have a size function");
|
|
2154
|
+
let highWaterMark = ExtractHighWaterMark(strategy, 0);
|
|
2155
|
+
SetUpReadableByteStreamControllerFromUnderlyingSource(this, underlyingSource, highWaterMark);
|
|
2156
|
+
} else {
|
|
2157
|
+
let sizeAlgorithm = ExtractSizeAlgorithm(strategy), highWaterMark = ExtractHighWaterMark(strategy, 1);
|
|
2158
|
+
SetUpReadableStreamDefaultControllerFromUnderlyingSource(this, underlyingSource, highWaterMark, sizeAlgorithm);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}.
|
|
2163
|
+
*/
|
|
2164
|
+
get locked() {
|
|
2165
|
+
if (!IsReadableStream(this))
|
|
2166
|
+
throw streamBrandCheckException$1("locked");
|
|
2167
|
+
return IsReadableStreamLocked(this);
|
|
2168
|
+
}
|
|
2169
|
+
/**
|
|
2170
|
+
* Cancels the stream, signaling a loss of interest in the stream by a consumer.
|
|
2171
|
+
*
|
|
2172
|
+
* The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
|
|
2173
|
+
* method, which might or might not use it.
|
|
2174
|
+
*/
|
|
2175
|
+
cancel(reason = void 0) {
|
|
2176
|
+
return IsReadableStream(this) ? IsReadableStreamLocked(this) ? promiseRejectedWith(new TypeError("Cannot cancel a stream that already has a reader")) : ReadableStreamCancel(this, reason) : promiseRejectedWith(streamBrandCheckException$1("cancel"));
|
|
2177
|
+
}
|
|
2178
|
+
getReader(rawOptions = void 0) {
|
|
2179
|
+
if (!IsReadableStream(this))
|
|
2180
|
+
throw streamBrandCheckException$1("getReader");
|
|
2181
|
+
return convertReaderOptions(rawOptions, "First parameter").mode === void 0 ? AcquireReadableStreamDefaultReader(this) : AcquireReadableStreamBYOBReader(this);
|
|
2182
|
+
}
|
|
2183
|
+
pipeThrough(rawTransform, rawOptions = {}) {
|
|
2184
|
+
if (!IsReadableStream(this))
|
|
2185
|
+
throw streamBrandCheckException$1("pipeThrough");
|
|
2186
|
+
assertRequiredArgument(rawTransform, 1, "pipeThrough");
|
|
2187
|
+
let transform = convertReadableWritablePair(rawTransform, "First parameter"), options = convertPipeOptions(rawOptions, "Second parameter");
|
|
2188
|
+
if (IsReadableStreamLocked(this))
|
|
2189
|
+
throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
|
|
2190
|
+
if (IsWritableStreamLocked(transform.writable))
|
|
2191
|
+
throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
|
|
2192
|
+
let promise = ReadableStreamPipeTo(this, transform.writable, options.preventClose, options.preventAbort, options.preventCancel, options.signal);
|
|
2193
|
+
return setPromiseIsHandledToTrue(promise), transform.readable;
|
|
2194
|
+
}
|
|
2195
|
+
pipeTo(destination, rawOptions = {}) {
|
|
2196
|
+
if (!IsReadableStream(this))
|
|
2197
|
+
return promiseRejectedWith(streamBrandCheckException$1("pipeTo"));
|
|
2198
|
+
if (destination === void 0)
|
|
2199
|
+
return promiseRejectedWith("Parameter 1 is required in 'pipeTo'.");
|
|
2200
|
+
if (!IsWritableStream(destination))
|
|
2201
|
+
return promiseRejectedWith(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
|
|
2202
|
+
let options;
|
|
2203
|
+
try {
|
|
2204
|
+
options = convertPipeOptions(rawOptions, "Second parameter");
|
|
2205
|
+
} catch (e2) {
|
|
2206
|
+
return promiseRejectedWith(e2);
|
|
2207
|
+
}
|
|
2208
|
+
return IsReadableStreamLocked(this) ? promiseRejectedWith(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : IsWritableStreamLocked(destination) ? promiseRejectedWith(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : ReadableStreamPipeTo(this, destination, options.preventClose, options.preventAbort, options.preventCancel, options.signal);
|
|
2209
|
+
}
|
|
2210
|
+
/**
|
|
2211
|
+
* Tees this readable stream, returning a two-element array containing the two resulting branches as
|
|
2212
|
+
* new {@link ReadableStream} instances.
|
|
2213
|
+
*
|
|
2214
|
+
* Teeing a stream will lock it, preventing any other consumer from acquiring a reader.
|
|
2215
|
+
* To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be
|
|
2216
|
+
* propagated to the stream's underlying source.
|
|
2217
|
+
*
|
|
2218
|
+
* Note that the chunks seen in each branch will be the same object. If the chunks are not immutable,
|
|
2219
|
+
* this could allow interference between the two branches.
|
|
2220
|
+
*/
|
|
2221
|
+
tee() {
|
|
2222
|
+
if (!IsReadableStream(this))
|
|
2223
|
+
throw streamBrandCheckException$1("tee");
|
|
2224
|
+
let branches = ReadableStreamTee(this);
|
|
2225
|
+
return CreateArrayFromList(branches);
|
|
2226
|
+
}
|
|
2227
|
+
values(rawOptions = void 0) {
|
|
2228
|
+
if (!IsReadableStream(this))
|
|
2229
|
+
throw streamBrandCheckException$1("values");
|
|
2230
|
+
let options = convertIteratorOptions(rawOptions, "First parameter");
|
|
2231
|
+
return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
|
|
2232
|
+
}
|
|
2233
|
+
[SymbolAsyncIterator](options) {
|
|
2234
|
+
return this.values(options);
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Creates a new ReadableStream wrapping the provided iterable or async iterable.
|
|
2238
|
+
*
|
|
2239
|
+
* This can be used to adapt various kinds of objects into a readable stream,
|
|
2240
|
+
* such as an array, an async generator, or a Node.js readable stream.
|
|
2241
|
+
*/
|
|
2242
|
+
static from(asyncIterable) {
|
|
2243
|
+
return ReadableStreamFrom(asyncIterable);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
Object.defineProperties(ReadableStream2, {
|
|
2247
|
+
from: { enumerable: !0 }
|
|
2248
|
+
}), Object.defineProperties(ReadableStream2.prototype, {
|
|
2249
|
+
cancel: { enumerable: !0 },
|
|
2250
|
+
getReader: { enumerable: !0 },
|
|
2251
|
+
pipeThrough: { enumerable: !0 },
|
|
2252
|
+
pipeTo: { enumerable: !0 },
|
|
2253
|
+
tee: { enumerable: !0 },
|
|
2254
|
+
values: { enumerable: !0 },
|
|
2255
|
+
locked: { enumerable: !0 }
|
|
2256
|
+
}), setFunctionName(ReadableStream2.from, "from"), setFunctionName(ReadableStream2.prototype.cancel, "cancel"), setFunctionName(ReadableStream2.prototype.getReader, "getReader"), setFunctionName(ReadableStream2.prototype.pipeThrough, "pipeThrough"), setFunctionName(ReadableStream2.prototype.pipeTo, "pipeTo"), setFunctionName(ReadableStream2.prototype.tee, "tee"), setFunctionName(ReadableStream2.prototype.values, "values"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ReadableStream2.prototype, Symbol.toStringTag, {
|
|
2257
|
+
value: "ReadableStream",
|
|
2258
|
+
configurable: !0
|
|
2259
|
+
}), Object.defineProperty(ReadableStream2.prototype, SymbolAsyncIterator, {
|
|
2260
|
+
value: ReadableStream2.prototype.values,
|
|
2261
|
+
writable: !0,
|
|
2262
|
+
configurable: !0
|
|
2263
|
+
});
|
|
2264
|
+
function CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark = 1, sizeAlgorithm = () => 1) {
|
|
2265
|
+
let stream = Object.create(ReadableStream2.prototype);
|
|
2266
|
+
InitializeReadableStream(stream);
|
|
2267
|
+
let controller = Object.create(ReadableStreamDefaultController.prototype);
|
|
2268
|
+
return SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm), stream;
|
|
2269
|
+
}
|
|
2270
|
+
function CreateReadableByteStream(startAlgorithm, pullAlgorithm, cancelAlgorithm) {
|
|
2271
|
+
let stream = Object.create(ReadableStream2.prototype);
|
|
2272
|
+
InitializeReadableStream(stream);
|
|
2273
|
+
let controller = Object.create(ReadableByteStreamController.prototype);
|
|
2274
|
+
return SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, 0, void 0), stream;
|
|
2275
|
+
}
|
|
2276
|
+
function InitializeReadableStream(stream) {
|
|
2277
|
+
stream._state = "readable", stream._reader = void 0, stream._storedError = void 0, stream._disturbed = !1;
|
|
2278
|
+
}
|
|
2279
|
+
function IsReadableStream(x2) {
|
|
2280
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_readableStreamController") ? !1 : x2 instanceof ReadableStream2;
|
|
2281
|
+
}
|
|
2282
|
+
function IsReadableStreamLocked(stream) {
|
|
2283
|
+
return stream._reader !== void 0;
|
|
2284
|
+
}
|
|
2285
|
+
function ReadableStreamCancel(stream, reason) {
|
|
2286
|
+
if (stream._disturbed = !0, stream._state === "closed")
|
|
2287
|
+
return promiseResolvedWith(void 0);
|
|
2288
|
+
if (stream._state === "errored")
|
|
2289
|
+
return promiseRejectedWith(stream._storedError);
|
|
2290
|
+
ReadableStreamClose(stream);
|
|
2291
|
+
let reader = stream._reader;
|
|
2292
|
+
if (reader !== void 0 && IsReadableStreamBYOBReader(reader)) {
|
|
2293
|
+
let readIntoRequests = reader._readIntoRequests;
|
|
2294
|
+
reader._readIntoRequests = new SimpleQueue(), readIntoRequests.forEach((readIntoRequest) => {
|
|
2295
|
+
readIntoRequest._closeSteps(void 0);
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
let sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
|
|
2299
|
+
return transformPromiseWith(sourceCancelPromise, noop);
|
|
2300
|
+
}
|
|
2301
|
+
function ReadableStreamClose(stream) {
|
|
2302
|
+
stream._state = "closed";
|
|
2303
|
+
let reader = stream._reader;
|
|
2304
|
+
if (reader !== void 0 && (defaultReaderClosedPromiseResolve(reader), IsReadableStreamDefaultReader(reader))) {
|
|
2305
|
+
let readRequests = reader._readRequests;
|
|
2306
|
+
reader._readRequests = new SimpleQueue(), readRequests.forEach((readRequest) => {
|
|
2307
|
+
readRequest._closeSteps();
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
function ReadableStreamError(stream, e2) {
|
|
2312
|
+
stream._state = "errored", stream._storedError = e2;
|
|
2313
|
+
let reader = stream._reader;
|
|
2314
|
+
reader !== void 0 && (defaultReaderClosedPromiseReject(reader, e2), IsReadableStreamDefaultReader(reader) ? ReadableStreamDefaultReaderErrorReadRequests(reader, e2) : ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2));
|
|
2315
|
+
}
|
|
2316
|
+
function streamBrandCheckException$1(name) {
|
|
2317
|
+
return new TypeError(`ReadableStream.prototype.${name} can only be used on a ReadableStream`);
|
|
2318
|
+
}
|
|
2319
|
+
function convertQueuingStrategyInit(init, context) {
|
|
2320
|
+
assertDictionary(init, context);
|
|
2321
|
+
let highWaterMark = init?.highWaterMark;
|
|
2322
|
+
return assertRequiredField(highWaterMark, "highWaterMark", "QueuingStrategyInit"), {
|
|
2323
|
+
highWaterMark: convertUnrestrictedDouble(highWaterMark)
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
let byteLengthSizeFunction = (chunk) => chunk.byteLength;
|
|
2327
|
+
setFunctionName(byteLengthSizeFunction, "size");
|
|
2328
|
+
class ByteLengthQueuingStrategy {
|
|
2329
|
+
constructor(options) {
|
|
2330
|
+
assertRequiredArgument(options, 1, "ByteLengthQueuingStrategy"), options = convertQueuingStrategyInit(options, "First parameter"), this._byteLengthQueuingStrategyHighWaterMark = options.highWaterMark;
|
|
2331
|
+
}
|
|
2332
|
+
/**
|
|
2333
|
+
* Returns the high water mark provided to the constructor.
|
|
2334
|
+
*/
|
|
2335
|
+
get highWaterMark() {
|
|
2336
|
+
if (!IsByteLengthQueuingStrategy(this))
|
|
2337
|
+
throw byteLengthBrandCheckException("highWaterMark");
|
|
2338
|
+
return this._byteLengthQueuingStrategyHighWaterMark;
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Measures the size of `chunk` by returning the value of its `byteLength` property.
|
|
2342
|
+
*/
|
|
2343
|
+
get size() {
|
|
2344
|
+
if (!IsByteLengthQueuingStrategy(this))
|
|
2345
|
+
throw byteLengthBrandCheckException("size");
|
|
2346
|
+
return byteLengthSizeFunction;
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
Object.defineProperties(ByteLengthQueuingStrategy.prototype, {
|
|
2350
|
+
highWaterMark: { enumerable: !0 },
|
|
2351
|
+
size: { enumerable: !0 }
|
|
2352
|
+
}), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
|
|
2353
|
+
value: "ByteLengthQueuingStrategy",
|
|
2354
|
+
configurable: !0
|
|
2355
|
+
});
|
|
2356
|
+
function byteLengthBrandCheckException(name) {
|
|
2357
|
+
return new TypeError(`ByteLengthQueuingStrategy.prototype.${name} can only be used on a ByteLengthQueuingStrategy`);
|
|
2358
|
+
}
|
|
2359
|
+
function IsByteLengthQueuingStrategy(x2) {
|
|
2360
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_byteLengthQueuingStrategyHighWaterMark") ? !1 : x2 instanceof ByteLengthQueuingStrategy;
|
|
2361
|
+
}
|
|
2362
|
+
let countSizeFunction = () => 1;
|
|
2363
|
+
setFunctionName(countSizeFunction, "size");
|
|
2364
|
+
class CountQueuingStrategy {
|
|
2365
|
+
constructor(options) {
|
|
2366
|
+
assertRequiredArgument(options, 1, "CountQueuingStrategy"), options = convertQueuingStrategyInit(options, "First parameter"), this._countQueuingStrategyHighWaterMark = options.highWaterMark;
|
|
2367
|
+
}
|
|
2368
|
+
/**
|
|
2369
|
+
* Returns the high water mark provided to the constructor.
|
|
2370
|
+
*/
|
|
2371
|
+
get highWaterMark() {
|
|
2372
|
+
if (!IsCountQueuingStrategy(this))
|
|
2373
|
+
throw countBrandCheckException("highWaterMark");
|
|
2374
|
+
return this._countQueuingStrategyHighWaterMark;
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Measures the size of `chunk` by always returning 1.
|
|
2378
|
+
* This ensures that the total queue size is a count of the number of chunks in the queue.
|
|
2379
|
+
*/
|
|
2380
|
+
get size() {
|
|
2381
|
+
if (!IsCountQueuingStrategy(this))
|
|
2382
|
+
throw countBrandCheckException("size");
|
|
2383
|
+
return countSizeFunction;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
Object.defineProperties(CountQueuingStrategy.prototype, {
|
|
2387
|
+
highWaterMark: { enumerable: !0 },
|
|
2388
|
+
size: { enumerable: !0 }
|
|
2389
|
+
}), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
|
|
2390
|
+
value: "CountQueuingStrategy",
|
|
2391
|
+
configurable: !0
|
|
2392
|
+
});
|
|
2393
|
+
function countBrandCheckException(name) {
|
|
2394
|
+
return new TypeError(`CountQueuingStrategy.prototype.${name} can only be used on a CountQueuingStrategy`);
|
|
2395
|
+
}
|
|
2396
|
+
function IsCountQueuingStrategy(x2) {
|
|
2397
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_countQueuingStrategyHighWaterMark") ? !1 : x2 instanceof CountQueuingStrategy;
|
|
2398
|
+
}
|
|
2399
|
+
function convertTransformer(original, context) {
|
|
2400
|
+
assertDictionary(original, context);
|
|
2401
|
+
let cancel = original?.cancel, flush = original?.flush, readableType = original?.readableType, start = original?.start, transform = original?.transform, writableType = original?.writableType;
|
|
2402
|
+
return {
|
|
2403
|
+
cancel: cancel === void 0 ? void 0 : convertTransformerCancelCallback(cancel, original, `${context} has member 'cancel' that`),
|
|
2404
|
+
flush: flush === void 0 ? void 0 : convertTransformerFlushCallback(flush, original, `${context} has member 'flush' that`),
|
|
2405
|
+
readableType,
|
|
2406
|
+
start: start === void 0 ? void 0 : convertTransformerStartCallback(start, original, `${context} has member 'start' that`),
|
|
2407
|
+
transform: transform === void 0 ? void 0 : convertTransformerTransformCallback(transform, original, `${context} has member 'transform' that`),
|
|
2408
|
+
writableType
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
function convertTransformerFlushCallback(fn, original, context) {
|
|
2412
|
+
return assertFunction(fn, context), (controller) => promiseCall(fn, original, [controller]);
|
|
2413
|
+
}
|
|
2414
|
+
function convertTransformerStartCallback(fn, original, context) {
|
|
2415
|
+
return assertFunction(fn, context), (controller) => reflectCall(fn, original, [controller]);
|
|
2416
|
+
}
|
|
2417
|
+
function convertTransformerTransformCallback(fn, original, context) {
|
|
2418
|
+
return assertFunction(fn, context), (chunk, controller) => promiseCall(fn, original, [chunk, controller]);
|
|
2419
|
+
}
|
|
2420
|
+
function convertTransformerCancelCallback(fn, original, context) {
|
|
2421
|
+
return assertFunction(fn, context), (reason) => promiseCall(fn, original, [reason]);
|
|
2422
|
+
}
|
|
2423
|
+
class TransformStream {
|
|
2424
|
+
constructor(rawTransformer = {}, rawWritableStrategy = {}, rawReadableStrategy = {}) {
|
|
2425
|
+
rawTransformer === void 0 && (rawTransformer = null);
|
|
2426
|
+
let writableStrategy = convertQueuingStrategy(rawWritableStrategy, "Second parameter"), readableStrategy = convertQueuingStrategy(rawReadableStrategy, "Third parameter"), transformer = convertTransformer(rawTransformer, "First parameter");
|
|
2427
|
+
if (transformer.readableType !== void 0)
|
|
2428
|
+
throw new RangeError("Invalid readableType specified");
|
|
2429
|
+
if (transformer.writableType !== void 0)
|
|
2430
|
+
throw new RangeError("Invalid writableType specified");
|
|
2431
|
+
let readableHighWaterMark = ExtractHighWaterMark(readableStrategy, 0), readableSizeAlgorithm = ExtractSizeAlgorithm(readableStrategy), writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1), writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy), startPromise_resolve, startPromise = newPromise((resolve) => {
|
|
2432
|
+
startPromise_resolve = resolve;
|
|
2433
|
+
});
|
|
2434
|
+
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm), SetUpTransformStreamDefaultControllerFromTransformer(this, transformer), transformer.start !== void 0 ? startPromise_resolve(transformer.start(this._transformStreamController)) : startPromise_resolve(void 0);
|
|
2435
|
+
}
|
|
2436
|
+
/**
|
|
2437
|
+
* The readable side of the transform stream.
|
|
2438
|
+
*/
|
|
2439
|
+
get readable() {
|
|
2440
|
+
if (!IsTransformStream(this))
|
|
2441
|
+
throw streamBrandCheckException("readable");
|
|
2442
|
+
return this._readable;
|
|
2443
|
+
}
|
|
2444
|
+
/**
|
|
2445
|
+
* The writable side of the transform stream.
|
|
2446
|
+
*/
|
|
2447
|
+
get writable() {
|
|
2448
|
+
if (!IsTransformStream(this))
|
|
2449
|
+
throw streamBrandCheckException("writable");
|
|
2450
|
+
return this._writable;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
Object.defineProperties(TransformStream.prototype, {
|
|
2454
|
+
readable: { enumerable: !0 },
|
|
2455
|
+
writable: { enumerable: !0 }
|
|
2456
|
+
}), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
|
|
2457
|
+
value: "TransformStream",
|
|
2458
|
+
configurable: !0
|
|
2459
|
+
});
|
|
2460
|
+
function InitializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm) {
|
|
2461
|
+
function startAlgorithm() {
|
|
2462
|
+
return startPromise;
|
|
2463
|
+
}
|
|
2464
|
+
function writeAlgorithm(chunk) {
|
|
2465
|
+
return TransformStreamDefaultSinkWriteAlgorithm(stream, chunk);
|
|
2466
|
+
}
|
|
2467
|
+
function abortAlgorithm(reason) {
|
|
2468
|
+
return TransformStreamDefaultSinkAbortAlgorithm(stream, reason);
|
|
2469
|
+
}
|
|
2470
|
+
function closeAlgorithm() {
|
|
2471
|
+
return TransformStreamDefaultSinkCloseAlgorithm(stream);
|
|
2472
|
+
}
|
|
2473
|
+
stream._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);
|
|
2474
|
+
function pullAlgorithm() {
|
|
2475
|
+
return TransformStreamDefaultSourcePullAlgorithm(stream);
|
|
2476
|
+
}
|
|
2477
|
+
function cancelAlgorithm(reason) {
|
|
2478
|
+
return TransformStreamDefaultSourceCancelAlgorithm(stream, reason);
|
|
2479
|
+
}
|
|
2480
|
+
stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm), stream._backpressure = void 0, stream._backpressureChangePromise = void 0, stream._backpressureChangePromise_resolve = void 0, TransformStreamSetBackpressure(stream, !0), stream._transformStreamController = void 0;
|
|
2481
|
+
}
|
|
2482
|
+
function IsTransformStream(x2) {
|
|
2483
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_transformStreamController") ? !1 : x2 instanceof TransformStream;
|
|
2484
|
+
}
|
|
2485
|
+
function TransformStreamError(stream, e2) {
|
|
2486
|
+
ReadableStreamDefaultControllerError(stream._readable._readableStreamController, e2), TransformStreamErrorWritableAndUnblockWrite(stream, e2);
|
|
2487
|
+
}
|
|
2488
|
+
function TransformStreamErrorWritableAndUnblockWrite(stream, e2) {
|
|
2489
|
+
TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController), WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e2), TransformStreamUnblockWrite(stream);
|
|
2490
|
+
}
|
|
2491
|
+
function TransformStreamUnblockWrite(stream) {
|
|
2492
|
+
stream._backpressure && TransformStreamSetBackpressure(stream, !1);
|
|
2493
|
+
}
|
|
2494
|
+
function TransformStreamSetBackpressure(stream, backpressure) {
|
|
2495
|
+
stream._backpressureChangePromise !== void 0 && stream._backpressureChangePromise_resolve(), stream._backpressureChangePromise = newPromise((resolve) => {
|
|
2496
|
+
stream._backpressureChangePromise_resolve = resolve;
|
|
2497
|
+
}), stream._backpressure = backpressure;
|
|
2498
|
+
}
|
|
2499
|
+
class TransformStreamDefaultController {
|
|
2500
|
+
constructor() {
|
|
2501
|
+
throw new TypeError("Illegal constructor");
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Returns the desired size to fill the readable side’s internal queue. It can be negative, if the queue is over-full.
|
|
2505
|
+
*/
|
|
2506
|
+
get desiredSize() {
|
|
2507
|
+
if (!IsTransformStreamDefaultController(this))
|
|
2508
|
+
throw defaultControllerBrandCheckException("desiredSize");
|
|
2509
|
+
let readableController = this._controlledTransformStream._readable._readableStreamController;
|
|
2510
|
+
return ReadableStreamDefaultControllerGetDesiredSize(readableController);
|
|
2511
|
+
}
|
|
2512
|
+
enqueue(chunk = void 0) {
|
|
2513
|
+
if (!IsTransformStreamDefaultController(this))
|
|
2514
|
+
throw defaultControllerBrandCheckException("enqueue");
|
|
2515
|
+
TransformStreamDefaultControllerEnqueue(this, chunk);
|
|
2516
|
+
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Errors both the readable side and the writable side of the controlled transform stream, making all future
|
|
2519
|
+
* interactions with it fail with the given error `e`. Any chunks queued for transformation will be discarded.
|
|
2520
|
+
*/
|
|
2521
|
+
error(reason = void 0) {
|
|
2522
|
+
if (!IsTransformStreamDefaultController(this))
|
|
2523
|
+
throw defaultControllerBrandCheckException("error");
|
|
2524
|
+
TransformStreamDefaultControllerError(this, reason);
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Closes the readable side and errors the writable side of the controlled transform stream. This is useful when the
|
|
2528
|
+
* transformer only needs to consume a portion of the chunks written to the writable side.
|
|
2529
|
+
*/
|
|
2530
|
+
terminate() {
|
|
2531
|
+
if (!IsTransformStreamDefaultController(this))
|
|
2532
|
+
throw defaultControllerBrandCheckException("terminate");
|
|
2533
|
+
TransformStreamDefaultControllerTerminate(this);
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
Object.defineProperties(TransformStreamDefaultController.prototype, {
|
|
2537
|
+
enqueue: { enumerable: !0 },
|
|
2538
|
+
error: { enumerable: !0 },
|
|
2539
|
+
terminate: { enumerable: !0 },
|
|
2540
|
+
desiredSize: { enumerable: !0 }
|
|
2541
|
+
}), setFunctionName(TransformStreamDefaultController.prototype.enqueue, "enqueue"), setFunctionName(TransformStreamDefaultController.prototype.error, "error"), setFunctionName(TransformStreamDefaultController.prototype.terminate, "terminate"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
2542
|
+
value: "TransformStreamDefaultController",
|
|
2543
|
+
configurable: !0
|
|
2544
|
+
});
|
|
2545
|
+
function IsTransformStreamDefaultController(x2) {
|
|
2546
|
+
return !typeIsObject(x2) || !Object.prototype.hasOwnProperty.call(x2, "_controlledTransformStream") ? !1 : x2 instanceof TransformStreamDefaultController;
|
|
2547
|
+
}
|
|
2548
|
+
function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm) {
|
|
2549
|
+
controller._controlledTransformStream = stream, stream._transformStreamController = controller, controller._transformAlgorithm = transformAlgorithm, controller._flushAlgorithm = flushAlgorithm, controller._cancelAlgorithm = cancelAlgorithm, controller._finishPromise = void 0, controller._finishPromise_resolve = void 0, controller._finishPromise_reject = void 0;
|
|
2550
|
+
}
|
|
2551
|
+
function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
|
|
2552
|
+
let controller = Object.create(TransformStreamDefaultController.prototype), transformAlgorithm, flushAlgorithm, cancelAlgorithm;
|
|
2553
|
+
transformer.transform !== void 0 ? transformAlgorithm = (chunk) => transformer.transform(chunk, controller) : transformAlgorithm = (chunk) => {
|
|
2554
|
+
try {
|
|
2555
|
+
return TransformStreamDefaultControllerEnqueue(controller, chunk), promiseResolvedWith(void 0);
|
|
2556
|
+
} catch (transformResultE) {
|
|
2557
|
+
return promiseRejectedWith(transformResultE);
|
|
2558
|
+
}
|
|
2559
|
+
}, transformer.flush !== void 0 ? flushAlgorithm = () => transformer.flush(controller) : flushAlgorithm = () => promiseResolvedWith(void 0), transformer.cancel !== void 0 ? cancelAlgorithm = (reason) => transformer.cancel(reason) : cancelAlgorithm = () => promiseResolvedWith(void 0), SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
|
|
2560
|
+
}
|
|
2561
|
+
function TransformStreamDefaultControllerClearAlgorithms(controller) {
|
|
2562
|
+
controller._transformAlgorithm = void 0, controller._flushAlgorithm = void 0, controller._cancelAlgorithm = void 0;
|
|
2563
|
+
}
|
|
2564
|
+
function TransformStreamDefaultControllerEnqueue(controller, chunk) {
|
|
2565
|
+
let stream = controller._controlledTransformStream, readableController = stream._readable._readableStreamController;
|
|
2566
|
+
if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController))
|
|
2567
|
+
throw new TypeError("Readable side is not in a state that permits enqueue");
|
|
2568
|
+
try {
|
|
2569
|
+
ReadableStreamDefaultControllerEnqueue(readableController, chunk);
|
|
2570
|
+
} catch (e2) {
|
|
2571
|
+
throw TransformStreamErrorWritableAndUnblockWrite(stream, e2), stream._readable._storedError;
|
|
2572
|
+
}
|
|
2573
|
+
ReadableStreamDefaultControllerHasBackpressure(readableController) !== stream._backpressure && TransformStreamSetBackpressure(stream, !0);
|
|
2574
|
+
}
|
|
2575
|
+
function TransformStreamDefaultControllerError(controller, e2) {
|
|
2576
|
+
TransformStreamError(controller._controlledTransformStream, e2);
|
|
2577
|
+
}
|
|
2578
|
+
function TransformStreamDefaultControllerPerformTransform(controller, chunk) {
|
|
2579
|
+
let transformPromise = controller._transformAlgorithm(chunk);
|
|
2580
|
+
return transformPromiseWith(transformPromise, void 0, (r2) => {
|
|
2581
|
+
throw TransformStreamError(controller._controlledTransformStream, r2), r2;
|
|
2582
|
+
});
|
|
2583
|
+
}
|
|
2584
|
+
function TransformStreamDefaultControllerTerminate(controller) {
|
|
2585
|
+
let stream = controller._controlledTransformStream, readableController = stream._readable._readableStreamController;
|
|
2586
|
+
ReadableStreamDefaultControllerClose(readableController);
|
|
2587
|
+
let error = new TypeError("TransformStream terminated");
|
|
2588
|
+
TransformStreamErrorWritableAndUnblockWrite(stream, error);
|
|
2589
|
+
}
|
|
2590
|
+
function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
|
|
2591
|
+
let controller = stream._transformStreamController;
|
|
2592
|
+
if (stream._backpressure) {
|
|
2593
|
+
let backpressureChangePromise = stream._backpressureChangePromise;
|
|
2594
|
+
return transformPromiseWith(backpressureChangePromise, () => {
|
|
2595
|
+
let writable = stream._writable;
|
|
2596
|
+
if (writable._state === "erroring")
|
|
2597
|
+
throw writable._storedError;
|
|
2598
|
+
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
return TransformStreamDefaultControllerPerformTransform(controller, chunk);
|
|
2602
|
+
}
|
|
2603
|
+
function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
|
|
2604
|
+
let controller = stream._transformStreamController;
|
|
2605
|
+
if (controller._finishPromise !== void 0)
|
|
2606
|
+
return controller._finishPromise;
|
|
2607
|
+
let readable = stream._readable;
|
|
2608
|
+
controller._finishPromise = newPromise((resolve, reject) => {
|
|
2609
|
+
controller._finishPromise_resolve = resolve, controller._finishPromise_reject = reject;
|
|
2610
|
+
});
|
|
2611
|
+
let cancelPromise = controller._cancelAlgorithm(reason);
|
|
2612
|
+
return TransformStreamDefaultControllerClearAlgorithms(controller), uponPromise(cancelPromise, () => (readable._state === "errored" ? defaultControllerFinishPromiseReject(controller, readable._storedError) : (ReadableStreamDefaultControllerError(readable._readableStreamController, reason), defaultControllerFinishPromiseResolve(controller)), null), (r2) => (ReadableStreamDefaultControllerError(readable._readableStreamController, r2), defaultControllerFinishPromiseReject(controller, r2), null)), controller._finishPromise;
|
|
2613
|
+
}
|
|
2614
|
+
function TransformStreamDefaultSinkCloseAlgorithm(stream) {
|
|
2615
|
+
let controller = stream._transformStreamController;
|
|
2616
|
+
if (controller._finishPromise !== void 0)
|
|
2617
|
+
return controller._finishPromise;
|
|
2618
|
+
let readable = stream._readable;
|
|
2619
|
+
controller._finishPromise = newPromise((resolve, reject) => {
|
|
2620
|
+
controller._finishPromise_resolve = resolve, controller._finishPromise_reject = reject;
|
|
2621
|
+
});
|
|
2622
|
+
let flushPromise = controller._flushAlgorithm();
|
|
2623
|
+
return TransformStreamDefaultControllerClearAlgorithms(controller), uponPromise(flushPromise, () => (readable._state === "errored" ? defaultControllerFinishPromiseReject(controller, readable._storedError) : (ReadableStreamDefaultControllerClose(readable._readableStreamController), defaultControllerFinishPromiseResolve(controller)), null), (r2) => (ReadableStreamDefaultControllerError(readable._readableStreamController, r2), defaultControllerFinishPromiseReject(controller, r2), null)), controller._finishPromise;
|
|
2624
|
+
}
|
|
2625
|
+
function TransformStreamDefaultSourcePullAlgorithm(stream) {
|
|
2626
|
+
return TransformStreamSetBackpressure(stream, !1), stream._backpressureChangePromise;
|
|
2627
|
+
}
|
|
2628
|
+
function TransformStreamDefaultSourceCancelAlgorithm(stream, reason) {
|
|
2629
|
+
let controller = stream._transformStreamController;
|
|
2630
|
+
if (controller._finishPromise !== void 0)
|
|
2631
|
+
return controller._finishPromise;
|
|
2632
|
+
let writable = stream._writable;
|
|
2633
|
+
controller._finishPromise = newPromise((resolve, reject) => {
|
|
2634
|
+
controller._finishPromise_resolve = resolve, controller._finishPromise_reject = reject;
|
|
2635
|
+
});
|
|
2636
|
+
let cancelPromise = controller._cancelAlgorithm(reason);
|
|
2637
|
+
return TransformStreamDefaultControllerClearAlgorithms(controller), uponPromise(cancelPromise, () => (writable._state === "errored" ? defaultControllerFinishPromiseReject(controller, writable._storedError) : (WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, reason), TransformStreamUnblockWrite(stream), defaultControllerFinishPromiseResolve(controller)), null), (r2) => (WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, r2), TransformStreamUnblockWrite(stream), defaultControllerFinishPromiseReject(controller, r2), null)), controller._finishPromise;
|
|
2638
|
+
}
|
|
2639
|
+
function defaultControllerBrandCheckException(name) {
|
|
2640
|
+
return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
|
|
2641
|
+
}
|
|
2642
|
+
function defaultControllerFinishPromiseResolve(controller) {
|
|
2643
|
+
controller._finishPromise_resolve !== void 0 && (controller._finishPromise_resolve(), controller._finishPromise_resolve = void 0, controller._finishPromise_reject = void 0);
|
|
2644
|
+
}
|
|
2645
|
+
function defaultControllerFinishPromiseReject(controller, reason) {
|
|
2646
|
+
controller._finishPromise_reject !== void 0 && (setPromiseIsHandledToTrue(controller._finishPromise), controller._finishPromise_reject(reason), controller._finishPromise_resolve = void 0, controller._finishPromise_reject = void 0);
|
|
2647
|
+
}
|
|
2648
|
+
function streamBrandCheckException(name) {
|
|
2649
|
+
return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
|
|
2650
|
+
}
|
|
2651
|
+
exports2.ByteLengthQueuingStrategy = ByteLengthQueuingStrategy, exports2.CountQueuingStrategy = CountQueuingStrategy, exports2.ReadableByteStreamController = ReadableByteStreamController, exports2.ReadableStream = ReadableStream2, exports2.ReadableStreamBYOBReader = ReadableStreamBYOBReader, exports2.ReadableStreamBYOBRequest = ReadableStreamBYOBRequest, exports2.ReadableStreamDefaultController = ReadableStreamDefaultController, exports2.ReadableStreamDefaultReader = ReadableStreamDefaultReader, exports2.TransformStream = TransformStream, exports2.TransformStreamDefaultController = TransformStreamDefaultController, exports2.WritableStream = WritableStream, exports2.WritableStreamDefaultController = WritableStreamDefaultController, exports2.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
|
|
2656
|
+
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/streams.cjs
|
|
2657
|
+
var require_streams = __commonJS({
|
|
2658
|
+
"../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/streams.cjs"() {
|
|
2659
|
+
init_cjs_shims();
|
|
2660
|
+
if (!globalThis.ReadableStream)
|
|
2661
|
+
try {
|
|
2662
|
+
let process = __require("node:process"), { emitWarning } = process;
|
|
2663
|
+
try {
|
|
2664
|
+
process.emitWarning = () => {
|
|
2665
|
+
}, Object.assign(globalThis, __require("node:stream/web")), process.emitWarning = emitWarning;
|
|
2666
|
+
} catch (error) {
|
|
2667
|
+
throw process.emitWarning = emitWarning, error;
|
|
2668
|
+
}
|
|
2669
|
+
} catch {
|
|
2670
|
+
Object.assign(globalThis, require_ponyfill_es2018());
|
|
2671
|
+
}
|
|
2672
|
+
try {
|
|
2673
|
+
let { Blob: Blob3 } = __require("buffer");
|
|
2674
|
+
Blob3 && !Blob3.prototype.stream && (Blob3.prototype.stream = function(params) {
|
|
2675
|
+
let position = 0, blob = this;
|
|
2676
|
+
return new ReadableStream({
|
|
2677
|
+
type: "bytes",
|
|
2678
|
+
async pull(ctrl) {
|
|
2679
|
+
let buffer = await blob.slice(position, Math.min(blob.size, position + 65536)).arrayBuffer();
|
|
2680
|
+
position += buffer.byteLength, ctrl.enqueue(new Uint8Array(buffer)), position === blob.size && ctrl.close();
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2683
|
+
});
|
|
2684
|
+
} catch {
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
});
|
|
2688
|
+
|
|
2689
|
+
// ../../node_modules/.pnpm/node-domexception@1.0.0/node_modules/node-domexception/index.js
|
|
2690
|
+
var require_node_domexception = __commonJS({
|
|
2691
|
+
"../../node_modules/.pnpm/node-domexception@1.0.0/node_modules/node-domexception/index.js"(exports, module) {
|
|
2692
|
+
init_cjs_shims();
|
|
2693
|
+
if (!globalThis.DOMException)
|
|
2694
|
+
try {
|
|
2695
|
+
let { MessageChannel } = __require("worker_threads"), port = new MessageChannel().port1, ab = new ArrayBuffer();
|
|
2696
|
+
port.postMessage(ab, [ab, ab]);
|
|
2697
|
+
} catch (err) {
|
|
2698
|
+
err.constructor.name === "DOMException" && (globalThis.DOMException = err.constructor);
|
|
2699
|
+
}
|
|
2700
|
+
module.exports = globalThis.DOMException;
|
|
2701
|
+
}
|
|
2702
|
+
});
|
|
2703
|
+
|
|
2704
|
+
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
|
|
2705
|
+
init_cjs_shims();
|
|
2706
|
+
|
|
2707
|
+
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js
|
|
2708
|
+
init_cjs_shims();
|
|
2709
|
+
var import_streams = __toESM(require_streams(), 1);
|
|
2710
|
+
var POOL_SIZE = 65536;
|
|
2711
|
+
async function* toIterator(parts, clone = !0) {
|
|
2712
|
+
for (let part of parts)
|
|
2713
|
+
if ("stream" in part)
|
|
2714
|
+
yield* (
|
|
2715
|
+
/** @type {AsyncIterableIterator<Uint8Array>} */
|
|
2716
|
+
part.stream()
|
|
2717
|
+
);
|
|
2718
|
+
else if (ArrayBuffer.isView(part))
|
|
2719
|
+
if (clone) {
|
|
2720
|
+
let position = part.byteOffset, end = part.byteOffset + part.byteLength;
|
|
2721
|
+
for (; position !== end; ) {
|
|
2722
|
+
let size = Math.min(end - position, POOL_SIZE), chunk = part.buffer.slice(position, position + size);
|
|
2723
|
+
position += chunk.byteLength, yield new Uint8Array(chunk);
|
|
2724
|
+
}
|
|
2725
|
+
} else
|
|
2726
|
+
yield part;
|
|
2727
|
+
else {
|
|
2728
|
+
let position = 0, b = (
|
|
2729
|
+
/** @type {Blob} */
|
|
2730
|
+
part
|
|
2731
|
+
);
|
|
2732
|
+
for (; position !== b.size; ) {
|
|
2733
|
+
let buffer = await b.slice(position, Math.min(b.size, position + POOL_SIZE)).arrayBuffer();
|
|
2734
|
+
position += buffer.byteLength, yield new Uint8Array(buffer);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
var _Blob = class Blob {
|
|
2739
|
+
/** @type {Array.<(Blob|Uint8Array)>} */
|
|
2740
|
+
#parts = [];
|
|
2741
|
+
#type = "";
|
|
2742
|
+
#size = 0;
|
|
2743
|
+
#endings = "transparent";
|
|
2744
|
+
/**
|
|
2745
|
+
* The Blob() constructor returns a new Blob object. The content
|
|
2746
|
+
* of the blob consists of the concatenation of the values given
|
|
2747
|
+
* in the parameter array.
|
|
2748
|
+
*
|
|
2749
|
+
* @param {*} blobParts
|
|
2750
|
+
* @param {{ type?: string, endings?: string }} [options]
|
|
2751
|
+
*/
|
|
2752
|
+
constructor(blobParts = [], options = {}) {
|
|
2753
|
+
if (typeof blobParts != "object" || blobParts === null)
|
|
2754
|
+
throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
|
|
2755
|
+
if (typeof blobParts[Symbol.iterator] != "function")
|
|
2756
|
+
throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
|
|
2757
|
+
if (typeof options != "object" && typeof options != "function")
|
|
2758
|
+
throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
|
|
2759
|
+
options === null && (options = {});
|
|
2760
|
+
let encoder = new TextEncoder();
|
|
2761
|
+
for (let element of blobParts) {
|
|
2762
|
+
let part;
|
|
2763
|
+
ArrayBuffer.isView(element) ? part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength)) : element instanceof ArrayBuffer ? part = new Uint8Array(element.slice(0)) : element instanceof Blob ? part = element : part = encoder.encode(`${element}`), this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size, this.#parts.push(part);
|
|
2764
|
+
}
|
|
2765
|
+
this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
|
|
2766
|
+
let type = options.type === void 0 ? "" : String(options.type);
|
|
2767
|
+
this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
|
|
2768
|
+
}
|
|
2769
|
+
/**
|
|
2770
|
+
* The Blob interface's size property returns the
|
|
2771
|
+
* size of the Blob in bytes.
|
|
2772
|
+
*/
|
|
2773
|
+
get size() {
|
|
2774
|
+
return this.#size;
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* The type property of a Blob object returns the MIME type of the file.
|
|
2778
|
+
*/
|
|
2779
|
+
get type() {
|
|
2780
|
+
return this.#type;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* The text() method in the Blob interface returns a Promise
|
|
2784
|
+
* that resolves with a string containing the contents of
|
|
2785
|
+
* the blob, interpreted as UTF-8.
|
|
2786
|
+
*
|
|
2787
|
+
* @return {Promise<string>}
|
|
2788
|
+
*/
|
|
2789
|
+
async text() {
|
|
2790
|
+
let decoder = new TextDecoder(), str = "";
|
|
2791
|
+
for await (let part of toIterator(this.#parts, !1))
|
|
2792
|
+
str += decoder.decode(part, { stream: !0 });
|
|
2793
|
+
return str += decoder.decode(), str;
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* The arrayBuffer() method in the Blob interface returns a
|
|
2797
|
+
* Promise that resolves with the contents of the blob as
|
|
2798
|
+
* binary data contained in an ArrayBuffer.
|
|
2799
|
+
*
|
|
2800
|
+
* @return {Promise<ArrayBuffer>}
|
|
2801
|
+
*/
|
|
2802
|
+
async arrayBuffer() {
|
|
2803
|
+
let data = new Uint8Array(this.size), offset = 0;
|
|
2804
|
+
for await (let chunk of toIterator(this.#parts, !1))
|
|
2805
|
+
data.set(chunk, offset), offset += chunk.length;
|
|
2806
|
+
return data.buffer;
|
|
2807
|
+
}
|
|
2808
|
+
stream() {
|
|
2809
|
+
let it = toIterator(this.#parts, !0);
|
|
2810
|
+
return new globalThis.ReadableStream({
|
|
2811
|
+
// @ts-ignore
|
|
2812
|
+
type: "bytes",
|
|
2813
|
+
async pull(ctrl) {
|
|
2814
|
+
let chunk = await it.next();
|
|
2815
|
+
chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
|
|
2816
|
+
},
|
|
2817
|
+
async cancel() {
|
|
2818
|
+
await it.return();
|
|
2819
|
+
}
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* The Blob interface's slice() method creates and returns a
|
|
2824
|
+
* new Blob object which contains data from a subset of the
|
|
2825
|
+
* blob on which it's called.
|
|
2826
|
+
*
|
|
2827
|
+
* @param {number} [start]
|
|
2828
|
+
* @param {number} [end]
|
|
2829
|
+
* @param {string} [type]
|
|
2830
|
+
*/
|
|
2831
|
+
slice(start = 0, end = this.size, type = "") {
|
|
2832
|
+
let { size } = this, relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size), relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size), span = Math.max(relativeEnd - relativeStart, 0), parts = this.#parts, blobParts = [], added = 0;
|
|
2833
|
+
for (let part of parts) {
|
|
2834
|
+
if (added >= span)
|
|
2835
|
+
break;
|
|
2836
|
+
let size2 = ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
2837
|
+
if (relativeStart && size2 <= relativeStart)
|
|
2838
|
+
relativeStart -= size2, relativeEnd -= size2;
|
|
2839
|
+
else {
|
|
2840
|
+
let chunk;
|
|
2841
|
+
ArrayBuffer.isView(part) ? (chunk = part.subarray(relativeStart, Math.min(size2, relativeEnd)), added += chunk.byteLength) : (chunk = part.slice(relativeStart, Math.min(size2, relativeEnd)), added += chunk.size), relativeEnd -= size2, blobParts.push(chunk), relativeStart = 0;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
let blob = new Blob([], { type: String(type).toLowerCase() });
|
|
2845
|
+
return blob.#size = span, blob.#parts = blobParts, blob;
|
|
2846
|
+
}
|
|
2847
|
+
get [Symbol.toStringTag]() {
|
|
2848
|
+
return "Blob";
|
|
2849
|
+
}
|
|
2850
|
+
static [Symbol.hasInstance](object) {
|
|
2851
|
+
return object && typeof object == "object" && typeof object.constructor == "function" && (typeof object.stream == "function" || typeof object.arrayBuffer == "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
|
|
2852
|
+
}
|
|
2853
|
+
};
|
|
2854
|
+
Object.defineProperties(_Blob.prototype, {
|
|
2855
|
+
size: { enumerable: !0 },
|
|
2856
|
+
type: { enumerable: !0 },
|
|
2857
|
+
slice: { enumerable: !0 }
|
|
2858
|
+
});
|
|
2859
|
+
var Blob2 = _Blob, fetch_blob_default = Blob2;
|
|
2860
|
+
|
|
2861
|
+
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
|
|
2862
|
+
var _File = class extends fetch_blob_default {
|
|
2863
|
+
#lastModified = 0;
|
|
2864
|
+
#name = "";
|
|
2865
|
+
/**
|
|
2866
|
+
* @param {*[]} fileBits
|
|
2867
|
+
* @param {string} fileName
|
|
2868
|
+
* @param {{lastModified?: number, type?: string}} options
|
|
2869
|
+
*/
|
|
2870
|
+
// @ts-ignore
|
|
2871
|
+
constructor(fileBits, fileName, options = {}) {
|
|
2872
|
+
if (arguments.length < 2)
|
|
2873
|
+
throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
|
|
2874
|
+
super(fileBits, options), options === null && (options = {});
|
|
2875
|
+
let lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
|
|
2876
|
+
Number.isNaN(lastModified) || (this.#lastModified = lastModified), this.#name = String(fileName);
|
|
2877
|
+
}
|
|
2878
|
+
get name() {
|
|
2879
|
+
return this.#name;
|
|
2880
|
+
}
|
|
2881
|
+
get lastModified() {
|
|
2882
|
+
return this.#lastModified;
|
|
2883
|
+
}
|
|
2884
|
+
get [Symbol.toStringTag]() {
|
|
2885
|
+
return "File";
|
|
2886
|
+
}
|
|
2887
|
+
static [Symbol.hasInstance](object) {
|
|
2888
|
+
return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
|
|
2889
|
+
}
|
|
2890
|
+
}, File2 = _File, file_default = File2;
|
|
2891
|
+
|
|
2892
|
+
// ../../node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js
|
|
2893
|
+
init_cjs_shims();
|
|
2894
|
+
var { toStringTag: t, iterator: i, hasInstance: h } = Symbol, r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new file_default([b], c, b) : b] : [a, b + ""]), e = (c, f2) => (f2 ? c : c.replace(/\r?\n|\r/g, `\r
|
|
2895
|
+
`)).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, e2) => {
|
|
2896
|
+
if (a.length < e2)
|
|
2897
|
+
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
2898
|
+
};
|
|
2899
|
+
var FormData = class {
|
|
2900
|
+
#d = [];
|
|
2901
|
+
constructor(...a) {
|
|
2902
|
+
if (a.length)
|
|
2903
|
+
throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.");
|
|
2904
|
+
}
|
|
2905
|
+
get [t]() {
|
|
2906
|
+
return "FormData";
|
|
2907
|
+
}
|
|
2908
|
+
[i]() {
|
|
2909
|
+
return this.entries();
|
|
2910
|
+
}
|
|
2911
|
+
static [h](o) {
|
|
2912
|
+
return o && typeof o == "object" && o[t] === "FormData" && !m.some((m2) => typeof o[m2] != "function");
|
|
2913
|
+
}
|
|
2914
|
+
append(...a) {
|
|
2915
|
+
x("append", arguments, 2), this.#d.push(f(...a));
|
|
2916
|
+
}
|
|
2917
|
+
delete(a) {
|
|
2918
|
+
x("delete", arguments, 1), a += "", this.#d = this.#d.filter(([b]) => b !== a);
|
|
2919
|
+
}
|
|
2920
|
+
get(a) {
|
|
2921
|
+
x("get", arguments, 1), a += "";
|
|
2922
|
+
for (var b = this.#d, l = b.length, c = 0; c < l; c++)
|
|
2923
|
+
if (b[c][0] === a)
|
|
2924
|
+
return b[c][1];
|
|
2925
|
+
return null;
|
|
2926
|
+
}
|
|
2927
|
+
getAll(a, b) {
|
|
2928
|
+
return x("getAll", arguments, 1), b = [], a += "", this.#d.forEach((c) => c[0] === a && b.push(c[1])), b;
|
|
2929
|
+
}
|
|
2930
|
+
has(a) {
|
|
2931
|
+
return x("has", arguments, 1), a += "", this.#d.some((b) => b[0] === a);
|
|
2932
|
+
}
|
|
2933
|
+
forEach(a, b) {
|
|
2934
|
+
x("forEach", arguments, 1);
|
|
2935
|
+
for (var [c, d] of this)
|
|
2936
|
+
a.call(b, d, c, this);
|
|
2937
|
+
}
|
|
2938
|
+
set(...a) {
|
|
2939
|
+
x("set", arguments, 2);
|
|
2940
|
+
var b = [], c = !0;
|
|
2941
|
+
a = f(...a), this.#d.forEach((d) => {
|
|
2942
|
+
d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
|
|
2943
|
+
}), c && b.push(a), this.#d = b;
|
|
2944
|
+
}
|
|
2945
|
+
*entries() {
|
|
2946
|
+
yield* this.#d;
|
|
2947
|
+
}
|
|
2948
|
+
*keys() {
|
|
2949
|
+
for (var [a] of this)
|
|
2950
|
+
yield a;
|
|
2951
|
+
}
|
|
2952
|
+
*values() {
|
|
2953
|
+
for (var [, a] of this)
|
|
2954
|
+
yield a;
|
|
2955
|
+
}
|
|
2956
|
+
};
|
|
2957
|
+
function formDataToBlob(F, B = fetch_blob_default) {
|
|
2958
|
+
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r
|
|
2959
|
+
Content-Disposition: form-data; name="`;
|
|
2960
|
+
return F.forEach((v, n) => typeof v == "string" ? c.push(p + e(n) + `"\r
|
|
2961
|
+
\r
|
|
2962
|
+
${v.replace(/\r(?!\n)|(?<!\r)\n/g, `\r
|
|
2963
|
+
`)}\r
|
|
2964
|
+
`) : c.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r
|
|
2965
|
+
Content-Type: ${v.type || "application/octet-stream"}\r
|
|
2966
|
+
\r
|
|
2967
|
+
`, v, `\r
|
|
2968
|
+
`)), c.push(`--${b}--`), new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
|
|
2972
|
+
init_cjs_shims();
|
|
2973
|
+
import { statSync, createReadStream, promises as fs } from "node:fs";
|
|
2974
|
+
var import_node_domexception = __toESM(require_node_domexception(), 1);
|
|
2975
|
+
var { stat } = fs;
|
|
2976
|
+
var BlobDataItem = class _BlobDataItem {
|
|
2977
|
+
#path;
|
|
2978
|
+
#start;
|
|
2979
|
+
constructor(options) {
|
|
2980
|
+
this.#path = options.path, this.#start = options.start, this.size = options.size, this.lastModified = options.lastModified;
|
|
2981
|
+
}
|
|
2982
|
+
/**
|
|
2983
|
+
* Slicing arguments is first validated and formatted
|
|
2984
|
+
* to not be out of range by Blob.prototype.slice
|
|
2985
|
+
*/
|
|
2986
|
+
slice(start, end) {
|
|
2987
|
+
return new _BlobDataItem({
|
|
2988
|
+
path: this.#path,
|
|
2989
|
+
lastModified: this.lastModified,
|
|
2990
|
+
size: end - start,
|
|
2991
|
+
start: this.#start + start
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
async *stream() {
|
|
2995
|
+
let { mtimeMs } = await stat(this.#path);
|
|
2996
|
+
if (mtimeMs > this.lastModified)
|
|
2997
|
+
throw new import_node_domexception.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.", "NotReadableError");
|
|
2998
|
+
yield* createReadStream(this.#path, {
|
|
2999
|
+
start: this.#start,
|
|
3000
|
+
end: this.#start + this.size - 1
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
get [Symbol.toStringTag]() {
|
|
3004
|
+
return "Blob";
|
|
3005
|
+
}
|
|
3006
|
+
};
|
|
3007
|
+
|
|
3008
|
+
export {
|
|
3009
|
+
fetch_blob_default,
|
|
3010
|
+
file_default,
|
|
3011
|
+
FormData,
|
|
3012
|
+
formDataToBlob
|
|
3013
|
+
};
|
|
3014
|
+
/*! Bundled license information:
|
|
3015
|
+
|
|
3016
|
+
web-streams-polyfill/dist/ponyfill.es2018.js:
|
|
3017
|
+
(**
|
|
3018
|
+
* @license
|
|
3019
|
+
* web-streams-polyfill v3.3.3
|
|
3020
|
+
* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
3021
|
+
* This code is released under the MIT license.
|
|
3022
|
+
* SPDX-License-Identifier: MIT
|
|
3023
|
+
*)
|
|
3024
|
+
|
|
3025
|
+
node-domexception/index.js:
|
|
3026
|
+
(*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
3027
|
+
|
|
3028
|
+
fetch-blob/index.js:
|
|
3029
|
+
(*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
3030
|
+
|
|
3031
|
+
formdata-polyfill/esm.min.js:
|
|
3032
|
+
(*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
3033
|
+
*/
|
|
3034
|
+
//# sourceMappingURL=chunk-VSLR7ET4.js.map
|