quickwin 1.1.4 → 1.2.1
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/README.en.md +7 -3
- package/README.md +7 -3
- package/examples/exec_server.js +3535 -34
- package/examples/exec_server.ts +71 -26
- package/examples/exec_server_worker.js +45 -0
- package/examples/exec_server_worker.ts +39 -0
- package/examples/pdf_viewer.js +11 -10
- package/examples/setres.js +104 -0
- package/examples/setres.ts +120 -0
- package/examples/test_gallery.js +11 -10
- package/examples/test_react_lazy.js +11 -10
- package/examples/test_react_listbox.js +11 -10
- package/examples/test_root_window.js +11 -10
- package/examples/test_tab.js +11 -10
- package/lib/fetch.js +35 -7
- package/lib/fetch.ts +24 -4
- package/lib/text-measure.js +8 -6
- package/lib/text-measure.ts +8 -6
- package/main.js +46 -0
- package/package.json +2 -1
- package/quickwin.d.ts +2 -1
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/test/run.js +4 -1
- package/test/run.ts +4 -1
- package/test/test_net_fetch.js +62 -0
- package/test/test_net_fetch.ts +72 -0
- package/test/test_react_complex.js +14 -13
- package/test/test_react_counter.js +11 -10
- package/test/test_react_flex.js +11 -10
- package/test/test_react_hidden.js +13 -12
- package/test/test_react_listview_link.js +11 -10
- package/test/test_react_render.js +11 -10
- package/test/test_wolfssl_read.js +201 -0
- package/test/test_wolfssl_read.ts +181 -0
- package/test/test_worker_concurrent.js +45 -0
- package/test/test_worker_concurrent.ts +56 -0
- package/test/test_worker_data_url.js +46 -0
- package/test/test_worker_data_url.ts +51 -0
package/examples/exec_server.js
CHANGED
|
@@ -1,38 +1,3539 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
// _build/lib/polyfill.js
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
|
|
4
|
+
// _build/lib/url.js
|
|
5
|
+
function _encode(s2) {
|
|
6
|
+
return encodeURIComponent(s2);
|
|
7
|
+
}
|
|
8
|
+
function _decode(s2) {
|
|
9
|
+
try {
|
|
10
|
+
return decodeURIComponent(s2.replace(/\+/g, " "));
|
|
11
|
+
} catch {
|
|
12
|
+
return s2;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _normalizePath(path) {
|
|
16
|
+
if (!path)
|
|
17
|
+
return "/";
|
|
18
|
+
const parts = path.split("/");
|
|
19
|
+
const out = [];
|
|
20
|
+
let hasRoot = path[0] === "/";
|
|
21
|
+
if (hasRoot)
|
|
22
|
+
out.push("");
|
|
23
|
+
for (const p2 of parts) {
|
|
24
|
+
if (p2 === "" || p2 === ".")
|
|
25
|
+
continue;
|
|
26
|
+
if (p2 === "..") {
|
|
27
|
+
const last = out[out.length - 1];
|
|
28
|
+
if (last !== void 0 && last !== "")
|
|
29
|
+
out.pop();
|
|
30
|
+
} else {
|
|
31
|
+
out.push(p2);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (path.endsWith("/") && out[out.length - 1] !== "")
|
|
35
|
+
out.push("");
|
|
36
|
+
const result = out.join("/");
|
|
37
|
+
if (hasRoot && !result.startsWith("/"))
|
|
38
|
+
return "/" + result;
|
|
39
|
+
return result || "/";
|
|
40
|
+
}
|
|
41
|
+
function _parseURL(url) {
|
|
42
|
+
const r2 = { scheme: "", user: "", pass: "", host: "", port: "", path: "/", query: "", fragment: "" };
|
|
43
|
+
const fi = url.indexOf("#");
|
|
44
|
+
if (fi >= 0) {
|
|
45
|
+
r2.fragment = url.slice(fi + 1);
|
|
46
|
+
url = url.slice(0, fi);
|
|
47
|
+
}
|
|
48
|
+
const qi = url.indexOf("?");
|
|
49
|
+
if (qi >= 0) {
|
|
50
|
+
r2.query = url.slice(qi + 1);
|
|
51
|
+
url = url.slice(0, qi);
|
|
52
|
+
}
|
|
53
|
+
const sm = url.match(/^([a-zA-Z][a-zA-Z0-9+\-.]*):(.*)$/);
|
|
54
|
+
if (sm) {
|
|
55
|
+
r2.scheme = sm[1].toLowerCase();
|
|
56
|
+
url = sm[2];
|
|
57
|
+
}
|
|
58
|
+
if (url.startsWith("//")) {
|
|
59
|
+
url = url.slice(2);
|
|
60
|
+
const si = url.indexOf("/");
|
|
61
|
+
let auth;
|
|
62
|
+
if (si < 0) {
|
|
63
|
+
auth = url;
|
|
64
|
+
url = "";
|
|
65
|
+
} else {
|
|
66
|
+
auth = url.slice(0, si);
|
|
67
|
+
url = url.slice(si);
|
|
68
|
+
}
|
|
69
|
+
const ai = auth.lastIndexOf("@");
|
|
70
|
+
if (ai >= 0) {
|
|
71
|
+
const ui = auth.slice(0, ai);
|
|
72
|
+
auth = auth.slice(ai + 1);
|
|
73
|
+
const ci = ui.indexOf(":");
|
|
74
|
+
if (ci >= 0) {
|
|
75
|
+
r2.user = _decode(ui.slice(0, ci));
|
|
76
|
+
r2.pass = _decode(ui.slice(ci + 1));
|
|
77
|
+
} else
|
|
78
|
+
r2.user = _decode(ui);
|
|
79
|
+
}
|
|
80
|
+
if (auth.startsWith("[")) {
|
|
81
|
+
const cb = auth.indexOf("]");
|
|
82
|
+
r2.host = auth.slice(1, cb).toLowerCase();
|
|
83
|
+
const pp = auth.slice(cb + 1);
|
|
84
|
+
if (pp.startsWith(":"))
|
|
85
|
+
r2.port = pp.slice(1);
|
|
86
|
+
} else {
|
|
87
|
+
const ci = auth.lastIndexOf(":");
|
|
88
|
+
if (ci >= 0 && ci === auth.lastIndexOf(":")) {
|
|
89
|
+
r2.host = auth.slice(0, ci).toLowerCase();
|
|
90
|
+
r2.port = auth.slice(ci + 1);
|
|
91
|
+
} else
|
|
92
|
+
r2.host = auth.toLowerCase();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
r2.path = url;
|
|
96
|
+
if (r2.host && !r2.path.startsWith("/"))
|
|
97
|
+
r2.path = "/" + r2.path;
|
|
98
|
+
return r2;
|
|
99
|
+
}
|
|
100
|
+
var URLSearchParamsImpl = class {
|
|
101
|
+
_list = [];
|
|
102
|
+
constructor(init) {
|
|
103
|
+
if (typeof init === "string") {
|
|
104
|
+
const s2 = init.startsWith("?") ? init.slice(1) : init;
|
|
105
|
+
if (!s2)
|
|
106
|
+
return;
|
|
107
|
+
for (const p2 of s2.split("&")) {
|
|
108
|
+
const eq = p2.indexOf("=");
|
|
109
|
+
if (eq < 0) {
|
|
110
|
+
this._list.push([_decode(p2), ""]);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
this._list.push([_decode(p2.slice(0, eq)), _decode(p2.slice(eq + 1))]);
|
|
114
|
+
}
|
|
115
|
+
} else if (init) {
|
|
116
|
+
if (Array.isArray(init))
|
|
117
|
+
for (const [k2, v2] of init)
|
|
118
|
+
this._list.push([String(k2), String(v2)]);
|
|
119
|
+
else
|
|
120
|
+
for (const k2 of Object.keys(init))
|
|
121
|
+
this._list.push([k2, String(init[k2])]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
append(key, value) {
|
|
125
|
+
this._list.push([key, value]);
|
|
126
|
+
}
|
|
127
|
+
delete(key) {
|
|
128
|
+
this._list = this._list.filter(([k2]) => k2 !== key);
|
|
129
|
+
}
|
|
130
|
+
get(key) {
|
|
131
|
+
for (const [k2, v2] of this._list)
|
|
132
|
+
if (k2 === key)
|
|
133
|
+
return v2;
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
getAll(key) {
|
|
137
|
+
return this._list.filter(([k2]) => k2 === key).map(([, v2]) => v2);
|
|
138
|
+
}
|
|
139
|
+
has(key) {
|
|
140
|
+
return this._list.some(([k2]) => k2 === key);
|
|
141
|
+
}
|
|
142
|
+
set(key, value) {
|
|
143
|
+
let f2 = false;
|
|
144
|
+
for (let i2 = 0; i2 < this._list.length; i2++) {
|
|
145
|
+
if (this._list[i2][0] === key) {
|
|
146
|
+
if (!f2) {
|
|
147
|
+
this._list[i2][1] = value;
|
|
148
|
+
f2 = true;
|
|
149
|
+
} else {
|
|
150
|
+
this._list.splice(i2, 1);
|
|
151
|
+
i2--;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (!f2)
|
|
156
|
+
this._list.push([key, value]);
|
|
157
|
+
}
|
|
158
|
+
sort() {
|
|
159
|
+
this._list.sort(([a2], [b2]) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
|
|
160
|
+
}
|
|
161
|
+
forEach(fn) {
|
|
162
|
+
for (const [k2, v2] of this._list)
|
|
163
|
+
fn(v2, k2);
|
|
164
|
+
}
|
|
165
|
+
*keys() {
|
|
166
|
+
for (const [k2] of this._list)
|
|
167
|
+
yield k2;
|
|
168
|
+
}
|
|
169
|
+
*values() {
|
|
170
|
+
for (const [, v2] of this._list)
|
|
171
|
+
yield v2;
|
|
172
|
+
}
|
|
173
|
+
*entries() {
|
|
174
|
+
for (const item of this._list)
|
|
175
|
+
yield [item[0], item[1]];
|
|
176
|
+
}
|
|
177
|
+
*[Symbol.iterator]() {
|
|
178
|
+
for (const item of this._list)
|
|
179
|
+
yield item;
|
|
180
|
+
}
|
|
181
|
+
toString() {
|
|
182
|
+
return this._list.map(([k2, v2]) => _encode(k2) + "=" + _encode(v2)).join("&");
|
|
183
|
+
}
|
|
184
|
+
get size() {
|
|
185
|
+
return this._list.length;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
if (typeof globalThis.URLSearchParams === "undefined") {
|
|
189
|
+
globalThis.URLSearchParams = URLSearchParamsImpl;
|
|
190
|
+
}
|
|
191
|
+
var URLImpl = class _URLImpl {
|
|
192
|
+
_scheme = "";
|
|
193
|
+
_username = "";
|
|
194
|
+
_password = "";
|
|
195
|
+
_hostname = "";
|
|
196
|
+
_port = "";
|
|
197
|
+
_pathname = "/";
|
|
198
|
+
_query = "";
|
|
199
|
+
_fragment = "";
|
|
200
|
+
_searchParams = new URLSearchParamsImpl();
|
|
201
|
+
constructor(url, base) {
|
|
202
|
+
let p2 = _parseURL(url);
|
|
203
|
+
if (p2.scheme) {
|
|
204
|
+
this._apply(p2);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (base === void 0)
|
|
208
|
+
throw new TypeError("Invalid URL");
|
|
209
|
+
const b2 = new _URLImpl(base);
|
|
210
|
+
if (p2.host) {
|
|
211
|
+
p2.scheme = b2._scheme;
|
|
212
|
+
this._apply(p2);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (!p2.path && !p2.query) {
|
|
216
|
+
this._apply({
|
|
217
|
+
scheme: b2._scheme,
|
|
218
|
+
user: b2._username,
|
|
219
|
+
pass: b2._password,
|
|
220
|
+
host: b2._hostname,
|
|
221
|
+
port: b2._port,
|
|
222
|
+
path: b2._pathname,
|
|
223
|
+
query: b2._query,
|
|
224
|
+
fragment: p2.fragment || ""
|
|
225
|
+
});
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
p2.scheme = b2._scheme;
|
|
229
|
+
if (!p2.user)
|
|
230
|
+
p2.user = b2._username;
|
|
231
|
+
if (!p2.pass)
|
|
232
|
+
p2.pass = b2._password;
|
|
233
|
+
if (!p2.host)
|
|
234
|
+
p2.host = b2._hostname;
|
|
235
|
+
if (!p2.port)
|
|
236
|
+
p2.port = b2._port;
|
|
237
|
+
if (!p2.fragment)
|
|
238
|
+
p2.fragment = "";
|
|
239
|
+
if (p2.path && !p2.path.startsWith("/")) {
|
|
240
|
+
const bd = b2._pathname.substring(0, b2._pathname.lastIndexOf("/") + 1);
|
|
241
|
+
p2.path = _normalizePath(bd + p2.path);
|
|
242
|
+
} else if (!p2.path) {
|
|
243
|
+
p2.path = b2._pathname;
|
|
244
|
+
if (!p2.query)
|
|
245
|
+
p2.query = b2._query;
|
|
246
|
+
}
|
|
247
|
+
this._apply(p2);
|
|
248
|
+
}
|
|
249
|
+
_apply(p2) {
|
|
250
|
+
this._scheme = p2.scheme;
|
|
251
|
+
this._username = p2.user;
|
|
252
|
+
this._password = p2.pass;
|
|
253
|
+
this._hostname = p2.host;
|
|
254
|
+
this._port = p2.port;
|
|
255
|
+
this._pathname = _normalizePath(p2.path || "/");
|
|
256
|
+
this._query = p2.query;
|
|
257
|
+
this._fragment = p2.fragment;
|
|
258
|
+
this._searchParams = new URLSearchParamsImpl(this._query);
|
|
259
|
+
}
|
|
260
|
+
get href() {
|
|
261
|
+
return this.toString();
|
|
262
|
+
}
|
|
263
|
+
get protocol() {
|
|
264
|
+
return this._scheme + ":";
|
|
265
|
+
}
|
|
266
|
+
get hostname() {
|
|
267
|
+
return this._hostname;
|
|
268
|
+
}
|
|
269
|
+
get port() {
|
|
270
|
+
return this._port;
|
|
271
|
+
}
|
|
272
|
+
get pathname() {
|
|
273
|
+
return this._pathname;
|
|
274
|
+
}
|
|
275
|
+
get search() {
|
|
276
|
+
return this._query ? "?" + this._query : "";
|
|
277
|
+
}
|
|
278
|
+
get hash() {
|
|
279
|
+
return this._fragment ? "#" + this._fragment : "";
|
|
280
|
+
}
|
|
281
|
+
get host() {
|
|
282
|
+
const h2 = this._hostname;
|
|
283
|
+
const ipv6 = h2.includes(":");
|
|
284
|
+
return (ipv6 ? "[" + h2 + "]" : h2) + (this._port ? ":" + this._port : "");
|
|
285
|
+
}
|
|
286
|
+
get origin() {
|
|
287
|
+
const h2 = this._hostname;
|
|
288
|
+
const ipv6 = h2.includes(":");
|
|
289
|
+
return this._scheme + "://" + (ipv6 ? "[" + h2 + "]" : h2) + (this._port ? ":" + this._port : "");
|
|
290
|
+
}
|
|
291
|
+
get username() {
|
|
292
|
+
return this._username;
|
|
293
|
+
}
|
|
294
|
+
get password() {
|
|
295
|
+
return this._password;
|
|
296
|
+
}
|
|
297
|
+
get searchParams() {
|
|
298
|
+
return this._searchParams;
|
|
299
|
+
}
|
|
300
|
+
toString() {
|
|
301
|
+
let s2 = this._scheme + ":";
|
|
302
|
+
const special = ["http", "https", "ws", "wss", "ftp", "file"];
|
|
303
|
+
if (this._hostname || special.includes(this._scheme) && this._pathname.startsWith("/")) {
|
|
304
|
+
s2 += "//";
|
|
305
|
+
if (this._username) {
|
|
306
|
+
s2 += _encode(this._username);
|
|
307
|
+
if (this._password)
|
|
308
|
+
s2 += ":" + _encode(this._password);
|
|
309
|
+
s2 += "@";
|
|
310
|
+
}
|
|
311
|
+
s2 += this._hostname.includes(":") ? "[" + this._hostname + "]" : this._hostname;
|
|
312
|
+
if (this._port)
|
|
313
|
+
s2 += ":" + this._port;
|
|
314
|
+
}
|
|
315
|
+
s2 += this._pathname;
|
|
316
|
+
if (this._query)
|
|
317
|
+
s2 += "?" + this._query;
|
|
318
|
+
if (this._fragment)
|
|
319
|
+
s2 += "#" + this._fragment;
|
|
320
|
+
return s2;
|
|
321
|
+
}
|
|
322
|
+
toJSON() {
|
|
323
|
+
return this.toString();
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
if (typeof globalThis.URL === "undefined") {
|
|
327
|
+
globalThis.URL = URLImpl;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// _build/lib/text-codec.js
|
|
331
|
+
var _labelMap = {
|
|
332
|
+
"utf-8": "utf-8",
|
|
333
|
+
"utf8": "utf-8",
|
|
334
|
+
"unicode-1-1-utf-8": "utf-8",
|
|
335
|
+
"utf-16": "utf-16le",
|
|
336
|
+
"utf-16le": "utf-16le",
|
|
337
|
+
"utf-16be": "utf-16be"
|
|
338
|
+
};
|
|
339
|
+
function _normalizeLabel(label) {
|
|
340
|
+
if (!label)
|
|
341
|
+
return "utf-8";
|
|
342
|
+
const result = _labelMap[label.trim().toLowerCase()];
|
|
343
|
+
if (result)
|
|
344
|
+
return result;
|
|
345
|
+
throw new RangeError(`The encoding label "${label}" is not supported`);
|
|
346
|
+
}
|
|
347
|
+
function _decodeUTF8(buf, fatal) {
|
|
348
|
+
let out = "";
|
|
349
|
+
for (let i2 = 0; i2 < buf.length; ) {
|
|
350
|
+
const b2 = buf[i2++];
|
|
351
|
+
if (b2 < 128) {
|
|
352
|
+
out += String.fromCharCode(b2);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (b2 < 192) {
|
|
356
|
+
out += fatal ? (() => {
|
|
357
|
+
throw new TypeError("unexpected continuation byte");
|
|
358
|
+
})() : "\uFFFD";
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
let c2, min;
|
|
362
|
+
if (b2 < 224) {
|
|
363
|
+
if (i2 >= buf.length) {
|
|
364
|
+
out += fatal ? (() => {
|
|
365
|
+
throw new TypeError("incomplete utf-8");
|
|
366
|
+
})() : "\uFFFD";
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
const b22 = buf[i2++];
|
|
370
|
+
if ((b22 & 192) !== 128) {
|
|
371
|
+
out += "\uFFFD";
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
c2 = (b2 & 31) << 6 | b22 & 63;
|
|
375
|
+
min = 128;
|
|
376
|
+
} else if (b2 < 240) {
|
|
377
|
+
if (i2 + 1 >= buf.length) {
|
|
378
|
+
out += fatal ? (() => {
|
|
379
|
+
throw new TypeError("incomplete utf-8");
|
|
380
|
+
})() : "\uFFFD";
|
|
381
|
+
break;
|
|
382
|
+
}
|
|
383
|
+
const b22 = buf[i2++];
|
|
384
|
+
const b3 = buf[i2++];
|
|
385
|
+
if ((b22 & 192) !== 128 || (b3 & 192) !== 128) {
|
|
386
|
+
out += "\uFFFD";
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
c2 = (b2 & 15) << 12 | (b22 & 63) << 6 | b3 & 63;
|
|
390
|
+
min = 2048;
|
|
391
|
+
} else if (b2 < 248) {
|
|
392
|
+
if (i2 + 2 >= buf.length) {
|
|
393
|
+
out += fatal ? (() => {
|
|
394
|
+
throw new TypeError("incomplete utf-8");
|
|
395
|
+
})() : "\uFFFD";
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
const b22 = buf[i2++];
|
|
399
|
+
const b3 = buf[i2++];
|
|
400
|
+
const b4 = buf[i2++];
|
|
401
|
+
if ((b22 & 192) !== 128 || (b3 & 192) !== 128 || (b4 & 192) !== 128) {
|
|
402
|
+
out += "\uFFFD";
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
c2 = (b2 & 7) << 18 | (b22 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
|
|
406
|
+
min = 65536;
|
|
407
|
+
} else {
|
|
408
|
+
out += fatal ? (() => {
|
|
409
|
+
throw new TypeError("invalid utf-8 start");
|
|
410
|
+
})() : "\uFFFD";
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
if (c2 < min || c2 >= 55296 && c2 <= 57343 || c2 > 1114111) {
|
|
414
|
+
out += fatal ? (() => {
|
|
415
|
+
throw new TypeError("invalid utf-8 codepoint");
|
|
416
|
+
})() : "\uFFFD";
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (c2 <= 65535)
|
|
420
|
+
out += String.fromCharCode(c2);
|
|
421
|
+
else {
|
|
422
|
+
c2 -= 65536;
|
|
423
|
+
out += String.fromCharCode(55296 | c2 >> 10, 56320 | c2 & 1023);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return out;
|
|
427
|
+
}
|
|
428
|
+
function _decodeUTF16(buf, le2, fatal) {
|
|
429
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
430
|
+
let out = "";
|
|
431
|
+
for (let i2 = 0; i2 + 1 < buf.length; i2 += 2) {
|
|
432
|
+
let c2 = dv.getUint16(i2, le2);
|
|
433
|
+
if (c2 >= 55296 && c2 <= 56319) {
|
|
434
|
+
i2 += 2;
|
|
435
|
+
if (i2 + 1 >= buf.length) {
|
|
436
|
+
out += fatal ? (() => {
|
|
437
|
+
throw new TypeError("truncated surrogate pair");
|
|
438
|
+
})() : "\uFFFD";
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
const c22 = dv.getUint16(i2, le2);
|
|
442
|
+
if (c22 >= 56320 && c22 <= 57343) {
|
|
443
|
+
out += String.fromCharCode(c2, c22);
|
|
444
|
+
} else {
|
|
445
|
+
out += fatal ? (() => {
|
|
446
|
+
throw new TypeError("invalid surrogate pair");
|
|
447
|
+
})() : "\uFFFD";
|
|
448
|
+
i2 -= 2;
|
|
449
|
+
}
|
|
450
|
+
} else if (c2 >= 56320 && c2 <= 57343) {
|
|
451
|
+
out += fatal ? (() => {
|
|
452
|
+
throw new TypeError("unexpected trailing surrogate");
|
|
453
|
+
})() : "\uFFFD";
|
|
454
|
+
} else {
|
|
455
|
+
out += String.fromCharCode(c2);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return out;
|
|
459
|
+
}
|
|
460
|
+
var TextDecoderImpl = class {
|
|
461
|
+
_encoding;
|
|
462
|
+
_fatal;
|
|
463
|
+
_ignoreBOM;
|
|
464
|
+
constructor(label, options) {
|
|
465
|
+
this._encoding = _normalizeLabel(label);
|
|
466
|
+
this._fatal = options?.fatal ?? false;
|
|
467
|
+
this._ignoreBOM = options?.ignoreBOM ?? false;
|
|
468
|
+
}
|
|
469
|
+
get encoding() {
|
|
470
|
+
return this._encoding;
|
|
471
|
+
}
|
|
472
|
+
get fatal() {
|
|
473
|
+
return this._fatal;
|
|
474
|
+
}
|
|
475
|
+
get ignoreBOM() {
|
|
476
|
+
return this._ignoreBOM;
|
|
477
|
+
}
|
|
478
|
+
decode(buffer) {
|
|
479
|
+
if (!buffer)
|
|
480
|
+
return "";
|
|
481
|
+
const arr = buffer instanceof Uint8Array ? buffer : buffer instanceof ArrayBuffer ? new Uint8Array(buffer) : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
482
|
+
if (this._encoding === "utf-8") {
|
|
483
|
+
return _decodeUTF8(arr, this._fatal);
|
|
484
|
+
}
|
|
485
|
+
const le2 = this._encoding === "utf-16le";
|
|
16
486
|
let offset = 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
487
|
+
if (arr.length >= 2 && !this._ignoreBOM) {
|
|
488
|
+
const bomLo = le2 ? arr[0] : arr[1];
|
|
489
|
+
const bomHi = le2 ? arr[1] : arr[0];
|
|
490
|
+
const bom = bomHi << 8 | bomLo;
|
|
491
|
+
if (bom === 65279 || bom === 65534) {
|
|
492
|
+
offset = 2;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return _decodeUTF16(arr.slice(offset), le2, this._fatal);
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
var TextEncoderImpl = class {
|
|
499
|
+
_encoding;
|
|
500
|
+
constructor(label) {
|
|
501
|
+
this._encoding = _normalizeLabel(label);
|
|
502
|
+
}
|
|
503
|
+
get encoding() {
|
|
504
|
+
return this._encoding;
|
|
505
|
+
}
|
|
506
|
+
encode(input) {
|
|
507
|
+
if (!input)
|
|
508
|
+
return new Uint8Array(0);
|
|
509
|
+
if (this._encoding === "utf-8") {
|
|
510
|
+
const bytes = [];
|
|
511
|
+
for (let i2 = 0; i2 < input.length; i2++) {
|
|
512
|
+
let c2 = input.charCodeAt(i2);
|
|
513
|
+
if (c2 < 128) {
|
|
514
|
+
bytes.push(c2);
|
|
515
|
+
} else if (c2 < 2048) {
|
|
516
|
+
bytes.push(192 | c2 >> 6, 128 | c2 & 63);
|
|
517
|
+
} else if (c2 < 55296 || c2 >= 57344) {
|
|
518
|
+
bytes.push(224 | c2 >> 12, 128 | c2 >> 6 & 63, 128 | c2 & 63);
|
|
519
|
+
} else {
|
|
520
|
+
i2++;
|
|
521
|
+
const c22 = input.charCodeAt(i2);
|
|
522
|
+
c2 = 65536 + ((c2 & 1023) << 10) | c22 & 1023;
|
|
523
|
+
bytes.push(240 | c2 >> 18, 128 | c2 >> 12 & 63, 128 | c2 >> 6 & 63, 128 | c2 & 63);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return new Uint8Array(bytes);
|
|
527
|
+
}
|
|
528
|
+
const le2 = this._encoding === "utf-16le";
|
|
529
|
+
const buf = new ArrayBuffer(input.length * 2);
|
|
530
|
+
const dv = new DataView(buf);
|
|
531
|
+
for (let i2 = 0; i2 < input.length; i2++)
|
|
532
|
+
dv.setUint16(i2 * 2, input.charCodeAt(i2), le2);
|
|
533
|
+
return new Uint8Array(buf);
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
if (typeof globalThis.TextDecoder === "undefined") {
|
|
537
|
+
globalThis.TextDecoder = TextDecoderImpl;
|
|
538
|
+
}
|
|
539
|
+
if (typeof globalThis.TextEncoder === "undefined") {
|
|
540
|
+
globalThis.TextEncoder = TextEncoderImpl;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// _build/lib/polyfill.js
|
|
544
|
+
if (typeof globalThis.window === "undefined")
|
|
545
|
+
globalThis.window = globalThis;
|
|
546
|
+
if (typeof globalThis.setTimeout === "undefined") {
|
|
547
|
+
globalThis.setTimeout = ((fn, ms, ...args) => {
|
|
548
|
+
return os.setTimeout(() => fn(...args), ms ?? 0);
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
if (typeof globalThis.clearTimeout === "undefined") {
|
|
552
|
+
globalThis.clearTimeout = os.clearTimeout;
|
|
553
|
+
}
|
|
554
|
+
if (typeof console.error === "undefined") {
|
|
555
|
+
console.error = (...args) => {
|
|
556
|
+
console.log(...args);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function sha1Bytes(bytes) {
|
|
560
|
+
const len = bytes.length;
|
|
561
|
+
const ml = len * 8;
|
|
562
|
+
bytes.push(128);
|
|
563
|
+
while (bytes.length % 64 !== 56) {
|
|
564
|
+
bytes.push(0);
|
|
565
|
+
}
|
|
566
|
+
bytes.push(0);
|
|
567
|
+
bytes.push(0);
|
|
568
|
+
bytes.push(0);
|
|
569
|
+
bytes.push(0);
|
|
570
|
+
bytes.push(ml >>> 24 & 255);
|
|
571
|
+
bytes.push(ml >>> 16 & 255);
|
|
572
|
+
bytes.push(ml >>> 8 & 255);
|
|
573
|
+
bytes.push(ml & 255);
|
|
574
|
+
let h0 = 1732584193, h1 = 4023233417;
|
|
575
|
+
let h2 = 2562383102, h3 = 271733878, h4 = 3285377520;
|
|
576
|
+
const rotl = (x2, n2) => (x2 << n2 | x2 >>> 32 - n2) >>> 0;
|
|
577
|
+
for (let i2 = 0; i2 < bytes.length; i2 += 64) {
|
|
578
|
+
const w2 = [];
|
|
579
|
+
for (let t2 = 0; t2 < 16; t2++) {
|
|
580
|
+
w2[t2] = bytes[i2 + 4 * t2] << 24 | bytes[i2 + 4 * t2 + 1] << 16 | bytes[i2 + 4 * t2 + 2] << 8 | bytes[i2 + 4 * t2 + 3];
|
|
581
|
+
}
|
|
582
|
+
for (let t2 = 16; t2 < 80; t2++) {
|
|
583
|
+
w2[t2] = rotl(w2[t2 - 3] ^ w2[t2 - 8] ^ w2[t2 - 14] ^ w2[t2 - 16], 1);
|
|
584
|
+
}
|
|
585
|
+
let a2 = h0, b2 = h1, c2 = h2, d2 = h3, e2 = h4;
|
|
586
|
+
for (let t2 = 0; t2 < 80; t2++) {
|
|
587
|
+
let f2, k2;
|
|
588
|
+
if (t2 < 20) {
|
|
589
|
+
f2 = b2 & c2 | ~b2 & d2;
|
|
590
|
+
k2 = 1518500249;
|
|
591
|
+
} else if (t2 < 40) {
|
|
592
|
+
f2 = b2 ^ c2 ^ d2;
|
|
593
|
+
k2 = 1859775393;
|
|
594
|
+
} else if (t2 < 60) {
|
|
595
|
+
f2 = b2 & c2 | b2 & d2 | c2 & d2;
|
|
596
|
+
k2 = 2400959708;
|
|
597
|
+
} else {
|
|
598
|
+
f2 = b2 ^ c2 ^ d2;
|
|
599
|
+
k2 = 3395469782;
|
|
600
|
+
}
|
|
601
|
+
const temp = rotl(a2, 5) + f2 + e2 + k2 + w2[t2] >>> 0;
|
|
602
|
+
e2 = d2;
|
|
603
|
+
d2 = c2;
|
|
604
|
+
c2 = rotl(b2, 30);
|
|
605
|
+
b2 = a2;
|
|
606
|
+
a2 = temp;
|
|
607
|
+
}
|
|
608
|
+
h0 = h0 + a2 >>> 0;
|
|
609
|
+
h1 = h1 + b2 >>> 0;
|
|
610
|
+
h2 = h2 + c2 >>> 0;
|
|
611
|
+
h3 = h3 + d2 >>> 0;
|
|
612
|
+
h4 = h4 + e2 >>> 0;
|
|
613
|
+
}
|
|
614
|
+
const result = new Uint8Array(20);
|
|
615
|
+
const w32 = (off, v2) => {
|
|
616
|
+
result[off] = v2 >>> 24 & 255;
|
|
617
|
+
result[off + 1] = v2 >>> 16 & 255;
|
|
618
|
+
result[off + 2] = v2 >>> 8 & 255;
|
|
619
|
+
result[off + 3] = v2 & 255;
|
|
620
|
+
};
|
|
621
|
+
w32(0, h0);
|
|
622
|
+
w32(4, h1);
|
|
623
|
+
w32(8, h2);
|
|
624
|
+
w32(12, h3);
|
|
625
|
+
w32(16, h4);
|
|
626
|
+
return result.buffer;
|
|
627
|
+
}
|
|
628
|
+
var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
629
|
+
function b64Encode(data) {
|
|
630
|
+
let r2 = "";
|
|
631
|
+
for (let i2 = 0; i2 < data.length; i2 += 3) {
|
|
632
|
+
const b0 = data[i2], b1 = i2 + 1 < data.length ? data[i2 + 1] : 0, b2 = i2 + 2 < data.length ? data[i2 + 2] : 0;
|
|
633
|
+
r2 += B64[b0 >> 2] + B64[(b0 & 3) << 4 | b1 >> 4];
|
|
634
|
+
r2 += i2 + 1 < data.length ? B64[(b1 & 15) << 2 | b2 >> 6] : "=";
|
|
635
|
+
r2 += i2 + 2 < data.length ? B64[b2 & 63] : "=";
|
|
636
|
+
}
|
|
637
|
+
return r2;
|
|
638
|
+
}
|
|
639
|
+
function b64Decode(str) {
|
|
640
|
+
str = str.replace(/[^A-Za-z0-9+/=]/g, "");
|
|
641
|
+
const bytes = [];
|
|
642
|
+
for (let i2 = 0; i2 < str.length; i2 += 4) {
|
|
643
|
+
const c0 = B64.indexOf(str[i2]), c1 = B64.indexOf(str[i2 + 1]);
|
|
644
|
+
const c2 = B64.indexOf(str[i2 + 2]), c3 = B64.indexOf(str[i2 + 3]);
|
|
645
|
+
bytes.push(c0 << 2 | c1 >> 4);
|
|
646
|
+
if (c2 >= 0)
|
|
647
|
+
bytes.push((c1 & 15) << 4 | c2 >> 2);
|
|
648
|
+
if (c3 >= 0)
|
|
649
|
+
bytes.push((c2 & 3) << 6 | c3);
|
|
650
|
+
}
|
|
651
|
+
return new Uint8Array(bytes);
|
|
652
|
+
}
|
|
653
|
+
if (typeof globalThis.btoa === "undefined") {
|
|
654
|
+
globalThis.btoa = (data) => {
|
|
655
|
+
const bytes = new Uint8Array(data.length);
|
|
656
|
+
for (let i2 = 0; i2 < data.length; i2++)
|
|
657
|
+
bytes[i2] = data.charCodeAt(i2) & 255;
|
|
658
|
+
return b64Encode(bytes);
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
if (typeof globalThis.atob === "undefined") {
|
|
662
|
+
globalThis.atob = (data) => {
|
|
663
|
+
const bytes = b64Decode(data);
|
|
664
|
+
let r2 = "";
|
|
665
|
+
for (let i2 = 0; i2 < bytes.length; i2++)
|
|
666
|
+
r2 += String.fromCharCode(bytes[i2]);
|
|
667
|
+
return r2;
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
if (typeof globalThis.crypto === "undefined") {
|
|
671
|
+
globalThis.crypto = {
|
|
672
|
+
getRandomValues: (array) => {
|
|
673
|
+
const view = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
674
|
+
for (let i2 = 0; i2 < view.length; i2++)
|
|
675
|
+
view[i2] = Math.random() * 256 | 0;
|
|
676
|
+
return array;
|
|
677
|
+
},
|
|
678
|
+
subtle: {
|
|
679
|
+
digest: (algorithm, data) => {
|
|
680
|
+
if (algorithm.toUpperCase() !== "SHA-1")
|
|
681
|
+
return Promise.reject(new Error("Digest: " + algorithm + " not supported"));
|
|
682
|
+
const bytes = data instanceof Uint8Array ? Array.from(data) : Array.from(new Uint8Array(data));
|
|
683
|
+
return Promise.resolve(sha1Bytes(bytes));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// _build/lib/http-server.js
|
|
690
|
+
import * as sock from "sock";
|
|
691
|
+
|
|
692
|
+
// _build/lib/vendor/web-streams/ponyfill.mjs
|
|
693
|
+
function e() {
|
|
694
|
+
}
|
|
695
|
+
function t(e2) {
|
|
696
|
+
return "object" == typeof e2 && null !== e2 || "function" == typeof e2;
|
|
697
|
+
}
|
|
698
|
+
var r = e;
|
|
699
|
+
function o(e2, t2) {
|
|
700
|
+
try {
|
|
701
|
+
Object.defineProperty(e2, "name", { value: t2, configurable: true });
|
|
702
|
+
} catch (e3) {
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
var n = Promise;
|
|
706
|
+
var i = Promise.resolve.bind(n);
|
|
707
|
+
var a = Promise.prototype.then;
|
|
708
|
+
var s = Promise.reject.bind(n);
|
|
709
|
+
var l = i;
|
|
710
|
+
function u(e2) {
|
|
711
|
+
return new n(e2);
|
|
712
|
+
}
|
|
713
|
+
function c(e2) {
|
|
714
|
+
return u((t2) => t2(e2));
|
|
715
|
+
}
|
|
716
|
+
function d(e2) {
|
|
717
|
+
return s(e2);
|
|
718
|
+
}
|
|
719
|
+
function f(e2, t2, r2) {
|
|
720
|
+
return a.call(e2, t2, r2);
|
|
721
|
+
}
|
|
722
|
+
function h(e2, t2, o2) {
|
|
723
|
+
f(f(e2, t2, o2), void 0, r);
|
|
724
|
+
}
|
|
725
|
+
function b(e2, t2) {
|
|
726
|
+
h(e2, t2);
|
|
727
|
+
}
|
|
728
|
+
function _(e2, t2) {
|
|
729
|
+
h(e2, void 0, t2);
|
|
730
|
+
}
|
|
731
|
+
function m(e2, t2, r2) {
|
|
732
|
+
return f(e2, t2, r2);
|
|
733
|
+
}
|
|
734
|
+
function p(e2) {
|
|
735
|
+
f(e2, void 0, r);
|
|
736
|
+
}
|
|
737
|
+
var y = (e2) => {
|
|
738
|
+
if ("function" == typeof queueMicrotask) y = queueMicrotask;
|
|
739
|
+
else {
|
|
740
|
+
const e3 = c(void 0);
|
|
741
|
+
y = (t2) => f(e3, t2);
|
|
742
|
+
}
|
|
743
|
+
return y(e2);
|
|
744
|
+
};
|
|
745
|
+
function S(e2, t2, r2) {
|
|
746
|
+
if ("function" != typeof e2) throw new TypeError("Argument is not a function");
|
|
747
|
+
return Function.prototype.apply.call(e2, t2, r2);
|
|
748
|
+
}
|
|
749
|
+
function g(e2, t2, r2) {
|
|
750
|
+
try {
|
|
751
|
+
return c(S(e2, t2, r2));
|
|
752
|
+
} catch (e3) {
|
|
753
|
+
return d(e3);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
var v = class {
|
|
757
|
+
constructor() {
|
|
758
|
+
this._cursor = 0, this._size = 0, this._front = { _elements: [], _next: void 0 }, this._back = this._front, this._cursor = 0, this._size = 0;
|
|
759
|
+
}
|
|
760
|
+
get length() {
|
|
761
|
+
return this._size;
|
|
762
|
+
}
|
|
763
|
+
push(e2) {
|
|
764
|
+
const t2 = this._back;
|
|
765
|
+
let r2 = t2;
|
|
766
|
+
16383 === t2._elements.length && (r2 = { _elements: [], _next: void 0 }), t2._elements.push(e2), r2 !== t2 && (this._back = r2, t2._next = r2), ++this._size;
|
|
767
|
+
}
|
|
768
|
+
shift() {
|
|
769
|
+
const e2 = this._front;
|
|
770
|
+
let t2 = e2;
|
|
771
|
+
const r2 = this._cursor;
|
|
772
|
+
let o2 = r2 + 1;
|
|
773
|
+
const n2 = e2._elements, i2 = n2[r2];
|
|
774
|
+
return 16384 === o2 && (t2 = e2._next, o2 = 0), --this._size, this._cursor = o2, e2 !== t2 && (this._front = t2), n2[r2] = void 0, i2;
|
|
775
|
+
}
|
|
776
|
+
forEach(e2) {
|
|
777
|
+
let t2 = this._cursor, r2 = this._front, o2 = r2._elements;
|
|
778
|
+
for (; !(t2 === o2.length && void 0 === r2._next || t2 === o2.length && (r2 = r2._next, o2 = r2._elements, t2 = 0, 0 === o2.length)); ) e2(o2[t2]), ++t2;
|
|
779
|
+
}
|
|
780
|
+
peek() {
|
|
781
|
+
const e2 = this._front, t2 = this._cursor;
|
|
782
|
+
return e2._elements[t2];
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
var w = /* @__PURE__ */ Symbol("[[AbortSteps]]");
|
|
786
|
+
var R = /* @__PURE__ */ Symbol("[[ErrorSteps]]");
|
|
787
|
+
var T = /* @__PURE__ */ Symbol("[[CancelSteps]]");
|
|
788
|
+
var P = /* @__PURE__ */ Symbol("[[PullSteps]]");
|
|
789
|
+
var C = /* @__PURE__ */ Symbol("[[CanPullSyncSteps]]");
|
|
790
|
+
var q = /* @__PURE__ */ Symbol("[[ReleaseSteps]]");
|
|
791
|
+
function E(e2, t2) {
|
|
792
|
+
e2._ownerReadableStream = t2, t2._reader = e2, "readable" === t2._state ? j(e2) : "closed" === t2._state ? (function(e3) {
|
|
793
|
+
j(e3), z(e3);
|
|
794
|
+
})(e2) : k(e2, t2._storedError);
|
|
795
|
+
}
|
|
796
|
+
function W(e2, t2) {
|
|
797
|
+
return Mr(e2._ownerReadableStream, t2);
|
|
798
|
+
}
|
|
799
|
+
function O(e2) {
|
|
800
|
+
const t2 = e2._ownerReadableStream;
|
|
801
|
+
"readable" === t2._state ? A(e2, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : (function(e3, t3) {
|
|
802
|
+
k(e3, t3);
|
|
803
|
+
})(e2, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), t2._readableStreamController[q](), t2._reader = void 0, e2._ownerReadableStream = void 0;
|
|
804
|
+
}
|
|
805
|
+
function B(e2) {
|
|
806
|
+
return new TypeError("Cannot " + e2 + " a stream using a released reader");
|
|
807
|
+
}
|
|
808
|
+
function j(e2) {
|
|
809
|
+
e2._closedPromise = u((t2, r2) => {
|
|
810
|
+
e2._closedPromise_resolve = t2, e2._closedPromise_reject = r2;
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
function k(e2, t2) {
|
|
814
|
+
j(e2), A(e2, t2);
|
|
815
|
+
}
|
|
816
|
+
function A(e2, t2) {
|
|
817
|
+
void 0 !== e2._closedPromise_reject && (p(e2._closedPromise), e2._closedPromise_reject(t2), e2._closedPromise_resolve = void 0, e2._closedPromise_reject = void 0);
|
|
818
|
+
}
|
|
819
|
+
function z(e2) {
|
|
820
|
+
void 0 !== e2._closedPromise_resolve && (e2._closedPromise_resolve(void 0), e2._closedPromise_resolve = void 0, e2._closedPromise_reject = void 0);
|
|
821
|
+
}
|
|
822
|
+
var D = Number.isFinite || function(e2) {
|
|
823
|
+
return "number" == typeof e2 && isFinite(e2);
|
|
824
|
+
};
|
|
825
|
+
var F = Math.trunc || function(e2) {
|
|
826
|
+
return e2 < 0 ? Math.ceil(e2) : Math.floor(e2);
|
|
827
|
+
};
|
|
828
|
+
function L(e2, t2) {
|
|
829
|
+
if (void 0 !== e2 && ("object" != typeof (r2 = e2) && "function" != typeof r2)) throw new TypeError(`${t2} is not an object.`);
|
|
830
|
+
var r2;
|
|
831
|
+
}
|
|
832
|
+
function I(e2, t2) {
|
|
833
|
+
if ("function" != typeof e2) throw new TypeError(`${t2} is not a function.`);
|
|
834
|
+
}
|
|
835
|
+
function $(e2, t2) {
|
|
836
|
+
if (!/* @__PURE__ */ (function(e3) {
|
|
837
|
+
return "object" == typeof e3 && null !== e3 || "function" == typeof e3;
|
|
838
|
+
})(e2)) throw new TypeError(`${t2} is not an object.`);
|
|
839
|
+
}
|
|
840
|
+
function M(e2, t2, r2) {
|
|
841
|
+
if (void 0 === e2) throw new TypeError(`Parameter ${t2} is required in '${r2}'.`);
|
|
842
|
+
}
|
|
843
|
+
function Y(e2, t2, r2) {
|
|
844
|
+
if (void 0 === e2) throw new TypeError(`${t2} is required in '${r2}'.`);
|
|
845
|
+
}
|
|
846
|
+
function x(e2) {
|
|
847
|
+
return Number(e2);
|
|
848
|
+
}
|
|
849
|
+
function Q(e2) {
|
|
850
|
+
return 0 === e2 ? 0 : e2;
|
|
851
|
+
}
|
|
852
|
+
function N(e2, t2) {
|
|
853
|
+
const r2 = Number.MAX_SAFE_INTEGER;
|
|
854
|
+
let o2 = Number(e2);
|
|
855
|
+
if (o2 = Q(o2), !D(o2)) throw new TypeError(`${t2} is not a finite number`);
|
|
856
|
+
if (o2 = (function(e3) {
|
|
857
|
+
return Q(F(e3));
|
|
858
|
+
})(o2), o2 < 0 || o2 > r2) throw new TypeError(`${t2} is outside the accepted range of 0 to ${r2}, inclusive`);
|
|
859
|
+
return D(o2) && 0 !== o2 ? o2 : 0;
|
|
860
|
+
}
|
|
861
|
+
function H(e2, t2) {
|
|
862
|
+
if (!Ir(e2)) throw new TypeError(`${t2} is not a ReadableStream.`);
|
|
863
|
+
}
|
|
864
|
+
function V(e2) {
|
|
865
|
+
return new ReadableStreamDefaultReader(e2);
|
|
866
|
+
}
|
|
867
|
+
function U(e2, t2) {
|
|
868
|
+
e2._reader._readRequests.push(t2);
|
|
869
|
+
}
|
|
870
|
+
function G(e2, t2, r2) {
|
|
871
|
+
const o2 = e2._reader._readRequests.shift();
|
|
872
|
+
r2 ? o2._closeSteps() : o2._chunkSteps(t2);
|
|
873
|
+
}
|
|
874
|
+
function X(e2) {
|
|
875
|
+
return e2._reader._readRequests.length;
|
|
876
|
+
}
|
|
877
|
+
function J(e2) {
|
|
878
|
+
const t2 = e2._reader;
|
|
879
|
+
return void 0 !== t2 && !!ee(t2);
|
|
880
|
+
}
|
|
881
|
+
var ReadableStreamDefaultReader = class {
|
|
882
|
+
constructor(e2) {
|
|
883
|
+
if (M(e2, 1, "ReadableStreamDefaultReader"), H(e2, "First parameter"), $r(e2)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
884
|
+
E(this, e2), this._readRequests = new v();
|
|
885
|
+
}
|
|
886
|
+
get closed() {
|
|
887
|
+
return ee(this) ? this._closedPromise : d(ne("closed"));
|
|
888
|
+
}
|
|
889
|
+
cancel(e2 = void 0) {
|
|
890
|
+
return ee(this) ? void 0 === this._ownerReadableStream ? d(B("cancel")) : W(this, e2) : d(ne("cancel"));
|
|
891
|
+
}
|
|
892
|
+
read() {
|
|
893
|
+
if (!ee(this)) return d(ne("read"));
|
|
894
|
+
if (void 0 === this._ownerReadableStream) return d(B("read from"));
|
|
895
|
+
const e2 = re(this) ? new Z() : new K();
|
|
896
|
+
return te(this, e2), e2._promise;
|
|
897
|
+
}
|
|
898
|
+
releaseLock() {
|
|
899
|
+
if (!ee(this)) throw ne("releaseLock");
|
|
900
|
+
void 0 !== this._ownerReadableStream && (function(e2) {
|
|
901
|
+
O(e2);
|
|
902
|
+
const t2 = new TypeError("Reader was released");
|
|
903
|
+
oe(e2, t2);
|
|
904
|
+
})(this);
|
|
905
|
+
}
|
|
906
|
+
};
|
|
907
|
+
Object.defineProperties(ReadableStreamDefaultReader.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }), 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, { value: "ReadableStreamDefaultReader", configurable: true });
|
|
908
|
+
var K = class {
|
|
909
|
+
constructor() {
|
|
910
|
+
this._promise = u((e2, t2) => {
|
|
911
|
+
this._resolvePromise = e2, this._rejectPromise = t2;
|
|
912
|
+
});
|
|
913
|
+
}
|
|
914
|
+
_chunkSteps(e2) {
|
|
915
|
+
this._resolvePromise({ value: e2, done: false });
|
|
916
|
+
}
|
|
917
|
+
_closeSteps() {
|
|
918
|
+
this._resolvePromise({ value: void 0, done: true });
|
|
919
|
+
}
|
|
920
|
+
_errorSteps(e2) {
|
|
921
|
+
this._rejectPromise(e2);
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
var Z = class {
|
|
925
|
+
constructor() {
|
|
926
|
+
this._promise = void 0;
|
|
927
|
+
}
|
|
928
|
+
_chunkSteps(e2) {
|
|
929
|
+
this._promise = l({ value: e2, done: false });
|
|
930
|
+
}
|
|
931
|
+
_closeSteps() {
|
|
932
|
+
this._promise = l({ value: void 0, done: true });
|
|
933
|
+
}
|
|
934
|
+
_errorSteps(e2) {
|
|
935
|
+
this._promise = d(e2);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
function ee(e2) {
|
|
939
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_readRequests") && e2 instanceof ReadableStreamDefaultReader);
|
|
940
|
+
}
|
|
941
|
+
function te(e2, t2) {
|
|
942
|
+
const r2 = e2._ownerReadableStream;
|
|
943
|
+
r2._disturbed = true, "closed" === r2._state ? t2._closeSteps() : "errored" === r2._state ? t2._errorSteps(r2._storedError) : r2._readableStreamController[P](t2);
|
|
944
|
+
}
|
|
945
|
+
function re(e2) {
|
|
946
|
+
const t2 = e2._ownerReadableStream;
|
|
947
|
+
return "closed" === t2._state || ("errored" === t2._state || t2._readableStreamController[C]());
|
|
948
|
+
}
|
|
949
|
+
function oe(e2, t2) {
|
|
950
|
+
const r2 = e2._readRequests;
|
|
951
|
+
e2._readRequests = new v(), r2.forEach((e3) => {
|
|
952
|
+
e3._errorSteps(t2);
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
function ne(e2) {
|
|
956
|
+
return new TypeError(`ReadableStreamDefaultReader.prototype.${e2} can only be used on a ReadableStreamDefaultReader`);
|
|
957
|
+
}
|
|
958
|
+
var ie;
|
|
959
|
+
var ae;
|
|
960
|
+
var se;
|
|
961
|
+
function le(e2) {
|
|
962
|
+
return e2.slice();
|
|
963
|
+
}
|
|
964
|
+
function ue(e2, t2, r2, o2, n2) {
|
|
965
|
+
new Uint8Array(e2).set(new Uint8Array(r2, o2, n2), t2);
|
|
966
|
+
}
|
|
967
|
+
var ce = (e2) => (ce = "function" == typeof e2.transfer ? (e3) => e3.transfer() : "function" == typeof structuredClone ? (e3) => structuredClone(e3, { transfer: [e3] }) : (e3) => e3, ce(e2));
|
|
968
|
+
var de = (e2) => (de = "boolean" == typeof e2.detached ? (e3) => e3.detached : (e3) => 0 === e3.byteLength, de(e2));
|
|
969
|
+
function fe(e2, t2, r2) {
|
|
970
|
+
if (e2.slice) return e2.slice(t2, r2);
|
|
971
|
+
const o2 = r2 - t2, n2 = new ArrayBuffer(o2);
|
|
972
|
+
return ue(n2, 0, e2, t2, o2), n2;
|
|
973
|
+
}
|
|
974
|
+
function he(e2, t2) {
|
|
975
|
+
const r2 = e2[t2];
|
|
976
|
+
if (null != r2) {
|
|
977
|
+
if ("function" != typeof r2) throw new TypeError(`${String(t2)} is not a function`);
|
|
978
|
+
return r2;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
function be(e2) {
|
|
982
|
+
try {
|
|
983
|
+
const t2 = e2.done, r2 = e2.value;
|
|
984
|
+
return f(l(r2), (e3) => ({ done: t2, value: e3 }));
|
|
985
|
+
} catch (e3) {
|
|
986
|
+
return d(e3);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
var _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";
|
|
990
|
+
function me(e2, r2 = "sync", o2) {
|
|
991
|
+
if (void 0 === o2) if ("async" === r2) {
|
|
992
|
+
if (void 0 === (o2 = he(e2, _e))) {
|
|
993
|
+
return (function(e3) {
|
|
994
|
+
const r3 = { next() {
|
|
995
|
+
let t2;
|
|
996
|
+
try {
|
|
997
|
+
t2 = pe(e3);
|
|
998
|
+
} catch (e4) {
|
|
999
|
+
return d(e4);
|
|
1000
|
+
}
|
|
1001
|
+
return be(t2);
|
|
1002
|
+
}, return(r4) {
|
|
1003
|
+
let o3;
|
|
1004
|
+
try {
|
|
1005
|
+
const t2 = he(e3.iterator, "return");
|
|
1006
|
+
if (void 0 === t2) return c({ done: true, value: r4 });
|
|
1007
|
+
o3 = S(t2, e3.iterator, [r4]);
|
|
1008
|
+
} catch (e4) {
|
|
1009
|
+
return d(e4);
|
|
1010
|
+
}
|
|
1011
|
+
return t(o3) ? be(o3) : d(new TypeError("The iterator.return() method must return an object"));
|
|
1012
|
+
} };
|
|
1013
|
+
return { iterator: r3, nextMethod: r3.next, done: false };
|
|
1014
|
+
})(me(e2, "sync", he(e2, Symbol.iterator)));
|
|
1015
|
+
}
|
|
1016
|
+
} else o2 = he(e2, Symbol.iterator);
|
|
1017
|
+
if (void 0 === o2) throw new TypeError("The object is not iterable");
|
|
1018
|
+
const n2 = S(o2, e2, []);
|
|
1019
|
+
if (!t(n2)) throw new TypeError("The iterator method must return an object");
|
|
1020
|
+
return { iterator: n2, nextMethod: n2.next, done: false };
|
|
1021
|
+
}
|
|
1022
|
+
function pe(e2) {
|
|
1023
|
+
const r2 = S(e2.nextMethod, e2.iterator, []);
|
|
1024
|
+
if (!t(r2)) throw new TypeError("The iterator.next() method must return an object");
|
|
1025
|
+
return r2;
|
|
1026
|
+
}
|
|
1027
|
+
var ye = class {
|
|
1028
|
+
constructor(e2, t2) {
|
|
1029
|
+
this._ongoingPromise = void 0, this._isFinished = false, this._reader = e2, this._preventCancel = t2;
|
|
1030
|
+
}
|
|
1031
|
+
next() {
|
|
1032
|
+
const e2 = () => this._nextSteps();
|
|
1033
|
+
return this._ongoingPromise = this._ongoingPromise ? m(this._ongoingPromise, e2, e2) : e2(), this._ongoingPromise;
|
|
1034
|
+
}
|
|
1035
|
+
return(e2) {
|
|
1036
|
+
const t2 = () => this._returnSteps(e2);
|
|
1037
|
+
return this._ongoingPromise = this._ongoingPromise ? m(this._ongoingPromise, t2, t2) : t2(), this._ongoingPromise;
|
|
1038
|
+
}
|
|
1039
|
+
_nextSteps() {
|
|
1040
|
+
if (this._isFinished) return Promise.resolve({ value: void 0, done: true });
|
|
1041
|
+
const e2 = this._reader, t2 = new Se(this);
|
|
1042
|
+
return te(e2, t2), t2._promise;
|
|
1043
|
+
}
|
|
1044
|
+
_returnSteps(e2) {
|
|
1045
|
+
if (this._isFinished) return Promise.resolve({ value: e2, done: true });
|
|
1046
|
+
this._isFinished = true;
|
|
1047
|
+
const t2 = this._reader;
|
|
1048
|
+
if (!this._preventCancel) {
|
|
1049
|
+
const r2 = W(t2, e2);
|
|
1050
|
+
return O(t2), m(r2, () => ({ value: e2, done: true }));
|
|
1051
|
+
}
|
|
1052
|
+
return O(t2), c({ value: e2, done: true });
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
var Se = class {
|
|
1056
|
+
constructor(e2) {
|
|
1057
|
+
this._iterator = e2, this._promise = u((e3, t2) => {
|
|
1058
|
+
this._resolvePromise = e3, this._rejectPromise = t2;
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
_chunkSteps(e2) {
|
|
1062
|
+
this._iterator._ongoingPromise = void 0, y(() => this._resolvePromise({ value: e2, done: false }));
|
|
1063
|
+
}
|
|
1064
|
+
_closeSteps() {
|
|
1065
|
+
const e2 = this._iterator;
|
|
1066
|
+
e2._ongoingPromise = void 0, e2._isFinished = true, O(e2._reader), this._resolvePromise({ value: void 0, done: true });
|
|
1067
|
+
}
|
|
1068
|
+
_errorSteps(e2) {
|
|
1069
|
+
const t2 = this._iterator;
|
|
1070
|
+
t2._ongoingPromise = void 0, t2._isFinished = true, O(t2._reader), this._rejectPromise(e2);
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
var ge = { next() {
|
|
1074
|
+
return ve(this) ? this._asyncIteratorImpl.next() : d(we("next"));
|
|
1075
|
+
}, return(e2) {
|
|
1076
|
+
return ve(this) ? this._asyncIteratorImpl.return(e2) : d(we("return"));
|
|
1077
|
+
}, [_e]() {
|
|
1078
|
+
return this;
|
|
1079
|
+
} };
|
|
1080
|
+
function ve(e2) {
|
|
1081
|
+
if (!t(e2)) return false;
|
|
1082
|
+
if (!Object.prototype.hasOwnProperty.call(e2, "_asyncIteratorImpl")) return false;
|
|
1083
|
+
try {
|
|
1084
|
+
return e2._asyncIteratorImpl instanceof ye;
|
|
1085
|
+
} catch (e3) {
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
function we(e2) {
|
|
1090
|
+
return new TypeError(`ReadableStreamAsyncIterator.${e2} can only be used on a ReadableSteamAsyncIterator`);
|
|
1091
|
+
}
|
|
1092
|
+
Object.defineProperty(ge, _e, { enumerable: false });
|
|
1093
|
+
var Re = Number.isNaN || function(e2) {
|
|
1094
|
+
return e2 != e2;
|
|
1095
|
+
};
|
|
1096
|
+
function Te(e2) {
|
|
1097
|
+
const t2 = fe(e2.buffer, e2.byteOffset, e2.byteOffset + e2.byteLength);
|
|
1098
|
+
return new Uint8Array(t2);
|
|
1099
|
+
}
|
|
1100
|
+
function Pe(e2) {
|
|
1101
|
+
const t2 = e2._queue.shift();
|
|
1102
|
+
return e2._queueTotalSize -= t2.size, e2._queueTotalSize < 0 && (e2._queueTotalSize = 0), t2.value;
|
|
1103
|
+
}
|
|
1104
|
+
function Ce(e2, t2, r2) {
|
|
1105
|
+
if ("number" != typeof (o2 = r2) || Re(o2) || o2 < 0 || r2 === 1 / 0) throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
|
|
1106
|
+
var o2;
|
|
1107
|
+
e2._queue.push({ value: t2, size: r2 }), e2._queueTotalSize += r2;
|
|
1108
|
+
}
|
|
1109
|
+
function qe(e2) {
|
|
1110
|
+
e2._queue = new v(), e2._queueTotalSize = 0;
|
|
1111
|
+
}
|
|
1112
|
+
function Ee(e2) {
|
|
1113
|
+
return e2 === DataView;
|
|
1114
|
+
}
|
|
1115
|
+
function We(e2) {
|
|
1116
|
+
return Ee(e2) ? 1 : e2.BYTES_PER_ELEMENT;
|
|
1117
|
+
}
|
|
1118
|
+
var ReadableStreamBYOBRequest = class {
|
|
1119
|
+
constructor() {
|
|
1120
|
+
throw new TypeError("Illegal constructor");
|
|
1121
|
+
}
|
|
1122
|
+
get view() {
|
|
1123
|
+
if (!Be(this)) throw ot("view");
|
|
1124
|
+
return this._view;
|
|
1125
|
+
}
|
|
1126
|
+
respond(e2) {
|
|
1127
|
+
if (!Be(this)) throw ot("respond");
|
|
1128
|
+
if (M(e2, 1, "respond"), e2 = N(e2, "First parameter"), void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
|
|
1129
|
+
if (de(this._view.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
|
|
1130
|
+
et(this._associatedReadableByteStreamController, e2);
|
|
1131
|
+
}
|
|
1132
|
+
respondWithNewView(e2) {
|
|
1133
|
+
if (!Be(this)) throw ot("respondWithNewView");
|
|
1134
|
+
if (M(e2, 1, "respondWithNewView"), !ArrayBuffer.isView(e2)) throw new TypeError("You can only respond with array buffer views");
|
|
1135
|
+
if (void 0 === this._associatedReadableByteStreamController) throw new TypeError("This BYOB request has been invalidated");
|
|
1136
|
+
if (de(e2.buffer)) throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
|
|
1137
|
+
tt(this._associatedReadableByteStreamController, e2);
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
Object.defineProperties(ReadableStreamBYOBRequest.prototype, { respond: { enumerable: true }, respondWithNewView: { enumerable: true }, view: { enumerable: true } }), o(ReadableStreamBYOBRequest.prototype.respond, "respond"), o(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, { value: "ReadableStreamBYOBRequest", configurable: true });
|
|
1141
|
+
var ReadableByteStreamController = class {
|
|
1142
|
+
constructor() {
|
|
1143
|
+
throw new TypeError("Illegal constructor");
|
|
1144
|
+
}
|
|
1145
|
+
get byobRequest() {
|
|
1146
|
+
if (!Oe(this)) throw nt("byobRequest");
|
|
1147
|
+
return Ke(this);
|
|
1148
|
+
}
|
|
1149
|
+
get desiredSize() {
|
|
1150
|
+
if (!Oe(this)) throw nt("desiredSize");
|
|
1151
|
+
return Ze(this);
|
|
1152
|
+
}
|
|
1153
|
+
close() {
|
|
1154
|
+
if (!Oe(this)) throw nt("close");
|
|
1155
|
+
if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!");
|
|
1156
|
+
const e2 = this._controlledReadableByteStream._state;
|
|
1157
|
+
if ("readable" !== e2) throw new TypeError(`The stream (in ${e2} state) is not in the readable state and cannot be closed`);
|
|
1158
|
+
Ue(this);
|
|
1159
|
+
}
|
|
1160
|
+
enqueue(e2) {
|
|
1161
|
+
if (!Oe(this)) throw nt("enqueue");
|
|
1162
|
+
if (M(e2, 1, "enqueue"), !ArrayBuffer.isView(e2)) throw new TypeError("chunk must be an array buffer view");
|
|
1163
|
+
if (0 === e2.byteLength) throw new TypeError("chunk must have non-zero byteLength");
|
|
1164
|
+
if (0 === e2.buffer.byteLength) throw new TypeError("chunk's buffer must have non-zero byteLength");
|
|
1165
|
+
if (this._closeRequested) throw new TypeError("stream is closed or draining");
|
|
1166
|
+
const t2 = this._controlledReadableByteStream._state;
|
|
1167
|
+
if ("readable" !== t2) throw new TypeError(`The stream (in ${t2} state) is not in the readable state and cannot be enqueued to`);
|
|
1168
|
+
Ge(this, e2);
|
|
1169
|
+
}
|
|
1170
|
+
error(e2 = void 0) {
|
|
1171
|
+
if (!Oe(this)) throw nt("error");
|
|
1172
|
+
Xe(this, e2);
|
|
1173
|
+
}
|
|
1174
|
+
[T](e2) {
|
|
1175
|
+
ke(this), qe(this);
|
|
1176
|
+
const t2 = this._cancelAlgorithm(e2);
|
|
1177
|
+
return Ve(this), t2;
|
|
1178
|
+
}
|
|
1179
|
+
[P](e2) {
|
|
1180
|
+
const t2 = this._controlledReadableByteStream;
|
|
1181
|
+
if (this._queueTotalSize > 0) return void Je(this, e2);
|
|
1182
|
+
const r2 = this._autoAllocateChunkSize;
|
|
1183
|
+
if (void 0 !== r2) {
|
|
1184
|
+
let t3;
|
|
1185
|
+
try {
|
|
1186
|
+
t3 = new ArrayBuffer(r2);
|
|
1187
|
+
} catch (t4) {
|
|
1188
|
+
return void e2._errorSteps(t4);
|
|
1189
|
+
}
|
|
1190
|
+
const o2 = { buffer: t3, bufferByteLength: r2, byteOffset: 0, byteLength: r2, bytesFilled: 0, minimumFill: 1, elementSize: 1, viewConstructor: Uint8Array, readerType: "default" };
|
|
1191
|
+
this._pendingPullIntos.push(o2);
|
|
1192
|
+
}
|
|
1193
|
+
U(t2, e2), je(this);
|
|
1194
|
+
}
|
|
1195
|
+
[C]() {
|
|
1196
|
+
return this._queueTotalSize > 0;
|
|
1197
|
+
}
|
|
1198
|
+
[q]() {
|
|
1199
|
+
if (this._pendingPullIntos.length > 0) {
|
|
1200
|
+
const e2 = this._pendingPullIntos.peek();
|
|
1201
|
+
e2.readerType = "none", this._pendingPullIntos = new v(), this._pendingPullIntos.push(e2);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
};
|
|
1205
|
+
function Oe(e2) {
|
|
1206
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_controlledReadableByteStream") && e2 instanceof ReadableByteStreamController);
|
|
1207
|
+
}
|
|
1208
|
+
function Be(e2) {
|
|
1209
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_associatedReadableByteStreamController") && e2 instanceof ReadableStreamBYOBRequest);
|
|
1210
|
+
}
|
|
1211
|
+
function je(e2) {
|
|
1212
|
+
const t2 = (function(e3) {
|
|
1213
|
+
const t3 = e3._controlledReadableByteStream;
|
|
1214
|
+
if ("readable" !== t3._state) return false;
|
|
1215
|
+
if (e3._closeRequested) return false;
|
|
1216
|
+
if (!e3._started) return false;
|
|
1217
|
+
if (J(t3) && X(t3) > 0) return true;
|
|
1218
|
+
if (ut(t3) && lt(t3) > 0) return true;
|
|
1219
|
+
const r2 = Ze(e3);
|
|
1220
|
+
if (r2 > 0) return true;
|
|
1221
|
+
return false;
|
|
1222
|
+
})(e2);
|
|
1223
|
+
if (!t2) return;
|
|
1224
|
+
if (e2._pulling) return void (e2._pullAgain = true);
|
|
1225
|
+
e2._pulling = true;
|
|
1226
|
+
h(e2._pullAlgorithm(), () => (e2._pulling = false, e2._pullAgain && (e2._pullAgain = false, je(e2)), null), (t3) => (Xe(e2, t3), null));
|
|
1227
|
+
}
|
|
1228
|
+
function ke(e2) {
|
|
1229
|
+
xe(e2), e2._pendingPullIntos = new v();
|
|
1230
|
+
}
|
|
1231
|
+
function Ae(e2, t2) {
|
|
1232
|
+
let r2 = false;
|
|
1233
|
+
"closed" === e2._state && (r2 = true);
|
|
1234
|
+
const o2 = De(t2);
|
|
1235
|
+
"default" === t2.readerType ? G(e2, o2, r2) : (function(e3, t3, r3) {
|
|
1236
|
+
const o3 = e3._reader, n2 = o3._readIntoRequests.shift();
|
|
1237
|
+
r3 ? n2._closeSteps(t3) : n2._chunkSteps(t3);
|
|
1238
|
+
})(e2, o2, r2);
|
|
1239
|
+
}
|
|
1240
|
+
function ze(e2, t2) {
|
|
1241
|
+
for (let r2 = 0; r2 < t2.length; ++r2) Ae(e2, t2[r2]);
|
|
1242
|
+
}
|
|
1243
|
+
function De(e2) {
|
|
1244
|
+
const t2 = e2.bytesFilled, r2 = e2.elementSize;
|
|
1245
|
+
return new e2.viewConstructor(e2.buffer, e2.byteOffset, t2 / r2);
|
|
1246
|
+
}
|
|
1247
|
+
function Fe(e2, t2, r2, o2) {
|
|
1248
|
+
e2._queue.push({ buffer: t2, byteOffset: r2, byteLength: o2 }), e2._queueTotalSize += o2;
|
|
1249
|
+
}
|
|
1250
|
+
function Le(e2, t2, r2, o2) {
|
|
1251
|
+
let n2;
|
|
1252
|
+
try {
|
|
1253
|
+
n2 = fe(t2, r2, r2 + o2);
|
|
1254
|
+
} catch (t3) {
|
|
1255
|
+
throw Xe(e2, t3), t3;
|
|
1256
|
+
}
|
|
1257
|
+
Fe(e2, n2, 0, o2);
|
|
1258
|
+
}
|
|
1259
|
+
function Ie(e2, t2) {
|
|
1260
|
+
t2.bytesFilled > 0 && Le(e2, t2.buffer, t2.byteOffset, t2.bytesFilled), He(e2);
|
|
1261
|
+
}
|
|
1262
|
+
function $e(e2, t2) {
|
|
1263
|
+
const r2 = Math.min(e2._queueTotalSize, t2.byteLength - t2.bytesFilled), o2 = t2.bytesFilled + r2;
|
|
1264
|
+
let n2 = r2, i2 = false;
|
|
1265
|
+
const a2 = o2 - o2 % t2.elementSize;
|
|
1266
|
+
a2 >= t2.minimumFill && (n2 = a2 - t2.bytesFilled, i2 = true);
|
|
1267
|
+
const s2 = e2._queue;
|
|
1268
|
+
for (; n2 > 0; ) {
|
|
1269
|
+
const r3 = s2.peek(), o3 = Math.min(n2, r3.byteLength), i3 = t2.byteOffset + t2.bytesFilled;
|
|
1270
|
+
ue(t2.buffer, i3, r3.buffer, r3.byteOffset, o3), r3.byteLength === o3 ? s2.shift() : (r3.byteOffset += o3, r3.byteLength -= o3), e2._queueTotalSize -= o3, Me(e2, o3, t2), n2 -= o3;
|
|
1271
|
+
}
|
|
1272
|
+
return i2;
|
|
1273
|
+
}
|
|
1274
|
+
function Me(e2, t2, r2) {
|
|
1275
|
+
r2.bytesFilled += t2;
|
|
1276
|
+
}
|
|
1277
|
+
function Ye(e2) {
|
|
1278
|
+
0 === e2._queueTotalSize && e2._closeRequested ? (Ve(e2), Yr(e2._controlledReadableByteStream)) : je(e2);
|
|
1279
|
+
}
|
|
1280
|
+
function xe(e2) {
|
|
1281
|
+
null !== e2._byobRequest && (e2._byobRequest._associatedReadableByteStreamController = void 0, e2._byobRequest._view = null, e2._byobRequest = null);
|
|
1282
|
+
}
|
|
1283
|
+
function Qe(e2) {
|
|
1284
|
+
const t2 = [];
|
|
1285
|
+
for (; e2._pendingPullIntos.length > 0 && 0 !== e2._queueTotalSize; ) {
|
|
1286
|
+
const r2 = e2._pendingPullIntos.peek();
|
|
1287
|
+
$e(e2, r2) && (He(e2), t2.push(r2));
|
|
1288
|
+
}
|
|
1289
|
+
return t2;
|
|
1290
|
+
}
|
|
1291
|
+
function Ne(e2, t2) {
|
|
1292
|
+
const r2 = e2._pendingPullIntos.peek();
|
|
1293
|
+
xe(e2);
|
|
1294
|
+
"closed" === e2._controlledReadableByteStream._state ? (function(e3, t3) {
|
|
1295
|
+
"none" === t3.readerType && He(e3);
|
|
1296
|
+
const r3 = e3._controlledReadableByteStream;
|
|
1297
|
+
if (ut(r3)) {
|
|
1298
|
+
const t4 = [];
|
|
1299
|
+
for (; t4.length < lt(r3); ) t4.push(He(e3));
|
|
1300
|
+
ze(r3, t4);
|
|
1301
|
+
}
|
|
1302
|
+
})(e2, r2) : (function(e3, t3, r3) {
|
|
1303
|
+
if (Me(0, t3, r3), "none" === r3.readerType) {
|
|
1304
|
+
Ie(e3, r3);
|
|
1305
|
+
const t4 = Qe(e3);
|
|
1306
|
+
return void ze(e3._controlledReadableByteStream, t4);
|
|
1307
|
+
}
|
|
1308
|
+
if (r3.bytesFilled < r3.minimumFill) return;
|
|
1309
|
+
He(e3);
|
|
1310
|
+
const o2 = r3.bytesFilled % r3.elementSize;
|
|
1311
|
+
if (o2 > 0) {
|
|
1312
|
+
const t4 = r3.byteOffset + r3.bytesFilled;
|
|
1313
|
+
Le(e3, r3.buffer, t4 - o2, o2);
|
|
1314
|
+
}
|
|
1315
|
+
r3.bytesFilled -= o2;
|
|
1316
|
+
const n2 = Qe(e3);
|
|
1317
|
+
Ae(e3._controlledReadableByteStream, r3), ze(e3._controlledReadableByteStream, n2);
|
|
1318
|
+
})(e2, t2, r2), je(e2);
|
|
1319
|
+
}
|
|
1320
|
+
function He(e2) {
|
|
1321
|
+
return e2._pendingPullIntos.shift();
|
|
1322
|
+
}
|
|
1323
|
+
function Ve(e2) {
|
|
1324
|
+
e2._pullAlgorithm = void 0, e2._cancelAlgorithm = void 0;
|
|
1325
|
+
}
|
|
1326
|
+
function Ue(e2) {
|
|
1327
|
+
const t2 = e2._controlledReadableByteStream;
|
|
1328
|
+
if (!e2._closeRequested && "readable" === t2._state) if (e2._queueTotalSize > 0) e2._closeRequested = true;
|
|
1329
|
+
else {
|
|
1330
|
+
if (e2._pendingPullIntos.length > 0) {
|
|
1331
|
+
const t3 = e2._pendingPullIntos.peek();
|
|
1332
|
+
if (t3.bytesFilled % t3.elementSize !== 0) {
|
|
1333
|
+
const t4 = new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
1334
|
+
throw Xe(e2, t4), t4;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
Ve(e2), Yr(t2);
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
function Ge(e2, t2) {
|
|
1341
|
+
const r2 = e2._controlledReadableByteStream;
|
|
1342
|
+
if (e2._closeRequested || "readable" !== r2._state) return;
|
|
1343
|
+
const { buffer: o2, byteOffset: n2, byteLength: i2 } = t2;
|
|
1344
|
+
if (de(o2)) throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
|
|
1345
|
+
const a2 = ce(o2);
|
|
1346
|
+
if (e2._pendingPullIntos.length > 0) {
|
|
1347
|
+
const t3 = e2._pendingPullIntos.peek();
|
|
1348
|
+
if (de(t3.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
|
|
1349
|
+
xe(e2), t3.buffer = ce(t3.buffer), "none" === t3.readerType && Ie(e2, t3);
|
|
1350
|
+
}
|
|
1351
|
+
if (J(r2)) if ((function(e3) {
|
|
1352
|
+
const t3 = e3._controlledReadableByteStream._reader;
|
|
1353
|
+
for (; t3._readRequests.length > 0; ) {
|
|
1354
|
+
if (0 === e3._queueTotalSize) return;
|
|
1355
|
+
Je(e3, t3._readRequests.shift());
|
|
1356
|
+
}
|
|
1357
|
+
})(e2), 0 === X(r2)) Fe(e2, a2, n2, i2);
|
|
1358
|
+
else {
|
|
1359
|
+
e2._pendingPullIntos.length > 0 && He(e2);
|
|
1360
|
+
G(r2, new Uint8Array(a2, n2, i2), false);
|
|
1361
|
+
}
|
|
1362
|
+
else if (ut(r2)) {
|
|
1363
|
+
Fe(e2, a2, n2, i2);
|
|
1364
|
+
ze(r2, Qe(e2));
|
|
1365
|
+
} else Fe(e2, a2, n2, i2);
|
|
1366
|
+
je(e2);
|
|
1367
|
+
}
|
|
1368
|
+
function Xe(e2, t2) {
|
|
1369
|
+
const r2 = e2._controlledReadableByteStream;
|
|
1370
|
+
"readable" === r2._state && (ke(e2), qe(e2), Ve(e2), xr(r2, t2));
|
|
1371
|
+
}
|
|
1372
|
+
function Je(e2, t2) {
|
|
1373
|
+
const r2 = e2._queue.shift();
|
|
1374
|
+
e2._queueTotalSize -= r2.byteLength, Ye(e2);
|
|
1375
|
+
const o2 = new Uint8Array(r2.buffer, r2.byteOffset, r2.byteLength);
|
|
1376
|
+
t2._chunkSteps(o2);
|
|
1377
|
+
}
|
|
1378
|
+
function Ke(e2) {
|
|
1379
|
+
if (null === e2._byobRequest && e2._pendingPullIntos.length > 0) {
|
|
1380
|
+
const t2 = e2._pendingPullIntos.peek(), r2 = new Uint8Array(t2.buffer, t2.byteOffset + t2.bytesFilled, t2.byteLength - t2.bytesFilled), o2 = Object.create(ReadableStreamBYOBRequest.prototype);
|
|
1381
|
+
!(function(e3, t3, r3) {
|
|
1382
|
+
e3._associatedReadableByteStreamController = t3, e3._view = r3;
|
|
1383
|
+
})(o2, e2, r2), e2._byobRequest = o2;
|
|
1384
|
+
}
|
|
1385
|
+
return e2._byobRequest;
|
|
1386
|
+
}
|
|
1387
|
+
function Ze(e2) {
|
|
1388
|
+
const t2 = e2._controlledReadableByteStream._state;
|
|
1389
|
+
return "errored" === t2 ? null : "closed" === t2 ? 0 : e2._strategyHWM - e2._queueTotalSize;
|
|
1390
|
+
}
|
|
1391
|
+
function et(e2, t2) {
|
|
1392
|
+
const r2 = e2._pendingPullIntos.peek();
|
|
1393
|
+
if ("closed" === e2._controlledReadableByteStream._state) {
|
|
1394
|
+
if (0 !== t2) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
|
|
1395
|
+
} else {
|
|
1396
|
+
if (0 === t2) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
|
|
1397
|
+
if (r2.bytesFilled + t2 > r2.byteLength) throw new RangeError("bytesWritten out of range");
|
|
1398
|
+
}
|
|
1399
|
+
r2.buffer = ce(r2.buffer), Ne(e2, t2);
|
|
1400
|
+
}
|
|
1401
|
+
function tt(e2, t2) {
|
|
1402
|
+
const r2 = e2._pendingPullIntos.peek();
|
|
1403
|
+
if ("closed" === e2._controlledReadableByteStream._state) {
|
|
1404
|
+
if (0 !== t2.byteLength) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
|
|
1405
|
+
} else if (0 === t2.byteLength) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
|
|
1406
|
+
if (r2.byteOffset + r2.bytesFilled !== t2.byteOffset) throw new RangeError("The region specified by view does not match byobRequest");
|
|
1407
|
+
if (r2.bufferByteLength !== t2.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest");
|
|
1408
|
+
if (r2.bytesFilled + t2.byteLength > r2.byteLength) throw new RangeError("The region specified by view is larger than byobRequest");
|
|
1409
|
+
const o2 = t2.byteLength;
|
|
1410
|
+
r2.buffer = ce(t2.buffer), Ne(e2, o2);
|
|
1411
|
+
}
|
|
1412
|
+
function rt(e2, t2, r2, o2, n2, i2, a2) {
|
|
1413
|
+
t2._controlledReadableByteStream = e2, t2._pullAgain = false, t2._pulling = false, t2._byobRequest = null, t2._queue = t2._queueTotalSize = void 0, qe(t2), t2._closeRequested = false, t2._started = false, t2._strategyHWM = i2, t2._pullAlgorithm = o2, t2._cancelAlgorithm = n2, t2._autoAllocateChunkSize = a2, t2._pendingPullIntos = new v(), e2._readableStreamController = t2;
|
|
1414
|
+
h(c(r2()), () => (t2._started = true, je(t2), null), (e3) => (Xe(t2, e3), null));
|
|
1415
|
+
}
|
|
1416
|
+
function ot(e2) {
|
|
1417
|
+
return new TypeError(`ReadableStreamBYOBRequest.prototype.${e2} can only be used on a ReadableStreamBYOBRequest`);
|
|
1418
|
+
}
|
|
1419
|
+
function nt(e2) {
|
|
1420
|
+
return new TypeError(`ReadableByteStreamController.prototype.${e2} can only be used on a ReadableByteStreamController`);
|
|
1421
|
+
}
|
|
1422
|
+
function it(e2, t2) {
|
|
1423
|
+
if ("byob" !== (e2 = `${e2}`)) throw new TypeError(`${t2} '${e2}' is not a valid enumeration value for ReadableStreamReaderMode`);
|
|
1424
|
+
return e2;
|
|
1425
|
+
}
|
|
1426
|
+
function at(e2) {
|
|
1427
|
+
return new ReadableStreamBYOBReader(e2);
|
|
1428
|
+
}
|
|
1429
|
+
function st(e2, t2) {
|
|
1430
|
+
e2._reader._readIntoRequests.push(t2);
|
|
1431
|
+
}
|
|
1432
|
+
function lt(e2) {
|
|
1433
|
+
return e2._reader._readIntoRequests.length;
|
|
1434
|
+
}
|
|
1435
|
+
function ut(e2) {
|
|
1436
|
+
const t2 = e2._reader;
|
|
1437
|
+
return void 0 !== t2 && !!ft(t2);
|
|
1438
|
+
}
|
|
1439
|
+
Object.defineProperties(ReadableByteStreamController.prototype, { close: { enumerable: true }, enqueue: { enumerable: true }, error: { enumerable: true }, byobRequest: { enumerable: true }, desiredSize: { enumerable: true } }), 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, { value: "ReadableByteStreamController", configurable: true });
|
|
1440
|
+
var ReadableStreamBYOBReader = class {
|
|
1441
|
+
constructor(e2) {
|
|
1442
|
+
if (M(e2, 1, "ReadableStreamBYOBReader"), H(e2, "First parameter"), $r(e2)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
|
|
1443
|
+
if (!Oe(e2._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
|
|
1444
|
+
E(this, e2), this._readIntoRequests = new v();
|
|
1445
|
+
}
|
|
1446
|
+
get closed() {
|
|
1447
|
+
return ft(this) ? this._closedPromise : d(_t("closed"));
|
|
1448
|
+
}
|
|
1449
|
+
cancel(e2 = void 0) {
|
|
1450
|
+
return ft(this) ? void 0 === this._ownerReadableStream ? d(B("cancel")) : W(this, e2) : d(_t("cancel"));
|
|
1451
|
+
}
|
|
1452
|
+
read(e2, t2 = {}) {
|
|
1453
|
+
if (!ft(this)) return d(_t("read"));
|
|
1454
|
+
if (!ArrayBuffer.isView(e2)) return d(new TypeError("view must be an array buffer view"));
|
|
1455
|
+
if (0 === e2.byteLength) return d(new TypeError("view must have non-zero byteLength"));
|
|
1456
|
+
if (0 === e2.buffer.byteLength) return d(new TypeError("view's buffer must have non-zero byteLength"));
|
|
1457
|
+
if (de(e2.buffer)) return d(new TypeError("view's buffer has been detached"));
|
|
1458
|
+
let r2;
|
|
1459
|
+
try {
|
|
1460
|
+
r2 = (function(e3, t3) {
|
|
1461
|
+
var r3;
|
|
1462
|
+
return L(e3, t3), { min: N(null !== (r3 = null == e3 ? void 0 : e3.min) && void 0 !== r3 ? r3 : 1, `${t3} has member 'min' that`) };
|
|
1463
|
+
})(t2, "options");
|
|
1464
|
+
} catch (e3) {
|
|
1465
|
+
return d(e3);
|
|
1466
|
+
}
|
|
1467
|
+
const o2 = r2.min;
|
|
1468
|
+
if (0 === o2) return d(new TypeError("options.min must be greater than 0"));
|
|
1469
|
+
if ((function(e3) {
|
|
1470
|
+
return Ee(e3.constructor);
|
|
1471
|
+
})(e2)) {
|
|
1472
|
+
if (o2 > e2.byteLength) return d(new RangeError("options.min must be less than or equal to view's byteLength"));
|
|
1473
|
+
} else if (o2 > e2.length) return d(new RangeError("options.min must be less than or equal to view's length"));
|
|
1474
|
+
if (void 0 === this._ownerReadableStream) return d(B("read from"));
|
|
1475
|
+
const n2 = (function(e3, t3, r3) {
|
|
1476
|
+
const o3 = e3._ownerReadableStream;
|
|
1477
|
+
return "errored" === o3._state || (function(e4, t4, r4) {
|
|
1478
|
+
const o4 = e4._controlledReadableByteStream, n3 = We(t4.constructor), { byteLength: i2 } = t4, a2 = r4 * n3;
|
|
1479
|
+
return !(e4._pendingPullIntos.length > 0) && ("closed" === o4._state || e4._queueTotalSize >= a2);
|
|
1480
|
+
})(o3._readableStreamController, t3, r3);
|
|
1481
|
+
})(this, e2, o2) ? new dt() : new ct();
|
|
1482
|
+
return ht(this, e2, o2, n2), n2._promise;
|
|
1483
|
+
}
|
|
1484
|
+
releaseLock() {
|
|
1485
|
+
if (!ft(this)) throw _t("releaseLock");
|
|
1486
|
+
void 0 !== this._ownerReadableStream && (function(e2) {
|
|
1487
|
+
O(e2);
|
|
1488
|
+
const t2 = new TypeError("Reader was released");
|
|
1489
|
+
bt(e2, t2);
|
|
1490
|
+
})(this);
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
Object.defineProperties(ReadableStreamBYOBReader.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }), 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, { value: "ReadableStreamBYOBReader", configurable: true });
|
|
1494
|
+
var ct = class {
|
|
1495
|
+
constructor() {
|
|
1496
|
+
this._promise = u((e2, t2) => {
|
|
1497
|
+
this._resolvePromise = e2, this._rejectPromise = t2;
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
_chunkSteps(e2) {
|
|
1501
|
+
this._resolvePromise({ value: e2, done: false });
|
|
1502
|
+
}
|
|
1503
|
+
_closeSteps(e2) {
|
|
1504
|
+
this._resolvePromise({ value: e2, done: true });
|
|
1505
|
+
}
|
|
1506
|
+
_errorSteps(e2) {
|
|
1507
|
+
this._rejectPromise(e2);
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
var dt = class {
|
|
1511
|
+
constructor() {
|
|
1512
|
+
this._promise = void 0;
|
|
1513
|
+
}
|
|
1514
|
+
_chunkSteps(e2) {
|
|
1515
|
+
this._promise = l({ value: e2, done: false });
|
|
1516
|
+
}
|
|
1517
|
+
_closeSteps(e2) {
|
|
1518
|
+
this._promise = l({ value: e2, done: true });
|
|
1519
|
+
}
|
|
1520
|
+
_errorSteps(e2) {
|
|
1521
|
+
this._promise = d(e2);
|
|
1522
|
+
}
|
|
1523
|
+
};
|
|
1524
|
+
function ft(e2) {
|
|
1525
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_readIntoRequests") && e2 instanceof ReadableStreamBYOBReader);
|
|
1526
|
+
}
|
|
1527
|
+
function ht(e2, t2, r2, o2) {
|
|
1528
|
+
const n2 = e2._ownerReadableStream;
|
|
1529
|
+
n2._disturbed = true, "errored" === n2._state ? o2._errorSteps(n2._storedError) : (function(e3, t3, r3, o3) {
|
|
1530
|
+
const n3 = e3._controlledReadableByteStream, i2 = t3.constructor, a2 = We(i2), { byteOffset: s2, byteLength: l2 } = t3, u2 = r3 * a2;
|
|
1531
|
+
let c2;
|
|
1532
|
+
try {
|
|
1533
|
+
c2 = ce(t3.buffer);
|
|
1534
|
+
} catch (e4) {
|
|
1535
|
+
return void o3._errorSteps(e4);
|
|
1536
|
+
}
|
|
1537
|
+
const d2 = { buffer: c2, bufferByteLength: c2.byteLength, byteOffset: s2, byteLength: l2, bytesFilled: 0, minimumFill: u2, elementSize: a2, viewConstructor: i2, readerType: "byob" };
|
|
1538
|
+
if (e3._pendingPullIntos.length > 0) return e3._pendingPullIntos.push(d2), void st(n3, o3);
|
|
1539
|
+
if ("closed" === n3._state) {
|
|
1540
|
+
const e4 = new i2(d2.buffer, d2.byteOffset, 0);
|
|
1541
|
+
return void o3._closeSteps(e4);
|
|
1542
|
+
}
|
|
1543
|
+
if (e3._queueTotalSize > 0) {
|
|
1544
|
+
if ($e(e3, d2)) {
|
|
1545
|
+
const t4 = De(d2);
|
|
1546
|
+
return Ye(e3), void o3._chunkSteps(t4);
|
|
1547
|
+
}
|
|
1548
|
+
if (e3._closeRequested) {
|
|
1549
|
+
const t4 = new TypeError("Insufficient bytes to fill elements in the given buffer");
|
|
1550
|
+
return Xe(e3, t4), void o3._errorSteps(t4);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
e3._pendingPullIntos.push(d2), st(n3, o3), je(e3);
|
|
1554
|
+
})(n2._readableStreamController, t2, r2, o2);
|
|
1555
|
+
}
|
|
1556
|
+
function bt(e2, t2) {
|
|
1557
|
+
const r2 = e2._readIntoRequests;
|
|
1558
|
+
e2._readIntoRequests = new v(), r2.forEach((e3) => {
|
|
1559
|
+
e3._errorSteps(t2);
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
function _t(e2) {
|
|
1563
|
+
return new TypeError(`ReadableStreamBYOBReader.prototype.${e2} can only be used on a ReadableStreamBYOBReader`);
|
|
1564
|
+
}
|
|
1565
|
+
function mt(e2, t2) {
|
|
1566
|
+
const { highWaterMark: r2 } = e2;
|
|
1567
|
+
if (void 0 === r2) return t2;
|
|
1568
|
+
if (Re(r2) || r2 < 0) throw new RangeError("Invalid highWaterMark");
|
|
1569
|
+
return r2;
|
|
1570
|
+
}
|
|
1571
|
+
function pt(e2) {
|
|
1572
|
+
const { size: t2 } = e2;
|
|
1573
|
+
return t2 || (() => 1);
|
|
1574
|
+
}
|
|
1575
|
+
function yt(e2, t2) {
|
|
1576
|
+
L(e2, t2);
|
|
1577
|
+
const r2 = null == e2 ? void 0 : e2.highWaterMark, o2 = null == e2 ? void 0 : e2.size;
|
|
1578
|
+
return { highWaterMark: void 0 === r2 ? void 0 : x(r2), size: void 0 === o2 ? void 0 : St(o2, `${t2} has member 'size' that`) };
|
|
1579
|
+
}
|
|
1580
|
+
function St(e2, t2) {
|
|
1581
|
+
return I(e2, t2), (t3) => x(e2(t3));
|
|
1582
|
+
}
|
|
1583
|
+
function gt(e2, t2, r2) {
|
|
1584
|
+
return I(e2, r2), (r3) => g(e2, t2, [r3]);
|
|
1585
|
+
}
|
|
1586
|
+
function vt(e2, t2, r2) {
|
|
1587
|
+
return I(e2, r2), () => g(e2, t2, []);
|
|
1588
|
+
}
|
|
1589
|
+
function wt(e2, t2, r2) {
|
|
1590
|
+
return I(e2, r2), (r3) => S(e2, t2, [r3]);
|
|
1591
|
+
}
|
|
1592
|
+
function Rt(e2, t2, r2) {
|
|
1593
|
+
return I(e2, r2), (r3, o2) => g(e2, t2, [r3, o2]);
|
|
1594
|
+
}
|
|
1595
|
+
function Tt(e2, t2) {
|
|
1596
|
+
if (!qt(e2)) throw new TypeError(`${t2} is not a WritableStream.`);
|
|
1597
|
+
}
|
|
1598
|
+
var WritableStream = class {
|
|
1599
|
+
constructor(e2 = {}, t2 = {}) {
|
|
1600
|
+
void 0 === e2 ? e2 = null : $(e2, "First parameter");
|
|
1601
|
+
const r2 = yt(t2, "Second parameter"), o2 = (function(e3, t3) {
|
|
1602
|
+
L(e3, t3);
|
|
1603
|
+
const r3 = null == e3 ? void 0 : e3.abort, o3 = null == e3 ? void 0 : e3.close, n3 = null == e3 ? void 0 : e3.start, i2 = null == e3 ? void 0 : e3.type, a2 = null == e3 ? void 0 : e3.write;
|
|
1604
|
+
return { abort: void 0 === r3 ? void 0 : gt(r3, e3, `${t3} has member 'abort' that`), close: void 0 === o3 ? void 0 : vt(o3, e3, `${t3} has member 'close' that`), start: void 0 === n3 ? void 0 : wt(n3, e3, `${t3} has member 'start' that`), write: void 0 === a2 ? void 0 : Rt(a2, e3, `${t3} has member 'write' that`), type: i2 };
|
|
1605
|
+
})(e2, "First parameter");
|
|
1606
|
+
Ct(this);
|
|
1607
|
+
if (void 0 !== o2.type) throw new RangeError("Invalid type is specified");
|
|
1608
|
+
const n2 = pt(r2);
|
|
1609
|
+
!(function(e3, t3, r3, o3) {
|
|
1610
|
+
const n3 = Object.create(WritableStreamDefaultController.prototype);
|
|
1611
|
+
let i2, a2, s2, l2;
|
|
1612
|
+
i2 = void 0 !== t3.start ? () => t3.start(n3) : () => {
|
|
1613
|
+
};
|
|
1614
|
+
a2 = void 0 !== t3.write ? (e4) => t3.write(e4, n3) : () => c(void 0);
|
|
1615
|
+
s2 = void 0 !== t3.close ? () => t3.close() : () => c(void 0);
|
|
1616
|
+
l2 = void 0 !== t3.abort ? (e4) => t3.abort(e4) : () => c(void 0);
|
|
1617
|
+
Nt(e3, n3, i2, a2, s2, l2, r3, o3);
|
|
1618
|
+
})(this, o2, mt(r2, 1), n2);
|
|
1619
|
+
}
|
|
1620
|
+
get locked() {
|
|
1621
|
+
if (!qt(this)) throw Kt("locked");
|
|
1622
|
+
return Et(this);
|
|
1623
|
+
}
|
|
1624
|
+
abort(e2 = void 0) {
|
|
1625
|
+
return qt(this) ? Et(this) ? d(new TypeError("Cannot abort a stream that already has a writer")) : Wt(this, e2) : d(Kt("abort"));
|
|
1626
|
+
}
|
|
1627
|
+
close() {
|
|
1628
|
+
return qt(this) ? Et(this) ? d(new TypeError("Cannot close a stream that already has a writer")) : At(this) ? d(new TypeError("Cannot close an already-closing stream")) : Ot(this) : d(Kt("close"));
|
|
1629
|
+
}
|
|
1630
|
+
getWriter() {
|
|
1631
|
+
if (!qt(this)) throw Kt("getWriter");
|
|
1632
|
+
return Pt(this);
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
function Pt(e2) {
|
|
1636
|
+
return new WritableStreamDefaultWriter(e2);
|
|
1637
|
+
}
|
|
1638
|
+
function Ct(e2) {
|
|
1639
|
+
e2._state = "writable", e2._storedError = void 0, e2._writer = void 0, e2._writableStreamController = void 0, e2._writeRequests = new v(), e2._inFlightWriteRequest = void 0, e2._closeRequest = void 0, e2._inFlightCloseRequest = void 0, e2._pendingAbortRequest = void 0, e2._backpressure = false;
|
|
1640
|
+
}
|
|
1641
|
+
function qt(e2) {
|
|
1642
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_writableStreamController") && e2 instanceof WritableStream);
|
|
1643
|
+
}
|
|
1644
|
+
function Et(e2) {
|
|
1645
|
+
return void 0 !== e2._writer;
|
|
1646
|
+
}
|
|
1647
|
+
function Wt(e2, t2) {
|
|
1648
|
+
var r2;
|
|
1649
|
+
if ("closed" === e2._state || "errored" === e2._state) return c(void 0);
|
|
1650
|
+
e2._writableStreamController._abortReason = t2, null === (r2 = e2._writableStreamController._abortController) || void 0 === r2 || r2.abort(t2);
|
|
1651
|
+
const o2 = e2._state;
|
|
1652
|
+
if ("closed" === o2 || "errored" === o2) return c(void 0);
|
|
1653
|
+
if (void 0 !== e2._pendingAbortRequest) return e2._pendingAbortRequest._promise;
|
|
1654
|
+
let n2 = false;
|
|
1655
|
+
"erroring" === o2 && (n2 = true, t2 = void 0);
|
|
1656
|
+
const i2 = u((r3, o3) => {
|
|
1657
|
+
e2._pendingAbortRequest = { _promise: void 0, _resolve: r3, _reject: o3, _reason: t2, _wasAlreadyErroring: n2 };
|
|
1658
|
+
});
|
|
1659
|
+
return e2._pendingAbortRequest._promise = i2, n2 || jt(e2, t2), i2;
|
|
1660
|
+
}
|
|
1661
|
+
function Ot(e2) {
|
|
1662
|
+
const t2 = e2._state;
|
|
1663
|
+
if ("closed" === t2 || "errored" === t2) return d(new TypeError(`The stream (in ${t2} state) is not in the writable state and cannot be closed`));
|
|
1664
|
+
const r2 = u((t3, r3) => {
|
|
1665
|
+
const o3 = { _resolve: t3, _reject: r3 };
|
|
1666
|
+
e2._closeRequest = o3;
|
|
1667
|
+
}), o2 = e2._writer;
|
|
1668
|
+
var n2;
|
|
1669
|
+
return void 0 !== o2 && e2._backpressure && "writable" === t2 && cr(o2), Ce(n2 = e2._writableStreamController, xt, 0), Ut(n2), r2;
|
|
1670
|
+
}
|
|
1671
|
+
function Bt(e2, t2) {
|
|
1672
|
+
"writable" !== e2._state ? kt(e2) : jt(e2, t2);
|
|
1673
|
+
}
|
|
1674
|
+
function jt(e2, t2) {
|
|
1675
|
+
const r2 = e2._writableStreamController;
|
|
1676
|
+
e2._state = "erroring", e2._storedError = t2;
|
|
1677
|
+
const o2 = e2._writer;
|
|
1678
|
+
void 0 !== o2 && $t(o2, t2), !(function(e3) {
|
|
1679
|
+
if (void 0 === e3._inFlightWriteRequest && void 0 === e3._inFlightCloseRequest) return false;
|
|
1680
|
+
return true;
|
|
1681
|
+
})(e2) && r2._started && kt(e2);
|
|
1682
|
+
}
|
|
1683
|
+
function kt(e2) {
|
|
1684
|
+
e2._state = "errored", e2._writableStreamController[R]();
|
|
1685
|
+
const t2 = e2._storedError;
|
|
1686
|
+
if (e2._writeRequests.forEach((e3) => {
|
|
1687
|
+
e3._reject(t2);
|
|
1688
|
+
}), e2._writeRequests = new v(), void 0 === e2._pendingAbortRequest) return void zt(e2);
|
|
1689
|
+
const r2 = e2._pendingAbortRequest;
|
|
1690
|
+
if (e2._pendingAbortRequest = void 0, r2._wasAlreadyErroring) return r2._reject(t2), void zt(e2);
|
|
1691
|
+
h(e2._writableStreamController[w](r2._reason), () => (r2._resolve(), zt(e2), null), (t3) => (r2._reject(t3), zt(e2), null));
|
|
1692
|
+
}
|
|
1693
|
+
function At(e2) {
|
|
1694
|
+
return void 0 !== e2._closeRequest || void 0 !== e2._inFlightCloseRequest;
|
|
1695
|
+
}
|
|
1696
|
+
function zt(e2) {
|
|
1697
|
+
void 0 !== e2._closeRequest && (e2._closeRequest._reject(e2._storedError), e2._closeRequest = void 0);
|
|
1698
|
+
const t2 = e2._writer;
|
|
1699
|
+
void 0 !== t2 && nr(t2, e2._storedError);
|
|
1700
|
+
}
|
|
1701
|
+
function Dt(e2, t2) {
|
|
1702
|
+
const r2 = e2._writer;
|
|
1703
|
+
void 0 !== r2 && t2 !== e2._backpressure && (t2 ? (function(e3) {
|
|
1704
|
+
ar(e3);
|
|
1705
|
+
})(r2) : cr(r2)), e2._backpressure = t2;
|
|
1706
|
+
}
|
|
1707
|
+
Object.defineProperties(WritableStream.prototype, { abort: { enumerable: true }, close: { enumerable: true }, getWriter: { enumerable: true }, locked: { enumerable: true } }), 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, { value: "WritableStream", configurable: true });
|
|
1708
|
+
var WritableStreamDefaultWriter = class {
|
|
1709
|
+
constructor(e2) {
|
|
1710
|
+
if (M(e2, 1, "WritableStreamDefaultWriter"), Tt(e2, "First parameter"), Et(e2)) throw new TypeError("This stream has already been locked for exclusive writing by another writer");
|
|
1711
|
+
this._ownerWritableStream = e2, e2._writer = this;
|
|
1712
|
+
const t2 = e2._state;
|
|
1713
|
+
if ("writable" === t2) !At(e2) && e2._backpressure ? ar(this) : lr(this), rr(this);
|
|
1714
|
+
else if ("erroring" === t2) sr(this, e2._storedError), rr(this);
|
|
1715
|
+
else if ("closed" === t2) lr(this), rr(r2 = this), ir(r2);
|
|
1716
|
+
else {
|
|
1717
|
+
const t3 = e2._storedError;
|
|
1718
|
+
sr(this, t3), or(this, t3);
|
|
1719
|
+
}
|
|
1720
|
+
var r2;
|
|
1721
|
+
}
|
|
1722
|
+
get closed() {
|
|
1723
|
+
return Ft(this) ? this._closedPromise : d(er("closed"));
|
|
1724
|
+
}
|
|
1725
|
+
get desiredSize() {
|
|
1726
|
+
if (!Ft(this)) throw er("desiredSize");
|
|
1727
|
+
if (void 0 === this._ownerWritableStream) throw tr("desiredSize");
|
|
1728
|
+
return (function(e2) {
|
|
1729
|
+
const t2 = e2._ownerWritableStream, r2 = t2._state;
|
|
1730
|
+
if ("errored" === r2 || "erroring" === r2) return null;
|
|
1731
|
+
if ("closed" === r2) return 0;
|
|
1732
|
+
return Vt(t2._writableStreamController);
|
|
1733
|
+
})(this);
|
|
1734
|
+
}
|
|
1735
|
+
get ready() {
|
|
1736
|
+
return Ft(this) ? this._readyPromise : d(er("ready"));
|
|
1737
|
+
}
|
|
1738
|
+
abort(e2 = void 0) {
|
|
1739
|
+
return Ft(this) ? void 0 === this._ownerWritableStream ? d(tr("abort")) : (function(e3, t2) {
|
|
1740
|
+
return Wt(e3._ownerWritableStream, t2);
|
|
1741
|
+
})(this, e2) : d(er("abort"));
|
|
1742
|
+
}
|
|
1743
|
+
close() {
|
|
1744
|
+
if (!Ft(this)) return d(er("close"));
|
|
1745
|
+
const e2 = this._ownerWritableStream;
|
|
1746
|
+
return void 0 === e2 ? d(tr("close")) : At(e2) ? d(new TypeError("Cannot close an already-closing stream")) : Lt(this);
|
|
1747
|
+
}
|
|
1748
|
+
releaseLock() {
|
|
1749
|
+
if (!Ft(this)) throw er("releaseLock");
|
|
1750
|
+
void 0 !== this._ownerWritableStream && Mt(this);
|
|
1751
|
+
}
|
|
1752
|
+
write(e2 = void 0) {
|
|
1753
|
+
return Ft(this) ? void 0 === this._ownerWritableStream ? d(tr("write to")) : Yt(this, e2) : d(er("write"));
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
function Ft(e2) {
|
|
1757
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_ownerWritableStream") && e2 instanceof WritableStreamDefaultWriter);
|
|
1758
|
+
}
|
|
1759
|
+
function Lt(e2) {
|
|
1760
|
+
return Ot(e2._ownerWritableStream);
|
|
1761
|
+
}
|
|
1762
|
+
function It(e2, t2) {
|
|
1763
|
+
"pending" === e2._closedPromiseState ? nr(e2, t2) : (function(e3, t3) {
|
|
1764
|
+
or(e3, t3);
|
|
1765
|
+
})(e2, t2);
|
|
1766
|
+
}
|
|
1767
|
+
function $t(e2, t2) {
|
|
1768
|
+
"pending" === e2._readyPromiseState ? ur(e2, t2) : (function(e3, t3) {
|
|
1769
|
+
sr(e3, t3);
|
|
1770
|
+
})(e2, t2);
|
|
1771
|
+
}
|
|
1772
|
+
function Mt(e2) {
|
|
1773
|
+
const t2 = e2._ownerWritableStream, r2 = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
|
|
1774
|
+
$t(e2, r2), It(e2, r2), t2._writer = void 0, e2._ownerWritableStream = void 0;
|
|
1775
|
+
}
|
|
1776
|
+
function Yt(e2, t2) {
|
|
1777
|
+
const r2 = e2._ownerWritableStream, o2 = r2._writableStreamController, n2 = (function(e3, t3) {
|
|
1778
|
+
if (void 0 === e3._strategySizeAlgorithm) return 1;
|
|
1779
|
+
try {
|
|
1780
|
+
return e3._strategySizeAlgorithm(t3);
|
|
1781
|
+
} catch (t4) {
|
|
1782
|
+
return Gt(e3, t4), 1;
|
|
1783
|
+
}
|
|
1784
|
+
})(o2, t2);
|
|
1785
|
+
if (r2 !== e2._ownerWritableStream) return d(tr("write to"));
|
|
1786
|
+
const i2 = r2._state;
|
|
1787
|
+
if ("errored" === i2) return d(r2._storedError);
|
|
1788
|
+
if (At(r2) || "closed" === i2) return d(new TypeError("The stream is closing or closed and cannot be written to"));
|
|
1789
|
+
if ("erroring" === i2) return d(r2._storedError);
|
|
1790
|
+
const a2 = (function(e3) {
|
|
1791
|
+
return u((t3, r3) => {
|
|
1792
|
+
const o3 = { _resolve: t3, _reject: r3 };
|
|
1793
|
+
e3._writeRequests.push(o3);
|
|
1794
|
+
});
|
|
1795
|
+
})(r2);
|
|
1796
|
+
return (function(e3, t3, r3) {
|
|
1797
|
+
try {
|
|
1798
|
+
Ce(e3, t3, r3);
|
|
1799
|
+
} catch (t4) {
|
|
1800
|
+
return void Gt(e3, t4);
|
|
1801
|
+
}
|
|
1802
|
+
const o3 = e3._controlledWritableStream;
|
|
1803
|
+
if (!At(o3) && "writable" === o3._state) {
|
|
1804
|
+
Dt(o3, Xt(e3));
|
|
1805
|
+
}
|
|
1806
|
+
Ut(e3);
|
|
1807
|
+
})(o2, t2, n2), a2;
|
|
1808
|
+
}
|
|
1809
|
+
Object.defineProperties(WritableStreamDefaultWriter.prototype, { abort: { enumerable: true }, close: { enumerable: true }, releaseLock: { enumerable: true }, write: { enumerable: true }, closed: { enumerable: true }, desiredSize: { enumerable: true }, ready: { enumerable: true } }), 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, { value: "WritableStreamDefaultWriter", configurable: true });
|
|
1810
|
+
var xt = {};
|
|
1811
|
+
var WritableStreamDefaultController = class {
|
|
1812
|
+
constructor() {
|
|
1813
|
+
throw new TypeError("Illegal constructor");
|
|
1814
|
+
}
|
|
1815
|
+
get abortReason() {
|
|
1816
|
+
if (!Qt(this)) throw Zt("abortReason");
|
|
1817
|
+
return this._abortReason;
|
|
1818
|
+
}
|
|
1819
|
+
get signal() {
|
|
1820
|
+
if (!Qt(this)) throw Zt("signal");
|
|
1821
|
+
if (void 0 === this._abortController) throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
|
|
1822
|
+
return this._abortController.signal;
|
|
1823
|
+
}
|
|
1824
|
+
error(e2 = void 0) {
|
|
1825
|
+
if (!Qt(this)) throw Zt("error");
|
|
1826
|
+
"writable" === this._controlledWritableStream._state && Jt(this, e2);
|
|
1827
|
+
}
|
|
1828
|
+
[w](e2) {
|
|
1829
|
+
const t2 = this._abortAlgorithm(e2);
|
|
1830
|
+
return Ht(this), t2;
|
|
1831
|
+
}
|
|
1832
|
+
[R]() {
|
|
1833
|
+
qe(this);
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
function Qt(e2) {
|
|
1837
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_controlledWritableStream") && e2 instanceof WritableStreamDefaultController);
|
|
1838
|
+
}
|
|
1839
|
+
function Nt(e2, t2, r2, o2, n2, i2, a2, s2) {
|
|
1840
|
+
t2._controlledWritableStream = e2, e2._writableStreamController = t2, t2._queue = void 0, t2._queueTotalSize = void 0, qe(t2), t2._abortReason = void 0, t2._abortController = (function() {
|
|
1841
|
+
if ("function" == typeof AbortController) return new AbortController();
|
|
1842
|
+
})(), t2._started = false, t2._strategySizeAlgorithm = s2, t2._strategyHWM = a2, t2._writeAlgorithm = o2, t2._closeAlgorithm = n2, t2._abortAlgorithm = i2;
|
|
1843
|
+
const l2 = Xt(t2);
|
|
1844
|
+
Dt(e2, l2);
|
|
1845
|
+
h(c(r2()), () => (t2._started = true, Ut(t2), null), (r3) => (t2._started = true, Bt(e2, r3), null));
|
|
1846
|
+
}
|
|
1847
|
+
function Ht(e2) {
|
|
1848
|
+
e2._writeAlgorithm = void 0, e2._closeAlgorithm = void 0, e2._abortAlgorithm = void 0, e2._strategySizeAlgorithm = void 0;
|
|
1849
|
+
}
|
|
1850
|
+
function Vt(e2) {
|
|
1851
|
+
return e2._strategyHWM - e2._queueTotalSize;
|
|
1852
|
+
}
|
|
1853
|
+
function Ut(e2) {
|
|
1854
|
+
const t2 = e2._controlledWritableStream;
|
|
1855
|
+
if (!e2._started) return;
|
|
1856
|
+
if (void 0 !== t2._inFlightWriteRequest) return;
|
|
1857
|
+
if ("erroring" === t2._state) return void kt(t2);
|
|
1858
|
+
if (0 === e2._queue.length) return;
|
|
1859
|
+
const r2 = e2._queue.peek().value;
|
|
1860
|
+
r2 === xt ? (function(e3) {
|
|
1861
|
+
const t3 = e3._controlledWritableStream;
|
|
1862
|
+
(function(e4) {
|
|
1863
|
+
e4._inFlightCloseRequest = e4._closeRequest, e4._closeRequest = void 0;
|
|
1864
|
+
})(t3), Pe(e3);
|
|
1865
|
+
const r3 = e3._closeAlgorithm();
|
|
1866
|
+
Ht(e3), h(r3, () => ((function(e4) {
|
|
1867
|
+
e4._inFlightCloseRequest._resolve(void 0), e4._inFlightCloseRequest = void 0, "erroring" === e4._state && (e4._storedError = void 0, void 0 !== e4._pendingAbortRequest && (e4._pendingAbortRequest._resolve(), e4._pendingAbortRequest = void 0)), e4._state = "closed";
|
|
1868
|
+
const t4 = e4._writer;
|
|
1869
|
+
void 0 !== t4 && ir(t4);
|
|
1870
|
+
})(t3), null), (e4) => ((function(e5, t4) {
|
|
1871
|
+
e5._inFlightCloseRequest._reject(t4), e5._inFlightCloseRequest = void 0, void 0 !== e5._pendingAbortRequest && (e5._pendingAbortRequest._reject(t4), e5._pendingAbortRequest = void 0), Bt(e5, t4);
|
|
1872
|
+
})(t3, e4), null));
|
|
1873
|
+
})(e2) : (function(e3, t3) {
|
|
1874
|
+
const r3 = e3._controlledWritableStream;
|
|
1875
|
+
!(function(e4) {
|
|
1876
|
+
e4._inFlightWriteRequest = e4._writeRequests.shift();
|
|
1877
|
+
})(r3);
|
|
1878
|
+
const o2 = e3._writeAlgorithm(t3);
|
|
1879
|
+
h(o2, () => {
|
|
1880
|
+
!(function(e4) {
|
|
1881
|
+
e4._inFlightWriteRequest._resolve(void 0), e4._inFlightWriteRequest = void 0;
|
|
1882
|
+
})(r3);
|
|
1883
|
+
const t4 = r3._state;
|
|
1884
|
+
if (Pe(e3), !At(r3) && "writable" === t4) {
|
|
1885
|
+
const t5 = Xt(e3);
|
|
1886
|
+
Dt(r3, t5);
|
|
1887
|
+
}
|
|
1888
|
+
return Ut(e3), null;
|
|
1889
|
+
}, (t4) => ("writable" === r3._state && Ht(e3), (function(e4, t5) {
|
|
1890
|
+
e4._inFlightWriteRequest._reject(t5), e4._inFlightWriteRequest = void 0, Bt(e4, t5);
|
|
1891
|
+
})(r3, t4), null));
|
|
1892
|
+
})(e2, r2);
|
|
1893
|
+
}
|
|
1894
|
+
function Gt(e2, t2) {
|
|
1895
|
+
"writable" === e2._controlledWritableStream._state && Jt(e2, t2);
|
|
1896
|
+
}
|
|
1897
|
+
function Xt(e2) {
|
|
1898
|
+
return Vt(e2) <= 0;
|
|
1899
|
+
}
|
|
1900
|
+
function Jt(e2, t2) {
|
|
1901
|
+
const r2 = e2._controlledWritableStream;
|
|
1902
|
+
Ht(e2), jt(r2, t2);
|
|
1903
|
+
}
|
|
1904
|
+
function Kt(e2) {
|
|
1905
|
+
return new TypeError(`WritableStream.prototype.${e2} can only be used on a WritableStream`);
|
|
1906
|
+
}
|
|
1907
|
+
function Zt(e2) {
|
|
1908
|
+
return new TypeError(`WritableStreamDefaultController.prototype.${e2} can only be used on a WritableStreamDefaultController`);
|
|
1909
|
+
}
|
|
1910
|
+
function er(e2) {
|
|
1911
|
+
return new TypeError(`WritableStreamDefaultWriter.prototype.${e2} can only be used on a WritableStreamDefaultWriter`);
|
|
1912
|
+
}
|
|
1913
|
+
function tr(e2) {
|
|
1914
|
+
return new TypeError("Cannot " + e2 + " a stream using a released writer");
|
|
1915
|
+
}
|
|
1916
|
+
function rr(e2) {
|
|
1917
|
+
e2._closedPromise = u((t2, r2) => {
|
|
1918
|
+
e2._closedPromise_resolve = t2, e2._closedPromise_reject = r2, e2._closedPromiseState = "pending";
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
function or(e2, t2) {
|
|
1922
|
+
rr(e2), nr(e2, t2);
|
|
1923
|
+
}
|
|
1924
|
+
function nr(e2, t2) {
|
|
1925
|
+
void 0 !== e2._closedPromise_reject && (p(e2._closedPromise), e2._closedPromise_reject(t2), e2._closedPromise_resolve = void 0, e2._closedPromise_reject = void 0, e2._closedPromiseState = "rejected");
|
|
1926
|
+
}
|
|
1927
|
+
function ir(e2) {
|
|
1928
|
+
void 0 !== e2._closedPromise_resolve && (e2._closedPromise_resolve(void 0), e2._closedPromise_resolve = void 0, e2._closedPromise_reject = void 0, e2._closedPromiseState = "resolved");
|
|
1929
|
+
}
|
|
1930
|
+
function ar(e2) {
|
|
1931
|
+
e2._readyPromise = u((t2, r2) => {
|
|
1932
|
+
e2._readyPromise_resolve = t2, e2._readyPromise_reject = r2;
|
|
1933
|
+
}), e2._readyPromiseState = "pending";
|
|
1934
|
+
}
|
|
1935
|
+
function sr(e2, t2) {
|
|
1936
|
+
ar(e2), ur(e2, t2);
|
|
1937
|
+
}
|
|
1938
|
+
function lr(e2) {
|
|
1939
|
+
ar(e2), cr(e2);
|
|
1940
|
+
}
|
|
1941
|
+
function ur(e2, t2) {
|
|
1942
|
+
void 0 !== e2._readyPromise_reject && (p(e2._readyPromise), e2._readyPromise_reject(t2), e2._readyPromise_resolve = void 0, e2._readyPromise_reject = void 0, e2._readyPromiseState = "rejected");
|
|
1943
|
+
}
|
|
1944
|
+
function cr(e2) {
|
|
1945
|
+
void 0 !== e2._readyPromise_resolve && (e2._readyPromise_resolve(void 0), e2._readyPromise_resolve = void 0, e2._readyPromise_reject = void 0, e2._readyPromiseState = "fulfilled");
|
|
1946
|
+
}
|
|
1947
|
+
Object.defineProperties(WritableStreamDefaultController.prototype, { abortReason: { enumerable: true }, signal: { enumerable: true }, error: { enumerable: true } }), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, { value: "WritableStreamDefaultController", configurable: true });
|
|
1948
|
+
var dr = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof global ? global : void 0;
|
|
1949
|
+
var fr = (function() {
|
|
1950
|
+
const e2 = null == dr ? void 0 : dr.DOMException;
|
|
1951
|
+
return (function(e3) {
|
|
1952
|
+
if ("function" != typeof e3 && "object" != typeof e3) return false;
|
|
1953
|
+
if ("DOMException" !== e3.name) return false;
|
|
1954
|
+
try {
|
|
1955
|
+
return new e3(), true;
|
|
1956
|
+
} catch (e4) {
|
|
1957
|
+
return false;
|
|
1958
|
+
}
|
|
1959
|
+
})(e2) ? e2 : void 0;
|
|
1960
|
+
})() || (function() {
|
|
1961
|
+
const e2 = function(e3, t2) {
|
|
1962
|
+
this.message = e3 || "", this.name = t2 || "Error", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
|
|
1963
|
+
};
|
|
1964
|
+
return o(e2, "DOMException"), e2.prototype = Object.create(Error.prototype), Object.defineProperty(e2.prototype, "constructor", { value: e2, writable: true, configurable: true }), e2;
|
|
1965
|
+
})();
|
|
1966
|
+
function hr(e2, t2, r2, o2, n2, i2) {
|
|
1967
|
+
const a2 = V(e2), s2 = Pt(t2);
|
|
1968
|
+
e2._disturbed = true;
|
|
1969
|
+
const l2 = new br(s2), _2 = new mr(l2);
|
|
1970
|
+
return u((m2, y2) => {
|
|
1971
|
+
let S2;
|
|
1972
|
+
if (void 0 !== i2) {
|
|
1973
|
+
if (S2 = () => {
|
|
1974
|
+
const r3 = void 0 !== i2.reason ? i2.reason : new fr("Aborted", "AbortError"), a3 = [];
|
|
1975
|
+
o2 || a3.push(() => "writable" === t2._state ? Wt(t2, r3) : c(void 0)), n2 || a3.push(() => "readable" === e2._state ? Mr(e2, r3) : c(void 0)), T2(() => Promise.all(a3.map((e3) => e3())), true, r3);
|
|
1976
|
+
}, i2.aborted) return void S2();
|
|
1977
|
+
i2.addEventListener("abort", S2);
|
|
1978
|
+
}
|
|
1979
|
+
function g2() {
|
|
1980
|
+
for (; !l2._shuttingDown && !t2._backpressure && "writable" === t2._state && !At(t2) && "readable" === e2._state && re(a2); ) te(a2, _2);
|
|
1981
|
+
if (l2._shuttingDown) return c(true);
|
|
1982
|
+
if (t2._backpressure) return f(s2._readyPromise, g2);
|
|
1983
|
+
const r3 = new _r(l2);
|
|
1984
|
+
return te(a2, r3), r3._promise;
|
|
1985
|
+
}
|
|
1986
|
+
var v2, w2, R2;
|
|
1987
|
+
if (pr(e2, a2._closedPromise, (e3) => (o2 ? P2(true, e3) : T2(() => Wt(t2, e3), true, e3), null)), pr(t2, s2._closedPromise, (t3) => (n2 ? P2(true, t3) : T2(() => Mr(e2, t3), true, t3), null)), v2 = e2, w2 = a2._closedPromise, R2 = () => (r2 ? P2() : T2(() => (function(e3) {
|
|
1988
|
+
const t3 = e3._ownerWritableStream, r3 = t3._state;
|
|
1989
|
+
return At(t3) || "closed" === r3 ? c(void 0) : "errored" === r3 ? d(t3._storedError) : Lt(e3);
|
|
1990
|
+
})(s2)), null), "closed" === v2._state ? R2() : b(w2, R2), At(t2) || "closed" === t2._state) {
|
|
1991
|
+
const t3 = new TypeError("the destination writable stream closed before all data could be piped to it");
|
|
1992
|
+
n2 ? P2(true, t3) : T2(() => Mr(e2, t3), true, t3);
|
|
1993
|
+
}
|
|
1994
|
+
function T2(e3, r3, o3) {
|
|
1995
|
+
function n3() {
|
|
1996
|
+
return h(e3(), () => C2(r3, o3), (e4) => C2(true, e4)), null;
|
|
1997
|
+
}
|
|
1998
|
+
l2._shuttingDown || (l2._shuttingDown = true, "writable" !== t2._state || At(t2) ? n3() : b(l2._waitForWritesToFinish(), n3));
|
|
1999
|
+
}
|
|
2000
|
+
function P2(e3, r3) {
|
|
2001
|
+
l2._shuttingDown || (l2._shuttingDown = true, "writable" !== t2._state || At(t2) ? C2(e3, r3) : b(l2._waitForWritesToFinish(), () => C2(e3, r3)));
|
|
2002
|
+
}
|
|
2003
|
+
function C2(e3, t3) {
|
|
2004
|
+
return Mt(s2), O(a2), void 0 !== i2 && i2.removeEventListener("abort", S2), e3 ? y2(t3) : m2(void 0), null;
|
|
2005
|
+
}
|
|
2006
|
+
p(u((e3, t3) => {
|
|
2007
|
+
!(function r3(o3) {
|
|
2008
|
+
o3 ? e3() : f(g2(), r3, t3);
|
|
2009
|
+
})(false);
|
|
2010
|
+
}));
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
var br = class {
|
|
2014
|
+
constructor(e2) {
|
|
2015
|
+
this._writer = e2, this._shuttingDown = false, this._currentWrite = c(void 0);
|
|
2016
|
+
}
|
|
2017
|
+
_waitForWritesToFinish() {
|
|
2018
|
+
const e2 = this._currentWrite;
|
|
2019
|
+
return f(this._currentWrite, () => e2 !== this._currentWrite ? this._waitForWritesToFinish() : void 0);
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
var _r = class {
|
|
2023
|
+
constructor(e2) {
|
|
2024
|
+
this._state = e2, this._promise = u((e3, t2) => {
|
|
2025
|
+
this._resolvePromise = e3, this._rejectPromise = t2;
|
|
2026
|
+
});
|
|
2027
|
+
}
|
|
2028
|
+
_chunkSteps(t2) {
|
|
2029
|
+
this._state._currentWrite = f(Yt(this._state._writer, t2), void 0, e), this._resolvePromise(false);
|
|
2030
|
+
}
|
|
2031
|
+
_closeSteps() {
|
|
2032
|
+
this._resolvePromise(true);
|
|
2033
|
+
}
|
|
2034
|
+
_errorSteps(e2) {
|
|
2035
|
+
this._rejectPromise(e2);
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
var mr = class {
|
|
2039
|
+
constructor(e2) {
|
|
2040
|
+
this._state = e2;
|
|
2041
|
+
}
|
|
2042
|
+
_chunkSteps(t2) {
|
|
2043
|
+
this._state._currentWrite = f(Yt(this._state._writer, t2), void 0, e);
|
|
2044
|
+
}
|
|
2045
|
+
_closeSteps() {
|
|
2046
|
+
}
|
|
2047
|
+
_errorSteps(e2) {
|
|
2048
|
+
}
|
|
2049
|
+
};
|
|
2050
|
+
function pr(e2, t2, r2) {
|
|
2051
|
+
"errored" === e2._state ? r2(e2._storedError) : _(t2, r2);
|
|
2052
|
+
}
|
|
2053
|
+
var ReadableStreamDefaultController = class {
|
|
2054
|
+
constructor() {
|
|
2055
|
+
throw new TypeError("Illegal constructor");
|
|
2056
|
+
}
|
|
2057
|
+
get desiredSize() {
|
|
2058
|
+
if (!yr(this)) throw Er("desiredSize");
|
|
2059
|
+
return Pr(this);
|
|
2060
|
+
}
|
|
2061
|
+
close() {
|
|
2062
|
+
if (!yr(this)) throw Er("close");
|
|
2063
|
+
if (!Cr(this)) throw new TypeError("The stream is not in a state that permits close");
|
|
2064
|
+
wr(this);
|
|
2065
|
+
}
|
|
2066
|
+
enqueue(e2 = void 0) {
|
|
2067
|
+
if (!yr(this)) throw Er("enqueue");
|
|
2068
|
+
if (!Cr(this)) throw new TypeError("The stream is not in a state that permits enqueue");
|
|
2069
|
+
return Rr(this, e2);
|
|
2070
|
+
}
|
|
2071
|
+
error(e2 = void 0) {
|
|
2072
|
+
if (!yr(this)) throw Er("error");
|
|
2073
|
+
Tr(this, e2);
|
|
2074
|
+
}
|
|
2075
|
+
[T](e2) {
|
|
2076
|
+
qe(this);
|
|
2077
|
+
const t2 = this._cancelAlgorithm(e2);
|
|
2078
|
+
return vr(this), t2;
|
|
2079
|
+
}
|
|
2080
|
+
[P](e2) {
|
|
2081
|
+
const t2 = this._controlledReadableStream;
|
|
2082
|
+
if (this._queue.length > 0) {
|
|
2083
|
+
const r2 = Pe(this);
|
|
2084
|
+
this._closeRequested && 0 === this._queue.length ? (vr(this), Yr(t2)) : Sr(this), e2._chunkSteps(r2);
|
|
2085
|
+
} else U(t2, e2), Sr(this);
|
|
2086
|
+
}
|
|
2087
|
+
[C]() {
|
|
2088
|
+
return this._queue.length > 0;
|
|
2089
|
+
}
|
|
2090
|
+
[q]() {
|
|
2091
|
+
}
|
|
2092
|
+
};
|
|
2093
|
+
function yr(e2) {
|
|
2094
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_controlledReadableStream") && e2 instanceof ReadableStreamDefaultController);
|
|
2095
|
+
}
|
|
2096
|
+
function Sr(e2) {
|
|
2097
|
+
if (!gr(e2)) return;
|
|
2098
|
+
if (e2._pulling) return void (e2._pullAgain = true);
|
|
2099
|
+
e2._pulling = true;
|
|
2100
|
+
h(e2._pullAlgorithm(), () => (e2._pulling = false, e2._pullAgain && (e2._pullAgain = false, Sr(e2)), null), (t2) => (Tr(e2, t2), null));
|
|
2101
|
+
}
|
|
2102
|
+
function gr(e2) {
|
|
2103
|
+
const t2 = e2._controlledReadableStream;
|
|
2104
|
+
if (!Cr(e2)) return false;
|
|
2105
|
+
if (!e2._started) return false;
|
|
2106
|
+
if ($r(t2) && X(t2) > 0) return true;
|
|
2107
|
+
return Pr(e2) > 0;
|
|
2108
|
+
}
|
|
2109
|
+
function vr(e2) {
|
|
2110
|
+
e2._pullAlgorithm = void 0, e2._cancelAlgorithm = void 0, e2._strategySizeAlgorithm = void 0;
|
|
2111
|
+
}
|
|
2112
|
+
function wr(e2) {
|
|
2113
|
+
if (!Cr(e2)) return;
|
|
2114
|
+
const t2 = e2._controlledReadableStream;
|
|
2115
|
+
e2._closeRequested = true, 0 === e2._queue.length && (vr(e2), Yr(t2));
|
|
2116
|
+
}
|
|
2117
|
+
function Rr(e2, t2) {
|
|
2118
|
+
if (!Cr(e2)) return;
|
|
2119
|
+
const r2 = e2._controlledReadableStream;
|
|
2120
|
+
if ($r(r2) && X(r2) > 0) G(r2, t2, false);
|
|
2121
|
+
else {
|
|
2122
|
+
let r3;
|
|
2123
|
+
try {
|
|
2124
|
+
r3 = e2._strategySizeAlgorithm(t2);
|
|
2125
|
+
} catch (t3) {
|
|
2126
|
+
throw Tr(e2, t3), t3;
|
|
2127
|
+
}
|
|
2128
|
+
try {
|
|
2129
|
+
Ce(e2, t2, r3);
|
|
2130
|
+
} catch (t3) {
|
|
2131
|
+
throw Tr(e2, t3), t3;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
Sr(e2);
|
|
2135
|
+
}
|
|
2136
|
+
function Tr(e2, t2) {
|
|
2137
|
+
const r2 = e2._controlledReadableStream;
|
|
2138
|
+
"readable" === r2._state && (qe(e2), vr(e2), xr(r2, t2));
|
|
2139
|
+
}
|
|
2140
|
+
function Pr(e2) {
|
|
2141
|
+
const t2 = e2._controlledReadableStream._state;
|
|
2142
|
+
return "errored" === t2 ? null : "closed" === t2 ? 0 : e2._strategyHWM - e2._queueTotalSize;
|
|
2143
|
+
}
|
|
2144
|
+
function Cr(e2) {
|
|
2145
|
+
const t2 = e2._controlledReadableStream._state;
|
|
2146
|
+
return !e2._closeRequested && "readable" === t2;
|
|
2147
|
+
}
|
|
2148
|
+
function qr(e2, t2, r2, o2, n2, i2, a2) {
|
|
2149
|
+
t2._controlledReadableStream = e2, t2._queue = void 0, t2._queueTotalSize = void 0, qe(t2), t2._started = false, t2._closeRequested = false, t2._pullAgain = false, t2._pulling = false, t2._strategySizeAlgorithm = a2, t2._strategyHWM = i2, t2._pullAlgorithm = o2, t2._cancelAlgorithm = n2, e2._readableStreamController = t2;
|
|
2150
|
+
h(c(r2()), () => (t2._started = true, Sr(t2), null), (e3) => (Tr(t2, e3), null));
|
|
2151
|
+
}
|
|
2152
|
+
function Er(e2) {
|
|
2153
|
+
return new TypeError(`ReadableStreamDefaultController.prototype.${e2} can only be used on a ReadableStreamDefaultController`);
|
|
2154
|
+
}
|
|
2155
|
+
function Wr(e2, t2) {
|
|
2156
|
+
return Oe(e2._readableStreamController) ? (function(e3) {
|
|
2157
|
+
let t3, r2, o2, n2, i2, a2 = V(e3), s2 = false, l2 = false, d2 = false, f2 = false, h2 = false;
|
|
2158
|
+
const b2 = u((e4) => {
|
|
2159
|
+
i2 = e4;
|
|
2160
|
+
});
|
|
2161
|
+
function m2(e4) {
|
|
2162
|
+
_(e4._closedPromise, (t4) => (e4 !== a2 || (Xe(o2._readableStreamController, t4), Xe(n2._readableStreamController, t4), f2 && h2 || i2(void 0)), null));
|
|
2163
|
+
}
|
|
2164
|
+
function p2() {
|
|
2165
|
+
ft(a2) && (O(a2), a2 = V(e3), m2(a2));
|
|
2166
|
+
te(a2, { _chunkSteps: (t4) => {
|
|
2167
|
+
y(() => {
|
|
2168
|
+
l2 = false, d2 = false;
|
|
2169
|
+
const r3 = t4;
|
|
2170
|
+
let a3 = t4;
|
|
2171
|
+
if (!f2 && !h2) try {
|
|
2172
|
+
a3 = Te(t4);
|
|
2173
|
+
} catch (t5) {
|
|
2174
|
+
return Xe(o2._readableStreamController, t5), Xe(n2._readableStreamController, t5), void i2(Mr(e3, t5));
|
|
2175
|
+
}
|
|
2176
|
+
f2 || Ge(o2._readableStreamController, r3), h2 || Ge(n2._readableStreamController, a3), s2 = false, l2 ? g2() : d2 && v2();
|
|
2177
|
+
});
|
|
2178
|
+
}, _closeSteps: () => {
|
|
2179
|
+
s2 = false, f2 || Ue(o2._readableStreamController), h2 || Ue(n2._readableStreamController), o2._readableStreamController._pendingPullIntos.length > 0 && et(o2._readableStreamController, 0), n2._readableStreamController._pendingPullIntos.length > 0 && et(n2._readableStreamController, 0), f2 && h2 || i2(void 0);
|
|
2180
|
+
}, _errorSteps: () => {
|
|
2181
|
+
s2 = false;
|
|
2182
|
+
} });
|
|
2183
|
+
}
|
|
2184
|
+
function S2(t4, r3) {
|
|
2185
|
+
ee(a2) && (O(a2), a2 = at(e3), m2(a2));
|
|
2186
|
+
const u2 = r3 ? n2 : o2, c2 = r3 ? o2 : n2;
|
|
2187
|
+
ht(a2, t4, 1, { _chunkSteps: (t5) => {
|
|
2188
|
+
y(() => {
|
|
2189
|
+
l2 = false, d2 = false;
|
|
2190
|
+
const o3 = r3 ? h2 : f2;
|
|
2191
|
+
if (r3 ? f2 : h2) o3 || tt(u2._readableStreamController, t5);
|
|
2192
|
+
else {
|
|
2193
|
+
let r4;
|
|
2194
|
+
try {
|
|
2195
|
+
r4 = Te(t5);
|
|
2196
|
+
} catch (t6) {
|
|
2197
|
+
return Xe(u2._readableStreamController, t6), Xe(c2._readableStreamController, t6), void i2(Mr(e3, t6));
|
|
2198
|
+
}
|
|
2199
|
+
o3 || tt(u2._readableStreamController, t5), Ge(c2._readableStreamController, r4);
|
|
2200
|
+
}
|
|
2201
|
+
s2 = false, l2 ? g2() : d2 && v2();
|
|
2202
|
+
});
|
|
2203
|
+
}, _closeSteps: (e4) => {
|
|
2204
|
+
s2 = false;
|
|
2205
|
+
const t5 = r3 ? h2 : f2, o3 = r3 ? f2 : h2;
|
|
2206
|
+
t5 || Ue(u2._readableStreamController), o3 || Ue(c2._readableStreamController), void 0 !== e4 && (t5 || tt(u2._readableStreamController, e4), !o3 && c2._readableStreamController._pendingPullIntos.length > 0 && et(c2._readableStreamController, 0)), t5 && o3 || i2(void 0);
|
|
2207
|
+
}, _errorSteps: () => {
|
|
2208
|
+
s2 = false;
|
|
2209
|
+
} });
|
|
2210
|
+
}
|
|
2211
|
+
function g2() {
|
|
2212
|
+
if (s2) return l2 = true, c(void 0);
|
|
2213
|
+
s2 = true;
|
|
2214
|
+
const e4 = Ke(o2._readableStreamController);
|
|
2215
|
+
return null === e4 ? p2() : S2(e4._view, false), c(void 0);
|
|
2216
|
+
}
|
|
2217
|
+
function v2() {
|
|
2218
|
+
if (s2) return d2 = true, c(void 0);
|
|
2219
|
+
s2 = true;
|
|
2220
|
+
const e4 = Ke(n2._readableStreamController);
|
|
2221
|
+
return null === e4 ? p2() : S2(e4._view, true), c(void 0);
|
|
2222
|
+
}
|
|
2223
|
+
function w2(o3) {
|
|
2224
|
+
if (f2 = true, t3 = o3, h2) {
|
|
2225
|
+
const o4 = le([t3, r2]), n3 = Mr(e3, o4);
|
|
2226
|
+
i2(n3);
|
|
2227
|
+
}
|
|
2228
|
+
return b2;
|
|
2229
|
+
}
|
|
2230
|
+
function R2(o3) {
|
|
2231
|
+
if (h2 = true, r2 = o3, f2) {
|
|
2232
|
+
const o4 = le([t3, r2]), n3 = Mr(e3, o4);
|
|
2233
|
+
i2(n3);
|
|
2234
|
+
}
|
|
2235
|
+
return b2;
|
|
2236
|
+
}
|
|
2237
|
+
function T2() {
|
|
2238
|
+
}
|
|
2239
|
+
return o2 = Fr(T2, g2, w2), n2 = Fr(T2, v2, R2), m2(a2), [o2, n2];
|
|
2240
|
+
})(e2) : (function(e3) {
|
|
2241
|
+
const t3 = V(e3);
|
|
2242
|
+
let r2, o2, n2, i2, a2, s2 = false, l2 = false, d2 = false, f2 = false;
|
|
2243
|
+
const h2 = u((e4) => {
|
|
2244
|
+
a2 = e4;
|
|
2245
|
+
});
|
|
2246
|
+
function b2() {
|
|
2247
|
+
if (s2) return l2 = true, c(void 0);
|
|
2248
|
+
s2 = true;
|
|
2249
|
+
return te(t3, { _chunkSteps: (e4) => {
|
|
2250
|
+
y(() => {
|
|
2251
|
+
l2 = false;
|
|
2252
|
+
const t4 = e4, r3 = e4;
|
|
2253
|
+
d2 || Rr(n2._readableStreamController, t4), f2 || Rr(i2._readableStreamController, r3), s2 = false, l2 && b2();
|
|
2254
|
+
});
|
|
2255
|
+
}, _closeSteps: () => {
|
|
2256
|
+
s2 = false, d2 || wr(n2._readableStreamController), f2 || wr(i2._readableStreamController), d2 && f2 || a2(void 0);
|
|
2257
|
+
}, _errorSteps: () => {
|
|
2258
|
+
s2 = false;
|
|
2259
|
+
} }), c(void 0);
|
|
2260
|
+
}
|
|
2261
|
+
function m2(t4) {
|
|
2262
|
+
if (d2 = true, r2 = t4, f2) {
|
|
2263
|
+
const t5 = le([r2, o2]), n3 = Mr(e3, t5);
|
|
2264
|
+
a2(n3);
|
|
2265
|
+
}
|
|
2266
|
+
return h2;
|
|
2267
|
+
}
|
|
2268
|
+
function p2(t4) {
|
|
2269
|
+
if (f2 = true, o2 = t4, d2) {
|
|
2270
|
+
const t5 = le([r2, o2]), n3 = Mr(e3, t5);
|
|
2271
|
+
a2(n3);
|
|
2272
|
+
}
|
|
2273
|
+
return h2;
|
|
2274
|
+
}
|
|
2275
|
+
function S2() {
|
|
2276
|
+
}
|
|
2277
|
+
return n2 = Dr(S2, b2, m2), i2 = Dr(S2, b2, p2), _(t3._closedPromise, (e4) => (Tr(n2._readableStreamController, e4), Tr(i2._readableStreamController, e4), d2 && f2 || a2(void 0), null)), [n2, i2];
|
|
2278
|
+
})(e2);
|
|
2279
|
+
}
|
|
2280
|
+
function Or(r2) {
|
|
2281
|
+
return t(o2 = r2) && void 0 !== o2.getReader ? (function(r3) {
|
|
2282
|
+
let o3;
|
|
2283
|
+
function n2() {
|
|
2284
|
+
let e2;
|
|
2285
|
+
try {
|
|
2286
|
+
e2 = r3.read();
|
|
2287
|
+
} catch (e3) {
|
|
2288
|
+
return d(e3);
|
|
2289
|
+
}
|
|
2290
|
+
return m(e2, (e3) => {
|
|
2291
|
+
if (!t(e3)) throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
|
|
2292
|
+
if (e3.done) wr(o3._readableStreamController);
|
|
2293
|
+
else {
|
|
2294
|
+
const t2 = e3.value;
|
|
2295
|
+
Rr(o3._readableStreamController, t2);
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
function i2(e2) {
|
|
2300
|
+
try {
|
|
2301
|
+
return c(r3.cancel(e2));
|
|
2302
|
+
} catch (e3) {
|
|
2303
|
+
return d(e3);
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
return o3 = Dr(e, n2, i2, 0), o3;
|
|
2307
|
+
})(r2.getReader()) : (function(r3) {
|
|
2308
|
+
let o3;
|
|
2309
|
+
const n2 = me(r3, "async");
|
|
2310
|
+
function i2() {
|
|
2311
|
+
let e2;
|
|
2312
|
+
try {
|
|
2313
|
+
e2 = pe(n2);
|
|
2314
|
+
} catch (e3) {
|
|
2315
|
+
return d(e3);
|
|
2316
|
+
}
|
|
2317
|
+
return m(c(e2), (e3) => {
|
|
2318
|
+
if (!t(e3)) throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
|
|
2319
|
+
if (e3.done) wr(o3._readableStreamController);
|
|
2320
|
+
else {
|
|
2321
|
+
const t2 = e3.value;
|
|
2322
|
+
Rr(o3._readableStreamController, t2);
|
|
2323
|
+
}
|
|
2324
|
+
});
|
|
2325
|
+
}
|
|
2326
|
+
function a2(e2) {
|
|
2327
|
+
const r4 = n2.iterator;
|
|
2328
|
+
let o4;
|
|
2329
|
+
try {
|
|
2330
|
+
o4 = he(r4, "return");
|
|
2331
|
+
} catch (e3) {
|
|
2332
|
+
return d(e3);
|
|
2333
|
+
}
|
|
2334
|
+
if (void 0 === o4) return c(void 0);
|
|
2335
|
+
return m(g(o4, r4, [e2]), (e3) => {
|
|
2336
|
+
if (!t(e3)) throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
return o3 = Dr(e, i2, a2, 0), o3;
|
|
2340
|
+
})(r2);
|
|
2341
|
+
var o2;
|
|
2342
|
+
}
|
|
2343
|
+
function Br(e2, t2, r2) {
|
|
2344
|
+
return I(e2, r2), (r3) => g(e2, t2, [r3]);
|
|
2345
|
+
}
|
|
2346
|
+
function jr(e2, t2, r2) {
|
|
2347
|
+
return I(e2, r2), (r3) => g(e2, t2, [r3]);
|
|
2348
|
+
}
|
|
2349
|
+
function kr(e2, t2, r2) {
|
|
2350
|
+
return I(e2, r2), (r3) => S(e2, t2, [r3]);
|
|
2351
|
+
}
|
|
2352
|
+
function Ar(e2, t2) {
|
|
2353
|
+
if ("bytes" !== (e2 = `${e2}`)) throw new TypeError(`${t2} '${e2}' is not a valid enumeration value for ReadableStreamType`);
|
|
2354
|
+
return e2;
|
|
2355
|
+
}
|
|
2356
|
+
function zr(e2, t2) {
|
|
2357
|
+
L(e2, t2);
|
|
2358
|
+
const r2 = null == e2 ? void 0 : e2.preventAbort, o2 = null == e2 ? void 0 : e2.preventCancel, n2 = null == e2 ? void 0 : e2.preventClose, i2 = null == e2 ? void 0 : e2.signal;
|
|
2359
|
+
return void 0 !== i2 && (function(e3, t3) {
|
|
2360
|
+
if (!(function(e4) {
|
|
2361
|
+
if ("object" != typeof e4 || null === e4) return false;
|
|
2362
|
+
try {
|
|
2363
|
+
return "boolean" == typeof e4.aborted;
|
|
2364
|
+
} catch (e5) {
|
|
2365
|
+
return false;
|
|
2366
|
+
}
|
|
2367
|
+
})(e3)) throw new TypeError(`${t3} is not an AbortSignal.`);
|
|
2368
|
+
})(i2, `${t2} has member 'signal' that`), { preventAbort: Boolean(r2), preventCancel: Boolean(o2), preventClose: Boolean(n2), signal: i2 };
|
|
2369
|
+
}
|
|
2370
|
+
Object.defineProperties(ReadableStreamDefaultController.prototype, { close: { enumerable: true }, enqueue: { enumerable: true }, error: { enumerable: true }, desiredSize: { enumerable: true } }), 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, { value: "ReadableStreamDefaultController", configurable: true });
|
|
2371
|
+
var ReadableStream2 = class {
|
|
2372
|
+
constructor(e2 = {}, t2 = {}) {
|
|
2373
|
+
void 0 === e2 ? e2 = null : $(e2, "First parameter");
|
|
2374
|
+
const r2 = yt(t2, "Second parameter"), o2 = (function(e3, t3) {
|
|
2375
|
+
L(e3, t3);
|
|
2376
|
+
const r3 = e3, o3 = null == r3 ? void 0 : r3.autoAllocateChunkSize, n2 = null == r3 ? void 0 : r3.cancel, i2 = null == r3 ? void 0 : r3.pull, a2 = null == r3 ? void 0 : r3.start, s2 = null == r3 ? void 0 : r3.type;
|
|
2377
|
+
return { autoAllocateChunkSize: void 0 === o3 ? void 0 : N(o3, `${t3} has member 'autoAllocateChunkSize' that`), cancel: void 0 === n2 ? void 0 : Br(n2, r3, `${t3} has member 'cancel' that`), pull: void 0 === i2 ? void 0 : jr(i2, r3, `${t3} has member 'pull' that`), start: void 0 === a2 ? void 0 : kr(a2, r3, `${t3} has member 'start' that`), type: void 0 === s2 ? void 0 : Ar(s2, `${t3} has member 'type' that`) };
|
|
2378
|
+
})(e2, "First parameter");
|
|
2379
|
+
if (Lr(this), "bytes" === o2.type) {
|
|
2380
|
+
if (void 0 !== r2.size) throw new RangeError("The strategy for a byte stream cannot have a size function");
|
|
2381
|
+
!(function(e3, t3, r3) {
|
|
2382
|
+
const o3 = Object.create(ReadableByteStreamController.prototype);
|
|
2383
|
+
let n2, i2, a2;
|
|
2384
|
+
n2 = void 0 !== t3.start ? () => t3.start(o3) : () => {
|
|
2385
|
+
}, i2 = void 0 !== t3.pull ? () => t3.pull(o3) : () => c(void 0), a2 = void 0 !== t3.cancel ? (e4) => t3.cancel(e4) : () => c(void 0);
|
|
2386
|
+
const s2 = t3.autoAllocateChunkSize;
|
|
2387
|
+
if (0 === s2) throw new TypeError("autoAllocateChunkSize must be greater than 0");
|
|
2388
|
+
rt(e3, o3, n2, i2, a2, r3, s2);
|
|
2389
|
+
})(this, o2, mt(r2, 0));
|
|
2390
|
+
} else {
|
|
2391
|
+
const e3 = pt(r2);
|
|
2392
|
+
!(function(e4, t3, r3, o3) {
|
|
2393
|
+
const n2 = Object.create(ReadableStreamDefaultController.prototype);
|
|
2394
|
+
let i2, a2, s2;
|
|
2395
|
+
i2 = void 0 !== t3.start ? () => t3.start(n2) : () => {
|
|
2396
|
+
}, a2 = void 0 !== t3.pull ? () => t3.pull(n2) : () => c(void 0), s2 = void 0 !== t3.cancel ? (e5) => t3.cancel(e5) : () => c(void 0), qr(e4, n2, i2, a2, s2, r3, o3);
|
|
2397
|
+
})(this, o2, mt(r2, 1), e3);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
get locked() {
|
|
2401
|
+
if (!Ir(this)) throw Qr("locked");
|
|
2402
|
+
return $r(this);
|
|
2403
|
+
}
|
|
2404
|
+
cancel(e2 = void 0) {
|
|
2405
|
+
return Ir(this) ? $r(this) ? d(new TypeError("Cannot cancel a stream that already has a reader")) : Mr(this, e2) : d(Qr("cancel"));
|
|
2406
|
+
}
|
|
2407
|
+
getReader(e2 = void 0) {
|
|
2408
|
+
if (!Ir(this)) throw Qr("getReader");
|
|
2409
|
+
return void 0 === (function(e3, t2) {
|
|
2410
|
+
L(e3, t2);
|
|
2411
|
+
const r2 = null == e3 ? void 0 : e3.mode;
|
|
2412
|
+
return { mode: void 0 === r2 ? void 0 : it(r2, `${t2} has member 'mode' that`) };
|
|
2413
|
+
})(e2, "First parameter").mode ? V(this) : at(this);
|
|
2414
|
+
}
|
|
2415
|
+
pipeThrough(e2, t2 = {}) {
|
|
2416
|
+
if (!Ir(this)) throw Qr("pipeThrough");
|
|
2417
|
+
M(e2, 1, "pipeThrough");
|
|
2418
|
+
const r2 = (function(e3, t3) {
|
|
2419
|
+
L(e3, t3);
|
|
2420
|
+
const r3 = null == e3 ? void 0 : e3.readable;
|
|
2421
|
+
Y(r3, "readable", "ReadableWritablePair"), H(r3, `${t3} has member 'readable' that`);
|
|
2422
|
+
const o3 = null == e3 ? void 0 : e3.writable;
|
|
2423
|
+
return Y(o3, "writable", "ReadableWritablePair"), Tt(o3, `${t3} has member 'writable' that`), { readable: r3, writable: o3 };
|
|
2424
|
+
})(e2, "First parameter"), o2 = zr(t2, "Second parameter");
|
|
2425
|
+
if ($r(this)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
|
|
2426
|
+
if (Et(r2.writable)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
|
|
2427
|
+
return p(hr(this, r2.writable, o2.preventClose, o2.preventAbort, o2.preventCancel, o2.signal)), r2.readable;
|
|
2428
|
+
}
|
|
2429
|
+
pipeTo(e2, t2 = {}) {
|
|
2430
|
+
if (!Ir(this)) return d(Qr("pipeTo"));
|
|
2431
|
+
if (void 0 === e2) return d("Parameter 1 is required in 'pipeTo'.");
|
|
2432
|
+
if (!qt(e2)) return d(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
|
|
2433
|
+
let r2;
|
|
2434
|
+
try {
|
|
2435
|
+
r2 = zr(t2, "Second parameter");
|
|
2436
|
+
} catch (e3) {
|
|
2437
|
+
return d(e3);
|
|
2438
|
+
}
|
|
2439
|
+
return $r(this) ? d(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : Et(e2) ? d(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : hr(this, e2, r2.preventClose, r2.preventAbort, r2.preventCancel, r2.signal);
|
|
2440
|
+
}
|
|
2441
|
+
tee() {
|
|
2442
|
+
if (!Ir(this)) throw Qr("tee");
|
|
2443
|
+
return le(Wr(this));
|
|
2444
|
+
}
|
|
2445
|
+
values(e2 = void 0) {
|
|
2446
|
+
if (!Ir(this)) throw Qr("values");
|
|
2447
|
+
return (function(e3, t2) {
|
|
2448
|
+
const r2 = V(e3), o2 = new ye(r2, t2), n2 = Object.create(ge);
|
|
2449
|
+
return n2._asyncIteratorImpl = o2, n2;
|
|
2450
|
+
})(this, (function(e3, t2) {
|
|
2451
|
+
L(e3, t2);
|
|
2452
|
+
const r2 = null == e3 ? void 0 : e3.preventCancel;
|
|
2453
|
+
return { preventCancel: Boolean(r2) };
|
|
2454
|
+
})(e2, "First parameter").preventCancel);
|
|
2455
|
+
}
|
|
2456
|
+
[_e](e2) {
|
|
2457
|
+
return this.values(e2);
|
|
2458
|
+
}
|
|
2459
|
+
static from(e2) {
|
|
2460
|
+
return Or(e2);
|
|
2461
|
+
}
|
|
2462
|
+
};
|
|
2463
|
+
function Dr(e2, t2, r2, o2 = 1, n2 = () => 1) {
|
|
2464
|
+
const i2 = Object.create(ReadableStream2.prototype);
|
|
2465
|
+
Lr(i2);
|
|
2466
|
+
return qr(i2, Object.create(ReadableStreamDefaultController.prototype), e2, t2, r2, o2, n2), i2;
|
|
2467
|
+
}
|
|
2468
|
+
function Fr(e2, t2, r2) {
|
|
2469
|
+
const o2 = Object.create(ReadableStream2.prototype);
|
|
2470
|
+
Lr(o2);
|
|
2471
|
+
return rt(o2, Object.create(ReadableByteStreamController.prototype), e2, t2, r2, 0, void 0), o2;
|
|
2472
|
+
}
|
|
2473
|
+
function Lr(e2) {
|
|
2474
|
+
e2._state = "readable", e2._reader = void 0, e2._storedError = void 0, e2._disturbed = false;
|
|
2475
|
+
}
|
|
2476
|
+
function Ir(e2) {
|
|
2477
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_readableStreamController") && e2 instanceof ReadableStream2);
|
|
2478
|
+
}
|
|
2479
|
+
function $r(e2) {
|
|
2480
|
+
return void 0 !== e2._reader;
|
|
2481
|
+
}
|
|
2482
|
+
function Mr(t2, r2) {
|
|
2483
|
+
if (t2._disturbed = true, "closed" === t2._state) return c(void 0);
|
|
2484
|
+
if ("errored" === t2._state) return d(t2._storedError);
|
|
2485
|
+
Yr(t2);
|
|
2486
|
+
const o2 = t2._reader;
|
|
2487
|
+
if (void 0 !== o2 && ft(o2)) {
|
|
2488
|
+
const e2 = o2._readIntoRequests;
|
|
2489
|
+
o2._readIntoRequests = new v(), e2.forEach((e3) => {
|
|
2490
|
+
e3._closeSteps(void 0);
|
|
2491
|
+
});
|
|
2492
|
+
}
|
|
2493
|
+
return m(t2._readableStreamController[T](r2), e);
|
|
2494
|
+
}
|
|
2495
|
+
function Yr(e2) {
|
|
2496
|
+
e2._state = "closed";
|
|
2497
|
+
const t2 = e2._reader;
|
|
2498
|
+
if (void 0 !== t2 && (z(t2), ee(t2))) {
|
|
2499
|
+
const e3 = t2._readRequests;
|
|
2500
|
+
t2._readRequests = new v(), e3.forEach((e4) => {
|
|
2501
|
+
e4._closeSteps();
|
|
2502
|
+
});
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
function xr(e2, t2) {
|
|
2506
|
+
e2._state = "errored", e2._storedError = t2;
|
|
2507
|
+
const r2 = e2._reader;
|
|
2508
|
+
void 0 !== r2 && (A(r2, t2), ee(r2) ? oe(r2, t2) : bt(r2, t2));
|
|
2509
|
+
}
|
|
2510
|
+
function Qr(e2) {
|
|
2511
|
+
return new TypeError(`ReadableStream.prototype.${e2} can only be used on a ReadableStream`);
|
|
2512
|
+
}
|
|
2513
|
+
function Nr(e2, t2) {
|
|
2514
|
+
L(e2, t2);
|
|
2515
|
+
const r2 = null == e2 ? void 0 : e2.highWaterMark;
|
|
2516
|
+
return Y(r2, "highWaterMark", "QueuingStrategyInit"), { highWaterMark: x(r2) };
|
|
2517
|
+
}
|
|
2518
|
+
Object.defineProperties(ReadableStream2, { from: { enumerable: true } }), Object.defineProperties(ReadableStream2.prototype, { cancel: { enumerable: true }, getReader: { enumerable: true }, pipeThrough: { enumerable: true }, pipeTo: { enumerable: true }, tee: { enumerable: true }, values: { enumerable: true }, locked: { enumerable: true } }), o(ReadableStream2.from, "from"), o(ReadableStream2.prototype.cancel, "cancel"), o(ReadableStream2.prototype.getReader, "getReader"), o(ReadableStream2.prototype.pipeThrough, "pipeThrough"), o(ReadableStream2.prototype.pipeTo, "pipeTo"), o(ReadableStream2.prototype.tee, "tee"), o(ReadableStream2.prototype.values, "values"), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ReadableStream2.prototype, Symbol.toStringTag, { value: "ReadableStream", configurable: true }), Object.defineProperty(ReadableStream2.prototype, _e, { value: ReadableStream2.prototype.values, writable: true, configurable: true });
|
|
2519
|
+
var Hr = (e2) => e2.byteLength;
|
|
2520
|
+
o(Hr, "size");
|
|
2521
|
+
var ByteLengthQueuingStrategy = class {
|
|
2522
|
+
constructor(e2) {
|
|
2523
|
+
M(e2, 1, "ByteLengthQueuingStrategy"), e2 = Nr(e2, "First parameter"), this._byteLengthQueuingStrategyHighWaterMark = e2.highWaterMark;
|
|
2524
|
+
}
|
|
2525
|
+
get highWaterMark() {
|
|
2526
|
+
if (!Ur(this)) throw Vr("highWaterMark");
|
|
2527
|
+
return this._byteLengthQueuingStrategyHighWaterMark;
|
|
2528
|
+
}
|
|
2529
|
+
get size() {
|
|
2530
|
+
if (!Ur(this)) throw Vr("size");
|
|
2531
|
+
return Hr;
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
function Vr(e2) {
|
|
2535
|
+
return new TypeError(`ByteLengthQueuingStrategy.prototype.${e2} can only be used on a ByteLengthQueuingStrategy`);
|
|
2536
|
+
}
|
|
2537
|
+
function Ur(e2) {
|
|
2538
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_byteLengthQueuingStrategyHighWaterMark") && e2 instanceof ByteLengthQueuingStrategy);
|
|
2539
|
+
}
|
|
2540
|
+
Object.defineProperties(ByteLengthQueuingStrategy.prototype, { highWaterMark: { enumerable: true }, size: { enumerable: true } }), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, { value: "ByteLengthQueuingStrategy", configurable: true });
|
|
2541
|
+
var Gr = () => 1;
|
|
2542
|
+
o(Gr, "size");
|
|
2543
|
+
var CountQueuingStrategy = class {
|
|
2544
|
+
constructor(e2) {
|
|
2545
|
+
M(e2, 1, "CountQueuingStrategy"), e2 = Nr(e2, "First parameter"), this._countQueuingStrategyHighWaterMark = e2.highWaterMark;
|
|
2546
|
+
}
|
|
2547
|
+
get highWaterMark() {
|
|
2548
|
+
if (!Jr(this)) throw Xr("highWaterMark");
|
|
2549
|
+
return this._countQueuingStrategyHighWaterMark;
|
|
2550
|
+
}
|
|
2551
|
+
get size() {
|
|
2552
|
+
if (!Jr(this)) throw Xr("size");
|
|
2553
|
+
return Gr;
|
|
2554
|
+
}
|
|
2555
|
+
};
|
|
2556
|
+
function Xr(e2) {
|
|
2557
|
+
return new TypeError(`CountQueuingStrategy.prototype.${e2} can only be used on a CountQueuingStrategy`);
|
|
2558
|
+
}
|
|
2559
|
+
function Jr(e2) {
|
|
2560
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_countQueuingStrategyHighWaterMark") && e2 instanceof CountQueuingStrategy);
|
|
2561
|
+
}
|
|
2562
|
+
function Kr(e2, t2, r2) {
|
|
2563
|
+
return I(e2, r2), (r3) => g(e2, t2, [r3]);
|
|
2564
|
+
}
|
|
2565
|
+
function Zr(e2, t2, r2) {
|
|
2566
|
+
return I(e2, r2), (r3) => S(e2, t2, [r3]);
|
|
2567
|
+
}
|
|
2568
|
+
function eo(e2, t2, r2) {
|
|
2569
|
+
return I(e2, r2), (r3, o2) => g(e2, t2, [r3, o2]);
|
|
2570
|
+
}
|
|
2571
|
+
function to(e2, t2, r2) {
|
|
2572
|
+
return I(e2, r2), (r3) => g(e2, t2, [r3]);
|
|
2573
|
+
}
|
|
2574
|
+
Object.defineProperties(CountQueuingStrategy.prototype, { highWaterMark: { enumerable: true }, size: { enumerable: true } }), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, { value: "CountQueuingStrategy", configurable: true });
|
|
2575
|
+
var TransformStream = class {
|
|
2576
|
+
constructor(e2 = {}, t2 = {}, r2 = {}) {
|
|
2577
|
+
void 0 === e2 && (e2 = null);
|
|
2578
|
+
const o2 = yt(t2, "Second parameter"), n2 = yt(r2, "Third parameter"), i2 = (function(e3, t3) {
|
|
2579
|
+
L(e3, t3);
|
|
2580
|
+
const r3 = null == e3 ? void 0 : e3.cancel, o3 = null == e3 ? void 0 : e3.flush, n3 = null == e3 ? void 0 : e3.readableType, i3 = null == e3 ? void 0 : e3.start, a3 = null == e3 ? void 0 : e3.transform, s3 = null == e3 ? void 0 : e3.writableType;
|
|
2581
|
+
return { cancel: void 0 === r3 ? void 0 : to(r3, e3, `${t3} has member 'cancel' that`), flush: void 0 === o3 ? void 0 : Kr(o3, e3, `${t3} has member 'flush' that`), readableType: n3, start: void 0 === i3 ? void 0 : Zr(i3, e3, `${t3} has member 'start' that`), transform: void 0 === a3 ? void 0 : eo(a3, e3, `${t3} has member 'transform' that`), writableType: s3 };
|
|
2582
|
+
})(e2, "First parameter");
|
|
2583
|
+
if (void 0 !== i2.readableType) throw new RangeError("Invalid readableType specified");
|
|
2584
|
+
if (void 0 !== i2.writableType) throw new RangeError("Invalid writableType specified");
|
|
2585
|
+
const a2 = mt(n2, 0), s2 = pt(n2), l2 = mt(o2, 1), f2 = pt(o2);
|
|
2586
|
+
let b2;
|
|
2587
|
+
!(function(e3, t3, r3, o3, n3, i3) {
|
|
2588
|
+
function a3() {
|
|
2589
|
+
return t3;
|
|
2590
|
+
}
|
|
2591
|
+
function s3(t4) {
|
|
2592
|
+
return (function(e4, t5) {
|
|
2593
|
+
const r4 = e4._transformStreamController;
|
|
2594
|
+
if (e4._backpressure) {
|
|
2595
|
+
return m(e4._backpressureChangePromise, () => {
|
|
2596
|
+
const o4 = e4._writable;
|
|
2597
|
+
if ("erroring" === o4._state) throw o4._storedError;
|
|
2598
|
+
return co(r4, t5);
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
return co(r4, t5);
|
|
2602
|
+
})(e3, t4);
|
|
2603
|
+
}
|
|
2604
|
+
function l3(t4) {
|
|
2605
|
+
return (function(e4, t5) {
|
|
2606
|
+
const r4 = e4._transformStreamController;
|
|
2607
|
+
if (void 0 !== r4._finishPromise) return r4._finishPromise;
|
|
2608
|
+
const o4 = e4._readable;
|
|
2609
|
+
r4._finishPromise = u((e5, t6) => {
|
|
2610
|
+
r4._finishPromise_resolve = e5, r4._finishPromise_reject = t6;
|
|
2611
|
+
});
|
|
2612
|
+
const n4 = r4._cancelAlgorithm(t5);
|
|
2613
|
+
return lo(r4), h(n4, () => ("errored" === o4._state ? bo(r4, o4._storedError) : (Tr(o4._readableStreamController, t5), ho(r4)), null), (e5) => (Tr(o4._readableStreamController, e5), bo(r4, e5), null)), r4._finishPromise;
|
|
2614
|
+
})(e3, t4);
|
|
2615
|
+
}
|
|
2616
|
+
function c2() {
|
|
2617
|
+
return (function(e4) {
|
|
2618
|
+
const t4 = e4._transformStreamController;
|
|
2619
|
+
if (void 0 !== t4._finishPromise) return t4._finishPromise;
|
|
2620
|
+
const r4 = e4._readable;
|
|
2621
|
+
t4._finishPromise = u((e5, r5) => {
|
|
2622
|
+
t4._finishPromise_resolve = e5, t4._finishPromise_reject = r5;
|
|
2623
|
+
});
|
|
2624
|
+
const o4 = t4._flushAlgorithm();
|
|
2625
|
+
return lo(t4), h(o4, () => ("errored" === r4._state ? bo(t4, r4._storedError) : (wr(r4._readableStreamController), ho(t4)), null), (e5) => (Tr(r4._readableStreamController, e5), bo(t4, e5), null)), t4._finishPromise;
|
|
2626
|
+
})(e3);
|
|
2627
|
+
}
|
|
2628
|
+
function d2() {
|
|
2629
|
+
return (function(e4) {
|
|
2630
|
+
return ao(e4, false), e4._backpressureChangePromise;
|
|
2631
|
+
})(e3);
|
|
2632
|
+
}
|
|
2633
|
+
function f3(t4) {
|
|
2634
|
+
return (function(e4, t5) {
|
|
2635
|
+
const r4 = e4._transformStreamController;
|
|
2636
|
+
if (void 0 !== r4._finishPromise) return r4._finishPromise;
|
|
2637
|
+
const o4 = e4._writable;
|
|
2638
|
+
r4._finishPromise = u((e5, t6) => {
|
|
2639
|
+
r4._finishPromise_resolve = e5, r4._finishPromise_reject = t6;
|
|
2640
|
+
});
|
|
2641
|
+
const n4 = r4._cancelAlgorithm(t5);
|
|
2642
|
+
return lo(r4), h(n4, () => ("errored" === o4._state ? bo(r4, o4._storedError) : (Gt(o4._writableStreamController, t5), io(e4), ho(r4)), null), (t6) => (Gt(o4._writableStreamController, t6), io(e4), bo(r4, t6), null)), r4._finishPromise;
|
|
2643
|
+
})(e3, t4);
|
|
2644
|
+
}
|
|
2645
|
+
e3._writable = (function(e4, t4, r4, o4, n4 = 1, i4 = () => 1) {
|
|
2646
|
+
const a4 = Object.create(WritableStream.prototype);
|
|
2647
|
+
return Ct(a4), Nt(a4, Object.create(WritableStreamDefaultController.prototype), e4, t4, r4, o4, n4, i4), a4;
|
|
2648
|
+
})(a3, s3, c2, l3, r3, o3), e3._readable = Dr(a3, d2, f3, n3, i3), e3._backpressure = void 0, e3._backpressureChangePromise = void 0, e3._backpressureChangePromise_resolve = void 0, ao(e3, true), e3._transformStreamController = void 0;
|
|
2649
|
+
})(this, u((e3) => {
|
|
2650
|
+
b2 = e3;
|
|
2651
|
+
}), l2, f2, a2, s2), (function(e3, t3) {
|
|
2652
|
+
const r3 = Object.create(TransformStreamDefaultController.prototype);
|
|
2653
|
+
let o3, n3, i3;
|
|
2654
|
+
o3 = void 0 !== t3.transform ? (e4) => t3.transform(e4, r3) : (e4) => {
|
|
2655
|
+
try {
|
|
2656
|
+
return uo(r3, e4), c(void 0);
|
|
2657
|
+
} catch (e5) {
|
|
2658
|
+
return d(e5);
|
|
2659
|
+
}
|
|
2660
|
+
};
|
|
2661
|
+
n3 = void 0 !== t3.flush ? () => t3.flush(r3) : () => c(void 0);
|
|
2662
|
+
i3 = void 0 !== t3.cancel ? (e4) => t3.cancel(e4) : () => c(void 0);
|
|
2663
|
+
!(function(e4, t4, r4, o4, n4) {
|
|
2664
|
+
t4._controlledTransformStream = e4, e4._transformStreamController = t4, t4._transformAlgorithm = r4, t4._flushAlgorithm = o4, t4._cancelAlgorithm = n4, t4._finishPromise = void 0, t4._finishPromise_resolve = void 0, t4._finishPromise_reject = void 0;
|
|
2665
|
+
})(e3, r3, o3, n3, i3);
|
|
2666
|
+
})(this, i2), void 0 !== i2.start ? b2(i2.start(this._transformStreamController)) : b2(void 0);
|
|
2667
|
+
}
|
|
2668
|
+
get readable() {
|
|
2669
|
+
if (!ro(this)) throw _o("readable");
|
|
2670
|
+
return this._readable;
|
|
2671
|
+
}
|
|
2672
|
+
get writable() {
|
|
2673
|
+
if (!ro(this)) throw _o("writable");
|
|
2674
|
+
return this._writable;
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
function ro(e2) {
|
|
2678
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_transformStreamController") && e2 instanceof TransformStream);
|
|
2679
|
+
}
|
|
2680
|
+
function oo(e2, t2) {
|
|
2681
|
+
Tr(e2._readable._readableStreamController, t2), no(e2, t2);
|
|
2682
|
+
}
|
|
2683
|
+
function no(e2, t2) {
|
|
2684
|
+
lo(e2._transformStreamController), Gt(e2._writable._writableStreamController, t2), io(e2);
|
|
2685
|
+
}
|
|
2686
|
+
function io(e2) {
|
|
2687
|
+
e2._backpressure && ao(e2, false);
|
|
2688
|
+
}
|
|
2689
|
+
function ao(e2, t2) {
|
|
2690
|
+
void 0 !== e2._backpressureChangePromise && e2._backpressureChangePromise_resolve(), e2._backpressureChangePromise = u((t3) => {
|
|
2691
|
+
e2._backpressureChangePromise_resolve = t3;
|
|
2692
|
+
}), e2._backpressure = t2;
|
|
2693
|
+
}
|
|
2694
|
+
Object.defineProperties(TransformStream.prototype, { readable: { enumerable: true }, writable: { enumerable: true } }), "symbol" == typeof Symbol.toStringTag && Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, { value: "TransformStream", configurable: true });
|
|
2695
|
+
var TransformStreamDefaultController = class {
|
|
2696
|
+
constructor() {
|
|
2697
|
+
throw new TypeError("Illegal constructor");
|
|
2698
|
+
}
|
|
2699
|
+
get desiredSize() {
|
|
2700
|
+
if (!so(this)) throw fo("desiredSize");
|
|
2701
|
+
return Pr(this._controlledTransformStream._readable._readableStreamController);
|
|
2702
|
+
}
|
|
2703
|
+
enqueue(e2 = void 0) {
|
|
2704
|
+
if (!so(this)) throw fo("enqueue");
|
|
2705
|
+
uo(this, e2);
|
|
2706
|
+
}
|
|
2707
|
+
error(e2 = void 0) {
|
|
2708
|
+
if (!so(this)) throw fo("error");
|
|
2709
|
+
var t2;
|
|
2710
|
+
t2 = e2, oo(this._controlledTransformStream, t2);
|
|
2711
|
+
}
|
|
2712
|
+
terminate() {
|
|
2713
|
+
if (!so(this)) throw fo("terminate");
|
|
2714
|
+
!(function(e2) {
|
|
2715
|
+
const t2 = e2._controlledTransformStream;
|
|
2716
|
+
wr(t2._readable._readableStreamController);
|
|
2717
|
+
const r2 = new TypeError("TransformStream terminated");
|
|
2718
|
+
no(t2, r2);
|
|
2719
|
+
})(this);
|
|
2720
|
+
}
|
|
2721
|
+
};
|
|
2722
|
+
function so(e2) {
|
|
2723
|
+
return !!t(e2) && (!!Object.prototype.hasOwnProperty.call(e2, "_controlledTransformStream") && e2 instanceof TransformStreamDefaultController);
|
|
2724
|
+
}
|
|
2725
|
+
function lo(e2) {
|
|
2726
|
+
e2._transformAlgorithm = void 0, e2._flushAlgorithm = void 0, e2._cancelAlgorithm = void 0;
|
|
2727
|
+
}
|
|
2728
|
+
function uo(e2, t2) {
|
|
2729
|
+
const r2 = e2._controlledTransformStream, o2 = r2._readable._readableStreamController;
|
|
2730
|
+
if (!Cr(o2)) throw new TypeError("Readable side is not in a state that permits enqueue");
|
|
2731
|
+
try {
|
|
2732
|
+
Rr(o2, t2);
|
|
2733
|
+
} catch (e3) {
|
|
2734
|
+
throw no(r2, e3), r2._readable._storedError;
|
|
2735
|
+
}
|
|
2736
|
+
const n2 = (function(e3) {
|
|
2737
|
+
return !gr(e3);
|
|
2738
|
+
})(o2);
|
|
2739
|
+
n2 !== r2._backpressure && ao(r2, true);
|
|
2740
|
+
}
|
|
2741
|
+
function co(e2, t2) {
|
|
2742
|
+
return m(e2._transformAlgorithm(t2), void 0, (t3) => {
|
|
2743
|
+
throw oo(e2._controlledTransformStream, t3), t3;
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
function fo(e2) {
|
|
2747
|
+
return new TypeError(`TransformStreamDefaultController.prototype.${e2} can only be used on a TransformStreamDefaultController`);
|
|
2748
|
+
}
|
|
2749
|
+
function ho(e2) {
|
|
2750
|
+
void 0 !== e2._finishPromise_resolve && (e2._finishPromise_resolve(), e2._finishPromise_resolve = void 0, e2._finishPromise_reject = void 0);
|
|
2751
|
+
}
|
|
2752
|
+
function bo(e2, t2) {
|
|
2753
|
+
void 0 !== e2._finishPromise_reject && (p(e2._finishPromise), e2._finishPromise_reject(t2), e2._finishPromise_resolve = void 0, e2._finishPromise_reject = void 0);
|
|
2754
|
+
}
|
|
2755
|
+
function _o(e2) {
|
|
2756
|
+
return new TypeError(`TransformStream.prototype.${e2} can only be used on a TransformStream`);
|
|
2757
|
+
}
|
|
2758
|
+
Object.defineProperties(TransformStreamDefaultController.prototype, { enqueue: { enumerable: true }, error: { enumerable: true }, terminate: { enumerable: true }, desiredSize: { enumerable: true } }), 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, { value: "TransformStreamDefaultController", configurable: true });
|
|
2759
|
+
|
|
2760
|
+
// _build/lib/stream.js
|
|
2761
|
+
globalThis.ReadableStream = ReadableStream2;
|
|
2762
|
+
|
|
2763
|
+
// _build/lib/http-common.js
|
|
2764
|
+
function _concat(parts) {
|
|
2765
|
+
if (parts.length === 0)
|
|
2766
|
+
return new Uint8Array(0);
|
|
2767
|
+
let totalLen = 0;
|
|
2768
|
+
for (const p2 of parts)
|
|
2769
|
+
totalLen += p2.length;
|
|
2770
|
+
const result = new Uint8Array(totalLen);
|
|
2771
|
+
let offset = 0;
|
|
2772
|
+
for (const p2 of parts) {
|
|
2773
|
+
result.set(p2, offset);
|
|
2774
|
+
offset += p2.length;
|
|
2775
|
+
}
|
|
2776
|
+
return result;
|
|
2777
|
+
}
|
|
2778
|
+
function _toReadableStream(body) {
|
|
2779
|
+
if (body instanceof ReadableStream)
|
|
2780
|
+
return body;
|
|
2781
|
+
const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body instanceof ArrayBuffer ? new Uint8Array(body) : new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
|
|
2782
|
+
return new ReadableStream({
|
|
2783
|
+
start(ctrl) {
|
|
2784
|
+
ctrl.enqueue(bytes);
|
|
2785
|
+
ctrl.close();
|
|
2786
|
+
}
|
|
2787
|
+
});
|
|
2788
|
+
}
|
|
2789
|
+
async function _readStream(stream) {
|
|
2790
|
+
const reader = stream.getReader();
|
|
2791
|
+
const chunks = [];
|
|
2792
|
+
while (true) {
|
|
2793
|
+
const { done, value } = await reader.read();
|
|
2794
|
+
if (done)
|
|
2795
|
+
break;
|
|
2796
|
+
chunks.push(value);
|
|
2797
|
+
}
|
|
2798
|
+
return _concat(chunks);
|
|
2799
|
+
}
|
|
2800
|
+
var HeadersImpl = class _HeadersImpl {
|
|
2801
|
+
_headers = [];
|
|
2802
|
+
constructor(init) {
|
|
2803
|
+
if (init) {
|
|
2804
|
+
if (init instanceof _HeadersImpl) {
|
|
2805
|
+
this._headers = [...init._headers];
|
|
2806
|
+
} else if (Array.isArray(init)) {
|
|
2807
|
+
this._headers = init.flatMap(([k2, v2]) => [k2.toLowerCase(), v2]);
|
|
2808
|
+
} else if (typeof init === "object") {
|
|
2809
|
+
this._headers = Object.entries(init).flatMap(([k2, v2]) => [k2.toLowerCase(), v2]);
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
append(name, value) {
|
|
2814
|
+
this._headers.push(name.toLowerCase(), value);
|
|
2815
|
+
}
|
|
2816
|
+
delete(name) {
|
|
2817
|
+
const key = name.toLowerCase();
|
|
2818
|
+
const h2 = this._headers;
|
|
2819
|
+
let i2 = h2.length - 2;
|
|
2820
|
+
while (i2 >= 0) {
|
|
2821
|
+
if (h2[i2] === key) {
|
|
2822
|
+
h2.splice(i2, 2);
|
|
2823
|
+
i2 -= 2;
|
|
2824
|
+
} else
|
|
2825
|
+
i2 -= 2;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
get(name) {
|
|
2829
|
+
const key = name.toLowerCase();
|
|
2830
|
+
const matches = [...this.entries()].filter(([k2]) => k2 === key).map(([, v2]) => v2);
|
|
2831
|
+
return matches.length ? matches.join(", ") : null;
|
|
2832
|
+
}
|
|
2833
|
+
has(name) {
|
|
2834
|
+
return [...this.keys()].includes(name.toLowerCase());
|
|
2835
|
+
}
|
|
2836
|
+
set(name, value) {
|
|
2837
|
+
const key = name.toLowerCase();
|
|
2838
|
+
const h2 = this._headers;
|
|
2839
|
+
let found = false;
|
|
2840
|
+
let i2 = h2.length - 2;
|
|
2841
|
+
while (i2 >= 0) {
|
|
2842
|
+
if (h2[i2] === key) {
|
|
2843
|
+
if (!found) {
|
|
2844
|
+
h2[i2 + 1] = value;
|
|
2845
|
+
found = true;
|
|
2846
|
+
} else {
|
|
2847
|
+
h2.splice(i2, 2);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
i2 -= 2;
|
|
2851
|
+
}
|
|
2852
|
+
if (!found)
|
|
2853
|
+
h2.push(key, value);
|
|
2854
|
+
}
|
|
2855
|
+
forEach(callback) {
|
|
2856
|
+
for (const [name, value] of this) {
|
|
2857
|
+
callback(value, name, this);
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
*entries() {
|
|
2861
|
+
const h2 = this._headers;
|
|
2862
|
+
for (let i2 = 0; i2 < h2.length; i2 += 2) {
|
|
2863
|
+
yield [h2[i2], h2[i2 + 1]];
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
*keys() {
|
|
2867
|
+
for (const [k2] of this)
|
|
2868
|
+
yield k2;
|
|
2869
|
+
}
|
|
2870
|
+
*values() {
|
|
2871
|
+
for (const [, v2] of this)
|
|
2872
|
+
yield v2;
|
|
2873
|
+
}
|
|
2874
|
+
[Symbol.iterator]() {
|
|
2875
|
+
return this.entries();
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
var RequestImpl = class _RequestImpl {
|
|
2879
|
+
url;
|
|
2880
|
+
method;
|
|
2881
|
+
headers;
|
|
2882
|
+
_body;
|
|
2883
|
+
redirect;
|
|
2884
|
+
timeout;
|
|
2885
|
+
maxRedirects;
|
|
2886
|
+
_bodyConsumed = false;
|
|
2887
|
+
integrity = "";
|
|
2888
|
+
keepalive = false;
|
|
2889
|
+
mode = "cors";
|
|
2890
|
+
cache = "default";
|
|
2891
|
+
credentials = "same-origin";
|
|
2892
|
+
referrer = "about:client";
|
|
2893
|
+
referrerPolicy = "";
|
|
2894
|
+
signal = null;
|
|
2895
|
+
destination = "";
|
|
2896
|
+
get body() {
|
|
2897
|
+
return this._body;
|
|
2898
|
+
}
|
|
2899
|
+
get bodyUsed() {
|
|
2900
|
+
return this._bodyConsumed || (this._body?.locked ?? false);
|
|
2901
|
+
}
|
|
2902
|
+
constructor(input, init = {}) {
|
|
2903
|
+
const initBody = init.body;
|
|
2904
|
+
if (input instanceof _RequestImpl) {
|
|
2905
|
+
this.url = input.url;
|
|
2906
|
+
this.method = init.method || input.method;
|
|
2907
|
+
this.headers = new HeadersImpl(init.headers || input.headers);
|
|
2908
|
+
if (initBody !== void 0 && initBody !== null) {
|
|
2909
|
+
this._body = _toReadableStream(initBody);
|
|
2910
|
+
} else {
|
|
2911
|
+
this._body = input._body;
|
|
2912
|
+
}
|
|
2913
|
+
this.redirect = init.redirect || input.redirect;
|
|
2914
|
+
this.timeout = init.timeout || input.timeout;
|
|
2915
|
+
this.maxRedirects = init.maxRedirects || input.maxRedirects;
|
|
2916
|
+
} else {
|
|
2917
|
+
this.url = input;
|
|
2918
|
+
this.method = init.method || "GET";
|
|
2919
|
+
this.headers = new HeadersImpl(init.headers);
|
|
2920
|
+
this._body = initBody !== null && initBody !== void 0 ? _toReadableStream(initBody) : null;
|
|
2921
|
+
this.redirect = init.redirect || "follow";
|
|
2922
|
+
this.timeout = init.timeout || 3e4;
|
|
2923
|
+
this.maxRedirects = init.maxRedirects || 5;
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
async arrayBuffer() {
|
|
2927
|
+
if (!this.body)
|
|
2928
|
+
return new ArrayBuffer(0);
|
|
2929
|
+
if (this._bodyConsumed)
|
|
2930
|
+
throw new TypeError("Body already used");
|
|
2931
|
+
this._bodyConsumed = true;
|
|
2932
|
+
const bytes = await _readStream(this.body);
|
|
2933
|
+
return bytes.buffer;
|
|
2934
|
+
}
|
|
2935
|
+
async json() {
|
|
2936
|
+
return JSON.parse(await this.text());
|
|
2937
|
+
}
|
|
2938
|
+
async text() {
|
|
2939
|
+
if (!this.body)
|
|
2940
|
+
return "";
|
|
2941
|
+
if (this._bodyConsumed)
|
|
2942
|
+
throw new TypeError("Body already used");
|
|
2943
|
+
this._bodyConsumed = true;
|
|
2944
|
+
const bytes = await _readStream(this.body);
|
|
2945
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
2946
|
+
}
|
|
2947
|
+
clone() {
|
|
2948
|
+
if (this.bodyUsed)
|
|
2949
|
+
throw new TypeError("Body already used");
|
|
2950
|
+
if (this._body) {
|
|
2951
|
+
const [branch1, branch2] = this._body.tee();
|
|
2952
|
+
this._body = branch1;
|
|
2953
|
+
const req = new _RequestImpl(this.url, {
|
|
2954
|
+
method: this.method,
|
|
2955
|
+
headers: this.headers,
|
|
2956
|
+
body: branch2,
|
|
2957
|
+
redirect: this.redirect,
|
|
2958
|
+
timeout: this.timeout,
|
|
2959
|
+
maxRedirects: this.maxRedirects
|
|
2960
|
+
});
|
|
2961
|
+
return req;
|
|
2962
|
+
}
|
|
2963
|
+
return new _RequestImpl(this.url, {
|
|
2964
|
+
method: this.method,
|
|
2965
|
+
headers: this.headers,
|
|
2966
|
+
redirect: this.redirect,
|
|
2967
|
+
timeout: this.timeout,
|
|
2968
|
+
maxRedirects: this.maxRedirects
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
};
|
|
2972
|
+
var ResponseImpl = class _ResponseImpl {
|
|
2973
|
+
status;
|
|
2974
|
+
statusText;
|
|
2975
|
+
ok;
|
|
2976
|
+
_headers;
|
|
2977
|
+
_redirected = false;
|
|
2978
|
+
_type = "basic";
|
|
2979
|
+
_url = "";
|
|
2980
|
+
_body;
|
|
2981
|
+
_bodyConsumed = false;
|
|
2982
|
+
get body() {
|
|
2983
|
+
return this._body;
|
|
2984
|
+
}
|
|
2985
|
+
get bodyUsed() {
|
|
2986
|
+
return this._bodyConsumed || this._body.locked;
|
|
2987
|
+
}
|
|
2988
|
+
get headers() {
|
|
2989
|
+
return this._headers;
|
|
2990
|
+
}
|
|
2991
|
+
get redirected() {
|
|
2992
|
+
return this._redirected;
|
|
2993
|
+
}
|
|
2994
|
+
get type() {
|
|
2995
|
+
return this._type;
|
|
2996
|
+
}
|
|
2997
|
+
get url() {
|
|
2998
|
+
return this._url;
|
|
2999
|
+
}
|
|
3000
|
+
constructor(body, init) {
|
|
3001
|
+
const status = init?.status ?? 200;
|
|
3002
|
+
const statusText = init?.statusText ?? "";
|
|
3003
|
+
const headers = new HeadersImpl(init?.headers);
|
|
3004
|
+
this.status = status;
|
|
3005
|
+
this.statusText = statusText;
|
|
3006
|
+
this._headers = headers;
|
|
3007
|
+
this.ok = status >= 200 && status < 300;
|
|
3008
|
+
this._body = body != null ? _toReadableStream(body) : new ReadableStream({
|
|
3009
|
+
start(ctrl) {
|
|
3010
|
+
ctrl.close();
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
async text() {
|
|
3015
|
+
if (this.bodyUsed)
|
|
3016
|
+
throw new TypeError("Body already used");
|
|
3017
|
+
this._bodyConsumed = true;
|
|
3018
|
+
const bytes = await _readStream(this._body);
|
|
3019
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
3020
|
+
}
|
|
3021
|
+
async json() {
|
|
3022
|
+
return JSON.parse(await this.text());
|
|
3023
|
+
}
|
|
3024
|
+
async arrayBuffer() {
|
|
3025
|
+
if (this.bodyUsed)
|
|
3026
|
+
throw new TypeError("Body already used");
|
|
3027
|
+
this._bodyConsumed = true;
|
|
3028
|
+
const bytes = await _readStream(this._body);
|
|
3029
|
+
return bytes.buffer;
|
|
3030
|
+
}
|
|
3031
|
+
async bytes() {
|
|
3032
|
+
if (this.bodyUsed)
|
|
3033
|
+
throw new TypeError("Body already used");
|
|
3034
|
+
this._bodyConsumed = true;
|
|
3035
|
+
return await _readStream(this._body);
|
|
3036
|
+
}
|
|
3037
|
+
clone() {
|
|
3038
|
+
if (this.bodyUsed)
|
|
3039
|
+
throw new TypeError("Body already used");
|
|
3040
|
+
const [branch1, branch2] = this._body.tee();
|
|
3041
|
+
this._body = branch1;
|
|
3042
|
+
return new _ResponseImpl(branch2, { status: this.status, statusText: this.statusText, headers: this._headers });
|
|
3043
|
+
}
|
|
3044
|
+
_applyDecompressedBody(stream, _body, newHeaders) {
|
|
3045
|
+
this._bodyConsumed = false;
|
|
3046
|
+
this._body = stream;
|
|
3047
|
+
this._headers = newHeaders;
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
globalThis.Headers = HeadersImpl;
|
|
3051
|
+
globalThis.Request = RequestImpl;
|
|
3052
|
+
globalThis.Response = ResponseImpl;
|
|
3053
|
+
|
|
3054
|
+
// _build/lib/http-server.js
|
|
3055
|
+
var STATUS_TEXT = {
|
|
3056
|
+
100: "Continue",
|
|
3057
|
+
101: "Switching Protocols",
|
|
3058
|
+
200: "OK",
|
|
3059
|
+
201: "Created",
|
|
3060
|
+
202: "Accepted",
|
|
3061
|
+
204: "No Content",
|
|
3062
|
+
301: "Moved Permanently",
|
|
3063
|
+
302: "Found",
|
|
3064
|
+
304: "Not Modified",
|
|
3065
|
+
400: "Bad Request",
|
|
3066
|
+
401: "Unauthorized",
|
|
3067
|
+
403: "Forbidden",
|
|
3068
|
+
404: "Not Found",
|
|
3069
|
+
405: "Method Not Allowed",
|
|
3070
|
+
408: "Request Timeout",
|
|
3071
|
+
413: "Payload Too Large",
|
|
3072
|
+
500: "Internal Server Error",
|
|
3073
|
+
501: "Not Implemented",
|
|
3074
|
+
502: "Bad Gateway",
|
|
3075
|
+
503: "Service Unavailable"
|
|
3076
|
+
};
|
|
3077
|
+
function concatU8(parts) {
|
|
3078
|
+
let total = 0;
|
|
3079
|
+
for (const p2 of parts)
|
|
3080
|
+
total += p2.length;
|
|
3081
|
+
const out = new Uint8Array(total);
|
|
3082
|
+
let off = 0;
|
|
3083
|
+
for (const p2 of parts) {
|
|
3084
|
+
out.set(p2, off);
|
|
3085
|
+
off += p2.length;
|
|
3086
|
+
}
|
|
3087
|
+
return out;
|
|
3088
|
+
}
|
|
3089
|
+
function toArrayBuffer(u8) {
|
|
3090
|
+
return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
|
|
3091
|
+
}
|
|
3092
|
+
function findCrLfCrLf(buf) {
|
|
3093
|
+
const n2 = buf.length - 3;
|
|
3094
|
+
for (let i2 = 0; i2 < n2; i2++) {
|
|
3095
|
+
if (buf[i2] === 13 && buf[i2 + 1] === 10 && buf[i2 + 2] === 13 && buf[i2 + 3] === 10)
|
|
3096
|
+
return i2;
|
|
3097
|
+
}
|
|
3098
|
+
return -1;
|
|
3099
|
+
}
|
|
3100
|
+
function decodeChunked(buf, start) {
|
|
3101
|
+
let pos = start;
|
|
3102
|
+
const parts = [];
|
|
3103
|
+
const decoder = new TextDecoder("utf-8");
|
|
3104
|
+
while (pos < buf.length) {
|
|
3105
|
+
let eol = pos;
|
|
3106
|
+
while (eol < buf.length && buf[eol] !== 13)
|
|
3107
|
+
eol++;
|
|
3108
|
+
if (eol >= buf.length || eol + 1 >= buf.length || buf[eol + 1] !== 10)
|
|
3109
|
+
return null;
|
|
3110
|
+
const sizeLine = decoder.decode(buf.subarray(pos, eol)).trim();
|
|
3111
|
+
const semi = sizeLine.indexOf(";");
|
|
3112
|
+
const hex = (semi >= 0 ? sizeLine.slice(0, semi) : sizeLine).trim();
|
|
3113
|
+
const size = parseInt(hex, 16);
|
|
3114
|
+
if (isNaN(size) || size < 0)
|
|
3115
|
+
return null;
|
|
3116
|
+
pos = eol + 2;
|
|
3117
|
+
if (size === 0) {
|
|
3118
|
+
while (true) {
|
|
3119
|
+
if (pos >= buf.length)
|
|
3120
|
+
return null;
|
|
3121
|
+
if (buf[pos] === 13) {
|
|
3122
|
+
if (pos + 1 >= buf.length || buf[pos + 1] !== 10)
|
|
3123
|
+
return null;
|
|
3124
|
+
pos += 2;
|
|
3125
|
+
return { data: concatU8(parts), end: pos };
|
|
3126
|
+
}
|
|
3127
|
+
let t2 = pos;
|
|
3128
|
+
while (t2 < buf.length && buf[t2] !== 13)
|
|
3129
|
+
t2++;
|
|
3130
|
+
if (t2 >= buf.length || t2 + 1 >= buf.length || buf[t2 + 1] !== 10)
|
|
3131
|
+
return null;
|
|
3132
|
+
pos = t2 + 2;
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
if (pos + size > buf.length)
|
|
3136
|
+
return null;
|
|
3137
|
+
parts.push(buf.subarray(pos, pos + size));
|
|
3138
|
+
pos += size;
|
|
3139
|
+
if (pos + 1 >= buf.length || buf[pos] !== 13 || buf[pos + 1] !== 10)
|
|
3140
|
+
return null;
|
|
3141
|
+
pos += 2;
|
|
3142
|
+
}
|
|
3143
|
+
return null;
|
|
3144
|
+
}
|
|
3145
|
+
function parseHeader(headerStr) {
|
|
3146
|
+
const lines = headerStr.split("\r\n");
|
|
3147
|
+
const first = lines[0];
|
|
3148
|
+
if (!first)
|
|
3149
|
+
return null;
|
|
3150
|
+
const sp1 = first.indexOf(" ");
|
|
3151
|
+
const sp2 = first.lastIndexOf(" ");
|
|
3152
|
+
if (sp1 <= 0 || sp2 <= sp1)
|
|
3153
|
+
return null;
|
|
3154
|
+
const method = first.slice(0, sp1);
|
|
3155
|
+
const target = first.slice(sp1 + 1, sp2);
|
|
3156
|
+
const version = first.slice(sp2 + 1).trim();
|
|
3157
|
+
const headers = {};
|
|
3158
|
+
for (let i2 = 1; i2 < lines.length; i2++) {
|
|
3159
|
+
const line = lines[i2];
|
|
3160
|
+
if (!line)
|
|
3161
|
+
continue;
|
|
3162
|
+
const ci = line.indexOf(":");
|
|
3163
|
+
if (ci <= 0)
|
|
3164
|
+
continue;
|
|
3165
|
+
const name = line.slice(0, ci).trim().toLowerCase();
|
|
3166
|
+
const value = line.slice(ci + 1).trim();
|
|
3167
|
+
if (headers[name] !== void 0)
|
|
3168
|
+
headers[name] = headers[name] + ", " + value;
|
|
3169
|
+
else
|
|
3170
|
+
headers[name] = value;
|
|
3171
|
+
}
|
|
3172
|
+
const te2 = (headers["transfer-encoding"] || "").toLowerCase();
|
|
3173
|
+
const chunked = te2.indexOf("chunked") >= 0;
|
|
3174
|
+
const contentLength = parseInt(headers["content-length"] || "0", 10) || 0;
|
|
3175
|
+
return { method, target, version, headers, chunked, contentLength };
|
|
3176
|
+
}
|
|
3177
|
+
var HttpServer = class {
|
|
3178
|
+
handler;
|
|
3179
|
+
serverSock = null;
|
|
3180
|
+
conns = /* @__PURE__ */ new Map();
|
|
3181
|
+
closed = false;
|
|
3182
|
+
constructor(handler) {
|
|
3183
|
+
this.handler = handler;
|
|
3184
|
+
}
|
|
3185
|
+
/** Actual bound address, or null if not listening. */
|
|
3186
|
+
address() {
|
|
3187
|
+
if (this.serverSock === null)
|
|
3188
|
+
return null;
|
|
3189
|
+
return sock.getsockname(this.serverSock);
|
|
3190
|
+
}
|
|
3191
|
+
/** Bind and start listening. Returns 0 on success, -1 on failure. */
|
|
3192
|
+
listen(port, host, backlog) {
|
|
3193
|
+
if (this.serverSock !== null)
|
|
3194
|
+
return -1;
|
|
3195
|
+
const s2 = sock.socket();
|
|
3196
|
+
if (s2 < 0)
|
|
3197
|
+
return -1;
|
|
3198
|
+
if (sock.bind(s2, host ?? null, port) !== 0) {
|
|
3199
|
+
sock.closesocket(s2);
|
|
3200
|
+
return -1;
|
|
3201
|
+
}
|
|
3202
|
+
if (sock.listen(s2, backlog ?? 64) !== 0) {
|
|
3203
|
+
sock.closesocket(s2);
|
|
3204
|
+
return -1;
|
|
3205
|
+
}
|
|
3206
|
+
this.serverSock = s2;
|
|
3207
|
+
sock.set_on_event(s2, (event) => {
|
|
3208
|
+
if (event.lNetworkEvents & 8)
|
|
3209
|
+
this.acceptLoop();
|
|
3210
|
+
});
|
|
3211
|
+
return 0;
|
|
3212
|
+
}
|
|
3213
|
+
close() {
|
|
3214
|
+
if (this.closed)
|
|
3215
|
+
return;
|
|
3216
|
+
this.closed = true;
|
|
3217
|
+
for (const c2 of Array.from(this.conns.values()))
|
|
3218
|
+
closeConn(c2);
|
|
3219
|
+
this.conns.clear();
|
|
3220
|
+
if (this.serverSock !== null) {
|
|
3221
|
+
sock.closesocket(this.serverSock);
|
|
3222
|
+
this.serverSock = null;
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
acceptLoop() {
|
|
3226
|
+
if (this.closed || this.serverSock === null)
|
|
3227
|
+
return;
|
|
3228
|
+
while (true) {
|
|
3229
|
+
const ac = sock.accept(this.serverSock);
|
|
3230
|
+
if (!ac)
|
|
3231
|
+
break;
|
|
3232
|
+
const c2 = {
|
|
3233
|
+
sock: ac.handle,
|
|
3234
|
+
parts: [],
|
|
3235
|
+
pending: null,
|
|
3236
|
+
current: null,
|
|
3237
|
+
outQueue: null,
|
|
3238
|
+
closed: false,
|
|
3239
|
+
closeAfterFlush: false,
|
|
3240
|
+
keepAlive: true,
|
|
3241
|
+
owner: this
|
|
3242
|
+
};
|
|
3243
|
+
this.conns.set(c2.sock, c2);
|
|
3244
|
+
sock.set_on_event(c2.sock, (event) => this.onConnEvent(c2, event));
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
onConnEvent(c2, event) {
|
|
3248
|
+
if (c2.closed)
|
|
3249
|
+
return;
|
|
3250
|
+
if (event.lNetworkEvents & 1)
|
|
3251
|
+
onRead(c2);
|
|
3252
|
+
if (event.lNetworkEvents & 2)
|
|
3253
|
+
flushQueue(c2);
|
|
3254
|
+
if (event.lNetworkEvents & 32) {
|
|
3255
|
+
onRead(c2);
|
|
3256
|
+
if (!c2.current && !c2.pending)
|
|
3257
|
+
closeConn(c2);
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
};
|
|
3261
|
+
function createServer(handler) {
|
|
3262
|
+
return new HttpServer(handler);
|
|
3263
|
+
}
|
|
3264
|
+
function onRead(c2) {
|
|
3265
|
+
if (c2.closed)
|
|
3266
|
+
return;
|
|
3267
|
+
while (true) {
|
|
3268
|
+
const d2 = sock.recv(c2.sock, 8192);
|
|
3269
|
+
if (!d2)
|
|
3270
|
+
break;
|
|
3271
|
+
c2.parts.push(new Uint8Array(d2));
|
|
3272
|
+
}
|
|
3273
|
+
if (!c2.closed)
|
|
3274
|
+
tryProcess(c2);
|
|
3275
|
+
}
|
|
3276
|
+
function queueSend(c2, data) {
|
|
3277
|
+
if (c2.closed || data.length === 0)
|
|
3278
|
+
return;
|
|
3279
|
+
if (c2.outQueue && c2.outQueue.length > 0) {
|
|
3280
|
+
c2.outQueue = concatU8([c2.outQueue, data]);
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
const ret = sock.send(c2.sock, toArrayBuffer(data));
|
|
3284
|
+
if (ret < 0) {
|
|
3285
|
+
c2.outQueue = data;
|
|
3286
|
+
return;
|
|
3287
|
+
}
|
|
3288
|
+
if (ret < data.length) {
|
|
3289
|
+
c2.outQueue = data.subarray(ret);
|
|
3290
|
+
return;
|
|
3291
|
+
}
|
|
3292
|
+
if (c2.closeAfterFlush)
|
|
3293
|
+
closeConn(c2);
|
|
3294
|
+
}
|
|
3295
|
+
function flushQueue(c2) {
|
|
3296
|
+
if (c2.closed)
|
|
3297
|
+
return;
|
|
3298
|
+
if (!c2.outQueue || c2.outQueue.length === 0) {
|
|
3299
|
+
if (c2.closeAfterFlush)
|
|
3300
|
+
closeConn(c2);
|
|
3301
|
+
return;
|
|
3302
|
+
}
|
|
3303
|
+
const q2 = c2.outQueue;
|
|
3304
|
+
const ret = sock.send(c2.sock, toArrayBuffer(q2));
|
|
3305
|
+
if (ret < 0)
|
|
3306
|
+
return;
|
|
3307
|
+
if (ret < q2.length) {
|
|
3308
|
+
c2.outQueue = q2.subarray(ret);
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
c2.outQueue = null;
|
|
3312
|
+
if (c2.closeAfterFlush)
|
|
3313
|
+
closeConn(c2);
|
|
3314
|
+
}
|
|
3315
|
+
function closeConn(c2) {
|
|
3316
|
+
if (c2.closed)
|
|
3317
|
+
return;
|
|
3318
|
+
c2.closed = true;
|
|
3319
|
+
if (c2.sock >= 0)
|
|
3320
|
+
sock.closesocket(c2.sock);
|
|
3321
|
+
c2.owner.conns.delete(c2.sock);
|
|
3322
|
+
}
|
|
3323
|
+
function whole(c2) {
|
|
3324
|
+
return concatU8(c2.parts);
|
|
3325
|
+
}
|
|
3326
|
+
function trimParts(c2, buf, consumed) {
|
|
3327
|
+
if (consumed >= buf.length) {
|
|
3328
|
+
c2.parts = [];
|
|
3329
|
+
} else {
|
|
3330
|
+
c2.parts = [buf.subarray(consumed)];
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
function tryProcess(c2) {
|
|
3334
|
+
if (c2.closed || c2.current)
|
|
3335
|
+
return;
|
|
3336
|
+
const buf = whole(c2);
|
|
3337
|
+
if (c2.pending) {
|
|
3338
|
+
const bodyStart2 = c2.pending.bodyStart;
|
|
3339
|
+
const parsed2 = c2.pending.parsed;
|
|
3340
|
+
let body;
|
|
3341
|
+
let end;
|
|
3342
|
+
if (parsed2.chunked) {
|
|
3343
|
+
const dec = decodeChunked(buf, bodyStart2);
|
|
3344
|
+
if (!dec)
|
|
3345
|
+
return;
|
|
3346
|
+
body = dec.data;
|
|
3347
|
+
end = dec.end;
|
|
3348
|
+
} else {
|
|
3349
|
+
const needed = parsed2.contentLength;
|
|
3350
|
+
if (bodyStart2 + needed > buf.length)
|
|
3351
|
+
return;
|
|
3352
|
+
body = buf.subarray(bodyStart2, bodyStart2 + needed);
|
|
3353
|
+
end = bodyStart2 + needed;
|
|
3354
|
+
}
|
|
3355
|
+
c2.pending = null;
|
|
3356
|
+
dispatchRequest(c2, parsed2, body, end);
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3359
|
+
const headerEnd = findCrLfCrLf(buf);
|
|
3360
|
+
if (headerEnd < 0)
|
|
3361
|
+
return;
|
|
3362
|
+
const absEnd = headerEnd + 4;
|
|
3363
|
+
const headerStr = new TextDecoder("utf-8").decode(buf.subarray(0, absEnd));
|
|
3364
|
+
const parsed = parseHeader(headerStr);
|
|
3365
|
+
if (!parsed) {
|
|
3366
|
+
closeConn(c2);
|
|
3367
|
+
return;
|
|
3368
|
+
}
|
|
3369
|
+
const bodyStart = absEnd;
|
|
3370
|
+
if (parsed.chunked) {
|
|
3371
|
+
const dec = decodeChunked(buf, bodyStart);
|
|
3372
|
+
if (!dec) {
|
|
3373
|
+
c2.pending = { parsed, bodyStart };
|
|
3374
|
+
return;
|
|
3375
|
+
}
|
|
3376
|
+
dispatchRequest(c2, parsed, dec.data, dec.end);
|
|
3377
|
+
} else if (parsed.contentLength > 0) {
|
|
3378
|
+
if (bodyStart + parsed.contentLength > buf.length) {
|
|
3379
|
+
c2.pending = { parsed, bodyStart };
|
|
3380
|
+
return;
|
|
3381
|
+
}
|
|
3382
|
+
dispatchRequest(c2, parsed, buf.subarray(bodyStart, bodyStart + parsed.contentLength), bodyStart + parsed.contentLength);
|
|
3383
|
+
} else {
|
|
3384
|
+
dispatchRequest(c2, parsed, new Uint8Array(0), bodyStart);
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
function dispatchRequest(c2, parsed, body, end) {
|
|
3388
|
+
const connHeader = (parsed.headers["connection"] || "").toLowerCase();
|
|
3389
|
+
if (parsed.version === "HTTP/1.1")
|
|
3390
|
+
c2.keepAlive = connHeader.indexOf("close") < 0;
|
|
3391
|
+
else
|
|
3392
|
+
c2.keepAlive = connHeader.indexOf("keep-alive") >= 0;
|
|
3393
|
+
let host = parsed.headers["host"];
|
|
3394
|
+
if (!host) {
|
|
3395
|
+
const a2 = c2.owner.address();
|
|
3396
|
+
const addrStr = a2 ? a2.addr.includes(":") ? `[${a2.addr}]` : a2.addr : "localhost";
|
|
3397
|
+
host = a2 ? addrStr + ":" + a2.port : "localhost";
|
|
3398
|
+
}
|
|
3399
|
+
const isAbsolute = parsed.target.startsWith("http://") || parsed.target.startsWith("https://");
|
|
3400
|
+
const url = isAbsolute ? parsed.target : "http://" + host + parsed.target;
|
|
3401
|
+
const req = new RequestImpl(url, {
|
|
3402
|
+
method: parsed.method,
|
|
3403
|
+
headers: new HeadersImpl(parsed.headers),
|
|
3404
|
+
body: body.length > 0 ? body : void 0
|
|
3405
|
+
});
|
|
3406
|
+
c2.current = { req };
|
|
3407
|
+
trimParts(c2, whole(c2), end);
|
|
3408
|
+
void handleRequest(c2);
|
|
3409
|
+
}
|
|
3410
|
+
async function handleRequest(c2) {
|
|
3411
|
+
const req = c2.current?.req;
|
|
3412
|
+
if (!req) {
|
|
3413
|
+
c2.current = null;
|
|
3414
|
+
return;
|
|
3415
|
+
}
|
|
3416
|
+
let res;
|
|
3417
|
+
try {
|
|
3418
|
+
const result = await c2.owner.handler(req);
|
|
3419
|
+
if (result instanceof ResponseImpl) {
|
|
3420
|
+
res = result;
|
|
3421
|
+
} else {
|
|
3422
|
+
console.error("[http-server] handler must return a Response");
|
|
3423
|
+
res = new ResponseImpl("Internal Server Error", { status: 500 });
|
|
3424
|
+
}
|
|
3425
|
+
} catch (e2) {
|
|
3426
|
+
console.error("[http-server] handler error:", e2);
|
|
3427
|
+
res = new ResponseImpl("Internal Server Error", { status: 500 });
|
|
3428
|
+
}
|
|
3429
|
+
if (c2.closed)
|
|
3430
|
+
return;
|
|
3431
|
+
await sendResponse(c2, req.method, res);
|
|
3432
|
+
if (c2.closed)
|
|
3433
|
+
return;
|
|
3434
|
+
c2.current = null;
|
|
3435
|
+
if (!c2.closeAfterFlush)
|
|
3436
|
+
tryProcess(c2);
|
|
3437
|
+
}
|
|
3438
|
+
async function sendResponse(c2, method, res) {
|
|
3439
|
+
const status = res.status;
|
|
3440
|
+
const statusText = res.statusText || STATUS_TEXT[status] || "OK";
|
|
3441
|
+
const headers = new HeadersImpl(res.headers);
|
|
3442
|
+
let body;
|
|
3443
|
+
try {
|
|
3444
|
+
body = await _readStream(res.body);
|
|
3445
|
+
} catch {
|
|
3446
|
+
body = new Uint8Array(0);
|
|
3447
|
+
}
|
|
3448
|
+
if (c2.closed)
|
|
3449
|
+
return;
|
|
3450
|
+
const headOnly = method === "HEAD";
|
|
3451
|
+
const bodyless = status >= 100 && status < 200 || status === 204 || status === 304;
|
|
3452
|
+
if (!headers.has("content-length") && !bodyless)
|
|
3453
|
+
headers.set("Content-Length", String(body.length));
|
|
3454
|
+
if (!headers.has("connection"))
|
|
3455
|
+
headers.set("Connection", c2.keepAlive ? "keep-alive" : "close");
|
|
3456
|
+
const connHdr = (headers.get("connection") || "").toLowerCase();
|
|
3457
|
+
if (!c2.keepAlive || connHdr === "close")
|
|
3458
|
+
c2.closeAfterFlush = true;
|
|
3459
|
+
let head = "HTTP/1.1 " + status + " " + statusText + "\r\n";
|
|
3460
|
+
for (const [name, value] of headers)
|
|
3461
|
+
head += name + ": " + value + "\r\n";
|
|
3462
|
+
head += "\r\n";
|
|
3463
|
+
const headBytes = new TextEncoder().encode(head);
|
|
3464
|
+
const payload = headOnly || body.length === 0 ? headBytes : concatU8([headBytes, body]);
|
|
3465
|
+
queueSend(c2, payload);
|
|
3466
|
+
}
|
|
3467
|
+
|
|
3468
|
+
// _build/examples/exec_server.js
|
|
3469
|
+
import * as os2 from "os";
|
|
3470
|
+
var EXEC_TIMEOUT_MS = 6e4;
|
|
3471
|
+
function runInWorker(cmd) {
|
|
3472
|
+
return new Promise((resolve, reject) => {
|
|
3473
|
+
const worker = new os2.Worker("data:text/javascript;base64,aW1wb3J0KmFzIGEgZnJvbSJvcyI7aW1wb3J0KmFzIGkgZnJvbSJzdGQiO2Z1bmN0aW9uIGwoYyl7bGV0IHQ9W10sbj1uZXcgVWludDhBcnJheSg0MDk2KTtmb3IoOzspe2xldCByPWMucmVhZChuLmJ1ZmZlciwwLDQwOTYpO2lmKHI8PTApYnJlYWs7dC5wdXNoKG4uc2xpY2UoMCxyKSl9bGV0IHM9MDtmb3IobGV0IHIgb2YgdClzKz1yLmxlbmd0aDtsZXQgbz1uZXcgVWludDhBcnJheShzKSxlPTA7Zm9yKGxldCByIG9mIHQpby5zZXQocixlKSxlKz1yLmxlbmd0aDtyZXR1cm4gb312YXIgZj1hLldvcmtlci5wYXJlbnQ7Zi5vbm1lc3NhZ2U9Yz0+e2xldCB0PWMuZGF0YTtpZih0LnR5cGUhPT0icnVuInx8dHlwZW9mIHQuY21kIT0ic3RyaW5nIilyZXR1cm47bGV0IG49bmV3IFVpbnQ4QXJyYXkoMCkscz0tMSxvPW51bGw7dHJ5e2xldCBlPWkucG9wZW4odC5jbWQsInIiKTtlPyhuPWwoZSkscz1lLmNsb3NlKCkpOm89InBvcGVuIGZhaWxlZCJ9Y2F0Y2goZSl7bz1TdHJpbmcoZSl9Zi5wb3N0TWVzc2FnZSh7dHlwZToicmVzdWx0IixpZDp0LmlkLG91dDpuLGNvZGU6cyxlcnJvcjpvfSl9Owo=");
|
|
3474
|
+
const id = 1;
|
|
3475
|
+
let settled = false;
|
|
3476
|
+
let timer;
|
|
3477
|
+
const finish = (fn) => {
|
|
3478
|
+
if (settled)
|
|
3479
|
+
return;
|
|
3480
|
+
settled = true;
|
|
3481
|
+
os2.clearTimeout(timer);
|
|
3482
|
+
worker.onmessage = null;
|
|
3483
|
+
fn();
|
|
3484
|
+
};
|
|
3485
|
+
timer = os2.setTimeout(() => {
|
|
3486
|
+
finish(() => reject(new Error("exec timeout")));
|
|
3487
|
+
}, EXEC_TIMEOUT_MS);
|
|
3488
|
+
worker.onmessage = (e2) => {
|
|
3489
|
+
const msg = e2.data;
|
|
3490
|
+
if (msg.type !== "result" || msg.id !== id)
|
|
3491
|
+
return;
|
|
3492
|
+
finish(() => resolve({ out: msg.out ?? new Uint8Array(0), code: msg.code ?? -1, error: msg.error ?? null }));
|
|
3493
|
+
};
|
|
3494
|
+
try {
|
|
3495
|
+
worker.postMessage({ type: "run", id, cmd });
|
|
3496
|
+
} catch (ex) {
|
|
3497
|
+
finish(() => reject(ex instanceof Error ? ex : new Error(String(ex))));
|
|
3498
|
+
}
|
|
3499
|
+
});
|
|
3500
|
+
}
|
|
3501
|
+
var server = createServer(async (req) => {
|
|
3502
|
+
const path = new URL(req.url).pathname;
|
|
3503
|
+
if (req.method === "GET" && (path === "/" || path === "/health")) {
|
|
3504
|
+
return new Response("ok", { headers: { "Content-Type": "text/plain" } });
|
|
3505
|
+
}
|
|
3506
|
+
if (req.method === "POST" && path === "/exec") {
|
|
3507
|
+
const body = await req.json();
|
|
3508
|
+
try {
|
|
3509
|
+
const { out, code, error } = await runInWorker(body.cmd);
|
|
3510
|
+
if (error) {
|
|
3511
|
+
return new Response(JSON.stringify({ error }), {
|
|
3512
|
+
status: 500,
|
|
3513
|
+
headers: { "Content-Type": "application/json" }
|
|
33
3514
|
});
|
|
3515
|
+
}
|
|
3516
|
+
return new Response(out, {
|
|
3517
|
+
headers: {
|
|
3518
|
+
"Content-Type": "application/octet-stream",
|
|
3519
|
+
"X-Exit-Code": String(code)
|
|
3520
|
+
}
|
|
3521
|
+
});
|
|
3522
|
+
} catch (ex) {
|
|
3523
|
+
return new Response(JSON.stringify({ error: String(ex) }), {
|
|
3524
|
+
status: 504,
|
|
3525
|
+
headers: { "Content-Type": "application/json" }
|
|
3526
|
+
});
|
|
34
3527
|
}
|
|
35
|
-
|
|
3528
|
+
}
|
|
3529
|
+
return new Response("Not Found", { status: 404 });
|
|
36
3530
|
});
|
|
37
|
-
server.listen(8080);
|
|
38
|
-
console.log(
|
|
3531
|
+
var rc = server.listen(8080, "0.0.0.0");
|
|
3532
|
+
console.log("listen rc=" + rc + " addr=" + JSON.stringify(server.address()));
|
|
3533
|
+
/**
|
|
3534
|
+
* @license
|
|
3535
|
+
* web-streams-polyfill v4.3.0
|
|
3536
|
+
* Copyright 2026 Mattias Buelens, Diwank Singh Tomer and other contributors.
|
|
3537
|
+
* This code is released under the MIT license.
|
|
3538
|
+
* SPDX-License-Identifier: MIT
|
|
3539
|
+
*/
|