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