next-ssr-middleware 1.1.2 → 1.1.4
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/index.cjs +3254 -0
- package/dist/index.d.cts +79 -0
- package/dist/index.d.mts +79 -0
- package/dist/index.mjs +3215 -0
- package/package.json +12 -4
- package/source/SSR/middleware/remote.ts +1 -14
- package/source/index.ts +1 -0
- package/source/utility.ts +13 -0
- package/tsconfig.json +1 -1
- package/dist/source/API.d.ts +0 -10
- package/dist/source/API.js +0 -33
- package/dist/source/API.js.map +0 -1
- package/dist/source/SSR/compose.d.ts +0 -4
- package/dist/source/SSR/compose.js +0 -9
- package/dist/source/SSR/compose.js.map +0 -1
- package/dist/source/SSR/index.d.ts +0 -3
- package/dist/source/SSR/index.js +0 -4
- package/dist/source/SSR/index.js.map +0 -1
- package/dist/source/SSR/middleware/index.d.ts +0 -2
- package/dist/source/SSR/middleware/index.js +0 -3
- package/dist/source/SSR/middleware/index.js.map +0 -1
- package/dist/source/SSR/middleware/local.d.ts +0 -14
- package/dist/source/SSR/middleware/local.js +0 -73
- package/dist/source/SSR/middleware/local.js.map +0 -1
- package/dist/source/SSR/middleware/remote.d.ts +0 -29
- package/dist/source/SSR/middleware/remote.js +0 -76
- package/dist/source/SSR/middleware/remote.js.map +0 -1
- package/dist/source/SSR/shim.d.ts +0 -14
- package/dist/source/SSR/shim.js +0 -53
- package/dist/source/SSR/shim.js.map +0 -1
- package/dist/source/index.d.ts +0 -2
- package/dist/source/index.js +0 -3
- package/dist/source/index.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3254 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _koa_bodyparser = require("@koa/bodyparser");
|
|
25
|
+
_koa_bodyparser = __toESM(_koa_bodyparser);
|
|
26
|
+
let _koa_router = require("@koa/router");
|
|
27
|
+
let koa = require("koa");
|
|
28
|
+
koa = __toESM(koa);
|
|
29
|
+
let jsonwebtoken = require("jsonwebtoken");
|
|
30
|
+
let web_utility = require("web-utility");
|
|
31
|
+
//#region source/API.ts
|
|
32
|
+
function withKoa(...parameters) {
|
|
33
|
+
let option;
|
|
34
|
+
let middlewares = [];
|
|
35
|
+
if (typeof parameters[0] === "function") {
|
|
36
|
+
option = void 0;
|
|
37
|
+
middlewares = parameters;
|
|
38
|
+
} else [option, ...middlewares] = parameters;
|
|
39
|
+
const app = new koa.default(option).use((0, _koa_bodyparser.default)());
|
|
40
|
+
for (const middleware of middlewares) app.use(middleware);
|
|
41
|
+
return app.callback();
|
|
42
|
+
}
|
|
43
|
+
const pageApiRouteOf = (path) => decodeURI(path).match(/pages(\/api\/.+)\.(j|t)s/)?.[1]?.split("/[")[0]?.replace(/\/index$/, "");
|
|
44
|
+
const createKoaRouter = (moduleURI, option) => new _koa_router.Router({
|
|
45
|
+
...option,
|
|
46
|
+
prefix: pageApiRouteOf(moduleURI)
|
|
47
|
+
});
|
|
48
|
+
function withKoaRouter(...parameters) {
|
|
49
|
+
let option;
|
|
50
|
+
let router;
|
|
51
|
+
let middlewares = [];
|
|
52
|
+
if (!parameters[1] || typeof parameters[1] === "function") [router, ...middlewares] = parameters;
|
|
53
|
+
else [option, router, ...middlewares] = parameters;
|
|
54
|
+
return withKoa(option, router.routes(), router.allowedMethods(), ...middlewares);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region source/SSR/compose.ts
|
|
58
|
+
function compose(...middlewares) {
|
|
59
|
+
return ((context) => {
|
|
60
|
+
const [first, ...rest] = middlewares;
|
|
61
|
+
const next = async () => await rest.shift()?.(context, next) || { props: {} };
|
|
62
|
+
return first(context, next);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region node_modules/.pnpm/web-streams-polyfill@4.3.0/node_modules/web-streams-polyfill/dist/ponyfill.mjs
|
|
67
|
+
/**
|
|
68
|
+
* @license
|
|
69
|
+
* web-streams-polyfill v4.3.0
|
|
70
|
+
* Copyright 2026 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
71
|
+
* This code is released under the MIT license.
|
|
72
|
+
* SPDX-License-Identifier: MIT
|
|
73
|
+
*/
|
|
74
|
+
function e() {}
|
|
75
|
+
function t(e) {
|
|
76
|
+
return "object" == typeof e && null !== e || "function" == typeof e;
|
|
77
|
+
}
|
|
78
|
+
const r = e;
|
|
79
|
+
function o(e, t) {
|
|
80
|
+
try {
|
|
81
|
+
Object.defineProperty(e, "name", {
|
|
82
|
+
value: t,
|
|
83
|
+
configurable: !0
|
|
84
|
+
});
|
|
85
|
+
} catch (e) {}
|
|
86
|
+
}
|
|
87
|
+
const n = Promise;
|
|
88
|
+
const i = Promise.resolve.bind(n);
|
|
89
|
+
const a = Promise.prototype.then;
|
|
90
|
+
const s = Promise.reject.bind(n);
|
|
91
|
+
const l = i;
|
|
92
|
+
function u(e) {
|
|
93
|
+
return new n(e);
|
|
94
|
+
}
|
|
95
|
+
function c(e) {
|
|
96
|
+
return u((t) => t(e));
|
|
97
|
+
}
|
|
98
|
+
function d(e) {
|
|
99
|
+
return s(e);
|
|
100
|
+
}
|
|
101
|
+
function f(e, t, r) {
|
|
102
|
+
return a.call(e, t, r);
|
|
103
|
+
}
|
|
104
|
+
function h(e, t, o) {
|
|
105
|
+
f(f(e, t, o), void 0, r);
|
|
106
|
+
}
|
|
107
|
+
function b(e, t) {
|
|
108
|
+
h(e, t);
|
|
109
|
+
}
|
|
110
|
+
function _(e, t) {
|
|
111
|
+
h(e, void 0, t);
|
|
112
|
+
}
|
|
113
|
+
function m(e, t, r) {
|
|
114
|
+
return f(e, t, r);
|
|
115
|
+
}
|
|
116
|
+
function p(e) {
|
|
117
|
+
f(e, void 0, r);
|
|
118
|
+
}
|
|
119
|
+
let y = (e) => {
|
|
120
|
+
if ("function" == typeof queueMicrotask) y = queueMicrotask;
|
|
121
|
+
else {
|
|
122
|
+
const e = c(void 0);
|
|
123
|
+
y = (t) => f(e, t);
|
|
124
|
+
}
|
|
125
|
+
return y(e);
|
|
126
|
+
};
|
|
127
|
+
function S(e, t, r) {
|
|
128
|
+
if ("function" != typeof e) throw new TypeError("Argument is not a function");
|
|
129
|
+
return Function.prototype.apply.call(e, t, r);
|
|
130
|
+
}
|
|
131
|
+
function g(e, t, r) {
|
|
132
|
+
try {
|
|
133
|
+
return c(S(e, t, r));
|
|
134
|
+
} catch (e) {
|
|
135
|
+
return d(e);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var v = class {
|
|
139
|
+
constructor() {
|
|
140
|
+
this._cursor = 0, this._size = 0, this._front = {
|
|
141
|
+
_elements: [],
|
|
142
|
+
_next: void 0
|
|
143
|
+
}, this._back = this._front, this._cursor = 0, this._size = 0;
|
|
144
|
+
}
|
|
145
|
+
get length() {
|
|
146
|
+
return this._size;
|
|
147
|
+
}
|
|
148
|
+
push(e) {
|
|
149
|
+
const t = this._back;
|
|
150
|
+
let r = t;
|
|
151
|
+
16383 === t._elements.length && (r = {
|
|
152
|
+
_elements: [],
|
|
153
|
+
_next: void 0
|
|
154
|
+
}), t._elements.push(e), r !== t && (this._back = r, t._next = r), ++this._size;
|
|
155
|
+
}
|
|
156
|
+
shift() {
|
|
157
|
+
const e = this._front;
|
|
158
|
+
let t = e;
|
|
159
|
+
const r = this._cursor;
|
|
160
|
+
let o = r + 1;
|
|
161
|
+
const n = e._elements, i = n[r];
|
|
162
|
+
return 16384 === o && (t = e._next, o = 0), --this._size, this._cursor = o, e !== t && (this._front = t), n[r] = void 0, i;
|
|
163
|
+
}
|
|
164
|
+
forEach(e) {
|
|
165
|
+
let t = this._cursor, r = this._front, o = r._elements;
|
|
166
|
+
for (; !(t === o.length && void 0 === r._next || t === o.length && (r = r._next, o = r._elements, t = 0, 0 === o.length));) e(o[t]), ++t;
|
|
167
|
+
}
|
|
168
|
+
peek() {
|
|
169
|
+
const e = this._front, t = this._cursor;
|
|
170
|
+
return e._elements[t];
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const w = Symbol("[[AbortSteps]]");
|
|
174
|
+
const R = Symbol("[[ErrorSteps]]");
|
|
175
|
+
const T = Symbol("[[CancelSteps]]");
|
|
176
|
+
const P = Symbol("[[PullSteps]]");
|
|
177
|
+
const C = Symbol("[[CanPullSyncSteps]]");
|
|
178
|
+
const q = Symbol("[[ReleaseSteps]]");
|
|
179
|
+
function E(e, t) {
|
|
180
|
+
e._ownerReadableStream = t, t._reader = e, "readable" === t._state ? j(e) : "closed" === t._state ? function(e) {
|
|
181
|
+
j(e), z(e);
|
|
182
|
+
}(e) : k(e, t._storedError);
|
|
183
|
+
}
|
|
184
|
+
function W(e, t) {
|
|
185
|
+
return Mr(e._ownerReadableStream, t);
|
|
186
|
+
}
|
|
187
|
+
function O(e) {
|
|
188
|
+
const t = e._ownerReadableStream;
|
|
189
|
+
"readable" === t._state ? A(e, /* @__PURE__ */ new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : function(e, t) {
|
|
190
|
+
k(e, t);
|
|
191
|
+
}(e, /* @__PURE__ */ new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), t._readableStreamController[q](), t._reader = void 0, e._ownerReadableStream = void 0;
|
|
192
|
+
}
|
|
193
|
+
function B(e) {
|
|
194
|
+
return /* @__PURE__ */ new TypeError("Cannot " + e + " a stream using a released reader");
|
|
195
|
+
}
|
|
196
|
+
function j(e) {
|
|
197
|
+
e._closedPromise = u((t, r) => {
|
|
198
|
+
e._closedPromise_resolve = t, e._closedPromise_reject = r;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function k(e, t) {
|
|
202
|
+
j(e), A(e, t);
|
|
203
|
+
}
|
|
204
|
+
function A(e, t) {
|
|
205
|
+
void 0 !== e._closedPromise_reject && (p(e._closedPromise), e._closedPromise_reject(t), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0);
|
|
206
|
+
}
|
|
207
|
+
function z(e) {
|
|
208
|
+
void 0 !== e._closedPromise_resolve && (e._closedPromise_resolve(void 0), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0);
|
|
209
|
+
}
|
|
210
|
+
const D = Number.isFinite || function(e) {
|
|
211
|
+
return "number" == typeof e && isFinite(e);
|
|
212
|
+
};
|
|
213
|
+
const F = Math.trunc || function(e) {
|
|
214
|
+
return e < 0 ? Math.ceil(e) : Math.floor(e);
|
|
215
|
+
};
|
|
216
|
+
function L(e, t) {
|
|
217
|
+
if (void 0 !== e && "object" != typeof (r = e) && "function" != typeof r) throw new TypeError(`${t} is not an object.`);
|
|
218
|
+
var r;
|
|
219
|
+
}
|
|
220
|
+
function I(e, t) {
|
|
221
|
+
if ("function" != typeof e) throw new TypeError(`${t} is not a function.`);
|
|
222
|
+
}
|
|
223
|
+
function $(e, t) {
|
|
224
|
+
if (!function(e) {
|
|
225
|
+
return "object" == typeof e && null !== e || "function" == typeof e;
|
|
226
|
+
}(e)) throw new TypeError(`${t} is not an object.`);
|
|
227
|
+
}
|
|
228
|
+
function M(e, t, r) {
|
|
229
|
+
if (void 0 === e) throw new TypeError(`Parameter ${t} is required in '${r}'.`);
|
|
230
|
+
}
|
|
231
|
+
function Y(e, t, r) {
|
|
232
|
+
if (void 0 === e) throw new TypeError(`${t} is required in '${r}'.`);
|
|
233
|
+
}
|
|
234
|
+
function x(e) {
|
|
235
|
+
return Number(e);
|
|
236
|
+
}
|
|
237
|
+
function Q(e) {
|
|
238
|
+
return 0 === e ? 0 : e;
|
|
239
|
+
}
|
|
240
|
+
function N(e, t) {
|
|
241
|
+
const r = Number.MAX_SAFE_INTEGER;
|
|
242
|
+
let o = Number(e);
|
|
243
|
+
if (o = Q(o), !D(o)) throw new TypeError(`${t} is not a finite number`);
|
|
244
|
+
if (o = function(e) {
|
|
245
|
+
return Q(F(e));
|
|
246
|
+
}(o), o < 0 || o > r) throw new TypeError(`${t} is outside the accepted range of 0 to ${r}, inclusive`);
|
|
247
|
+
return D(o) && 0 !== o ? o : 0;
|
|
248
|
+
}
|
|
249
|
+
function H(e, t) {
|
|
250
|
+
if (!Ir(e)) throw new TypeError(`${t} is not a ReadableStream.`);
|
|
251
|
+
}
|
|
252
|
+
function V(e) {
|
|
253
|
+
return new ReadableStreamDefaultReader(e);
|
|
254
|
+
}
|
|
255
|
+
function U(e, t) {
|
|
256
|
+
e._reader._readRequests.push(t);
|
|
257
|
+
}
|
|
258
|
+
function G(e, t, r) {
|
|
259
|
+
const o = e._reader._readRequests.shift();
|
|
260
|
+
r ? o._closeSteps() : o._chunkSteps(t);
|
|
261
|
+
}
|
|
262
|
+
function X(e) {
|
|
263
|
+
return e._reader._readRequests.length;
|
|
264
|
+
}
|
|
265
|
+
function J(e) {
|
|
266
|
+
const t = e._reader;
|
|
267
|
+
return void 0 !== t && !!ee(t);
|
|
268
|
+
}
|
|
269
|
+
var ReadableStreamDefaultReader = class {
|
|
270
|
+
constructor(e) {
|
|
271
|
+
if (M(e, 1, "ReadableStreamDefaultReader"), H(e, "First parameter"), $r(e)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
272
|
+
E(this, e), this._readRequests = new v();
|
|
273
|
+
}
|
|
274
|
+
get closed() {
|
|
275
|
+
return ee(this) ? this._closedPromise : d(ne("closed"));
|
|
276
|
+
}
|
|
277
|
+
cancel(e = void 0) {
|
|
278
|
+
return ee(this) ? void 0 === this._ownerReadableStream ? d(B("cancel")) : W(this, e) : d(ne("cancel"));
|
|
279
|
+
}
|
|
280
|
+
read() {
|
|
281
|
+
if (!ee(this)) return d(ne("read"));
|
|
282
|
+
if (void 0 === this._ownerReadableStream) return d(B("read from"));
|
|
283
|
+
const e = re(this) ? new Z() : new K();
|
|
284
|
+
return te(this, e), e._promise;
|
|
285
|
+
}
|
|
286
|
+
releaseLock() {
|
|
287
|
+
if (!ee(this)) throw ne("releaseLock");
|
|
288
|
+
void 0 !== this._ownerReadableStream && function(e) {
|
|
289
|
+
O(e);
|
|
290
|
+
oe(e, /* @__PURE__ */ new TypeError("Reader was released"));
|
|
291
|
+
}(this);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
Object.defineProperties(ReadableStreamDefaultReader.prototype, {
|
|
295
|
+
cancel: { enumerable: !0 },
|
|
296
|
+
read: { enumerable: !0 },
|
|
297
|
+
releaseLock: { enumerable: !0 },
|
|
298
|
+
closed: { enumerable: !0 }
|
|
299
|
+
}), o(ReadableStreamDefaultReader.prototype.cancel, "cancel"), o(ReadableStreamDefaultReader.prototype.read, "read"), o(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
|
|
300
|
+
value: "ReadableStreamDefaultReader",
|
|
301
|
+
configurable: !0
|
|
302
|
+
});
|
|
303
|
+
var K = class {
|
|
304
|
+
constructor() {
|
|
305
|
+
this._promise = u((e, t) => {
|
|
306
|
+
this._resolvePromise = e, this._rejectPromise = t;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
_chunkSteps(e) {
|
|
310
|
+
this._resolvePromise({
|
|
311
|
+
value: e,
|
|
312
|
+
done: !1
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
_closeSteps() {
|
|
316
|
+
this._resolvePromise({
|
|
317
|
+
value: void 0,
|
|
318
|
+
done: !0
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
_errorSteps(e) {
|
|
322
|
+
this._rejectPromise(e);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
var Z = class {
|
|
326
|
+
constructor() {
|
|
327
|
+
this._promise = void 0;
|
|
328
|
+
}
|
|
329
|
+
_chunkSteps(e) {
|
|
330
|
+
this._promise = l({
|
|
331
|
+
value: e,
|
|
332
|
+
done: !1
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
_closeSteps() {
|
|
336
|
+
this._promise = l({
|
|
337
|
+
value: void 0,
|
|
338
|
+
done: !0
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
_errorSteps(e) {
|
|
342
|
+
this._promise = d(e);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
function ee(e) {
|
|
346
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_readRequests") && e instanceof ReadableStreamDefaultReader;
|
|
347
|
+
}
|
|
348
|
+
function te(e, t) {
|
|
349
|
+
const r = e._ownerReadableStream;
|
|
350
|
+
r._disturbed = !0, "closed" === r._state ? t._closeSteps() : "errored" === r._state ? t._errorSteps(r._storedError) : r._readableStreamController[P](t);
|
|
351
|
+
}
|
|
352
|
+
function re(e) {
|
|
353
|
+
const t = e._ownerReadableStream;
|
|
354
|
+
return "closed" === t._state || "errored" === t._state || t._readableStreamController[C]();
|
|
355
|
+
}
|
|
356
|
+
function oe(e, t) {
|
|
357
|
+
const r = e._readRequests;
|
|
358
|
+
e._readRequests = new v(), r.forEach((e) => {
|
|
359
|
+
e._errorSteps(t);
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
function ne(e) {
|
|
363
|
+
return /* @__PURE__ */ new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`);
|
|
364
|
+
}
|
|
365
|
+
var ie;
|
|
366
|
+
var ae;
|
|
367
|
+
var se;
|
|
368
|
+
function le(e) {
|
|
369
|
+
return e.slice();
|
|
370
|
+
}
|
|
371
|
+
function ue(e, t, r, o, n) {
|
|
372
|
+
new Uint8Array(e).set(new Uint8Array(r, o, n), t);
|
|
373
|
+
}
|
|
374
|
+
let ce = (e) => (ce = "function" == typeof e.transfer ? (e) => e.transfer() : "function" == typeof structuredClone ? (e) => structuredClone(e, { transfer: [e] }) : (e) => e, ce(e));
|
|
375
|
+
let de = (e) => (de = "boolean" == typeof e.detached ? (e) => e.detached : (e) => 0 === e.byteLength, de(e));
|
|
376
|
+
function fe(e, t, r) {
|
|
377
|
+
if (e.slice) return e.slice(t, r);
|
|
378
|
+
const o = r - t, n = new ArrayBuffer(o);
|
|
379
|
+
return ue(n, 0, e, t, o), n;
|
|
380
|
+
}
|
|
381
|
+
function he(e, t) {
|
|
382
|
+
const r = e[t];
|
|
383
|
+
if (null != r) {
|
|
384
|
+
if ("function" != typeof r) throw new TypeError(`${String(t)} is not a function`);
|
|
385
|
+
return r;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
function be(e) {
|
|
389
|
+
try {
|
|
390
|
+
const t = e.done, r = e.value;
|
|
391
|
+
return f(l(r), (e) => ({
|
|
392
|
+
done: t,
|
|
393
|
+
value: e
|
|
394
|
+
}));
|
|
395
|
+
} catch (e) {
|
|
396
|
+
return d(e);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const _e = null !== (se = null !== (ie = Symbol.asyncIterator) && void 0 !== ie ? ie : null === (ae = Symbol.for) || void 0 === ae ? void 0 : ae.call(Symbol, "Symbol.asyncIterator")) && void 0 !== se ? se : "@@asyncIterator";
|
|
400
|
+
function me(e, r = "sync", o) {
|
|
401
|
+
if (void 0 === o) if ("async" === r) {
|
|
402
|
+
if (void 0 === (o = he(e, _e))) return function(e) {
|
|
403
|
+
const r = {
|
|
404
|
+
next() {
|
|
405
|
+
let t;
|
|
406
|
+
try {
|
|
407
|
+
t = pe(e);
|
|
408
|
+
} catch (e) {
|
|
409
|
+
return d(e);
|
|
410
|
+
}
|
|
411
|
+
return be(t);
|
|
412
|
+
},
|
|
413
|
+
return(r) {
|
|
414
|
+
let o;
|
|
415
|
+
try {
|
|
416
|
+
const t = he(e.iterator, "return");
|
|
417
|
+
if (void 0 === t) return c({
|
|
418
|
+
done: !0,
|
|
419
|
+
value: r
|
|
420
|
+
});
|
|
421
|
+
o = S(t, e.iterator, [r]);
|
|
422
|
+
} catch (e) {
|
|
423
|
+
return d(e);
|
|
424
|
+
}
|
|
425
|
+
return t(o) ? be(o) : d(/* @__PURE__ */ new TypeError("The iterator.return() method must return an object"));
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
return {
|
|
429
|
+
iterator: r,
|
|
430
|
+
nextMethod: r.next,
|
|
431
|
+
done: !1
|
|
432
|
+
};
|
|
433
|
+
}(me(e, "sync", he(e, Symbol.iterator)));
|
|
434
|
+
} else o = he(e, Symbol.iterator);
|
|
435
|
+
if (void 0 === o) throw new TypeError("The object is not iterable");
|
|
436
|
+
const n = S(o, e, []);
|
|
437
|
+
if (!t(n)) throw new TypeError("The iterator method must return an object");
|
|
438
|
+
return {
|
|
439
|
+
iterator: n,
|
|
440
|
+
nextMethod: n.next,
|
|
441
|
+
done: !1
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function pe(e) {
|
|
445
|
+
const r = S(e.nextMethod, e.iterator, []);
|
|
446
|
+
if (!t(r)) throw new TypeError("The iterator.next() method must return an object");
|
|
447
|
+
return r;
|
|
448
|
+
}
|
|
449
|
+
var ye = class {
|
|
450
|
+
constructor(e, t) {
|
|
451
|
+
this._ongoingPromise = void 0, this._isFinished = !1, this._reader = e, this._preventCancel = t;
|
|
452
|
+
}
|
|
453
|
+
next() {
|
|
454
|
+
const e = () => this._nextSteps();
|
|
455
|
+
return this._ongoingPromise = this._ongoingPromise ? m(this._ongoingPromise, e, e) : e(), this._ongoingPromise;
|
|
456
|
+
}
|
|
457
|
+
return(e) {
|
|
458
|
+
const t = () => this._returnSteps(e);
|
|
459
|
+
return this._ongoingPromise = this._ongoingPromise ? m(this._ongoingPromise, t, t) : t(), this._ongoingPromise;
|
|
460
|
+
}
|
|
461
|
+
_nextSteps() {
|
|
462
|
+
if (this._isFinished) return Promise.resolve({
|
|
463
|
+
value: void 0,
|
|
464
|
+
done: !0
|
|
465
|
+
});
|
|
466
|
+
const e = this._reader, t = new Se(this);
|
|
467
|
+
return te(e, t), t._promise;
|
|
468
|
+
}
|
|
469
|
+
_returnSteps(e) {
|
|
470
|
+
if (this._isFinished) return Promise.resolve({
|
|
471
|
+
value: e,
|
|
472
|
+
done: !0
|
|
473
|
+
});
|
|
474
|
+
this._isFinished = !0;
|
|
475
|
+
const t = this._reader;
|
|
476
|
+
if (!this._preventCancel) {
|
|
477
|
+
const r = W(t, e);
|
|
478
|
+
return O(t), m(r, () => ({
|
|
479
|
+
value: e,
|
|
480
|
+
done: !0
|
|
481
|
+
}));
|
|
482
|
+
}
|
|
483
|
+
return O(t), c({
|
|
484
|
+
value: e,
|
|
485
|
+
done: !0
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
var Se = class {
|
|
490
|
+
constructor(e) {
|
|
491
|
+
this._iterator = e, this._promise = u((e, t) => {
|
|
492
|
+
this._resolvePromise = e, this._rejectPromise = t;
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
_chunkSteps(e) {
|
|
496
|
+
this._iterator._ongoingPromise = void 0, y(() => this._resolvePromise({
|
|
497
|
+
value: e,
|
|
498
|
+
done: !1
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
_closeSteps() {
|
|
502
|
+
const e = this._iterator;
|
|
503
|
+
e._ongoingPromise = void 0, e._isFinished = !0, O(e._reader), this._resolvePromise({
|
|
504
|
+
value: void 0,
|
|
505
|
+
done: !0
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
_errorSteps(e) {
|
|
509
|
+
const t = this._iterator;
|
|
510
|
+
t._ongoingPromise = void 0, t._isFinished = !0, O(t._reader), this._rejectPromise(e);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
const ge = {
|
|
514
|
+
next() {
|
|
515
|
+
return ve(this) ? this._asyncIteratorImpl.next() : d(we("next"));
|
|
516
|
+
},
|
|
517
|
+
return(e) {
|
|
518
|
+
return ve(this) ? this._asyncIteratorImpl.return(e) : d(we("return"));
|
|
519
|
+
},
|
|
520
|
+
[_e]() {
|
|
521
|
+
return this;
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
function ve(e) {
|
|
525
|
+
if (!t(e)) return !1;
|
|
526
|
+
if (!Object.prototype.hasOwnProperty.call(e, "_asyncIteratorImpl")) return !1;
|
|
527
|
+
try {
|
|
528
|
+
return e._asyncIteratorImpl instanceof ye;
|
|
529
|
+
} catch (e) {
|
|
530
|
+
return !1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function we(e) {
|
|
534
|
+
return /* @__PURE__ */ new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`);
|
|
535
|
+
}
|
|
536
|
+
Object.defineProperty(ge, _e, { enumerable: !1 });
|
|
537
|
+
const Re = Number.isNaN || function(e) {
|
|
538
|
+
return e != e;
|
|
539
|
+
};
|
|
540
|
+
function Te(e) {
|
|
541
|
+
const t = fe(e.buffer, e.byteOffset, e.byteOffset + e.byteLength);
|
|
542
|
+
return new Uint8Array(t);
|
|
543
|
+
}
|
|
544
|
+
function Pe(e) {
|
|
545
|
+
const t = e._queue.shift();
|
|
546
|
+
return e._queueTotalSize -= t.size, e._queueTotalSize < 0 && (e._queueTotalSize = 0), t.value;
|
|
547
|
+
}
|
|
548
|
+
function Ce(e, t, r) {
|
|
549
|
+
if ("number" != typeof (o = r) || Re(o) || o < 0 || r === 1 / 0) throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
|
|
550
|
+
var o;
|
|
551
|
+
e._queue.push({
|
|
552
|
+
value: t,
|
|
553
|
+
size: r
|
|
554
|
+
}), e._queueTotalSize += r;
|
|
555
|
+
}
|
|
556
|
+
function qe(e) {
|
|
557
|
+
e._queue = new v(), e._queueTotalSize = 0;
|
|
558
|
+
}
|
|
559
|
+
function Ee(e) {
|
|
560
|
+
return e === DataView;
|
|
561
|
+
}
|
|
562
|
+
function We(e) {
|
|
563
|
+
return Ee(e) ? 1 : e.BYTES_PER_ELEMENT;
|
|
564
|
+
}
|
|
565
|
+
var ReadableStreamBYOBRequest = class {
|
|
566
|
+
constructor() {
|
|
567
|
+
throw new TypeError("Illegal constructor");
|
|
568
|
+
}
|
|
569
|
+
get view() {
|
|
570
|
+
if (!Be(this)) throw ot("view");
|
|
571
|
+
return this._view;
|
|
572
|
+
}
|
|
573
|
+
respond(e) {
|
|
574
|
+
if (!Be(this)) throw ot("respond");
|
|
575
|
+
if (M(e, 1, "respond"), e = N(e, "First parameter"), void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
|
|
576
|
+
if (de(this._view.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
|
|
577
|
+
et(this._associatedReadableByteStreamController, e);
|
|
578
|
+
}
|
|
579
|
+
respondWithNewView(e) {
|
|
580
|
+
if (!Be(this)) throw ot("respondWithNewView");
|
|
581
|
+
if (M(e, 1, "respondWithNewView"), !ArrayBuffer.isView(e)) throw new TypeError("You can only respond with array buffer views");
|
|
582
|
+
if (void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
|
|
583
|
+
if (de(e.buffer)) throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
|
|
584
|
+
tt(this._associatedReadableByteStreamController, e);
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
|
|
588
|
+
respond: { enumerable: !0 },
|
|
589
|
+
respondWithNewView: { enumerable: !0 },
|
|
590
|
+
view: { enumerable: !0 }
|
|
591
|
+
}), o(ReadableStreamBYOBRequest.prototype.respond, "respond"), o(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
|
|
592
|
+
value: "ReadableStreamBYOBRequest",
|
|
593
|
+
configurable: !0
|
|
594
|
+
});
|
|
595
|
+
var ReadableByteStreamController = class {
|
|
596
|
+
constructor() {
|
|
597
|
+
throw new TypeError("Illegal constructor");
|
|
598
|
+
}
|
|
599
|
+
get byobRequest() {
|
|
600
|
+
if (!Oe(this)) throw nt("byobRequest");
|
|
601
|
+
return Ke(this);
|
|
602
|
+
}
|
|
603
|
+
get desiredSize() {
|
|
604
|
+
if (!Oe(this)) throw nt("desiredSize");
|
|
605
|
+
return Ze(this);
|
|
606
|
+
}
|
|
607
|
+
close() {
|
|
608
|
+
if (!Oe(this)) throw nt("close");
|
|
609
|
+
if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!");
|
|
610
|
+
const e = this._controlledReadableByteStream._state;
|
|
611
|
+
if ("readable" !== e) throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);
|
|
612
|
+
Ue(this);
|
|
613
|
+
}
|
|
614
|
+
enqueue(e) {
|
|
615
|
+
if (!Oe(this)) throw nt("enqueue");
|
|
616
|
+
if (M(e, 1, "enqueue"), !ArrayBuffer.isView(e)) throw new TypeError("chunk must be an array buffer view");
|
|
617
|
+
if (0 === e.byteLength) throw new TypeError("chunk must have non-zero byteLength");
|
|
618
|
+
if (0 === e.buffer.byteLength) throw new TypeError("chunk's buffer must have non-zero byteLength");
|
|
619
|
+
if (this._closeRequested) throw new TypeError("stream is closed or draining");
|
|
620
|
+
const t = this._controlledReadableByteStream._state;
|
|
621
|
+
if ("readable" !== t) throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);
|
|
622
|
+
Ge(this, e);
|
|
623
|
+
}
|
|
624
|
+
error(e = void 0) {
|
|
625
|
+
if (!Oe(this)) throw nt("error");
|
|
626
|
+
Xe(this, e);
|
|
627
|
+
}
|
|
628
|
+
[T](e) {
|
|
629
|
+
ke(this), qe(this);
|
|
630
|
+
const t = this._cancelAlgorithm(e);
|
|
631
|
+
return Ve(this), t;
|
|
632
|
+
}
|
|
633
|
+
[P](e) {
|
|
634
|
+
const t = this._controlledReadableByteStream;
|
|
635
|
+
if (this._queueTotalSize > 0) return void Je(this, e);
|
|
636
|
+
const r = this._autoAllocateChunkSize;
|
|
637
|
+
if (void 0 !== r) {
|
|
638
|
+
let t;
|
|
639
|
+
try {
|
|
640
|
+
t = new ArrayBuffer(r);
|
|
641
|
+
} catch (t) {
|
|
642
|
+
e._errorSteps(t);
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
const o = {
|
|
646
|
+
buffer: t,
|
|
647
|
+
bufferByteLength: r,
|
|
648
|
+
byteOffset: 0,
|
|
649
|
+
byteLength: r,
|
|
650
|
+
bytesFilled: 0,
|
|
651
|
+
minimumFill: 1,
|
|
652
|
+
elementSize: 1,
|
|
653
|
+
viewConstructor: Uint8Array,
|
|
654
|
+
readerType: "default"
|
|
655
|
+
};
|
|
656
|
+
this._pendingPullIntos.push(o);
|
|
657
|
+
}
|
|
658
|
+
U(t, e), je(this);
|
|
659
|
+
}
|
|
660
|
+
[C]() {
|
|
661
|
+
return this._queueTotalSize > 0;
|
|
662
|
+
}
|
|
663
|
+
[q]() {
|
|
664
|
+
if (this._pendingPullIntos.length > 0) {
|
|
665
|
+
const e = this._pendingPullIntos.peek();
|
|
666
|
+
e.readerType = "none", this._pendingPullIntos = new v(), this._pendingPullIntos.push(e);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
function Oe(e) {
|
|
671
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_controlledReadableByteStream") && e instanceof ReadableByteStreamController;
|
|
672
|
+
}
|
|
673
|
+
function Be(e) {
|
|
674
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_associatedReadableByteStreamController") && e instanceof ReadableStreamBYOBRequest;
|
|
675
|
+
}
|
|
676
|
+
function je(e) {
|
|
677
|
+
if (!function(e) {
|
|
678
|
+
const t = e._controlledReadableByteStream;
|
|
679
|
+
if ("readable" !== t._state) return !1;
|
|
680
|
+
if (e._closeRequested) return !1;
|
|
681
|
+
if (!e._started) return !1;
|
|
682
|
+
if (J(t) && X(t) > 0) return !0;
|
|
683
|
+
if (ut(t) && lt(t) > 0) return !0;
|
|
684
|
+
if (Ze(e) > 0) return !0;
|
|
685
|
+
return !1;
|
|
686
|
+
}(e)) return;
|
|
687
|
+
if (e._pulling) return void (e._pullAgain = !0);
|
|
688
|
+
e._pulling = !0;
|
|
689
|
+
h(e._pullAlgorithm(), () => (e._pulling = !1, e._pullAgain && (e._pullAgain = !1, je(e)), null), (t) => (Xe(e, t), null));
|
|
690
|
+
}
|
|
691
|
+
function ke(e) {
|
|
692
|
+
xe(e), e._pendingPullIntos = new v();
|
|
693
|
+
}
|
|
694
|
+
function Ae(e, t) {
|
|
695
|
+
let r = !1;
|
|
696
|
+
"closed" === e._state && (r = !0);
|
|
697
|
+
const o = De(t);
|
|
698
|
+
"default" === t.readerType ? G(e, o, r) : function(e, t, r) {
|
|
699
|
+
const n = e._reader._readIntoRequests.shift();
|
|
700
|
+
r ? n._closeSteps(t) : n._chunkSteps(t);
|
|
701
|
+
}(e, o, r);
|
|
702
|
+
}
|
|
703
|
+
function ze(e, t) {
|
|
704
|
+
for (let r = 0; r < t.length; ++r) Ae(e, t[r]);
|
|
705
|
+
}
|
|
706
|
+
function De(e) {
|
|
707
|
+
const t = e.bytesFilled, r = e.elementSize;
|
|
708
|
+
return new e.viewConstructor(e.buffer, e.byteOffset, t / r);
|
|
709
|
+
}
|
|
710
|
+
function Fe(e, t, r, o) {
|
|
711
|
+
e._queue.push({
|
|
712
|
+
buffer: t,
|
|
713
|
+
byteOffset: r,
|
|
714
|
+
byteLength: o
|
|
715
|
+
}), e._queueTotalSize += o;
|
|
716
|
+
}
|
|
717
|
+
function Le(e, t, r, o) {
|
|
718
|
+
let n;
|
|
719
|
+
try {
|
|
720
|
+
n = fe(t, r, r + o);
|
|
721
|
+
} catch (t) {
|
|
722
|
+
throw Xe(e, t), t;
|
|
723
|
+
}
|
|
724
|
+
Fe(e, n, 0, o);
|
|
725
|
+
}
|
|
726
|
+
function Ie(e, t) {
|
|
727
|
+
t.bytesFilled > 0 && Le(e, t.buffer, t.byteOffset, t.bytesFilled), He(e);
|
|
728
|
+
}
|
|
729
|
+
function $e(e, t) {
|
|
730
|
+
const r = Math.min(e._queueTotalSize, t.byteLength - t.bytesFilled), o = t.bytesFilled + r;
|
|
731
|
+
let n = r, i = !1;
|
|
732
|
+
const a = o - o % t.elementSize;
|
|
733
|
+
a >= t.minimumFill && (n = a - t.bytesFilled, i = !0);
|
|
734
|
+
const s = e._queue;
|
|
735
|
+
for (; n > 0;) {
|
|
736
|
+
const r = s.peek(), o = Math.min(n, r.byteLength), i = t.byteOffset + t.bytesFilled;
|
|
737
|
+
ue(t.buffer, i, r.buffer, r.byteOffset, o), r.byteLength === o ? s.shift() : (r.byteOffset += o, r.byteLength -= o), e._queueTotalSize -= o, Me(e, o, t), n -= o;
|
|
738
|
+
}
|
|
739
|
+
return i;
|
|
740
|
+
}
|
|
741
|
+
function Me(e, t, r) {
|
|
742
|
+
r.bytesFilled += t;
|
|
743
|
+
}
|
|
744
|
+
function Ye(e) {
|
|
745
|
+
0 === e._queueTotalSize && e._closeRequested ? (Ve(e), Yr(e._controlledReadableByteStream)) : je(e);
|
|
746
|
+
}
|
|
747
|
+
function xe(e) {
|
|
748
|
+
null !== e._byobRequest && (e._byobRequest._associatedReadableByteStreamController = void 0, e._byobRequest._view = null, e._byobRequest = null);
|
|
749
|
+
}
|
|
750
|
+
function Qe(e) {
|
|
751
|
+
const t = [];
|
|
752
|
+
for (; e._pendingPullIntos.length > 0 && 0 !== e._queueTotalSize;) {
|
|
753
|
+
const r = e._pendingPullIntos.peek();
|
|
754
|
+
$e(e, r) && (He(e), t.push(r));
|
|
755
|
+
}
|
|
756
|
+
return t;
|
|
757
|
+
}
|
|
758
|
+
function Ne(e, t) {
|
|
759
|
+
const r = e._pendingPullIntos.peek();
|
|
760
|
+
xe(e);
|
|
761
|
+
"closed" === e._controlledReadableByteStream._state ? function(e, t) {
|
|
762
|
+
"none" === t.readerType && He(e);
|
|
763
|
+
const r = e._controlledReadableByteStream;
|
|
764
|
+
if (ut(r)) {
|
|
765
|
+
const t = [];
|
|
766
|
+
for (; t.length < lt(r);) t.push(He(e));
|
|
767
|
+
ze(r, t);
|
|
768
|
+
}
|
|
769
|
+
}(e, r) : function(e, t, r) {
|
|
770
|
+
if (Me(0, t, r), "none" === r.readerType) {
|
|
771
|
+
Ie(e, r);
|
|
772
|
+
const t = Qe(e);
|
|
773
|
+
ze(e._controlledReadableByteStream, t);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
if (r.bytesFilled < r.minimumFill) return;
|
|
777
|
+
He(e);
|
|
778
|
+
const o = r.bytesFilled % r.elementSize;
|
|
779
|
+
if (o > 0) {
|
|
780
|
+
const t = r.byteOffset + r.bytesFilled;
|
|
781
|
+
Le(e, r.buffer, t - o, o);
|
|
782
|
+
}
|
|
783
|
+
r.bytesFilled -= o;
|
|
784
|
+
const n = Qe(e);
|
|
785
|
+
Ae(e._controlledReadableByteStream, r), ze(e._controlledReadableByteStream, n);
|
|
786
|
+
}(e, t, r), je(e);
|
|
787
|
+
}
|
|
788
|
+
function He(e) {
|
|
789
|
+
return e._pendingPullIntos.shift();
|
|
790
|
+
}
|
|
791
|
+
function Ve(e) {
|
|
792
|
+
e._pullAlgorithm = void 0, e._cancelAlgorithm = void 0;
|
|
793
|
+
}
|
|
794
|
+
function Ue(e) {
|
|
795
|
+
const t = e._controlledReadableByteStream;
|
|
796
|
+
if (!e._closeRequested && "readable" === t._state) if (e._queueTotalSize > 0) e._closeRequested = !0;
|
|
797
|
+
else {
|
|
798
|
+
if (e._pendingPullIntos.length > 0) {
|
|
799
|
+
const t = e._pendingPullIntos.peek();
|
|
800
|
+
if (t.bytesFilled % t.elementSize !== 0) {
|
|
801
|
+
const t = /* @__PURE__ */ new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
802
|
+
throw Xe(e, t), t;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
Ve(e), Yr(t);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function Ge(e, t) {
|
|
809
|
+
const r = e._controlledReadableByteStream;
|
|
810
|
+
if (e._closeRequested || "readable" !== r._state) return;
|
|
811
|
+
const { buffer: o, byteOffset: n, byteLength: i } = t;
|
|
812
|
+
if (de(o)) throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
|
|
813
|
+
const a = ce(o);
|
|
814
|
+
if (e._pendingPullIntos.length > 0) {
|
|
815
|
+
const t = e._pendingPullIntos.peek();
|
|
816
|
+
if (de(t.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
|
|
817
|
+
xe(e), t.buffer = ce(t.buffer), "none" === t.readerType && Ie(e, t);
|
|
818
|
+
}
|
|
819
|
+
if (J(r)) if (function(e) {
|
|
820
|
+
const t = e._controlledReadableByteStream._reader;
|
|
821
|
+
for (; t._readRequests.length > 0;) {
|
|
822
|
+
if (0 === e._queueTotalSize) return;
|
|
823
|
+
Je(e, t._readRequests.shift());
|
|
824
|
+
}
|
|
825
|
+
}(e), 0 === X(r)) Fe(e, a, n, i);
|
|
826
|
+
else {
|
|
827
|
+
e._pendingPullIntos.length > 0 && He(e);
|
|
828
|
+
G(r, new Uint8Array(a, n, i), !1);
|
|
829
|
+
}
|
|
830
|
+
else if (ut(r)) {
|
|
831
|
+
Fe(e, a, n, i);
|
|
832
|
+
ze(r, Qe(e));
|
|
833
|
+
} else Fe(e, a, n, i);
|
|
834
|
+
je(e);
|
|
835
|
+
}
|
|
836
|
+
function Xe(e, t) {
|
|
837
|
+
const r = e._controlledReadableByteStream;
|
|
838
|
+
"readable" === r._state && (ke(e), qe(e), Ve(e), xr(r, t));
|
|
839
|
+
}
|
|
840
|
+
function Je(e, t) {
|
|
841
|
+
const r = e._queue.shift();
|
|
842
|
+
e._queueTotalSize -= r.byteLength, Ye(e);
|
|
843
|
+
const o = new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
|
|
844
|
+
t._chunkSteps(o);
|
|
845
|
+
}
|
|
846
|
+
function Ke(e) {
|
|
847
|
+
if (null === e._byobRequest && e._pendingPullIntos.length > 0) {
|
|
848
|
+
const t = e._pendingPullIntos.peek(), r = new Uint8Array(t.buffer, t.byteOffset + t.bytesFilled, t.byteLength - t.bytesFilled), o = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
849
|
+
(function(e, t, r) {
|
|
850
|
+
e._associatedReadableByteStreamController = t, e._view = r;
|
|
851
|
+
})(o, e, r), e._byobRequest = o;
|
|
852
|
+
}
|
|
853
|
+
return e._byobRequest;
|
|
854
|
+
}
|
|
855
|
+
function Ze(e) {
|
|
856
|
+
const t = e._controlledReadableByteStream._state;
|
|
857
|
+
return "errored" === t ? null : "closed" === t ? 0 : e._strategyHWM - e._queueTotalSize;
|
|
858
|
+
}
|
|
859
|
+
function et(e, t) {
|
|
860
|
+
const r = e._pendingPullIntos.peek();
|
|
861
|
+
if ("closed" === e._controlledReadableByteStream._state) {
|
|
862
|
+
if (0 !== t) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
|
|
863
|
+
} else {
|
|
864
|
+
if (0 === t) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
|
|
865
|
+
if (r.bytesFilled + t > r.byteLength) throw new RangeError("bytesWritten out of range");
|
|
866
|
+
}
|
|
867
|
+
r.buffer = ce(r.buffer), Ne(e, t);
|
|
868
|
+
}
|
|
869
|
+
function tt(e, t) {
|
|
870
|
+
const r = e._pendingPullIntos.peek();
|
|
871
|
+
if ("closed" === e._controlledReadableByteStream._state) {
|
|
872
|
+
if (0 !== t.byteLength) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
|
|
873
|
+
} else if (0 === t.byteLength) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
|
|
874
|
+
if (r.byteOffset + r.bytesFilled !== t.byteOffset) throw new RangeError("The region specified by view does not match byobRequest");
|
|
875
|
+
if (r.bufferByteLength !== t.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest");
|
|
876
|
+
if (r.bytesFilled + t.byteLength > r.byteLength) throw new RangeError("The region specified by view is larger than byobRequest");
|
|
877
|
+
const o = t.byteLength;
|
|
878
|
+
r.buffer = ce(t.buffer), Ne(e, o);
|
|
879
|
+
}
|
|
880
|
+
function rt(e, t, r, o, n, i, a) {
|
|
881
|
+
t._controlledReadableByteStream = e, t._pullAgain = !1, t._pulling = !1, t._byobRequest = null, t._queue = t._queueTotalSize = void 0, qe(t), t._closeRequested = !1, t._started = !1, t._strategyHWM = i, t._pullAlgorithm = o, t._cancelAlgorithm = n, t._autoAllocateChunkSize = a, t._pendingPullIntos = new v(), e._readableStreamController = t;
|
|
882
|
+
h(c(r()), () => (t._started = !0, je(t), null), (e) => (Xe(t, e), null));
|
|
883
|
+
}
|
|
884
|
+
function ot(e) {
|
|
885
|
+
return /* @__PURE__ */ new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`);
|
|
886
|
+
}
|
|
887
|
+
function nt(e) {
|
|
888
|
+
return /* @__PURE__ */ new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`);
|
|
889
|
+
}
|
|
890
|
+
function it(e, t) {
|
|
891
|
+
if ("byob" !== (e = `${e}`)) throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);
|
|
892
|
+
return e;
|
|
893
|
+
}
|
|
894
|
+
function at(e) {
|
|
895
|
+
return new ReadableStreamBYOBReader(e);
|
|
896
|
+
}
|
|
897
|
+
function st(e, t) {
|
|
898
|
+
e._reader._readIntoRequests.push(t);
|
|
899
|
+
}
|
|
900
|
+
function lt(e) {
|
|
901
|
+
return e._reader._readIntoRequests.length;
|
|
902
|
+
}
|
|
903
|
+
function ut(e) {
|
|
904
|
+
const t = e._reader;
|
|
905
|
+
return void 0 !== t && !!ft(t);
|
|
906
|
+
}
|
|
907
|
+
Object.defineProperties(ReadableByteStreamController.prototype, {
|
|
908
|
+
close: { enumerable: !0 },
|
|
909
|
+
enqueue: { enumerable: !0 },
|
|
910
|
+
error: { enumerable: !0 },
|
|
911
|
+
byobRequest: { enumerable: !0 },
|
|
912
|
+
desiredSize: { enumerable: !0 }
|
|
913
|
+
}), o(ReadableByteStreamController.prototype.close, "close"), o(ReadableByteStreamController.prototype.enqueue, "enqueue"), o(ReadableByteStreamController.prototype.error, "error"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
|
|
914
|
+
value: "ReadableByteStreamController",
|
|
915
|
+
configurable: !0
|
|
916
|
+
});
|
|
917
|
+
var ReadableStreamBYOBReader = class {
|
|
918
|
+
constructor(e) {
|
|
919
|
+
if (M(e, 1, "ReadableStreamBYOBReader"), H(e, "First parameter"), $r(e)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
920
|
+
if (!Oe(e._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
|
|
921
|
+
E(this, e), this._readIntoRequests = new v();
|
|
922
|
+
}
|
|
923
|
+
get closed() {
|
|
924
|
+
return ft(this) ? this._closedPromise : d(_t("closed"));
|
|
925
|
+
}
|
|
926
|
+
cancel(e = void 0) {
|
|
927
|
+
return ft(this) ? void 0 === this._ownerReadableStream ? d(B("cancel")) : W(this, e) : d(_t("cancel"));
|
|
928
|
+
}
|
|
929
|
+
read(e, t = {}) {
|
|
930
|
+
if (!ft(this)) return d(_t("read"));
|
|
931
|
+
if (!ArrayBuffer.isView(e)) return d(/* @__PURE__ */ new TypeError("view must be an array buffer view"));
|
|
932
|
+
if (0 === e.byteLength) return d(/* @__PURE__ */ new TypeError("view must have non-zero byteLength"));
|
|
933
|
+
if (0 === e.buffer.byteLength) return d(/* @__PURE__ */ new TypeError("view's buffer must have non-zero byteLength"));
|
|
934
|
+
if (de(e.buffer)) return d(/* @__PURE__ */ new TypeError("view's buffer has been detached"));
|
|
935
|
+
let r;
|
|
936
|
+
try {
|
|
937
|
+
r = function(e, t) {
|
|
938
|
+
var r;
|
|
939
|
+
return L(e, t), { min: N(null !== (r = null == e ? void 0 : e.min) && void 0 !== r ? r : 1, `${t} has member 'min' that`) };
|
|
940
|
+
}(t, "options");
|
|
941
|
+
} catch (e) {
|
|
942
|
+
return d(e);
|
|
943
|
+
}
|
|
944
|
+
const o = r.min;
|
|
945
|
+
if (0 === o) return d(/* @__PURE__ */ new TypeError("options.min must be greater than 0"));
|
|
946
|
+
if (function(e) {
|
|
947
|
+
return Ee(e.constructor);
|
|
948
|
+
}(e)) {
|
|
949
|
+
if (o > e.byteLength) return d(/* @__PURE__ */ new RangeError("options.min must be less than or equal to view's byteLength"));
|
|
950
|
+
} else if (o > e.length) return d(/* @__PURE__ */ new RangeError("options.min must be less than or equal to view's length"));
|
|
951
|
+
if (void 0 === this._ownerReadableStream) return d(B("read from"));
|
|
952
|
+
const n = function(e, t, r) {
|
|
953
|
+
const o = e._ownerReadableStream;
|
|
954
|
+
return "errored" === o._state || function(e, t, r) {
|
|
955
|
+
const o = e._controlledReadableByteStream, n = We(t.constructor), { byteLength: i } = t, a = r * n;
|
|
956
|
+
return !(e._pendingPullIntos.length > 0) && ("closed" === o._state || e._queueTotalSize >= a);
|
|
957
|
+
}(o._readableStreamController, t, r);
|
|
958
|
+
}(this, e, o) ? new dt() : new ct();
|
|
959
|
+
return ht(this, e, o, n), n._promise;
|
|
960
|
+
}
|
|
961
|
+
releaseLock() {
|
|
962
|
+
if (!ft(this)) throw _t("releaseLock");
|
|
963
|
+
void 0 !== this._ownerReadableStream && function(e) {
|
|
964
|
+
O(e);
|
|
965
|
+
bt(e, /* @__PURE__ */ new TypeError("Reader was released"));
|
|
966
|
+
}(this);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
Object.defineProperties(ReadableStreamBYOBReader.prototype, {
|
|
970
|
+
cancel: { enumerable: !0 },
|
|
971
|
+
read: { enumerable: !0 },
|
|
972
|
+
releaseLock: { enumerable: !0 },
|
|
973
|
+
closed: { enumerable: !0 }
|
|
974
|
+
}), o(ReadableStreamBYOBReader.prototype.cancel, "cancel"), o(ReadableStreamBYOBReader.prototype.read, "read"), o(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
|
|
975
|
+
value: "ReadableStreamBYOBReader",
|
|
976
|
+
configurable: !0
|
|
977
|
+
});
|
|
978
|
+
var ct = class {
|
|
979
|
+
constructor() {
|
|
980
|
+
this._promise = u((e, t) => {
|
|
981
|
+
this._resolvePromise = e, this._rejectPromise = t;
|
|
982
|
+
});
|
|
983
|
+
}
|
|
984
|
+
_chunkSteps(e) {
|
|
985
|
+
this._resolvePromise({
|
|
986
|
+
value: e,
|
|
987
|
+
done: !1
|
|
988
|
+
});
|
|
989
|
+
}
|
|
990
|
+
_closeSteps(e) {
|
|
991
|
+
this._resolvePromise({
|
|
992
|
+
value: e,
|
|
993
|
+
done: !0
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
_errorSteps(e) {
|
|
997
|
+
this._rejectPromise(e);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
var dt = class {
|
|
1001
|
+
constructor() {
|
|
1002
|
+
this._promise = void 0;
|
|
1003
|
+
}
|
|
1004
|
+
_chunkSteps(e) {
|
|
1005
|
+
this._promise = l({
|
|
1006
|
+
value: e,
|
|
1007
|
+
done: !1
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
_closeSteps(e) {
|
|
1011
|
+
this._promise = l({
|
|
1012
|
+
value: e,
|
|
1013
|
+
done: !0
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
_errorSteps(e) {
|
|
1017
|
+
this._promise = d(e);
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
function ft(e) {
|
|
1021
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_readIntoRequests") && e instanceof ReadableStreamBYOBReader;
|
|
1022
|
+
}
|
|
1023
|
+
function ht(e, t, r, o) {
|
|
1024
|
+
const n = e._ownerReadableStream;
|
|
1025
|
+
n._disturbed = !0, "errored" === n._state ? o._errorSteps(n._storedError) : function(e, t, r, o) {
|
|
1026
|
+
const n = e._controlledReadableByteStream, i = t.constructor, a = We(i), { byteOffset: s, byteLength: l } = t, u = r * a;
|
|
1027
|
+
let c;
|
|
1028
|
+
try {
|
|
1029
|
+
c = ce(t.buffer);
|
|
1030
|
+
} catch (e) {
|
|
1031
|
+
o._errorSteps(e);
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
const d = {
|
|
1035
|
+
buffer: c,
|
|
1036
|
+
bufferByteLength: c.byteLength,
|
|
1037
|
+
byteOffset: s,
|
|
1038
|
+
byteLength: l,
|
|
1039
|
+
bytesFilled: 0,
|
|
1040
|
+
minimumFill: u,
|
|
1041
|
+
elementSize: a,
|
|
1042
|
+
viewConstructor: i,
|
|
1043
|
+
readerType: "byob"
|
|
1044
|
+
};
|
|
1045
|
+
if (e._pendingPullIntos.length > 0) return e._pendingPullIntos.push(d), void st(n, o);
|
|
1046
|
+
if ("closed" === n._state) {
|
|
1047
|
+
const e = new i(d.buffer, d.byteOffset, 0);
|
|
1048
|
+
o._closeSteps(e);
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
if (e._queueTotalSize > 0) {
|
|
1052
|
+
if ($e(e, d)) {
|
|
1053
|
+
const t = De(d);
|
|
1054
|
+
Ye(e), o._chunkSteps(t);
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
if (e._closeRequested) {
|
|
1058
|
+
const t = /* @__PURE__ */ new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
1059
|
+
Xe(e, t), o._errorSteps(t);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
e._pendingPullIntos.push(d), st(n, o), je(e);
|
|
1064
|
+
}(n._readableStreamController, t, r, o);
|
|
1065
|
+
}
|
|
1066
|
+
function bt(e, t) {
|
|
1067
|
+
const r = e._readIntoRequests;
|
|
1068
|
+
e._readIntoRequests = new v(), r.forEach((e) => {
|
|
1069
|
+
e._errorSteps(t);
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
function _t(e) {
|
|
1073
|
+
return /* @__PURE__ */ new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`);
|
|
1074
|
+
}
|
|
1075
|
+
function mt(e, t) {
|
|
1076
|
+
const { highWaterMark: r } = e;
|
|
1077
|
+
if (void 0 === r) return t;
|
|
1078
|
+
if (Re(r) || r < 0) throw new RangeError("Invalid highWaterMark");
|
|
1079
|
+
return r;
|
|
1080
|
+
}
|
|
1081
|
+
function pt(e) {
|
|
1082
|
+
const { size: t } = e;
|
|
1083
|
+
return t || (() => 1);
|
|
1084
|
+
}
|
|
1085
|
+
function yt(e, t) {
|
|
1086
|
+
L(e, t);
|
|
1087
|
+
const r = null == e ? void 0 : e.highWaterMark, o = null == e ? void 0 : e.size;
|
|
1088
|
+
return {
|
|
1089
|
+
highWaterMark: void 0 === r ? void 0 : x(r),
|
|
1090
|
+
size: void 0 === o ? void 0 : St(o, `${t} has member 'size' that`)
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
function St(e, t) {
|
|
1094
|
+
return I(e, t), (t) => x(e(t));
|
|
1095
|
+
}
|
|
1096
|
+
function gt(e, t, r) {
|
|
1097
|
+
return I(e, r), (r) => g(e, t, [r]);
|
|
1098
|
+
}
|
|
1099
|
+
function vt(e, t, r) {
|
|
1100
|
+
return I(e, r), () => g(e, t, []);
|
|
1101
|
+
}
|
|
1102
|
+
function wt(e, t, r) {
|
|
1103
|
+
return I(e, r), (r) => S(e, t, [r]);
|
|
1104
|
+
}
|
|
1105
|
+
function Rt(e, t, r) {
|
|
1106
|
+
return I(e, r), (r, o) => g(e, t, [r, o]);
|
|
1107
|
+
}
|
|
1108
|
+
function Tt(e, t) {
|
|
1109
|
+
if (!qt(e)) throw new TypeError(`${t} is not a WritableStream.`);
|
|
1110
|
+
}
|
|
1111
|
+
var WritableStream = class {
|
|
1112
|
+
constructor(e = {}, t = {}) {
|
|
1113
|
+
void 0 === e ? e = null : $(e, "First parameter");
|
|
1114
|
+
const r = yt(t, "Second parameter"), o = function(e, t) {
|
|
1115
|
+
L(e, t);
|
|
1116
|
+
const r = null == e ? void 0 : e.abort, o = null == e ? void 0 : e.close, n = null == e ? void 0 : e.start, i = null == e ? void 0 : e.type, a = null == e ? void 0 : e.write;
|
|
1117
|
+
return {
|
|
1118
|
+
abort: void 0 === r ? void 0 : gt(r, e, `${t} has member 'abort' that`),
|
|
1119
|
+
close: void 0 === o ? void 0 : vt(o, e, `${t} has member 'close' that`),
|
|
1120
|
+
start: void 0 === n ? void 0 : wt(n, e, `${t} has member 'start' that`),
|
|
1121
|
+
write: void 0 === a ? void 0 : Rt(a, e, `${t} has member 'write' that`),
|
|
1122
|
+
type: i
|
|
1123
|
+
};
|
|
1124
|
+
}(e, "First parameter");
|
|
1125
|
+
Ct(this);
|
|
1126
|
+
if (void 0 !== o.type) throw new RangeError("Invalid type is specified");
|
|
1127
|
+
const n = pt(r);
|
|
1128
|
+
(function(e, t, r, o) {
|
|
1129
|
+
const n = Object.create(WritableStreamDefaultController.prototype);
|
|
1130
|
+
let i, a, s, l;
|
|
1131
|
+
i = void 0 !== t.start ? () => t.start(n) : () => {};
|
|
1132
|
+
a = void 0 !== t.write ? (e) => t.write(e, n) : () => c(void 0);
|
|
1133
|
+
s = void 0 !== t.close ? () => t.close() : () => c(void 0);
|
|
1134
|
+
l = void 0 !== t.abort ? (e) => t.abort(e) : () => c(void 0);
|
|
1135
|
+
Nt(e, n, i, a, s, l, r, o);
|
|
1136
|
+
})(this, o, mt(r, 1), n);
|
|
1137
|
+
}
|
|
1138
|
+
get locked() {
|
|
1139
|
+
if (!qt(this)) throw Kt("locked");
|
|
1140
|
+
return Et(this);
|
|
1141
|
+
}
|
|
1142
|
+
abort(e = void 0) {
|
|
1143
|
+
return qt(this) ? Et(this) ? d(/* @__PURE__ */ new TypeError("Cannot abort a stream that already has a writer")) : Wt(this, e) : d(Kt("abort"));
|
|
1144
|
+
}
|
|
1145
|
+
close() {
|
|
1146
|
+
return qt(this) ? Et(this) ? d(/* @__PURE__ */ new TypeError("Cannot close a stream that already has a writer")) : At(this) ? d(/* @__PURE__ */ new TypeError("Cannot close an already-closing stream")) : Ot(this) : d(Kt("close"));
|
|
1147
|
+
}
|
|
1148
|
+
getWriter() {
|
|
1149
|
+
if (!qt(this)) throw Kt("getWriter");
|
|
1150
|
+
return Pt(this);
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
function Pt(e) {
|
|
1154
|
+
return new WritableStreamDefaultWriter(e);
|
|
1155
|
+
}
|
|
1156
|
+
function Ct(e) {
|
|
1157
|
+
e._state = "writable", e._storedError = void 0, e._writer = void 0, e._writableStreamController = void 0, e._writeRequests = new v(), e._inFlightWriteRequest = void 0, e._closeRequest = void 0, e._inFlightCloseRequest = void 0, e._pendingAbortRequest = void 0, e._backpressure = !1;
|
|
1158
|
+
}
|
|
1159
|
+
function qt(e) {
|
|
1160
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_writableStreamController") && e instanceof WritableStream;
|
|
1161
|
+
}
|
|
1162
|
+
function Et(e) {
|
|
1163
|
+
return void 0 !== e._writer;
|
|
1164
|
+
}
|
|
1165
|
+
function Wt(e, t) {
|
|
1166
|
+
var r;
|
|
1167
|
+
if ("closed" === e._state || "errored" === e._state) return c(void 0);
|
|
1168
|
+
e._writableStreamController._abortReason = t, null === (r = e._writableStreamController._abortController) || void 0 === r || r.abort(t);
|
|
1169
|
+
const o = e._state;
|
|
1170
|
+
if ("closed" === o || "errored" === o) return c(void 0);
|
|
1171
|
+
if (void 0 !== e._pendingAbortRequest) return e._pendingAbortRequest._promise;
|
|
1172
|
+
let n = !1;
|
|
1173
|
+
"erroring" === o && (n = !0, t = void 0);
|
|
1174
|
+
const i = u((r, o) => {
|
|
1175
|
+
e._pendingAbortRequest = {
|
|
1176
|
+
_promise: void 0,
|
|
1177
|
+
_resolve: r,
|
|
1178
|
+
_reject: o,
|
|
1179
|
+
_reason: t,
|
|
1180
|
+
_wasAlreadyErroring: n
|
|
1181
|
+
};
|
|
1182
|
+
});
|
|
1183
|
+
return e._pendingAbortRequest._promise = i, n || jt(e, t), i;
|
|
1184
|
+
}
|
|
1185
|
+
function Ot(e) {
|
|
1186
|
+
const t = e._state;
|
|
1187
|
+
if ("closed" === t || "errored" === t) return d(/* @__PURE__ */ new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));
|
|
1188
|
+
const r = u((t, r) => {
|
|
1189
|
+
e._closeRequest = {
|
|
1190
|
+
_resolve: t,
|
|
1191
|
+
_reject: r
|
|
1192
|
+
};
|
|
1193
|
+
}), o = e._writer;
|
|
1194
|
+
var n;
|
|
1195
|
+
return void 0 !== o && e._backpressure && "writable" === t && cr(o), Ce(n = e._writableStreamController, xt, 0), Ut(n), r;
|
|
1196
|
+
}
|
|
1197
|
+
function Bt(e, t) {
|
|
1198
|
+
"writable" !== e._state ? kt(e) : jt(e, t);
|
|
1199
|
+
}
|
|
1200
|
+
function jt(e, t) {
|
|
1201
|
+
const r = e._writableStreamController;
|
|
1202
|
+
e._state = "erroring", e._storedError = t;
|
|
1203
|
+
const o = e._writer;
|
|
1204
|
+
void 0 !== o && $t(o, t), !function(e) {
|
|
1205
|
+
if (void 0 === e._inFlightWriteRequest && void 0 === e._inFlightCloseRequest) return !1;
|
|
1206
|
+
return !0;
|
|
1207
|
+
}(e) && r._started && kt(e);
|
|
1208
|
+
}
|
|
1209
|
+
function kt(e) {
|
|
1210
|
+
e._state = "errored", e._writableStreamController[R]();
|
|
1211
|
+
const t = e._storedError;
|
|
1212
|
+
if (e._writeRequests.forEach((e) => {
|
|
1213
|
+
e._reject(t);
|
|
1214
|
+
}), e._writeRequests = new v(), void 0 === e._pendingAbortRequest) return void zt(e);
|
|
1215
|
+
const r = e._pendingAbortRequest;
|
|
1216
|
+
if (e._pendingAbortRequest = void 0, r._wasAlreadyErroring) return r._reject(t), void zt(e);
|
|
1217
|
+
h(e._writableStreamController[w](r._reason), () => (r._resolve(), zt(e), null), (t) => (r._reject(t), zt(e), null));
|
|
1218
|
+
}
|
|
1219
|
+
function At(e) {
|
|
1220
|
+
return void 0 !== e._closeRequest || void 0 !== e._inFlightCloseRequest;
|
|
1221
|
+
}
|
|
1222
|
+
function zt(e) {
|
|
1223
|
+
void 0 !== e._closeRequest && (e._closeRequest._reject(e._storedError), e._closeRequest = void 0);
|
|
1224
|
+
const t = e._writer;
|
|
1225
|
+
void 0 !== t && nr(t, e._storedError);
|
|
1226
|
+
}
|
|
1227
|
+
function Dt(e, t) {
|
|
1228
|
+
const r = e._writer;
|
|
1229
|
+
void 0 !== r && t !== e._backpressure && (t ? function(e) {
|
|
1230
|
+
ar(e);
|
|
1231
|
+
}(r) : cr(r)), e._backpressure = t;
|
|
1232
|
+
}
|
|
1233
|
+
Object.defineProperties(WritableStream.prototype, {
|
|
1234
|
+
abort: { enumerable: !0 },
|
|
1235
|
+
close: { enumerable: !0 },
|
|
1236
|
+
getWriter: { enumerable: !0 },
|
|
1237
|
+
locked: { enumerable: !0 }
|
|
1238
|
+
}), o(WritableStream.prototype.abort, "abort"), o(WritableStream.prototype.close, "close"), o(WritableStream.prototype.getWriter, "getWriter"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
|
|
1239
|
+
value: "WritableStream",
|
|
1240
|
+
configurable: !0
|
|
1241
|
+
});
|
|
1242
|
+
var WritableStreamDefaultWriter = class {
|
|
1243
|
+
constructor(e) {
|
|
1244
|
+
if (M(e, 1, "WritableStreamDefaultWriter"), Tt(e, "First parameter"), Et(e)) throw new TypeError("This stream has already been locked for exclusive writing by another writer");
|
|
1245
|
+
this._ownerWritableStream = e, e._writer = this;
|
|
1246
|
+
const t = e._state;
|
|
1247
|
+
if ("writable" === t) !At(e) && e._backpressure ? ar(this) : lr(this), rr(this);
|
|
1248
|
+
else if ("erroring" === t) sr(this, e._storedError), rr(this);
|
|
1249
|
+
else if ("closed" === t) lr(this), rr(r = this), ir(r);
|
|
1250
|
+
else {
|
|
1251
|
+
const t = e._storedError;
|
|
1252
|
+
sr(this, t), or(this, t);
|
|
1253
|
+
}
|
|
1254
|
+
var r;
|
|
1255
|
+
}
|
|
1256
|
+
get closed() {
|
|
1257
|
+
return Ft(this) ? this._closedPromise : d(er("closed"));
|
|
1258
|
+
}
|
|
1259
|
+
get desiredSize() {
|
|
1260
|
+
if (!Ft(this)) throw er("desiredSize");
|
|
1261
|
+
if (void 0 === this._ownerWritableStream) throw tr("desiredSize");
|
|
1262
|
+
return function(e) {
|
|
1263
|
+
const t = e._ownerWritableStream, r = t._state;
|
|
1264
|
+
if ("errored" === r || "erroring" === r) return null;
|
|
1265
|
+
if ("closed" === r) return 0;
|
|
1266
|
+
return Vt(t._writableStreamController);
|
|
1267
|
+
}(this);
|
|
1268
|
+
}
|
|
1269
|
+
get ready() {
|
|
1270
|
+
return Ft(this) ? this._readyPromise : d(er("ready"));
|
|
1271
|
+
}
|
|
1272
|
+
abort(e = void 0) {
|
|
1273
|
+
return Ft(this) ? void 0 === this._ownerWritableStream ? d(tr("abort")) : function(e, t) {
|
|
1274
|
+
return Wt(e._ownerWritableStream, t);
|
|
1275
|
+
}(this, e) : d(er("abort"));
|
|
1276
|
+
}
|
|
1277
|
+
close() {
|
|
1278
|
+
if (!Ft(this)) return d(er("close"));
|
|
1279
|
+
const e = this._ownerWritableStream;
|
|
1280
|
+
return void 0 === e ? d(tr("close")) : At(e) ? d(/* @__PURE__ */ new TypeError("Cannot close an already-closing stream")) : Lt(this);
|
|
1281
|
+
}
|
|
1282
|
+
releaseLock() {
|
|
1283
|
+
if (!Ft(this)) throw er("releaseLock");
|
|
1284
|
+
void 0 !== this._ownerWritableStream && Mt(this);
|
|
1285
|
+
}
|
|
1286
|
+
write(e = void 0) {
|
|
1287
|
+
return Ft(this) ? void 0 === this._ownerWritableStream ? d(tr("write to")) : Yt(this, e) : d(er("write"));
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
function Ft(e) {
|
|
1291
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_ownerWritableStream") && e instanceof WritableStreamDefaultWriter;
|
|
1292
|
+
}
|
|
1293
|
+
function Lt(e) {
|
|
1294
|
+
return Ot(e._ownerWritableStream);
|
|
1295
|
+
}
|
|
1296
|
+
function It(e, t) {
|
|
1297
|
+
"pending" === e._closedPromiseState ? nr(e, t) : function(e, t) {
|
|
1298
|
+
or(e, t);
|
|
1299
|
+
}(e, t);
|
|
1300
|
+
}
|
|
1301
|
+
function $t(e, t) {
|
|
1302
|
+
"pending" === e._readyPromiseState ? ur(e, t) : function(e, t) {
|
|
1303
|
+
sr(e, t);
|
|
1304
|
+
}(e, t);
|
|
1305
|
+
}
|
|
1306
|
+
function Mt(e) {
|
|
1307
|
+
const t = e._ownerWritableStream, r = /* @__PURE__ */ new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
|
|
1308
|
+
$t(e, r), It(e, r), t._writer = void 0, e._ownerWritableStream = void 0;
|
|
1309
|
+
}
|
|
1310
|
+
function Yt(e, t) {
|
|
1311
|
+
const r = e._ownerWritableStream, o = r._writableStreamController, n = function(e, t) {
|
|
1312
|
+
if (void 0 === e._strategySizeAlgorithm) return 1;
|
|
1313
|
+
try {
|
|
1314
|
+
return e._strategySizeAlgorithm(t);
|
|
1315
|
+
} catch (t) {
|
|
1316
|
+
return Gt(e, t), 1;
|
|
1317
|
+
}
|
|
1318
|
+
}(o, t);
|
|
1319
|
+
if (r !== e._ownerWritableStream) return d(tr("write to"));
|
|
1320
|
+
const i = r._state;
|
|
1321
|
+
if ("errored" === i) return d(r._storedError);
|
|
1322
|
+
if (At(r) || "closed" === i) return d(/* @__PURE__ */ new TypeError("The stream is closing or closed and cannot be written to"));
|
|
1323
|
+
if ("erroring" === i) return d(r._storedError);
|
|
1324
|
+
const a = function(e) {
|
|
1325
|
+
return u((t, r) => {
|
|
1326
|
+
const o = {
|
|
1327
|
+
_resolve: t,
|
|
1328
|
+
_reject: r
|
|
1329
|
+
};
|
|
1330
|
+
e._writeRequests.push(o);
|
|
1331
|
+
});
|
|
1332
|
+
}(r);
|
|
1333
|
+
return function(e, t, r) {
|
|
1334
|
+
try {
|
|
1335
|
+
Ce(e, t, r);
|
|
1336
|
+
} catch (t) {
|
|
1337
|
+
Gt(e, t);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
const o = e._controlledWritableStream;
|
|
1341
|
+
if (!At(o) && "writable" === o._state) Dt(o, Xt(e));
|
|
1342
|
+
Ut(e);
|
|
1343
|
+
}(o, t, n), a;
|
|
1344
|
+
}
|
|
1345
|
+
Object.defineProperties(WritableStreamDefaultWriter.prototype, {
|
|
1346
|
+
abort: { enumerable: !0 },
|
|
1347
|
+
close: { enumerable: !0 },
|
|
1348
|
+
releaseLock: { enumerable: !0 },
|
|
1349
|
+
write: { enumerable: !0 },
|
|
1350
|
+
closed: { enumerable: !0 },
|
|
1351
|
+
desiredSize: { enumerable: !0 },
|
|
1352
|
+
ready: { enumerable: !0 }
|
|
1353
|
+
}), o(WritableStreamDefaultWriter.prototype.abort, "abort"), o(WritableStreamDefaultWriter.prototype.close, "close"), o(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock"), o(WritableStreamDefaultWriter.prototype.write, "write"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
|
|
1354
|
+
value: "WritableStreamDefaultWriter",
|
|
1355
|
+
configurable: !0
|
|
1356
|
+
});
|
|
1357
|
+
const xt = {};
|
|
1358
|
+
var WritableStreamDefaultController = class {
|
|
1359
|
+
constructor() {
|
|
1360
|
+
throw new TypeError("Illegal constructor");
|
|
1361
|
+
}
|
|
1362
|
+
get abortReason() {
|
|
1363
|
+
if (!Qt(this)) throw Zt("abortReason");
|
|
1364
|
+
return this._abortReason;
|
|
1365
|
+
}
|
|
1366
|
+
get signal() {
|
|
1367
|
+
if (!Qt(this)) throw Zt("signal");
|
|
1368
|
+
if (void 0 === this._abortController) throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
|
|
1369
|
+
return this._abortController.signal;
|
|
1370
|
+
}
|
|
1371
|
+
error(e = void 0) {
|
|
1372
|
+
if (!Qt(this)) throw Zt("error");
|
|
1373
|
+
"writable" === this._controlledWritableStream._state && Jt(this, e);
|
|
1374
|
+
}
|
|
1375
|
+
[w](e) {
|
|
1376
|
+
const t = this._abortAlgorithm(e);
|
|
1377
|
+
return Ht(this), t;
|
|
1378
|
+
}
|
|
1379
|
+
[R]() {
|
|
1380
|
+
qe(this);
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
function Qt(e) {
|
|
1384
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_controlledWritableStream") && e instanceof WritableStreamDefaultController;
|
|
1385
|
+
}
|
|
1386
|
+
function Nt(e, t, r, o, n, i, a, s) {
|
|
1387
|
+
t._controlledWritableStream = e, e._writableStreamController = t, t._queue = void 0, t._queueTotalSize = void 0, qe(t), t._abortReason = void 0, t._abortController = function() {
|
|
1388
|
+
if ("function" == typeof AbortController) return new AbortController();
|
|
1389
|
+
}(), t._started = !1, t._strategySizeAlgorithm = s, t._strategyHWM = a, t._writeAlgorithm = o, t._closeAlgorithm = n, t._abortAlgorithm = i;
|
|
1390
|
+
Dt(e, Xt(t));
|
|
1391
|
+
h(c(r()), () => (t._started = !0, Ut(t), null), (r) => (t._started = !0, Bt(e, r), null));
|
|
1392
|
+
}
|
|
1393
|
+
function Ht(e) {
|
|
1394
|
+
e._writeAlgorithm = void 0, e._closeAlgorithm = void 0, e._abortAlgorithm = void 0, e._strategySizeAlgorithm = void 0;
|
|
1395
|
+
}
|
|
1396
|
+
function Vt(e) {
|
|
1397
|
+
return e._strategyHWM - e._queueTotalSize;
|
|
1398
|
+
}
|
|
1399
|
+
function Ut(e) {
|
|
1400
|
+
const t = e._controlledWritableStream;
|
|
1401
|
+
if (!e._started) return;
|
|
1402
|
+
if (void 0 !== t._inFlightWriteRequest) return;
|
|
1403
|
+
if ("erroring" === t._state) return void kt(t);
|
|
1404
|
+
if (0 === e._queue.length) return;
|
|
1405
|
+
const r = e._queue.peek().value;
|
|
1406
|
+
r === xt ? function(e) {
|
|
1407
|
+
const t = e._controlledWritableStream;
|
|
1408
|
+
(function(e) {
|
|
1409
|
+
e._inFlightCloseRequest = e._closeRequest, e._closeRequest = void 0;
|
|
1410
|
+
})(t), Pe(e);
|
|
1411
|
+
const r = e._closeAlgorithm();
|
|
1412
|
+
Ht(e), h(r, () => (function(e) {
|
|
1413
|
+
e._inFlightCloseRequest._resolve(void 0), e._inFlightCloseRequest = void 0, "erroring" === e._state && (e._storedError = void 0, void 0 !== e._pendingAbortRequest && (e._pendingAbortRequest._resolve(), e._pendingAbortRequest = void 0)), e._state = "closed";
|
|
1414
|
+
const t = e._writer;
|
|
1415
|
+
void 0 !== t && ir(t);
|
|
1416
|
+
}(t), null), (e) => (function(e, t) {
|
|
1417
|
+
e._inFlightCloseRequest._reject(t), e._inFlightCloseRequest = void 0, void 0 !== e._pendingAbortRequest && (e._pendingAbortRequest._reject(t), e._pendingAbortRequest = void 0), Bt(e, t);
|
|
1418
|
+
}(t, e), null));
|
|
1419
|
+
}(e) : function(e, t) {
|
|
1420
|
+
const r = e._controlledWritableStream;
|
|
1421
|
+
(function(e) {
|
|
1422
|
+
e._inFlightWriteRequest = e._writeRequests.shift();
|
|
1423
|
+
})(r);
|
|
1424
|
+
h(e._writeAlgorithm(t), () => {
|
|
1425
|
+
(function(e) {
|
|
1426
|
+
e._inFlightWriteRequest._resolve(void 0), e._inFlightWriteRequest = void 0;
|
|
1427
|
+
})(r);
|
|
1428
|
+
const t = r._state;
|
|
1429
|
+
if (Pe(e), !At(r) && "writable" === t) {
|
|
1430
|
+
const t = Xt(e);
|
|
1431
|
+
Dt(r, t);
|
|
1432
|
+
}
|
|
1433
|
+
return Ut(e), null;
|
|
1434
|
+
}, (t) => ("writable" === r._state && Ht(e), function(e, t) {
|
|
1435
|
+
e._inFlightWriteRequest._reject(t), e._inFlightWriteRequest = void 0, Bt(e, t);
|
|
1436
|
+
}(r, t), null));
|
|
1437
|
+
}(e, r);
|
|
1438
|
+
}
|
|
1439
|
+
function Gt(e, t) {
|
|
1440
|
+
"writable" === e._controlledWritableStream._state && Jt(e, t);
|
|
1441
|
+
}
|
|
1442
|
+
function Xt(e) {
|
|
1443
|
+
return Vt(e) <= 0;
|
|
1444
|
+
}
|
|
1445
|
+
function Jt(e, t) {
|
|
1446
|
+
const r = e._controlledWritableStream;
|
|
1447
|
+
Ht(e), jt(r, t);
|
|
1448
|
+
}
|
|
1449
|
+
function Kt(e) {
|
|
1450
|
+
return /* @__PURE__ */ new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`);
|
|
1451
|
+
}
|
|
1452
|
+
function Zt(e) {
|
|
1453
|
+
return /* @__PURE__ */ new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`);
|
|
1454
|
+
}
|
|
1455
|
+
function er(e) {
|
|
1456
|
+
return /* @__PURE__ */ new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`);
|
|
1457
|
+
}
|
|
1458
|
+
function tr(e) {
|
|
1459
|
+
return /* @__PURE__ */ new TypeError("Cannot " + e + " a stream using a released writer");
|
|
1460
|
+
}
|
|
1461
|
+
function rr(e) {
|
|
1462
|
+
e._closedPromise = u((t, r) => {
|
|
1463
|
+
e._closedPromise_resolve = t, e._closedPromise_reject = r, e._closedPromiseState = "pending";
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
function or(e, t) {
|
|
1467
|
+
rr(e), nr(e, t);
|
|
1468
|
+
}
|
|
1469
|
+
function nr(e, t) {
|
|
1470
|
+
void 0 !== e._closedPromise_reject && (p(e._closedPromise), e._closedPromise_reject(t), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0, e._closedPromiseState = "rejected");
|
|
1471
|
+
}
|
|
1472
|
+
function ir(e) {
|
|
1473
|
+
void 0 !== e._closedPromise_resolve && (e._closedPromise_resolve(void 0), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0, e._closedPromiseState = "resolved");
|
|
1474
|
+
}
|
|
1475
|
+
function ar(e) {
|
|
1476
|
+
e._readyPromise = u((t, r) => {
|
|
1477
|
+
e._readyPromise_resolve = t, e._readyPromise_reject = r;
|
|
1478
|
+
}), e._readyPromiseState = "pending";
|
|
1479
|
+
}
|
|
1480
|
+
function sr(e, t) {
|
|
1481
|
+
ar(e), ur(e, t);
|
|
1482
|
+
}
|
|
1483
|
+
function lr(e) {
|
|
1484
|
+
ar(e), cr(e);
|
|
1485
|
+
}
|
|
1486
|
+
function ur(e, t) {
|
|
1487
|
+
void 0 !== e._readyPromise_reject && (p(e._readyPromise), e._readyPromise_reject(t), e._readyPromise_resolve = void 0, e._readyPromise_reject = void 0, e._readyPromiseState = "rejected");
|
|
1488
|
+
}
|
|
1489
|
+
function cr(e) {
|
|
1490
|
+
void 0 !== e._readyPromise_resolve && (e._readyPromise_resolve(void 0), e._readyPromise_resolve = void 0, e._readyPromise_reject = void 0, e._readyPromiseState = "fulfilled");
|
|
1491
|
+
}
|
|
1492
|
+
Object.defineProperties(WritableStreamDefaultController.prototype, {
|
|
1493
|
+
abortReason: { enumerable: !0 },
|
|
1494
|
+
signal: { enumerable: !0 },
|
|
1495
|
+
error: { enumerable: !0 }
|
|
1496
|
+
}), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
1497
|
+
value: "WritableStreamDefaultController",
|
|
1498
|
+
configurable: !0
|
|
1499
|
+
});
|
|
1500
|
+
const dr = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof global ? global : void 0;
|
|
1501
|
+
const fr = function() {
|
|
1502
|
+
const e = null == dr ? void 0 : dr.DOMException;
|
|
1503
|
+
return function(e) {
|
|
1504
|
+
if ("function" != typeof e && "object" != typeof e) return !1;
|
|
1505
|
+
if ("DOMException" !== e.name) return !1;
|
|
1506
|
+
try {
|
|
1507
|
+
return new e(), !0;
|
|
1508
|
+
} catch (e) {
|
|
1509
|
+
return !1;
|
|
1510
|
+
}
|
|
1511
|
+
}(e) ? e : void 0;
|
|
1512
|
+
}() || function() {
|
|
1513
|
+
const e = function(e, t) {
|
|
1514
|
+
this.message = e || "", this.name = t || "Error", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
1515
|
+
};
|
|
1516
|
+
return o(e, "DOMException"), e.prototype = Object.create(Error.prototype), Object.defineProperty(e.prototype, "constructor", {
|
|
1517
|
+
value: e,
|
|
1518
|
+
writable: !0,
|
|
1519
|
+
configurable: !0
|
|
1520
|
+
}), e;
|
|
1521
|
+
}();
|
|
1522
|
+
function hr(e, t, r, o, n, i) {
|
|
1523
|
+
const a = V(e), s = Pt(t);
|
|
1524
|
+
e._disturbed = !0;
|
|
1525
|
+
const l = new br(s), _ = new mr(l);
|
|
1526
|
+
return u((m, y) => {
|
|
1527
|
+
let S;
|
|
1528
|
+
if (void 0 !== i) {
|
|
1529
|
+
if (S = () => {
|
|
1530
|
+
const r = void 0 !== i.reason ? i.reason : new fr("Aborted", "AbortError"), a = [];
|
|
1531
|
+
o || a.push(() => "writable" === t._state ? Wt(t, r) : c(void 0)), n || a.push(() => "readable" === e._state ? Mr(e, r) : c(void 0)), T(() => Promise.all(a.map((e) => e())), !0, r);
|
|
1532
|
+
}, i.aborted) return void S();
|
|
1533
|
+
i.addEventListener("abort", S);
|
|
1534
|
+
}
|
|
1535
|
+
function g() {
|
|
1536
|
+
for (; !l._shuttingDown && !t._backpressure && "writable" === t._state && !At(t) && "readable" === e._state && re(a);) te(a, _);
|
|
1537
|
+
if (l._shuttingDown) return c(!0);
|
|
1538
|
+
if (t._backpressure) return f(s._readyPromise, g);
|
|
1539
|
+
const r = new _r(l);
|
|
1540
|
+
return te(a, r), r._promise;
|
|
1541
|
+
}
|
|
1542
|
+
var v, w, R;
|
|
1543
|
+
if (pr(e, a._closedPromise, (e) => (o ? P(!0, e) : T(() => Wt(t, e), !0, e), null)), pr(t, s._closedPromise, (t) => (n ? P(!0, t) : T(() => Mr(e, t), !0, t), null)), v = e, w = a._closedPromise, R = () => (r ? P() : T(() => function(e) {
|
|
1544
|
+
const t = e._ownerWritableStream, r = t._state;
|
|
1545
|
+
return At(t) || "closed" === r ? c(void 0) : "errored" === r ? d(t._storedError) : Lt(e);
|
|
1546
|
+
}(s)), null), "closed" === v._state ? R() : b(w, R), At(t) || "closed" === t._state) {
|
|
1547
|
+
const t = /* @__PURE__ */ new TypeError("the destination writable stream closed before all data could be piped to it");
|
|
1548
|
+
n ? P(!0, t) : T(() => Mr(e, t), !0, t);
|
|
1549
|
+
}
|
|
1550
|
+
function T(e, r, o) {
|
|
1551
|
+
function n() {
|
|
1552
|
+
return h(e(), () => C(r, o), (e) => C(!0, e)), null;
|
|
1553
|
+
}
|
|
1554
|
+
l._shuttingDown || (l._shuttingDown = !0, "writable" !== t._state || At(t) ? n() : b(l._waitForWritesToFinish(), n));
|
|
1555
|
+
}
|
|
1556
|
+
function P(e, r) {
|
|
1557
|
+
l._shuttingDown || (l._shuttingDown = !0, "writable" !== t._state || At(t) ? C(e, r) : b(l._waitForWritesToFinish(), () => C(e, r)));
|
|
1558
|
+
}
|
|
1559
|
+
function C(e, t) {
|
|
1560
|
+
return Mt(s), O(a), void 0 !== i && i.removeEventListener("abort", S), e ? y(t) : m(void 0), null;
|
|
1561
|
+
}
|
|
1562
|
+
p(u((e, t) => {
|
|
1563
|
+
(function r(o) {
|
|
1564
|
+
o ? e() : f(g(), r, t);
|
|
1565
|
+
})(!1);
|
|
1566
|
+
}));
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
var br = class {
|
|
1570
|
+
constructor(e) {
|
|
1571
|
+
this._writer = e, this._shuttingDown = !1, this._currentWrite = c(void 0);
|
|
1572
|
+
}
|
|
1573
|
+
_waitForWritesToFinish() {
|
|
1574
|
+
const e = this._currentWrite;
|
|
1575
|
+
return f(this._currentWrite, () => e !== this._currentWrite ? this._waitForWritesToFinish() : void 0);
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
var _r = class {
|
|
1579
|
+
constructor(e) {
|
|
1580
|
+
this._state = e, this._promise = u((e, t) => {
|
|
1581
|
+
this._resolvePromise = e, this._rejectPromise = t;
|
|
1582
|
+
});
|
|
1583
|
+
}
|
|
1584
|
+
_chunkSteps(t) {
|
|
1585
|
+
this._state._currentWrite = f(Yt(this._state._writer, t), void 0, e), this._resolvePromise(!1);
|
|
1586
|
+
}
|
|
1587
|
+
_closeSteps() {
|
|
1588
|
+
this._resolvePromise(!0);
|
|
1589
|
+
}
|
|
1590
|
+
_errorSteps(e) {
|
|
1591
|
+
this._rejectPromise(e);
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
var mr = class {
|
|
1595
|
+
constructor(e) {
|
|
1596
|
+
this._state = e;
|
|
1597
|
+
}
|
|
1598
|
+
_chunkSteps(t) {
|
|
1599
|
+
this._state._currentWrite = f(Yt(this._state._writer, t), void 0, e);
|
|
1600
|
+
}
|
|
1601
|
+
_closeSteps() {}
|
|
1602
|
+
_errorSteps(e) {}
|
|
1603
|
+
};
|
|
1604
|
+
function pr(e, t, r) {
|
|
1605
|
+
"errored" === e._state ? r(e._storedError) : _(t, r);
|
|
1606
|
+
}
|
|
1607
|
+
var ReadableStreamDefaultController = class {
|
|
1608
|
+
constructor() {
|
|
1609
|
+
throw new TypeError("Illegal constructor");
|
|
1610
|
+
}
|
|
1611
|
+
get desiredSize() {
|
|
1612
|
+
if (!yr(this)) throw Er("desiredSize");
|
|
1613
|
+
return Pr(this);
|
|
1614
|
+
}
|
|
1615
|
+
close() {
|
|
1616
|
+
if (!yr(this)) throw Er("close");
|
|
1617
|
+
if (!Cr(this)) throw new TypeError("The stream is not in a state that permits close");
|
|
1618
|
+
wr(this);
|
|
1619
|
+
}
|
|
1620
|
+
enqueue(e = void 0) {
|
|
1621
|
+
if (!yr(this)) throw Er("enqueue");
|
|
1622
|
+
if (!Cr(this)) throw new TypeError("The stream is not in a state that permits enqueue");
|
|
1623
|
+
return Rr(this, e);
|
|
1624
|
+
}
|
|
1625
|
+
error(e = void 0) {
|
|
1626
|
+
if (!yr(this)) throw Er("error");
|
|
1627
|
+
Tr(this, e);
|
|
1628
|
+
}
|
|
1629
|
+
[T](e) {
|
|
1630
|
+
qe(this);
|
|
1631
|
+
const t = this._cancelAlgorithm(e);
|
|
1632
|
+
return vr(this), t;
|
|
1633
|
+
}
|
|
1634
|
+
[P](e) {
|
|
1635
|
+
const t = this._controlledReadableStream;
|
|
1636
|
+
if (this._queue.length > 0) {
|
|
1637
|
+
const r = Pe(this);
|
|
1638
|
+
this._closeRequested && 0 === this._queue.length ? (vr(this), Yr(t)) : Sr(this), e._chunkSteps(r);
|
|
1639
|
+
} else U(t, e), Sr(this);
|
|
1640
|
+
}
|
|
1641
|
+
[C]() {
|
|
1642
|
+
return this._queue.length > 0;
|
|
1643
|
+
}
|
|
1644
|
+
[q]() {}
|
|
1645
|
+
};
|
|
1646
|
+
function yr(e) {
|
|
1647
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_controlledReadableStream") && e instanceof ReadableStreamDefaultController;
|
|
1648
|
+
}
|
|
1649
|
+
function Sr(e) {
|
|
1650
|
+
if (!gr(e)) return;
|
|
1651
|
+
if (e._pulling) return void (e._pullAgain = !0);
|
|
1652
|
+
e._pulling = !0;
|
|
1653
|
+
h(e._pullAlgorithm(), () => (e._pulling = !1, e._pullAgain && (e._pullAgain = !1, Sr(e)), null), (t) => (Tr(e, t), null));
|
|
1654
|
+
}
|
|
1655
|
+
function gr(e) {
|
|
1656
|
+
const t = e._controlledReadableStream;
|
|
1657
|
+
if (!Cr(e)) return !1;
|
|
1658
|
+
if (!e._started) return !1;
|
|
1659
|
+
if ($r(t) && X(t) > 0) return !0;
|
|
1660
|
+
return Pr(e) > 0;
|
|
1661
|
+
}
|
|
1662
|
+
function vr(e) {
|
|
1663
|
+
e._pullAlgorithm = void 0, e._cancelAlgorithm = void 0, e._strategySizeAlgorithm = void 0;
|
|
1664
|
+
}
|
|
1665
|
+
function wr(e) {
|
|
1666
|
+
if (!Cr(e)) return;
|
|
1667
|
+
const t = e._controlledReadableStream;
|
|
1668
|
+
e._closeRequested = !0, 0 === e._queue.length && (vr(e), Yr(t));
|
|
1669
|
+
}
|
|
1670
|
+
function Rr(e, t) {
|
|
1671
|
+
if (!Cr(e)) return;
|
|
1672
|
+
const r = e._controlledReadableStream;
|
|
1673
|
+
if ($r(r) && X(r) > 0) G(r, t, !1);
|
|
1674
|
+
else {
|
|
1675
|
+
let r;
|
|
1676
|
+
try {
|
|
1677
|
+
r = e._strategySizeAlgorithm(t);
|
|
1678
|
+
} catch (t) {
|
|
1679
|
+
throw Tr(e, t), t;
|
|
1680
|
+
}
|
|
1681
|
+
try {
|
|
1682
|
+
Ce(e, t, r);
|
|
1683
|
+
} catch (t) {
|
|
1684
|
+
throw Tr(e, t), t;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
Sr(e);
|
|
1688
|
+
}
|
|
1689
|
+
function Tr(e, t) {
|
|
1690
|
+
const r = e._controlledReadableStream;
|
|
1691
|
+
"readable" === r._state && (qe(e), vr(e), xr(r, t));
|
|
1692
|
+
}
|
|
1693
|
+
function Pr(e) {
|
|
1694
|
+
const t = e._controlledReadableStream._state;
|
|
1695
|
+
return "errored" === t ? null : "closed" === t ? 0 : e._strategyHWM - e._queueTotalSize;
|
|
1696
|
+
}
|
|
1697
|
+
function Cr(e) {
|
|
1698
|
+
const t = e._controlledReadableStream._state;
|
|
1699
|
+
return !e._closeRequested && "readable" === t;
|
|
1700
|
+
}
|
|
1701
|
+
function qr(e, t, r, o, n, i, a) {
|
|
1702
|
+
t._controlledReadableStream = e, t._queue = void 0, t._queueTotalSize = void 0, qe(t), t._started = !1, t._closeRequested = !1, t._pullAgain = !1, t._pulling = !1, t._strategySizeAlgorithm = a, t._strategyHWM = i, t._pullAlgorithm = o, t._cancelAlgorithm = n, e._readableStreamController = t;
|
|
1703
|
+
h(c(r()), () => (t._started = !0, Sr(t), null), (e) => (Tr(t, e), null));
|
|
1704
|
+
}
|
|
1705
|
+
function Er(e) {
|
|
1706
|
+
return /* @__PURE__ */ new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`);
|
|
1707
|
+
}
|
|
1708
|
+
function Wr(e, t) {
|
|
1709
|
+
return Oe(e._readableStreamController) ? function(e) {
|
|
1710
|
+
let t, r, o, n, i, a = V(e), s = !1, l = !1, d = !1, f = !1, h = !1;
|
|
1711
|
+
const b = u((e) => {
|
|
1712
|
+
i = e;
|
|
1713
|
+
});
|
|
1714
|
+
function m(e) {
|
|
1715
|
+
_(e._closedPromise, (t) => (e !== a || (Xe(o._readableStreamController, t), Xe(n._readableStreamController, t), f && h || i(void 0)), null));
|
|
1716
|
+
}
|
|
1717
|
+
function p() {
|
|
1718
|
+
ft(a) && (O(a), a = V(e), m(a));
|
|
1719
|
+
te(a, {
|
|
1720
|
+
_chunkSteps: (t) => {
|
|
1721
|
+
y(() => {
|
|
1722
|
+
l = !1, d = !1;
|
|
1723
|
+
const r = t;
|
|
1724
|
+
let a = t;
|
|
1725
|
+
if (!f && !h) try {
|
|
1726
|
+
a = Te(t);
|
|
1727
|
+
} catch (t) {
|
|
1728
|
+
Xe(o._readableStreamController, t), Xe(n._readableStreamController, t), i(Mr(e, t));
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
f || Ge(o._readableStreamController, r), h || Ge(n._readableStreamController, a), s = !1, l ? g() : d && v();
|
|
1732
|
+
});
|
|
1733
|
+
},
|
|
1734
|
+
_closeSteps: () => {
|
|
1735
|
+
s = !1, f || Ue(o._readableStreamController), h || Ue(n._readableStreamController), o._readableStreamController._pendingPullIntos.length > 0 && et(o._readableStreamController, 0), n._readableStreamController._pendingPullIntos.length > 0 && et(n._readableStreamController, 0), f && h || i(void 0);
|
|
1736
|
+
},
|
|
1737
|
+
_errorSteps: () => {
|
|
1738
|
+
s = !1;
|
|
1739
|
+
}
|
|
1740
|
+
});
|
|
1741
|
+
}
|
|
1742
|
+
function S(t, r) {
|
|
1743
|
+
ee(a) && (O(a), a = at(e), m(a));
|
|
1744
|
+
const u = r ? n : o, c = r ? o : n;
|
|
1745
|
+
ht(a, t, 1, {
|
|
1746
|
+
_chunkSteps: (t) => {
|
|
1747
|
+
y(() => {
|
|
1748
|
+
l = !1, d = !1;
|
|
1749
|
+
const o = r ? h : f;
|
|
1750
|
+
if (r ? f : h) o || tt(u._readableStreamController, t);
|
|
1751
|
+
else {
|
|
1752
|
+
let r;
|
|
1753
|
+
try {
|
|
1754
|
+
r = Te(t);
|
|
1755
|
+
} catch (t) {
|
|
1756
|
+
Xe(u._readableStreamController, t), Xe(c._readableStreamController, t), i(Mr(e, t));
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
o || tt(u._readableStreamController, t), Ge(c._readableStreamController, r);
|
|
1760
|
+
}
|
|
1761
|
+
s = !1, l ? g() : d && v();
|
|
1762
|
+
});
|
|
1763
|
+
},
|
|
1764
|
+
_closeSteps: (e) => {
|
|
1765
|
+
s = !1;
|
|
1766
|
+
const t = r ? h : f, o = r ? f : h;
|
|
1767
|
+
t || Ue(u._readableStreamController), o || Ue(c._readableStreamController), void 0 !== e && (t || tt(u._readableStreamController, e), !o && c._readableStreamController._pendingPullIntos.length > 0 && et(c._readableStreamController, 0)), t && o || i(void 0);
|
|
1768
|
+
},
|
|
1769
|
+
_errorSteps: () => {
|
|
1770
|
+
s = !1;
|
|
1771
|
+
}
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
function g() {
|
|
1775
|
+
if (s) return l = !0, c(void 0);
|
|
1776
|
+
s = !0;
|
|
1777
|
+
const e = Ke(o._readableStreamController);
|
|
1778
|
+
return null === e ? p() : S(e._view, !1), c(void 0);
|
|
1779
|
+
}
|
|
1780
|
+
function v() {
|
|
1781
|
+
if (s) return d = !0, c(void 0);
|
|
1782
|
+
s = !0;
|
|
1783
|
+
const e = Ke(n._readableStreamController);
|
|
1784
|
+
return null === e ? p() : S(e._view, !0), c(void 0);
|
|
1785
|
+
}
|
|
1786
|
+
function w(o) {
|
|
1787
|
+
if (f = !0, t = o, h) {
|
|
1788
|
+
const n = Mr(e, le([t, r]));
|
|
1789
|
+
i(n);
|
|
1790
|
+
}
|
|
1791
|
+
return b;
|
|
1792
|
+
}
|
|
1793
|
+
function R(o) {
|
|
1794
|
+
if (h = !0, r = o, f) {
|
|
1795
|
+
const n = Mr(e, le([t, r]));
|
|
1796
|
+
i(n);
|
|
1797
|
+
}
|
|
1798
|
+
return b;
|
|
1799
|
+
}
|
|
1800
|
+
function T() {}
|
|
1801
|
+
return o = Fr(T, g, w), n = Fr(T, v, R), m(a), [o, n];
|
|
1802
|
+
}(e) : function(e) {
|
|
1803
|
+
const t = V(e);
|
|
1804
|
+
let r, o, n, i, a, s = !1, l = !1, d = !1, f = !1;
|
|
1805
|
+
const h = u((e) => {
|
|
1806
|
+
a = e;
|
|
1807
|
+
});
|
|
1808
|
+
function b() {
|
|
1809
|
+
if (s) return l = !0, c(void 0);
|
|
1810
|
+
s = !0;
|
|
1811
|
+
return te(t, {
|
|
1812
|
+
_chunkSteps: (e) => {
|
|
1813
|
+
y(() => {
|
|
1814
|
+
l = !1;
|
|
1815
|
+
const t = e, r = e;
|
|
1816
|
+
d || Rr(n._readableStreamController, t), f || Rr(i._readableStreamController, r), s = !1, l && b();
|
|
1817
|
+
});
|
|
1818
|
+
},
|
|
1819
|
+
_closeSteps: () => {
|
|
1820
|
+
s = !1, d || wr(n._readableStreamController), f || wr(i._readableStreamController), d && f || a(void 0);
|
|
1821
|
+
},
|
|
1822
|
+
_errorSteps: () => {
|
|
1823
|
+
s = !1;
|
|
1824
|
+
}
|
|
1825
|
+
}), c(void 0);
|
|
1826
|
+
}
|
|
1827
|
+
function m(t) {
|
|
1828
|
+
if (d = !0, r = t, f) {
|
|
1829
|
+
const n = Mr(e, le([r, o]));
|
|
1830
|
+
a(n);
|
|
1831
|
+
}
|
|
1832
|
+
return h;
|
|
1833
|
+
}
|
|
1834
|
+
function p(t) {
|
|
1835
|
+
if (f = !0, o = t, d) {
|
|
1836
|
+
const n = Mr(e, le([r, o]));
|
|
1837
|
+
a(n);
|
|
1838
|
+
}
|
|
1839
|
+
return h;
|
|
1840
|
+
}
|
|
1841
|
+
function S() {}
|
|
1842
|
+
return n = Dr(S, b, m), i = Dr(S, b, p), _(t._closedPromise, (e) => (Tr(n._readableStreamController, e), Tr(i._readableStreamController, e), d && f || a(void 0), null)), [n, i];
|
|
1843
|
+
}(e);
|
|
1844
|
+
}
|
|
1845
|
+
function Or(r) {
|
|
1846
|
+
return t(o = r) && void 0 !== o.getReader ? function(r) {
|
|
1847
|
+
let o;
|
|
1848
|
+
function n() {
|
|
1849
|
+
let e;
|
|
1850
|
+
try {
|
|
1851
|
+
e = r.read();
|
|
1852
|
+
} catch (e) {
|
|
1853
|
+
return d(e);
|
|
1854
|
+
}
|
|
1855
|
+
return m(e, (e) => {
|
|
1856
|
+
if (!t(e)) throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
|
|
1857
|
+
if (e.done) wr(o._readableStreamController);
|
|
1858
|
+
else {
|
|
1859
|
+
const t = e.value;
|
|
1860
|
+
Rr(o._readableStreamController, t);
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
function i(e) {
|
|
1865
|
+
try {
|
|
1866
|
+
return c(r.cancel(e));
|
|
1867
|
+
} catch (e) {
|
|
1868
|
+
return d(e);
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
return o = Dr(e, n, i, 0), o;
|
|
1872
|
+
}(r.getReader()) : function(r) {
|
|
1873
|
+
let o;
|
|
1874
|
+
const n = me(r, "async");
|
|
1875
|
+
function i() {
|
|
1876
|
+
let e;
|
|
1877
|
+
try {
|
|
1878
|
+
e = pe(n);
|
|
1879
|
+
} catch (e) {
|
|
1880
|
+
return d(e);
|
|
1881
|
+
}
|
|
1882
|
+
return m(c(e), (e) => {
|
|
1883
|
+
if (!t(e)) throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
|
|
1884
|
+
if (e.done) wr(o._readableStreamController);
|
|
1885
|
+
else {
|
|
1886
|
+
const t = e.value;
|
|
1887
|
+
Rr(o._readableStreamController, t);
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
}
|
|
1891
|
+
function a(e) {
|
|
1892
|
+
const r = n.iterator;
|
|
1893
|
+
let o;
|
|
1894
|
+
try {
|
|
1895
|
+
o = he(r, "return");
|
|
1896
|
+
} catch (e) {
|
|
1897
|
+
return d(e);
|
|
1898
|
+
}
|
|
1899
|
+
if (void 0 === o) return c(void 0);
|
|
1900
|
+
return m(g(o, r, [e]), (e) => {
|
|
1901
|
+
if (!t(e)) throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
|
|
1902
|
+
});
|
|
1903
|
+
}
|
|
1904
|
+
return o = Dr(e, i, a, 0), o;
|
|
1905
|
+
}(r);
|
|
1906
|
+
var o;
|
|
1907
|
+
}
|
|
1908
|
+
function Br(e, t, r) {
|
|
1909
|
+
return I(e, r), (r) => g(e, t, [r]);
|
|
1910
|
+
}
|
|
1911
|
+
function jr(e, t, r) {
|
|
1912
|
+
return I(e, r), (r) => g(e, t, [r]);
|
|
1913
|
+
}
|
|
1914
|
+
function kr(e, t, r) {
|
|
1915
|
+
return I(e, r), (r) => S(e, t, [r]);
|
|
1916
|
+
}
|
|
1917
|
+
function Ar(e, t) {
|
|
1918
|
+
if ("bytes" !== (e = `${e}`)) throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);
|
|
1919
|
+
return e;
|
|
1920
|
+
}
|
|
1921
|
+
function zr(e, t) {
|
|
1922
|
+
L(e, t);
|
|
1923
|
+
const r = null == e ? void 0 : e.preventAbort, o = null == e ? void 0 : e.preventCancel, n = null == e ? void 0 : e.preventClose, i = null == e ? void 0 : e.signal;
|
|
1924
|
+
return void 0 !== i && function(e, t) {
|
|
1925
|
+
if (!function(e) {
|
|
1926
|
+
if ("object" != typeof e || null === e) return !1;
|
|
1927
|
+
try {
|
|
1928
|
+
return "boolean" == typeof e.aborted;
|
|
1929
|
+
} catch (e) {
|
|
1930
|
+
return !1;
|
|
1931
|
+
}
|
|
1932
|
+
}(e)) throw new TypeError(`${t} is not an AbortSignal.`);
|
|
1933
|
+
}(i, `${t} has member 'signal' that`), {
|
|
1934
|
+
preventAbort: Boolean(r),
|
|
1935
|
+
preventCancel: Boolean(o),
|
|
1936
|
+
preventClose: Boolean(n),
|
|
1937
|
+
signal: i
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
Object.defineProperties(ReadableStreamDefaultController.prototype, {
|
|
1941
|
+
close: { enumerable: !0 },
|
|
1942
|
+
enqueue: { enumerable: !0 },
|
|
1943
|
+
error: { enumerable: !0 },
|
|
1944
|
+
desiredSize: { enumerable: !0 }
|
|
1945
|
+
}), o(ReadableStreamDefaultController.prototype.close, "close"), o(ReadableStreamDefaultController.prototype.enqueue, "enqueue"), o(ReadableStreamDefaultController.prototype.error, "error"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
1946
|
+
value: "ReadableStreamDefaultController",
|
|
1947
|
+
configurable: !0
|
|
1948
|
+
});
|
|
1949
|
+
var ReadableStream = class {
|
|
1950
|
+
constructor(e = {}, t = {}) {
|
|
1951
|
+
void 0 === e ? e = null : $(e, "First parameter");
|
|
1952
|
+
const r = yt(t, "Second parameter"), o = function(e, t) {
|
|
1953
|
+
L(e, t);
|
|
1954
|
+
const r = e, o = null == r ? void 0 : r.autoAllocateChunkSize, n = null == r ? void 0 : r.cancel, i = null == r ? void 0 : r.pull, a = null == r ? void 0 : r.start, s = null == r ? void 0 : r.type;
|
|
1955
|
+
return {
|
|
1956
|
+
autoAllocateChunkSize: void 0 === o ? void 0 : N(o, `${t} has member 'autoAllocateChunkSize' that`),
|
|
1957
|
+
cancel: void 0 === n ? void 0 : Br(n, r, `${t} has member 'cancel' that`),
|
|
1958
|
+
pull: void 0 === i ? void 0 : jr(i, r, `${t} has member 'pull' that`),
|
|
1959
|
+
start: void 0 === a ? void 0 : kr(a, r, `${t} has member 'start' that`),
|
|
1960
|
+
type: void 0 === s ? void 0 : Ar(s, `${t} has member 'type' that`)
|
|
1961
|
+
};
|
|
1962
|
+
}(e, "First parameter");
|
|
1963
|
+
if (Lr(this), "bytes" === o.type) {
|
|
1964
|
+
if (void 0 !== r.size) throw new RangeError("The strategy for a byte stream cannot have a size function");
|
|
1965
|
+
(function(e, t, r) {
|
|
1966
|
+
const o = Object.create(ReadableByteStreamController.prototype);
|
|
1967
|
+
let n, i, a;
|
|
1968
|
+
n = void 0 !== t.start ? () => t.start(o) : () => {}, i = void 0 !== t.pull ? () => t.pull(o) : () => c(void 0), a = void 0 !== t.cancel ? (e) => t.cancel(e) : () => c(void 0);
|
|
1969
|
+
const s = t.autoAllocateChunkSize;
|
|
1970
|
+
if (0 === s) throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
|
1971
|
+
rt(e, o, n, i, a, r, s);
|
|
1972
|
+
})(this, o, mt(r, 0));
|
|
1973
|
+
} else {
|
|
1974
|
+
const e = pt(r);
|
|
1975
|
+
(function(e, t, r, o) {
|
|
1976
|
+
const n = Object.create(ReadableStreamDefaultController.prototype);
|
|
1977
|
+
let i, a, s;
|
|
1978
|
+
i = void 0 !== t.start ? () => t.start(n) : () => {}, a = void 0 !== t.pull ? () => t.pull(n) : () => c(void 0), s = void 0 !== t.cancel ? (e) => t.cancel(e) : () => c(void 0), qr(e, n, i, a, s, r, o);
|
|
1979
|
+
})(this, o, mt(r, 1), e);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
get locked() {
|
|
1983
|
+
if (!Ir(this)) throw Qr("locked");
|
|
1984
|
+
return $r(this);
|
|
1985
|
+
}
|
|
1986
|
+
cancel(e = void 0) {
|
|
1987
|
+
return Ir(this) ? $r(this) ? d(/* @__PURE__ */ new TypeError("Cannot cancel a stream that already has a reader")) : Mr(this, e) : d(Qr("cancel"));
|
|
1988
|
+
}
|
|
1989
|
+
getReader(e = void 0) {
|
|
1990
|
+
if (!Ir(this)) throw Qr("getReader");
|
|
1991
|
+
return void 0 === function(e, t) {
|
|
1992
|
+
L(e, t);
|
|
1993
|
+
const r = null == e ? void 0 : e.mode;
|
|
1994
|
+
return { mode: void 0 === r ? void 0 : it(r, `${t} has member 'mode' that`) };
|
|
1995
|
+
}(e, "First parameter").mode ? V(this) : at(this);
|
|
1996
|
+
}
|
|
1997
|
+
pipeThrough(e, t = {}) {
|
|
1998
|
+
if (!Ir(this)) throw Qr("pipeThrough");
|
|
1999
|
+
M(e, 1, "pipeThrough");
|
|
2000
|
+
const r = function(e, t) {
|
|
2001
|
+
L(e, t);
|
|
2002
|
+
const r = null == e ? void 0 : e.readable;
|
|
2003
|
+
Y(r, "readable", "ReadableWritablePair"), H(r, `${t} has member 'readable' that`);
|
|
2004
|
+
const o = null == e ? void 0 : e.writable;
|
|
2005
|
+
return Y(o, "writable", "ReadableWritablePair"), Tt(o, `${t} has member 'writable' that`), {
|
|
2006
|
+
readable: r,
|
|
2007
|
+
writable: o
|
|
2008
|
+
};
|
|
2009
|
+
}(e, "First parameter"), o = zr(t, "Second parameter");
|
|
2010
|
+
if ($r(this)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
|
|
2011
|
+
if (Et(r.writable)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
|
|
2012
|
+
return p(hr(this, r.writable, o.preventClose, o.preventAbort, o.preventCancel, o.signal)), r.readable;
|
|
2013
|
+
}
|
|
2014
|
+
pipeTo(e, t = {}) {
|
|
2015
|
+
if (!Ir(this)) return d(Qr("pipeTo"));
|
|
2016
|
+
if (void 0 === e) return d("Parameter 1 is required in 'pipeTo'.");
|
|
2017
|
+
if (!qt(e)) return d(/* @__PURE__ */ new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
|
|
2018
|
+
let r;
|
|
2019
|
+
try {
|
|
2020
|
+
r = zr(t, "Second parameter");
|
|
2021
|
+
} catch (e) {
|
|
2022
|
+
return d(e);
|
|
2023
|
+
}
|
|
2024
|
+
return $r(this) ? d(/* @__PURE__ */ new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : Et(e) ? d(/* @__PURE__ */ new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : hr(this, e, r.preventClose, r.preventAbort, r.preventCancel, r.signal);
|
|
2025
|
+
}
|
|
2026
|
+
tee() {
|
|
2027
|
+
if (!Ir(this)) throw Qr("tee");
|
|
2028
|
+
return le(Wr(this));
|
|
2029
|
+
}
|
|
2030
|
+
values(e = void 0) {
|
|
2031
|
+
if (!Ir(this)) throw Qr("values");
|
|
2032
|
+
return function(e, t) {
|
|
2033
|
+
const o = new ye(V(e), t), n = Object.create(ge);
|
|
2034
|
+
return n._asyncIteratorImpl = o, n;
|
|
2035
|
+
}(this, function(e, t) {
|
|
2036
|
+
L(e, t);
|
|
2037
|
+
const r = null == e ? void 0 : e.preventCancel;
|
|
2038
|
+
return { preventCancel: Boolean(r) };
|
|
2039
|
+
}(e, "First parameter").preventCancel);
|
|
2040
|
+
}
|
|
2041
|
+
[_e](e) {
|
|
2042
|
+
return this.values(e);
|
|
2043
|
+
}
|
|
2044
|
+
static from(e) {
|
|
2045
|
+
return Or(e);
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
function Dr(e, t, r, o = 1, n = () => 1) {
|
|
2049
|
+
const i = Object.create(ReadableStream.prototype);
|
|
2050
|
+
Lr(i);
|
|
2051
|
+
return qr(i, Object.create(ReadableStreamDefaultController.prototype), e, t, r, o, n), i;
|
|
2052
|
+
}
|
|
2053
|
+
function Fr(e, t, r) {
|
|
2054
|
+
const o = Object.create(ReadableStream.prototype);
|
|
2055
|
+
Lr(o);
|
|
2056
|
+
return rt(o, Object.create(ReadableByteStreamController.prototype), e, t, r, 0, void 0), o;
|
|
2057
|
+
}
|
|
2058
|
+
function Lr(e) {
|
|
2059
|
+
e._state = "readable", e._reader = void 0, e._storedError = void 0, e._disturbed = !1;
|
|
2060
|
+
}
|
|
2061
|
+
function Ir(e) {
|
|
2062
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_readableStreamController") && e instanceof ReadableStream;
|
|
2063
|
+
}
|
|
2064
|
+
function $r(e) {
|
|
2065
|
+
return void 0 !== e._reader;
|
|
2066
|
+
}
|
|
2067
|
+
function Mr(t, r) {
|
|
2068
|
+
if (t._disturbed = !0, "closed" === t._state) return c(void 0);
|
|
2069
|
+
if ("errored" === t._state) return d(t._storedError);
|
|
2070
|
+
Yr(t);
|
|
2071
|
+
const o = t._reader;
|
|
2072
|
+
if (void 0 !== o && ft(o)) {
|
|
2073
|
+
const e = o._readIntoRequests;
|
|
2074
|
+
o._readIntoRequests = new v(), e.forEach((e) => {
|
|
2075
|
+
e._closeSteps(void 0);
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
return m(t._readableStreamController[T](r), e);
|
|
2079
|
+
}
|
|
2080
|
+
function Yr(e) {
|
|
2081
|
+
e._state = "closed";
|
|
2082
|
+
const t = e._reader;
|
|
2083
|
+
if (void 0 !== t && (z(t), ee(t))) {
|
|
2084
|
+
const e = t._readRequests;
|
|
2085
|
+
t._readRequests = new v(), e.forEach((e) => {
|
|
2086
|
+
e._closeSteps();
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
function xr(e, t) {
|
|
2091
|
+
e._state = "errored", e._storedError = t;
|
|
2092
|
+
const r = e._reader;
|
|
2093
|
+
void 0 !== r && (A(r, t), ee(r) ? oe(r, t) : bt(r, t));
|
|
2094
|
+
}
|
|
2095
|
+
function Qr(e) {
|
|
2096
|
+
return /* @__PURE__ */ new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`);
|
|
2097
|
+
}
|
|
2098
|
+
function Nr(e, t) {
|
|
2099
|
+
L(e, t);
|
|
2100
|
+
const r = null == e ? void 0 : e.highWaterMark;
|
|
2101
|
+
return Y(r, "highWaterMark", "QueuingStrategyInit"), { highWaterMark: x(r) };
|
|
2102
|
+
}
|
|
2103
|
+
Object.defineProperties(ReadableStream, { from: { enumerable: !0 } }), Object.defineProperties(ReadableStream.prototype, {
|
|
2104
|
+
cancel: { enumerable: !0 },
|
|
2105
|
+
getReader: { enumerable: !0 },
|
|
2106
|
+
pipeThrough: { enumerable: !0 },
|
|
2107
|
+
pipeTo: { enumerable: !0 },
|
|
2108
|
+
tee: { enumerable: !0 },
|
|
2109
|
+
values: { enumerable: !0 },
|
|
2110
|
+
locked: { enumerable: !0 }
|
|
2111
|
+
}), o(ReadableStream.from, "from"), o(ReadableStream.prototype.cancel, "cancel"), o(ReadableStream.prototype.getReader, "getReader"), o(ReadableStream.prototype.pipeThrough, "pipeThrough"), o(ReadableStream.prototype.pipeTo, "pipeTo"), o(ReadableStream.prototype.tee, "tee"), o(ReadableStream.prototype.values, "values"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStream.prototype, Symbol.toStringTag, {
|
|
2112
|
+
value: "ReadableStream",
|
|
2113
|
+
configurable: !0
|
|
2114
|
+
}), Object.defineProperty(ReadableStream.prototype, _e, {
|
|
2115
|
+
value: ReadableStream.prototype.values,
|
|
2116
|
+
writable: !0,
|
|
2117
|
+
configurable: !0
|
|
2118
|
+
});
|
|
2119
|
+
const Hr = (e) => e.byteLength;
|
|
2120
|
+
o(Hr, "size");
|
|
2121
|
+
var ByteLengthQueuingStrategy = class {
|
|
2122
|
+
constructor(e) {
|
|
2123
|
+
M(e, 1, "ByteLengthQueuingStrategy"), e = Nr(e, "First parameter"), this._byteLengthQueuingStrategyHighWaterMark = e.highWaterMark;
|
|
2124
|
+
}
|
|
2125
|
+
get highWaterMark() {
|
|
2126
|
+
if (!Ur(this)) throw Vr("highWaterMark");
|
|
2127
|
+
return this._byteLengthQueuingStrategyHighWaterMark;
|
|
2128
|
+
}
|
|
2129
|
+
get size() {
|
|
2130
|
+
if (!Ur(this)) throw Vr("size");
|
|
2131
|
+
return Hr;
|
|
2132
|
+
}
|
|
2133
|
+
};
|
|
2134
|
+
function Vr(e) {
|
|
2135
|
+
return /* @__PURE__ */ new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`);
|
|
2136
|
+
}
|
|
2137
|
+
function Ur(e) {
|
|
2138
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_byteLengthQueuingStrategyHighWaterMark") && e instanceof ByteLengthQueuingStrategy;
|
|
2139
|
+
}
|
|
2140
|
+
Object.defineProperties(ByteLengthQueuingStrategy.prototype, {
|
|
2141
|
+
highWaterMark: { enumerable: !0 },
|
|
2142
|
+
size: { enumerable: !0 }
|
|
2143
|
+
}), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
|
|
2144
|
+
value: "ByteLengthQueuingStrategy",
|
|
2145
|
+
configurable: !0
|
|
2146
|
+
});
|
|
2147
|
+
const Gr = () => 1;
|
|
2148
|
+
o(Gr, "size");
|
|
2149
|
+
var CountQueuingStrategy = class {
|
|
2150
|
+
constructor(e) {
|
|
2151
|
+
M(e, 1, "CountQueuingStrategy"), e = Nr(e, "First parameter"), this._countQueuingStrategyHighWaterMark = e.highWaterMark;
|
|
2152
|
+
}
|
|
2153
|
+
get highWaterMark() {
|
|
2154
|
+
if (!Jr(this)) throw Xr("highWaterMark");
|
|
2155
|
+
return this._countQueuingStrategyHighWaterMark;
|
|
2156
|
+
}
|
|
2157
|
+
get size() {
|
|
2158
|
+
if (!Jr(this)) throw Xr("size");
|
|
2159
|
+
return Gr;
|
|
2160
|
+
}
|
|
2161
|
+
};
|
|
2162
|
+
function Xr(e) {
|
|
2163
|
+
return /* @__PURE__ */ new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`);
|
|
2164
|
+
}
|
|
2165
|
+
function Jr(e) {
|
|
2166
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_countQueuingStrategyHighWaterMark") && e instanceof CountQueuingStrategy;
|
|
2167
|
+
}
|
|
2168
|
+
function Kr(e, t, r) {
|
|
2169
|
+
return I(e, r), (r) => g(e, t, [r]);
|
|
2170
|
+
}
|
|
2171
|
+
function Zr(e, t, r) {
|
|
2172
|
+
return I(e, r), (r) => S(e, t, [r]);
|
|
2173
|
+
}
|
|
2174
|
+
function eo(e, t, r) {
|
|
2175
|
+
return I(e, r), (r, o) => g(e, t, [r, o]);
|
|
2176
|
+
}
|
|
2177
|
+
function to(e, t, r) {
|
|
2178
|
+
return I(e, r), (r) => g(e, t, [r]);
|
|
2179
|
+
}
|
|
2180
|
+
Object.defineProperties(CountQueuingStrategy.prototype, {
|
|
2181
|
+
highWaterMark: { enumerable: !0 },
|
|
2182
|
+
size: { enumerable: !0 }
|
|
2183
|
+
}), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
|
|
2184
|
+
value: "CountQueuingStrategy",
|
|
2185
|
+
configurable: !0
|
|
2186
|
+
});
|
|
2187
|
+
var TransformStream = class {
|
|
2188
|
+
constructor(e = {}, t = {}, r = {}) {
|
|
2189
|
+
void 0 === e && (e = null);
|
|
2190
|
+
const o = yt(t, "Second parameter"), n = yt(r, "Third parameter"), i = function(e, t) {
|
|
2191
|
+
L(e, t);
|
|
2192
|
+
const r = null == e ? void 0 : e.cancel, o = null == e ? void 0 : e.flush, n = null == e ? void 0 : e.readableType, i = null == e ? void 0 : e.start, a = null == e ? void 0 : e.transform, s = null == e ? void 0 : e.writableType;
|
|
2193
|
+
return {
|
|
2194
|
+
cancel: void 0 === r ? void 0 : to(r, e, `${t} has member 'cancel' that`),
|
|
2195
|
+
flush: void 0 === o ? void 0 : Kr(o, e, `${t} has member 'flush' that`),
|
|
2196
|
+
readableType: n,
|
|
2197
|
+
start: void 0 === i ? void 0 : Zr(i, e, `${t} has member 'start' that`),
|
|
2198
|
+
transform: void 0 === a ? void 0 : eo(a, e, `${t} has member 'transform' that`),
|
|
2199
|
+
writableType: s
|
|
2200
|
+
};
|
|
2201
|
+
}(e, "First parameter");
|
|
2202
|
+
if (void 0 !== i.readableType) throw new RangeError("Invalid readableType specified");
|
|
2203
|
+
if (void 0 !== i.writableType) throw new RangeError("Invalid writableType specified");
|
|
2204
|
+
const a = mt(n, 0), s = pt(n), l = mt(o, 1), f = pt(o);
|
|
2205
|
+
let b;
|
|
2206
|
+
(function(e, t, r, o, n, i) {
|
|
2207
|
+
function a() {
|
|
2208
|
+
return t;
|
|
2209
|
+
}
|
|
2210
|
+
function s(t) {
|
|
2211
|
+
return function(e, t) {
|
|
2212
|
+
const r = e._transformStreamController;
|
|
2213
|
+
if (e._backpressure) return m(e._backpressureChangePromise, () => {
|
|
2214
|
+
const o = e._writable;
|
|
2215
|
+
if ("erroring" === o._state) throw o._storedError;
|
|
2216
|
+
return co(r, t);
|
|
2217
|
+
});
|
|
2218
|
+
return co(r, t);
|
|
2219
|
+
}(e, t);
|
|
2220
|
+
}
|
|
2221
|
+
function l(t) {
|
|
2222
|
+
return function(e, t) {
|
|
2223
|
+
const r = e._transformStreamController;
|
|
2224
|
+
if (void 0 !== r._finishPromise) return r._finishPromise;
|
|
2225
|
+
const o = e._readable;
|
|
2226
|
+
r._finishPromise = u((e, t) => {
|
|
2227
|
+
r._finishPromise_resolve = e, r._finishPromise_reject = t;
|
|
2228
|
+
});
|
|
2229
|
+
const n = r._cancelAlgorithm(t);
|
|
2230
|
+
return lo(r), h(n, () => ("errored" === o._state ? bo(r, o._storedError) : (Tr(o._readableStreamController, t), ho(r)), null), (e) => (Tr(o._readableStreamController, e), bo(r, e), null)), r._finishPromise;
|
|
2231
|
+
}(e, t);
|
|
2232
|
+
}
|
|
2233
|
+
function c() {
|
|
2234
|
+
return function(e) {
|
|
2235
|
+
const t = e._transformStreamController;
|
|
2236
|
+
if (void 0 !== t._finishPromise) return t._finishPromise;
|
|
2237
|
+
const r = e._readable;
|
|
2238
|
+
t._finishPromise = u((e, r) => {
|
|
2239
|
+
t._finishPromise_resolve = e, t._finishPromise_reject = r;
|
|
2240
|
+
});
|
|
2241
|
+
const o = t._flushAlgorithm();
|
|
2242
|
+
return lo(t), h(o, () => ("errored" === r._state ? bo(t, r._storedError) : (wr(r._readableStreamController), ho(t)), null), (e) => (Tr(r._readableStreamController, e), bo(t, e), null)), t._finishPromise;
|
|
2243
|
+
}(e);
|
|
2244
|
+
}
|
|
2245
|
+
function d() {
|
|
2246
|
+
return function(e) {
|
|
2247
|
+
return ao(e, !1), e._backpressureChangePromise;
|
|
2248
|
+
}(e);
|
|
2249
|
+
}
|
|
2250
|
+
function f(t) {
|
|
2251
|
+
return function(e, t) {
|
|
2252
|
+
const r = e._transformStreamController;
|
|
2253
|
+
if (void 0 !== r._finishPromise) return r._finishPromise;
|
|
2254
|
+
const o = e._writable;
|
|
2255
|
+
r._finishPromise = u((e, t) => {
|
|
2256
|
+
r._finishPromise_resolve = e, r._finishPromise_reject = t;
|
|
2257
|
+
});
|
|
2258
|
+
const n = r._cancelAlgorithm(t);
|
|
2259
|
+
return lo(r), h(n, () => ("errored" === o._state ? bo(r, o._storedError) : (Gt(o._writableStreamController, t), io(e), ho(r)), null), (t) => (Gt(o._writableStreamController, t), io(e), bo(r, t), null)), r._finishPromise;
|
|
2260
|
+
}(e, t);
|
|
2261
|
+
}
|
|
2262
|
+
e._writable = function(e, t, r, o, n = 1, i = () => 1) {
|
|
2263
|
+
const a = Object.create(WritableStream.prototype);
|
|
2264
|
+
return Ct(a), Nt(a, Object.create(WritableStreamDefaultController.prototype), e, t, r, o, n, i), a;
|
|
2265
|
+
}(a, s, c, l, r, o), e._readable = Dr(a, d, f, n, i), e._backpressure = void 0, e._backpressureChangePromise = void 0, e._backpressureChangePromise_resolve = void 0, ao(e, !0), e._transformStreamController = void 0;
|
|
2266
|
+
})(this, u((e) => {
|
|
2267
|
+
b = e;
|
|
2268
|
+
}), l, f, a, s), function(e, t) {
|
|
2269
|
+
const r = Object.create(TransformStreamDefaultController.prototype);
|
|
2270
|
+
let o, n, i;
|
|
2271
|
+
o = void 0 !== t.transform ? (e) => t.transform(e, r) : (e) => {
|
|
2272
|
+
try {
|
|
2273
|
+
return uo(r, e), c(void 0);
|
|
2274
|
+
} catch (e) {
|
|
2275
|
+
return d(e);
|
|
2276
|
+
}
|
|
2277
|
+
};
|
|
2278
|
+
n = void 0 !== t.flush ? () => t.flush(r) : () => c(void 0);
|
|
2279
|
+
i = void 0 !== t.cancel ? (e) => t.cancel(e) : () => c(void 0);
|
|
2280
|
+
(function(e, t, r, o, n) {
|
|
2281
|
+
t._controlledTransformStream = e, e._transformStreamController = t, t._transformAlgorithm = r, t._flushAlgorithm = o, t._cancelAlgorithm = n, t._finishPromise = void 0, t._finishPromise_resolve = void 0, t._finishPromise_reject = void 0;
|
|
2282
|
+
})(e, r, o, n, i);
|
|
2283
|
+
}(this, i), void 0 !== i.start ? b(i.start(this._transformStreamController)) : b(void 0);
|
|
2284
|
+
}
|
|
2285
|
+
get readable() {
|
|
2286
|
+
if (!ro(this)) throw _o("readable");
|
|
2287
|
+
return this._readable;
|
|
2288
|
+
}
|
|
2289
|
+
get writable() {
|
|
2290
|
+
if (!ro(this)) throw _o("writable");
|
|
2291
|
+
return this._writable;
|
|
2292
|
+
}
|
|
2293
|
+
};
|
|
2294
|
+
function ro(e) {
|
|
2295
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_transformStreamController") && e instanceof TransformStream;
|
|
2296
|
+
}
|
|
2297
|
+
function oo(e, t) {
|
|
2298
|
+
Tr(e._readable._readableStreamController, t), no(e, t);
|
|
2299
|
+
}
|
|
2300
|
+
function no(e, t) {
|
|
2301
|
+
lo(e._transformStreamController), Gt(e._writable._writableStreamController, t), io(e);
|
|
2302
|
+
}
|
|
2303
|
+
function io(e) {
|
|
2304
|
+
e._backpressure && ao(e, !1);
|
|
2305
|
+
}
|
|
2306
|
+
function ao(e, t) {
|
|
2307
|
+
void 0 !== e._backpressureChangePromise && e._backpressureChangePromise_resolve(), e._backpressureChangePromise = u((t) => {
|
|
2308
|
+
e._backpressureChangePromise_resolve = t;
|
|
2309
|
+
}), e._backpressure = t;
|
|
2310
|
+
}
|
|
2311
|
+
Object.defineProperties(TransformStream.prototype, {
|
|
2312
|
+
readable: { enumerable: !0 },
|
|
2313
|
+
writable: { enumerable: !0 }
|
|
2314
|
+
}), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
|
|
2315
|
+
value: "TransformStream",
|
|
2316
|
+
configurable: !0
|
|
2317
|
+
});
|
|
2318
|
+
var TransformStreamDefaultController = class {
|
|
2319
|
+
constructor() {
|
|
2320
|
+
throw new TypeError("Illegal constructor");
|
|
2321
|
+
}
|
|
2322
|
+
get desiredSize() {
|
|
2323
|
+
if (!so(this)) throw fo("desiredSize");
|
|
2324
|
+
return Pr(this._controlledTransformStream._readable._readableStreamController);
|
|
2325
|
+
}
|
|
2326
|
+
enqueue(e = void 0) {
|
|
2327
|
+
if (!so(this)) throw fo("enqueue");
|
|
2328
|
+
uo(this, e);
|
|
2329
|
+
}
|
|
2330
|
+
error(e = void 0) {
|
|
2331
|
+
if (!so(this)) throw fo("error");
|
|
2332
|
+
var t = e;
|
|
2333
|
+
oo(this._controlledTransformStream, t);
|
|
2334
|
+
}
|
|
2335
|
+
terminate() {
|
|
2336
|
+
if (!so(this)) throw fo("terminate");
|
|
2337
|
+
(function(e) {
|
|
2338
|
+
const t = e._controlledTransformStream;
|
|
2339
|
+
wr(t._readable._readableStreamController);
|
|
2340
|
+
no(t, /* @__PURE__ */ new TypeError("TransformStream terminated"));
|
|
2341
|
+
})(this);
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
function so(e) {
|
|
2345
|
+
return !!t(e) && !!Object.prototype.hasOwnProperty.call(e, "_controlledTransformStream") && e instanceof TransformStreamDefaultController;
|
|
2346
|
+
}
|
|
2347
|
+
function lo(e) {
|
|
2348
|
+
e._transformAlgorithm = void 0, e._flushAlgorithm = void 0, e._cancelAlgorithm = void 0;
|
|
2349
|
+
}
|
|
2350
|
+
function uo(e, t) {
|
|
2351
|
+
const r = e._controlledTransformStream, o = r._readable._readableStreamController;
|
|
2352
|
+
if (!Cr(o)) throw new TypeError("Readable side is not in a state that permits enqueue");
|
|
2353
|
+
try {
|
|
2354
|
+
Rr(o, t);
|
|
2355
|
+
} catch (e) {
|
|
2356
|
+
throw no(r, e), r._readable._storedError;
|
|
2357
|
+
}
|
|
2358
|
+
(function(e) {
|
|
2359
|
+
return !gr(e);
|
|
2360
|
+
})(o) !== r._backpressure && ao(r, !0);
|
|
2361
|
+
}
|
|
2362
|
+
function co(e, t) {
|
|
2363
|
+
return m(e._transformAlgorithm(t), void 0, (t) => {
|
|
2364
|
+
throw oo(e._controlledTransformStream, t), t;
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
function fo(e) {
|
|
2368
|
+
return /* @__PURE__ */ new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`);
|
|
2369
|
+
}
|
|
2370
|
+
function ho(e) {
|
|
2371
|
+
void 0 !== e._finishPromise_resolve && (e._finishPromise_resolve(), e._finishPromise_resolve = void 0, e._finishPromise_reject = void 0);
|
|
2372
|
+
}
|
|
2373
|
+
function bo(e, t) {
|
|
2374
|
+
void 0 !== e._finishPromise_reject && (p(e._finishPromise), e._finishPromise_reject(t), e._finishPromise_resolve = void 0, e._finishPromise_reject = void 0);
|
|
2375
|
+
}
|
|
2376
|
+
function _o(e) {
|
|
2377
|
+
return /* @__PURE__ */ new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`);
|
|
2378
|
+
}
|
|
2379
|
+
Object.defineProperties(TransformStreamDefaultController.prototype, {
|
|
2380
|
+
enqueue: { enumerable: !0 },
|
|
2381
|
+
error: { enumerable: !0 },
|
|
2382
|
+
terminate: { enumerable: !0 },
|
|
2383
|
+
desiredSize: { enumerable: !0 }
|
|
2384
|
+
}), o(TransformStreamDefaultController.prototype.enqueue, "enqueue"), o(TransformStreamDefaultController.prototype.error, "error"), o(TransformStreamDefaultController.prototype.terminate, "terminate"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
|
|
2385
|
+
value: "TransformStreamDefaultController",
|
|
2386
|
+
configurable: !0
|
|
2387
|
+
});
|
|
2388
|
+
//#endregion
|
|
2389
|
+
//#region node_modules/.pnpm/koajax@3.3.1_typescript@6.0.3/node_modules/koajax/dist/index.esm.js
|
|
2390
|
+
function $parcel$export(e, n, v, s) {
|
|
2391
|
+
Object.defineProperty(e, n, {
|
|
2392
|
+
get: v,
|
|
2393
|
+
set: s,
|
|
2394
|
+
enumerable: true,
|
|
2395
|
+
configurable: true
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
$parcel$export({}, "Stack", function() {
|
|
2399
|
+
return $eef213ff4197108b$export$694e0d28c7ffc90c;
|
|
2400
|
+
});
|
|
2401
|
+
const { push: $eef213ff4197108b$var$push } = Array.prototype;
|
|
2402
|
+
var $eef213ff4197108b$export$694e0d28c7ffc90c = class {
|
|
2403
|
+
use(...middlewares) {
|
|
2404
|
+
$eef213ff4197108b$var$push.apply(this, middlewares);
|
|
2405
|
+
return this;
|
|
2406
|
+
}
|
|
2407
|
+
execute(context, depth = 0) {
|
|
2408
|
+
const middleware = this[depth];
|
|
2409
|
+
if (middleware instanceof Function) return middleware(context, this.execute.bind(this, context, ++depth));
|
|
2410
|
+
}
|
|
2411
|
+
mount(condition, stack) {
|
|
2412
|
+
return this.use((context, next) => condition(context) ? stack.execute(context) : next());
|
|
2413
|
+
}
|
|
2414
|
+
constructor() {
|
|
2415
|
+
this.length = 0;
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
var $0fe1f1400993ba8a$exports = {};
|
|
2419
|
+
$parcel$export($0fe1f1400993ba8a$exports, "BodyRequestMethods", function() {
|
|
2420
|
+
return $0fe1f1400993ba8a$export$4125cfe7e08e2040;
|
|
2421
|
+
});
|
|
2422
|
+
$parcel$export($0fe1f1400993ba8a$exports, "HTTPError", function() {
|
|
2423
|
+
return $0fe1f1400993ba8a$export$aa9d629c530f62a7;
|
|
2424
|
+
});
|
|
2425
|
+
$parcel$export($0fe1f1400993ba8a$exports, "headerParser", function() {
|
|
2426
|
+
return $0fe1f1400993ba8a$export$b725a69477e4d33f;
|
|
2427
|
+
});
|
|
2428
|
+
$parcel$export($0fe1f1400993ba8a$exports, "parseHeaders", function() {
|
|
2429
|
+
return $0fe1f1400993ba8a$export$eea2c1c5e1a37e50;
|
|
2430
|
+
});
|
|
2431
|
+
$parcel$export($0fe1f1400993ba8a$exports, "parseBody", function() {
|
|
2432
|
+
return $0fe1f1400993ba8a$export$3b629cd0ff482602;
|
|
2433
|
+
});
|
|
2434
|
+
$parcel$export($0fe1f1400993ba8a$exports, "FILE_TYPE_MAGIC_NUMBER_SIZE", function() {
|
|
2435
|
+
return $0fe1f1400993ba8a$export$153cac11fce574d;
|
|
2436
|
+
});
|
|
2437
|
+
$parcel$export($0fe1f1400993ba8a$exports, "defaultHTTPRuntime", function() {
|
|
2438
|
+
return $0fe1f1400993ba8a$export$80e06a8ed038dcf8;
|
|
2439
|
+
});
|
|
2440
|
+
$parcel$export($0fe1f1400993ba8a$exports, "HTTPToolkit", function() {
|
|
2441
|
+
return $0fe1f1400993ba8a$export$7370b3fc922cf1e6;
|
|
2442
|
+
});
|
|
2443
|
+
$parcel$export($0fe1f1400993ba8a$exports, "requestXHR", function() {
|
|
2444
|
+
return $0fe1f1400993ba8a$export$4f2a8c8c11a6373a;
|
|
2445
|
+
});
|
|
2446
|
+
$parcel$export($0fe1f1400993ba8a$exports, "requestFetch", function() {
|
|
2447
|
+
return $0fe1f1400993ba8a$export$bda27a3e49197b9;
|
|
2448
|
+
});
|
|
2449
|
+
$parcel$export($0fe1f1400993ba8a$exports, "parseResponse", function() {
|
|
2450
|
+
return $0fe1f1400993ba8a$export$ba14d9a5a581e827;
|
|
2451
|
+
});
|
|
2452
|
+
$parcel$export($0fe1f1400993ba8a$exports, "parseFetchBody", function() {
|
|
2453
|
+
return $0fe1f1400993ba8a$export$b7b86d31099674dc;
|
|
2454
|
+
});
|
|
2455
|
+
$parcel$export($0fe1f1400993ba8a$exports, "rawRequest", function() {
|
|
2456
|
+
return $0fe1f1400993ba8a$export$3052fa16c23a17ef;
|
|
2457
|
+
});
|
|
2458
|
+
$parcel$export($0fe1f1400993ba8a$exports, "requestHead", function() {
|
|
2459
|
+
return $0fe1f1400993ba8a$export$199f266664335871;
|
|
2460
|
+
});
|
|
2461
|
+
$parcel$export($0fe1f1400993ba8a$exports, "request", function() {
|
|
2462
|
+
return $0fe1f1400993ba8a$export$b5fe3f66a567bec0;
|
|
2463
|
+
});
|
|
2464
|
+
var $22de11b45b0eeb97$exports = {};
|
|
2465
|
+
$parcel$export($22de11b45b0eeb97$exports, "FileMethod", function() {
|
|
2466
|
+
return $22de11b45b0eeb97$export$226b21d2db5eaf9f;
|
|
2467
|
+
});
|
|
2468
|
+
$parcel$export($22de11b45b0eeb97$exports, "defaultDataRuntime", function() {
|
|
2469
|
+
return $22de11b45b0eeb97$export$f7195e83247c5fe1;
|
|
2470
|
+
});
|
|
2471
|
+
$parcel$export($22de11b45b0eeb97$exports, "DataToolkit", function() {
|
|
2472
|
+
return $22de11b45b0eeb97$export$bc241bb96b6158a8;
|
|
2473
|
+
});
|
|
2474
|
+
$parcel$export($22de11b45b0eeb97$exports, "polyfillProgressEvent", function() {
|
|
2475
|
+
return $22de11b45b0eeb97$export$5e6a03ce7b01784;
|
|
2476
|
+
});
|
|
2477
|
+
$parcel$export($22de11b45b0eeb97$exports, "parseDocument", function() {
|
|
2478
|
+
return $22de11b45b0eeb97$export$b6a9369736b19f4d;
|
|
2479
|
+
});
|
|
2480
|
+
$parcel$export($22de11b45b0eeb97$exports, "makeFormData", function() {
|
|
2481
|
+
return $22de11b45b0eeb97$export$2c28ab2e118e73f1;
|
|
2482
|
+
});
|
|
2483
|
+
$parcel$export($22de11b45b0eeb97$exports, "serializeNode", function() {
|
|
2484
|
+
return $22de11b45b0eeb97$export$a0beee2e55fb5dd1;
|
|
2485
|
+
});
|
|
2486
|
+
$parcel$export($22de11b45b0eeb97$exports, "serialize", function() {
|
|
2487
|
+
return $22de11b45b0eeb97$export$dfdc1655ccc5b9cb;
|
|
2488
|
+
});
|
|
2489
|
+
$parcel$export($22de11b45b0eeb97$exports, "takeBytes", function() {
|
|
2490
|
+
return $22de11b45b0eeb97$export$45c4469e58b7b0ca;
|
|
2491
|
+
});
|
|
2492
|
+
$parcel$export($22de11b45b0eeb97$exports, "readBytes", function() {
|
|
2493
|
+
return $22de11b45b0eeb97$export$f9f241124ee3198e;
|
|
2494
|
+
});
|
|
2495
|
+
$parcel$export($22de11b45b0eeb97$exports, "makeStream", function() {
|
|
2496
|
+
return $22de11b45b0eeb97$export$4b366c43f3cabead;
|
|
2497
|
+
});
|
|
2498
|
+
$parcel$export($22de11b45b0eeb97$exports, "streamFromProgress", function() {
|
|
2499
|
+
return $22de11b45b0eeb97$export$f8162fcba31fa547;
|
|
2500
|
+
});
|
|
2501
|
+
$parcel$export($22de11b45b0eeb97$exports, "emitStreamProgress", function() {
|
|
2502
|
+
return $22de11b45b0eeb97$export$cebfdbc318a33abe;
|
|
2503
|
+
});
|
|
2504
|
+
$parcel$export($22de11b45b0eeb97$exports, "readAs", function() {
|
|
2505
|
+
return $22de11b45b0eeb97$export$e209cbb66c5b18c;
|
|
2506
|
+
});
|
|
2507
|
+
$parcel$export($22de11b45b0eeb97$exports, "encodeBase64", function() {
|
|
2508
|
+
return $22de11b45b0eeb97$export$8fb536984ec8b4d7;
|
|
2509
|
+
});
|
|
2510
|
+
var $22de11b45b0eeb97$export$226b21d2db5eaf9f = /*#__PURE__*/ function(FileMethod) {
|
|
2511
|
+
FileMethod["text"] = "readAsText";
|
|
2512
|
+
FileMethod["dataURL"] = "readAsDataURL";
|
|
2513
|
+
FileMethod["binaryString"] = "readAsBinaryString";
|
|
2514
|
+
FileMethod["arrayBuffer"] = "readAsArrayBuffer";
|
|
2515
|
+
return FileMethod;
|
|
2516
|
+
}({});
|
|
2517
|
+
const $22de11b45b0eeb97$var$DataURI = /^data:(.+?\/(.+?))?(;base64)?,([\s\S]+)/;
|
|
2518
|
+
const $22de11b45b0eeb97$export$f7195e83247c5fe1 = {
|
|
2519
|
+
DOMParser: globalThis.DOMParser,
|
|
2520
|
+
Node: globalThis.Node,
|
|
2521
|
+
Document: globalThis.Document,
|
|
2522
|
+
HTMLElement: globalThis.HTMLElement,
|
|
2523
|
+
SVGElement: globalThis.SVGElement,
|
|
2524
|
+
FormData: globalThis.FormData,
|
|
2525
|
+
URLSearchParams: globalThis.URLSearchParams,
|
|
2526
|
+
Blob: globalThis.Blob,
|
|
2527
|
+
FileReader: globalThis.FileReader,
|
|
2528
|
+
Event: globalThis.Event,
|
|
2529
|
+
ProgressEvent: globalThis.ProgressEvent,
|
|
2530
|
+
ReadableStream
|
|
2531
|
+
};
|
|
2532
|
+
var $22de11b45b0eeb97$export$bc241bb96b6158a8 = class {
|
|
2533
|
+
constructor(runtime = $22de11b45b0eeb97$export$f7195e83247c5fe1) {
|
|
2534
|
+
this.runtime = runtime;
|
|
2535
|
+
this.polyfillProgressEvent = () => globalThis.ProgressEvent ||= class ProgressEvent extends this.runtime.Event {
|
|
2536
|
+
constructor(type, { lengthComputable, total, loaded, ...meta } = {}) {
|
|
2537
|
+
super(type, meta);
|
|
2538
|
+
this.lengthComputable = lengthComputable;
|
|
2539
|
+
this.total = total;
|
|
2540
|
+
this.loaded = loaded;
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
this.parseDocument = async (text, contentType = "") => {
|
|
2544
|
+
const { DOMParser } = this.runtime;
|
|
2545
|
+
const [type] = contentType?.split(";") || [];
|
|
2546
|
+
return new DOMParser().parseFromString(text, type || "text/html");
|
|
2547
|
+
};
|
|
2548
|
+
this.makeFormData = (data) => {
|
|
2549
|
+
const { FormData } = this.runtime;
|
|
2550
|
+
const formData = new FormData();
|
|
2551
|
+
for (const [key, value] of Object.entries(data)) {
|
|
2552
|
+
const list = typeof value !== "string" && (0, web_utility.likeArray)(value) ? value : [value];
|
|
2553
|
+
for (const item of Array.from(list)) if (item != null) {
|
|
2554
|
+
if (typeof item === "object") formData.append(key, item, item.name);
|
|
2555
|
+
else formData.append(key, item);
|
|
2556
|
+
}
|
|
2557
|
+
}
|
|
2558
|
+
return formData;
|
|
2559
|
+
};
|
|
2560
|
+
this.serializeNode = (root) => {
|
|
2561
|
+
const { URLSearchParams, FormData, Document, HTMLElement, SVGElement } = this.runtime;
|
|
2562
|
+
var contentType;
|
|
2563
|
+
if (!(root instanceof HTMLFormElement)) return {
|
|
2564
|
+
contentType: root instanceof SVGElement ? "image/svg" : root instanceof Document || root instanceof HTMLElement ? "text/html" : "application/xml",
|
|
2565
|
+
data: (0, web_utility.stringifyDOM)(root)
|
|
2566
|
+
};
|
|
2567
|
+
if (root.querySelector("input[type=\"file\"][name]")) return {
|
|
2568
|
+
contentType: "multipart/form-data",
|
|
2569
|
+
data: new FormData(root)
|
|
2570
|
+
};
|
|
2571
|
+
const data = (0, web_utility.formToJSON)(root);
|
|
2572
|
+
switch (contentType = root.enctype) {
|
|
2573
|
+
case "text/plain": return {
|
|
2574
|
+
contentType,
|
|
2575
|
+
data: Object.entries(data).map(([name, value]) => `${name}=${value}`).join("\n")
|
|
2576
|
+
};
|
|
2577
|
+
case "application/x-www-form-urlencoded": return {
|
|
2578
|
+
contentType,
|
|
2579
|
+
data: new URLSearchParams(data)
|
|
2580
|
+
};
|
|
2581
|
+
default: return {
|
|
2582
|
+
contentType: "application/json",
|
|
2583
|
+
data: JSON.stringify(data)
|
|
2584
|
+
};
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
this.serialize = (data, contentType) => {
|
|
2588
|
+
const { Node, URLSearchParams, FormData, Blob, ReadableStream } = this.runtime;
|
|
2589
|
+
const [type] = contentType?.split(";") || [];
|
|
2590
|
+
switch (type) {
|
|
2591
|
+
case "application/x-www-form-urlencoded": return {
|
|
2592
|
+
contentType,
|
|
2593
|
+
data: new URLSearchParams(data)
|
|
2594
|
+
};
|
|
2595
|
+
case "multipart/form-data": return { data: this.makeFormData(data) };
|
|
2596
|
+
case "application/json": return {
|
|
2597
|
+
contentType,
|
|
2598
|
+
data: JSON.stringify(data)
|
|
2599
|
+
};
|
|
2600
|
+
case "text/html":
|
|
2601
|
+
case "application/xml":
|
|
2602
|
+
case "image/svg": return {
|
|
2603
|
+
contentType,
|
|
2604
|
+
data: (0, web_utility.stringifyDOM)(data)
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
if (type) return {
|
|
2608
|
+
data,
|
|
2609
|
+
contentType
|
|
2610
|
+
};
|
|
2611
|
+
try {
|
|
2612
|
+
if (data instanceof URLSearchParams) return {
|
|
2613
|
+
contentType: "application/x-www-form-urlencoded",
|
|
2614
|
+
data
|
|
2615
|
+
};
|
|
2616
|
+
} catch {}
|
|
2617
|
+
try {
|
|
2618
|
+
if (data instanceof FormData) return { data };
|
|
2619
|
+
} catch {}
|
|
2620
|
+
try {
|
|
2621
|
+
if (data instanceof Node) return this.serializeNode(data);
|
|
2622
|
+
} catch {}
|
|
2623
|
+
try {
|
|
2624
|
+
if ((0, web_utility.isTypedArray)(data) || data instanceof ArrayBuffer || data instanceof DataView || data instanceof Blob || data instanceof ReadableStream) return {
|
|
2625
|
+
contentType: "application/octet-stream",
|
|
2626
|
+
data
|
|
2627
|
+
};
|
|
2628
|
+
} catch {}
|
|
2629
|
+
try {
|
|
2630
|
+
return {
|
|
2631
|
+
contentType: "application/json",
|
|
2632
|
+
data: JSON.stringify(data)
|
|
2633
|
+
};
|
|
2634
|
+
} catch {}
|
|
2635
|
+
throw new Error("Unserialized Object needs a specific Content-Type");
|
|
2636
|
+
};
|
|
2637
|
+
this.readBytes = async (stream, limit = Infinity) => {
|
|
2638
|
+
const { Blob } = this.runtime;
|
|
2639
|
+
return new Blob(await Array.fromAsync(this.takeBytes(stream, limit))).arrayBuffer();
|
|
2640
|
+
};
|
|
2641
|
+
this.makeStream = (...chunks) => {
|
|
2642
|
+
const { Blob } = this.runtime;
|
|
2643
|
+
return new Blob(chunks).stream();
|
|
2644
|
+
};
|
|
2645
|
+
this.streamFromProgress = (target) => (0, web_utility.createAsyncIterator)(({ next, complete, error }) => {
|
|
2646
|
+
const handleProgress = ({ loaded, total }) => {
|
|
2647
|
+
next({
|
|
2648
|
+
loaded,
|
|
2649
|
+
total
|
|
2650
|
+
});
|
|
2651
|
+
if (loaded >= total) complete();
|
|
2652
|
+
};
|
|
2653
|
+
target.addEventListener("progress", handleProgress);
|
|
2654
|
+
target.addEventListener("error", error);
|
|
2655
|
+
return () => {
|
|
2656
|
+
target.removeEventListener("progress", handleProgress);
|
|
2657
|
+
target.removeEventListener("error", error);
|
|
2658
|
+
};
|
|
2659
|
+
});
|
|
2660
|
+
this.emitStreamProgress = (stream, total, eventTarget) => {
|
|
2661
|
+
const { ProgressEvent } = this.runtime;
|
|
2662
|
+
return async function* () {
|
|
2663
|
+
var loaded = 0;
|
|
2664
|
+
for await (const chunk of stream) {
|
|
2665
|
+
yield chunk;
|
|
2666
|
+
loaded += chunk.byteLength;
|
|
2667
|
+
const event = new ProgressEvent("progress", {
|
|
2668
|
+
lengthComputable: isNaN(total),
|
|
2669
|
+
loaded,
|
|
2670
|
+
total
|
|
2671
|
+
});
|
|
2672
|
+
eventTarget.dispatchEvent(event);
|
|
2673
|
+
}
|
|
2674
|
+
}();
|
|
2675
|
+
};
|
|
2676
|
+
this.readAs = (file, method, encoding) => {
|
|
2677
|
+
const { FileReader } = this.runtime;
|
|
2678
|
+
const reader = new FileReader();
|
|
2679
|
+
const result = new Promise((resolve, reject) => {
|
|
2680
|
+
reader.onerror = reject;
|
|
2681
|
+
reader.onload = () => resolve(reader.result);
|
|
2682
|
+
reader[$22de11b45b0eeb97$export$226b21d2db5eaf9f[method]](file, encoding);
|
|
2683
|
+
});
|
|
2684
|
+
return {
|
|
2685
|
+
progress: this.streamFromProgress(reader),
|
|
2686
|
+
result
|
|
2687
|
+
};
|
|
2688
|
+
};
|
|
2689
|
+
this.encodeBase64 = async (raw) => {
|
|
2690
|
+
const { Blob } = this.runtime;
|
|
2691
|
+
if (raw instanceof Blob) {
|
|
2692
|
+
const text = await this.readAs(raw, "dataURL").result;
|
|
2693
|
+
return ($22de11b45b0eeb97$var$DataURI.exec(text) || "")[4];
|
|
2694
|
+
}
|
|
2695
|
+
const text = encodeURIComponent(raw).replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(+("0x" + p1)));
|
|
2696
|
+
return btoa(text);
|
|
2697
|
+
};
|
|
2698
|
+
if (runtime.Event) this.runtime.ProgressEvent = this.polyfillProgressEvent();
|
|
2699
|
+
}
|
|
2700
|
+
async *takeBytes(stream, limit = Infinity) {
|
|
2701
|
+
let total = 0;
|
|
2702
|
+
for await (const chunk of stream) {
|
|
2703
|
+
const remaining = limit - total;
|
|
2704
|
+
if (chunk.byteLength > remaining) {
|
|
2705
|
+
yield chunk.slice(0, remaining);
|
|
2706
|
+
break;
|
|
2707
|
+
}
|
|
2708
|
+
yield new Uint8Array(chunk);
|
|
2709
|
+
total += chunk.byteLength;
|
|
2710
|
+
if (total >= limit) break;
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
};
|
|
2714
|
+
const { polyfillProgressEvent: $22de11b45b0eeb97$export$5e6a03ce7b01784, parseDocument: $22de11b45b0eeb97$export$b6a9369736b19f4d, makeFormData: $22de11b45b0eeb97$export$2c28ab2e118e73f1, serializeNode: $22de11b45b0eeb97$export$a0beee2e55fb5dd1, serialize: $22de11b45b0eeb97$export$dfdc1655ccc5b9cb, takeBytes: $22de11b45b0eeb97$export$45c4469e58b7b0ca, readBytes: $22de11b45b0eeb97$export$f9f241124ee3198e, makeStream: $22de11b45b0eeb97$export$4b366c43f3cabead, streamFromProgress: $22de11b45b0eeb97$export$f8162fcba31fa547, emitStreamProgress: $22de11b45b0eeb97$export$cebfdbc318a33abe, readAs: $22de11b45b0eeb97$export$e209cbb66c5b18c, encodeBase64: $22de11b45b0eeb97$export$8fb536984ec8b4d7 } = new $22de11b45b0eeb97$export$bc241bb96b6158a8();
|
|
2715
|
+
var $0fe1f1400993ba8a$export$4125cfe7e08e2040 = /*#__PURE__*/ function(BodyRequestMethods) {
|
|
2716
|
+
BodyRequestMethods["POST"] = "POST";
|
|
2717
|
+
BodyRequestMethods["PUT"] = "PUT";
|
|
2718
|
+
BodyRequestMethods["PATCH"] = "PATCH";
|
|
2719
|
+
BodyRequestMethods["DELETE"] = "DELETE";
|
|
2720
|
+
return BodyRequestMethods;
|
|
2721
|
+
}({});
|
|
2722
|
+
var $0fe1f1400993ba8a$export$aa9d629c530f62a7 = class extends URIError {
|
|
2723
|
+
constructor(message, request, response) {
|
|
2724
|
+
super(message), this.request = request, this.response = response;
|
|
2725
|
+
}
|
|
2726
|
+
};
|
|
2727
|
+
const $0fe1f1400993ba8a$export$b725a69477e4d33f = { Link: (value) => Object.fromEntries(Array.from(value.matchAll(/<(\S+?)>; rel="(\w+)"(?:; title="(.*?)")?/g), ([_, URI, rel, title]) => [rel, {
|
|
2728
|
+
rel,
|
|
2729
|
+
URI,
|
|
2730
|
+
title
|
|
2731
|
+
}])) };
|
|
2732
|
+
const $0fe1f1400993ba8a$export$eea2c1c5e1a37e50 = (raw) => Object.fromEntries(Array.from(raw.trim().matchAll(/^([\w-]+):\s*(.*)/gm), ([_, key, value]) => {
|
|
2733
|
+
key = key.replace(/(^[a-z]|-[a-z])/g, (char) => char.toUpperCase());
|
|
2734
|
+
return [key, $0fe1f1400993ba8a$export$b725a69477e4d33f[key]?.(value) ?? value];
|
|
2735
|
+
}));
|
|
2736
|
+
function $0fe1f1400993ba8a$export$3b629cd0ff482602(raw, contentType) {
|
|
2737
|
+
if (contentType.includes("json")) return (0, web_utility.parseJSON)(raw);
|
|
2738
|
+
if (contentType.match(/html|xml/)) try {
|
|
2739
|
+
return this.parseDocument(raw, contentType);
|
|
2740
|
+
} catch {}
|
|
2741
|
+
if (contentType.includes("text")) return raw;
|
|
2742
|
+
return new TextEncoder().encode(raw).buffer;
|
|
2743
|
+
}
|
|
2744
|
+
const $0fe1f1400993ba8a$export$153cac11fce574d = 4100;
|
|
2745
|
+
const $0fe1f1400993ba8a$export$80e06a8ed038dcf8 = {
|
|
2746
|
+
...$22de11b45b0eeb97$export$f7195e83247c5fe1,
|
|
2747
|
+
EventTarget: globalThis.EventTarget,
|
|
2748
|
+
XMLHttpRequest: globalThis.XMLHttpRequest,
|
|
2749
|
+
Headers: globalThis.Headers,
|
|
2750
|
+
fetch: globalThis.fetch
|
|
2751
|
+
};
|
|
2752
|
+
var $0fe1f1400993ba8a$export$7370b3fc922cf1e6 = class extends $22de11b45b0eeb97$export$bc241bb96b6158a8 {
|
|
2753
|
+
constructor(runtime = $0fe1f1400993ba8a$export$80e06a8ed038dcf8) {
|
|
2754
|
+
super(runtime), this.runtime = runtime, this.requestXHR = ({ method = "GET", path, headers = {}, body, signal, ...rest }) => {
|
|
2755
|
+
const { XMLHttpRequest, Headers, Blob, ReadableStream } = this.runtime;
|
|
2756
|
+
const request = new XMLHttpRequest();
|
|
2757
|
+
const header = new Headers(headers);
|
|
2758
|
+
const bodyPromise = body instanceof ReadableStream ? Array.fromAsync(body).then((parts) => new Blob(parts)) : Promise.resolve(body);
|
|
2759
|
+
const abort = () => request.abort();
|
|
2760
|
+
signal?.addEventListener("abort", abort);
|
|
2761
|
+
const response = new Promise((resolve, reject) => {
|
|
2762
|
+
request.onreadystatechange = () => {
|
|
2763
|
+
const { readyState, status, statusText, responseType } = request;
|
|
2764
|
+
if (readyState !== 4 || !status && !signal?.aborted) return;
|
|
2765
|
+
resolve({
|
|
2766
|
+
status,
|
|
2767
|
+
statusText,
|
|
2768
|
+
headers: $0fe1f1400993ba8a$export$eea2c1c5e1a37e50(request.getAllResponseHeaders()),
|
|
2769
|
+
body: responseType && responseType !== "text" ? request.response : request.responseText
|
|
2770
|
+
});
|
|
2771
|
+
};
|
|
2772
|
+
request.onerror = request.ontimeout = reject;
|
|
2773
|
+
const [MIMEType] = header.get("Accept")?.split(",") || [rest.responseType === "document" ? "application/xhtml+xml" : rest.responseType === "json" ? "application/json" : ""];
|
|
2774
|
+
if (MIMEType) request.overrideMimeType(MIMEType);
|
|
2775
|
+
request.open(method, path + "");
|
|
2776
|
+
for (const [key, value] of header) request.setRequestHeader(key, value);
|
|
2777
|
+
Object.assign(request, rest);
|
|
2778
|
+
bodyPromise.then((body) => request.send(body));
|
|
2779
|
+
}).then(({ body, ...meta }) => {
|
|
2780
|
+
signal?.throwIfAborted();
|
|
2781
|
+
const contentType = request.getResponseHeader("Content-Type") || "";
|
|
2782
|
+
if (typeof body === "string" && !contentType.includes("text")) body = $0fe1f1400993ba8a$export$3b629cd0ff482602(body, contentType);
|
|
2783
|
+
return {
|
|
2784
|
+
...meta,
|
|
2785
|
+
body
|
|
2786
|
+
};
|
|
2787
|
+
});
|
|
2788
|
+
response.finally(() => signal?.removeEventListener("abort", abort));
|
|
2789
|
+
return {
|
|
2790
|
+
response,
|
|
2791
|
+
upload: this.streamFromProgress(request.upload),
|
|
2792
|
+
download: this.streamFromProgress(request)
|
|
2793
|
+
};
|
|
2794
|
+
}, this.requestFetch = ({ path, method, headers, withCredentials, body, signal, timeout, responseType }) => {
|
|
2795
|
+
const { EventTarget, Headers, ReadableStream, fetch } = this.runtime;
|
|
2796
|
+
const signals = [signal, timeout && AbortSignal.timeout(timeout)].filter(Boolean);
|
|
2797
|
+
headers = headers instanceof Headers ? Object.fromEntries(headers.entries()) : headers instanceof Array ? Object.fromEntries(headers) : headers;
|
|
2798
|
+
headers = responseType === "text" ? {
|
|
2799
|
+
...headers,
|
|
2800
|
+
Accept: "text/plain"
|
|
2801
|
+
} : responseType === "json" ? {
|
|
2802
|
+
...headers,
|
|
2803
|
+
Accept: "application/json"
|
|
2804
|
+
} : responseType === "document" ? {
|
|
2805
|
+
...headers,
|
|
2806
|
+
Accept: "text/html, application/xhtml+xml, application/xml"
|
|
2807
|
+
} : responseType === "arraybuffer" || responseType === "blob" ? {
|
|
2808
|
+
...headers,
|
|
2809
|
+
Accept: "application/octet-stream"
|
|
2810
|
+
} : headers;
|
|
2811
|
+
const isStream = body instanceof ReadableStream;
|
|
2812
|
+
var upload;
|
|
2813
|
+
if (isStream) {
|
|
2814
|
+
const uploadProgress = new EventTarget();
|
|
2815
|
+
body = ReadableStream.from(this.emitStreamProgress(body, +headers["Content-Length"], uploadProgress));
|
|
2816
|
+
upload = this.streamFromProgress(uploadProgress);
|
|
2817
|
+
}
|
|
2818
|
+
const downloadProgress = new EventTarget();
|
|
2819
|
+
const response = fetch(path + "", {
|
|
2820
|
+
method,
|
|
2821
|
+
headers,
|
|
2822
|
+
credentials: withCredentials ? "include" : "omit",
|
|
2823
|
+
body,
|
|
2824
|
+
signal: signals[0] && AbortSignal.any(signals),
|
|
2825
|
+
duplex: isStream ? "half" : void 0
|
|
2826
|
+
}).then((response) => this.parseResponse(response, responseType, downloadProgress));
|
|
2827
|
+
const download = this.streamFromProgress(downloadProgress);
|
|
2828
|
+
return {
|
|
2829
|
+
response,
|
|
2830
|
+
upload,
|
|
2831
|
+
download
|
|
2832
|
+
};
|
|
2833
|
+
}, this.parseResponse = async ({ status, statusText, headers, body }, responseType, downloadProgress) => {
|
|
2834
|
+
const { ReadableStream } = this.runtime;
|
|
2835
|
+
const contentType = headers.get("Content-Type") || "";
|
|
2836
|
+
const header = $0fe1f1400993ba8a$export$eea2c1c5e1a37e50([...headers].map(([key, value]) => `${key}: ${value}`).join("\n"));
|
|
2837
|
+
if (status === 204 || !body) return {
|
|
2838
|
+
status,
|
|
2839
|
+
statusText,
|
|
2840
|
+
headers: header,
|
|
2841
|
+
body: void 0
|
|
2842
|
+
};
|
|
2843
|
+
const stream = ReadableStream.from(this.emitStreamProgress(ReadableStream.from(body), +headers.get("Content-Length"), downloadProgress));
|
|
2844
|
+
return {
|
|
2845
|
+
status,
|
|
2846
|
+
statusText,
|
|
2847
|
+
headers: header,
|
|
2848
|
+
body: await this.parseFetchBody(stream, contentType, responseType)
|
|
2849
|
+
};
|
|
2850
|
+
}, this.parseFetchBody = async (stream, contentType, responseType) => {
|
|
2851
|
+
const { Blob } = this.runtime;
|
|
2852
|
+
const blob = new Blob(await Array.fromAsync(stream), { type: contentType });
|
|
2853
|
+
if (responseType === "blob") return blob;
|
|
2854
|
+
if (responseType === "arraybuffer") return blob.arrayBuffer();
|
|
2855
|
+
const text = await blob.text();
|
|
2856
|
+
if (responseType === "text") return text;
|
|
2857
|
+
return $0fe1f1400993ba8a$export$3b629cd0ff482602(text, contentType);
|
|
2858
|
+
}, this.rawRequest = typeof this.runtime.XMLHttpRequest === "function" ? this.requestXHR : this.requestFetch, this.requestHead = async ({ path, headers, withCredentials, timeout, signal }) => {
|
|
2859
|
+
const { Headers, fetch } = this.runtime;
|
|
2860
|
+
const normalizedHeaders = !headers ? {} : headers instanceof Headers ? Object.fromEntries(headers) : Array.isArray(headers) ? Object.fromEntries(headers) : headers;
|
|
2861
|
+
const signals = [signal, timeout && AbortSignal.timeout(timeout)].filter(Boolean);
|
|
2862
|
+
const fetchOptions = {
|
|
2863
|
+
credentials: withCredentials ? "include" : "omit",
|
|
2864
|
+
signal: signals[1] ? AbortSignal.any(signals) : signals[0]
|
|
2865
|
+
};
|
|
2866
|
+
const toHeaders = (raw) => $0fe1f1400993ba8a$export$eea2c1c5e1a37e50([...raw].map(([k, v]) => `${k}: ${v}`).join("\n"));
|
|
2867
|
+
try {
|
|
2868
|
+
const response = await fetch(path + "", {
|
|
2869
|
+
method: "HEAD",
|
|
2870
|
+
...fetchOptions,
|
|
2871
|
+
headers: normalizedHeaders
|
|
2872
|
+
});
|
|
2873
|
+
if (response.ok) return { headers: toHeaders(response.headers) };
|
|
2874
|
+
} catch {}
|
|
2875
|
+
try {
|
|
2876
|
+
const response = await fetch(path + "", {
|
|
2877
|
+
...fetchOptions,
|
|
2878
|
+
headers: {
|
|
2879
|
+
...normalizedHeaders,
|
|
2880
|
+
Range: `bytes=0-4099`
|
|
2881
|
+
}
|
|
2882
|
+
});
|
|
2883
|
+
if (!response.ok) throw new Error(`${response.status} ${response.statusText}`);
|
|
2884
|
+
return {
|
|
2885
|
+
headers: toHeaders(response.headers),
|
|
2886
|
+
body: await response.arrayBuffer()
|
|
2887
|
+
};
|
|
2888
|
+
} catch {}
|
|
2889
|
+
const response = await fetch(path, {
|
|
2890
|
+
...fetchOptions,
|
|
2891
|
+
headers: normalizedHeaders
|
|
2892
|
+
});
|
|
2893
|
+
const body = await this.readBytes(ReadableStream.from(response.body), $0fe1f1400993ba8a$export$153cac11fce574d);
|
|
2894
|
+
return {
|
|
2895
|
+
headers: toHeaders(response.headers),
|
|
2896
|
+
body
|
|
2897
|
+
};
|
|
2898
|
+
}, this.request = (option) => {
|
|
2899
|
+
if (option.method !== "HEAD") return this.rawRequest(option);
|
|
2900
|
+
return {
|
|
2901
|
+
response: this.requestHead(option).then(({ headers, body }) => ({
|
|
2902
|
+
status: 204,
|
|
2903
|
+
statusText: "No Content",
|
|
2904
|
+
headers,
|
|
2905
|
+
body
|
|
2906
|
+
})),
|
|
2907
|
+
download: async function* () {}()
|
|
2908
|
+
};
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
const { requestXHR: $0fe1f1400993ba8a$export$4f2a8c8c11a6373a, requestFetch: $0fe1f1400993ba8a$export$bda27a3e49197b9, parseResponse: $0fe1f1400993ba8a$export$ba14d9a5a581e827, parseFetchBody: $0fe1f1400993ba8a$export$b7b86d31099674dc, rawRequest: $0fe1f1400993ba8a$export$3052fa16c23a17ef, requestHead: $0fe1f1400993ba8a$export$199f266664335871, request: $0fe1f1400993ba8a$export$b5fe3f66a567bec0 } = new $0fe1f1400993ba8a$export$7370b3fc922cf1e6();
|
|
2913
|
+
$parcel$export({}, "HTTPClient", function() {
|
|
2914
|
+
return $cbd22d3323bef9ca$export$45cf759b359d3d24;
|
|
2915
|
+
});
|
|
2916
|
+
const { splice: $cbd22d3323bef9ca$var$splice } = Array.prototype;
|
|
2917
|
+
var $cbd22d3323bef9ca$export$45cf759b359d3d24 = class extends $eef213ff4197108b$export$694e0d28c7ffc90c {
|
|
2918
|
+
constructor({ baseURI = globalThis.document?.baseURI, baseRequest = $0fe1f1400993ba8a$export$b5fe3f66a567bec0, ...options } = {}) {
|
|
2919
|
+
super(), this.defaultWare = async ({ request, response }, next) => {
|
|
2920
|
+
const { method = "GET", headers = {}, body } = request;
|
|
2921
|
+
if (method in $0fe1f1400993ba8a$export$4125cfe7e08e2040 && body && typeof body === "object") {
|
|
2922
|
+
const { contentType, data } = $22de11b45b0eeb97$export$dfdc1655ccc5b9cb(body, headers["Content-Type"]);
|
|
2923
|
+
if (contentType) headers["Content-Type"] = contentType;
|
|
2924
|
+
request.body = data;
|
|
2925
|
+
}
|
|
2926
|
+
await next();
|
|
2927
|
+
if (response.status > 299) throw new $0fe1f1400993ba8a$export$aa9d629c530f62a7(response.statusText, request, response);
|
|
2928
|
+
};
|
|
2929
|
+
this.baseURI = baseURI;
|
|
2930
|
+
this.baseRequest = baseRequest;
|
|
2931
|
+
this.options = options;
|
|
2932
|
+
super.use(this.defaultWare);
|
|
2933
|
+
super.use(async ({ request: data, response }) => {
|
|
2934
|
+
data.path = new URL(data.path, this.baseURI) + "";
|
|
2935
|
+
Object.assign(response, await this.baseRequest({
|
|
2936
|
+
...options,
|
|
2937
|
+
...data
|
|
2938
|
+
}).response);
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
use(...middlewares) {
|
|
2942
|
+
$cbd22d3323bef9ca$var$splice.call(this, -2, 0, ...middlewares);
|
|
2943
|
+
return this;
|
|
2944
|
+
}
|
|
2945
|
+
async request(data) {
|
|
2946
|
+
const context = {
|
|
2947
|
+
request: {
|
|
2948
|
+
...data,
|
|
2949
|
+
headers: { ...data.headers }
|
|
2950
|
+
},
|
|
2951
|
+
response: {}
|
|
2952
|
+
};
|
|
2953
|
+
await this.execute(context);
|
|
2954
|
+
return context.response;
|
|
2955
|
+
}
|
|
2956
|
+
async head(path, headers, options) {
|
|
2957
|
+
const { headers: data } = await this.request({
|
|
2958
|
+
method: "HEAD",
|
|
2959
|
+
path,
|
|
2960
|
+
headers,
|
|
2961
|
+
...options
|
|
2962
|
+
});
|
|
2963
|
+
return data;
|
|
2964
|
+
}
|
|
2965
|
+
get(path, headers, options) {
|
|
2966
|
+
return this.request({
|
|
2967
|
+
method: "GET",
|
|
2968
|
+
path,
|
|
2969
|
+
headers,
|
|
2970
|
+
...options
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
post(path, body, headers, options) {
|
|
2974
|
+
return this.request({
|
|
2975
|
+
method: "POST",
|
|
2976
|
+
path,
|
|
2977
|
+
headers,
|
|
2978
|
+
body,
|
|
2979
|
+
...options
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
put(path, body, headers, options) {
|
|
2983
|
+
return this.request({
|
|
2984
|
+
method: "PUT",
|
|
2985
|
+
path,
|
|
2986
|
+
headers,
|
|
2987
|
+
body,
|
|
2988
|
+
...options
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
patch(path, body, headers, options) {
|
|
2992
|
+
return this.request({
|
|
2993
|
+
method: "PATCH",
|
|
2994
|
+
path,
|
|
2995
|
+
headers,
|
|
2996
|
+
body,
|
|
2997
|
+
...options
|
|
2998
|
+
});
|
|
2999
|
+
}
|
|
3000
|
+
delete(path, body, headers, options) {
|
|
3001
|
+
return this.request({
|
|
3002
|
+
method: "DELETE",
|
|
3003
|
+
path,
|
|
3004
|
+
headers,
|
|
3005
|
+
body,
|
|
3006
|
+
...options
|
|
3007
|
+
});
|
|
3008
|
+
}
|
|
3009
|
+
async *download(path, { headers, chunkSize = 1024 ** 2, range: [start = 0, end = Infinity] = [], ...options } = {}) {
|
|
3010
|
+
const { "Content-Length": length } = await this.head(path, headers, options);
|
|
3011
|
+
const total = +length;
|
|
3012
|
+
if (end === Infinity) end = total;
|
|
3013
|
+
for (let i = start, j = i - 1 + chunkSize; i < end; i = j + 1, j += chunkSize) {
|
|
3014
|
+
const { status, body } = await this.get(path, {
|
|
3015
|
+
...headers,
|
|
3016
|
+
Range: `bytes=${i}-${j}`
|
|
3017
|
+
}, options);
|
|
3018
|
+
if (status !== 206) {
|
|
3019
|
+
yield {
|
|
3020
|
+
total,
|
|
3021
|
+
loaded: total,
|
|
3022
|
+
percent: 100,
|
|
3023
|
+
buffer: body
|
|
3024
|
+
};
|
|
3025
|
+
break;
|
|
3026
|
+
}
|
|
3027
|
+
const loaded = i + body.byteLength;
|
|
3028
|
+
yield {
|
|
3029
|
+
total,
|
|
3030
|
+
loaded,
|
|
3031
|
+
percent: +(loaded / total * 100).toFixed(2),
|
|
3032
|
+
buffer: body
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3037
|
+
//#endregion
|
|
3038
|
+
//#region source/SSR/middleware/local.ts
|
|
3039
|
+
async function errorLogger(context, next) {
|
|
3040
|
+
try {
|
|
3041
|
+
return await next();
|
|
3042
|
+
} catch (error) {
|
|
3043
|
+
console.error(error);
|
|
3044
|
+
if (error instanceof $0fe1f1400993ba8a$export$aa9d629c530f62a7) {
|
|
3045
|
+
const { status } = error.response;
|
|
3046
|
+
if (status === 404) return {
|
|
3047
|
+
notFound: true,
|
|
3048
|
+
props: {}
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3051
|
+
throw error;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
async function router(context, next) {
|
|
3055
|
+
const options = await next() || {}, { resolvedUrl, params, query, locales } = context;
|
|
3056
|
+
return {
|
|
3057
|
+
...options,
|
|
3058
|
+
props: {
|
|
3059
|
+
..."props" in options ? options.props : {},
|
|
3060
|
+
route: JSON.parse(JSON.stringify({
|
|
3061
|
+
resolvedUrl,
|
|
3062
|
+
params,
|
|
3063
|
+
query,
|
|
3064
|
+
locales
|
|
3065
|
+
}))
|
|
3066
|
+
}
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
function jwtVerifier(tokenKey = "token", secretKey = "JWT_SECRET", options = {}) {
|
|
3070
|
+
return async ({ req: { url, cookies } }, next) => {
|
|
3071
|
+
const token = cookies[tokenKey] || "", secret = process.env[secretKey] || "";
|
|
3072
|
+
let jwtPayload;
|
|
3073
|
+
try {
|
|
3074
|
+
jwtPayload = (0, jsonwebtoken.verify)(token, secret, options);
|
|
3075
|
+
} catch (error) {
|
|
3076
|
+
console.error(url, error);
|
|
3077
|
+
}
|
|
3078
|
+
const data = await next();
|
|
3079
|
+
if ("props" in data && jwtPayload) data.props["jwtPayload"] = jwtPayload;
|
|
3080
|
+
return data;
|
|
3081
|
+
};
|
|
3082
|
+
}
|
|
3083
|
+
const serverRenderCache = {};
|
|
3084
|
+
function cache(oneInterval = 30 * web_utility.Second, allInterval = web_utility.Day) {
|
|
3085
|
+
function cleanCache() {
|
|
3086
|
+
for (const [URI, { expiredAt = 0 }] of Object.entries(serverRenderCache)) if (Date.now() - expiredAt > allInterval) delete serverRenderCache[URI];
|
|
3087
|
+
}
|
|
3088
|
+
return (async (context, next) => {
|
|
3089
|
+
const { resolvedUrl, req } = context;
|
|
3090
|
+
const cache = serverRenderCache[resolvedUrl] ||= {}, noCache = req.headers["cache-control"] === "no-cache", title = `[SSR cache] ${resolvedUrl}`;
|
|
3091
|
+
const { data, expiredAt = 0 } = cache;
|
|
3092
|
+
if ((!data || expiredAt < Date.now() || noCache) && !cache.buffer) {
|
|
3093
|
+
console.time(title);
|
|
3094
|
+
cache.buffer = next().then((data) => {
|
|
3095
|
+
cache.data = data;
|
|
3096
|
+
cache.expiredAt = Date.now() + oneInterval;
|
|
3097
|
+
console.log(cache);
|
|
3098
|
+
return data;
|
|
3099
|
+
}).finally(() => {
|
|
3100
|
+
delete cache.buffer;
|
|
3101
|
+
cleanCache();
|
|
3102
|
+
console.timeEnd(title);
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
return data || cache.buffer;
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
//#endregion
|
|
3109
|
+
//#region source/utility.ts
|
|
3110
|
+
const { NODE_ENV, VERCEL_ENV = NODE_ENV, VERCEL_URL, VERCEL_PROJECT_PRODUCTION_URL } = process.env;
|
|
3111
|
+
const RemoteDomain = VERCEL_ENV === "production" ? VERCEL_PROJECT_PRODUCTION_URL : VERCEL_URL;
|
|
3112
|
+
const CurrentHost = RemoteDomain ? `https://${RemoteDomain}` : "http://localhost:3000";
|
|
3113
|
+
//#endregion
|
|
3114
|
+
//#region source/SSR/middleware/remote.ts
|
|
3115
|
+
function oauth2Signer({ signInURL, accessToken, userProfile, tokenKey = "token" }) {
|
|
3116
|
+
return async ({ req: { url, headers, cookies }, query, res }, next) => {
|
|
3117
|
+
const token = cookies[tokenKey] || query[tokenKey];
|
|
3118
|
+
const pageURL = new URL(url || "/", headers["origin"] || CurrentHost);
|
|
3119
|
+
if (query.code) {
|
|
3120
|
+
const token = await accessToken(query), { searchParams } = pageURL;
|
|
3121
|
+
try {
|
|
3122
|
+
res.setHeader("Set-Cookie", `${tokenKey}=${token}; Path=/`);
|
|
3123
|
+
} catch {
|
|
3124
|
+
searchParams.set(tokenKey, token);
|
|
3125
|
+
}
|
|
3126
|
+
searchParams.delete("code");
|
|
3127
|
+
if (searchParams.get("state") === "") searchParams.delete("state");
|
|
3128
|
+
return {
|
|
3129
|
+
redirect: {
|
|
3130
|
+
destination: pageURL + "",
|
|
3131
|
+
permanent: false
|
|
3132
|
+
},
|
|
3133
|
+
props: {}
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
if (token) {
|
|
3137
|
+
const user = await userProfile?.(token + ""), data = await next();
|
|
3138
|
+
const props = "props" in data ? {
|
|
3139
|
+
...data.props,
|
|
3140
|
+
token,
|
|
3141
|
+
user
|
|
3142
|
+
} : {};
|
|
3143
|
+
return {
|
|
3144
|
+
...data,
|
|
3145
|
+
props
|
|
3146
|
+
};
|
|
3147
|
+
}
|
|
3148
|
+
return {
|
|
3149
|
+
redirect: {
|
|
3150
|
+
destination: signInURL(pageURL + ""),
|
|
3151
|
+
permanent: false
|
|
3152
|
+
},
|
|
3153
|
+
props: {}
|
|
3154
|
+
};
|
|
3155
|
+
};
|
|
3156
|
+
}
|
|
3157
|
+
function githubOAuth2({ rootBaseURL = "https://github.com", apiBaseURL = "https://api.github.com", client_id, client_secret, scopes, allow_signup = true }) {
|
|
3158
|
+
return oauth2Signer({
|
|
3159
|
+
signInURL: (redirect_uri) => `https://github.com/login/oauth/authorize?${(0, web_utility.buildURLData)({
|
|
3160
|
+
client_id,
|
|
3161
|
+
scope: scopes?.join(" "),
|
|
3162
|
+
allow_signup,
|
|
3163
|
+
redirect_uri
|
|
3164
|
+
})}`,
|
|
3165
|
+
accessToken: async ({ code }) => {
|
|
3166
|
+
const { error, access_token } = await (await fetch(new URL("login/oauth/access_token", rootBaseURL), {
|
|
3167
|
+
method: "POST",
|
|
3168
|
+
headers: {
|
|
3169
|
+
Accept: "application/json",
|
|
3170
|
+
"Content-Type": "application/json"
|
|
3171
|
+
},
|
|
3172
|
+
body: JSON.stringify({
|
|
3173
|
+
client_id,
|
|
3174
|
+
client_secret,
|
|
3175
|
+
code
|
|
3176
|
+
})
|
|
3177
|
+
})).json();
|
|
3178
|
+
if (error) throw new URIError(error);
|
|
3179
|
+
return access_token;
|
|
3180
|
+
},
|
|
3181
|
+
userProfile: async (token) => {
|
|
3182
|
+
const response = await fetch(new URL("user", apiBaseURL), { headers: {
|
|
3183
|
+
Authorization: `Bearer ${token}`,
|
|
3184
|
+
Accept: "application/json"
|
|
3185
|
+
} });
|
|
3186
|
+
if (response.status < 300) return response.json();
|
|
3187
|
+
throw new URIError("Invalid GitHub access token");
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
|
+
}
|
|
3191
|
+
//#endregion
|
|
3192
|
+
//#region source/SSR/shim.ts
|
|
3193
|
+
/**
|
|
3194
|
+
* @see {@link https://www.propelauth.com/post/getting-url-in-next-server-components}
|
|
3195
|
+
*/
|
|
3196
|
+
function patchHeaders(request) {
|
|
3197
|
+
const resolvedUrl = request.nextUrl + "", { locale, defaultLocale = "", domainLocale } = request.nextUrl, headers = new Headers(request.headers);
|
|
3198
|
+
const locales = domainLocale?.locales?.join(",") || locale;
|
|
3199
|
+
headers.set("x-resolved-url", resolvedUrl);
|
|
3200
|
+
headers.set("x-locale", locale);
|
|
3201
|
+
headers.set("x-locales", locales);
|
|
3202
|
+
headers.set("x-default-locale", defaultLocale);
|
|
3203
|
+
return headers;
|
|
3204
|
+
}
|
|
3205
|
+
const withMiddleware = (getServerSideProps, serverComponent) => async ({ params, searchParams }) => {
|
|
3206
|
+
const { headers, cookies, draftMode } = await import("next/headers");
|
|
3207
|
+
const resolvedParams = await params, resolvedSearchParams = await searchParams, header = await headers(), cookie = await cookies(), { isEnabled } = await draftMode();
|
|
3208
|
+
const url = header.get("x-resolved-url") || "", locale = header.get("x-locale") || "", locales = header.get("x-locales")?.split(",") || [], defaultLocale = header.get("x-default-locale") || "";
|
|
3209
|
+
const result = await getServerSideProps({
|
|
3210
|
+
req: {
|
|
3211
|
+
url,
|
|
3212
|
+
headers: Object.fromEntries([...header]),
|
|
3213
|
+
cookies: Object.fromEntries(cookie.getAll().map(({ name, value }) => [name, value]))
|
|
3214
|
+
},
|
|
3215
|
+
res: {},
|
|
3216
|
+
params: resolvedParams,
|
|
3217
|
+
query: resolvedSearchParams,
|
|
3218
|
+
preview: false,
|
|
3219
|
+
previewData: {},
|
|
3220
|
+
draftMode: isEnabled,
|
|
3221
|
+
resolvedUrl: url,
|
|
3222
|
+
locale,
|
|
3223
|
+
locales,
|
|
3224
|
+
defaultLocale
|
|
3225
|
+
});
|
|
3226
|
+
if ("redirect" in result) {
|
|
3227
|
+
const { redirect, permanentRedirect } = await import("next/navigation");
|
|
3228
|
+
const isPermanent = "statusCode" in result.redirect ? result.redirect.statusCode === 308 : "permanent" in result.redirect && result.redirect.permanent;
|
|
3229
|
+
const { destination } = result.redirect;
|
|
3230
|
+
if (isPermanent) permanentRedirect(destination);
|
|
3231
|
+
else redirect(destination);
|
|
3232
|
+
}
|
|
3233
|
+
if ("props" in result) return serverComponent({
|
|
3234
|
+
params,
|
|
3235
|
+
searchParams,
|
|
3236
|
+
...await result.props
|
|
3237
|
+
});
|
|
3238
|
+
};
|
|
3239
|
+
//#endregion
|
|
3240
|
+
exports.CurrentHost = CurrentHost;
|
|
3241
|
+
exports.RemoteDomain = RemoteDomain;
|
|
3242
|
+
exports.cache = cache;
|
|
3243
|
+
exports.compose = compose;
|
|
3244
|
+
exports.createKoaRouter = createKoaRouter;
|
|
3245
|
+
exports.errorLogger = errorLogger;
|
|
3246
|
+
exports.githubOAuth2 = githubOAuth2;
|
|
3247
|
+
exports.jwtVerifier = jwtVerifier;
|
|
3248
|
+
exports.oauth2Signer = oauth2Signer;
|
|
3249
|
+
exports.pageApiRouteOf = pageApiRouteOf;
|
|
3250
|
+
exports.patchHeaders = patchHeaders;
|
|
3251
|
+
exports.router = router;
|
|
3252
|
+
exports.withKoa = withKoa;
|
|
3253
|
+
exports.withKoaRouter = withKoaRouter;
|
|
3254
|
+
exports.withMiddleware = withMiddleware;
|