@hot-updater/console 0.12.5 → 0.12.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/dist/index.cjs CHANGED
@@ -2,14 +2,841 @@
2
2
  const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
3
  return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
4
  }();
5
- var __webpack_require__ = {};
6
- (()=>{
7
- __webpack_require__.n = function(module) {
8
- var getter = module && module.__esModule ? function() {
9
- return module['default'];
10
- } : function() {
11
- return module;
5
+ var __webpack_modules__ = {
6
+ "../../node_modules/.pnpm/@hono+typia-validator@0.1.0_hono@4.6.3_typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3_/node_modules/@hono/typia-validator/dist/cjs/index.js": function(__unused_webpack_module, exports1, __webpack_require__) {
7
+ exports1.typiaValidator = void 0;
8
+ const validator_1 = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/index.js");
9
+ const typiaValidator = (target, validate, hook)=>(0, validator_1.validator)(target, async (value, c)=>{
10
+ const result = validate(value);
11
+ if (hook) {
12
+ const hookResult = await hook({
13
+ ...result,
14
+ data: value
15
+ }, c);
16
+ if (hookResult) {
17
+ if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
18
+ if ('response' in hookResult) return hookResult.response;
19
+ }
20
+ }
21
+ if (!result.success) return c.json({
22
+ success: false,
23
+ error: result.errors
24
+ }, 400);
25
+ return result.data;
26
+ });
27
+ exports1.typiaValidator = typiaValidator;
28
+ },
29
+ "../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3/node_modules/typia/lib/internal/_validateReport.js": function(__unused_webpack_module, exports1) {
30
+ exports1._validateReport = void 0;
31
+ const _validateReport = (array)=>{
32
+ const reportable = (path)=>{
33
+ if (0 === array.length) return true;
34
+ const last = array[array.length - 1].path;
35
+ return path.length > last.length || last.substring(0, path.length) !== path;
36
+ };
37
+ return (exceptable, error)=>{
38
+ if (exceptable && reportable(error.path)) array.push(error);
39
+ return false;
40
+ };
41
+ };
42
+ exports1._validateReport = _validateReport;
43
+ },
44
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/helper/cookie/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
45
+ var __defProp = Object.defineProperty;
46
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
47
+ var __getOwnPropNames = Object.getOwnPropertyNames;
48
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
49
+ var __export = (target, all)=>{
50
+ for(var name in all)__defProp(target, name, {
51
+ get: all[name],
52
+ enumerable: true
53
+ });
54
+ };
55
+ var __copyProps = (to, from, except, desc)=>{
56
+ if (from && "object" == typeof from || "function" == typeof from) {
57
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
58
+ get: ()=>from[key],
59
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
60
+ });
61
+ }
62
+ return to;
63
+ };
64
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
65
+ value: true
66
+ }), mod);
67
+ var cookie_exports = {};
68
+ __export(cookie_exports, {
69
+ deleteCookie: ()=>deleteCookie,
70
+ getCookie: ()=>getCookie,
71
+ getSignedCookie: ()=>getSignedCookie,
72
+ setCookie: ()=>setCookie,
73
+ setSignedCookie: ()=>setSignedCookie
74
+ });
75
+ module.exports = __toCommonJS(cookie_exports);
76
+ var import_cookie = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/cookie.js");
77
+ const getCookie = (c, key, prefix)=>{
78
+ const cookie = c.req.raw.headers.get("Cookie");
79
+ if ("string" == typeof key) {
80
+ if (!cookie) return;
81
+ let finalKey = key;
82
+ if ("secure" === prefix) finalKey = "__Secure-" + key;
83
+ else if ("host" === prefix) finalKey = "__Host-" + key;
84
+ const obj2 = (0, import_cookie.parse)(cookie, finalKey);
85
+ return obj2[finalKey];
86
+ }
87
+ if (!cookie) return {};
88
+ const obj = (0, import_cookie.parse)(cookie);
89
+ return obj;
90
+ };
91
+ const getSignedCookie = async (c, secret, key, prefix)=>{
92
+ const cookie = c.req.raw.headers.get("Cookie");
93
+ if ("string" == typeof key) {
94
+ if (!cookie) return;
95
+ let finalKey = key;
96
+ if ("secure" === prefix) finalKey = "__Secure-" + key;
97
+ else if ("host" === prefix) finalKey = "__Host-" + key;
98
+ const obj2 = await (0, import_cookie.parseSigned)(cookie, secret, finalKey);
99
+ return obj2[finalKey];
100
+ }
101
+ if (!cookie) return {};
102
+ const obj = await (0, import_cookie.parseSigned)(cookie, secret);
103
+ return obj;
104
+ };
105
+ const setCookie = (c, name, value, opt)=>{
106
+ let cookie;
107
+ cookie = opt?.prefix === "secure" ? (0, import_cookie.serialize)("__Secure-" + name, value, {
108
+ path: "/",
109
+ ...opt,
110
+ secure: true
111
+ }) : opt?.prefix === "host" ? (0, import_cookie.serialize)("__Host-" + name, value, {
112
+ ...opt,
113
+ path: "/",
114
+ secure: true,
115
+ domain: void 0
116
+ }) : (0, import_cookie.serialize)(name, value, {
117
+ path: "/",
118
+ ...opt
119
+ });
120
+ c.header("set-cookie", cookie, {
121
+ append: true
122
+ });
123
+ };
124
+ const setSignedCookie = async (c, name, value, secret, opt)=>{
125
+ let cookie;
126
+ cookie = opt?.prefix === "secure" ? await (0, import_cookie.serializeSigned)("__Secure-" + name, value, secret, {
127
+ path: "/",
128
+ ...opt,
129
+ secure: true
130
+ }) : opt?.prefix === "host" ? await (0, import_cookie.serializeSigned)("__Host-" + name, value, secret, {
131
+ ...opt,
132
+ path: "/",
133
+ secure: true,
134
+ domain: void 0
135
+ }) : await (0, import_cookie.serializeSigned)(name, value, secret, {
136
+ path: "/",
137
+ ...opt
138
+ });
139
+ c.header("set-cookie", cookie, {
140
+ append: true
141
+ });
142
+ };
143
+ const deleteCookie = (c, name, opt)=>{
144
+ const deletedCookie = getCookie(c, name);
145
+ setCookie(c, name, "", {
146
+ ...opt,
147
+ maxAge: 0
148
+ });
149
+ return deletedCookie;
150
+ };
151
+ },
152
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/http-exception.js": function(module) {
153
+ var __defProp = Object.defineProperty;
154
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
155
+ var __getOwnPropNames = Object.getOwnPropertyNames;
156
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
157
+ var __export = (target, all)=>{
158
+ for(var name in all)__defProp(target, name, {
159
+ get: all[name],
160
+ enumerable: true
161
+ });
162
+ };
163
+ var __copyProps = (to, from, except, desc)=>{
164
+ if (from && "object" == typeof from || "function" == typeof from) {
165
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
166
+ get: ()=>from[key],
167
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
168
+ });
169
+ }
170
+ return to;
171
+ };
172
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
173
+ value: true
174
+ }), mod);
175
+ var http_exception_exports = {};
176
+ __export(http_exception_exports, {
177
+ HTTPException: ()=>HTTPException
178
+ });
179
+ module.exports = __toCommonJS(http_exception_exports);
180
+ class HTTPException extends Error {
181
+ res;
182
+ status;
183
+ constructor(status = 500, options){
184
+ super(options?.message, {
185
+ cause: options?.cause
186
+ });
187
+ this.res = options?.res;
188
+ this.status = status;
189
+ }
190
+ getResponse() {
191
+ if (this.res) {
192
+ const newResponse = new Response(this.res.body, {
193
+ status: this.status,
194
+ headers: this.res.headers
195
+ });
196
+ return newResponse;
197
+ }
198
+ return new Response(this.message, {
199
+ status: this.status
200
+ });
201
+ }
202
+ }
203
+ },
204
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/buffer.js": function(module, __unused_webpack_exports, __webpack_require__) {
205
+ var __defProp = Object.defineProperty;
206
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
207
+ var __getOwnPropNames = Object.getOwnPropertyNames;
208
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
209
+ var __export = (target, all)=>{
210
+ for(var name in all)__defProp(target, name, {
211
+ get: all[name],
212
+ enumerable: true
213
+ });
12
214
  };
215
+ var __copyProps = (to, from, except, desc)=>{
216
+ if (from && "object" == typeof from || "function" == typeof from) {
217
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
218
+ get: ()=>from[key],
219
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
220
+ });
221
+ }
222
+ return to;
223
+ };
224
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
225
+ value: true
226
+ }), mod);
227
+ var buffer_exports = {};
228
+ __export(buffer_exports, {
229
+ bufferToFormData: ()=>bufferToFormData,
230
+ bufferToString: ()=>bufferToString,
231
+ equal: ()=>equal,
232
+ timingSafeEqual: ()=>timingSafeEqual
233
+ });
234
+ module.exports = __toCommonJS(buffer_exports);
235
+ var import_crypto = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/crypto.js");
236
+ const equal = (a, b)=>{
237
+ if (a === b) return true;
238
+ if (a.byteLength !== b.byteLength) return false;
239
+ const va = new DataView(a);
240
+ const vb = new DataView(b);
241
+ let i = va.byteLength;
242
+ while(i--)if (va.getUint8(i) !== vb.getUint8(i)) return false;
243
+ return true;
244
+ };
245
+ const timingSafeEqual = async (a, b, hashFunction)=>{
246
+ if (!hashFunction) hashFunction = import_crypto.sha256;
247
+ const [sa, sb] = await Promise.all([
248
+ hashFunction(a),
249
+ hashFunction(b)
250
+ ]);
251
+ if (!sa || !sb) return false;
252
+ return sa === sb && a === b;
253
+ };
254
+ const bufferToString = (buffer)=>{
255
+ if (buffer instanceof ArrayBuffer) {
256
+ const enc = new TextDecoder("utf-8");
257
+ return enc.decode(buffer);
258
+ }
259
+ return buffer;
260
+ };
261
+ const bufferToFormData = (arrayBuffer, contentType)=>{
262
+ const response = new Response(arrayBuffer, {
263
+ headers: {
264
+ "Content-Type": contentType
265
+ }
266
+ });
267
+ return response.formData();
268
+ };
269
+ },
270
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/cookie.js": function(module, __unused_webpack_exports, __webpack_require__) {
271
+ var __defProp = Object.defineProperty;
272
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
273
+ var __getOwnPropNames = Object.getOwnPropertyNames;
274
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
275
+ var __export = (target, all)=>{
276
+ for(var name in all)__defProp(target, name, {
277
+ get: all[name],
278
+ enumerable: true
279
+ });
280
+ };
281
+ var __copyProps = (to, from, except, desc)=>{
282
+ if (from && "object" == typeof from || "function" == typeof from) {
283
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
284
+ get: ()=>from[key],
285
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
286
+ });
287
+ }
288
+ return to;
289
+ };
290
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
291
+ value: true
292
+ }), mod);
293
+ var cookie_exports = {};
294
+ __export(cookie_exports, {
295
+ parse: ()=>parse,
296
+ parseSigned: ()=>parseSigned,
297
+ serialize: ()=>serialize,
298
+ serializeSigned: ()=>serializeSigned
299
+ });
300
+ module.exports = __toCommonJS(cookie_exports);
301
+ var import_url = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/url.js");
302
+ const algorithm = {
303
+ name: "HMAC",
304
+ hash: "SHA-256"
305
+ };
306
+ const getCryptoKey = async (secret)=>{
307
+ const secretBuf = "string" == typeof secret ? new TextEncoder().encode(secret) : secret;
308
+ return await crypto.subtle.importKey("raw", secretBuf, algorithm, false, [
309
+ "sign",
310
+ "verify"
311
+ ]);
312
+ };
313
+ const makeSignature = async (value, secret)=>{
314
+ const key = await getCryptoKey(secret);
315
+ const signature = await crypto.subtle.sign(algorithm.name, key, new TextEncoder().encode(value));
316
+ return btoa(String.fromCharCode(...new Uint8Array(signature)));
317
+ };
318
+ const verifySignature = async (base64Signature, value, secret)=>{
319
+ try {
320
+ const signatureBinStr = atob(base64Signature);
321
+ const signature = new Uint8Array(signatureBinStr.length);
322
+ for(let i = 0, len = signatureBinStr.length; i < len; i++)signature[i] = signatureBinStr.charCodeAt(i);
323
+ return await crypto.subtle.verify(algorithm, secret, signature, new TextEncoder().encode(value));
324
+ } catch {
325
+ return false;
326
+ }
327
+ };
328
+ const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
329
+ const validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
330
+ const parse = (cookie, name)=>{
331
+ const pairs = cookie.trim().split(";");
332
+ return pairs.reduce((parsedCookie, pairStr)=>{
333
+ pairStr = pairStr.trim();
334
+ const valueStartPos = pairStr.indexOf("=");
335
+ if (-1 === valueStartPos) return parsedCookie;
336
+ const cookieName = pairStr.substring(0, valueStartPos).trim();
337
+ if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
338
+ let cookieValue = pairStr.substring(valueStartPos + 1).trim();
339
+ if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) cookieValue = cookieValue.slice(1, -1);
340
+ if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = (0, import_url.decodeURIComponent_)(cookieValue);
341
+ return parsedCookie;
342
+ }, {});
343
+ };
344
+ const parseSigned = async (cookie, secret, name)=>{
345
+ const parsedCookie = {};
346
+ const secretKey = await getCryptoKey(secret);
347
+ for (const [key, value] of Object.entries(parse(cookie, name))){
348
+ const signatureStartPos = value.lastIndexOf(".");
349
+ if (signatureStartPos < 1) continue;
350
+ const signedValue = value.substring(0, signatureStartPos);
351
+ const signature = value.substring(signatureStartPos + 1);
352
+ if (44 !== signature.length || !signature.endsWith("=")) continue;
353
+ const isVerified = await verifySignature(signature, signedValue, secretKey);
354
+ parsedCookie[key] = isVerified ? signedValue : false;
355
+ }
356
+ return parsedCookie;
357
+ };
358
+ const _serialize = (name, value, opt = {})=>{
359
+ let cookie = `${name}=${value}`;
360
+ if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
361
+ if (name.startsWith("__Host-")) {
362
+ if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
363
+ if ("/" !== opt.path) throw new Error('__Host- Cookie must have Path attributes with "/"');
364
+ if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
365
+ }
366
+ if (opt && "number" == typeof opt.maxAge && opt.maxAge >= 0) {
367
+ if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
368
+ cookie += `; Max-Age=${Math.floor(opt.maxAge)}`;
369
+ }
370
+ if (opt.domain && "host" !== opt.prefix) cookie += `; Domain=${opt.domain}`;
371
+ if (opt.path) cookie += `; Path=${opt.path}`;
372
+ if (opt.expires) {
373
+ if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
374
+ cookie += `; Expires=${opt.expires.toUTCString()}`;
375
+ }
376
+ if (opt.httpOnly) cookie += "; HttpOnly";
377
+ if (opt.secure) cookie += "; Secure";
378
+ if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
379
+ if (opt.partitioned) {
380
+ if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
381
+ cookie += "; Partitioned";
382
+ }
383
+ return cookie;
384
+ };
385
+ const serialize = (name, value, opt)=>{
386
+ value = encodeURIComponent(value);
387
+ return _serialize(name, value, opt);
388
+ };
389
+ const serializeSigned = async (name, value, secret, opt = {})=>{
390
+ const signature = await makeSignature(value, secret);
391
+ value = `${value}.${signature}`;
392
+ value = encodeURIComponent(value);
393
+ return _serialize(name, value, opt);
394
+ };
395
+ },
396
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/crypto.js": function(module) {
397
+ var __defProp = Object.defineProperty;
398
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
399
+ var __getOwnPropNames = Object.getOwnPropertyNames;
400
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
401
+ var __export = (target, all)=>{
402
+ for(var name in all)__defProp(target, name, {
403
+ get: all[name],
404
+ enumerable: true
405
+ });
406
+ };
407
+ var __copyProps = (to, from, except, desc)=>{
408
+ if (from && "object" == typeof from || "function" == typeof from) {
409
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
410
+ get: ()=>from[key],
411
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
412
+ });
413
+ }
414
+ return to;
415
+ };
416
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
417
+ value: true
418
+ }), mod);
419
+ var crypto_exports = {};
420
+ __export(crypto_exports, {
421
+ createHash: ()=>createHash,
422
+ md5: ()=>md5,
423
+ sha1: ()=>sha1,
424
+ sha256: ()=>sha256
425
+ });
426
+ module.exports = __toCommonJS(crypto_exports);
427
+ const sha256 = async (data)=>{
428
+ const algorithm = {
429
+ name: "SHA-256",
430
+ alias: "sha256"
431
+ };
432
+ const hash = await createHash(data, algorithm);
433
+ return hash;
434
+ };
435
+ const sha1 = async (data)=>{
436
+ const algorithm = {
437
+ name: "SHA-1",
438
+ alias: "sha1"
439
+ };
440
+ const hash = await createHash(data, algorithm);
441
+ return hash;
442
+ };
443
+ const md5 = async (data)=>{
444
+ const algorithm = {
445
+ name: "MD5",
446
+ alias: "md5"
447
+ };
448
+ const hash = await createHash(data, algorithm);
449
+ return hash;
450
+ };
451
+ const createHash = async (data, algorithm)=>{
452
+ let sourceBuffer;
453
+ if (data instanceof ReadableStream) {
454
+ let body = "";
455
+ const reader = data.getReader();
456
+ await reader?.read().then(async (chuck)=>{
457
+ const value = await createHash(chuck.value || "", algorithm);
458
+ body += value;
459
+ });
460
+ return body;
461
+ }
462
+ if (ArrayBuffer.isView(data) || data instanceof ArrayBuffer) sourceBuffer = data;
463
+ else {
464
+ if ("object" == typeof data) data = JSON.stringify(data);
465
+ sourceBuffer = new TextEncoder().encode(String(data));
466
+ }
467
+ if (crypto && crypto.subtle) {
468
+ const buffer = await crypto.subtle.digest({
469
+ name: algorithm.name
470
+ }, sourceBuffer);
471
+ const hash = Array.prototype.map.call(new Uint8Array(buffer), (x)=>("00" + x.toString(16)).slice(-2)).join("");
472
+ return hash;
473
+ }
474
+ return null;
475
+ };
476
+ },
477
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/url.js": function(module) {
478
+ var __defProp = Object.defineProperty;
479
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
480
+ var __getOwnPropNames = Object.getOwnPropertyNames;
481
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
482
+ var __export = (target, all)=>{
483
+ for(var name in all)__defProp(target, name, {
484
+ get: all[name],
485
+ enumerable: true
486
+ });
487
+ };
488
+ var __copyProps = (to, from, except, desc)=>{
489
+ if (from && "object" == typeof from || "function" == typeof from) {
490
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
491
+ get: ()=>from[key],
492
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
493
+ });
494
+ }
495
+ return to;
496
+ };
497
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
498
+ value: true
499
+ }), mod);
500
+ var url_exports = {};
501
+ __export(url_exports, {
502
+ checkOptionalParameter: ()=>checkOptionalParameter,
503
+ decodeURIComponent_: ()=>decodeURIComponent_,
504
+ getPath: ()=>getPath,
505
+ getPathNoStrict: ()=>getPathNoStrict,
506
+ getPattern: ()=>getPattern,
507
+ getQueryParam: ()=>getQueryParam,
508
+ getQueryParams: ()=>getQueryParams,
509
+ getQueryStrings: ()=>getQueryStrings,
510
+ mergePath: ()=>mergePath,
511
+ splitPath: ()=>splitPath,
512
+ splitRoutingPath: ()=>splitRoutingPath
513
+ });
514
+ module.exports = __toCommonJS(url_exports);
515
+ const splitPath = (path)=>{
516
+ const paths = path.split("/");
517
+ if ("" === paths[0]) paths.shift();
518
+ return paths;
519
+ };
520
+ const splitRoutingPath = (routePath)=>{
521
+ const { groups, path } = extractGroupsFromPath(routePath);
522
+ const paths = splitPath(path);
523
+ return replaceGroupMarks(paths, groups);
524
+ };
525
+ const extractGroupsFromPath = (path)=>{
526
+ const groups = [];
527
+ path = path.replace(/\{[^}]+\}/g, (match, index)=>{
528
+ const mark = `@${index}`;
529
+ groups.push([
530
+ mark,
531
+ match
532
+ ]);
533
+ return mark;
534
+ });
535
+ return {
536
+ groups,
537
+ path
538
+ };
539
+ };
540
+ const replaceGroupMarks = (paths, groups)=>{
541
+ for(let i = groups.length - 1; i >= 0; i--){
542
+ const [mark] = groups[i];
543
+ for(let j = paths.length - 1; j >= 0; j--)if (paths[j].includes(mark)) {
544
+ paths[j] = paths[j].replace(mark, groups[i][1]);
545
+ break;
546
+ }
547
+ }
548
+ return paths;
549
+ };
550
+ const patternCache = {};
551
+ const getPattern = (label)=>{
552
+ if ("*" === label) return "*";
553
+ const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
554
+ if (match) {
555
+ if (!patternCache[label]) {
556
+ if (match[2]) patternCache[label] = [
557
+ label,
558
+ match[1],
559
+ new RegExp("^" + match[2] + "$")
560
+ ];
561
+ else patternCache[label] = [
562
+ label,
563
+ match[1],
564
+ true
565
+ ];
566
+ }
567
+ return patternCache[label];
568
+ }
569
+ return null;
570
+ };
571
+ const tryDecodeURI = (str)=>{
572
+ try {
573
+ return decodeURI(str);
574
+ } catch {
575
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match)=>{
576
+ try {
577
+ return decodeURI(match);
578
+ } catch {
579
+ return match;
580
+ }
581
+ });
582
+ }
583
+ };
584
+ const getPath = (request)=>{
585
+ const url = request.url;
586
+ const start = url.indexOf("/", 8);
587
+ let i = start;
588
+ for(; i < url.length; i++){
589
+ const charCode = url.charCodeAt(i);
590
+ if (37 === charCode) {
591
+ const queryIndex = url.indexOf("?", i);
592
+ const path = url.slice(start, -1 === queryIndex ? void 0 : queryIndex);
593
+ return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
594
+ }
595
+ if (63 === charCode) break;
596
+ }
597
+ return url.slice(start, i);
598
+ };
599
+ const getQueryStrings = (url)=>{
600
+ const queryIndex = url.indexOf("?", 8);
601
+ return -1 === queryIndex ? "" : "?" + url.slice(queryIndex + 1);
602
+ };
603
+ const getPathNoStrict = (request)=>{
604
+ const result = getPath(request);
605
+ return result.length > 1 && "/" === result[result.length - 1] ? result.slice(0, -1) : result;
606
+ };
607
+ const mergePath = (...paths)=>{
608
+ let p = "";
609
+ let endsWithSlash = false;
610
+ for (let path of paths){
611
+ if ("/" === p[p.length - 1]) {
612
+ p = p.slice(0, -1);
613
+ endsWithSlash = true;
614
+ }
615
+ if ("/" !== path[0]) path = `/${path}`;
616
+ if ("/" === path && endsWithSlash) p = `${p}/`;
617
+ else if ("/" !== path) p = `${p}${path}`;
618
+ if ("/" === path && "" === p) p = "/";
619
+ }
620
+ return p;
621
+ };
622
+ const checkOptionalParameter = (path)=>{
623
+ if (!path.match(/\:.+\?$/)) return null;
624
+ const segments = path.split("/");
625
+ const results = [];
626
+ let basePath = "";
627
+ segments.forEach((segment)=>{
628
+ if ("" === segment || /\:/.test(segment)) {
629
+ if (/\:/.test(segment)) {
630
+ if (/\?/.test(segment)) {
631
+ if (0 === results.length && "" === basePath) results.push("/");
632
+ else results.push(basePath);
633
+ const optionalSegment = segment.replace("?", "");
634
+ basePath += "/" + optionalSegment;
635
+ results.push(basePath);
636
+ } else basePath += "/" + segment;
637
+ }
638
+ } else basePath += "/" + segment;
639
+ });
640
+ return results.filter((v, i, a)=>a.indexOf(v) === i);
641
+ };
642
+ const _decodeURI = (value)=>{
643
+ if (!/[%+]/.test(value)) return value;
644
+ if (-1 !== value.indexOf("+")) value = value.replace(/\+/g, " ");
645
+ return /%/.test(value) ? decodeURIComponent_(value) : value;
646
+ };
647
+ const _getQueryParam = (url, key, multiple)=>{
648
+ let encoded;
649
+ if (!multiple && key && !/[%+]/.test(key)) {
650
+ let keyIndex2 = url.indexOf(`?${key}`, 8);
651
+ if (-1 === keyIndex2) keyIndex2 = url.indexOf(`&${key}`, 8);
652
+ while(-1 !== keyIndex2){
653
+ const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
654
+ if (61 === trailingKeyCode) {
655
+ const valueIndex = keyIndex2 + key.length + 2;
656
+ const endIndex = url.indexOf("&", valueIndex);
657
+ return _decodeURI(url.slice(valueIndex, -1 === endIndex ? void 0 : endIndex));
658
+ }
659
+ if (38 == trailingKeyCode || isNaN(trailingKeyCode)) return "";
660
+ keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
661
+ }
662
+ encoded = /[%+]/.test(url);
663
+ if (!encoded) return;
664
+ }
665
+ const results = {};
666
+ encoded ??= /[%+]/.test(url);
667
+ let keyIndex = url.indexOf("?", 8);
668
+ while(-1 !== keyIndex){
669
+ const nextKeyIndex = url.indexOf("&", keyIndex + 1);
670
+ let valueIndex = url.indexOf("=", keyIndex);
671
+ if (valueIndex > nextKeyIndex && -1 !== nextKeyIndex) valueIndex = -1;
672
+ let name = url.slice(keyIndex + 1, -1 === valueIndex ? -1 === nextKeyIndex ? void 0 : nextKeyIndex : valueIndex);
673
+ if (encoded) name = _decodeURI(name);
674
+ keyIndex = nextKeyIndex;
675
+ if ("" === name) continue;
676
+ let value;
677
+ if (-1 === valueIndex) value = "";
678
+ else {
679
+ value = url.slice(valueIndex + 1, -1 === nextKeyIndex ? void 0 : nextKeyIndex);
680
+ if (encoded) value = _decodeURI(value);
681
+ }
682
+ if (multiple) {
683
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
684
+ results[name].push(value);
685
+ } else results[name] ??= value;
686
+ }
687
+ return key ? results[key] : results;
688
+ };
689
+ const getQueryParam = _getQueryParam;
690
+ const getQueryParams = (url, key)=>_getQueryParam(url, key, true);
691
+ const decodeURIComponent_ = decodeURIComponent;
692
+ },
693
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
694
+ var __defProp = Object.defineProperty;
695
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
696
+ var __getOwnPropNames = Object.getOwnPropertyNames;
697
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
698
+ var __export = (target, all)=>{
699
+ for(var name in all)__defProp(target, name, {
700
+ get: all[name],
701
+ enumerable: true
702
+ });
703
+ };
704
+ var __copyProps = (to, from, except, desc)=>{
705
+ if (from && "object" == typeof from || "function" == typeof from) {
706
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
707
+ get: ()=>from[key],
708
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
709
+ });
710
+ }
711
+ return to;
712
+ };
713
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
714
+ value: true
715
+ }), mod);
716
+ var validator_exports = {};
717
+ __export(validator_exports, {
718
+ validator: ()=>import_validator.validator
719
+ });
720
+ module.exports = __toCommonJS(validator_exports);
721
+ var import_validator = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/validator.js");
722
+ },
723
+ "../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/validator/validator.js": function(module, __unused_webpack_exports, __webpack_require__) {
724
+ var __defProp = Object.defineProperty;
725
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
726
+ var __getOwnPropNames = Object.getOwnPropertyNames;
727
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
728
+ var __export = (target, all)=>{
729
+ for(var name in all)__defProp(target, name, {
730
+ get: all[name],
731
+ enumerable: true
732
+ });
733
+ };
734
+ var __copyProps = (to, from, except, desc)=>{
735
+ if (from && "object" == typeof from || "function" == typeof from) {
736
+ for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
737
+ get: ()=>from[key],
738
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
739
+ });
740
+ }
741
+ return to;
742
+ };
743
+ var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
744
+ value: true
745
+ }), mod);
746
+ var validator_exports = {};
747
+ __export(validator_exports, {
748
+ validator: ()=>validator
749
+ });
750
+ module.exports = __toCommonJS(validator_exports);
751
+ var import_cookie = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/helper/cookie/index.js");
752
+ var import_http_exception = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/http-exception.js");
753
+ var import_buffer = __webpack_require__("../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/cjs/utils/buffer.js");
754
+ const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
755
+ const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
756
+ const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
757
+ const validator = (target, validationFunc)=>async (c, next)=>{
758
+ let value = {};
759
+ const contentType = c.req.header("Content-Type");
760
+ switch(target){
761
+ case "json":
762
+ if (!contentType || !jsonRegex.test(contentType)) break;
763
+ try {
764
+ value = await c.req.json();
765
+ } catch {
766
+ const message = "Malformed JSON in request body";
767
+ throw new import_http_exception.HTTPException(400, {
768
+ message
769
+ });
770
+ }
771
+ break;
772
+ case "form":
773
+ {
774
+ if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
775
+ let formData;
776
+ if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
777
+ else try {
778
+ const arrayBuffer = await c.req.arrayBuffer();
779
+ formData = await (0, import_buffer.bufferToFormData)(arrayBuffer, contentType);
780
+ c.req.bodyCache.formData = formData;
781
+ } catch (e) {
782
+ let message = "Malformed FormData request.";
783
+ message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
784
+ throw new import_http_exception.HTTPException(400, {
785
+ message
786
+ });
787
+ }
788
+ const form = {};
789
+ formData.forEach((value2, key)=>{
790
+ if (key.endsWith("[]")) (form[key] ??= []).push(value2);
791
+ else if (Array.isArray(form[key])) form[key].push(value2);
792
+ else if (key in form) form[key] = [
793
+ form[key],
794
+ value2
795
+ ];
796
+ else form[key] = value2;
797
+ });
798
+ value = form;
799
+ break;
800
+ }
801
+ case "query":
802
+ value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v])=>1 === v.length ? [
803
+ k,
804
+ v[0]
805
+ ] : [
806
+ k,
807
+ v
808
+ ]));
809
+ break;
810
+ case "param":
811
+ value = c.req.param();
812
+ break;
813
+ case "header":
814
+ value = c.req.header();
815
+ break;
816
+ case "cookie":
817
+ value = (0, import_cookie.getCookie)(c);
818
+ break;
819
+ }
820
+ const res = await validationFunc(value, c);
821
+ if (res instanceof Response) return res;
822
+ c.req.addValidatedData(target, res);
823
+ await next();
824
+ };
825
+ }
826
+ };
827
+ var __webpack_module_cache__ = {};
828
+ function __webpack_require__(moduleId) {
829
+ var cachedModule = __webpack_module_cache__[moduleId];
830
+ if (void 0 !== cachedModule) return cachedModule.exports;
831
+ var module = __webpack_module_cache__[moduleId] = {
832
+ exports: {}
833
+ };
834
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
835
+ return module.exports;
836
+ }
837
+ (()=>{
838
+ __webpack_require__.n = (module)=>{
839
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
13
840
  __webpack_require__.d(getter, {
14
841
  a: getter
15
842
  });
@@ -17,7 +844,7 @@ var __webpack_require__ = {};
17
844
  };
18
845
  })();
