elysia 1.3.19 → 1.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapter/bun/compose.mjs +17 -13
- package/dist/adapter/bun/handler-native.mjs +30 -24
- package/dist/adapter/bun/handler.mjs +17 -13
- package/dist/adapter/bun/index.mjs +30 -24
- package/dist/adapter/utils.mjs +17 -13
- package/dist/adapter/web-standard/handler.mjs +96 -13
- package/dist/adapter/web-standard/index.mjs +96 -13
- package/dist/bun/index.js +23 -23
- package/dist/bun/index.js.map +7 -7
- package/dist/cjs/adapter/bun/compose.js +17 -13
- package/dist/cjs/adapter/bun/handler-native.js +30 -24
- package/dist/cjs/adapter/bun/handler.js +17 -13
- package/dist/cjs/adapter/bun/index.js +30 -24
- package/dist/cjs/adapter/utils.js +17 -13
- package/dist/cjs/adapter/web-standard/handler.js +96 -13
- package/dist/cjs/adapter/web-standard/index.js +96 -13
- package/dist/cjs/compose.js +84 -67
- package/dist/cjs/index.js +117 -94
- package/dist/compose.mjs +84 -67
- package/dist/index.mjs +117 -94
- package/package.json +1 -1
|
@@ -679,22 +679,26 @@ var handleFile = (response, set2) => {
|
|
|
679
679
|
try {
|
|
680
680
|
for await (let chunk of generator) {
|
|
681
681
|
if (end) break;
|
|
682
|
-
if (chunk != null)
|
|
682
|
+
if (chunk != null)
|
|
683
683
|
if (chunk.toSSE)
|
|
684
684
|
controller.enqueue(chunk.toSSE());
|
|
685
|
-
else
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
685
|
+
else {
|
|
686
|
+
if (typeof chunk == "object")
|
|
687
|
+
try {
|
|
688
|
+
controller.enqueue(
|
|
689
|
+
format(JSON.stringify(chunk))
|
|
690
|
+
);
|
|
691
|
+
} catch {
|
|
692
|
+
controller.enqueue(
|
|
693
|
+
format(chunk.toString())
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
else
|
|
691
697
|
controller.enqueue(format(chunk.toString()));
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
+
isSSE || await new Promise(
|
|
699
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
700
|
+
);
|
|
701
|
+
}
|
|
698
702
|
}
|
|
699
703
|
} catch (error) {
|
|
700
704
|
console.warn(error);
|
|
@@ -6,7 +6,7 @@ import decode from "fast-decode-uri-component";
|
|
|
6
6
|
var isBun = typeof Bun < "u";
|
|
7
7
|
|
|
8
8
|
// src/universal/file.ts
|
|
9
|
-
var
|
|
9
|
+
var mime = {
|
|
10
10
|
aac: "audio/aac",
|
|
11
11
|
abw: "application/x-abiword",
|
|
12
12
|
ai: "application/postscript",
|
|
@@ -103,7 +103,7 @@ var createReadStream, stat, ElysiaFile = class {
|
|
|
103
103
|
get type() {
|
|
104
104
|
return (
|
|
105
105
|
// @ts-ignore
|
|
106
|
-
|
|
106
|
+
mime[getFileExtension(this.path)] || "application/octet-stream"
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
get length() {
|
|
@@ -693,22 +693,26 @@ var handleFile = (response, set2) => {
|
|
|
693
693
|
try {
|
|
694
694
|
for await (let chunk of generator) {
|
|
695
695
|
if (end) break;
|
|
696
|
-
if (chunk != null)
|
|
696
|
+
if (chunk != null)
|
|
697
697
|
if (chunk.toSSE)
|
|
698
698
|
controller.enqueue(chunk.toSSE());
|
|
699
|
-
else
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
699
|
+
else {
|
|
700
|
+
if (typeof chunk == "object")
|
|
701
|
+
try {
|
|
702
|
+
controller.enqueue(
|
|
703
|
+
format(JSON.stringify(chunk))
|
|
704
|
+
);
|
|
705
|
+
} catch {
|
|
706
|
+
controller.enqueue(
|
|
707
|
+
format(chunk.toString())
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
else
|
|
705
711
|
controller.enqueue(format(chunk.toString()));
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
+
isSSE || await new Promise(
|
|
713
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
714
|
+
);
|
|
715
|
+
}
|
|
712
716
|
}
|
|
713
717
|
} catch (error) {
|
|
714
718
|
console.warn(error);
|
|
@@ -3411,7 +3415,9 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3411
3415
|
),
|
|
3412
3416
|
websocket: {
|
|
3413
3417
|
...app.config.websocket || {},
|
|
3414
|
-
...websocket || {}
|
|
3418
|
+
...websocket || {},
|
|
3419
|
+
// @ts-expect-error not available in this variant of options type
|
|
3420
|
+
...options.websocket || {}
|
|
3415
3421
|
},
|
|
3416
3422
|
fetch: app.fetch
|
|
3417
3423
|
} : {
|
|
@@ -3517,7 +3523,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3517
3523
|
...(app.event.error ?? []).map(
|
|
3518
3524
|
(x) => typeof x == "function" ? x : x.fn
|
|
3519
3525
|
)
|
|
3520
|
-
].filter((x) => x),
|
|
3526
|
+
].filter((x) => x), hasCustomErrorHandlers = errorHandlers.length > 0, handleErrors = hasCustomErrorHandlers ? async (ws, error) => {
|
|
3521
3527
|
for (let handleError of errorHandlers) {
|
|
3522
3528
|
let response2 = handleError(
|
|
3523
3529
|
Object.assign(context, { error })
|
|
@@ -3554,14 +3560,14 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3554
3560
|
},
|
|
3555
3561
|
message: async (ws, _message) => {
|
|
3556
3562
|
let message = await parseMessage(ws, _message);
|
|
3557
|
-
if (validateMessage?.Check(message) === !1)
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
message
|
|
3563
|
-
).message
|
|
3563
|
+
if (validateMessage?.Check(message) === !1) {
|
|
3564
|
+
let validationError = new ValidationError(
|
|
3565
|
+
"message",
|
|
3566
|
+
validateMessage,
|
|
3567
|
+
message
|
|
3564
3568
|
);
|
|
3569
|
+
return hasCustomErrorHandlers ? handleErrors(ws, validationError) : void ws.send(validationError.message);
|
|
3570
|
+
}
|
|
3565
3571
|
try {
|
|
3566
3572
|
await handleResponse3(
|
|
3567
3573
|
ws,
|
|
@@ -375,22 +375,26 @@ var handleFile = (response, set2) => {
|
|
|
375
375
|
try {
|
|
376
376
|
for await (let chunk of generator) {
|
|
377
377
|
if (end) break;
|
|
378
|
-
if (chunk != null)
|
|
378
|
+
if (chunk != null)
|
|
379
379
|
if (chunk.toSSE)
|
|
380
380
|
controller.enqueue(chunk.toSSE());
|
|
381
|
-
else
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
381
|
+
else {
|
|
382
|
+
if (typeof chunk == "object")
|
|
383
|
+
try {
|
|
384
|
+
controller.enqueue(
|
|
385
|
+
format(JSON.stringify(chunk))
|
|
386
|
+
);
|
|
387
|
+
} catch {
|
|
388
|
+
controller.enqueue(
|
|
389
|
+
format(chunk.toString())
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
else
|
|
387
393
|
controller.enqueue(format(chunk.toString()));
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
);
|
|
393
|
-
}
|
|
394
|
+
isSSE || await new Promise(
|
|
395
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
396
|
+
);
|
|
397
|
+
}
|
|
394
398
|
}
|
|
395
399
|
} catch (error) {
|
|
396
400
|
console.warn(error);
|
|
@@ -6,7 +6,7 @@ import decode from "fast-decode-uri-component";
|
|
|
6
6
|
var isBun = typeof Bun < "u";
|
|
7
7
|
|
|
8
8
|
// src/universal/file.ts
|
|
9
|
-
var
|
|
9
|
+
var mime = {
|
|
10
10
|
aac: "audio/aac",
|
|
11
11
|
abw: "application/x-abiword",
|
|
12
12
|
ai: "application/postscript",
|
|
@@ -103,7 +103,7 @@ var createReadStream, stat, ElysiaFile = class {
|
|
|
103
103
|
get type() {
|
|
104
104
|
return (
|
|
105
105
|
// @ts-ignore
|
|
106
|
-
|
|
106
|
+
mime[getFileExtension(this.path)] || "application/octet-stream"
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
get length() {
|
|
@@ -693,22 +693,26 @@ var handleFile = (response, set2) => {
|
|
|
693
693
|
try {
|
|
694
694
|
for await (let chunk of generator) {
|
|
695
695
|
if (end) break;
|
|
696
|
-
if (chunk != null)
|
|
696
|
+
if (chunk != null)
|
|
697
697
|
if (chunk.toSSE)
|
|
698
698
|
controller.enqueue(chunk.toSSE());
|
|
699
|
-
else
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
699
|
+
else {
|
|
700
|
+
if (typeof chunk == "object")
|
|
701
|
+
try {
|
|
702
|
+
controller.enqueue(
|
|
703
|
+
format(JSON.stringify(chunk))
|
|
704
|
+
);
|
|
705
|
+
} catch {
|
|
706
|
+
controller.enqueue(
|
|
707
|
+
format(chunk.toString())
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
else
|
|
705
711
|
controller.enqueue(format(chunk.toString()));
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
);
|
|
711
|
-
}
|
|
712
|
+
isSSE || await new Promise(
|
|
713
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
714
|
+
);
|
|
715
|
+
}
|
|
712
716
|
}
|
|
713
717
|
} catch (error) {
|
|
714
718
|
console.warn(error);
|
|
@@ -3428,7 +3432,9 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3428
3432
|
),
|
|
3429
3433
|
websocket: {
|
|
3430
3434
|
...app.config.websocket || {},
|
|
3431
|
-
...websocket || {}
|
|
3435
|
+
...websocket || {},
|
|
3436
|
+
// @ts-expect-error not available in this variant of options type
|
|
3437
|
+
...options.websocket || {}
|
|
3432
3438
|
},
|
|
3433
3439
|
fetch: app.fetch
|
|
3434
3440
|
} : {
|
|
@@ -3534,7 +3540,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3534
3540
|
...(app.event.error ?? []).map(
|
|
3535
3541
|
(x) => typeof x == "function" ? x : x.fn
|
|
3536
3542
|
)
|
|
3537
|
-
].filter((x) => x),
|
|
3543
|
+
].filter((x) => x), hasCustomErrorHandlers = errorHandlers.length > 0, handleErrors = hasCustomErrorHandlers ? async (ws, error) => {
|
|
3538
3544
|
for (let handleError of errorHandlers) {
|
|
3539
3545
|
let response2 = handleError(
|
|
3540
3546
|
Object.assign(context, { error })
|
|
@@ -3571,14 +3577,14 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3571
3577
|
},
|
|
3572
3578
|
message: async (ws, _message) => {
|
|
3573
3579
|
let message = await parseMessage(ws, _message);
|
|
3574
|
-
if (validateMessage?.Check(message) === !1)
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
message
|
|
3580
|
-
).message
|
|
3580
|
+
if (validateMessage?.Check(message) === !1) {
|
|
3581
|
+
let validationError = new ValidationError(
|
|
3582
|
+
"message",
|
|
3583
|
+
validateMessage,
|
|
3584
|
+
message
|
|
3581
3585
|
);
|
|
3586
|
+
return hasCustomErrorHandlers ? handleErrors(ws, validationError) : void ws.send(validationError.message);
|
|
3587
|
+
}
|
|
3582
3588
|
try {
|
|
3583
3589
|
await handleResponse3(
|
|
3584
3590
|
ws,
|
package/dist/adapter/utils.mjs
CHANGED
|
@@ -249,22 +249,26 @@ var handleFile = (response, set) => {
|
|
|
249
249
|
try {
|
|
250
250
|
for await (let chunk of generator) {
|
|
251
251
|
if (end) break;
|
|
252
|
-
if (chunk != null)
|
|
252
|
+
if (chunk != null)
|
|
253
253
|
if (chunk.toSSE)
|
|
254
254
|
controller.enqueue(chunk.toSSE());
|
|
255
|
-
else
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
255
|
+
else {
|
|
256
|
+
if (typeof chunk == "object")
|
|
257
|
+
try {
|
|
258
|
+
controller.enqueue(
|
|
259
|
+
format(JSON.stringify(chunk))
|
|
260
|
+
);
|
|
261
|
+
} catch {
|
|
262
|
+
controller.enqueue(
|
|
263
|
+
format(chunk.toString())
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
else
|
|
261
267
|
controller.enqueue(format(chunk.toString()));
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
+
isSSE || await new Promise(
|
|
269
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
268
272
|
}
|
|
269
273
|
} catch (error) {
|
|
270
274
|
console.warn(error);
|
|
@@ -5,6 +5,85 @@ import decode from "fast-decode-uri-component";
|
|
|
5
5
|
// src/universal/utils.ts
|
|
6
6
|
var isBun = typeof Bun < "u";
|
|
7
7
|
|
|
8
|
+
// src/universal/file.ts
|
|
9
|
+
var mime = {
|
|
10
|
+
aac: "audio/aac",
|
|
11
|
+
abw: "application/x-abiword",
|
|
12
|
+
ai: "application/postscript",
|
|
13
|
+
arc: "application/octet-stream",
|
|
14
|
+
avi: "video/x-msvideo",
|
|
15
|
+
azw: "application/vnd.amazon.ebook",
|
|
16
|
+
bin: "application/octet-stream",
|
|
17
|
+
bz: "application/x-bzip",
|
|
18
|
+
bz2: "application/x-bzip2",
|
|
19
|
+
csh: "application/x-csh",
|
|
20
|
+
css: "text/css",
|
|
21
|
+
csv: "text/csv",
|
|
22
|
+
doc: "application/msword",
|
|
23
|
+
dll: "application/octet-stream",
|
|
24
|
+
eot: "application/vnd.ms-fontobject",
|
|
25
|
+
epub: "application/epub+zip",
|
|
26
|
+
gif: "image/gif",
|
|
27
|
+
htm: "text/html",
|
|
28
|
+
html: "text/html",
|
|
29
|
+
ico: "image/x-icon",
|
|
30
|
+
ics: "text/calendar",
|
|
31
|
+
jar: "application/java-archive",
|
|
32
|
+
jpeg: "image/jpeg",
|
|
33
|
+
jpg: "image/jpeg",
|
|
34
|
+
js: "application/javascript",
|
|
35
|
+
json: "application/json",
|
|
36
|
+
mid: "audio/midi",
|
|
37
|
+
midi: "audio/midi",
|
|
38
|
+
mp2: "audio/mpeg",
|
|
39
|
+
mp3: "audio/mpeg",
|
|
40
|
+
mp4: "video/mp4",
|
|
41
|
+
mpa: "video/mpeg",
|
|
42
|
+
mpe: "video/mpeg",
|
|
43
|
+
mpeg: "video/mpeg",
|
|
44
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
45
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
46
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
47
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
48
|
+
oga: "audio/ogg",
|
|
49
|
+
ogv: "video/ogg",
|
|
50
|
+
ogx: "application/ogg",
|
|
51
|
+
otf: "font/otf",
|
|
52
|
+
png: "image/png",
|
|
53
|
+
pdf: "application/pdf",
|
|
54
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
55
|
+
rar: "application/x-rar-compressed",
|
|
56
|
+
rtf: "application/rtf",
|
|
57
|
+
sh: "application/x-sh",
|
|
58
|
+
svg: "image/svg+xml",
|
|
59
|
+
swf: "application/x-shockwave-flash",
|
|
60
|
+
tar: "application/x-tar",
|
|
61
|
+
tif: "image/tiff",
|
|
62
|
+
tiff: "image/tiff",
|
|
63
|
+
ts: "application/typescript",
|
|
64
|
+
ttf: "font/ttf",
|
|
65
|
+
txt: "text/plain",
|
|
66
|
+
vsd: "application/vnd.visio",
|
|
67
|
+
wav: "audio/x-wav",
|
|
68
|
+
weba: "audio/webm",
|
|
69
|
+
webm: "video/webm",
|
|
70
|
+
webp: "image/webp",
|
|
71
|
+
woff: "font/woff",
|
|
72
|
+
woff2: "font/woff2",
|
|
73
|
+
xhtml: "application/xhtml+xml",
|
|
74
|
+
xls: "application/vnd.ms-excel",
|
|
75
|
+
xlsx: "application/vnd.ms-excel",
|
|
76
|
+
xlsx_OLD: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
77
|
+
xml: "application/xml",
|
|
78
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
79
|
+
zip: "application/zip",
|
|
80
|
+
"3gp": "video/3gpp",
|
|
81
|
+
"3gp_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp",
|
|
82
|
+
"3gp2": "video/3gpp2",
|
|
83
|
+
"3gp2_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp2",
|
|
84
|
+
"7z": "application/x-7z-compressed"
|
|
85
|
+
};
|
|
86
|
+
|
|
8
87
|
// src/utils.ts
|
|
9
88
|
var hasHeaderShorthand = "toJSON" in new Headers();
|
|
10
89
|
var primitiveHooks = [
|
|
@@ -375,22 +454,26 @@ var handleFile = (response, set2) => {
|
|
|
375
454
|
try {
|
|
376
455
|
for await (let chunk of generator) {
|
|
377
456
|
if (end) break;
|
|
378
|
-
if (chunk != null)
|
|
457
|
+
if (chunk != null)
|
|
379
458
|
if (chunk.toSSE)
|
|
380
459
|
controller.enqueue(chunk.toSSE());
|
|
381
|
-
else
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
460
|
+
else {
|
|
461
|
+
if (typeof chunk == "object")
|
|
462
|
+
try {
|
|
463
|
+
controller.enqueue(
|
|
464
|
+
format(JSON.stringify(chunk))
|
|
465
|
+
);
|
|
466
|
+
} catch {
|
|
467
|
+
controller.enqueue(
|
|
468
|
+
format(chunk.toString())
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
else
|
|
387
472
|
controller.enqueue(format(chunk.toString()));
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
);
|
|
393
|
-
}
|
|
473
|
+
isSSE || await new Promise(
|
|
474
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
394
477
|
}
|
|
395
478
|
} catch (error) {
|
|
396
479
|
console.warn(error);
|
|
@@ -5,6 +5,85 @@ import decode from "fast-decode-uri-component";
|
|
|
5
5
|
// src/universal/utils.ts
|
|
6
6
|
var isBun = typeof Bun < "u";
|
|
7
7
|
|
|
8
|
+
// src/universal/file.ts
|
|
9
|
+
var mime = {
|
|
10
|
+
aac: "audio/aac",
|
|
11
|
+
abw: "application/x-abiword",
|
|
12
|
+
ai: "application/postscript",
|
|
13
|
+
arc: "application/octet-stream",
|
|
14
|
+
avi: "video/x-msvideo",
|
|
15
|
+
azw: "application/vnd.amazon.ebook",
|
|
16
|
+
bin: "application/octet-stream",
|
|
17
|
+
bz: "application/x-bzip",
|
|
18
|
+
bz2: "application/x-bzip2",
|
|
19
|
+
csh: "application/x-csh",
|
|
20
|
+
css: "text/css",
|
|
21
|
+
csv: "text/csv",
|
|
22
|
+
doc: "application/msword",
|
|
23
|
+
dll: "application/octet-stream",
|
|
24
|
+
eot: "application/vnd.ms-fontobject",
|
|
25
|
+
epub: "application/epub+zip",
|
|
26
|
+
gif: "image/gif",
|
|
27
|
+
htm: "text/html",
|
|
28
|
+
html: "text/html",
|
|
29
|
+
ico: "image/x-icon",
|
|
30
|
+
ics: "text/calendar",
|
|
31
|
+
jar: "application/java-archive",
|
|
32
|
+
jpeg: "image/jpeg",
|
|
33
|
+
jpg: "image/jpeg",
|
|
34
|
+
js: "application/javascript",
|
|
35
|
+
json: "application/json",
|
|
36
|
+
mid: "audio/midi",
|
|
37
|
+
midi: "audio/midi",
|
|
38
|
+
mp2: "audio/mpeg",
|
|
39
|
+
mp3: "audio/mpeg",
|
|
40
|
+
mp4: "video/mp4",
|
|
41
|
+
mpa: "video/mpeg",
|
|
42
|
+
mpe: "video/mpeg",
|
|
43
|
+
mpeg: "video/mpeg",
|
|
44
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
45
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
46
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
47
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
48
|
+
oga: "audio/ogg",
|
|
49
|
+
ogv: "video/ogg",
|
|
50
|
+
ogx: "application/ogg",
|
|
51
|
+
otf: "font/otf",
|
|
52
|
+
png: "image/png",
|
|
53
|
+
pdf: "application/pdf",
|
|
54
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
55
|
+
rar: "application/x-rar-compressed",
|
|
56
|
+
rtf: "application/rtf",
|
|
57
|
+
sh: "application/x-sh",
|
|
58
|
+
svg: "image/svg+xml",
|
|
59
|
+
swf: "application/x-shockwave-flash",
|
|
60
|
+
tar: "application/x-tar",
|
|
61
|
+
tif: "image/tiff",
|
|
62
|
+
tiff: "image/tiff",
|
|
63
|
+
ts: "application/typescript",
|
|
64
|
+
ttf: "font/ttf",
|
|
65
|
+
txt: "text/plain",
|
|
66
|
+
vsd: "application/vnd.visio",
|
|
67
|
+
wav: "audio/x-wav",
|
|
68
|
+
weba: "audio/webm",
|
|
69
|
+
webm: "video/webm",
|
|
70
|
+
webp: "image/webp",
|
|
71
|
+
woff: "font/woff",
|
|
72
|
+
woff2: "font/woff2",
|
|
73
|
+
xhtml: "application/xhtml+xml",
|
|
74
|
+
xls: "application/vnd.ms-excel",
|
|
75
|
+
xlsx: "application/vnd.ms-excel",
|
|
76
|
+
xlsx_OLD: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
77
|
+
xml: "application/xml",
|
|
78
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
79
|
+
zip: "application/zip",
|
|
80
|
+
"3gp": "video/3gpp",
|
|
81
|
+
"3gp_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp",
|
|
82
|
+
"3gp2": "video/3gpp2",
|
|
83
|
+
"3gp2_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp2",
|
|
84
|
+
"7z": "application/x-7z-compressed"
|
|
85
|
+
};
|
|
86
|
+
|
|
8
87
|
// src/utils.ts
|
|
9
88
|
var hasHeaderShorthand = "toJSON" in new Headers();
|
|
10
89
|
var primitiveHooks = [
|
|
@@ -375,22 +454,26 @@ var handleFile = (response, set2) => {
|
|
|
375
454
|
try {
|
|
376
455
|
for await (let chunk of generator) {
|
|
377
456
|
if (end) break;
|
|
378
|
-
if (chunk != null)
|
|
457
|
+
if (chunk != null)
|
|
379
458
|
if (chunk.toSSE)
|
|
380
459
|
controller.enqueue(chunk.toSSE());
|
|
381
|
-
else
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
460
|
+
else {
|
|
461
|
+
if (typeof chunk == "object")
|
|
462
|
+
try {
|
|
463
|
+
controller.enqueue(
|
|
464
|
+
format(JSON.stringify(chunk))
|
|
465
|
+
);
|
|
466
|
+
} catch {
|
|
467
|
+
controller.enqueue(
|
|
468
|
+
format(chunk.toString())
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
else
|
|
387
472
|
controller.enqueue(format(chunk.toString()));
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
);
|
|
393
|
-
}
|
|
473
|
+
isSSE || await new Promise(
|
|
474
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
475
|
+
);
|
|
476
|
+
}
|
|
394
477
|
}
|
|
395
478
|
} catch (error) {
|
|
396
479
|
console.warn(error);
|