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
|
@@ -709,22 +709,26 @@ var handleFile = (response, set2) => {
|
|
|
709
709
|
try {
|
|
710
710
|
for await (let chunk of generator) {
|
|
711
711
|
if (end) break;
|
|
712
|
-
if (chunk != null)
|
|
712
|
+
if (chunk != null)
|
|
713
713
|
if (chunk.toSSE)
|
|
714
714
|
controller.enqueue(chunk.toSSE());
|
|
715
|
-
else
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
715
|
+
else {
|
|
716
|
+
if (typeof chunk == "object")
|
|
717
|
+
try {
|
|
718
|
+
controller.enqueue(
|
|
719
|
+
format(JSON.stringify(chunk))
|
|
720
|
+
);
|
|
721
|
+
} catch {
|
|
722
|
+
controller.enqueue(
|
|
723
|
+
format(chunk.toString())
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
else
|
|
721
727
|
controller.enqueue(format(chunk.toString()));
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
);
|
|
727
|
-
}
|
|
728
|
+
isSSE || await new Promise(
|
|
729
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
730
|
+
);
|
|
731
|
+
}
|
|
728
732
|
}
|
|
729
733
|
} catch (error) {
|
|
730
734
|
console.warn(error);
|
|
@@ -36,7 +36,7 @@ var import_cookie = require("cookie"), import_fast_decode_uri_component = __toES
|
|
|
36
36
|
var isBun = typeof Bun < "u";
|
|
37
37
|
|
|
38
38
|
// src/universal/file.ts
|
|
39
|
-
var
|
|
39
|
+
var mime = {
|
|
40
40
|
aac: "audio/aac",
|
|
41
41
|
abw: "application/x-abiword",
|
|
42
42
|
ai: "application/postscript",
|
|
@@ -133,7 +133,7 @@ var createReadStream, stat, ElysiaFile = class {
|
|
|
133
133
|
get type() {
|
|
134
134
|
return (
|
|
135
135
|
// @ts-ignore
|
|
136
|
-
|
|
136
|
+
mime[getFileExtension(this.path)] || "application/octet-stream"
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
get length() {
|
|
@@ -723,22 +723,26 @@ var handleFile = (response, set2) => {
|
|
|
723
723
|
try {
|
|
724
724
|
for await (let chunk of generator) {
|
|
725
725
|
if (end) break;
|
|
726
|
-
if (chunk != null)
|
|
726
|
+
if (chunk != null)
|
|
727
727
|
if (chunk.toSSE)
|
|
728
728
|
controller.enqueue(chunk.toSSE());
|
|
729
|
-
else
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
729
|
+
else {
|
|
730
|
+
if (typeof chunk == "object")
|
|
731
|
+
try {
|
|
732
|
+
controller.enqueue(
|
|
733
|
+
format(JSON.stringify(chunk))
|
|
734
|
+
);
|
|
735
|
+
} catch {
|
|
736
|
+
controller.enqueue(
|
|
737
|
+
format(chunk.toString())
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
else
|
|
735
741
|
controller.enqueue(format(chunk.toString()));
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
);
|
|
741
|
-
}
|
|
742
|
+
isSSE || await new Promise(
|
|
743
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
744
|
+
);
|
|
745
|
+
}
|
|
742
746
|
}
|
|
743
747
|
} catch (error) {
|
|
744
748
|
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,
|
|
@@ -409,22 +409,26 @@ var handleFile = (response, set2) => {
|
|
|
409
409
|
try {
|
|
410
410
|
for await (let chunk of generator) {
|
|
411
411
|
if (end) break;
|
|
412
|
-
if (chunk != null)
|
|
412
|
+
if (chunk != null)
|
|
413
413
|
if (chunk.toSSE)
|
|
414
414
|
controller.enqueue(chunk.toSSE());
|
|
415
|
-
else
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
415
|
+
else {
|
|
416
|
+
if (typeof chunk == "object")
|
|
417
|
+
try {
|
|
418
|
+
controller.enqueue(
|
|
419
|
+
format(JSON.stringify(chunk))
|
|
420
|
+
);
|
|
421
|
+
} catch {
|
|
422
|
+
controller.enqueue(
|
|
423
|
+
format(chunk.toString())
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
else
|
|
421
427
|
controller.enqueue(format(chunk.toString()));
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
+
isSSE || await new Promise(
|
|
429
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
430
|
+
);
|
|
431
|
+
}
|
|
428
432
|
}
|
|
429
433
|
} catch (error) {
|
|
430
434
|
console.warn(error);
|
|
@@ -37,7 +37,7 @@ var import_cookie = require("cookie"), import_fast_decode_uri_component = __toES
|
|
|
37
37
|
var isBun = typeof Bun < "u";
|
|
38
38
|
|
|
39
39
|
// src/universal/file.ts
|
|
40
|
-
var
|
|
40
|
+
var mime = {
|
|
41
41
|
aac: "audio/aac",
|
|
42
42
|
abw: "application/x-abiword",
|
|
43
43
|
ai: "application/postscript",
|
|
@@ -134,7 +134,7 @@ var createReadStream, stat, ElysiaFile = class {
|
|
|
134
134
|
get type() {
|
|
135
135
|
return (
|
|
136
136
|
// @ts-ignore
|
|
137
|
-
|
|
137
|
+
mime[getFileExtension(this.path)] || "application/octet-stream"
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
get length() {
|
|
@@ -724,22 +724,26 @@ var handleFile = (response, set2) => {
|
|
|
724
724
|
try {
|
|
725
725
|
for await (let chunk of generator) {
|
|
726
726
|
if (end) break;
|
|
727
|
-
if (chunk != null)
|
|
727
|
+
if (chunk != null)
|
|
728
728
|
if (chunk.toSSE)
|
|
729
729
|
controller.enqueue(chunk.toSSE());
|
|
730
|
-
else
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
730
|
+
else {
|
|
731
|
+
if (typeof chunk == "object")
|
|
732
|
+
try {
|
|
733
|
+
controller.enqueue(
|
|
734
|
+
format(JSON.stringify(chunk))
|
|
735
|
+
);
|
|
736
|
+
} catch {
|
|
737
|
+
controller.enqueue(
|
|
738
|
+
format(chunk.toString())
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
else
|
|
736
742
|
controller.enqueue(format(chunk.toString()));
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
+
isSSE || await new Promise(
|
|
744
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
745
|
+
);
|
|
746
|
+
}
|
|
743
747
|
}
|
|
744
748
|
} catch (error) {
|
|
745
749
|
console.warn(error);
|
|
@@ -3429,7 +3433,9 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3429
3433
|
),
|
|
3430
3434
|
websocket: {
|
|
3431
3435
|
...app.config.websocket || {},
|
|
3432
|
-
...websocket || {}
|
|
3436
|
+
...websocket || {},
|
|
3437
|
+
// @ts-expect-error not available in this variant of options type
|
|
3438
|
+
...options.websocket || {}
|
|
3433
3439
|
},
|
|
3434
3440
|
fetch: app.fetch
|
|
3435
3441
|
} : {
|
|
@@ -3535,7 +3541,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3535
3541
|
...(app.event.error ?? []).map(
|
|
3536
3542
|
(x) => typeof x == "function" ? x : x.fn
|
|
3537
3543
|
)
|
|
3538
|
-
].filter((x) => x),
|
|
3544
|
+
].filter((x) => x), hasCustomErrorHandlers = errorHandlers.length > 0, handleErrors = hasCustomErrorHandlers ? async (ws, error) => {
|
|
3539
3545
|
for (let handleError of errorHandlers) {
|
|
3540
3546
|
let response2 = handleError(
|
|
3541
3547
|
Object.assign(context, { error })
|
|
@@ -3572,14 +3578,14 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
|
|
|
3572
3578
|
},
|
|
3573
3579
|
message: async (ws, _message) => {
|
|
3574
3580
|
let message = await parseMessage(ws, _message);
|
|
3575
|
-
if (validateMessage?.Check(message) === !1)
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
message
|
|
3581
|
-
).message
|
|
3581
|
+
if (validateMessage?.Check(message) === !1) {
|
|
3582
|
+
let validationError = new ValidationError(
|
|
3583
|
+
"message",
|
|
3584
|
+
validateMessage,
|
|
3585
|
+
message
|
|
3582
3586
|
);
|
|
3587
|
+
return hasCustomErrorHandlers ? handleErrors(ws, validationError) : void ws.send(validationError.message);
|
|
3588
|
+
}
|
|
3583
3589
|
try {
|
|
3584
3590
|
await handleResponse3(
|
|
3585
3591
|
ws,
|
|
@@ -285,22 +285,26 @@ var handleFile = (response, set) => {
|
|
|
285
285
|
try {
|
|
286
286
|
for await (let chunk of generator) {
|
|
287
287
|
if (end) break;
|
|
288
|
-
if (chunk != null)
|
|
288
|
+
if (chunk != null)
|
|
289
289
|
if (chunk.toSSE)
|
|
290
290
|
controller.enqueue(chunk.toSSE());
|
|
291
|
-
else
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
else {
|
|
292
|
+
if (typeof chunk == "object")
|
|
293
|
+
try {
|
|
294
|
+
controller.enqueue(
|
|
295
|
+
format(JSON.stringify(chunk))
|
|
296
|
+
);
|
|
297
|
+
} catch {
|
|
298
|
+
controller.enqueue(
|
|
299
|
+
format(chunk.toString())
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
else
|
|
297
303
|
controller.enqueue(format(chunk.toString()));
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
+
isSSE || await new Promise(
|
|
305
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
306
|
+
);
|
|
307
|
+
}
|
|
304
308
|
}
|
|
305
309
|
} catch (error) {
|
|
306
310
|
console.warn(error);
|
|
@@ -39,6 +39,85 @@ var import_cookie = require("cookie"), import_fast_decode_uri_component = __toES
|
|
|
39
39
|
// src/universal/utils.ts
|
|
40
40
|
var isBun = typeof Bun < "u";
|
|
41
41
|
|
|
42
|
+
// src/universal/file.ts
|
|
43
|
+
var mime = {
|
|
44
|
+
aac: "audio/aac",
|
|
45
|
+
abw: "application/x-abiword",
|
|
46
|
+
ai: "application/postscript",
|
|
47
|
+
arc: "application/octet-stream",
|
|
48
|
+
avi: "video/x-msvideo",
|
|
49
|
+
azw: "application/vnd.amazon.ebook",
|
|
50
|
+
bin: "application/octet-stream",
|
|
51
|
+
bz: "application/x-bzip",
|
|
52
|
+
bz2: "application/x-bzip2",
|
|
53
|
+
csh: "application/x-csh",
|
|
54
|
+
css: "text/css",
|
|
55
|
+
csv: "text/csv",
|
|
56
|
+
doc: "application/msword",
|
|
57
|
+
dll: "application/octet-stream",
|
|
58
|
+
eot: "application/vnd.ms-fontobject",
|
|
59
|
+
epub: "application/epub+zip",
|
|
60
|
+
gif: "image/gif",
|
|
61
|
+
htm: "text/html",
|
|
62
|
+
html: "text/html",
|
|
63
|
+
ico: "image/x-icon",
|
|
64
|
+
ics: "text/calendar",
|
|
65
|
+
jar: "application/java-archive",
|
|
66
|
+
jpeg: "image/jpeg",
|
|
67
|
+
jpg: "image/jpeg",
|
|
68
|
+
js: "application/javascript",
|
|
69
|
+
json: "application/json",
|
|
70
|
+
mid: "audio/midi",
|
|
71
|
+
midi: "audio/midi",
|
|
72
|
+
mp2: "audio/mpeg",
|
|
73
|
+
mp3: "audio/mpeg",
|
|
74
|
+
mp4: "video/mp4",
|
|
75
|
+
mpa: "video/mpeg",
|
|
76
|
+
mpe: "video/mpeg",
|
|
77
|
+
mpeg: "video/mpeg",
|
|
78
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
79
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
80
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
81
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
82
|
+
oga: "audio/ogg",
|
|
83
|
+
ogv: "video/ogg",
|
|
84
|
+
ogx: "application/ogg",
|
|
85
|
+
otf: "font/otf",
|
|
86
|
+
png: "image/png",
|
|
87
|
+
pdf: "application/pdf",
|
|
88
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
89
|
+
rar: "application/x-rar-compressed",
|
|
90
|
+
rtf: "application/rtf",
|
|
91
|
+
sh: "application/x-sh",
|
|
92
|
+
svg: "image/svg+xml",
|
|
93
|
+
swf: "application/x-shockwave-flash",
|
|
94
|
+
tar: "application/x-tar",
|
|
95
|
+
tif: "image/tiff",
|
|
96
|
+
tiff: "image/tiff",
|
|
97
|
+
ts: "application/typescript",
|
|
98
|
+
ttf: "font/ttf",
|
|
99
|
+
txt: "text/plain",
|
|
100
|
+
vsd: "application/vnd.visio",
|
|
101
|
+
wav: "audio/x-wav",
|
|
102
|
+
weba: "audio/webm",
|
|
103
|
+
webm: "video/webm",
|
|
104
|
+
webp: "image/webp",
|
|
105
|
+
woff: "font/woff",
|
|
106
|
+
woff2: "font/woff2",
|
|
107
|
+
xhtml: "application/xhtml+xml",
|
|
108
|
+
xls: "application/vnd.ms-excel",
|
|
109
|
+
xlsx: "application/vnd.ms-excel",
|
|
110
|
+
xlsx_OLD: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
111
|
+
xml: "application/xml",
|
|
112
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
113
|
+
zip: "application/zip",
|
|
114
|
+
"3gp": "video/3gpp",
|
|
115
|
+
"3gp_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp",
|
|
116
|
+
"3gp2": "video/3gpp2",
|
|
117
|
+
"3gp2_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp2",
|
|
118
|
+
"7z": "application/x-7z-compressed"
|
|
119
|
+
};
|
|
120
|
+
|
|
42
121
|
// src/utils.ts
|
|
43
122
|
var hasHeaderShorthand = "toJSON" in new Headers();
|
|
44
123
|
var primitiveHooks = [
|
|
@@ -409,22 +488,26 @@ var handleFile = (response, set2) => {
|
|
|
409
488
|
try {
|
|
410
489
|
for await (let chunk of generator) {
|
|
411
490
|
if (end) break;
|
|
412
|
-
if (chunk != null)
|
|
491
|
+
if (chunk != null)
|
|
413
492
|
if (chunk.toSSE)
|
|
414
493
|
controller.enqueue(chunk.toSSE());
|
|
415
|
-
else
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
494
|
+
else {
|
|
495
|
+
if (typeof chunk == "object")
|
|
496
|
+
try {
|
|
497
|
+
controller.enqueue(
|
|
498
|
+
format(JSON.stringify(chunk))
|
|
499
|
+
);
|
|
500
|
+
} catch {
|
|
501
|
+
controller.enqueue(
|
|
502
|
+
format(chunk.toString())
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
else
|
|
421
506
|
controller.enqueue(format(chunk.toString()));
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
);
|
|
427
|
-
}
|
|
507
|
+
isSSE || await new Promise(
|
|
508
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
428
511
|
}
|
|
429
512
|
} catch (error) {
|
|
430
513
|
console.warn(error);
|
|
@@ -35,6 +35,85 @@ var import_cookie = require("cookie"), import_fast_decode_uri_component = __toES
|
|
|
35
35
|
// src/universal/utils.ts
|
|
36
36
|
var isBun = typeof Bun < "u";
|
|
37
37
|
|
|
38
|
+
// src/universal/file.ts
|
|
39
|
+
var mime = {
|
|
40
|
+
aac: "audio/aac",
|
|
41
|
+
abw: "application/x-abiword",
|
|
42
|
+
ai: "application/postscript",
|
|
43
|
+
arc: "application/octet-stream",
|
|
44
|
+
avi: "video/x-msvideo",
|
|
45
|
+
azw: "application/vnd.amazon.ebook",
|
|
46
|
+
bin: "application/octet-stream",
|
|
47
|
+
bz: "application/x-bzip",
|
|
48
|
+
bz2: "application/x-bzip2",
|
|
49
|
+
csh: "application/x-csh",
|
|
50
|
+
css: "text/css",
|
|
51
|
+
csv: "text/csv",
|
|
52
|
+
doc: "application/msword",
|
|
53
|
+
dll: "application/octet-stream",
|
|
54
|
+
eot: "application/vnd.ms-fontobject",
|
|
55
|
+
epub: "application/epub+zip",
|
|
56
|
+
gif: "image/gif",
|
|
57
|
+
htm: "text/html",
|
|
58
|
+
html: "text/html",
|
|
59
|
+
ico: "image/x-icon",
|
|
60
|
+
ics: "text/calendar",
|
|
61
|
+
jar: "application/java-archive",
|
|
62
|
+
jpeg: "image/jpeg",
|
|
63
|
+
jpg: "image/jpeg",
|
|
64
|
+
js: "application/javascript",
|
|
65
|
+
json: "application/json",
|
|
66
|
+
mid: "audio/midi",
|
|
67
|
+
midi: "audio/midi",
|
|
68
|
+
mp2: "audio/mpeg",
|
|
69
|
+
mp3: "audio/mpeg",
|
|
70
|
+
mp4: "video/mp4",
|
|
71
|
+
mpa: "video/mpeg",
|
|
72
|
+
mpe: "video/mpeg",
|
|
73
|
+
mpeg: "video/mpeg",
|
|
74
|
+
mpkg: "application/vnd.apple.installer+xml",
|
|
75
|
+
odp: "application/vnd.oasis.opendocument.presentation",
|
|
76
|
+
ods: "application/vnd.oasis.opendocument.spreadsheet",
|
|
77
|
+
odt: "application/vnd.oasis.opendocument.text",
|
|
78
|
+
oga: "audio/ogg",
|
|
79
|
+
ogv: "video/ogg",
|
|
80
|
+
ogx: "application/ogg",
|
|
81
|
+
otf: "font/otf",
|
|
82
|
+
png: "image/png",
|
|
83
|
+
pdf: "application/pdf",
|
|
84
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
85
|
+
rar: "application/x-rar-compressed",
|
|
86
|
+
rtf: "application/rtf",
|
|
87
|
+
sh: "application/x-sh",
|
|
88
|
+
svg: "image/svg+xml",
|
|
89
|
+
swf: "application/x-shockwave-flash",
|
|
90
|
+
tar: "application/x-tar",
|
|
91
|
+
tif: "image/tiff",
|
|
92
|
+
tiff: "image/tiff",
|
|
93
|
+
ts: "application/typescript",
|
|
94
|
+
ttf: "font/ttf",
|
|
95
|
+
txt: "text/plain",
|
|
96
|
+
vsd: "application/vnd.visio",
|
|
97
|
+
wav: "audio/x-wav",
|
|
98
|
+
weba: "audio/webm",
|
|
99
|
+
webm: "video/webm",
|
|
100
|
+
webp: "image/webp",
|
|
101
|
+
woff: "font/woff",
|
|
102
|
+
woff2: "font/woff2",
|
|
103
|
+
xhtml: "application/xhtml+xml",
|
|
104
|
+
xls: "application/vnd.ms-excel",
|
|
105
|
+
xlsx: "application/vnd.ms-excel",
|
|
106
|
+
xlsx_OLD: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
107
|
+
xml: "application/xml",
|
|
108
|
+
xul: "application/vnd.mozilla.xul+xml",
|
|
109
|
+
zip: "application/zip",
|
|
110
|
+
"3gp": "video/3gpp",
|
|
111
|
+
"3gp_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp",
|
|
112
|
+
"3gp2": "video/3gpp2",
|
|
113
|
+
"3gp2_DOES_NOT_CONTAIN_VIDEO": "audio/3gpp2",
|
|
114
|
+
"7z": "application/x-7z-compressed"
|
|
115
|
+
};
|
|
116
|
+
|
|
38
117
|
// src/utils.ts
|
|
39
118
|
var hasHeaderShorthand = "toJSON" in new Headers();
|
|
40
119
|
var primitiveHooks = [
|
|
@@ -405,22 +484,26 @@ var handleFile = (response, set2) => {
|
|
|
405
484
|
try {
|
|
406
485
|
for await (let chunk of generator) {
|
|
407
486
|
if (end) break;
|
|
408
|
-
if (chunk != null)
|
|
487
|
+
if (chunk != null)
|
|
409
488
|
if (chunk.toSSE)
|
|
410
489
|
controller.enqueue(chunk.toSSE());
|
|
411
|
-
else
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
490
|
+
else {
|
|
491
|
+
if (typeof chunk == "object")
|
|
492
|
+
try {
|
|
493
|
+
controller.enqueue(
|
|
494
|
+
format(JSON.stringify(chunk))
|
|
495
|
+
);
|
|
496
|
+
} catch {
|
|
497
|
+
controller.enqueue(
|
|
498
|
+
format(chunk.toString())
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
else
|
|
417
502
|
controller.enqueue(format(chunk.toString()));
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
);
|
|
423
|
-
}
|
|
503
|
+
isSSE || await new Promise(
|
|
504
|
+
(resolve) => setTimeout(() => resolve(), 0)
|
|
505
|
+
);
|
|
506
|
+
}
|
|
424
507
|
}
|
|
425
508
|
} catch (error) {
|
|
426
509
|
console.warn(error);
|