@siddharatha/adapter-node-rolldown 1.1.5 → 1.1.7
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/files/env.js +21 -86
- package/files/handler.js +865 -1231
- package/files/index.js +223 -469
- package/files/shims.js +12 -13
- package/index.js +13 -6
- package/package.json +55 -50
package/files/handler.js
CHANGED
|
@@ -1,1201 +1,982 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import "SHIMS";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import * as fs$1 from "fs";
|
|
5
|
+
import { readdirSync, statSync } from "fs";
|
|
6
|
+
import { join, normalize, resolve } from "path";
|
|
7
|
+
import * as qs from "node:querystring";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import "node:stream";
|
|
10
|
+
import { Server } from "SERVER";
|
|
11
|
+
import { manifest, prerendered } from "MANIFEST";
|
|
12
|
+
import { env } from "ENV";
|
|
13
|
+
|
|
14
|
+
//#region rolldown:runtime
|
|
15
|
+
var __create = Object.create;
|
|
16
|
+
var __defProp = Object.defineProperty;
|
|
17
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
18
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
19
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
20
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
21
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
25
|
+
key = keys[i];
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: ((k) => from[k]).bind(null, key),
|
|
29
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
37
|
+
value: mod,
|
|
38
|
+
enumerable: true
|
|
39
|
+
}) : target, mod));
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region node_modules/.pnpm/totalist@3.0.1/node_modules/totalist/sync/index.mjs
|
|
43
|
+
function totalist(dir$1, callback, pre = "") {
|
|
44
|
+
dir$1 = resolve(".", dir$1);
|
|
45
|
+
let arr = readdirSync(dir$1);
|
|
46
|
+
let i = 0, abs, stats;
|
|
17
47
|
for (; i < arr.length; i++) {
|
|
18
|
-
abs = join(dir, arr[i]);
|
|
48
|
+
abs = join(dir$1, arr[i]);
|
|
19
49
|
stats = statSync(abs);
|
|
20
|
-
stats.isDirectory()
|
|
21
|
-
? totalist(abs, callback, join(pre, arr[i]))
|
|
22
|
-
: callback(join(pre, arr[i]), abs, stats);
|
|
50
|
+
stats.isDirectory() ? totalist(abs, callback, join(pre, arr[i])) : callback(join(pre, arr[i]), abs, stats);
|
|
23
51
|
}
|
|
24
52
|
}
|
|
25
53
|
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region node_modules/.pnpm/@polka+url@1.0.0-next.29/node_modules/@polka/url/build.mjs
|
|
26
56
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
* @typedef ParsedURL
|
|
58
|
+
* @type {import('.').ParsedURL}
|
|
59
|
+
*/
|
|
31
60
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
61
|
+
* @typedef Request
|
|
62
|
+
* @property {string} url
|
|
63
|
+
* @property {ParsedURL} _parsedUrl
|
|
64
|
+
*/
|
|
37
65
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
* @param {Request} req
|
|
67
|
+
* @returns {ParsedURL|void}
|
|
68
|
+
*/
|
|
41
69
|
function parse(req) {
|
|
42
70
|
let raw = req.url;
|
|
43
71
|
if (raw == null) return;
|
|
44
|
-
|
|
45
72
|
let prev = req._parsedUrl;
|
|
46
73
|
if (prev && prev.raw === raw) return prev;
|
|
47
|
-
|
|
48
|
-
let pathname=raw, search='', query, hash;
|
|
49
|
-
|
|
74
|
+
let pathname = raw, search = "", query, hash;
|
|
50
75
|
if (raw.length > 1) {
|
|
51
|
-
let idx = raw.indexOf(
|
|
52
|
-
|
|
76
|
+
let idx = raw.indexOf("#", 1);
|
|
53
77
|
if (idx !== -1) {
|
|
54
78
|
hash = raw.substring(idx);
|
|
55
79
|
pathname = raw.substring(0, idx);
|
|
56
80
|
}
|
|
57
|
-
|
|
58
|
-
idx = pathname.indexOf('?', 1);
|
|
59
|
-
|
|
81
|
+
idx = pathname.indexOf("?", 1);
|
|
60
82
|
if (idx !== -1) {
|
|
61
83
|
search = pathname.substring(idx);
|
|
62
84
|
pathname = pathname.substring(0, idx);
|
|
63
|
-
if (search.length > 1)
|
|
64
|
-
query = qs.parse(search.substring(1));
|
|
65
|
-
}
|
|
85
|
+
if (search.length > 1) query = qs.parse(search.substring(1));
|
|
66
86
|
}
|
|
67
87
|
}
|
|
68
|
-
|
|
69
|
-
|
|
88
|
+
return req._parsedUrl = {
|
|
89
|
+
pathname,
|
|
90
|
+
search,
|
|
91
|
+
query,
|
|
92
|
+
hash,
|
|
93
|
+
raw
|
|
94
|
+
};
|
|
70
95
|
}
|
|
71
96
|
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region node_modules/.pnpm/mrmime@2.0.1/node_modules/mrmime/index.mjs
|
|
72
99
|
const mimes = {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
100
|
+
"3g2": "video/3gpp2",
|
|
101
|
+
"3gp": "video/3gpp",
|
|
102
|
+
"3gpp": "video/3gpp",
|
|
103
|
+
"3mf": "model/3mf",
|
|
104
|
+
"aac": "audio/aac",
|
|
105
|
+
"ac": "application/pkix-attr-cert",
|
|
106
|
+
"adp": "audio/adpcm",
|
|
107
|
+
"adts": "audio/aac",
|
|
108
|
+
"ai": "application/postscript",
|
|
109
|
+
"aml": "application/automationml-aml+xml",
|
|
110
|
+
"amlx": "application/automationml-amlx+zip",
|
|
111
|
+
"amr": "audio/amr",
|
|
112
|
+
"apng": "image/apng",
|
|
113
|
+
"appcache": "text/cache-manifest",
|
|
114
|
+
"appinstaller": "application/appinstaller",
|
|
115
|
+
"appx": "application/appx",
|
|
116
|
+
"appxbundle": "application/appxbundle",
|
|
117
|
+
"asc": "application/pgp-keys",
|
|
118
|
+
"atom": "application/atom+xml",
|
|
119
|
+
"atomcat": "application/atomcat+xml",
|
|
120
|
+
"atomdeleted": "application/atomdeleted+xml",
|
|
121
|
+
"atomsvc": "application/atomsvc+xml",
|
|
122
|
+
"au": "audio/basic",
|
|
123
|
+
"avci": "image/avci",
|
|
124
|
+
"avcs": "image/avcs",
|
|
125
|
+
"avif": "image/avif",
|
|
126
|
+
"aw": "application/applixware",
|
|
127
|
+
"bdoc": "application/bdoc",
|
|
128
|
+
"bin": "application/octet-stream",
|
|
129
|
+
"bmp": "image/bmp",
|
|
130
|
+
"bpk": "application/octet-stream",
|
|
131
|
+
"btf": "image/prs.btif",
|
|
132
|
+
"btif": "image/prs.btif",
|
|
133
|
+
"buffer": "application/octet-stream",
|
|
134
|
+
"ccxml": "application/ccxml+xml",
|
|
135
|
+
"cdfx": "application/cdfx+xml",
|
|
136
|
+
"cdmia": "application/cdmi-capability",
|
|
137
|
+
"cdmic": "application/cdmi-container",
|
|
138
|
+
"cdmid": "application/cdmi-domain",
|
|
139
|
+
"cdmio": "application/cdmi-object",
|
|
140
|
+
"cdmiq": "application/cdmi-queue",
|
|
141
|
+
"cer": "application/pkix-cert",
|
|
142
|
+
"cgm": "image/cgm",
|
|
143
|
+
"cjs": "application/node",
|
|
144
|
+
"class": "application/java-vm",
|
|
145
|
+
"coffee": "text/coffeescript",
|
|
146
|
+
"conf": "text/plain",
|
|
147
|
+
"cpl": "application/cpl+xml",
|
|
148
|
+
"cpt": "application/mac-compactpro",
|
|
149
|
+
"crl": "application/pkix-crl",
|
|
150
|
+
"css": "text/css",
|
|
151
|
+
"csv": "text/csv",
|
|
152
|
+
"cu": "application/cu-seeme",
|
|
153
|
+
"cwl": "application/cwl",
|
|
154
|
+
"cww": "application/prs.cww",
|
|
155
|
+
"davmount": "application/davmount+xml",
|
|
156
|
+
"dbk": "application/docbook+xml",
|
|
157
|
+
"deb": "application/octet-stream",
|
|
158
|
+
"def": "text/plain",
|
|
159
|
+
"deploy": "application/octet-stream",
|
|
160
|
+
"dib": "image/bmp",
|
|
161
|
+
"disposition-notification": "message/disposition-notification",
|
|
162
|
+
"dist": "application/octet-stream",
|
|
163
|
+
"distz": "application/octet-stream",
|
|
164
|
+
"dll": "application/octet-stream",
|
|
165
|
+
"dmg": "application/octet-stream",
|
|
166
|
+
"dms": "application/octet-stream",
|
|
167
|
+
"doc": "application/msword",
|
|
168
|
+
"dot": "application/msword",
|
|
169
|
+
"dpx": "image/dpx",
|
|
170
|
+
"drle": "image/dicom-rle",
|
|
171
|
+
"dsc": "text/prs.lines.tag",
|
|
172
|
+
"dssc": "application/dssc+der",
|
|
173
|
+
"dtd": "application/xml-dtd",
|
|
174
|
+
"dump": "application/octet-stream",
|
|
175
|
+
"dwd": "application/atsc-dwd+xml",
|
|
176
|
+
"ear": "application/java-archive",
|
|
177
|
+
"ecma": "application/ecmascript",
|
|
178
|
+
"elc": "application/octet-stream",
|
|
179
|
+
"emf": "image/emf",
|
|
180
|
+
"eml": "message/rfc822",
|
|
181
|
+
"emma": "application/emma+xml",
|
|
182
|
+
"emotionml": "application/emotionml+xml",
|
|
183
|
+
"eps": "application/postscript",
|
|
184
|
+
"epub": "application/epub+zip",
|
|
185
|
+
"exe": "application/octet-stream",
|
|
186
|
+
"exi": "application/exi",
|
|
187
|
+
"exp": "application/express",
|
|
188
|
+
"exr": "image/aces",
|
|
189
|
+
"ez": "application/andrew-inset",
|
|
190
|
+
"fdf": "application/fdf",
|
|
191
|
+
"fdt": "application/fdt+xml",
|
|
192
|
+
"fits": "image/fits",
|
|
193
|
+
"g3": "image/g3fax",
|
|
194
|
+
"gbr": "application/rpki-ghostbusters",
|
|
195
|
+
"geojson": "application/geo+json",
|
|
196
|
+
"gif": "image/gif",
|
|
197
|
+
"glb": "model/gltf-binary",
|
|
198
|
+
"gltf": "model/gltf+json",
|
|
199
|
+
"gml": "application/gml+xml",
|
|
200
|
+
"gpx": "application/gpx+xml",
|
|
201
|
+
"gram": "application/srgs",
|
|
202
|
+
"grxml": "application/srgs+xml",
|
|
203
|
+
"gxf": "application/gxf",
|
|
204
|
+
"gz": "application/gzip",
|
|
205
|
+
"h261": "video/h261",
|
|
206
|
+
"h263": "video/h263",
|
|
207
|
+
"h264": "video/h264",
|
|
208
|
+
"heic": "image/heic",
|
|
209
|
+
"heics": "image/heic-sequence",
|
|
210
|
+
"heif": "image/heif",
|
|
211
|
+
"heifs": "image/heif-sequence",
|
|
212
|
+
"hej2": "image/hej2k",
|
|
213
|
+
"held": "application/atsc-held+xml",
|
|
214
|
+
"hjson": "application/hjson",
|
|
215
|
+
"hlp": "application/winhlp",
|
|
216
|
+
"hqx": "application/mac-binhex40",
|
|
217
|
+
"hsj2": "image/hsj2",
|
|
218
|
+
"htm": "text/html",
|
|
219
|
+
"html": "text/html",
|
|
220
|
+
"ics": "text/calendar",
|
|
221
|
+
"ief": "image/ief",
|
|
222
|
+
"ifb": "text/calendar",
|
|
223
|
+
"iges": "model/iges",
|
|
224
|
+
"igs": "model/iges",
|
|
225
|
+
"img": "application/octet-stream",
|
|
226
|
+
"in": "text/plain",
|
|
227
|
+
"ini": "text/plain",
|
|
228
|
+
"ink": "application/inkml+xml",
|
|
229
|
+
"inkml": "application/inkml+xml",
|
|
230
|
+
"ipfix": "application/ipfix",
|
|
231
|
+
"iso": "application/octet-stream",
|
|
232
|
+
"its": "application/its+xml",
|
|
233
|
+
"jade": "text/jade",
|
|
234
|
+
"jar": "application/java-archive",
|
|
235
|
+
"jhc": "image/jphc",
|
|
236
|
+
"jls": "image/jls",
|
|
237
|
+
"jp2": "image/jp2",
|
|
238
|
+
"jpe": "image/jpeg",
|
|
239
|
+
"jpeg": "image/jpeg",
|
|
240
|
+
"jpf": "image/jpx",
|
|
241
|
+
"jpg": "image/jpeg",
|
|
242
|
+
"jpg2": "image/jp2",
|
|
243
|
+
"jpgm": "image/jpm",
|
|
244
|
+
"jpgv": "video/jpeg",
|
|
245
|
+
"jph": "image/jph",
|
|
246
|
+
"jpm": "image/jpm",
|
|
247
|
+
"jpx": "image/jpx",
|
|
248
|
+
"js": "text/javascript",
|
|
249
|
+
"json": "application/json",
|
|
250
|
+
"json5": "application/json5",
|
|
251
|
+
"jsonld": "application/ld+json",
|
|
252
|
+
"jsonml": "application/jsonml+json",
|
|
253
|
+
"jsx": "text/jsx",
|
|
254
|
+
"jt": "model/jt",
|
|
255
|
+
"jxl": "image/jxl",
|
|
256
|
+
"jxr": "image/jxr",
|
|
257
|
+
"jxra": "image/jxra",
|
|
258
|
+
"jxrs": "image/jxrs",
|
|
259
|
+
"jxs": "image/jxs",
|
|
260
|
+
"jxsc": "image/jxsc",
|
|
261
|
+
"jxsi": "image/jxsi",
|
|
262
|
+
"jxss": "image/jxss",
|
|
263
|
+
"kar": "audio/midi",
|
|
264
|
+
"ktx": "image/ktx",
|
|
265
|
+
"ktx2": "image/ktx2",
|
|
266
|
+
"less": "text/less",
|
|
267
|
+
"lgr": "application/lgr+xml",
|
|
268
|
+
"list": "text/plain",
|
|
269
|
+
"litcoffee": "text/coffeescript",
|
|
270
|
+
"log": "text/plain",
|
|
271
|
+
"lostxml": "application/lost+xml",
|
|
272
|
+
"lrf": "application/octet-stream",
|
|
273
|
+
"m1v": "video/mpeg",
|
|
274
|
+
"m21": "application/mp21",
|
|
275
|
+
"m2a": "audio/mpeg",
|
|
276
|
+
"m2t": "video/mp2t",
|
|
277
|
+
"m2ts": "video/mp2t",
|
|
278
|
+
"m2v": "video/mpeg",
|
|
279
|
+
"m3a": "audio/mpeg",
|
|
280
|
+
"m4a": "audio/mp4",
|
|
281
|
+
"m4p": "application/mp4",
|
|
282
|
+
"m4s": "video/iso.segment",
|
|
283
|
+
"ma": "application/mathematica",
|
|
284
|
+
"mads": "application/mads+xml",
|
|
285
|
+
"maei": "application/mmt-aei+xml",
|
|
286
|
+
"man": "text/troff",
|
|
287
|
+
"manifest": "text/cache-manifest",
|
|
288
|
+
"map": "application/json",
|
|
289
|
+
"mar": "application/octet-stream",
|
|
290
|
+
"markdown": "text/markdown",
|
|
291
|
+
"mathml": "application/mathml+xml",
|
|
292
|
+
"mb": "application/mathematica",
|
|
293
|
+
"mbox": "application/mbox",
|
|
294
|
+
"md": "text/markdown",
|
|
295
|
+
"mdx": "text/mdx",
|
|
296
|
+
"me": "text/troff",
|
|
297
|
+
"mesh": "model/mesh",
|
|
298
|
+
"meta4": "application/metalink4+xml",
|
|
299
|
+
"metalink": "application/metalink+xml",
|
|
300
|
+
"mets": "application/mets+xml",
|
|
301
|
+
"mft": "application/rpki-manifest",
|
|
302
|
+
"mid": "audio/midi",
|
|
303
|
+
"midi": "audio/midi",
|
|
304
|
+
"mime": "message/rfc822",
|
|
305
|
+
"mj2": "video/mj2",
|
|
306
|
+
"mjp2": "video/mj2",
|
|
307
|
+
"mjs": "text/javascript",
|
|
308
|
+
"mml": "text/mathml",
|
|
309
|
+
"mods": "application/mods+xml",
|
|
310
|
+
"mov": "video/quicktime",
|
|
311
|
+
"mp2": "audio/mpeg",
|
|
312
|
+
"mp21": "application/mp21",
|
|
313
|
+
"mp2a": "audio/mpeg",
|
|
314
|
+
"mp3": "audio/mpeg",
|
|
315
|
+
"mp4": "video/mp4",
|
|
316
|
+
"mp4a": "audio/mp4",
|
|
317
|
+
"mp4s": "application/mp4",
|
|
318
|
+
"mp4v": "video/mp4",
|
|
319
|
+
"mpd": "application/dash+xml",
|
|
320
|
+
"mpe": "video/mpeg",
|
|
321
|
+
"mpeg": "video/mpeg",
|
|
322
|
+
"mpf": "application/media-policy-dataset+xml",
|
|
323
|
+
"mpg": "video/mpeg",
|
|
324
|
+
"mpg4": "video/mp4",
|
|
325
|
+
"mpga": "audio/mpeg",
|
|
326
|
+
"mpp": "application/dash-patch+xml",
|
|
327
|
+
"mrc": "application/marc",
|
|
328
|
+
"mrcx": "application/marcxml+xml",
|
|
329
|
+
"ms": "text/troff",
|
|
330
|
+
"mscml": "application/mediaservercontrol+xml",
|
|
331
|
+
"msh": "model/mesh",
|
|
332
|
+
"msi": "application/octet-stream",
|
|
333
|
+
"msix": "application/msix",
|
|
334
|
+
"msixbundle": "application/msixbundle",
|
|
335
|
+
"msm": "application/octet-stream",
|
|
336
|
+
"msp": "application/octet-stream",
|
|
337
|
+
"mtl": "model/mtl",
|
|
338
|
+
"mts": "video/mp2t",
|
|
339
|
+
"musd": "application/mmt-usd+xml",
|
|
340
|
+
"mxf": "application/mxf",
|
|
341
|
+
"mxmf": "audio/mobile-xmf",
|
|
342
|
+
"mxml": "application/xv+xml",
|
|
343
|
+
"n3": "text/n3",
|
|
344
|
+
"nb": "application/mathematica",
|
|
345
|
+
"nq": "application/n-quads",
|
|
346
|
+
"nt": "application/n-triples",
|
|
347
|
+
"obj": "model/obj",
|
|
348
|
+
"oda": "application/oda",
|
|
349
|
+
"oga": "audio/ogg",
|
|
350
|
+
"ogg": "audio/ogg",
|
|
351
|
+
"ogv": "video/ogg",
|
|
352
|
+
"ogx": "application/ogg",
|
|
353
|
+
"omdoc": "application/omdoc+xml",
|
|
354
|
+
"onepkg": "application/onenote",
|
|
355
|
+
"onetmp": "application/onenote",
|
|
356
|
+
"onetoc": "application/onenote",
|
|
357
|
+
"onetoc2": "application/onenote",
|
|
358
|
+
"opf": "application/oebps-package+xml",
|
|
359
|
+
"opus": "audio/ogg",
|
|
360
|
+
"otf": "font/otf",
|
|
361
|
+
"owl": "application/rdf+xml",
|
|
362
|
+
"oxps": "application/oxps",
|
|
363
|
+
"p10": "application/pkcs10",
|
|
364
|
+
"p7c": "application/pkcs7-mime",
|
|
365
|
+
"p7m": "application/pkcs7-mime",
|
|
366
|
+
"p7s": "application/pkcs7-signature",
|
|
367
|
+
"p8": "application/pkcs8",
|
|
368
|
+
"pdf": "application/pdf",
|
|
369
|
+
"pfr": "application/font-tdpfr",
|
|
370
|
+
"pgp": "application/pgp-encrypted",
|
|
371
|
+
"pkg": "application/octet-stream",
|
|
372
|
+
"pki": "application/pkixcmp",
|
|
373
|
+
"pkipath": "application/pkix-pkipath",
|
|
374
|
+
"pls": "application/pls+xml",
|
|
375
|
+
"png": "image/png",
|
|
376
|
+
"prc": "model/prc",
|
|
377
|
+
"prf": "application/pics-rules",
|
|
378
|
+
"provx": "application/provenance+xml",
|
|
379
|
+
"ps": "application/postscript",
|
|
380
|
+
"pskcxml": "application/pskc+xml",
|
|
381
|
+
"pti": "image/prs.pti",
|
|
382
|
+
"qt": "video/quicktime",
|
|
383
|
+
"raml": "application/raml+yaml",
|
|
384
|
+
"rapd": "application/route-apd+xml",
|
|
385
|
+
"rdf": "application/rdf+xml",
|
|
386
|
+
"relo": "application/p2p-overlay+xml",
|
|
387
|
+
"rif": "application/reginfo+xml",
|
|
388
|
+
"rl": "application/resource-lists+xml",
|
|
389
|
+
"rld": "application/resource-lists-diff+xml",
|
|
390
|
+
"rmi": "audio/midi",
|
|
391
|
+
"rnc": "application/relax-ng-compact-syntax",
|
|
392
|
+
"rng": "application/xml",
|
|
393
|
+
"roa": "application/rpki-roa",
|
|
394
|
+
"roff": "text/troff",
|
|
395
|
+
"rq": "application/sparql-query",
|
|
396
|
+
"rs": "application/rls-services+xml",
|
|
397
|
+
"rsat": "application/atsc-rsat+xml",
|
|
398
|
+
"rsd": "application/rsd+xml",
|
|
399
|
+
"rsheet": "application/urc-ressheet+xml",
|
|
400
|
+
"rss": "application/rss+xml",
|
|
401
|
+
"rtf": "text/rtf",
|
|
402
|
+
"rtx": "text/richtext",
|
|
403
|
+
"rusd": "application/route-usd+xml",
|
|
404
|
+
"s3m": "audio/s3m",
|
|
405
|
+
"sbml": "application/sbml+xml",
|
|
406
|
+
"scq": "application/scvp-cv-request",
|
|
407
|
+
"scs": "application/scvp-cv-response",
|
|
408
|
+
"sdp": "application/sdp",
|
|
409
|
+
"senmlx": "application/senml+xml",
|
|
410
|
+
"sensmlx": "application/sensml+xml",
|
|
411
|
+
"ser": "application/java-serialized-object",
|
|
412
|
+
"setpay": "application/set-payment-initiation",
|
|
413
|
+
"setreg": "application/set-registration-initiation",
|
|
414
|
+
"sgi": "image/sgi",
|
|
415
|
+
"sgm": "text/sgml",
|
|
416
|
+
"sgml": "text/sgml",
|
|
417
|
+
"shex": "text/shex",
|
|
418
|
+
"shf": "application/shf+xml",
|
|
419
|
+
"shtml": "text/html",
|
|
420
|
+
"sieve": "application/sieve",
|
|
421
|
+
"sig": "application/pgp-signature",
|
|
422
|
+
"sil": "audio/silk",
|
|
423
|
+
"silo": "model/mesh",
|
|
424
|
+
"siv": "application/sieve",
|
|
425
|
+
"slim": "text/slim",
|
|
426
|
+
"slm": "text/slim",
|
|
427
|
+
"sls": "application/route-s-tsid+xml",
|
|
428
|
+
"smi": "application/smil+xml",
|
|
429
|
+
"smil": "application/smil+xml",
|
|
430
|
+
"snd": "audio/basic",
|
|
431
|
+
"so": "application/octet-stream",
|
|
432
|
+
"spdx": "text/spdx",
|
|
433
|
+
"spp": "application/scvp-vp-response",
|
|
434
|
+
"spq": "application/scvp-vp-request",
|
|
435
|
+
"spx": "audio/ogg",
|
|
436
|
+
"sql": "application/sql",
|
|
437
|
+
"sru": "application/sru+xml",
|
|
438
|
+
"srx": "application/sparql-results+xml",
|
|
439
|
+
"ssdl": "application/ssdl+xml",
|
|
440
|
+
"ssml": "application/ssml+xml",
|
|
441
|
+
"stk": "application/hyperstudio",
|
|
442
|
+
"stl": "model/stl",
|
|
443
|
+
"stpx": "model/step+xml",
|
|
444
|
+
"stpxz": "model/step-xml+zip",
|
|
445
|
+
"stpz": "model/step+zip",
|
|
446
|
+
"styl": "text/stylus",
|
|
447
|
+
"stylus": "text/stylus",
|
|
448
|
+
"svg": "image/svg+xml",
|
|
449
|
+
"svgz": "image/svg+xml",
|
|
450
|
+
"swidtag": "application/swid+xml",
|
|
451
|
+
"t": "text/troff",
|
|
452
|
+
"t38": "image/t38",
|
|
453
|
+
"td": "application/urc-targetdesc+xml",
|
|
454
|
+
"tei": "application/tei+xml",
|
|
455
|
+
"teicorpus": "application/tei+xml",
|
|
456
|
+
"text": "text/plain",
|
|
457
|
+
"tfi": "application/thraud+xml",
|
|
458
|
+
"tfx": "image/tiff-fx",
|
|
459
|
+
"tif": "image/tiff",
|
|
460
|
+
"tiff": "image/tiff",
|
|
461
|
+
"toml": "application/toml",
|
|
462
|
+
"tr": "text/troff",
|
|
463
|
+
"trig": "application/trig",
|
|
464
|
+
"ts": "video/mp2t",
|
|
465
|
+
"tsd": "application/timestamped-data",
|
|
466
|
+
"tsv": "text/tab-separated-values",
|
|
467
|
+
"ttc": "font/collection",
|
|
468
|
+
"ttf": "font/ttf",
|
|
469
|
+
"ttl": "text/turtle",
|
|
470
|
+
"ttml": "application/ttml+xml",
|
|
471
|
+
"txt": "text/plain",
|
|
472
|
+
"u3d": "model/u3d",
|
|
473
|
+
"u8dsn": "message/global-delivery-status",
|
|
474
|
+
"u8hdr": "message/global-headers",
|
|
475
|
+
"u8mdn": "message/global-disposition-notification",
|
|
476
|
+
"u8msg": "message/global",
|
|
477
|
+
"ubj": "application/ubjson",
|
|
478
|
+
"uri": "text/uri-list",
|
|
479
|
+
"uris": "text/uri-list",
|
|
480
|
+
"urls": "text/uri-list",
|
|
481
|
+
"vcard": "text/vcard",
|
|
482
|
+
"vrml": "model/vrml",
|
|
483
|
+
"vtt": "text/vtt",
|
|
484
|
+
"vxml": "application/voicexml+xml",
|
|
485
|
+
"war": "application/java-archive",
|
|
486
|
+
"wasm": "application/wasm",
|
|
487
|
+
"wav": "audio/wav",
|
|
488
|
+
"weba": "audio/webm",
|
|
489
|
+
"webm": "video/webm",
|
|
490
|
+
"webmanifest": "application/manifest+json",
|
|
491
|
+
"webp": "image/webp",
|
|
492
|
+
"wgsl": "text/wgsl",
|
|
493
|
+
"wgt": "application/widget",
|
|
494
|
+
"wif": "application/watcherinfo+xml",
|
|
495
|
+
"wmf": "image/wmf",
|
|
496
|
+
"woff": "font/woff",
|
|
497
|
+
"woff2": "font/woff2",
|
|
498
|
+
"wrl": "model/vrml",
|
|
499
|
+
"wsdl": "application/wsdl+xml",
|
|
500
|
+
"wspolicy": "application/wspolicy+xml",
|
|
501
|
+
"x3d": "model/x3d+xml",
|
|
502
|
+
"x3db": "model/x3d+fastinfoset",
|
|
503
|
+
"x3dbz": "model/x3d+binary",
|
|
504
|
+
"x3dv": "model/x3d-vrml",
|
|
505
|
+
"x3dvz": "model/x3d+vrml",
|
|
506
|
+
"x3dz": "model/x3d+xml",
|
|
507
|
+
"xaml": "application/xaml+xml",
|
|
508
|
+
"xav": "application/xcap-att+xml",
|
|
509
|
+
"xca": "application/xcap-caps+xml",
|
|
510
|
+
"xcs": "application/calendar+xml",
|
|
511
|
+
"xdf": "application/xcap-diff+xml",
|
|
512
|
+
"xdssc": "application/dssc+xml",
|
|
513
|
+
"xel": "application/xcap-el+xml",
|
|
514
|
+
"xenc": "application/xenc+xml",
|
|
515
|
+
"xer": "application/patch-ops-error+xml",
|
|
516
|
+
"xfdf": "application/xfdf",
|
|
517
|
+
"xht": "application/xhtml+xml",
|
|
518
|
+
"xhtml": "application/xhtml+xml",
|
|
519
|
+
"xhvml": "application/xv+xml",
|
|
520
|
+
"xlf": "application/xliff+xml",
|
|
521
|
+
"xm": "audio/xm",
|
|
522
|
+
"xml": "text/xml",
|
|
523
|
+
"xns": "application/xcap-ns+xml",
|
|
524
|
+
"xop": "application/xop+xml",
|
|
525
|
+
"xpl": "application/xproc+xml",
|
|
526
|
+
"xsd": "application/xml",
|
|
527
|
+
"xsf": "application/prs.xsf+xml",
|
|
528
|
+
"xsl": "application/xml",
|
|
529
|
+
"xslt": "application/xml",
|
|
530
|
+
"xspf": "application/xspf+xml",
|
|
531
|
+
"xvm": "application/xv+xml",
|
|
532
|
+
"xvml": "application/xv+xml",
|
|
533
|
+
"yaml": "text/yaml",
|
|
534
|
+
"yang": "application/yang",
|
|
535
|
+
"yin": "application/yin+xml",
|
|
536
|
+
"yml": "text/yaml",
|
|
537
|
+
"zip": "application/zip"
|
|
511
538
|
};
|
|
512
|
-
|
|
513
539
|
function lookup(extn) {
|
|
514
|
-
let tmp = (
|
|
515
|
-
let idx = tmp.lastIndexOf(
|
|
540
|
+
let tmp = ("" + extn).trim().toLowerCase();
|
|
541
|
+
let idx = tmp.lastIndexOf(".");
|
|
516
542
|
return mimes[!~idx ? tmp : tmp.substring(++idx)];
|
|
517
543
|
}
|
|
518
544
|
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region node_modules/.pnpm/sirv@2.0.4/node_modules/sirv/build.mjs
|
|
519
547
|
const noop = () => {};
|
|
520
|
-
|
|
521
548
|
function isMatch(uri, arr) {
|
|
522
|
-
for (let i=0; i < arr.length; i++)
|
|
523
|
-
if (arr[i].test(uri)) return true;
|
|
524
|
-
}
|
|
549
|
+
for (let i = 0; i < arr.length; i++) if (arr[i].test(uri)) return true;
|
|
525
550
|
}
|
|
526
|
-
|
|
527
551
|
function toAssume(uri, extns) {
|
|
528
|
-
let i=0, x, len=uri.length - 1;
|
|
529
|
-
if (uri.charCodeAt(len) === 47)
|
|
530
|
-
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
let arr=[], tmp=`${uri}/index`;
|
|
552
|
+
let i = 0, x, len = uri.length - 1;
|
|
553
|
+
if (uri.charCodeAt(len) === 47) uri = uri.substring(0, len);
|
|
554
|
+
let arr = [], tmp = `${uri}/index`;
|
|
534
555
|
for (; i < extns.length; i++) {
|
|
535
|
-
x = extns[i] ? `.${extns[i]}` :
|
|
556
|
+
x = extns[i] ? `.${extns[i]}` : "";
|
|
536
557
|
if (uri) arr.push(uri + x);
|
|
537
558
|
arr.push(tmp + x);
|
|
538
559
|
}
|
|
539
|
-
|
|
540
560
|
return arr;
|
|
541
561
|
}
|
|
542
|
-
|
|
543
562
|
function viaCache(cache, uri, extns) {
|
|
544
|
-
let i=0, data, arr=toAssume(uri, extns);
|
|
545
|
-
for (; i < arr.length; i++)
|
|
546
|
-
if (data = cache[arr[i]]) return data;
|
|
547
|
-
}
|
|
563
|
+
let i = 0, data, arr = toAssume(uri, extns);
|
|
564
|
+
for (; i < arr.length; i++) if (data = cache[arr[i]]) return data;
|
|
548
565
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
let i=0, arr=toAssume(uri, extns);
|
|
566
|
+
function viaLocal(dir$1, isEtag, uri, extns) {
|
|
567
|
+
let i = 0, arr = toAssume(uri, extns);
|
|
552
568
|
let abs, stats, name, headers;
|
|
553
569
|
for (; i < arr.length; i++) {
|
|
554
|
-
abs = normalize(
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (abs.startsWith(dir) && fs.existsSync(abs)) {
|
|
559
|
-
stats = fs.statSync(abs);
|
|
570
|
+
abs = normalize(join(dir$1, name = arr[i]));
|
|
571
|
+
if (abs.startsWith(dir$1) && fs$1.existsSync(abs)) {
|
|
572
|
+
stats = fs$1.statSync(abs);
|
|
560
573
|
if (stats.isDirectory()) continue;
|
|
561
574
|
headers = toHeaders(name, stats, isEtag);
|
|
562
|
-
headers[
|
|
563
|
-
return {
|
|
575
|
+
headers["Cache-Control"] = isEtag ? "no-cache" : "no-store";
|
|
576
|
+
return {
|
|
577
|
+
abs,
|
|
578
|
+
stats,
|
|
579
|
+
headers
|
|
580
|
+
};
|
|
564
581
|
}
|
|
565
582
|
}
|
|
566
583
|
}
|
|
567
|
-
|
|
568
584
|
function is404(req, res) {
|
|
569
|
-
return
|
|
585
|
+
return res.statusCode = 404, res.end();
|
|
570
586
|
}
|
|
571
|
-
|
|
572
587
|
function send(req, res, file, stats, headers) {
|
|
573
|
-
let code=200, tmp, opts={};
|
|
588
|
+
let code = 200, tmp, opts = {};
|
|
574
589
|
headers = { ...headers };
|
|
575
|
-
|
|
576
590
|
for (let key in headers) {
|
|
577
591
|
tmp = res.getHeader(key);
|
|
578
592
|
if (tmp) headers[key] = tmp;
|
|
579
593
|
}
|
|
580
|
-
|
|
581
|
-
if (tmp = res.getHeader('content-type')) {
|
|
582
|
-
headers['Content-Type'] = tmp;
|
|
583
|
-
}
|
|
584
|
-
|
|
594
|
+
if (tmp = res.getHeader("content-type")) headers["Content-Type"] = tmp;
|
|
585
595
|
if (req.headers.range) {
|
|
586
596
|
code = 206;
|
|
587
|
-
let [x, y] = req.headers.range.replace(
|
|
597
|
+
let [x, y] = req.headers.range.replace("bytes=", "").split("-");
|
|
588
598
|
let end = opts.end = parseInt(y, 10) || stats.size - 1;
|
|
589
599
|
let start = opts.start = parseInt(x, 10) || 0;
|
|
590
|
-
|
|
591
|
-
if (end >= stats.size) {
|
|
592
|
-
end = stats.size - 1;
|
|
593
|
-
}
|
|
594
|
-
|
|
600
|
+
if (end >= stats.size) end = stats.size - 1;
|
|
595
601
|
if (start >= stats.size) {
|
|
596
|
-
res.setHeader(
|
|
602
|
+
res.setHeader("Content-Range", `bytes */${stats.size}`);
|
|
597
603
|
res.statusCode = 416;
|
|
598
604
|
return res.end();
|
|
599
605
|
}
|
|
600
|
-
|
|
601
|
-
headers[
|
|
602
|
-
headers[
|
|
603
|
-
headers['Accept-Ranges'] = 'bytes';
|
|
606
|
+
headers["Content-Range"] = `bytes ${start}-${end}/${stats.size}`;
|
|
607
|
+
headers["Content-Length"] = end - start + 1;
|
|
608
|
+
headers["Accept-Ranges"] = "bytes";
|
|
604
609
|
}
|
|
605
|
-
|
|
606
610
|
res.writeHead(code, headers);
|
|
607
|
-
fs.createReadStream(file, opts).pipe(res);
|
|
611
|
+
fs$1.createReadStream(file, opts).pipe(res);
|
|
608
612
|
}
|
|
609
|
-
|
|
610
613
|
const ENCODING = {
|
|
611
|
-
|
|
612
|
-
|
|
614
|
+
".br": "br",
|
|
615
|
+
".gz": "gzip"
|
|
613
616
|
};
|
|
614
|
-
|
|
615
617
|
function toHeaders(name, stats, isEtag) {
|
|
616
618
|
let enc = ENCODING[name.slice(-3)];
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
if (ctype === 'text/html') ctype += ';charset=utf-8';
|
|
620
|
-
|
|
619
|
+
let ctype = lookup(name.slice(0, enc && -3)) || "";
|
|
620
|
+
if (ctype === "text/html") ctype += ";charset=utf-8";
|
|
621
621
|
let headers = {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
622
|
+
"Content-Length": stats.size,
|
|
623
|
+
"Content-Type": ctype,
|
|
624
|
+
"Last-Modified": stats.mtime.toUTCString()
|
|
625
625
|
};
|
|
626
|
-
|
|
627
|
-
if (
|
|
628
|
-
if (isEtag) headers['ETag'] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
629
|
-
|
|
626
|
+
if (enc) headers["Content-Encoding"] = enc;
|
|
627
|
+
if (isEtag) headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
630
628
|
return headers;
|
|
631
629
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
dir = resolve(dir || '.');
|
|
635
|
-
|
|
630
|
+
function build_default(dir$1, opts = {}) {
|
|
631
|
+
dir$1 = resolve(dir$1 || ".");
|
|
636
632
|
let isNotFound = opts.onNoMatch || is404;
|
|
637
633
|
let setHeaders = opts.setHeaders || noop;
|
|
638
|
-
|
|
639
|
-
let
|
|
640
|
-
let
|
|
641
|
-
let brots = opts.brotli && extensions.map(x => `${x}.br`).concat('br');
|
|
642
|
-
|
|
634
|
+
let extensions = opts.extensions || ["html", "htm"];
|
|
635
|
+
let gzips = opts.gzip && extensions.map((x) => `${x}.gz`).concat("gz");
|
|
636
|
+
let brots = opts.brotli && extensions.map((x) => `${x}.br`).concat("br");
|
|
643
637
|
const FILES = {};
|
|
644
|
-
|
|
645
|
-
let fallback = '/';
|
|
638
|
+
let fallback = "/";
|
|
646
639
|
let isEtag = !!opts.etag;
|
|
647
640
|
let isSPA = !!opts.single;
|
|
648
|
-
if (typeof opts.single ===
|
|
649
|
-
let idx = opts.single.lastIndexOf(
|
|
641
|
+
if (typeof opts.single === "string") {
|
|
642
|
+
let idx = opts.single.lastIndexOf(".");
|
|
650
643
|
fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
|
|
651
644
|
}
|
|
652
|
-
|
|
653
645
|
let ignores = [];
|
|
654
646
|
if (opts.ignores !== false) {
|
|
655
|
-
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
|
|
647
|
+
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
|
|
656
648
|
if (opts.dotfiles) ignores.push(/\/\.\w/);
|
|
657
649
|
else ignores.push(/\/\.well-known/);
|
|
658
|
-
[].concat(opts.ignores || []).forEach(x => {
|
|
659
|
-
ignores.push(new RegExp(x,
|
|
650
|
+
[].concat(opts.ignores || []).forEach((x) => {
|
|
651
|
+
ignores.push(new RegExp(x, "i"));
|
|
660
652
|
});
|
|
661
653
|
}
|
|
662
|
-
|
|
663
654
|
let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
|
|
664
|
-
if (cc && opts.immutable) cc +=
|
|
665
|
-
else if (cc && opts.maxAge === 0) cc +=
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
let lookup = opts.dev ? viaLocal.bind(0, dir + sep, isEtag) : viaCache.bind(0, FILES);
|
|
680
|
-
|
|
681
|
-
return function (req, res, next) {
|
|
682
|
-
let extns = [''];
|
|
655
|
+
if (cc && opts.immutable) cc += ",immutable";
|
|
656
|
+
else if (cc && opts.maxAge === 0) cc += ",must-revalidate";
|
|
657
|
+
if (!opts.dev) totalist(dir$1, (name, abs, stats) => {
|
|
658
|
+
if (/\.well-known[\\+\/]/.test(name)) {} else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
|
|
659
|
+
let headers = toHeaders(name, stats, isEtag);
|
|
660
|
+
if (cc) headers["Cache-Control"] = cc;
|
|
661
|
+
FILES["/" + name.normalize().replace(/\\+/g, "/")] = {
|
|
662
|
+
abs,
|
|
663
|
+
stats,
|
|
664
|
+
headers
|
|
665
|
+
};
|
|
666
|
+
});
|
|
667
|
+
let lookup$1 = opts.dev ? viaLocal.bind(0, dir$1, isEtag) : viaCache.bind(0, FILES);
|
|
668
|
+
return function(req, res, next) {
|
|
669
|
+
let extns = [""];
|
|
683
670
|
let pathname = parse(req).pathname;
|
|
684
|
-
let val = req.headers[
|
|
685
|
-
if (gzips && val.includes(
|
|
671
|
+
let val = req.headers["accept-encoding"] || "";
|
|
672
|
+
if (gzips && val.includes("gzip")) extns.unshift(...gzips);
|
|
686
673
|
if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
|
|
687
|
-
extns.push(...extensions);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
|
|
674
|
+
extns.push(...extensions);
|
|
675
|
+
if (pathname.indexOf("%") !== -1) try {
|
|
676
|
+
pathname = decodeURI(pathname);
|
|
677
|
+
} catch (err) {}
|
|
678
|
+
let data = lookup$1(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup$1(fallback, extns);
|
|
695
679
|
if (!data) return next ? next() : isNotFound(req, res);
|
|
696
|
-
|
|
697
|
-
if (isEtag && req.headers['if-none-match'] === data.headers['ETag']) {
|
|
680
|
+
if (isEtag && req.headers["if-none-match"] === data.headers["ETag"]) {
|
|
698
681
|
res.writeHead(304);
|
|
699
682
|
return res.end();
|
|
700
683
|
}
|
|
701
|
-
|
|
702
|
-
if (gzips || brots) {
|
|
703
|
-
res.setHeader('Vary', 'Accept-Encoding');
|
|
704
|
-
}
|
|
705
|
-
|
|
684
|
+
if (gzips || brots) res.setHeader("Vary", "Accept-Encoding");
|
|
706
685
|
setHeaders(res, pathname, data.stats);
|
|
707
686
|
send(req, res, data.abs, data.stats, data.headers);
|
|
708
687
|
};
|
|
709
688
|
}
|
|
710
689
|
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
var
|
|
714
|
-
|
|
715
|
-
function requireSetCookie () {
|
|
716
|
-
if (hasRequiredSetCookie) return setCookie.exports;
|
|
717
|
-
hasRequiredSetCookie = 1;
|
|
718
|
-
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region node_modules/.pnpm/set-cookie-parser@2.7.2/node_modules/set-cookie-parser/lib/set-cookie.js
|
|
692
|
+
var require_set_cookie = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
719
693
|
var defaultParseOptions = {
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
694
|
+
decodeValues: true,
|
|
695
|
+
map: false,
|
|
696
|
+
silent: false
|
|
723
697
|
};
|
|
724
|
-
|
|
725
698
|
function isForbiddenKey(key) {
|
|
726
|
-
|
|
699
|
+
return typeof key !== "string" || key in {};
|
|
727
700
|
}
|
|
728
|
-
|
|
729
701
|
function createNullObj() {
|
|
730
|
-
|
|
702
|
+
return Object.create(null);
|
|
731
703
|
}
|
|
732
|
-
|
|
733
704
|
function isNonEmptyString(str) {
|
|
734
|
-
|
|
705
|
+
return typeof str === "string" && !!str.trim();
|
|
735
706
|
}
|
|
736
|
-
|
|
737
707
|
function parseString(setCookieValue, options) {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
var key = sides.shift().trimLeft().toLowerCase();
|
|
769
|
-
if (isForbiddenKey(key)) {
|
|
770
|
-
return;
|
|
771
|
-
}
|
|
772
|
-
var value = sides.join("=");
|
|
773
|
-
if (key === "expires") {
|
|
774
|
-
cookie.expires = new Date(value);
|
|
775
|
-
} else if (key === "max-age") {
|
|
776
|
-
var n = parseInt(value, 10);
|
|
777
|
-
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
778
|
-
} else if (key === "secure") {
|
|
779
|
-
cookie.secure = true;
|
|
780
|
-
} else if (key === "httponly") {
|
|
781
|
-
cookie.httpOnly = true;
|
|
782
|
-
} else if (key === "samesite") {
|
|
783
|
-
cookie.sameSite = value;
|
|
784
|
-
} else if (key === "partitioned") {
|
|
785
|
-
cookie.partitioned = true;
|
|
786
|
-
} else if (key) {
|
|
787
|
-
cookie[key] = value;
|
|
788
|
-
}
|
|
789
|
-
});
|
|
790
|
-
|
|
791
|
-
return cookie;
|
|
708
|
+
var parts = setCookieValue.split(";").filter(isNonEmptyString);
|
|
709
|
+
var parsed = parseNameValuePair(parts.shift());
|
|
710
|
+
var name = parsed.name;
|
|
711
|
+
var value = parsed.value;
|
|
712
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
713
|
+
if (isForbiddenKey(name)) return null;
|
|
714
|
+
try {
|
|
715
|
+
value = options.decodeValues ? decodeURIComponent(value) : value;
|
|
716
|
+
} catch (e) {
|
|
717
|
+
console.error("set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.", e);
|
|
718
|
+
}
|
|
719
|
+
var cookie = createNullObj();
|
|
720
|
+
cookie.name = name;
|
|
721
|
+
cookie.value = value;
|
|
722
|
+
parts.forEach(function(part) {
|
|
723
|
+
var sides = part.split("=");
|
|
724
|
+
var key = sides.shift().trimLeft().toLowerCase();
|
|
725
|
+
if (isForbiddenKey(key)) return;
|
|
726
|
+
var value$1 = sides.join("=");
|
|
727
|
+
if (key === "expires") cookie.expires = new Date(value$1);
|
|
728
|
+
else if (key === "max-age") {
|
|
729
|
+
var n = parseInt(value$1, 10);
|
|
730
|
+
if (!Number.isNaN(n)) cookie.maxAge = n;
|
|
731
|
+
} else if (key === "secure") cookie.secure = true;
|
|
732
|
+
else if (key === "httponly") cookie.httpOnly = true;
|
|
733
|
+
else if (key === "samesite") cookie.sameSite = value$1;
|
|
734
|
+
else if (key === "partitioned") cookie.partitioned = true;
|
|
735
|
+
else if (key) cookie[key] = value$1;
|
|
736
|
+
});
|
|
737
|
+
return cookie;
|
|
792
738
|
}
|
|
793
|
-
|
|
794
739
|
function parseNameValuePair(nameValuePairStr) {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
return { name: name, value: value };
|
|
740
|
+
var name = "";
|
|
741
|
+
var value = "";
|
|
742
|
+
var nameValueArr = nameValuePairStr.split("=");
|
|
743
|
+
if (nameValueArr.length > 1) {
|
|
744
|
+
name = nameValueArr.shift();
|
|
745
|
+
value = nameValueArr.join("=");
|
|
746
|
+
} else value = nameValuePairStr;
|
|
747
|
+
return {
|
|
748
|
+
name,
|
|
749
|
+
value
|
|
750
|
+
};
|
|
808
751
|
}
|
|
809
|
-
|
|
810
752
|
function parse(input, options) {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
Object.keys(input.headers).find(function (key) {
|
|
836
|
-
return key.toLowerCase() === "set-cookie";
|
|
837
|
-
})
|
|
838
|
-
];
|
|
839
|
-
// warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
|
|
840
|
-
if (!sch && input.headers.cookie && !options.silent) {
|
|
841
|
-
console.warn(
|
|
842
|
-
"Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
|
|
843
|
-
);
|
|
844
|
-
}
|
|
845
|
-
input = sch;
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
if (!Array.isArray(input)) {
|
|
849
|
-
input = [input];
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
if (!options.map) {
|
|
853
|
-
return input
|
|
854
|
-
.filter(isNonEmptyString)
|
|
855
|
-
.map(function (str) {
|
|
856
|
-
return parseString(str, options);
|
|
857
|
-
})
|
|
858
|
-
.filter(Boolean);
|
|
859
|
-
} else {
|
|
860
|
-
var cookies = createNullObj();
|
|
861
|
-
return input.filter(isNonEmptyString).reduce(function (cookies, str) {
|
|
862
|
-
var cookie = parseString(str, options);
|
|
863
|
-
if (cookie && !isForbiddenKey(cookie.name)) {
|
|
864
|
-
cookies[cookie.name] = cookie;
|
|
865
|
-
}
|
|
866
|
-
return cookies;
|
|
867
|
-
}, cookies);
|
|
868
|
-
}
|
|
753
|
+
options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
|
|
754
|
+
if (!input) if (!options.map) return [];
|
|
755
|
+
else return createNullObj();
|
|
756
|
+
if (input.headers) if (typeof input.headers.getSetCookie === "function") input = input.headers.getSetCookie();
|
|
757
|
+
else if (input.headers["set-cookie"]) input = input.headers["set-cookie"];
|
|
758
|
+
else {
|
|
759
|
+
var sch = input.headers[Object.keys(input.headers).find(function(key) {
|
|
760
|
+
return key.toLowerCase() === "set-cookie";
|
|
761
|
+
})];
|
|
762
|
+
if (!sch && input.headers.cookie && !options.silent) console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning.");
|
|
763
|
+
input = sch;
|
|
764
|
+
}
|
|
765
|
+
if (!Array.isArray(input)) input = [input];
|
|
766
|
+
if (!options.map) return input.filter(isNonEmptyString).map(function(str) {
|
|
767
|
+
return parseString(str, options);
|
|
768
|
+
}).filter(Boolean);
|
|
769
|
+
else {
|
|
770
|
+
var cookies = createNullObj();
|
|
771
|
+
return input.filter(isNonEmptyString).reduce(function(cookies$1, str) {
|
|
772
|
+
var cookie = parseString(str, options);
|
|
773
|
+
if (cookie && !isForbiddenKey(cookie.name)) cookies$1[cookie.name] = cookie;
|
|
774
|
+
return cookies$1;
|
|
775
|
+
}, cookies);
|
|
776
|
+
}
|
|
869
777
|
}
|
|
870
|
-
|
|
871
|
-
/*
|
|
872
|
-
Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
|
|
873
|
-
that are within a single set-cookie field-value, such as in the Expires portion.
|
|
874
|
-
|
|
875
|
-
This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
|
|
876
|
-
Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
|
|
877
|
-
React Native's fetch does this for *every* header, including set-cookie.
|
|
878
|
-
|
|
879
|
-
Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
|
|
880
|
-
Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
|
|
881
|
-
*/
|
|
882
778
|
function splitCookiesString(cookiesString) {
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
skipWhitespace();
|
|
923
|
-
nextStart = pos;
|
|
924
|
-
|
|
925
|
-
while (pos < cookiesString.length && notSpecialChar()) {
|
|
926
|
-
pos += 1;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
// currently special character
|
|
930
|
-
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
931
|
-
// we found cookies separator
|
|
932
|
-
cookiesSeparatorFound = true;
|
|
933
|
-
// pos is inside the next cookie, so back up and return it.
|
|
934
|
-
pos = nextStart;
|
|
935
|
-
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
936
|
-
start = pos;
|
|
937
|
-
} else {
|
|
938
|
-
// in param ',' or param separator ';',
|
|
939
|
-
// we continue from that comma
|
|
940
|
-
pos = lastComma + 1;
|
|
941
|
-
}
|
|
942
|
-
} else {
|
|
943
|
-
pos += 1;
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
948
|
-
cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
return cookiesStrings;
|
|
779
|
+
if (Array.isArray(cookiesString)) return cookiesString;
|
|
780
|
+
if (typeof cookiesString !== "string") return [];
|
|
781
|
+
var cookiesStrings = [];
|
|
782
|
+
var pos = 0;
|
|
783
|
+
var start;
|
|
784
|
+
var ch;
|
|
785
|
+
var lastComma;
|
|
786
|
+
var nextStart;
|
|
787
|
+
var cookiesSeparatorFound;
|
|
788
|
+
function skipWhitespace() {
|
|
789
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) pos += 1;
|
|
790
|
+
return pos < cookiesString.length;
|
|
791
|
+
}
|
|
792
|
+
function notSpecialChar() {
|
|
793
|
+
ch = cookiesString.charAt(pos);
|
|
794
|
+
return ch !== "=" && ch !== ";" && ch !== ",";
|
|
795
|
+
}
|
|
796
|
+
while (pos < cookiesString.length) {
|
|
797
|
+
start = pos;
|
|
798
|
+
cookiesSeparatorFound = false;
|
|
799
|
+
while (skipWhitespace()) {
|
|
800
|
+
ch = cookiesString.charAt(pos);
|
|
801
|
+
if (ch === ",") {
|
|
802
|
+
lastComma = pos;
|
|
803
|
+
pos += 1;
|
|
804
|
+
skipWhitespace();
|
|
805
|
+
nextStart = pos;
|
|
806
|
+
while (pos < cookiesString.length && notSpecialChar()) pos += 1;
|
|
807
|
+
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
808
|
+
cookiesSeparatorFound = true;
|
|
809
|
+
pos = nextStart;
|
|
810
|
+
cookiesStrings.push(cookiesString.substring(start, lastComma));
|
|
811
|
+
start = pos;
|
|
812
|
+
} else pos = lastComma + 1;
|
|
813
|
+
} else pos += 1;
|
|
814
|
+
}
|
|
815
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
|
|
816
|
+
}
|
|
817
|
+
return cookiesStrings;
|
|
953
818
|
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
var
|
|
963
|
-
|
|
964
|
-
/** @import { StandardSchemaV1 } from '@standard-schema/spec' */
|
|
965
|
-
|
|
966
|
-
|
|
819
|
+
module.exports = parse;
|
|
820
|
+
module.exports.parse = parse;
|
|
821
|
+
module.exports.parseString = parseString;
|
|
822
|
+
module.exports.splitCookiesString = splitCookiesString;
|
|
823
|
+
}));
|
|
824
|
+
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region node_modules/.pnpm/@sveltejs+kit@2.49.4_@opentelemetry+api@1.7.0_@sveltejs+vite-plugin-svelte@3.1.2_svelte_c9e193a2a3d1b6c3ce1a7d87af2ed627/node_modules/@sveltejs/kit/src/exports/internal/index.js
|
|
827
|
+
var import_set_cookie = /* @__PURE__ */ __toESM(require_set_cookie(), 1);
|
|
967
828
|
/**
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
829
|
+
* An error that was thrown from within the SvelteKit runtime that is not fatal and doesn't result in a 500, such as a 404.
|
|
830
|
+
* `SvelteKitError` goes through `handleError`.
|
|
831
|
+
* @extends Error
|
|
832
|
+
*/
|
|
833
|
+
var SvelteKitError = class extends Error {
|
|
973
834
|
/**
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
835
|
+
* @param {number} status
|
|
836
|
+
* @param {string} text
|
|
837
|
+
* @param {string} message
|
|
838
|
+
*/
|
|
978
839
|
constructor(status, text, message) {
|
|
979
840
|
super(message);
|
|
980
841
|
this.status = status;
|
|
981
842
|
this.text = text;
|
|
982
843
|
}
|
|
983
|
-
}
|
|
844
|
+
};
|
|
984
845
|
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region node_modules/.pnpm/@sveltejs+kit@2.49.4_@opentelemetry+api@1.7.0_@sveltejs+vite-plugin-svelte@3.1.2_svelte_c9e193a2a3d1b6c3ce1a7d87af2ed627/node_modules/@sveltejs/kit/src/exports/node/index.js
|
|
985
848
|
/**
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
function get_raw_body(req, body_size_limit) {
|
|
849
|
+
* @param {import('http').IncomingMessage} req
|
|
850
|
+
* @param {number} [body_size_limit]
|
|
851
|
+
*/
|
|
852
|
+
function get_raw_body(req, body_size_limit$1) {
|
|
990
853
|
const h = req.headers;
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
const content_length = Number(h['content-length']);
|
|
997
|
-
|
|
998
|
-
// check if no request body
|
|
999
|
-
if (
|
|
1000
|
-
(req.httpVersionMajor === 1 && isNaN(content_length) && h['transfer-encoding'] == null) ||
|
|
1001
|
-
content_length === 0
|
|
1002
|
-
) {
|
|
1003
|
-
return null;
|
|
1004
|
-
}
|
|
1005
|
-
|
|
854
|
+
if (!h["content-type"]) return null;
|
|
855
|
+
const content_length = Number(h["content-length"]);
|
|
856
|
+
if (req.httpVersionMajor === 1 && isNaN(content_length) && h["transfer-encoding"] == null || content_length === 0) return null;
|
|
1006
857
|
if (req.destroyed) {
|
|
1007
858
|
const readable = new ReadableStream();
|
|
1008
|
-
|
|
859
|
+
readable.cancel();
|
|
1009
860
|
return readable;
|
|
1010
861
|
}
|
|
1011
|
-
|
|
1012
862
|
let size = 0;
|
|
1013
863
|
let cancelled = false;
|
|
1014
|
-
|
|
1015
864
|
return new ReadableStream({
|
|
1016
865
|
start(controller) {
|
|
1017
|
-
if (body_size_limit !==
|
|
1018
|
-
let message = `Content-length of ${content_length} exceeds limit of ${body_size_limit} bytes.`;
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
// https://github.com/sveltejs/kit/pull/11589
|
|
1022
|
-
// TODO this exists to aid migration — remove in a future version
|
|
1023
|
-
message += ' To disable body size limits, specify Infinity rather than 0.';
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
const error = new SvelteKitError(413, 'Payload Too Large', message);
|
|
1027
|
-
|
|
866
|
+
if (body_size_limit$1 !== void 0 && content_length > body_size_limit$1) {
|
|
867
|
+
let message = `Content-length of ${content_length} exceeds limit of ${body_size_limit$1} bytes.`;
|
|
868
|
+
if (body_size_limit$1 === 0) message += " To disable body size limits, specify Infinity rather than 0.";
|
|
869
|
+
const error = new SvelteKitError(413, "Payload Too Large", message);
|
|
1028
870
|
controller.error(error);
|
|
1029
871
|
return;
|
|
1030
872
|
}
|
|
1031
|
-
|
|
1032
|
-
req.on('error', (error) => {
|
|
873
|
+
req.on("error", (error) => {
|
|
1033
874
|
cancelled = true;
|
|
1034
875
|
controller.error(error);
|
|
1035
876
|
});
|
|
1036
|
-
|
|
1037
|
-
req.on('end', () => {
|
|
877
|
+
req.on("end", () => {
|
|
1038
878
|
if (cancelled) return;
|
|
1039
879
|
controller.close();
|
|
1040
880
|
});
|
|
1041
|
-
|
|
1042
|
-
req.on('data', (chunk) => {
|
|
881
|
+
req.on("data", (chunk) => {
|
|
1043
882
|
if (cancelled) return;
|
|
1044
|
-
|
|
1045
883
|
size += chunk.length;
|
|
1046
884
|
if (size > content_length) {
|
|
1047
885
|
cancelled = true;
|
|
1048
|
-
|
|
1049
|
-
const constraint = content_length ? 'content-length' : 'BODY_SIZE_LIMIT';
|
|
1050
|
-
const message = `request body size exceeded ${constraint} of ${content_length}`;
|
|
1051
|
-
|
|
1052
|
-
const error = new SvelteKitError(413, 'Payload Too Large', message);
|
|
886
|
+
const error = new SvelteKitError(413, "Payload Too Large", `request body size exceeded ${content_length ? "content-length" : "BODY_SIZE_LIMIT"} of ${content_length}`);
|
|
1053
887
|
controller.error(error);
|
|
1054
|
-
|
|
1055
888
|
return;
|
|
1056
889
|
}
|
|
1057
|
-
|
|
1058
890
|
controller.enqueue(chunk);
|
|
1059
|
-
|
|
1060
|
-
if (controller.desiredSize === null || controller.desiredSize <= 0) {
|
|
1061
|
-
req.pause();
|
|
1062
|
-
}
|
|
891
|
+
if (controller.desiredSize === null || controller.desiredSize <= 0) req.pause();
|
|
1063
892
|
});
|
|
1064
893
|
},
|
|
1065
|
-
|
|
1066
894
|
pull() {
|
|
1067
895
|
req.resume();
|
|
1068
896
|
},
|
|
1069
|
-
|
|
1070
897
|
cancel(reason) {
|
|
1071
898
|
cancelled = true;
|
|
1072
899
|
req.destroy(reason);
|
|
1073
900
|
}
|
|
1074
901
|
});
|
|
1075
902
|
}
|
|
1076
|
-
|
|
1077
903
|
/**
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
// TODO 3.0 make the signature synchronous?
|
|
1086
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
904
|
+
* @param {{
|
|
905
|
+
* request: import('http').IncomingMessage;
|
|
906
|
+
* base: string;
|
|
907
|
+
* bodySizeLimit?: number;
|
|
908
|
+
* }} options
|
|
909
|
+
* @returns {Promise<Request>}
|
|
910
|
+
*/
|
|
1087
911
|
async function getRequest({ request, base, bodySizeLimit }) {
|
|
1088
|
-
let headers =
|
|
912
|
+
let headers = request.headers;
|
|
1089
913
|
if (request.httpVersionMajor >= 2) {
|
|
1090
|
-
// the Request constructor rejects headers with ':' in the name
|
|
1091
914
|
headers = Object.assign({}, headers);
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
delete headers[
|
|
1097
|
-
delete headers[':method'];
|
|
1098
|
-
delete headers[':path'];
|
|
1099
|
-
delete headers[':scheme'];
|
|
915
|
+
if (headers[":authority"]) headers.host = headers[":authority"];
|
|
916
|
+
delete headers[":authority"];
|
|
917
|
+
delete headers[":method"];
|
|
918
|
+
delete headers[":path"];
|
|
919
|
+
delete headers[":scheme"];
|
|
1100
920
|
}
|
|
1101
|
-
|
|
1102
|
-
// TODO: Whenever Node >=22 is minimum supported version, we can use `request.readableAborted`
|
|
1103
|
-
// @see https://github.com/nodejs/node/blob/5cf3c3e24c7257a0c6192ed8ef71efec8ddac22b/lib/internal/streams/readable.js#L1443-L1453
|
|
1104
921
|
const controller = new AbortController();
|
|
1105
922
|
let errored = false;
|
|
1106
923
|
let end_emitted = false;
|
|
1107
|
-
request.once(
|
|
1108
|
-
request.once(
|
|
1109
|
-
request.once(
|
|
1110
|
-
if ((errored || request.destroyed) && !end_emitted)
|
|
1111
|
-
controller.abort();
|
|
1112
|
-
}
|
|
924
|
+
request.once("error", () => errored = true);
|
|
925
|
+
request.once("end", () => end_emitted = true);
|
|
926
|
+
request.once("close", () => {
|
|
927
|
+
if ((errored || request.destroyed) && !end_emitted) controller.abort();
|
|
1113
928
|
});
|
|
1114
|
-
|
|
1115
929
|
return new Request(base + request.url, {
|
|
1116
|
-
|
|
1117
|
-
duplex: 'half',
|
|
930
|
+
duplex: "half",
|
|
1118
931
|
method: request.method,
|
|
1119
932
|
headers: Object.entries(headers),
|
|
1120
933
|
signal: controller.signal,
|
|
1121
|
-
body:
|
|
1122
|
-
request.method === 'GET' || request.method === 'HEAD'
|
|
1123
|
-
? undefined
|
|
1124
|
-
: get_raw_body(request, bodySizeLimit)
|
|
934
|
+
body: request.method === "GET" || request.method === "HEAD" ? void 0 : get_raw_body(request, bodySizeLimit)
|
|
1125
935
|
});
|
|
1126
936
|
}
|
|
1127
|
-
|
|
1128
937
|
/**
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
// TODO 3.0 make the signature synchronous?
|
|
1134
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
938
|
+
* @param {import('http').ServerResponse} res
|
|
939
|
+
* @param {Response} response
|
|
940
|
+
* @returns {Promise<void>}
|
|
941
|
+
*/
|
|
1135
942
|
async function setResponse(res, response) {
|
|
1136
|
-
for (const [key, value] of response.headers) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
// This is absurd but necessary, TODO: investigate why
|
|
1143
|
-
/** @type {string}*/ (response.headers.get(key))
|
|
1144
|
-
)
|
|
1145
|
-
: value
|
|
1146
|
-
);
|
|
1147
|
-
} catch (error) {
|
|
1148
|
-
res.getHeaderNames().forEach((name) => res.removeHeader(name));
|
|
1149
|
-
res.writeHead(500).end(String(error));
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
943
|
+
for (const [key, value] of response.headers) try {
|
|
944
|
+
res.setHeader(key, key === "set-cookie" ? import_set_cookie.splitCookiesString(response.headers.get(key)) : value);
|
|
945
|
+
} catch (error) {
|
|
946
|
+
res.getHeaderNames().forEach((name) => res.removeHeader(name));
|
|
947
|
+
res.writeHead(500).end(String(error));
|
|
948
|
+
return;
|
|
1152
949
|
}
|
|
1153
|
-
|
|
1154
950
|
res.writeHead(response.status);
|
|
1155
|
-
|
|
1156
951
|
if (!response.body) {
|
|
1157
952
|
res.end();
|
|
1158
953
|
return;
|
|
1159
954
|
}
|
|
1160
|
-
|
|
1161
955
|
if (response.body.locked) {
|
|
1162
|
-
res.end(
|
|
1163
|
-
'Fatal error: Response body is locked. ' +
|
|
1164
|
-
"This can happen when the response was already read (for example through 'response.json()' or 'response.text()')."
|
|
1165
|
-
);
|
|
956
|
+
res.end("Fatal error: Response body is locked. This can happen when the response was already read (for example through 'response.json()' or 'response.text()').");
|
|
1166
957
|
return;
|
|
1167
958
|
}
|
|
1168
|
-
|
|
1169
959
|
const reader = response.body.getReader();
|
|
1170
|
-
|
|
1171
960
|
if (res.destroyed) {
|
|
1172
|
-
|
|
961
|
+
reader.cancel();
|
|
1173
962
|
return;
|
|
1174
963
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
res.off(
|
|
1178
|
-
res.off('error', cancel);
|
|
1179
|
-
|
|
1180
|
-
// If the reader has already been interrupted with an error earlier,
|
|
1181
|
-
// then it will appear here, it is useless, but it needs to be catch.
|
|
964
|
+
const cancel = (error) => {
|
|
965
|
+
res.off("close", cancel);
|
|
966
|
+
res.off("error", cancel);
|
|
1182
967
|
reader.cancel(error).catch(() => {});
|
|
1183
968
|
if (error) res.destroy(error);
|
|
1184
969
|
};
|
|
1185
|
-
|
|
1186
|
-
res.on(
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
void next();
|
|
970
|
+
res.on("close", cancel);
|
|
971
|
+
res.on("error", cancel);
|
|
972
|
+
next();
|
|
1190
973
|
async function next() {
|
|
1191
974
|
try {
|
|
1192
975
|
for (;;) {
|
|
1193
976
|
const { done, value } = await reader.read();
|
|
1194
|
-
|
|
1195
977
|
if (done) break;
|
|
1196
|
-
|
|
1197
978
|
if (!res.write(value)) {
|
|
1198
|
-
res.once(
|
|
979
|
+
res.once("drain", next);
|
|
1199
980
|
return;
|
|
1200
981
|
}
|
|
1201
982
|
}
|
|
@@ -1206,255 +987,108 @@ async function setResponse(res, response) {
|
|
|
1206
987
|
}
|
|
1207
988
|
}
|
|
1208
989
|
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
* @param {string} file
|
|
1212
|
-
* @returns {ReadableStream}
|
|
1213
|
-
* @since 2.4.0
|
|
1214
|
-
*/
|
|
1215
|
-
function createReadableStream(file) {
|
|
1216
|
-
return /** @type {ReadableStream} */ (Readable.toWeb(createReadStream(file)));
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
* Parses the given value into number of bytes.
|
|
1221
|
-
*
|
|
1222
|
-
* @param {string} value - Size in bytes. Can also be specified with a unit suffix kilobytes (K), megabytes (M), or gigabytes (G).
|
|
1223
|
-
* @returns {number}
|
|
1224
|
-
*/
|
|
1225
|
-
function parse_as_bytes(value) {
|
|
1226
|
-
const multiplier =
|
|
1227
|
-
{
|
|
1228
|
-
K: 1024,
|
|
1229
|
-
M: 1024 * 1024,
|
|
1230
|
-
G: 1024 * 1024 * 1024
|
|
1231
|
-
}[value[value.length - 1]?.toUpperCase()] ?? 1;
|
|
1232
|
-
return Number(multiplier != 1 ? value.substring(0, value.length - 1) : value) * multiplier;
|
|
1233
|
-
}
|
|
1234
|
-
|
|
1235
|
-
/* global ENV_PREFIX */
|
|
1236
|
-
/* global PRECOMPRESS */
|
|
1237
|
-
|
|
990
|
+
//#endregion
|
|
991
|
+
//#region src/handler.js
|
|
1238
992
|
const server = new Server(manifest);
|
|
1239
|
-
|
|
1240
|
-
const origin = env(
|
|
1241
|
-
const xff_depth = parseInt(env(
|
|
1242
|
-
const address_header = env(
|
|
1243
|
-
const protocol_header = env(
|
|
1244
|
-
const host_header = env(
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1247
|
-
const body_size_limit = parse_as_bytes(env('BODY_SIZE_LIMIT', '512K'));
|
|
1248
|
-
|
|
1249
|
-
if (isNaN(body_size_limit)) {
|
|
1250
|
-
throw new Error(
|
|
1251
|
-
`Invalid BODY_SIZE_LIMIT: '${env('BODY_SIZE_LIMIT')}'. Please provide a numeric value.`
|
|
1252
|
-
);
|
|
1253
|
-
}
|
|
1254
|
-
|
|
993
|
+
await server.init({ env: process.env });
|
|
994
|
+
const origin = env("ORIGIN", void 0);
|
|
995
|
+
const xff_depth = parseInt(env("XFF_DEPTH", "1"));
|
|
996
|
+
const address_header = env("ADDRESS_HEADER", "").toLowerCase();
|
|
997
|
+
const protocol_header = env("PROTOCOL_HEADER", "").toLowerCase();
|
|
998
|
+
const host_header = env("HOST_HEADER", "host").toLowerCase();
|
|
999
|
+
const body_size_limit = parseInt(env("BODY_SIZE_LIMIT", "524288"));
|
|
1255
1000
|
const dir = path.dirname(fileURLToPath(import.meta.url));
|
|
1256
|
-
|
|
1257
|
-
const asset_dir = `${dir}/client${base}`;
|
|
1258
|
-
|
|
1259
|
-
await server.init({
|
|
1260
|
-
env: /** @type {Record<string, string>} */ (process.env),
|
|
1261
|
-
read: (file) => createReadableStream(`${asset_dir}/${file}`)
|
|
1262
|
-
});
|
|
1263
|
-
|
|
1264
1001
|
/**
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
function serve(path, client = false) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (
|
|
1278
|
-
pathname.startsWith(`/${manifest.appPath}/immutable/`) &&
|
|
1279
|
-
res.statusCode === 200
|
|
1280
|
-
) {
|
|
1281
|
-
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
: undefined
|
|
1285
|
-
})
|
|
1286
|
-
: undefined;
|
|
1002
|
+
* @param {string} path
|
|
1003
|
+
* @param {boolean} client
|
|
1004
|
+
*/
|
|
1005
|
+
function serve(path$1, client = false) {
|
|
1006
|
+
return fs.existsSync(path$1) && build_default(path$1, {
|
|
1007
|
+
etag: true,
|
|
1008
|
+
gzip: true,
|
|
1009
|
+
brotli: true,
|
|
1010
|
+
setHeaders: client && ((res, pathname) => {
|
|
1011
|
+
if (pathname.startsWith(`/${manifest.appPath}/immutable/`) && res.statusCode === 200) res.setHeader("cache-control", "public,max-age=31536000,immutable");
|
|
1012
|
+
})
|
|
1013
|
+
});
|
|
1287
1014
|
}
|
|
1288
|
-
|
|
1289
|
-
// required because the static file server ignores trailing slashes
|
|
1290
1015
|
/** @returns {import('polka').Middleware} */
|
|
1291
1016
|
function serve_prerendered() {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
// remove or add trailing slash as appropriate
|
|
1308
|
-
let location = pathname.at(-1) === '/' ? pathname.slice(0, -1) : pathname + '/';
|
|
1309
|
-
if (prerendered.has(location)) {
|
|
1310
|
-
if (query) location += search;
|
|
1311
|
-
res.writeHead(308, { location }).end();
|
|
1312
|
-
} else {
|
|
1313
|
-
void next();
|
|
1314
|
-
}
|
|
1315
|
-
};
|
|
1017
|
+
const handler = serve(path.join(dir, "prerendered"));
|
|
1018
|
+
return (req, res, next) => {
|
|
1019
|
+
let { pathname, search, query } = parse(req);
|
|
1020
|
+
try {
|
|
1021
|
+
pathname = decodeURIComponent(pathname);
|
|
1022
|
+
} catch {}
|
|
1023
|
+
if (prerendered.has(pathname)) return handler(req, res, next);
|
|
1024
|
+
let location = pathname.at(-1) === "/" ? pathname.slice(0, -1) : pathname + "/";
|
|
1025
|
+
if (prerendered.has(location)) {
|
|
1026
|
+
if (query) location += search;
|
|
1027
|
+
res.writeHead(308, { location }).end();
|
|
1028
|
+
} else next();
|
|
1029
|
+
};
|
|
1316
1030
|
}
|
|
1317
|
-
|
|
1318
1031
|
/** @type {import('polka').Middleware} */
|
|
1319
1032
|
const ssr = async (req, res) => {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
if (address_header === 'x-forwarded-for') {
|
|
1351
|
-
const addresses = value.split(',');
|
|
1352
|
-
|
|
1353
|
-
if (xff_depth < 1) {
|
|
1354
|
-
throw new Error(`${ENV_PREFIX + 'XFF_DEPTH'} must be a positive integer`);
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
if (xff_depth > addresses.length) {
|
|
1358
|
-
throw new Error(
|
|
1359
|
-
`${ENV_PREFIX + 'XFF_DEPTH'} is ${xff_depth}, but only found ${addresses.length
|
|
1360
|
-
} addresses`
|
|
1361
|
-
);
|
|
1362
|
-
}
|
|
1363
|
-
return addresses[addresses.length - xff_depth].trim();
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
return value;
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
return (
|
|
1370
|
-
req.connection?.remoteAddress ||
|
|
1371
|
-
// @ts-expect-error
|
|
1372
|
-
req.connection?.socket?.remoteAddress ||
|
|
1373
|
-
req.socket?.remoteAddress ||
|
|
1374
|
-
// @ts-expect-error
|
|
1375
|
-
req.info?.remoteAddress
|
|
1376
|
-
);
|
|
1377
|
-
}
|
|
1378
|
-
})
|
|
1379
|
-
);
|
|
1033
|
+
/** @type {Request | undefined} */
|
|
1034
|
+
let request;
|
|
1035
|
+
try {
|
|
1036
|
+
request = await getRequest({
|
|
1037
|
+
base: origin || get_origin(req.headers),
|
|
1038
|
+
request: req,
|
|
1039
|
+
bodySizeLimit: body_size_limit
|
|
1040
|
+
});
|
|
1041
|
+
} catch (err) {
|
|
1042
|
+
res.statusCode = err.status || 400;
|
|
1043
|
+
res.end("Invalid request body");
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
setResponse(res, await server.respond(request, {
|
|
1047
|
+
platform: { req },
|
|
1048
|
+
getClientAddress: () => {
|
|
1049
|
+
if (address_header) {
|
|
1050
|
+
if (!(address_header in req.headers)) throw new Error(`Address header was specified with ${ENV_PREFIX + "ADDRESS_HEADER"}=${address_header} but is absent from request`);
|
|
1051
|
+
const value = req.headers[address_header] || "";
|
|
1052
|
+
if (address_header === "x-forwarded-for") {
|
|
1053
|
+
const addresses = value.split(",");
|
|
1054
|
+
if (xff_depth < 1) throw new Error(`${ENV_PREFIX + "XFF_DEPTH"} must be a positive integer`);
|
|
1055
|
+
if (xff_depth > addresses.length) throw new Error(`${ENV_PREFIX + "XFF_DEPTH"} is ${xff_depth}, but only found ${addresses.length} addresses`);
|
|
1056
|
+
return addresses[addresses.length - xff_depth].trim();
|
|
1057
|
+
}
|
|
1058
|
+
return value;
|
|
1059
|
+
}
|
|
1060
|
+
return req.connection?.remoteAddress || req.connection?.socket?.remoteAddress || req.socket?.remoteAddress || req.info?.remoteAddress;
|
|
1061
|
+
}
|
|
1062
|
+
}));
|
|
1380
1063
|
};
|
|
1381
|
-
|
|
1382
1064
|
/** @param {import('polka').Middleware[]} handlers */
|
|
1383
1065
|
function sequence(handlers) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
return handle(0);
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
|
|
1402
|
-
/**
|
|
1403
|
-
* @param {string} name
|
|
1404
|
-
* @param {string | string[] | undefined} value
|
|
1405
|
-
* @returns {string | undefined}
|
|
1406
|
-
*/
|
|
1407
|
-
function normalise_header(name, value) {
|
|
1408
|
-
if (!name) return undefined;
|
|
1409
|
-
if (Array.isArray(value)) {
|
|
1410
|
-
if (value.length === 0) return undefined;
|
|
1411
|
-
if (value.length === 1) return value[0];
|
|
1412
|
-
throw new Error(
|
|
1413
|
-
`Multiple values provided for ${name} header where only one expected: ${value}`
|
|
1414
|
-
);
|
|
1415
|
-
}
|
|
1416
|
-
return value;
|
|
1066
|
+
/** @type {import('polka').Middleware} */
|
|
1067
|
+
return (req, res, next) => {
|
|
1068
|
+
/**
|
|
1069
|
+
* @param {number} i
|
|
1070
|
+
* @returns {ReturnType<import('polka').Middleware>}
|
|
1071
|
+
*/
|
|
1072
|
+
function handle(i) {
|
|
1073
|
+
if (i < handlers.length) return handlers[i](req, res, () => handle(i + 1));
|
|
1074
|
+
else return next();
|
|
1075
|
+
}
|
|
1076
|
+
return handle(0);
|
|
1077
|
+
};
|
|
1417
1078
|
}
|
|
1418
|
-
|
|
1419
1079
|
/**
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1080
|
+
* @param {import('http').IncomingHttpHeaders} headers
|
|
1081
|
+
* @returns
|
|
1082
|
+
*/
|
|
1423
1083
|
function get_origin(headers) {
|
|
1424
|
-
|
|
1425
|
-
normalise_header(protocol_header, headers[protocol_header]) || 'https'
|
|
1426
|
-
);
|
|
1427
|
-
|
|
1428
|
-
// this helps us avoid host injections through the protocol header
|
|
1429
|
-
if (protocol.includes(':')) {
|
|
1430
|
-
throw new Error(
|
|
1431
|
-
`The ${protocol_header} header specified ${protocol} which is an invalid because it includes \`:\`. It should only contain the protocol scheme (e.g. \`https\`)`
|
|
1432
|
-
);
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
const host =
|
|
1436
|
-
normalise_header(host_header, headers[host_header]) ||
|
|
1437
|
-
normalise_header('host', headers['host']);
|
|
1438
|
-
if (!host) {
|
|
1439
|
-
const header_names = host_header ? `${host_header} or host headers` : 'host header';
|
|
1440
|
-
throw new Error(
|
|
1441
|
-
`Could not determine host. The request must have a value provided by the ${header_names}`
|
|
1442
|
-
);
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
const port = normalise_header(port_header, headers[port_header]);
|
|
1446
|
-
if (port && isNaN(+port)) {
|
|
1447
|
-
throw new Error(
|
|
1448
|
-
`The ${port_header} header specified ${port} which is an invalid port because it is not a number. The value should only contain the port number (e.g. 443)`
|
|
1449
|
-
);
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
return port ? `${protocol}://${host}:${port}` : `${protocol}://${host}`;
|
|
1084
|
+
return `${protocol_header && headers[protocol_header] || "https"}://${headers[host_header]}`;
|
|
1453
1085
|
}
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1086
|
+
const handler = sequence([
|
|
1087
|
+
serve(path.join(dir, "client"), true),
|
|
1088
|
+
serve(path.join(dir, "static")),
|
|
1089
|
+
serve_prerendered(),
|
|
1090
|
+
ssr
|
|
1091
|
+
].filter(Boolean));
|
|
1092
|
+
|
|
1093
|
+
//#endregion
|
|
1094
|
+
export { handler };
|