19
846
  (()=>{
20
- __webpack_require__.d = function(exports1, definition) {
847
+ __webpack_require__.d = (exports1, definition)=>{
21
848
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
22
849
  enumerable: true,
23
850
  get: definition[key]
@@ -25,12 +852,10 @@ var __webpack_require__ = {};
25
852
  };
26
853
  })();
27
854
  (()=>{
28
- __webpack_require__.o = function(obj, prop) {
29
- return Object.prototype.hasOwnProperty.call(obj, prop);
30
- };
855
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
31
856
  })();
32
857
  (()=>{
33
- __webpack_require__.r = function(exports1) {
858
+ __webpack_require__.r = (exports1)=>{
34
859
  if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
35
860
  value: 'Module'
36
861
  });
@@ -40,2062 +865,1752 @@ var __webpack_require__ = {};
40
865
  };
41
866
  })();
42
867
  var __webpack_exports__ = {};
43
- __webpack_require__.r(__webpack_exports__);
44
- __webpack_require__.d(__webpack_exports__, {
45
- default: ()=>src_server_rslib_entry_
46
- });
47
- const external_path_namespaceObject = require("path");
48
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
49
- const external_url_namespaceObject = require("url");
50
- var getFilePath = (options)=>{
51
- let filename = options.filename;
52
- const defaultDocument = options.defaultDocument || "index.html";
53
- if (filename.endsWith("/")) filename = filename.concat(defaultDocument);
54
- else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) filename = filename.concat("/" + defaultDocument);
55
- const path = getFilePathWithoutDefaultDocument({
56
- root: options.root,
57
- filename
58
- });
59
- return path;
60
- };
61
- var getFilePathWithoutDefaultDocument = (options)=>{
62
- let root = options.root || "";
63
- let filename = options.filename;
64
- if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) return;
65
- filename = filename.replace(/^\.?[\/\\]/, "");
66
- filename = filename.replace(/\\/, "/");
67
- root = root.replace(/\/$/, "");
68
- let path = root ? root + "/" + filename : filename;
69
- path = path.replace(/^\.?\//, "");
70
- if ("/" !== root[0] && "/" === path[0]) return;
71
- return path;
72
- };
73
- var getMimeType = (filename, mimes = baseMimes)=>{
74
- const regexp = /\.([a-zA-Z0-9]+?)$/;
75
- const match = filename.match(regexp);
76
- if (!match) return;
77
- let mimeType = mimes[match[1]];
78
- if (mimeType && mimeType.startsWith("text") || "application/json" === mimeType) mimeType += "; charset=utf-8";
79
- return mimeType;
80
- };
81
- var baseMimes = {
82
- aac: "audio/aac",
83
- avi: "video/x-msvideo",
84
- avif: "image/avif",
85
- av1: "video/av1",
86
- bin: "application/octet-stream",
87
- bmp: "image/bmp",
88
- css: "text/css",
89
- csv: "text/csv",
90
- eot: "application/vnd.ms-fontobject",
91
- epub: "application/epub+zip",
92
- gif: "image/gif",
93
- gz: "application/gzip",
94
- htm: "text/html",
95
- html: "text/html",
96
- ico: "image/x-icon",
97
- ics: "text/calendar",
98
- jpeg: "image/jpeg",
99
- jpg: "image/jpeg",
100
- js: "text/javascript",
101
- json: "application/json",
102
- jsonld: "application/ld+json",
103
- map: "application/json",
104
- mid: "audio/x-midi",
105
- midi: "audio/x-midi",
106
- mjs: "text/javascript",
107
- mp3: "audio/mpeg",
108
- mp4: "video/mp4",
109
- mpeg: "video/mpeg",
110
- oga: "audio/ogg",
111
- ogv: "video/ogg",
112
- ogx: "application/ogg",
113
- opus: "audio/opus",
114
- otf: "font/otf",
115
- pdf: "application/pdf",
116
- png: "image/png",
117
- rtf: "application/rtf",
118
- svg: "image/svg+xml",
119
- tif: "image/tiff",
120
- tiff: "image/tiff",
121
- ts: "video/mp2t",
122
- ttf: "font/ttf",
123
- txt: "text/plain",
124
- wasm: "application/wasm",
125
- webm: "video/webm",
126
- weba: "audio/webm",
127
- webp: "image/webp",
128
- woff: "font/woff",
129
- woff2: "font/woff2",
130
- xhtml: "application/xhtml+xml",
131
- xml: "application/xml",
132
- zip: "application/zip",
133
- "3gp": "video/3gpp",
134
- "3g2": "video/3gpp2",
135
- gltf: "model/gltf+json",
136
- glb: "model/gltf-binary"
137
- };
138
- const external_fs_namespaceObject = require("fs");
139
- var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
140
- var ENCODINGS = {
141
- br: ".br",
142
- zstd: ".zst",
143
- gzip: ".gz"
144
- };
145
- var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
146
- var createStreamBody = (stream)=>{
147
- const body = new ReadableStream({
148
- start (controller) {
149
- stream.on("data", (chunk)=>{
150
- controller.enqueue(chunk);
151
- });
152
- stream.on("end", ()=>{
153
- controller.close();
154
- });
155
- },
156
- cancel () {
157
- stream.destroy();
158
- }
868
+ (()=>{
869
+ __webpack_require__.r(__webpack_exports__);
870
+ __webpack_require__.d(__webpack_exports__, {
871
+ default: ()=>src_server_rslib_entry_
159
872
  });
160
- return body;
161
- };
162
- var addCurrentDirPrefix = (path)=>`./${path}`;
163
- var getStats = (path)=>{
164
- let stats;
165
- try {
166
- stats = (0, external_fs_namespaceObject.lstatSync)(path);
167
- } catch {}
168
- return stats;
169
- };
170
- var serveStatic = (options = {
171
- root: ""
172
- })=>async (c, next)=>{
173
- if (c.finalized) return next();
174
- let filename;
175
- try {
176
- filename = options.path ?? decodeURIComponent(c.req.path);
177
- } catch {
178
- await options.onNotFound?.(c.req.path, c);
179
- return next();
180
- }
181
- let path = getFilePathWithoutDefaultDocument({
182
- filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
183
- root: options.root
873
+ const external_path_namespaceObject = require("path");
874
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
875
+ const external_url_namespaceObject = require("url");
876
+ var getFilePath = (options)=>{
877
+ let filename = options.filename;
878
+ const defaultDocument = options.defaultDocument || "index.html";
879
+ if (filename.endsWith("/")) filename = filename.concat(defaultDocument);
880
+ else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) filename = filename.concat("/" + defaultDocument);
881
+ const path = getFilePathWithoutDefaultDocument({
882
+ root: options.root,
883
+ filename
884
+ });
885
+ return path;
886
+ };
887
+ var getFilePathWithoutDefaultDocument = (options)=>{
888
+ let root = options.root || "";
889
+ let filename = options.filename;
890
+ if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) return;
891
+ filename = filename.replace(/^\.?[\/\\]/, "");
892
+ filename = filename.replace(/\\/, "/");
893
+ root = root.replace(/\/$/, "");
894
+ let path = root ? root + "/" + filename : filename;
895
+ path = path.replace(/^\.?\//, "");
896
+ if ("/" !== root[0] && "/" === path[0]) return;
897
+ return path;
898
+ };
899
+ var getMimeType = (filename, mimes = baseMimes)=>{
900
+ const regexp = /\.([a-zA-Z0-9]+?)$/;
901
+ const match = filename.match(regexp);
902
+ if (!match) return;
903
+ let mimeType = mimes[match[1]];
904
+ if (mimeType && mimeType.startsWith("text") || "application/json" === mimeType) mimeType += "; charset=utf-8";
905
+ return mimeType;
906
+ };
907
+ var baseMimes = {
908
+ aac: "audio/aac",
909
+ avi: "video/x-msvideo",
910
+ avif: "image/avif",
911
+ av1: "video/av1",
912
+ bin: "application/octet-stream",
913
+ bmp: "image/bmp",
914
+ css: "text/css",
915
+ csv: "text/csv",
916
+ eot: "application/vnd.ms-fontobject",
917
+ epub: "application/epub+zip",
918
+ gif: "image/gif",
919
+ gz: "application/gzip",
920
+ htm: "text/html",
921
+ html: "text/html",
922
+ ico: "image/x-icon",
923
+ ics: "text/calendar",
924
+ jpeg: "image/jpeg",
925
+ jpg: "image/jpeg",
926
+ js: "text/javascript",
927
+ json: "application/json",
928
+ jsonld: "application/ld+json",
929
+ map: "application/json",
930
+ mid: "audio/x-midi",
931
+ midi: "audio/x-midi",
932
+ mjs: "text/javascript",
933
+ mp3: "audio/mpeg",
934
+ mp4: "video/mp4",
935
+ mpeg: "video/mpeg",
936
+ oga: "audio/ogg",
937
+ ogv: "video/ogg",
938
+ ogx: "application/ogg",
939
+ opus: "audio/opus",
940
+ otf: "font/otf",
941
+ pdf: "application/pdf",
942
+ png: "image/png",
943
+ rtf: "application/rtf",
944
+ svg: "image/svg+xml",
945
+ tif: "image/tiff",
946
+ tiff: "image/tiff",
947
+ ts: "video/mp2t",
948
+ ttf: "font/ttf",
949
+ txt: "text/plain",
950
+ wasm: "application/wasm",
951
+ webm: "video/webm",
952
+ weba: "audio/webm",
953
+ webp: "image/webp",
954
+ woff: "font/woff",
955
+ woff2: "font/woff2",
956
+ xhtml: "application/xhtml+xml",
957
+ xml: "application/xml",
958
+ zip: "application/zip",
959
+ "3gp": "video/3gpp",
960
+ "3g2": "video/3gpp2",
961
+ gltf: "model/gltf+json",
962
+ glb: "model/gltf-binary"
963
+ };
964
+ const external_fs_namespaceObject = require("fs");
965
+ var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
966
+ var ENCODINGS = {
967
+ br: ".br",
968
+ zstd: ".zst",
969
+ gzip: ".gz"
970
+ };
971
+ var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
972
+ var createStreamBody = (stream)=>{
973
+ const body = new ReadableStream({
974
+ start (controller) {
975
+ stream.on("data", (chunk)=>{
976
+ controller.enqueue(chunk);
977
+ });
978
+ stream.on("end", ()=>{
979
+ controller.close();
980
+ });
981
+ },
982
+ cancel () {
983
+ stream.destroy();
984
+ }
184
985
  });
185
- if (!path) return next();
186
- path = addCurrentDirPrefix(path);
187
- let stats = getStats(path);
188
- if (stats && stats.isDirectory()) {
189
- path = getFilePath({
986
+ return body;
987
+ };
988
+ var addCurrentDirPrefix = (path)=>`./${path}`;
989
+ var getStats = (path)=>{
990
+ let stats;
991
+ try {
992
+ stats = (0, external_fs_namespaceObject.lstatSync)(path);
993
+ } catch {}
994
+ return stats;
995
+ };
996
+ var serveStatic = (options = {
997
+ root: ""
998
+ })=>async (c, next)=>{
999
+ if (c.finalized) return next();
1000
+ let filename;
1001
+ try {
1002
+ filename = options.path ?? decodeURIComponent(c.req.path);
1003
+ } catch {
1004
+ await options.onNotFound?.(c.req.path, c);
1005
+ return next();
1006
+ }
1007
+ let path = getFilePathWithoutDefaultDocument({
190
1008
  filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
191
- root: options.root,
192
- defaultDocument: options.index ?? "index.html"
1009
+ root: options.root
193
1010
  });
194
1011
  if (!path) return next();
195
1012
  path = addCurrentDirPrefix(path);
196
- stats = getStats(path);
197
- }
198
- if (!stats) {
199
- await options.onNotFound?.(path, c);
200
- return next();
201
- }
202
- await options.onFound?.(path, c);
203
- const mimeType = getMimeType(path);
204
- c.header("Content-Type", mimeType || "application/octet-stream");
205
- if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
206
- const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding)=>encoding.trim()));
207
- for (const encoding of ENCODINGS_ORDERED_KEYS){
208
- if (!acceptEncodingSet.has(encoding)) continue;
209
- const precompressedStats = getStats(path + ENCODINGS[encoding]);
210
- if (precompressedStats) {
211
- c.header("Content-Encoding", encoding);
212
- c.header("Vary", "Accept-Encoding", {
213
- append: true
214
- });
215
- stats = precompressedStats;
216
- path += ENCODINGS[encoding];
217
- break;
1013
+ let stats = getStats(path);
1014
+ if (stats && stats.isDirectory()) {
1015
+ path = getFilePath({
1016
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
1017
+ root: options.root,
1018
+ defaultDocument: options.index ?? "index.html"
1019
+ });
1020
+ if (!path) return next();
1021
+ path = addCurrentDirPrefix(path);
1022
+ stats = getStats(path);
1023
+ }
1024
+ if (!stats) {
1025
+ await options.onNotFound?.(path, c);
1026
+ return next();
1027
+ }
1028
+ await options.onFound?.(path, c);
1029
+ const mimeType = getMimeType(path);
1030
+ c.header("Content-Type", mimeType || "application/octet-stream");
1031
+ if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
1032
+ const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding)=>encoding.trim()));
1033
+ for (const encoding of ENCODINGS_ORDERED_KEYS){
1034
+ if (!acceptEncodingSet.has(encoding)) continue;
1035
+ const precompressedStats = getStats(path + ENCODINGS[encoding]);
1036
+ if (precompressedStats) {
1037
+ c.header("Content-Encoding", encoding);
1038
+ c.header("Vary", "Accept-Encoding", {
1039
+ append: true
1040
+ });
1041
+ stats = precompressedStats;
1042
+ path += ENCODINGS[encoding];
1043
+ break;
1044
+ }
218
1045
  }
219
1046
  }
220
- }
221
- const size = stats.size;
222
- if ("HEAD" == c.req.method || "OPTIONS" == c.req.method) {
223
- c.header("Content-Length", size.toString());
224
- c.status(200);
225
- return c.body(null);
226
- }
227
- const range = c.req.header("range") || "";
228
- if (!range) {
229
- c.header("Content-Length", size.toString());
230
- return c.body(createStreamBody((0, external_fs_namespaceObject.createReadStream)(path)), 200);
231
- }
232
- c.header("Accept-Ranges", "bytes");
233
- c.header("Date", stats.birthtime.toUTCString());
234
- const parts = range.replace(/bytes=/, "").split("-", 2);
235
- const start = parts[0] ? parseInt(parts[0], 10) : 0;
236
- let end = parts[1] ? parseInt(parts[1], 10) : stats.size - 1;
237
- if (size < end - start + 1) end = size - 1;
238
- const chunksize = end - start + 1;
239
- const stream = (0, external_fs_namespaceObject.createReadStream)(path, {
240
- start,
241
- end
1047
+ const size = stats.size;
1048
+ if ("HEAD" == c.req.method || "OPTIONS" == c.req.method) {
1049
+ c.header("Content-Length", size.toString());
1050
+ c.status(200);
1051
+ return c.body(null);
1052
+ }
1053
+ const range = c.req.header("range") || "";
1054
+ if (!range) {
1055
+ c.header("Content-Length", size.toString());
1056
+ return c.body(createStreamBody((0, external_fs_namespaceObject.createReadStream)(path)), 200);
1057
+ }
1058
+ c.header("Accept-Ranges", "bytes");
1059
+ c.header("Date", stats.birthtime.toUTCString());
1060
+ const parts = range.replace(/bytes=/, "").split("-", 2);
1061
+ const start = parts[0] ? parseInt(parts[0], 10) : 0;
1062
+ let end = parts[1] ? parseInt(parts[1], 10) : stats.size - 1;
1063
+ if (size < end - start + 1) end = size - 1;
1064
+ const chunksize = end - start + 1;
1065
+ const stream = (0, external_fs_namespaceObject.createReadStream)(path, {
1066
+ start,
1067
+ end
1068
+ });
1069
+ c.header("Content-Length", chunksize.toString());
1070
+ c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
1071
+ return c.body(createStreamBody(stream), 206);
1072
+ };
1073
+ var parseBody = async (request, options = /* @__PURE__ */ Object.create(null))=>{
1074
+ const { all = false, dot = false } = options;
1075
+ const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
1076
+ const contentType = headers.get("Content-Type");
1077
+ if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
1078
+ all,
1079
+ dot
242
1080
  });
243
- c.header("Content-Length", chunksize.toString());
244
- c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
245
- return c.body(createStreamBody(stream), 206);
1081
+ return {};
246
1082
  };
247
- var parseBody = async (request, options = /* @__PURE__ */ Object.create(null))=>{
248
- const { all = false, dot = false } = options;
249
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
250
- const contentType = headers.get("Content-Type");
251
- if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
252
- all,
253
- dot
254
- });
255
- return {};
256
- };
257
- async function parseFormData(request, options) {
258
- const formData = await request.formData();
259
- if (formData) return convertFormDataToBodyData(formData, options);
260
- return {};
261
- }
262
- function convertFormDataToBodyData(formData, options) {
263
- const form = /* @__PURE__ */ Object.create(null);
264
- formData.forEach((value, key)=>{
265
- const shouldParseAllValues = options.all || key.endsWith("[]");
266
- if (shouldParseAllValues) handleParsingAllValues(form, key, value);
267
- else form[key] = value;
268
- });
269
- if (options.dot) Object.entries(form).forEach(([key, value])=>{
270
- const shouldParseDotValues = key.includes(".");
271
- if (shouldParseDotValues) {
272
- handleParsingNestedValues(form, key, value);
273
- delete form[key];
274
- }
275
- });
276
- return form;
277
- }
278
- var handleParsingAllValues = (form, key, value)=>{
279
- if (void 0 !== form[key]) {
280
- if (Array.isArray(form[key])) form[key].push(value);
281
- else form[key] = [
282
- form[key],
283
- value
284
- ];
285
- } else form[key] = value;
286
- };
287
- var handleParsingNestedValues = (form, key, value)=>{
288
- let nestedForm = form;
289
- const keys = key.split(".");
290
- keys.forEach((key2, index)=>{
291
- if (index === keys.length - 1) nestedForm[key2] = value;
292
- else {
293
- if (!nestedForm[key2] || "object" != typeof nestedForm[key2] || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) nestedForm[key2] = /* @__PURE__ */ Object.create(null);
294
- nestedForm = nestedForm[key2];
295
- }
296
- });
297
- };
298
- var splitPath = (path)=>{
299
- const paths = path.split("/");
300
- if ("" === paths[0]) paths.shift();
301
- return paths;
302
- };
303
- var splitRoutingPath = (routePath)=>{
304
- const { groups, path } = extractGroupsFromPath(routePath);
305
- const paths = splitPath(path);
306
- return replaceGroupMarks(paths, groups);
307
- };
308
- var extractGroupsFromPath = (path)=>{
309
- const groups = [];
310
- path = path.replace(/\{[^}]+\}/g, (match, index)=>{
311
- const mark = `@${index}`;
312
- groups.push([
313
- mark,
314
- match
315
- ]);
316
- return mark;
317
- });
318
- return {
319
- groups,
320
- path
321
- };
322
- };
323
- var replaceGroupMarks = (paths, groups)=>{
324
- for(let i = groups.length - 1; i >= 0; i--){
325
- const [mark] = groups[i];
326
- for(let j = paths.length - 1; j >= 0; j--)if (paths[j].includes(mark)) {
327
- paths[j] = paths[j].replace(mark, groups[i][1]);
328
- break;
329
- }
330
- }
331
- return paths;
332
- };
333
- var patternCache = {};
334
- var getPattern = (label)=>{
335
- if ("*" === label) return "*";
336
- const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
337
- if (match) {
338
- if (!patternCache[label]) {
339
- if (match[2]) patternCache[label] = [
340
- label,
341
- match[1],
342
- new RegExp("^" + match[2] + "$")
343
- ];
344
- else patternCache[label] = [
345
- label,
346
- match[1],
347
- true
348
- ];
349
- }
350
- return patternCache[label];
351
- }
352
- return null;
353
- };
354
- var tryDecodeURI = (str)=>{
355
- try {
356
- return decodeURI(str);
357
- } catch {
358
- return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match)=>{
359
- try {
360
- return decodeURI(match);
361
- } catch {
362
- return match;
1083
+ async function parseFormData(request, options) {
1084
+ const formData = await request.formData();
1085
+ if (formData) return convertFormDataToBodyData(formData, options);
1086
+ return {};
1087
+ }
1088
+ function convertFormDataToBodyData(formData, options) {
1089
+ const form = /* @__PURE__ */ Object.create(null);
1090
+ formData.forEach((value, key)=>{
1091
+ const shouldParseAllValues = options.all || key.endsWith("[]");
1092
+ if (shouldParseAllValues) handleParsingAllValues(form, key, value);
1093
+ else form[key] = value;
1094
+ });
1095
+ if (options.dot) Object.entries(form).forEach(([key, value])=>{
1096
+ const shouldParseDotValues = key.includes(".");
1097
+ if (shouldParseDotValues) {
1098
+ handleParsingNestedValues(form, key, value);
1099
+ delete form[key];
363
1100
  }
364
1101
  });
365
- }
366
- };
367
- var getPath = (request)=>{
368
- const url = request.url;
369
- const start = url.indexOf("/", 8);
370
- let i = start;
371
- for(; i < url.length; i++){
372
- const charCode = url.charCodeAt(i);
373
- if (37 === charCode) {
374
- const queryIndex = url.indexOf("?", i);
375
- const path = url.slice(start, -1 === queryIndex ? void 0 : queryIndex);
376
- return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
377
- }
378
- if (63 === charCode) break;
379
- }
380
- return url.slice(start, i);
381
- };
382
- var getPathNoStrict = (request)=>{
383
- const result = getPath(request);
384
- return result.length > 1 && "/" === result[result.length - 1] ? result.slice(0, -1) : result;
385
- };
386
- var mergePath = (...paths)=>{
387
- let p = "";
388
- let endsWithSlash = false;
389
- for (let path of paths){
390
- if ("/" === p[p.length - 1]) {
391
- p = p.slice(0, -1);
392
- endsWithSlash = true;
393
- }
394
- if ("/" !== path[0]) path = `/${path}`;
395
- if ("/" === path && endsWithSlash) p = `${p}/`;
396
- else if ("/" !== path) p = `${p}${path}`;
397
- if ("/" === path && "" === p) p = "/";
398
- }
399
- return p;
400
- };
401
- var checkOptionalParameter = (path)=>{
402
- if (!path.match(/\:.+\?$/)) return null;
403
- const segments = path.split("/");
404
- const results = [];
405
- let basePath = "";
406
- segments.forEach((segment)=>{
407
- if ("" === segment || /\:/.test(segment)) {
408
- if (/\:/.test(segment)) {
409
- if (/\?/.test(segment)) {
410
- if (0 === results.length && "" === basePath) results.push("/");
411
- else results.push(basePath);
412
- const optionalSegment = segment.replace("?", "");
413
- basePath += "/" + optionalSegment;
414
- results.push(basePath);
415
- } else basePath += "/" + segment;
1102
+ return form;
1103
+ }
1104
+ var handleParsingAllValues = (form, key, value)=>{
1105
+ if (void 0 !== form[key]) {
1106
+ if (Array.isArray(form[key])) form[key].push(value);
1107
+ else form[key] = [
1108
+ form[key],
1109
+ value
1110
+ ];
1111
+ } else form[key] = value;
1112
+ };
1113
+ var handleParsingNestedValues = (form, key, value)=>{
1114
+ let nestedForm = form;
1115
+ const keys = key.split(".");
1116
+ keys.forEach((key2, index)=>{
1117
+ if (index === keys.length - 1) nestedForm[key2] = value;
1118
+ else {
1119
+ if (!nestedForm[key2] || "object" != typeof nestedForm[key2] || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) nestedForm[key2] = /* @__PURE__ */ Object.create(null);
1120
+ nestedForm = nestedForm[key2];
416
1121
  }
417
- } else basePath += "/" + segment;
418
- });
419
- return results.filter((v, i, a)=>a.indexOf(v) === i);
420
- };
421
- var _decodeURI = (value)=>{
422
- if (!/[%+]/.test(value)) return value;
423
- if (-1 !== value.indexOf("+")) value = value.replace(/\+/g, " ");
424
- return /%/.test(value) ? decodeURIComponent_(value) : value;
425
- };
426
- var _getQueryParam = (url, key, multiple)=>{
427
- let encoded;
428
- if (!multiple && key && !/[%+]/.test(key)) {
429
- let keyIndex2 = url.indexOf(`?${key}`, 8);
430
- if (-1 === keyIndex2) keyIndex2 = url.indexOf(`&${key}`, 8);
431
- while(-1 !== keyIndex2){
432
- const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
433
- if (61 === trailingKeyCode) {
434
- const valueIndex = keyIndex2 + key.length + 2;
435
- const endIndex = url.indexOf("&", valueIndex);
436
- return _decodeURI(url.slice(valueIndex, -1 === endIndex ? void 0 : endIndex));
437
- }
438
- if (38 == trailingKeyCode || isNaN(trailingKeyCode)) return "";
439
- keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
440
- }
441
- encoded = /[%+]/.test(url);
442
- if (!encoded) return;
443
- }
444
- const results = {};
445
- encoded ??= /[%+]/.test(url);
446
- let keyIndex = url.indexOf("?", 8);
447
- while(-1 !== keyIndex){
448
- const nextKeyIndex = url.indexOf("&", keyIndex + 1);
449
- let valueIndex = url.indexOf("=", keyIndex);
450
- if (valueIndex > nextKeyIndex && -1 !== nextKeyIndex) valueIndex = -1;
451
- let name = url.slice(keyIndex + 1, -1 === valueIndex ? -1 === nextKeyIndex ? void 0 : nextKeyIndex : valueIndex);
452
- if (encoded) name = _decodeURI(name);
453
- keyIndex = nextKeyIndex;
454
- if ("" === name) continue;
455
- let value;
456
- if (-1 === valueIndex) value = "";
457
- else {
458
- value = url.slice(valueIndex + 1, -1 === nextKeyIndex ? void 0 : nextKeyIndex);
459
- if (encoded) value = _decodeURI(value);
460
- }
461
- if (multiple) {
462
- if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
463
- results[name].push(value);
464
- } else results[name] ??= value;
465
- }
466
- return key ? results[key] : results;
467
- };
468
- var getQueryParam = _getQueryParam;
469
- var getQueryParams = (url, key)=>_getQueryParam(url, key, true);
470
- var decodeURIComponent_ = decodeURIComponent;
471
- var HonoRequest = class {
472
- raw;
473
- #validatedData;
474
- #matchResult;
475
- routeIndex = 0;
476
- path;
477
- bodyCache = {};
478
- constructor(request, path = "/", matchResult = [
479
- []
480
- ]){
481
- this.raw = request;
482
- this.path = path;
483
- this.#matchResult = matchResult;
484
- this.#validatedData = {};
485
- }
486
- param(key) {
487
- return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
488
- }
489
- getDecodedParam(key) {
490
- const paramKey = this.#matchResult[0][this.routeIndex][1][key];
491
- const param = this.getParamValue(paramKey);
492
- return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
493
- }
494
- getAllDecodedParams() {
495
- const decoded = {};
496
- const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
497
- for (const key of keys){
498
- const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
499
- if (value && "string" == typeof value) decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
500
- }
501
- return decoded;
502
- }
503
- getParamValue(paramKey) {
504
- return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
505
- }
506
- query(key) {
507
- return getQueryParam(this.url, key);
508
- }
509
- queries(key) {
510
- return getQueryParams(this.url, key);
511
- }
512
- header(name) {
513
- if (name) return this.raw.headers.get(name.toLowerCase()) ?? void 0;
514
- const headerData = {};
515
- this.raw.headers.forEach((value, key)=>{
516
- headerData[key] = value;
517
1122
  });
518
- return headerData;
519
- }
520
- async parseBody(options) {
521
- return this.bodyCache.parsedBody ??= await parseBody(this, options);
522
- }
523
- cachedBody = (key)=>{
524
- const { bodyCache, raw } = this;
525
- const cachedBody = bodyCache[key];
526
- if (cachedBody) return cachedBody;
527
- const anyCachedKey = Object.keys(bodyCache)[0];
528
- if (anyCachedKey) return bodyCache[anyCachedKey].then((body)=>{
529
- if ("json" === anyCachedKey) body = JSON.stringify(body);
530
- return new Response(body)[key]();
1123
+ };
1124
+ var splitPath = (path)=>{
1125
+ const paths = path.split("/");
1126
+ if ("" === paths[0]) paths.shift();
1127
+ return paths;
1128
+ };
1129
+ var splitRoutingPath = (routePath)=>{
1130
+ const { groups, path } = extractGroupsFromPath(routePath);
1131
+ const paths = splitPath(path);
1132
+ return replaceGroupMarks(paths, groups);
1133
+ };
1134
+ var extractGroupsFromPath = (path)=>{
1135
+ const groups = [];
1136
+ path = path.replace(/\{[^}]+\}/g, (match, index)=>{
1137
+ const mark = `@${index}`;
1138
+ groups.push([
1139
+ mark,
1140
+ match
1141
+ ]);
1142
+ return mark;
531
1143
  });
532
- return bodyCache[key] = raw[key]();
1144
+ return {
1145
+ groups,
1146
+ path
1147
+ };
533
1148
  };
534
- json() {
535
- return this.cachedBody("json");
536
- }
537
- text() {
538
- return this.cachedBody("text");
539
- }
540
- arrayBuffer() {
541
- return this.cachedBody("arrayBuffer");
542
- }
543
- blob() {
544
- return this.cachedBody("blob");
545
- }
546
- formData() {
547
- return this.cachedBody("formData");
548
- }
549
- addValidatedData(target, data) {
550
- this.#validatedData[target] = data;
551
- }
552
- valid(target) {
553
- return this.#validatedData[target];
554
- }
555
- get url() {
556
- return this.raw.url;
557
- }
558
- get method() {
559
- return this.raw.method;
560
- }
561
- get matchedRoutes() {
562
- return this.#matchResult[0].map(([[, route]])=>route);
563
- }
564
- get routePath() {
565
- return this.#matchResult[0].map(([[, route]])=>route)[this.routeIndex].path;
566
- }
567
- };
568
- var HtmlEscapedCallbackPhase = {
569
- Stringify: 1,
570
- BeforeStream: 2,
571
- Stream: 3
572
- };
573
- var html_raw = (value, callbacks)=>{
574
- const escapedString = new String(value);
575
- escapedString.isEscaped = true;
576
- escapedString.callbacks = callbacks;
577
- return escapedString;
578
- };
579
- var resolveCallback = async (str, phase, preserveCallbacks, context, buffer)=>{
580
- if ("object" == typeof str && !(str instanceof String)) {
581
- if (!(str instanceof Promise)) str = str.toString();
582
- if (str instanceof Promise) str = await str;
583
- }
584
- const callbacks = str.callbacks;
585
- if (!callbacks?.length) return Promise.resolve(str);
586
- if (buffer) buffer[0] += str;
587
- else buffer = [
588
- str
589
- ];
590
- const resStr = Promise.all(callbacks.map((c)=>c({
591
- phase,
592
- buffer,
593
- context
594
- }))).then((res)=>Promise.all(res.filter(Boolean).map((str2)=>resolveCallback(str2, phase, false, context, buffer))).then(()=>buffer[0]));
595
- if (preserveCallbacks) return html_raw(await resStr, callbacks);
596
- return resStr;
597
- };
598
- var TEXT_PLAIN = "text/plain; charset=UTF-8";
599
- var setHeaders = (headers, map = {})=>{
600
- Object.entries(map).forEach(([key, value])=>headers.set(key, value));
601
- return headers;
602
- };
603
- var Context = class {
604
- #rawRequest;
605
- #req;
606
- env = {};
607
- #var;
608
- finalized = false;
609
- error;
610
- #status = 200;
611
- #executionCtx;
612
- #headers;
613
- #preparedHeaders;
614
- #res;
615
- #isFresh = true;
616
- #layout;
617
- #renderer;
618
- #notFoundHandler;
619
- #matchResult;
620
- #path;
621
- constructor(req, options){
622
- this.#rawRequest = req;
623
- if (options) {
624
- this.#executionCtx = options.executionCtx;
625
- this.env = options.env;
626
- this.#notFoundHandler = options.notFoundHandler;
627
- this.#path = options.path;
628
- this.#matchResult = options.matchResult;
1149
+ var replaceGroupMarks = (paths, groups)=>{
1150
+ for(let i = groups.length - 1; i >= 0; i--){
1151
+ const [mark] = groups[i];
1152
+ for(let j = paths.length - 1; j >= 0; j--)if (paths[j].includes(mark)) {
1153
+ paths[j] = paths[j].replace(mark, groups[i][1]);
1154
+ break;
1155
+ }
629
1156
  }
630
- }
631
- get req() {
632
- this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
633
- return this.#req;
634
- }
635
- get event() {
636
- if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
637
- throw Error("This context has no FetchEvent");
638
- }
639
- get executionCtx() {
640
- if (this.#executionCtx) return this.#executionCtx;
641
- throw Error("This context has no ExecutionContext");
642
- }
643
- get res() {
644
- this.#isFresh = false;
645
- return this.#res ||= new Response("404 Not Found", {
646
- status: 404
647
- });
648
- }
649
- set res(_res) {
650
- this.#isFresh = false;
651
- if (this.#res && _res) try {
652
- for (const [k, v] of this.#res.headers.entries())if ("content-type" !== k) {
653
- if ("set-cookie" === k) {
654
- const cookies = this.#res.headers.getSetCookie();
655
- _res.headers.delete("set-cookie");
656
- for (const cookie of cookies)_res.headers.append("set-cookie", cookie);
657
- } else _res.headers.set(k, v);
658
- }
659
- } catch (e) {
660
- if (e instanceof TypeError && e.message.includes("immutable")) {
661
- this.res = new Response(_res.body, {
662
- headers: _res.headers,
663
- status: _res.status
664
- });
665
- return;
1157
+ return paths;
1158
+ };
1159
+ var patternCache = {};
1160
+ var getPattern = (label)=>{
1161
+ if ("*" === label) return "*";
1162
+ const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1163
+ if (match) {
1164
+ if (!patternCache[label]) {
1165
+ if (match[2]) patternCache[label] = [
1166
+ label,
1167
+ match[1],
1168
+ new RegExp("^" + match[2] + "$")
1169
+ ];
1170
+ else patternCache[label] = [
1171
+ label,
1172
+ match[1],
1173
+ true
1174
+ ];
666
1175
  }
667
- throw e;
1176
+ return patternCache[label];
668
1177
  }
669
- this.#res = _res;
670
- this.finalized = true;
671
- }
672
- render = (...args)=>{
673
- this.#renderer ??= (content)=>this.html(content);
674
- return this.#renderer(...args);
1178
+ return null;
675
1179
  };
676
- setLayout = (layout)=>this.#layout = layout;
677
- getLayout = ()=>this.#layout;
678
- setRenderer = (renderer)=>{
679
- this.#renderer = renderer;
1180
+ var tryDecodeURI = (str)=>{
1181
+ try {
1182
+ return decodeURI(str);
1183
+ } catch {
1184
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match)=>{
1185
+ try {
1186
+ return decodeURI(match);
1187
+ } catch {
1188
+ return match;
1189
+ }
1190
+ });
1191
+ }
680
1192
  };
681
- header = (name, value, options)=>{
682
- if (void 0 === value) {
683
- if (this.#headers) this.#headers.delete(name);
684
- else if (this.#preparedHeaders) delete this.#preparedHeaders[name.toLocaleLowerCase()];
685
- if (this.finalized) this.res.headers.delete(name);
686
- return;
687
- }
688
- if (options?.append) {
689
- if (!this.#headers) {
690
- this.#isFresh = false;
691
- this.#headers = new Headers(this.#preparedHeaders);
692
- this.#preparedHeaders = {};
1193
+ var getPath = (request)=>{
1194
+ const url = request.url;
1195
+ const start = url.indexOf("/", 8);
1196
+ let i = start;
1197
+ for(; i < url.length; i++){
1198
+ const charCode = url.charCodeAt(i);
1199
+ if (37 === charCode) {
1200
+ const queryIndex = url.indexOf("?", i);
1201
+ const path = url.slice(start, -1 === queryIndex ? void 0 : queryIndex);
1202
+ return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
693
1203
  }
694
- this.#headers.append(name, value);
695
- } else if (this.#headers) this.#headers.set(name, value);
696
- else {
697
- this.#preparedHeaders ??= {};
698
- this.#preparedHeaders[name.toLowerCase()] = value;
699
- }
700
- if (this.finalized) {
701
- if (options?.append) this.res.headers.append(name, value);
702
- else this.res.headers.set(name, value);
1204
+ if (63 === charCode) break;
703
1205
  }
1206
+ return url.slice(start, i);
704
1207
  };
705
- status = (status)=>{
706
- this.#isFresh = false;
707
- this.#status = status;
1208
+ var getPathNoStrict = (request)=>{
1209
+ const result = getPath(request);
1210
+ return result.length > 1 && "/" === result[result.length - 1] ? result.slice(0, -1) : result;
708
1211
  };
709
- set = (key, value)=>{
710
- this.#var ??= /* @__PURE__ */ new Map();
711
- this.#var.set(key, value);
1212
+ var mergePath = (...paths)=>{
1213
+ let p = "";
1214
+ let endsWithSlash = false;
1215
+ for (let path of paths){
1216
+ if ("/" === p[p.length - 1]) {
1217
+ p = p.slice(0, -1);
1218
+ endsWithSlash = true;
1219
+ }
1220
+ if ("/" !== path[0]) path = `/${path}`;
1221
+ if ("/" === path && endsWithSlash) p = `${p}/`;
1222
+ else if ("/" !== path) p = `${p}${path}`;
1223
+ if ("/" === path && "" === p) p = "/";
1224
+ }
1225
+ return p;
712
1226
  };
713
- get = (key)=>this.#var ? this.#var.get(key) : void 0;
714
- get var() {
715
- if (!this.#var) return {};
716
- return Object.fromEntries(this.#var);
717
- }
718
- newResponse = (data, arg, headers)=>{
719
- if (this.#isFresh && !headers && !arg && 200 === this.#status) return new Response(data, {
720
- headers: this.#preparedHeaders
1227
+ var checkOptionalParameter = (path)=>{
1228
+ if (!path.match(/\:.+\?$/)) return null;
1229
+ const segments = path.split("/");
1230
+ const results = [];
1231
+ let basePath = "";
1232
+ segments.forEach((segment)=>{
1233
+ if ("" === segment || /\:/.test(segment)) {
1234
+ if (/\:/.test(segment)) {
1235
+ if (/\?/.test(segment)) {
1236
+ if (0 === results.length && "" === basePath) results.push("/");
1237
+ else results.push(basePath);
1238
+ const optionalSegment = segment.replace("?", "");
1239
+ basePath += "/" + optionalSegment;
1240
+ results.push(basePath);
1241
+ } else basePath += "/" + segment;
1242
+ }
1243
+ } else basePath += "/" + segment;
721
1244
  });
722
- if (arg && "number" != typeof arg) {
723
- const header = new Headers(arg.headers);
724
- if (this.#headers) this.#headers.forEach((v, k)=>{
725
- if ("set-cookie" === k) header.append(k, v);
726
- else header.set(k, v);
727
- });
728
- const headers2 = setHeaders(header, this.#preparedHeaders);
729
- return new Response(data, {
730
- headers: headers2,
731
- status: arg.status ?? this.#status
1245
+ return results.filter((v, i, a)=>a.indexOf(v) === i);
1246
+ };
1247
+ var _decodeURI = (value)=>{
1248
+ if (!/[%+]/.test(value)) return value;
1249
+ if (-1 !== value.indexOf("+")) value = value.replace(/\+/g, " ");
1250
+ return /%/.test(value) ? decodeURIComponent_(value) : value;
1251
+ };
1252
+ var _getQueryParam = (url, key, multiple)=>{
1253
+ let encoded;
1254
+ if (!multiple && key && !/[%+]/.test(key)) {
1255
+ let keyIndex2 = url.indexOf(`?${key}`, 8);
1256
+ if (-1 === keyIndex2) keyIndex2 = url.indexOf(`&${key}`, 8);
1257
+ while(-1 !== keyIndex2){
1258
+ const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
1259
+ if (61 === trailingKeyCode) {
1260
+ const valueIndex = keyIndex2 + key.length + 2;
1261
+ const endIndex = url.indexOf("&", valueIndex);
1262
+ return _decodeURI(url.slice(valueIndex, -1 === endIndex ? void 0 : endIndex));
1263
+ }
1264
+ if (38 == trailingKeyCode || isNaN(trailingKeyCode)) return "";
1265
+ keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
1266
+ }
1267
+ encoded = /[%+]/.test(url);
1268
+ if (!encoded) return;
1269
+ }
1270
+ const results = {};
1271
+ encoded ??= /[%+]/.test(url);
1272
+ let keyIndex = url.indexOf("?", 8);
1273
+ while(-1 !== keyIndex){
1274
+ const nextKeyIndex = url.indexOf("&", keyIndex + 1);
1275
+ let valueIndex = url.indexOf("=", keyIndex);
1276
+ if (valueIndex > nextKeyIndex && -1 !== nextKeyIndex) valueIndex = -1;
1277
+ let name = url.slice(keyIndex + 1, -1 === valueIndex ? -1 === nextKeyIndex ? void 0 : nextKeyIndex : valueIndex);
1278
+ if (encoded) name = _decodeURI(name);
1279
+ keyIndex = nextKeyIndex;
1280
+ if ("" === name) continue;
1281
+ let value;
1282
+ if (-1 === valueIndex) value = "";
1283
+ else {
1284
+ value = url.slice(valueIndex + 1, -1 === nextKeyIndex ? void 0 : nextKeyIndex);
1285
+ if (encoded) value = _decodeURI(value);
1286
+ }
1287
+ if (multiple) {
1288
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
1289
+ results[name].push(value);
1290
+ } else results[name] ??= value;
1291
+ }
1292
+ return key ? results[key] : results;
1293
+ };
1294
+ var getQueryParam = _getQueryParam;
1295
+ var getQueryParams = (url, key)=>_getQueryParam(url, key, true);
1296
+ var decodeURIComponent_ = decodeURIComponent;
1297
+ var HonoRequest = class {
1298
+ raw;
1299
+ #validatedData;
1300
+ #matchResult;
1301
+ routeIndex = 0;
1302
+ path;
1303
+ bodyCache = {};
1304
+ constructor(request, path = "/", matchResult = [
1305
+ []
1306
+ ]){
1307
+ this.raw = request;
1308
+ this.path = path;
1309
+ this.#matchResult = matchResult;
1310
+ this.#validatedData = {};
1311
+ }
1312
+ param(key) {
1313
+ return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
1314
+ }
1315
+ getDecodedParam(key) {
1316
+ const paramKey = this.#matchResult[0][this.routeIndex][1][key];
1317
+ const param = this.getParamValue(paramKey);
1318
+ return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
1319
+ }
1320
+ getAllDecodedParams() {
1321
+ const decoded = {};
1322
+ const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
1323
+ for (const key of keys){
1324
+ const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
1325
+ if (value && "string" == typeof value) decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
1326
+ }
1327
+ return decoded;
1328
+ }
1329
+ getParamValue(paramKey) {
1330
+ return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
1331
+ }
1332
+ query(key) {
1333
+ return getQueryParam(this.url, key);
1334
+ }
1335
+ queries(key) {
1336
+ return getQueryParams(this.url, key);
1337
+ }
1338
+ header(name) {
1339
+ if (name) return this.raw.headers.get(name.toLowerCase()) ?? void 0;
1340
+ const headerData = {};
1341
+ this.raw.headers.forEach((value, key)=>{
1342
+ headerData[key] = value;
732
1343
  });
1344
+ return headerData;
733
1345
  }
734
- const status = "number" == typeof arg ? arg : this.#status;
735
- this.#preparedHeaders ??= {};
736
- this.#headers ??= new Headers();
737
- setHeaders(this.#headers, this.#preparedHeaders);
738
- if (this.#res) {
739
- this.#res.headers.forEach((v, k)=>{
740
- if ("set-cookie" === k) this.#headers?.append(k, v);
741
- else this.#headers?.set(k, v);
1346
+ async parseBody(options) {
1347
+ return this.bodyCache.parsedBody ??= await parseBody(this, options);
1348
+ }
1349
+ cachedBody = (key)=>{
1350
+ const { bodyCache, raw } = this;
1351
+ const cachedBody = bodyCache[key];
1352
+ if (cachedBody) return cachedBody;
1353
+ const anyCachedKey = Object.keys(bodyCache)[0];
1354
+ if (anyCachedKey) return bodyCache[anyCachedKey].then((body)=>{
1355
+ if ("json" === anyCachedKey) body = JSON.stringify(body);
1356
+ return new Response(body)[key]();
742
1357
  });
743
- setHeaders(this.#headers, this.#preparedHeaders);
1358
+ return bodyCache[key] = raw[key]();
1359
+ };
1360
+ json() {
1361
+ return this.cachedBody("json");
744
1362
  }
745
- headers ??= {};
746
- for (const [k, v] of Object.entries(headers))if ("string" == typeof v) this.#headers.set(k, v);
747
- else {
748
- this.#headers.delete(k);
749
- for (const v2 of v)this.#headers.append(k, v2);
1363
+ text() {
1364
+ return this.cachedBody("text");
1365
+ }
1366
+ arrayBuffer() {
1367
+ return this.cachedBody("arrayBuffer");
1368
+ }
1369
+ blob() {
1370
+ return this.cachedBody("blob");
1371
+ }
1372
+ formData() {
1373
+ return this.cachedBody("formData");
1374
+ }
1375
+ addValidatedData(target, data) {
1376
+ this.#validatedData[target] = data;
1377
+ }
1378
+ valid(target) {
1379
+ return this.#validatedData[target];
1380
+ }
1381
+ get url() {
1382
+ return this.raw.url;
1383
+ }
1384
+ get method() {
1385
+ return this.raw.method;
1386
+ }
1387
+ get matchedRoutes() {
1388
+ return this.#matchResult[0].map(([[, route]])=>route);
1389
+ }
1390
+ get routePath() {
1391
+ return this.#matchResult[0].map(([[, route]])=>route)[this.routeIndex].path;
750
1392
  }
751
- return new Response(data, {
752
- status,
753
- headers: this.#headers
754
- });
755
- };
756
- body = (data, arg, headers)=>"number" == typeof arg ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
757
- text = (text, arg, headers)=>{
758
- if (!this.#preparedHeaders) {
759
- if (this.#isFresh && !headers && !arg) return new Response(text);
760
- this.#preparedHeaders = {};
761
- }
762
- this.#preparedHeaders["content-type"] = TEXT_PLAIN;
763
- return "number" == typeof arg ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
764
1393
  };
765
- json = (object, arg, headers)=>{
766
- const body = JSON.stringify(object);
767
- this.#preparedHeaders ??= {};
768
- this.#preparedHeaders["content-type"] = "application/json; charset=UTF-8";
769
- return "number" == typeof arg ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
1394
+ var HtmlEscapedCallbackPhase = {
1395
+ Stringify: 1,
1396
+ BeforeStream: 2,
1397
+ Stream: 3
770
1398
  };
771
- html = (html, arg, headers)=>{
772
- this.#preparedHeaders ??= {};
773
- this.#preparedHeaders["content-type"] = "text/html; charset=UTF-8";
774
- if ("object" == typeof html) return resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then((html2)=>"number" == typeof arg ? this.newResponse(html2, arg, headers) : this.newResponse(html2, arg));
775
- return "number" == typeof arg ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
1399
+ var html_raw = (value, callbacks)=>{
1400
+ const escapedString = new String(value);
1401
+ escapedString.isEscaped = true;
1402
+ escapedString.callbacks = callbacks;
1403
+ return escapedString;
776
1404
  };
777
- redirect = (location, status)=>{
778
- this.#headers ??= new Headers();
779
- this.#headers.set("Location", location);
780
- return this.newResponse(null, status ?? 302);
1405
+ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer)=>{
1406
+ if ("object" == typeof str && !(str instanceof String)) {
1407
+ if (!(str instanceof Promise)) str = str.toString();
1408
+ if (str instanceof Promise) str = await str;
1409
+ }
1410
+ const callbacks = str.callbacks;
1411
+ if (!callbacks?.length) return Promise.resolve(str);
1412
+ if (buffer) buffer[0] += str;
1413
+ else buffer = [
1414
+ str
1415
+ ];
1416
+ const resStr = Promise.all(callbacks.map((c)=>c({
1417
+ phase,
1418
+ buffer,
1419
+ context
1420
+ }))).then((res)=>Promise.all(res.filter(Boolean).map((str2)=>resolveCallback(str2, phase, false, context, buffer))).then(()=>buffer[0]));
1421
+ if (preserveCallbacks) return html_raw(await resStr, callbacks);
1422
+ return resStr;
781
1423
  };
782
- notFound = ()=>{
783
- this.#notFoundHandler ??= ()=>new Response();
784
- return this.#notFoundHandler(this);
1424
+ var TEXT_PLAIN = "text/plain; charset=UTF-8";
1425
+ var setHeaders = (headers, map = {})=>{
1426
+ Object.entries(map).forEach(([key, value])=>headers.set(key, value));
1427
+ return headers;
785
1428
  };
786
- };
787
- var compose = (middleware, onError, onNotFound)=>(context, next)=>{
788
- let index = -1;
789
- return dispatch(0);
790
- async function dispatch(i) {
791
- if (i <= index) throw new Error("next() called multiple times");
792
- index = i;
793
- let res;
794
- let isError = false;
795
- let handler;
796
- if (middleware[i]) {
797
- handler = middleware[i][0][0];
798
- if (context instanceof Context) context.req.routeIndex = i;
799
- } else handler = i === middleware.length && next || void 0;
800
- if (handler) try {
801
- res = await handler(context, ()=>dispatch(i + 1));
802
- } catch (err) {
803
- if (err instanceof Error && context instanceof Context && onError) {
804
- context.error = err;
805
- res = await onError(err, context);
806
- isError = true;
807
- } else throw err;
808
- }
809
- else if (context instanceof Context && false === context.finalized && onNotFound) res = await onNotFound(context);
810
- if (res && (false === context.finalized || isError)) context.res = res;
811
- return context;
1429
+ var Context = class {
1430
+ #rawRequest;
1431
+ #req;
1432
+ env = {};
1433
+ #var;
1434
+ finalized = false;
1435
+ error;
1436
+ #status = 200;
1437
+ #executionCtx;
1438
+ #headers;
1439
+ #preparedHeaders;
1440
+ #res;
1441
+ #isFresh = true;
1442
+ #layout;
1443
+ #renderer;
1444
+ #notFoundHandler;
1445
+ #matchResult;
1446
+ #path;
1447
+ constructor(req, options){
1448
+ this.#rawRequest = req;
1449
+ if (options) {
1450
+ this.#executionCtx = options.executionCtx;
1451
+ this.env = options.env;
1452
+ this.#notFoundHandler = options.notFoundHandler;
1453
+ this.#path = options.path;
1454
+ this.#matchResult = options.matchResult;
1455
+ }
812
1456
  }
813
- };
814
- var METHOD_NAME_ALL = "ALL";
815
- var METHOD_NAME_ALL_LOWERCASE = "all";
816
- var METHODS = [
817
- "get",
818
- "post",
819
- "put",
820
- "delete",
821
- "options",
822
- "patch"
823
- ];
824
- var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
825
- var UnsupportedPathError = class extends Error {
826
- };
827
- var COMPOSED_HANDLER = Symbol("composedHandler");
828
- var notFoundHandler = (c)=>c.text("404 Not Found", 404);
829
- var errorHandler = (err, c)=>{
830
- if ("getResponse" in err) return err.getResponse();
831
- console.error(err);
832
- return c.text("Internal Server Error", 500);
833
- };
834
- var Hono = class {
835
- get;
836
- post;
837
- put;
838
- delete;
839
- options;
840
- patch;
841
- all;
842
- on;
843
- use;
844
- router;
845
- getPath;
846
- _basePath = "/";
847
- #path = "/";
848
- routes = [];
849
- constructor(options = {}){
850
- const allMethods = [
851
- ...METHODS,
852
- METHOD_NAME_ALL_LOWERCASE
853
- ];
854
- allMethods.forEach((method)=>{
855
- this[method] = (args1, ...args)=>{
856
- if ("string" == typeof args1) this.#path = args1;
857
- else this.addRoute(method, this.#path, args1);
858
- args.forEach((handler)=>{
859
- if ("string" != typeof handler) this.addRoute(method, this.#path, handler);
860
- });
861
- return this;
862
- };
863
- });
864
- this.on = (method, path, ...handlers)=>{
865
- for (const p of [
866
- path
867
- ].flat()){
868
- this.#path = p;
869
- for (const m of [
870
- method
871
- ].flat())handlers.map((handler)=>{
872
- this.addRoute(m.toUpperCase(), this.#path, handler);
873
- });
1457
+ get req() {
1458
+ this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
1459
+ return this.#req;
1460
+ }
1461
+ get event() {
1462
+ if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
1463
+ throw Error("This context has no FetchEvent");
1464
+ }
1465
+ get executionCtx() {
1466
+ if (this.#executionCtx) return this.#executionCtx;
1467
+ throw Error("This context has no ExecutionContext");
1468
+ }
1469
+ get res() {
1470
+ this.#isFresh = false;
1471
+ return this.#res ||= new Response("404 Not Found", {
1472
+ status: 404
1473
+ });
1474
+ }
1475
+ set res(_res) {
1476
+ this.#isFresh = false;
1477
+ if (this.#res && _res) try {
1478
+ for (const [k, v] of this.#res.headers.entries())if ("content-type" !== k) {
1479
+ if ("set-cookie" === k) {
1480
+ const cookies = this.#res.headers.getSetCookie();
1481
+ _res.headers.delete("set-cookie");
1482
+ for (const cookie of cookies)_res.headers.append("set-cookie", cookie);
1483
+ } else _res.headers.set(k, v);
1484
+ }
1485
+ } catch (e) {
1486
+ if (e instanceof TypeError && e.message.includes("immutable")) {
1487
+ this.res = new Response(_res.body, {
1488
+ headers: _res.headers,
1489
+ status: _res.status
1490
+ });
1491
+ return;
1492
+ }
1493
+ throw e;
874
1494
  }
875
- return this;
1495
+ this.#res = _res;
1496
+ this.finalized = true;
1497
+ }
1498
+ render = (...args)=>{
1499
+ this.#renderer ??= (content)=>this.html(content);
1500
+ return this.#renderer(...args);
876
1501
  };
877
- this.use = (arg1, ...handlers)=>{
878
- if ("string" == typeof arg1) this.#path = arg1;
879
- else {
880
- this.#path = "*";
881
- handlers.unshift(arg1);
882
- }
883
- handlers.forEach((handler)=>{
884
- this.addRoute(METHOD_NAME_ALL, this.#path, handler);
885
- });
886
- return this;
1502
+ setLayout = (layout)=>this.#layout = layout;
1503
+ getLayout = ()=>this.#layout;
1504
+ setRenderer = (renderer)=>{
1505
+ this.#renderer = renderer;
887
1506
  };
888
- const strict = options.strict ?? true;
889
- delete options.strict;
890
- Object.assign(this, options);
891
- this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
892
- }
893
- clone() {
894
- const clone = new Hono({
895
- router: this.router,
896
- getPath: this.getPath
897
- });
898
- clone.routes = this.routes;
899
- return clone;
900
- }
901
- notFoundHandler = notFoundHandler;
902
- errorHandler = errorHandler;
903
- route(path, app) {
904
- const subApp = this.basePath(path);
905
- app.routes.map((r)=>{
906
- let handler;
907
- if (app.errorHandler === errorHandler) handler = r.handler;
908
- else {
909
- handler = async (c, next)=>(await compose([], app.errorHandler)(c, ()=>r.handler(c, next))).res;
910
- handler[COMPOSED_HANDLER] = r.handler;
1507
+ header = (name, value, options)=>{
1508
+ if (void 0 === value) {
1509
+ if (this.#headers) this.#headers.delete(name);
1510
+ else if (this.#preparedHeaders) delete this.#preparedHeaders[name.toLocaleLowerCase()];
1511
+ if (this.finalized) this.res.headers.delete(name);
1512
+ return;
911
1513
  }
912
- subApp.addRoute(r.method, r.path, handler);
913
- });
914
- return this;
915
- }
916
- basePath(path) {
917
- const subApp = this.clone();
918
- subApp._basePath = mergePath(this._basePath, path);
919
- return subApp;
920
- }
921
- onError = (handler)=>{
922
- this.errorHandler = handler;
923
- return this;
924
- };
925
- notFound = (handler)=>{
926
- this.notFoundHandler = handler;
927
- return this;
928
- };
929
- mount(path, applicationHandler, options) {
930
- let replaceRequest;
931
- let optionHandler;
932
- if (options) {
933
- if ("function" == typeof options) optionHandler = options;
1514
+ if (options?.append) {
1515
+ if (!this.#headers) {
1516
+ this.#isFresh = false;
1517
+ this.#headers = new Headers(this.#preparedHeaders);
1518
+ this.#preparedHeaders = {};
1519
+ }
1520
+ this.#headers.append(name, value);
1521
+ } else if (this.#headers) this.#headers.set(name, value);
934
1522
  else {
935
- optionHandler = options.optionHandler;
936
- replaceRequest = options.replaceRequest;
1523
+ this.#preparedHeaders ??= {};
1524
+ this.#preparedHeaders[name.toLowerCase()] = value;
1525
+ }
1526
+ if (this.finalized) {
1527
+ if (options?.append) this.res.headers.append(name, value);
1528
+ else this.res.headers.set(name, value);
937
1529
  }
938
- }
939
- const getOptions = optionHandler ? (c)=>{
940
- const options2 = optionHandler(c);
941
- return Array.isArray(options2) ? options2 : [
942
- options2
943
- ];
944
- } : (c)=>{
945
- let executionContext;
946
- try {
947
- executionContext = c.executionCtx;
948
- } catch {}
949
- return [
950
- c.env,
951
- executionContext
952
- ];
953
1530
  };
954
- replaceRequest ||= (()=>{
955
- const mergedPath = mergePath(this._basePath, path);
956
- const pathPrefixLength = "/" === mergedPath ? 0 : mergedPath.length;
957
- return (request)=>{
958
- const url = new URL(request.url);
959
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
960
- return new Request(url, request);
961
- };
962
- })();
963
- const handler = async (c, next)=>{
964
- const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
965
- if (res) return res;
966
- await next();
967
- };
968
- this.addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
969
- return this;
970
- }
971
- addRoute(method, path, handler) {
972
- method = method.toUpperCase();
973
- path = mergePath(this._basePath, path);
974
- const r = {
975
- path,
976
- method,
977
- handler
978
- };
979
- this.router.add(method, path, [
980
- handler,
981
- r
982
- ]);
983
- this.routes.push(r);
984
- }
985
- matchRoute(method, path) {
986
- return this.router.match(method, path);
987
- }
988
- handleError(err, c) {
989
- if (err instanceof Error) return this.errorHandler(err, c);
990
- throw err;
991
- }
992
- dispatch(request, executionCtx, env, method) {
993
- if ("HEAD" === method) return (async ()=>new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
994
- const path = this.getPath(request, {
995
- env
996
- });
997
- const matchResult = this.matchRoute(method, path);
998
- const c = new Context(request, {
999
- path,
1000
- matchResult,
1001
- env,
1002
- executionCtx,
1003
- notFoundHandler: this.notFoundHandler
1004
- });
1005
- if (1 === matchResult[0].length) {
1006
- let res;
1007
- try {
1008
- res = matchResult[0][0][0][0](c, async ()=>{
1009
- c.res = await this.notFoundHandler(c);
1531
+ status = (status)=>{
1532
+ this.#isFresh = false;
1533
+ this.#status = status;
1534
+ };
1535
+ set = (key, value)=>{
1536
+ this.#var ??= /* @__PURE__ */ new Map();
1537
+ this.#var.set(key, value);
1538
+ };
1539
+ get = (key)=>this.#var ? this.#var.get(key) : void 0;
1540
+ get var() {
1541
+ if (!this.#var) return {};
1542
+ return Object.fromEntries(this.#var);
1543
+ }
1544
+ newResponse = (data, arg, headers)=>{
1545
+ if (this.#isFresh && !headers && !arg && 200 === this.#status) return new Response(data, {
1546
+ headers: this.#preparedHeaders
1547
+ });
1548
+ if (arg && "number" != typeof arg) {
1549
+ const header = new Headers(arg.headers);
1550
+ if (this.#headers) this.#headers.forEach((v, k)=>{
1551
+ if ("set-cookie" === k) header.append(k, v);
1552
+ else header.set(k, v);
1553
+ });
1554
+ const headers2 = setHeaders(header, this.#preparedHeaders);
1555
+ return new Response(data, {
1556
+ headers: headers2,
1557
+ status: arg.status ?? this.#status
1010
1558
  });
1011
- } catch (err) {
1012
- return this.handleError(err, c);
1013
1559
  }
1014
- return res instanceof Promise ? res.then((resolved)=>resolved || (c.finalized ? c.res : this.notFoundHandler(c))).catch((err)=>this.handleError(err, c)) : res ?? this.notFoundHandler(c);
1015
- }
1016
- const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
1017
- return (async ()=>{
1018
- try {
1019
- const context = await composed(c);
1020
- if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
1021
- return context.res;
1022
- } catch (err) {
1023
- return this.handleError(err, c);
1560
+ const status = "number" == typeof arg ? arg : this.#status;
1561
+ this.#preparedHeaders ??= {};
1562
+ this.#headers ??= new Headers();
1563
+ setHeaders(this.#headers, this.#preparedHeaders);
1564
+ if (this.#res) {
1565
+ this.#res.headers.forEach((v, k)=>{
1566
+ if ("set-cookie" === k) this.#headers?.append(k, v);
1567
+ else this.#headers?.set(k, v);
1568
+ });
1569
+ setHeaders(this.#headers, this.#preparedHeaders);
1024
1570
  }
1025
- })();
1026
- }
1027
- fetch = (request, ...rest)=>this.dispatch(request, rest[1], rest[0], request.method);
1028
- request = (input, requestInit, Env, executionCtx)=>{
1029
- if (input instanceof Request) {
1030
- if (void 0 !== requestInit) input = new Request(input, requestInit);
1031
- return this.fetch(input, Env, executionCtx);
1032
- }
1033
- input = input.toString();
1034
- const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`;
1035
- const req = new Request(path, requestInit);
1036
- return this.fetch(req, Env, executionCtx);
1037
- };
1038
- fire = ()=>{
1039
- addEventListener("fetch", (event)=>{
1040
- event.respondWith(this.dispatch(event.request, event, void 0, event.request.method));
1041
- });
1042
- };
1043
- };
1044
- var LABEL_REG_EXP_STR = "[^/]+";
1045
- var ONLY_WILDCARD_REG_EXP_STR = ".*";
1046
- var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1047
- var PATH_ERROR = Symbol();
1048
- var regExpMetaChars = new Set(".\\+*[^]$()");
1049
- function compareKey(a, b) {
1050
- if (1 === a.length) return 1 === b.length ? a < b ? -1 : 1 : -1;
1051
- if (1 === b.length) return 1;
1052
- if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) return 1;
1053
- if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) return -1;
1054
- if (a === LABEL_REG_EXP_STR) return 1;
1055
- if (b === LABEL_REG_EXP_STR) return -1;
1056
- return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
1057
- }
1058
- var Node = class {
1059
- index;
1060
- varIndex;
1061
- children = /* @__PURE__ */ Object.create(null);
1062
- insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
1063
- if (0 === tokens.length) {
1064
- if (void 0 !== this.index) throw PATH_ERROR;
1065
- if (pathErrorCheckOnly) return;
1066
- this.index = index;
1067
- return;
1068
- }
1069
- const [token, ...restTokens] = tokens;
1070
- const pattern = "*" === token ? 0 === restTokens.length ? [
1071
- "",
1072
- "",
1073
- ONLY_WILDCARD_REG_EXP_STR
1074
- ] : [
1075
- "",
1076
- "",
1077
- LABEL_REG_EXP_STR
1078
- ] : "/*" === token ? [
1079
- "",
1080
- "",
1081
- TAIL_WILDCARD_REG_EXP_STR
1082
- ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1083
- let node;
1084
- if (pattern) {
1085
- const name = pattern[1];
1086
- let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
1087
- if (name && pattern[2]) {
1088
- regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1089
- if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1090
- }
1091
- node = this.children[regexpStr];
1092
- if (!node) {
1093
- if (Object.keys(this.children).some((k)=>k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1094
- if (pathErrorCheckOnly) return;
1095
- node = this.children[regexpStr] = new Node();
1096
- if ("" !== name) node.varIndex = context.varIndex++;
1571
+ headers ??= {};
1572
+ for (const [k, v] of Object.entries(headers))if ("string" == typeof v) this.#headers.set(k, v);
1573
+ else {
1574
+ this.#headers.delete(k);
1575
+ for (const v2 of v)this.#headers.append(k, v2);
1097
1576
  }
1098
- if (!pathErrorCheckOnly && "" !== name) paramMap.push([
1099
- name,
1100
- node.varIndex
1101
- ]);
1102
- } else {
1103
- node = this.children[token];
1104
- if (!node) {
1105
- if (Object.keys(this.children).some((k)=>k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1106
- if (pathErrorCheckOnly) return;
1107
- node = this.children[token] = new Node();
1577
+ return new Response(data, {
1578
+ status,
1579
+ headers: this.#headers
1580
+ });
1581
+ };
1582
+ body = (data, arg, headers)=>"number" == typeof arg ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
1583
+ text = (text, arg, headers)=>{
1584
+ if (!this.#preparedHeaders) {
1585
+ if (this.#isFresh && !headers && !arg) return new Response(text);
1586
+ this.#preparedHeaders = {};
1108
1587
  }
1109
- }
1110
- node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
1111
- }
1112
- buildRegExpStr() {
1113
- const childKeys = Object.keys(this.children).sort(compareKey);
1114
- const strList = childKeys.map((k)=>{
1115
- const c = this.children[k];
1116
- return ("number" == typeof c.varIndex ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
1117
- });
1118
- if ("number" == typeof this.index) strList.unshift(`#${this.index}`);
1119
- if (0 === strList.length) return "";
1120
- if (1 === strList.length) return strList[0];
1121
- return "(?:" + strList.join("|") + ")";
1122
- }
1123
- };
1124
- var Trie = class {
1125
- context = {
1126
- varIndex: 0
1588
+ this.#preparedHeaders["content-type"] = TEXT_PLAIN;
1589
+ return "number" == typeof arg ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
1590
+ };
1591
+ json = (object, arg, headers)=>{
1592
+ const body = JSON.stringify(object);
1593
+ this.#preparedHeaders ??= {};
1594
+ this.#preparedHeaders["content-type"] = "application/json; charset=UTF-8";
1595
+ return "number" == typeof arg ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
1596
+ };
1597
+ html = (html, arg, headers)=>{
1598
+ this.#preparedHeaders ??= {};
1599
+ this.#preparedHeaders["content-type"] = "text/html; charset=UTF-8";
1600
+ if ("object" == typeof html) return resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then((html2)=>"number" == typeof arg ? this.newResponse(html2, arg, headers) : this.newResponse(html2, arg));
1601
+ return "number" == typeof arg ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
1602
+ };
1603
+ redirect = (location, status)=>{
1604
+ this.#headers ??= new Headers();
1605
+ this.#headers.set("Location", location);
1606
+ return this.newResponse(null, status ?? 302);
1607
+ };
1608
+ notFound = ()=>{
1609
+ this.#notFoundHandler ??= ()=>new Response();
1610
+ return this.#notFoundHandler(this);
1611
+ };
1127
1612
  };
1128
- root = new Node();
1129
- insert(path, index, pathErrorCheckOnly) {
1130
- const paramAssoc = [];
1131
- const groups = [];
1132
- for(let i = 0;;){
1133
- let replaced = false;
1134
- path = path.replace(/\{[^}]+\}/g, (m)=>{
1135
- const mark = `@\\${i}`;
1136
- groups[i] = [
1137
- mark,
1138
- m
1139
- ];
1140
- i++;
1141
- replaced = true;
1142
- return mark;
1143
- });
1144
- if (!replaced) break;
1145
- }
1146
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1147
- for(let i = groups.length - 1; i >= 0; i--){
1148
- const [mark] = groups[i];
1149
- for(let j = tokens.length - 1; j >= 0; j--)if (-1 !== tokens[j].indexOf(mark)) {
1150
- tokens[j] = tokens[j].replace(mark, groups[i][1]);
1151
- break;
1613
+ var compose = (middleware, onError, onNotFound)=>(context, next)=>{
1614
+ let index = -1;
1615
+ return dispatch(0);
1616
+ async function dispatch(i) {
1617
+ if (i <= index) throw new Error("next() called multiple times");
1618
+ index = i;
1619
+ let res;
1620
+ let isError = false;
1621
+ let handler;
1622
+ if (middleware[i]) {
1623
+ handler = middleware[i][0][0];
1624
+ if (context instanceof Context) context.req.routeIndex = i;
1625
+ } else handler = i === middleware.length && next || void 0;
1626
+ if (handler) try {
1627
+ res = await handler(context, ()=>dispatch(i + 1));
1628
+ } catch (err) {
1629
+ if (err instanceof Error && context instanceof Context && onError) {
1630
+ context.error = err;
1631
+ res = await onError(err, context);
1632
+ isError = true;
1633
+ } else throw err;
1634
+ }
1635
+ else if (context instanceof Context && false === context.finalized && onNotFound) res = await onNotFound(context);
1636
+ if (res && (false === context.finalized || isError)) context.res = res;
1637
+ return context;
1152
1638
  }
1639
+ };
1640
+ var METHOD_NAME_ALL = "ALL";
1641
+ var METHOD_NAME_ALL_LOWERCASE = "all";
1642
+ var METHODS = [
1643
+ "get",
1644
+ "post",
1645
+ "put",
1646
+ "delete",
1647
+ "options",
1648
+ "patch"
1649
+ ];
1650
+ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
1651
+ var UnsupportedPathError = class extends Error {
1652
+ };
1653
+ var COMPOSED_HANDLER = Symbol("composedHandler");
1654
+ var notFoundHandler = (c)=>c.text("404 Not Found", 404);
1655
+ var errorHandler = (err, c)=>{
1656
+ if ("getResponse" in err) return err.getResponse();
1657
+ console.error(err);
1658
+ return c.text("Internal Server Error", 500);
1659
+ };
1660
+ var Hono = class {
1661
+ get;
1662
+ post;
1663
+ put;
1664
+ delete;
1665
+ options;
1666
+ patch;
1667
+ all;
1668
+ on;
1669
+ use;
1670
+ router;
1671
+ getPath;
1672
+ _basePath = "/";
1673
+ #path = "/";
1674
+ routes = [];
1675
+ constructor(options = {}){
1676
+ const allMethods = [
1677
+ ...METHODS,
1678
+ METHOD_NAME_ALL_LOWERCASE
1679
+ ];
1680
+ allMethods.forEach((method)=>{
1681
+ this[method] = (args1, ...args)=>{
1682
+ if ("string" == typeof args1) this.#path = args1;
1683
+ else this.addRoute(method, this.#path, args1);
1684
+ args.forEach((handler)=>{
1685
+ if ("string" != typeof handler) this.addRoute(method, this.#path, handler);
1686
+ });
1687
+ return this;
1688
+ };
1689
+ });
1690
+ this.on = (method, path, ...handlers)=>{
1691
+ for (const p of [
1692
+ path
1693
+ ].flat()){
1694
+ this.#path = p;
1695
+ for (const m of [
1696
+ method
1697
+ ].flat())handlers.map((handler)=>{
1698
+ this.addRoute(m.toUpperCase(), this.#path, handler);
1699
+ });
1700
+ }
1701
+ return this;
1702
+ };
1703
+ this.use = (arg1, ...handlers)=>{
1704
+ if ("string" == typeof arg1) this.#path = arg1;
1705
+ else {
1706
+ this.#path = "*";
1707
+ handlers.unshift(arg1);
1708
+ }
1709
+ handlers.forEach((handler)=>{
1710
+ this.addRoute(METHOD_NAME_ALL, this.#path, handler);
1711
+ });
1712
+ return this;
1713
+ };
1714
+ const strict = options.strict ?? true;
1715
+ delete options.strict;
1716
+ Object.assign(this, options);
1717
+ this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
1153
1718
  }
1154
- this.root.insert(tokens, index, paramAssoc, this.context, pathErrorCheckOnly);
1155
- return paramAssoc;
1156
- }
1157
- buildRegExp() {
1158
- let regexp = this.root.buildRegExpStr();
1159
- if ("" === regexp) return [
1160
- /^$/,
1161
- [],
1162
- []
1163
- ];
1164
- let captureIndex = 0;
1165
- const indexReplacementMap = [];
1166
- const paramReplacementMap = [];
1167
- regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex)=>{
1168
- if (void 0 !== handlerIndex) {
1169
- indexReplacementMap[++captureIndex] = Number(handlerIndex);
1170
- return "$()";
1171
- }
1172
- if (void 0 !== paramIndex) paramReplacementMap[Number(paramIndex)] = ++captureIndex;
1173
- return "";
1174
- });
1175
- return [
1176
- new RegExp(`^${regexp}`),
1177
- indexReplacementMap,
1178
- paramReplacementMap
1179
- ];
1180
- }
1181
- };
1182
- var emptyParam = [];
1183
- var nullMatcher = [
1184
- /^$/,
1185
- [],
1186
- /* @__PURE__ */ Object.create(null)
1187
- ];
1188
- var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1189
- function buildWildcardRegExp(path) {
1190
- return wildcardRegExpCache[path] ??= new RegExp("*" === path ? "" : `^${path.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar)=>metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
1191
- }
1192
- function clearWildcardRegExpCache() {
1193
- wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1194
- }
1195
- function buildMatcherFromPreprocessedRoutes(routes) {
1196
- const trie = new Trie();
1197
- const handlerData = [];
1198
- if (0 === routes.length) return nullMatcher;
1199
- const routesWithStaticPathFlag = routes.map((route)=>[
1200
- !/\*|\/:/.test(route[0]),
1201
- ...route
1202
- ]).sort(([isStaticA, pathA], [isStaticB, pathB])=>isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
1203
- const staticMap = /* @__PURE__ */ Object.create(null);
1204
- for(let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++){
1205
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
1206
- if (pathErrorCheckOnly) staticMap[path] = [
1207
- handlers.map(([h])=>[
1208
- h,
1209
- /* @__PURE__ */ Object.create(null)
1210
- ]),
1211
- emptyParam
1212
- ];
1213
- else j++;
1214
- let paramAssoc;
1215
- try {
1216
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
1217
- } catch (e) {
1218
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
1219
- }
1220
- if (!pathErrorCheckOnly) handlerData[j] = handlers.map(([h, paramCount])=>{
1221
- const paramIndexMap = /* @__PURE__ */ Object.create(null);
1222
- paramCount -= 1;
1223
- for(; paramCount >= 0; paramCount--){
1224
- const [key, value] = paramAssoc[paramCount];
1225
- paramIndexMap[key] = value;
1226
- }
1227
- return [
1228
- h,
1229
- paramIndexMap
1230
- ];
1231
- });
1232
- }
1233
- const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1234
- for(let i = 0, len = handlerData.length; i < len; i++)for(let j = 0, len2 = handlerData[i].length; j < len2; j++){
1235
- const map = handlerData[i][j]?.[1];
1236
- if (!map) continue;
1237
- const keys = Object.keys(map);
1238
- for(let k = 0, len3 = keys.length; k < len3; k++)map[keys[k]] = paramReplacementMap[map[keys[k]]];
1239
- }
1240
- const handlerMap = [];
1241
- for(const i in indexReplacementMap)handlerMap[i] = handlerData[indexReplacementMap[i]];
1242
- return [
1243
- regexp,
1244
- handlerMap,
1245
- staticMap
1246
- ];
1247
- }
1248
- function findMiddleware(middleware, path) {
1249
- if (!middleware) return;
1250
- for (const k of Object.keys(middleware).sort((a, b)=>b.length - a.length))if (buildWildcardRegExp(k).test(path)) return [
1251
- ...middleware[k]
1252
- ];
1253
- }
1254
- var RegExpRouter = class {
1255
- name = "RegExpRouter";
1256
- middleware;
1257
- routes;
1258
- constructor(){
1259
- this.middleware = {
1260
- [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
1719
+ clone() {
1720
+ const clone = new Hono({
1721
+ router: this.router,
1722
+ getPath: this.getPath
1723
+ });
1724
+ clone.routes = this.routes;
1725
+ return clone;
1726
+ }
1727
+ notFoundHandler = notFoundHandler;
1728
+ errorHandler = errorHandler;
1729
+ route(path, app) {
1730
+ const subApp = this.basePath(path);
1731
+ app.routes.map((r)=>{
1732
+ let handler;
1733
+ if (app.errorHandler === errorHandler) handler = r.handler;
1734
+ else {
1735
+ handler = async (c, next)=>(await compose([], app.errorHandler)(c, ()=>r.handler(c, next))).res;
1736
+ handler[COMPOSED_HANDLER] = r.handler;
1737
+ }
1738
+ subApp.addRoute(r.method, r.path, handler);
1739
+ });
1740
+ return this;
1741
+ }
1742
+ basePath(path) {
1743
+ const subApp = this.clone();
1744
+ subApp._basePath = mergePath(this._basePath, path);
1745
+ return subApp;
1746
+ }
1747
+ onError = (handler)=>{
1748
+ this.errorHandler = handler;
1749
+ return this;
1261
1750
  };
1262
- this.routes = {
1263
- [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
1751
+ notFound = (handler)=>{
1752
+ this.notFoundHandler = handler;
1753
+ return this;
1264
1754
  };
1265
- }
1266
- add(method, path, handler) {
1267
- const { middleware, routes } = this;
1268
- if (!middleware || !routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1269
- if (!middleware[method]) [
1270
- middleware,
1271
- routes
1272
- ].forEach((handlerMap)=>{
1273
- handlerMap[method] = /* @__PURE__ */ Object.create(null);
1274
- Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p)=>{
1275
- handlerMap[method][p] = [
1276
- ...handlerMap[METHOD_NAME_ALL][p]
1755
+ mount(path, applicationHandler, options) {
1756
+ let replaceRequest;
1757
+ let optionHandler;
1758
+ if (options) {
1759
+ if ("function" == typeof options) optionHandler = options;
1760
+ else {
1761
+ optionHandler = options.optionHandler;
1762
+ replaceRequest = options.replaceRequest;
1763
+ }
1764
+ }
1765
+ const getOptions = optionHandler ? (c)=>{
1766
+ const options2 = optionHandler(c);
1767
+ return Array.isArray(options2) ? options2 : [
1768
+ options2
1769
+ ];
1770
+ } : (c)=>{
1771
+ let executionContext;
1772
+ try {
1773
+ executionContext = c.executionCtx;
1774
+ } catch {}
1775
+ return [
1776
+ c.env,
1777
+ executionContext
1277
1778
  ];
1779
+ };
1780
+ replaceRequest ||= (()=>{
1781
+ const mergedPath = mergePath(this._basePath, path);
1782
+ const pathPrefixLength = "/" === mergedPath ? 0 : mergedPath.length;
1783
+ return (request)=>{
1784
+ const url = new URL(request.url);
1785
+ url.pathname = url.pathname.slice(pathPrefixLength) || "/";
1786
+ return new Request(url, request);
1787
+ };
1788
+ })();
1789
+ const handler = async (c, next)=>{
1790
+ const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
1791
+ if (res) return res;
1792
+ await next();
1793
+ };
1794
+ this.addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
1795
+ return this;
1796
+ }
1797
+ addRoute(method, path, handler) {
1798
+ method = method.toUpperCase();
1799
+ path = mergePath(this._basePath, path);
1800
+ const r = {
1801
+ path,
1802
+ method,
1803
+ handler
1804
+ };
1805
+ this.router.add(method, path, [
1806
+ handler,
1807
+ r
1808
+ ]);
1809
+ this.routes.push(r);
1810
+ }
1811
+ matchRoute(method, path) {
1812
+ return this.router.match(method, path);
1813
+ }
1814
+ handleError(err, c) {
1815
+ if (err instanceof Error) return this.errorHandler(err, c);
1816
+ throw err;
1817
+ }
1818
+ dispatch(request, executionCtx, env, method) {
1819
+ if ("HEAD" === method) return (async ()=>new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
1820
+ const path = this.getPath(request, {
1821
+ env
1278
1822
  });
1279
- });
1280
- if ("/*" === path) path = "*";
1281
- const paramCount = (path.match(/\/:/g) || []).length;
1282
- if (/\*$/.test(path)) {
1283
- const re = buildWildcardRegExp(path);
1284
- if (method === METHOD_NAME_ALL) Object.keys(middleware).forEach((m)=>{
1285
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
1823
+ const matchResult = this.matchRoute(method, path);
1824
+ const c = new Context(request, {
1825
+ path,
1826
+ matchResult,
1827
+ env,
1828
+ executionCtx,
1829
+ notFoundHandler: this.notFoundHandler
1286
1830
  });
1287
- else middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
1288
- Object.keys(middleware).forEach((m)=>{
1289
- if (method === METHOD_NAME_ALL || method === m) Object.keys(middleware[m]).forEach((p)=>{
1290
- re.test(p) && middleware[m][p].push([
1291
- handler,
1292
- paramCount
1293
- ]);
1294
- });
1831
+ if (1 === matchResult[0].length) {
1832
+ let res;
1833
+ try {
1834
+ res = matchResult[0][0][0][0](c, async ()=>{
1835
+ c.res = await this.notFoundHandler(c);
1836
+ });
1837
+ } catch (err) {
1838
+ return this.handleError(err, c);
1839
+ }
1840
+ return res instanceof Promise ? res.then((resolved)=>resolved || (c.finalized ? c.res : this.notFoundHandler(c))).catch((err)=>this.handleError(err, c)) : res ?? this.notFoundHandler(c);
1841
+ }
1842
+ const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
1843
+ return (async ()=>{
1844
+ try {
1845
+ const context = await composed(c);
1846
+ if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
1847
+ return context.res;
1848
+ } catch (err) {
1849
+ return this.handleError(err, c);
1850
+ }
1851
+ })();
1852
+ }
1853
+ fetch = (request, ...rest)=>this.dispatch(request, rest[1], rest[0], request.method);
1854
+ request = (input, requestInit, Env, executionCtx)=>{
1855
+ if (input instanceof Request) {
1856
+ if (void 0 !== requestInit) input = new Request(input, requestInit);
1857
+ return this.fetch(input, Env, executionCtx);
1858
+ }
1859
+ input = input.toString();
1860
+ const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`;
1861
+ const req = new Request(path, requestInit);
1862
+ return this.fetch(req, Env, executionCtx);
1863
+ };
1864
+ fire = ()=>{
1865
+ addEventListener("fetch", (event)=>{
1866
+ event.respondWith(this.dispatch(event.request, event, void 0, event.request.method));
1295
1867
  });
1296
- Object.keys(routes).forEach((m)=>{
1297
- if (method === METHOD_NAME_ALL || method === m) Object.keys(routes[m]).forEach((p)=>re.test(p) && routes[m][p].push([
1298
- handler,
1299
- paramCount
1300
- ]));
1868
+ };
1869
+ };
1870
+ var LABEL_REG_EXP_STR = "[^/]+";
1871
+ var ONLY_WILDCARD_REG_EXP_STR = ".*";
1872
+ var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1873
+ var PATH_ERROR = Symbol();
1874
+ var regExpMetaChars = new Set(".\\+*[^]$()");
1875
+ function compareKey(a, b) {
1876
+ if (1 === a.length) return 1 === b.length ? a < b ? -1 : 1 : -1;
1877
+ if (1 === b.length) return 1;
1878
+ if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) return 1;
1879
+ if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) return -1;
1880
+ if (a === LABEL_REG_EXP_STR) return 1;
1881
+ if (b === LABEL_REG_EXP_STR) return -1;
1882
+ return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
1883
+ }
1884
+ var Node = class {
1885
+ index;
1886
+ varIndex;
1887
+ children = /* @__PURE__ */ Object.create(null);
1888
+ insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
1889
+ if (0 === tokens.length) {
1890
+ if (void 0 !== this.index) throw PATH_ERROR;
1891
+ if (pathErrorCheckOnly) return;
1892
+ this.index = index;
1893
+ return;
1894
+ }
1895
+ const [token, ...restTokens] = tokens;
1896
+ const pattern = "*" === token ? 0 === restTokens.length ? [
1897
+ "",
1898
+ "",
1899
+ ONLY_WILDCARD_REG_EXP_STR
1900
+ ] : [
1901
+ "",
1902
+ "",
1903
+ LABEL_REG_EXP_STR
1904
+ ] : "/*" === token ? [
1905
+ "",
1906
+ "",
1907
+ TAIL_WILDCARD_REG_EXP_STR
1908
+ ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1909
+ let node;
1910
+ if (pattern) {
1911
+ const name = pattern[1];
1912
+ let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
1913
+ if (name && pattern[2]) {
1914
+ regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1915
+ if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1916
+ }
1917
+ node = this.children[regexpStr];
1918
+ if (!node) {
1919
+ if (Object.keys(this.children).some((k)=>k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1920
+ if (pathErrorCheckOnly) return;
1921
+ node = this.children[regexpStr] = new Node();
1922
+ if ("" !== name) node.varIndex = context.varIndex++;
1923
+ }
1924
+ if (!pathErrorCheckOnly && "" !== name) paramMap.push([
1925
+ name,
1926
+ node.varIndex
1927
+ ]);
1928
+ } else {
1929
+ node = this.children[token];
1930
+ if (!node) {
1931
+ if (Object.keys(this.children).some((k)=>k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1932
+ if (pathErrorCheckOnly) return;
1933
+ node = this.children[token] = new Node();
1934
+ }
1935
+ }
1936
+ node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
1937
+ }
1938
+ buildRegExpStr() {
1939
+ const childKeys = Object.keys(this.children).sort(compareKey);
1940
+ const strList = childKeys.map((k)=>{
1941
+ const c = this.children[k];
1942
+ return ("number" == typeof c.varIndex ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
1301
1943
  });
1302
- return;
1944
+ if ("number" == typeof this.index) strList.unshift(`#${this.index}`);
1945
+ if (0 === strList.length) return "";
1946
+ if (1 === strList.length) return strList[0];
1947
+ return "(?:" + strList.join("|") + ")";
1303
1948
  }
1304
- const paths = checkOptionalParameter(path) || [
1305
- path
1306
- ];
1307
- for(let i = 0, len = paths.length; i < len; i++){
1308
- const path2 = paths[i];
1309
- Object.keys(routes).forEach((m)=>{
1310
- if (method === METHOD_NAME_ALL || method === m) {
1311
- routes[m][path2] ||= [
1312
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
1949
+ };
1950
+ var Trie = class {
1951
+ context = {
1952
+ varIndex: 0
1953
+ };
1954
+ root = new Node();
1955
+ insert(path, index, pathErrorCheckOnly) {
1956
+ const paramAssoc = [];
1957
+ const groups = [];
1958
+ for(let i = 0;;){
1959
+ let replaced = false;
1960
+ path = path.replace(/\{[^}]+\}/g, (m)=>{
1961
+ const mark = `@\\${i}`;
1962
+ groups[i] = [
1963
+ mark,
1964
+ m
1313
1965
  ];
1314
- routes[m][path2].push([
1315
- handler,
1316
- paramCount - len + i + 1
1317
- ]);
1966
+ i++;
1967
+ replaced = true;
1968
+ return mark;
1969
+ });
1970
+ if (!replaced) break;
1971
+ }
1972
+ const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1973
+ for(let i = groups.length - 1; i >= 0; i--){
1974
+ const [mark] = groups[i];
1975
+ for(let j = tokens.length - 1; j >= 0; j--)if (-1 !== tokens[j].indexOf(mark)) {
1976
+ tokens[j] = tokens[j].replace(mark, groups[i][1]);
1977
+ break;
1318
1978
  }
1319
- });
1979
+ }
1980
+ this.root.insert(tokens, index, paramAssoc, this.context, pathErrorCheckOnly);
1981
+ return paramAssoc;
1320
1982
  }
1321
- }
1322
- match(method, path) {
1323
- clearWildcardRegExpCache();
1324
- const matchers = this.buildAllMatchers();
1325
- this.match = (method2, path2)=>{
1326
- const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
1327
- const staticMatch = matcher[2][path2];
1328
- if (staticMatch) return staticMatch;
1329
- const match = path2.match(matcher[0]);
1330
- if (!match) return [
1983
+ buildRegExp() {
1984
+ let regexp = this.root.buildRegExpStr();
1985
+ if ("" === regexp) return [
1986
+ /^$/,
1331
1987
  [],
1332
- emptyParam
1988
+ []
1333
1989
  ];
1334
- const index = match.indexOf("", 1);
1990
+ let captureIndex = 0;
1991
+ const indexReplacementMap = [];
1992
+ const paramReplacementMap = [];
1993
+ regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex)=>{
1994
+ if (void 0 !== handlerIndex) {
1995
+ indexReplacementMap[++captureIndex] = Number(handlerIndex);
1996
+ return "$()";
1997
+ }
1998
+ if (void 0 !== paramIndex) paramReplacementMap[Number(paramIndex)] = ++captureIndex;
1999
+ return "";
2000
+ });
1335
2001
  return [
1336
- matcher[1][index],
1337
- match
2002
+ new RegExp(`^${regexp}`),
2003
+ indexReplacementMap,
2004
+ paramReplacementMap
1338
2005
  ];
1339
- };
1340
- return this.match(method, path);
1341
- }
1342
- buildAllMatchers() {
1343
- const matchers = /* @__PURE__ */ Object.create(null);
1344
- [
1345
- ...Object.keys(this.routes),
1346
- ...Object.keys(this.middleware)
1347
- ].forEach((method)=>{
1348
- matchers[method] ||= this.buildMatcher(method);
1349
- });
1350
- this.middleware = this.routes = void 0;
1351
- return matchers;
1352
- }
1353
- buildMatcher(method) {
1354
- const routes = [];
1355
- let hasOwnRoute = method === METHOD_NAME_ALL;
1356
- [
1357
- this.middleware,
1358
- this.routes
1359
- ].forEach((r)=>{
1360
- const ownRoute = r[method] ? Object.keys(r[method]).map((path)=>[
1361
- path,
1362
- r[method][path]
1363
- ]) : [];
1364
- if (0 !== ownRoute.length) {
1365
- hasOwnRoute ||= true;
1366
- routes.push(...ownRoute);
1367
- } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path)=>[
1368
- path,
1369
- r[METHOD_NAME_ALL][path]
1370
- ]));
1371
- });
1372
- if (!hasOwnRoute) return null;
1373
- return buildMatcherFromPreprocessedRoutes(routes);
1374
- }
1375
- };
1376
- var SmartRouter = class {
1377
- name = "SmartRouter";
1378
- routers = [];
1379
- routes = [];
1380
- constructor(init){
1381
- Object.assign(this, init);
1382
- }
1383
- add(method, path, handler) {
1384
- if (!this.routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1385
- this.routes.push([
1386
- method,
1387
- path,
1388
- handler
1389
- ]);
1390
- }
1391
- match(method, path) {
1392
- if (!this.routes) throw new Error("Fatal error");
1393
- const { routers, routes } = this;
1394
- const len = routers.length;
1395
- let i = 0;
1396
- let res;
1397
- for(; i < len; i++){
1398
- const router = routers[i];
2006
+ }
2007
+ };
2008
+ var emptyParam = [];
2009
+ var nullMatcher = [
2010
+ /^$/,
2011
+ [],
2012
+ /* @__PURE__ */ Object.create(null)
2013
+ ];
2014
+ var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
2015
+ function buildWildcardRegExp(path) {
2016
+ return wildcardRegExpCache[path] ??= new RegExp("*" === path ? "" : `^${path.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar)=>metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
2017
+ }
2018
+ function clearWildcardRegExpCache() {
2019
+ wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
2020
+ }
2021
+ function buildMatcherFromPreprocessedRoutes(routes) {
2022
+ const trie = new Trie();
2023
+ const handlerData = [];
2024
+ if (0 === routes.length) return nullMatcher;
2025
+ const routesWithStaticPathFlag = routes.map((route)=>[
2026
+ !/\*|\/:/.test(route[0]),
2027
+ ...route
2028
+ ]).sort(([isStaticA, pathA], [isStaticB, pathB])=>isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
2029
+ const staticMap = /* @__PURE__ */ Object.create(null);
2030
+ for(let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++){
2031
+ const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
2032
+ if (pathErrorCheckOnly) staticMap[path] = [
2033
+ handlers.map(([h])=>[
2034
+ h,
2035
+ /* @__PURE__ */ Object.create(null)
2036
+ ]),
2037
+ emptyParam
2038
+ ];
2039
+ else j++;
2040
+ let paramAssoc;
1399
2041
  try {
1400
- routes.forEach((args)=>{
1401
- router.add(...args);
1402
- });
1403
- res = router.match(method, path);
2042
+ paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
1404
2043
  } catch (e) {
1405
- if (e instanceof UnsupportedPathError) continue;
1406
- throw e;
2044
+ throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
1407
2045
  }
1408
- this.match = router.match.bind(router);
1409
- this.routers = [
1410
- router
1411
- ];
1412
- this.routes = void 0;
1413
- break;
2046
+ if (!pathErrorCheckOnly) handlerData[j] = handlers.map(([h, paramCount])=>{
2047
+ const paramIndexMap = /* @__PURE__ */ Object.create(null);
2048
+ paramCount -= 1;
2049
+ for(; paramCount >= 0; paramCount--){
2050
+ const [key, value] = paramAssoc[paramCount];
2051
+ paramIndexMap[key] = value;
2052
+ }
2053
+ return [
2054
+ h,
2055
+ paramIndexMap
2056
+ ];
2057
+ });
2058
+ }
2059
+ const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
2060
+ for(let i = 0, len = handlerData.length; i < len; i++)for(let j = 0, len2 = handlerData[i].length; j < len2; j++){
2061
+ const map = handlerData[i][j]?.[1];
2062
+ if (!map) continue;
2063
+ const keys = Object.keys(map);
2064
+ for(let k = 0, len3 = keys.length; k < len3; k++)map[keys[k]] = paramReplacementMap[map[keys[k]]];
1414
2065
  }
1415
- if (i === len) throw new Error("Fatal error");
1416
- this.name = `SmartRouter + ${this.activeRouter.name}`;
1417
- return res;
2066
+ const handlerMap = [];
2067
+ for(const i in indexReplacementMap)handlerMap[i] = handlerData[indexReplacementMap[i]];
2068
+ return [
2069
+ regexp,
2070
+ handlerMap,
2071
+ staticMap
2072
+ ];
1418
2073
  }
1419
- get activeRouter() {
1420
- if (this.routes || 1 !== this.routers.length) throw new Error("No active router has been determined yet.");
1421
- return this.routers[0];
2074
+ function findMiddleware(middleware, path) {
2075
+ if (!middleware) return;
2076
+ for (const k of Object.keys(middleware).sort((a, b)=>b.length - a.length))if (buildWildcardRegExp(k).test(path)) return [
2077
+ ...middleware[k]
2078
+ ];
1422
2079
  }
1423
- };
1424
- var node_Node = class {
1425
- methods;
1426
- children;
1427
- patterns;
1428
- order = 0;
1429
- name;
1430
- params = /* @__PURE__ */ Object.create(null);
1431
- constructor(method, handler, children){
1432
- this.children = children || /* @__PURE__ */ Object.create(null);
1433
- this.methods = [];
1434
- this.name = "";
1435
- if (method && handler) {
1436
- const m = /* @__PURE__ */ Object.create(null);
1437
- m[method] = {
1438
- handler,
1439
- possibleKeys: [],
1440
- score: 0,
1441
- name: this.name
2080
+ var RegExpRouter = class {
2081
+ name = "RegExpRouter";
2082
+ middleware;
2083
+ routes;
2084
+ constructor(){
2085
+ this.middleware = {
2086
+ [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
2087
+ };
2088
+ this.routes = {
2089
+ [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
1442
2090
  };
1443
- this.methods = [
1444
- m
1445
- ];
1446
2091
  }
1447
- this.patterns = [];
1448
- }
1449
- insert(method, path, handler) {
1450
- this.name = `${method} ${path}`;
1451
- this.order = ++this.order;
1452
- let curNode = this;
1453
- const parts = splitRoutingPath(path);
1454
- const possibleKeys = [];
1455
- for(let i = 0, len = parts.length; i < len; i++){
1456
- const p = parts[i];
1457
- if (Object.keys(curNode.children).includes(p)) {
1458
- curNode = curNode.children[p];
1459
- const pattern2 = getPattern(p);
1460
- if (pattern2) possibleKeys.push(pattern2[1]);
1461
- continue;
1462
- }
1463
- curNode.children[p] = new node_Node();
1464
- const pattern = getPattern(p);
1465
- if (pattern) {
1466
- curNode.patterns.push(pattern);
1467
- possibleKeys.push(pattern[1]);
1468
- }
1469
- curNode = curNode.children[p];
1470
- }
1471
- if (!curNode.methods.length) curNode.methods = [];
1472
- const m = /* @__PURE__ */ Object.create(null);
1473
- const handlerSet = {
1474
- handler,
1475
- possibleKeys: possibleKeys.filter((v, i, a)=>a.indexOf(v) === i),
1476
- name: this.name,
1477
- score: this.order
1478
- };
1479
- m[method] = handlerSet;
1480
- curNode.methods.push(m);
1481
- return curNode;
1482
- }
1483
- gHSets(node, method, nodeParams, params) {
1484
- const handlerSets = [];
1485
- for(let i = 0, len = node.methods.length; i < len; i++){
1486
- const m = node.methods[i];
1487
- const handlerSet = m[method] || m[METHOD_NAME_ALL];
1488
- const processedSet = /* @__PURE__ */ Object.create(null);
1489
- if (void 0 !== handlerSet) {
1490
- handlerSet.params = /* @__PURE__ */ Object.create(null);
1491
- handlerSet.possibleKeys.forEach((key)=>{
1492
- const processed = processedSet[handlerSet.name];
1493
- handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
1494
- processedSet[handlerSet.name] = true;
2092
+ add(method, path, handler) {
2093
+ const { middleware, routes } = this;
2094
+ if (!middleware || !routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2095
+ if (!middleware[method]) [
2096
+ middleware,
2097
+ routes
2098
+ ].forEach((handlerMap)=>{
2099
+ handlerMap[method] = /* @__PURE__ */ Object.create(null);
2100
+ Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p)=>{
2101
+ handlerMap[method][p] = [
2102
+ ...handlerMap[METHOD_NAME_ALL][p]
2103
+ ];
1495
2104
  });
1496
- handlerSets.push(handlerSet);
2105
+ });
2106
+ if ("/*" === path) path = "*";
2107
+ const paramCount = (path.match(/\/:/g) || []).length;
2108
+ if (/\*$/.test(path)) {
2109
+ const re = buildWildcardRegExp(path);
2110
+ if (method === METHOD_NAME_ALL) Object.keys(middleware).forEach((m)=>{
2111
+ middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2112
+ });
2113
+ else middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
2114
+ Object.keys(middleware).forEach((m)=>{
2115
+ if (method === METHOD_NAME_ALL || method === m) Object.keys(middleware[m]).forEach((p)=>{
2116
+ re.test(p) && middleware[m][p].push([
2117
+ handler,
2118
+ paramCount
2119
+ ]);
2120
+ });
2121
+ });
2122
+ Object.keys(routes).forEach((m)=>{
2123
+ if (method === METHOD_NAME_ALL || method === m) Object.keys(routes[m]).forEach((p)=>re.test(p) && routes[m][p].push([
2124
+ handler,
2125
+ paramCount
2126
+ ]));
2127
+ });
2128
+ return;
1497
2129
  }
1498
- }
1499
- return handlerSets;
1500
- }
1501
- search(method, path) {
1502
- const handlerSets = [];
1503
- this.params = /* @__PURE__ */ Object.create(null);
1504
- const curNode = this;
1505
- let curNodes = [
1506
- curNode
1507
- ];
1508
- const parts = splitPath(path);
1509
- for(let i = 0, len = parts.length; i < len; i++){
1510
- const part = parts[i];
1511
- const isLast = i === len - 1;
1512
- const tempNodes = [];
1513
- for(let j = 0, len2 = curNodes.length; j < len2; j++){
1514
- const node = curNodes[j];
1515
- const nextNode = node.children[part];
1516
- if (nextNode) {
1517
- nextNode.params = node.params;
1518
- if (true === isLast) {
1519
- if (nextNode.children["*"]) handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null)));
1520
- handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1521
- } else tempNodes.push(nextNode);
1522
- }
1523
- for(let k = 0, len3 = node.patterns.length; k < len3; k++){
1524
- const pattern = node.patterns[k];
1525
- const params = {
1526
- ...node.params
1527
- };
1528
- if ("*" === pattern) {
1529
- const astNode = node.children["*"];
1530
- if (astNode) {
1531
- handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1532
- tempNodes.push(astNode);
1533
- }
1534
- continue;
1535
- }
1536
- if ("" === part) continue;
1537
- const [key, name, matcher] = pattern;
1538
- const child = node.children[key];
1539
- const restPathString = parts.slice(i).join("/");
1540
- if (matcher instanceof RegExp && matcher.test(restPathString)) {
1541
- params[name] = restPathString;
1542
- handlerSets.push(...this.gHSets(child, method, node.params, params));
1543
- continue;
1544
- }
1545
- if (true === matcher || matcher instanceof RegExp && matcher.test(part)) {
1546
- if ("string" == typeof key) {
1547
- params[name] = part;
1548
- if (true === isLast) {
1549
- handlerSets.push(...this.gHSets(child, method, params, node.params));
1550
- if (child.children["*"]) handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
1551
- } else {
1552
- child.params = params;
1553
- tempNodes.push(child);
1554
- }
1555
- }
2130
+ const paths = checkOptionalParameter(path) || [
2131
+ path
2132
+ ];
2133
+ for(let i = 0, len = paths.length; i < len; i++){
2134
+ const path2 = paths[i];
2135
+ Object.keys(routes).forEach((m)=>{
2136
+ if (method === METHOD_NAME_ALL || method === m) {
2137
+ routes[m][path2] ||= [
2138
+ ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
2139
+ ];
2140
+ routes[m][path2].push([
2141
+ handler,
2142
+ paramCount - len + i + 1
2143
+ ]);
1556
2144
  }
1557
- }
2145
+ });
1558
2146
  }
1559
- curNodes = tempNodes;
1560
2147
  }
1561
- const results = handlerSets.sort((a, b)=>a.score - b.score);
1562
- return [
1563
- results.map(({ handler, params })=>[
1564
- handler,
1565
- params
1566
- ])
1567
- ];
1568
- }
1569
- };
1570
- var TrieRouter = class {
1571
- name = "TrieRouter";
1572
- node;
1573
- constructor(){
1574
- this.node = new node_Node();
1575
- }
1576
- add(method, path, handler) {
1577
- const results = checkOptionalParameter(path);
1578
- if (results) {
1579
- for (const p of results)this.node.insert(method, p, handler);
1580
- return;
2148
+ match(method, path) {
2149
+ clearWildcardRegExpCache();
2150
+ const matchers = this.buildAllMatchers();
2151
+ this.match = (method2, path2)=>{
2152
+ const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
2153
+ const staticMatch = matcher[2][path2];
2154
+ if (staticMatch) return staticMatch;
2155
+ const match = path2.match(matcher[0]);
2156
+ if (!match) return [
2157
+ [],
2158
+ emptyParam
2159
+ ];
2160
+ const index = match.indexOf("", 1);
2161
+ return [
2162
+ matcher[1][index],
2163
+ match
2164
+ ];
2165
+ };
2166
+ return this.match(method, path);
1581
2167
  }
1582
- this.node.insert(method, path, handler);
1583
- }
1584
- match(method, path) {
1585
- return this.node.search(method, path);
1586
- }
1587
- };
1588
- var hono_Hono = class extends Hono {
1589
- constructor(options = {}){
1590
- super(options);
1591
- this.router = options.router ?? new SmartRouter({
1592
- routers: [
1593
- new RegExpRouter(),
1594
- new TrieRouter()
1595
- ]
1596
- });
1597
- }
1598
- };
1599
- var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
1600
- var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
1601
- var parse = (cookie, name)=>{
1602
- const pairs = cookie.trim().split(";");
1603
- return pairs.reduce((parsedCookie, pairStr)=>{
1604
- pairStr = pairStr.trim();
1605
- const valueStartPos = pairStr.indexOf("=");
1606
- if (-1 === valueStartPos) return parsedCookie;
1607
- const cookieName = pairStr.substring(0, valueStartPos).trim();
1608
- if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
1609
- let cookieValue = pairStr.substring(valueStartPos + 1).trim();
1610
- if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) cookieValue = cookieValue.slice(1, -1);
1611
- if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = decodeURIComponent_(cookieValue);
1612
- return parsedCookie;
1613
- }, {});
1614
- };
1615
- var getCookie = (c, key, prefix)=>{
1616
- const cookie = c.req.raw.headers.get("Cookie");
1617
- if ("string" == typeof key) {
1618
- if (!cookie) return;
1619
- let finalKey = key;
1620
- if ("secure" === prefix) finalKey = "__Secure-" + key;
1621
- else if ("host" === prefix) finalKey = "__Host-" + key;
1622
- const obj2 = parse(cookie, finalKey);
1623
- return obj2[finalKey];
1624
- }
1625
- if (!cookie) return {};
1626
- const obj = parse(cookie);
1627
- return obj;
1628
- };
1629
- var HTTPException = class extends Error {
1630
- res;
1631
- status;
1632
- constructor(status = 500, options){
1633
- super(options?.message, {
1634
- cause: options?.cause
1635
- });
1636
- this.res = options?.res;
1637
- this.status = status;
1638
- }
1639
- getResponse() {
1640
- if (this.res) {
1641
- const newResponse = new Response(this.res.body, {
1642
- status: this.status,
1643
- headers: this.res.headers
2168
+ buildAllMatchers() {
2169
+ const matchers = /* @__PURE__ */ Object.create(null);
2170
+ [
2171
+ ...Object.keys(this.routes),
2172
+ ...Object.keys(this.middleware)
2173
+ ].forEach((method)=>{
2174
+ matchers[method] ||= this.buildMatcher(method);
1644
2175
  });
1645
- return newResponse;
2176
+ this.middleware = this.routes = void 0;
2177
+ return matchers;
1646
2178
  }
1647
- return new Response(this.message, {
1648
- status: this.status
1649
- });
1650
- }
1651
- };
1652
- var bufferToFormData = (arrayBuffer, contentType)=>{
1653
- const response = new Response(arrayBuffer, {
1654
- headers: {
1655
- "Content-Type": contentType
2179
+ buildMatcher(method) {
2180
+ const routes = [];
2181
+ let hasOwnRoute = method === METHOD_NAME_ALL;
2182
+ [
2183
+ this.middleware,
2184
+ this.routes
2185
+ ].forEach((r)=>{
2186
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path)=>[
2187
+ path,
2188
+ r[method][path]
2189
+ ]) : [];
2190
+ if (0 !== ownRoute.length) {
2191
+ hasOwnRoute ||= true;
2192
+ routes.push(...ownRoute);
2193
+ } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path)=>[
2194
+ path,
2195
+ r[METHOD_NAME_ALL][path]
2196
+ ]));
2197
+ });
2198
+ if (!hasOwnRoute) return null;
2199
+ return buildMatcherFromPreprocessedRoutes(routes);
1656
2200
  }
1657
- });
1658
- return response.formData();
1659
- };
1660
- var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1661
- var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
1662
- var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1663
- var validator = (target, validationFunc)=>async (c, next)=>{
1664
- let value = {};
1665
- const contentType = c.req.header("Content-Type");
1666
- switch(target){
1667
- case "json":
1668
- if (!contentType || !jsonRegex.test(contentType)) break;
2201
+ };
2202
+ var SmartRouter = class {
2203
+ name = "SmartRouter";
2204
+ routers = [];
2205
+ routes = [];
2206
+ constructor(init){
2207
+ Object.assign(this, init);
2208
+ }
2209
+ add(method, path, handler) {
2210
+ if (!this.routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
2211
+ this.routes.push([
2212
+ method,
2213
+ path,
2214
+ handler
2215
+ ]);
2216
+ }
2217
+ match(method, path) {
2218
+ if (!this.routes) throw new Error("Fatal error");
2219
+ const { routers, routes } = this;
2220
+ const len = routers.length;
2221
+ let i = 0;
2222
+ let res;
2223
+ for(; i < len; i++){
2224
+ const router = routers[i];
1669
2225
  try {
1670
- value = await c.req.json();
1671
- } catch {
1672
- const message = "Malformed JSON in request body";
1673
- throw new HTTPException(400, {
1674
- message
1675
- });
1676
- }
1677
- break;
1678
- case "form":
1679
- {
1680
- if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
1681
- let formData;
1682
- if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
1683
- else try {
1684
- const arrayBuffer = await c.req.arrayBuffer();
1685
- formData = await bufferToFormData(arrayBuffer, contentType);
1686
- c.req.bodyCache.formData = formData;
1687
- } catch (e) {
1688
- let message = "Malformed FormData request.";
1689
- message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
1690
- throw new HTTPException(400, {
1691
- message
1692
- });
1693
- }
1694
- const form = {};
1695
- formData.forEach((value2, key)=>{
1696
- if (key.endsWith("[]")) (form[key] ??= []).push(value2);
1697
- else if (Array.isArray(form[key])) form[key].push(value2);
1698
- else if (key in form) form[key] = [
1699
- form[key],
1700
- value2
1701
- ];
1702
- else form[key] = value2;
2226
+ routes.forEach((args)=>{
2227
+ router.add(...args);
1703
2228
  });
1704
- value = form;
1705
- break;
2229
+ res = router.match(method, path);
2230
+ } catch (e) {
2231
+ if (e instanceof UnsupportedPathError) continue;
2232
+ throw e;
1706
2233
  }
1707
- case "query":
1708
- value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v])=>1 === v.length ? [
1709
- k,
1710
- v[0]
1711
- ] : [
1712
- k,
1713
- v
1714
- ]));
1715
- break;
1716
- case "param":
1717
- value = c.req.param();
1718
- break;
1719
- case "header":
1720
- value = c.req.header();
1721
- break;
1722
- case "cookie":
1723
- value = getCookie(c);
2234
+ this.match = router.match.bind(router);
2235
+ this.routers = [
2236
+ router
2237
+ ];
2238
+ this.routes = void 0;
1724
2239
  break;
2240
+ }
2241
+ if (i === len) throw new Error("Fatal error");
2242
+ this.name = `SmartRouter + ${this.activeRouter.name}`;
2243
+ return res;
1725
2244
  }
1726
- const res = await validationFunc(value, c);
1727
- if (res instanceof Response) return res;
1728
- c.req.addValidatedData(target, res);
1729
- await next();
1730
- };
1731
- var store;
1732
- function getGlobalConfig(config2) {
1733
- return {
1734
- lang: config2?.lang ?? store?.lang,
1735
- message: config2?.message,
1736
- abortEarly: config2?.abortEarly ?? store?.abortEarly,
1737
- abortPipeEarly: config2?.abortPipeEarly ?? store?.abortPipeEarly
1738
- };
1739
- }
1740
- var store2;
1741
- function getGlobalMessage(lang) {
1742
- return store2?.get(lang);
1743
- }
1744
- var store3;
1745
- function getSchemaMessage(lang) {
1746
- return store3?.get(lang);
1747
- }
1748
- var store4;
1749
- function getSpecificMessage(reference, lang) {
1750
- return store4?.get(reference)?.get(lang);
1751
- }
1752
- function _stringify(input) {
1753
- const type = typeof input;
1754
- if ("string" === type) return `"${input}"`;
1755
- if ("number" === type || "bigint" === type || "boolean" === type) return `${input}`;
1756
- if ("object" === type || "function" === type) return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
1757
- return type;
1758
- }
1759
- function _addIssue(context, label, dataset, config2, other) {
1760
- const input = other && "input" in other ? other.input : dataset.value;
1761
- const expected = other?.expected ?? context.expects ?? null;
1762
- const received = other?.received ?? _stringify(input);
1763
- const issue = {
1764
- kind: context.kind,
1765
- type: context.type,
1766
- input,
1767
- expected,
1768
- received,
1769
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
1770
- requirement: context.requirement,
1771
- path: other?.path,
1772
- issues: other?.issues,
1773
- lang: config2.lang,
1774
- abortEarly: config2.abortEarly,
1775
- abortPipeEarly: config2.abortPipeEarly
1776
- };
1777
- const isSchema = "schema" === context.kind;
1778
- const message = other?.message ?? context.message ?? getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? getSchemaMessage(issue.lang) : null) ?? config2.message ?? getGlobalMessage(issue.lang);
1779
- if (message) issue.message = "function" == typeof message ? message(issue) : message;
1780
- if (isSchema) dataset.typed = false;
1781
- if (dataset.issues) dataset.issues.push(issue);
1782
- else dataset.issues = [
1783
- issue
1784
- ];
1785
- }
1786
- function _joinExpects(values, separator) {
1787
- const list = [
1788
- ...new Set(values)
1789
- ];
1790
- if (list.length > 1) return `(${list.join(` ${separator} `)})`;
1791
- return list[0] ?? "never";
1792
- }
1793
- function getDefault(schema, dataset, config2) {
1794
- return "function" == typeof schema.default ? schema.default(dataset, config2) : schema.default;
1795
- }
1796
- function dist_boolean(message) {
1797
- return {
1798
- kind: "schema",
1799
- type: "boolean",
1800
- reference: dist_boolean,
1801
- expects: "boolean",
1802
- async: false,
1803
- message,
1804
- _run (dataset, config2) {
1805
- if ("boolean" == typeof dataset.value) dataset.typed = true;
1806
- else _addIssue(this, "type", dataset, config2);
1807
- return dataset;
2245
+ get activeRouter() {
2246
+ if (this.routes || 1 !== this.routers.length) throw new Error("No active router has been determined yet.");
2247
+ return this.routers[0];
1808
2248
  }
1809
2249
  };
1810
- }
1811
- function literal(literal_, message) {
1812
- return {
1813
- kind: "schema",
1814
- type: "literal",
1815
- reference: literal,
1816
- expects: _stringify(literal_),
1817
- async: false,
1818
- literal: literal_,
1819
- message,
1820
- _run (dataset, config2) {
1821
- if (dataset.value === this.literal) dataset.typed = true;
1822
- else _addIssue(this, "type", dataset, config2);
1823
- return dataset;
2250
+ var node_Node = class {
2251
+ methods;
2252
+ children;
2253
+ patterns;
2254
+ order = 0;
2255
+ name;
2256
+ params = /* @__PURE__ */ Object.create(null);
2257
+ constructor(method, handler, children){
2258
+ this.children = children || /* @__PURE__ */ Object.create(null);
2259
+ this.methods = [];
2260
+ this.name = "";
2261
+ if (method && handler) {
2262
+ const m = /* @__PURE__ */ Object.create(null);
2263
+ m[method] = {
2264
+ handler,
2265
+ possibleKeys: [],
2266
+ score: 0,
2267
+ name: this.name
2268
+ };
2269
+ this.methods = [
2270
+ m
2271
+ ];
2272
+ }
2273
+ this.patterns = [];
1824
2274
  }
1825
- };
1826
- }
1827
- function nullable(wrapped, ...args) {
1828
- const schema = {
1829
- kind: "schema",
1830
- type: "nullable",
1831
- reference: nullable,
1832
- expects: `(${wrapped.expects} | null)`,
1833
- async: false,
1834
- wrapped,
1835
- _run (dataset, config2) {
1836
- if (null === dataset.value) {
1837
- if ("default" in this) dataset.value = getDefault(this, dataset, config2);
1838
- if (null === dataset.value) {
1839
- dataset.typed = true;
1840
- return dataset;
2275
+ insert(method, path, handler) {
2276
+ this.name = `${method} ${path}`;
2277
+ this.order = ++this.order;
2278
+ let curNode = this;
2279
+ const parts = splitRoutingPath(path);
2280
+ const possibleKeys = [];
2281
+ for(let i = 0, len = parts.length; i < len; i++){
2282
+ const p = parts[i];
2283
+ if (Object.keys(curNode.children).includes(p)) {
2284
+ curNode = curNode.children[p];
2285
+ const pattern2 = getPattern(p);
2286
+ if (pattern2) possibleKeys.push(pattern2[1]);
2287
+ continue;
1841
2288
  }
2289
+ curNode.children[p] = new node_Node();
2290
+ const pattern = getPattern(p);
2291
+ if (pattern) {
2292
+ curNode.patterns.push(pattern);
2293
+ possibleKeys.push(pattern[1]);
2294
+ }
2295
+ curNode = curNode.children[p];
1842
2296
  }
1843
- return this.wrapped._run(dataset, config2);
2297
+ if (!curNode.methods.length) curNode.methods = [];
2298
+ const m = /* @__PURE__ */ Object.create(null);
2299
+ const handlerSet = {
2300
+ handler,
2301
+ possibleKeys: possibleKeys.filter((v, i, a)=>a.indexOf(v) === i),
2302
+ name: this.name,
2303
+ score: this.order
2304
+ };
2305
+ m[method] = handlerSet;
2306
+ curNode.methods.push(m);
2307
+ return curNode;
1844
2308
  }
1845
- };
1846
- if (0 in args) schema.default = args[0];
1847
- return schema;
1848
- }
1849
- function dist_object(entries, message) {
1850
- return {
1851
- kind: "schema",
1852
- type: "object",
1853
- reference: dist_object,
1854
- expects: "Object",
1855
- async: false,
1856
- entries,
1857
- message,
1858
- _run (dataset, config2) {
1859
- const input = dataset.value;
1860
- if (input && "object" == typeof input) {
1861
- dataset.typed = true;
1862
- dataset.value = {};
1863
- for(const key in this.entries){
1864
- const value2 = input[key];
1865
- const valueDataset = this.entries[key]._run({
1866
- typed: false,
1867
- value: value2
1868
- }, config2);
1869
- if (valueDataset.issues) {
1870
- const pathItem = {
1871
- type: "object",
1872
- origin: "value",
1873
- input,
1874
- key,
1875
- value: value2
2309
+ gHSets(node, method, nodeParams, params) {
2310
+ const handlerSets = [];
2311
+ for(let i = 0, len = node.methods.length; i < len; i++){
2312
+ const m = node.methods[i];
2313
+ const handlerSet = m[method] || m[METHOD_NAME_ALL];
2314
+ const processedSet = /* @__PURE__ */ Object.create(null);
2315
+ if (void 0 !== handlerSet) {
2316
+ handlerSet.params = /* @__PURE__ */ Object.create(null);
2317
+ handlerSet.possibleKeys.forEach((key)=>{
2318
+ const processed = processedSet[handlerSet.name];
2319
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
2320
+ processedSet[handlerSet.name] = true;
2321
+ });
2322
+ handlerSets.push(handlerSet);
2323
+ }
2324
+ }
2325
+ return handlerSets;
2326
+ }
2327
+ search(method, path) {
2328
+ const handlerSets = [];
2329
+ this.params = /* @__PURE__ */ Object.create(null);
2330
+ const curNode = this;
2331
+ let curNodes = [
2332
+ curNode
2333
+ ];
2334
+ const parts = splitPath(path);
2335
+ for(let i = 0, len = parts.length; i < len; i++){
2336
+ const part = parts[i];
2337
+ const isLast = i === len - 1;
2338
+ const tempNodes = [];
2339
+ for(let j = 0, len2 = curNodes.length; j < len2; j++){
2340
+ const node = curNodes[j];
2341
+ const nextNode = node.children[part];
2342
+ if (nextNode) {
2343
+ nextNode.params = node.params;
2344
+ if (true === isLast) {
2345
+ if (nextNode.children["*"]) handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null)));
2346
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
2347
+ } else tempNodes.push(nextNode);
2348
+ }
2349
+ for(let k = 0, len3 = node.patterns.length; k < len3; k++){
2350
+ const pattern = node.patterns[k];
2351
+ const params = {
2352
+ ...node.params
1876
2353
  };
1877
- for (const issue of valueDataset.issues){
1878
- if (issue.path) issue.path.unshift(pathItem);
1879
- else issue.path = [
1880
- pathItem
1881
- ];
1882
- dataset.issues?.push(issue);
2354
+ if ("*" === pattern) {
2355
+ const astNode = node.children["*"];
2356
+ if (astNode) {
2357
+ handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
2358
+ tempNodes.push(astNode);
2359
+ }
2360
+ continue;
1883
2361
  }
1884
- if (!dataset.issues) dataset.issues = valueDataset.issues;
1885
- if (config2.abortEarly) {
1886
- dataset.typed = false;
1887
- break;
2362
+ if ("" === part) continue;
2363
+ const [key, name, matcher] = pattern;
2364
+ const child = node.children[key];
2365
+ const restPathString = parts.slice(i).join("/");
2366
+ if (matcher instanceof RegExp && matcher.test(restPathString)) {
2367
+ params[name] = restPathString;
2368
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
2369
+ continue;
2370
+ }
2371
+ if (true === matcher || matcher instanceof RegExp && matcher.test(part)) {
2372
+ if ("string" == typeof key) {
2373
+ params[name] = part;
2374
+ if (true === isLast) {
2375
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
2376
+ if (child.children["*"]) handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
2377
+ } else {
2378
+ child.params = params;
2379
+ tempNodes.push(child);
2380
+ }
2381
+ }
1888
2382
  }
1889
2383
  }
1890
- if (!valueDataset.typed) dataset.typed = false;
1891
- if (void 0 !== valueDataset.value || key in input) dataset.value[key] = valueDataset.value;
1892
2384
  }
1893
- } else _addIssue(this, "type", dataset, config2);
1894
- return dataset;
2385
+ curNodes = tempNodes;
2386
+ }
2387
+ const results = handlerSets.sort((a, b)=>a.score - b.score);
2388
+ return [
2389
+ results.map(({ handler, params })=>[
2390
+ handler,
2391
+ params
2392
+ ])
2393
+ ];
1895
2394
  }
1896
2395
  };
1897
- }
1898
- function optional(wrapped, ...args) {
1899
- const schema = {
1900
- kind: "schema",
1901
- type: "optional",
1902
- reference: optional,
1903
- expects: `(${wrapped.expects} | undefined)`,
1904
- async: false,
1905
- wrapped,
1906
- _run (dataset, config2) {
1907
- if (void 0 === dataset.value) {
1908
- if ("default" in this) dataset.value = getDefault(this, dataset, config2);
1909
- if (void 0 === dataset.value) {
1910
- dataset.typed = true;
1911
- return dataset;
1912
- }
2396
+ var TrieRouter = class {
2397
+ name = "TrieRouter";
2398
+ node;
2399
+ constructor(){
2400
+ this.node = new node_Node();
2401
+ }
2402
+ add(method, path, handler) {
2403
+ const results = checkOptionalParameter(path);
2404
+ if (results) {
2405
+ for (const p of results)this.node.insert(method, p, handler);
2406
+ return;
1913
2407
  }
1914
- return this.wrapped._run(dataset, config2);
2408
+ this.node.insert(method, path, handler);
2409
+ }
2410
+ match(method, path) {
2411
+ return this.node.search(method, path);
1915
2412
  }
1916
2413
  };
1917
- if (0 in args) schema.default = args[0];
1918
- return schema;
1919
- }
1920
- function string(message) {
1921
- return {
1922
- kind: "schema",
1923
- type: "string",
1924
- reference: string,
1925
- expects: "string",
1926
- async: false,
1927
- message,
1928
- _run (dataset, config2) {
1929
- if ("string" == typeof dataset.value) dataset.typed = true;
1930
- else _addIssue(this, "type", dataset, config2);
1931
- return dataset;
2414
+ var hono_Hono = class extends Hono {
2415
+ constructor(options = {}){
2416
+ super(options);
2417
+ this.router = options.router ?? new SmartRouter({
2418
+ routers: [
2419
+ new RegExpRouter(),
2420
+ new TrieRouter()
2421
+ ]
2422
+ });
1932
2423
  }
1933
2424
  };
1934
- }
1935
- function _subIssues(datasets) {
1936
- let issues;
1937
- if (datasets) for (const dataset of datasets)if (issues) issues.push(...dataset.issues);
1938
- else issues = dataset.issues;
1939
- return issues;
1940
- }
1941
- function union(options, message) {
1942
- return {
1943
- kind: "schema",
1944
- type: "union",
1945
- reference: union,
1946
- expects: _joinExpects(options.map((option)=>option.expects), "|"),
1947
- async: false,
1948
- options,
1949
- message,
1950
- _run (dataset, config2) {
1951
- let validDataset;
1952
- let typedDatasets;
1953
- let untypedDatasets;
1954
- for (const schema of this.options){
1955
- const optionDataset = schema._run({
1956
- typed: false,
1957
- value: dataset.value
1958
- }, config2);
1959
- if (optionDataset.typed) {
1960
- if (optionDataset.issues) {
1961
- if (typedDatasets) typedDatasets.push(optionDataset);
1962
- else typedDatasets = [
1963
- optionDataset
1964
- ];
1965
- } else {
1966
- validDataset = optionDataset;
1967
- break;
1968
- }
1969
- } else if (untypedDatasets) untypedDatasets.push(optionDataset);
1970
- else untypedDatasets = [
1971
- optionDataset
1972
- ];
2425
+ var _validateReport = __webpack_require__("../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3/node_modules/typia/lib/internal/_validateReport.js");
2426
+ var cjs = __webpack_require__("../../node_modules/.pnpm/@hono+typia-validator@0.1.0_hono@4.6.3_typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.6.3_/node_modules/@hono/typia-validator/dist/cjs/index.js");
2427
+ const plugin_core_namespaceObject = require("@hot-updater/plugin-core");
2428
+ const bundleIdValidator = (()=>{
2429
+ const _io0 = (input)=>"string" == typeof input.bundleId;
2430
+ const _vo0 = (input, _path, _exceptionable = true)=>[
2431
+ "string" == typeof input.bundleId || _report(_exceptionable, {
2432
+ path: _path + ".bundleId",
2433
+ expected: "string",
2434
+ value: input.bundleId
2435
+ })
2436
+ ].every((flag)=>flag);
2437
+ const __is = (input)=>"object" == typeof input && null !== input && _io0(input);
2438
+ let errors;
2439
+ let _report;
2440
+ return (input)=>{
2441
+ if (false === __is(input)) {
2442
+ errors = [];
2443
+ _report = _validateReport._validateReport(errors);
2444
+ ((input, _path, _exceptionable = true)=>("object" == typeof input && null !== input || _report(true, {
2445
+ path: _path + "",
2446
+ expected: "__type",
2447
+ value: input
2448
+ })) && _vo0(input, _path + "", true) || _report(true, {
2449
+ path: _path + "",
2450
+ expected: "__type",
2451
+ value: input
2452
+ }))(input, "$input", true);
2453
+ const success = 0 === errors.length;
2454
+ return success ? {
2455
+ success,
2456
+ data: input
2457
+ } : {
2458
+ success,
2459
+ errors,
2460
+ data: input
2461
+ };
1973
2462
  }
1974
- if (validDataset) return validDataset;
1975
- if (typedDatasets) {
1976
- if (1 === typedDatasets.length) return typedDatasets[0];
1977
- _addIssue(this, "type", dataset, config2, {
1978
- issues: _subIssues(typedDatasets)
1979
- });
1980
- dataset.typed = true;
1981
- } else {
1982
- if (untypedDatasets?.length === 1) return untypedDatasets[0];
1983
- _addIssue(this, "type", dataset, config2, {
1984
- issues: _subIssues(untypedDatasets)
1985
- });
2463
+ return {
2464
+ success: true,
2465
+ data: input
2466
+ };
2467
+ };
2468
+ })();
2469
+ const updateBundleValidator = (()=>{
2470
+ const _io0 = (input)=>"string" == typeof input.targetBundleId && "object" == typeof input.bundle && null !== input.bundle && false === Array.isArray(input.bundle) && _io1(input.bundle);
2471
+ const _io1 = (input)=>(void 0 === input.id || "string" == typeof input.id) && (void 0 === input.platform || "ios" === input.platform || "android" === input.platform) && (void 0 === input.targetAppVersion || "string" == typeof input.targetAppVersion) && (void 0 === input.shouldForceUpdate || "boolean" == typeof input.shouldForceUpdate) && (void 0 === input.enabled || "boolean" == typeof input.enabled) && (void 0 === input.fileUrl || "string" == typeof input.fileUrl) && (void 0 === input.fileHash || "string" == typeof input.fileHash) && (null === input.gitCommitHash || void 0 === input.gitCommitHash || "string" == typeof input.gitCommitHash) && (null === input.message || void 0 === input.message || "string" == typeof input.message);
2472
+ const _vo0 = (input, _path, _exceptionable = true)=>[
2473
+ "string" == typeof input.targetBundleId || _report(_exceptionable, {
2474
+ path: _path + ".targetBundleId",
2475
+ expected: "string",
2476
+ value: input.targetBundleId
2477
+ }),
2478
+ ("object" == typeof input.bundle && null !== input.bundle && false === Array.isArray(input.bundle) || _report(_exceptionable, {
2479
+ path: _path + ".bundle",
2480
+ expected: "Partial<Bundle>",
2481
+ value: input.bundle
2482
+ })) && _vo1(input.bundle, _path + ".bundle", _exceptionable) || _report(_exceptionable, {
2483
+ path: _path + ".bundle",
2484
+ expected: "Partial<Bundle>",
2485
+ value: input.bundle
2486
+ })
2487
+ ].every((flag)=>flag);
2488
+ const _vo1 = (input, _path, _exceptionable = true)=>[
2489
+ void 0 === input.id || "string" == typeof input.id || _report(_exceptionable, {
2490
+ path: _path + ".id",
2491
+ expected: "(string | undefined)",
2492
+ value: input.id
2493
+ }),
2494
+ void 0 === input.platform || "ios" === input.platform || "android" === input.platform || _report(_exceptionable, {
2495
+ path: _path + ".platform",
2496
+ expected: "(\"android\" | \"ios\" | undefined)",
2497
+ value: input.platform
2498
+ }),
2499
+ void 0 === input.targetAppVersion || "string" == typeof input.targetAppVersion || _report(_exceptionable, {
2500
+ path: _path + ".targetAppVersion",
2501
+ expected: "(string | undefined)",
2502
+ value: input.targetAppVersion
2503
+ }),
2504
+ void 0 === input.shouldForceUpdate || "boolean" == typeof input.shouldForceUpdate || _report(_exceptionable, {
2505
+ path: _path + ".shouldForceUpdate",
2506
+ expected: "(boolean | undefined)",
2507
+ value: input.shouldForceUpdate
2508
+ }),
2509
+ void 0 === input.enabled || "boolean" == typeof input.enabled || _report(_exceptionable, {
2510
+ path: _path + ".enabled",
2511
+ expected: "(boolean | undefined)",
2512
+ value: input.enabled
2513
+ }),
2514
+ void 0 === input.fileUrl || "string" == typeof input.fileUrl || _report(_exceptionable, {
2515
+ path: _path + ".fileUrl",
2516
+ expected: "(string | undefined)",
2517
+ value: input.fileUrl
2518
+ }),
2519
+ void 0 === input.fileHash || "string" == typeof input.fileHash || _report(_exceptionable, {
2520
+ path: _path + ".fileHash",
2521
+ expected: "(string | undefined)",
2522
+ value: input.fileHash
2523
+ }),
2524
+ null === input.gitCommitHash || void 0 === input.gitCommitHash || "string" == typeof input.gitCommitHash || _report(_exceptionable, {
2525
+ path: _path + ".gitCommitHash",
2526
+ expected: "(null | string | undefined)",
2527
+ value: input.gitCommitHash
2528
+ }),
2529
+ null === input.message || void 0 === input.message || "string" == typeof input.message || _report(_exceptionable, {
2530
+ path: _path + ".message",
2531
+ expected: "(null | string | undefined)",
2532
+ value: input.message
2533
+ })
2534
+ ].every((flag)=>flag);
2535
+ const __is = (input)=>"object" == typeof input && null !== input && _io0(input);
2536
+ let errors;
2537
+ let _report;
2538
+ return (input)=>{
2539
+ if (false === __is(input)) {
2540
+ errors = [];
2541
+ _report = _validateReport._validateReport(errors);
2542
+ ((input, _path, _exceptionable = true)=>("object" == typeof input && null !== input || _report(true, {
2543
+ path: _path + "",
2544
+ expected: "__type",
2545
+ value: input
2546
+ })) && _vo0(input, _path + "", true) || _report(true, {
2547
+ path: _path + "",
2548
+ expected: "__type",
2549
+ value: input
2550
+ }))(input, "$input", true);
2551
+ const success = 0 === errors.length;
2552
+ return success ? {
2553
+ success,
2554
+ data: input
2555
+ } : {
2556
+ success,
2557
+ errors,
2558
+ data: input
2559
+ };
1986
2560
  }
1987
- return dataset;
2561
+ return {
2562
+ success: true,
2563
+ data: input
2564
+ };
2565
+ };
2566
+ })();
2567
+ let rpc_config = null;
2568
+ let rpc_databasePlugin = null;
2569
+ const prepareConfig = async ()=>{
2570
+ if (!rpc_config) {
2571
+ rpc_config = await (0, plugin_core_namespaceObject.loadConfig)({
2572
+ platform: "console"
2573
+ });
2574
+ rpc_databasePlugin = await rpc_config?.database({
2575
+ cwd: plugin_core_namespaceObject.getCwd()
2576
+ }) ?? null;
1988
2577
  }
2578
+ return {
2579
+ config: rpc_config,
2580
+ databasePlugin: rpc_databasePlugin
2581
+ };
1989
2582
  };
1990
- }
1991
- function omit(schema, keys) {
1992
- const entries = {
1993
- ...schema.entries
1994
- };
1995
- for (const key of keys)delete entries[key];
1996
- return {
1997
- ...schema,
1998
- entries
1999
- };
2000
- }
2001
- function partial(schema, keys) {
2002
- const entries = {};
2003
- for(const key in schema.entries)entries[key] = !keys || keys.includes(key) ? optional(schema.entries[key]) : schema.entries[key];
2004
- return {
2005
- ...schema,
2006
- entries
2007
- };
2008
- }
2009
- async function safeParseAsync(schema, input, config2) {
2010
- const dataset = await schema._run({
2011
- typed: false,
2012
- value: input
2013
- }, getGlobalConfig(config2));
2014
- return {
2015
- typed: dataset.typed,
2016
- success: !dataset.issues,
2017
- output: dataset.value,
2018
- issues: dataset.issues
2019
- };
2020
- }
2021
- var vValidator = (target, schema, hook)=>validator(target, async (value, c)=>{
2022
- const result = await safeParseAsync(schema, value);
2023
- if (hook) {
2024
- const hookResult = hook(result, c);
2025
- if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
2026
- }
2027
- if (!result.success) return c.json(result, 400);
2028
- const data = result.output;
2029
- return data;
2030
- });
2031
- const plugin_core_namespaceObject = require("@hot-updater/plugin-core");
2032
- const bundleSchema = dist_object({
2033
- platform: union([
2034
- literal("ios"),
2035
- literal("android")
2036
- ]),
2037
- targetAppVersion: string(),
2038
- id: string(),
2039
- shouldForceUpdate: dist_boolean(),
2040
- enabled: dist_boolean(),
2041
- fileUrl: string(),
2042
- fileHash: string(),
2043
- gitCommitHash: nullable(string()),
2044
- message: nullable(string())
2045
- });
2046
- let rpc_config = null;
2047
- let rpc_databasePlugin = null;
2048
- const prepareConfig = async ()=>{
2049
- if (!rpc_config) {
2050
- rpc_config = await (0, plugin_core_namespaceObject.loadConfig)({
2051
- platform: "console"
2583
+ const rpc = new hono_Hono().get("/getConfig", async (c)=>{
2584
+ const { config } = await prepareConfig();
2585
+ return c.json({
2586
+ console: config?.console
2052
2587
  });
2053
- rpc_databasePlugin = await rpc_config?.database({
2054
- cwd: plugin_core_namespaceObject.getCwd()
2055
- }) ?? null;
2056
- }
2057
- return {
2058
- config: rpc_config,
2059
- databasePlugin: rpc_databasePlugin
2060
- };
2061
- };
2062
- const rpc = new hono_Hono().get("/getConfig", async (c)=>{
2063
- const { config } = await prepareConfig();
2064
- return c.json({
2065
- console: config?.console
2588
+ }).get("/isConfigLoaded", (c)=>c.json(null !== rpc_config)).get("/getBundles", async (c)=>{
2589
+ const { databasePlugin } = await prepareConfig();
2590
+ const bundles = await databasePlugin?.getBundles(true);
2591
+ return c.json(bundles ?? []);
2592
+ }).get("/getBundleById", (0, cjs.typiaValidator)("query", bundleIdValidator), async (c)=>{
2593
+ const { bundleId } = c.req.valid("query");
2594
+ const { databasePlugin } = await prepareConfig();
2595
+ const bundle = await databasePlugin?.getBundleById(bundleId);
2596
+ return c.json(bundle ?? null);
2597
+ }).post("/updateBundle", (0, cjs.typiaValidator)("json", updateBundleValidator), async (c)=>{
2598
+ const { targetBundleId, bundle } = c.req.valid("json");
2599
+ const { databasePlugin } = await prepareConfig();
2600
+ await databasePlugin?.updateBundle(targetBundleId, bundle);
2601
+ await databasePlugin?.commitBundle();
2602
+ return c.json(true);
2066
2603
  });
2067
- }).get("/isConfigLoaded", (c)=>c.json(null !== rpc_config)).get("/getBundles", async (c)=>{
2068
- const { databasePlugin } = await prepareConfig();
2069
- const bundles = await databasePlugin?.getBundles(true);
2070
- return c.json(bundles ?? []);
2071
- }).get("/getBundleById", vValidator("query", dist_object({
2072
- bundleId: string()
2073
- })), async (c)=>{
2074
- const { bundleId } = c.req.valid("query");
2075
- const { databasePlugin } = await prepareConfig();
2076
- const bundle = await databasePlugin?.getBundleById(bundleId);
2077
- return c.json(bundle ?? null);
2078
- }).post("/updateBundle", vValidator("json", dist_object({
2079
- targetBundleId: string(),
2080
- bundle: partial(omit(bundleSchema, [
2081
- "id"
2082
- ]))
2083
- })), async (c)=>{
2084
- const { targetBundleId, bundle } = c.req.valid("json");
2085
- const { databasePlugin } = await prepareConfig();
2086
- await databasePlugin?.updateBundle(targetBundleId, bundle);
2087
- await databasePlugin?.commitBundle();
2088
- return c.json(true);
2089
- });
2090
- const src_server_rslib_entry_dirname = external_path_default().dirname((0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
2091
- const relativePathToScript = external_path_default().relative(process.cwd(), src_server_rslib_entry_dirname);
2092
- const src_server_rslib_entry_app = new hono_Hono().get("/ping", (c)=>c.text("pong")).route("/rpc", rpc).use("/assets/*", serveStatic({
2093
- root: relativePathToScript
2094
- })).get("*", serveStatic({
2095
- root: relativePathToScript,
2096
- path: "index.html"
2097
- }));
2098
- const src_server_rslib_entry_ = src_server_rslib_entry_app;
2604
+ const src_server_rslib_entry_dirname = external_path_default().dirname((0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
2605
+ const relativePathToScript = external_path_default().relative(process.cwd(), src_server_rslib_entry_dirname);
2606
+ const src_server_rslib_entry_app = new hono_Hono().get("/ping", (c)=>c.text("pong")).route("/rpc", rpc).use("/assets/*", serveStatic({
2607
+ root: relativePathToScript
2608
+ })).get("*", serveStatic({
2609
+ root: relativePathToScript,
2610
+ path: "index.html"
2611
+ }));
2612
+ const src_server_rslib_entry_ = src_server_rslib_entry_app;
2613
+ })();
2099
2614
  var __webpack_export_target__ = exports;
2100
2615
  for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
2101
2616
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {