@hot-updater/console 0.16.7-0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/assets/index-B40KfAQR.css +1 -0
  2. package/dist/assets/index-ClfoMSQp.js +27 -0
  3. package/dist/index.cjs +1997 -2048
  4. package/dist/index.d.cts +154 -0
  5. package/dist/index.d.ts +154 -0
  6. package/dist/index.html +2 -2
  7. package/dist/index.js +1906 -1911
  8. package/package.json +6 -5
  9. package/dist/assets/index-C9l9iw4B.js +0 -27
  10. package/dist/assets/index-paAi6YFm.css +0 -1
  11. package/dist/src/App.d.ts +0 -2
  12. package/dist/src/components/spash-screen.d.ts +0 -1
  13. package/dist/src/components/ui/button.d.ts +0 -15
  14. package/dist/src/components/ui/label.d.ts +0 -3
  15. package/dist/src/components/ui/layout.d.ts +0 -4
  16. package/dist/src/components/ui/navigation-menu.d.ts +0 -35
  17. package/dist/src/components/ui/pagination.d.ts +0 -27
  18. package/dist/src/components/ui/sheet.d.ts +0 -26
  19. package/dist/src/components/ui/skeleton.d.ts +0 -8
  20. package/dist/src/components/ui/sonner.d.ts +0 -5
  21. package/dist/src/components/ui/switch.d.ts +0 -20
  22. package/dist/src/components/ui/table.d.ts +0 -10
  23. package/dist/src/components/ui/text-field.d.ts +0 -26
  24. package/dist/src/components/ui/toast.d.ts +0 -41
  25. package/dist/src/hooks/useFilter.d.ts +0 -9
  26. package/dist/src/index.d.ts +0 -1
  27. package/dist/src/lib/api.d.ts +0 -157
  28. package/dist/src/lib/extract-timestamp-from-uuidv7.d.ts +0 -1
  29. package/dist/src/lib/utils.d.ts +0 -3
  30. package/dist/src/routes/_components/columns.d.ts +0 -3
  31. package/dist/src/routes/_components/data-table.d.ts +0 -8
  32. package/dist/src/routes/_components/edit-bundle-sheet-content.d.ts +0 -5
  33. package/dist/src/routes/index.d.ts +0 -1
  34. package/dist/src-server/index.d.ts +0 -140
  35. package/dist/src-server/rpc.d.ts +0 -130
package/dist/index.cjs CHANGED
@@ -1,2054 +1,2003 @@
1
- "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
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
- }();
5
- var __webpack_modules__ = {
6
- "../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.8.3/node_modules/typia/lib/internal/_validateReport.js": function(__unused_webpack_module, exports1) {
7
- exports1._validateReport = void 0;
8
- const _validateReport = (array)=>{
9
- const reportable = (path)=>{
10
- if (0 === array.length) return true;
11
- const last = array[array.length - 1].path;
12
- return path.length > last.length || last.substring(0, path.length) !== path;
13
- };
14
- return (exceptable, error)=>{
15
- if (exceptable && reportable(error.path)) array.push(error);
16
- return false;
17
- };
18
- };
19
- exports1._validateReport = _validateReport;
20
- }
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
21
10
  };
22
- var __webpack_module_cache__ = {};
23
- function __webpack_require__(moduleId) {
24
- var cachedModule = __webpack_module_cache__[moduleId];
25
- if (void 0 !== cachedModule) return cachedModule.exports;
26
- var module = __webpack_module_cache__[moduleId] = {
27
- exports: {}
28
- };
29
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
30
- return module.exports;
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
+ key = keys[i];
14
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
22
+ value: mod,
23
+ enumerable: true
24
+ }) : target, mod));
25
+
26
+ //#endregion
27
+ const path = __toESM(require("path"));
28
+ const url = __toESM(require("url"));
29
+ const fs = __toESM(require("fs"));
30
+ const __hot_updater_plugin_core = __toESM(require("@hot-updater/plugin-core"));
31
+
32
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/filepath.js
33
+ var getFilePath = (options) => {
34
+ let filename = options.filename;
35
+ const defaultDocument = options.defaultDocument || "index.html";
36
+ if (filename.endsWith("/")) filename = filename.concat(defaultDocument);
37
+ else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) filename = filename.concat("/" + defaultDocument);
38
+ const path$2 = getFilePathWithoutDefaultDocument({
39
+ root: options.root,
40
+ filename
41
+ });
42
+ return path$2;
43
+ };
44
+ var getFilePathWithoutDefaultDocument = (options) => {
45
+ let root = options.root || "";
46
+ let filename = options.filename;
47
+ if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) return;
48
+ filename = filename.replace(/^\.?[\/\\]/, "");
49
+ filename = filename.replace(/\\/, "/");
50
+ root = root.replace(/\/$/, "");
51
+ let path$2 = root ? root + "/" + filename : filename;
52
+ path$2 = path$2.replace(/^\.?\//, "");
53
+ if (root[0] !== "/" && path$2[0] === "/") return;
54
+ return path$2;
55
+ };
56
+
57
+ //#endregion
58
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/mime.js
59
+ var getMimeType = (filename, mimes = baseMimes) => {
60
+ const regexp = /\.([a-zA-Z0-9]+?)$/;
61
+ const match = filename.match(regexp);
62
+ if (!match) return;
63
+ let mimeType = mimes[match[1]];
64
+ if (mimeType && mimeType.startsWith("text") || mimeType === "application/json") mimeType += "; charset=utf-8";
65
+ return mimeType;
66
+ };
67
+ var baseMimes = {
68
+ aac: "audio/aac",
69
+ avi: "video/x-msvideo",
70
+ avif: "image/avif",
71
+ av1: "video/av1",
72
+ bin: "application/octet-stream",
73
+ bmp: "image/bmp",
74
+ css: "text/css",
75
+ csv: "text/csv",
76
+ eot: "application/vnd.ms-fontobject",
77
+ epub: "application/epub+zip",
78
+ gif: "image/gif",
79
+ gz: "application/gzip",
80
+ htm: "text/html",
81
+ html: "text/html",
82
+ ico: "image/x-icon",
83
+ ics: "text/calendar",
84
+ jpeg: "image/jpeg",
85
+ jpg: "image/jpeg",
86
+ js: "text/javascript",
87
+ json: "application/json",
88
+ jsonld: "application/ld+json",
89
+ map: "application/json",
90
+ mid: "audio/x-midi",
91
+ midi: "audio/x-midi",
92
+ mjs: "text/javascript",
93
+ mp3: "audio/mpeg",
94
+ mp4: "video/mp4",
95
+ mpeg: "video/mpeg",
96
+ oga: "audio/ogg",
97
+ ogv: "video/ogg",
98
+ ogx: "application/ogg",
99
+ opus: "audio/opus",
100
+ otf: "font/otf",
101
+ pdf: "application/pdf",
102
+ png: "image/png",
103
+ rtf: "application/rtf",
104
+ svg: "image/svg+xml",
105
+ tif: "image/tiff",
106
+ tiff: "image/tiff",
107
+ ts: "video/mp2t",
108
+ ttf: "font/ttf",
109
+ txt: "text/plain",
110
+ wasm: "application/wasm",
111
+ webm: "video/webm",
112
+ weba: "audio/webm",
113
+ webp: "image/webp",
114
+ woff: "font/woff",
115
+ woff2: "font/woff2",
116
+ xhtml: "application/xhtml+xml",
117
+ xml: "application/xml",
118
+ zip: "application/zip",
119
+ "3gp": "video/3gpp",
120
+ "3g2": "video/3gpp2",
121
+ gltf: "model/gltf+json",
122
+ glb: "model/gltf-binary"
123
+ };
124
+
125
+ //#endregion
126
+ //#region ../../node_modules/.pnpm/@hono+node-server@1.13.4_hono@4.6.3/node_modules/@hono/node-server/dist/serve-static.mjs
127
+ 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;
128
+ var ENCODINGS = {
129
+ br: ".br",
130
+ zstd: ".zst",
131
+ gzip: ".gz"
132
+ };
133
+ var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
134
+ var createStreamBody = (stream) => {
135
+ const body = new ReadableStream({
136
+ start(controller) {
137
+ stream.on("data", (chunk) => {
138
+ controller.enqueue(chunk);
139
+ });
140
+ stream.on("end", () => {
141
+ controller.close();
142
+ });
143
+ },
144
+ cancel() {
145
+ stream.destroy();
146
+ }
147
+ });
148
+ return body;
149
+ };
150
+ var addCurrentDirPrefix = (path$2) => {
151
+ return `./${path$2}`;
152
+ };
153
+ var getStats = (path$2) => {
154
+ let stats;
155
+ try {
156
+ stats = (0, fs.lstatSync)(path$2);
157
+ } catch {}
158
+ return stats;
159
+ };
160
+ var serveStatic = (options = { root: "" }) => {
161
+ return async (c, next) => {
162
+ if (c.finalized) return next();
163
+ let filename;
164
+ try {
165
+ filename = options.path ?? decodeURIComponent(c.req.path);
166
+ } catch {
167
+ await options.onNotFound?.(c.req.path, c);
168
+ return next();
169
+ }
170
+ let path$2 = getFilePathWithoutDefaultDocument({
171
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
172
+ root: options.root
173
+ });
174
+ if (path$2) path$2 = addCurrentDirPrefix(path$2);
175
+ else return next();
176
+ let stats = getStats(path$2);
177
+ if (stats && stats.isDirectory()) {
178
+ path$2 = getFilePath({
179
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
180
+ root: options.root,
181
+ defaultDocument: options.index ?? "index.html"
182
+ });
183
+ if (path$2) path$2 = addCurrentDirPrefix(path$2);
184
+ else return next();
185
+ stats = getStats(path$2);
186
+ }
187
+ if (!stats) {
188
+ await options.onNotFound?.(path$2, c);
189
+ return next();
190
+ }
191
+ await options.onFound?.(path$2, c);
192
+ const mimeType = getMimeType(path$2);
193
+ c.header("Content-Type", mimeType || "application/octet-stream");
194
+ if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
195
+ const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim()));
196
+ for (const encoding of ENCODINGS_ORDERED_KEYS) {
197
+ if (!acceptEncodingSet.has(encoding)) continue;
198
+ const precompressedStats = getStats(path$2 + ENCODINGS[encoding]);
199
+ if (precompressedStats) {
200
+ c.header("Content-Encoding", encoding);
201
+ c.header("Vary", "Accept-Encoding", { append: true });
202
+ stats = precompressedStats;
203
+ path$2 = path$2 + ENCODINGS[encoding];
204
+ break;
205
+ }
206
+ }
207
+ }
208
+ const size = stats.size;
209
+ if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
210
+ c.header("Content-Length", size.toString());
211
+ c.status(200);
212
+ return c.body(null);
213
+ }
214
+ const range = c.req.header("range") || "";
215
+ if (!range) {
216
+ c.header("Content-Length", size.toString());
217
+ return c.body(createStreamBody((0, fs.createReadStream)(path$2)), 200);
218
+ }
219
+ c.header("Accept-Ranges", "bytes");
220
+ c.header("Date", stats.birthtime.toUTCString());
221
+ const parts = range.replace(/bytes=/, "").split("-", 2);
222
+ const start = parts[0] ? parseInt(parts[0], 10) : 0;
223
+ let end = parts[1] ? parseInt(parts[1], 10) : stats.size - 1;
224
+ if (size < end - start + 1) end = size - 1;
225
+ const chunksize = end - start + 1;
226
+ const stream = (0, fs.createReadStream)(path$2, {
227
+ start,
228
+ end
229
+ });
230
+ c.header("Content-Length", chunksize.toString());
231
+ c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
232
+ return c.body(createStreamBody(stream), 206);
233
+ };
234
+ };
235
+
236
+ //#endregion
237
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/body.js
238
+ var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
239
+ const { all = false, dot = false } = options;
240
+ const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
241
+ const contentType = headers.get("Content-Type");
242
+ if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
243
+ all,
244
+ dot
245
+ });
246
+ return {};
247
+ };
248
+ async function parseFormData(request, options) {
249
+ const formData = await request.formData();
250
+ if (formData) return convertFormDataToBodyData(formData, options);
251
+ return {};
31
252
  }
32
- (()=>{
33
- __webpack_require__.n = (module)=>{
34
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
35
- __webpack_require__.d(getter, {
36
- a: getter
37
- });
38
- return getter;
39
- };
40
- })();
41
- (()=>{
42
- __webpack_require__.d = (exports1, definition)=>{
43
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
44
- enumerable: true,
45
- get: definition[key]
46
- });
47
- };
48
- })();
49
- (()=>{
50
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
253
+ function convertFormDataToBodyData(formData, options) {
254
+ const form = /* @__PURE__ */ Object.create(null);
255
+ formData.forEach((value, key) => {
256
+ const shouldParseAllValues = options.all || key.endsWith("[]");
257
+ if (!shouldParseAllValues) form[key] = value;
258
+ else handleParsingAllValues(form, key, value);
259
+ });
260
+ if (options.dot) Object.entries(form).forEach(([key, value]) => {
261
+ const shouldParseDotValues = key.includes(".");
262
+ if (shouldParseDotValues) {
263
+ handleParsingNestedValues(form, key, value);
264
+ delete form[key];
265
+ }
266
+ });
267
+ return form;
268
+ }
269
+ var handleParsingAllValues = (form, key, value) => {
270
+ if (form[key] !== void 0) if (Array.isArray(form[key])) form[key].push(value);
271
+ else form[key] = [form[key], value];
272
+ else form[key] = value;
273
+ };
274
+ var handleParsingNestedValues = (form, key, value) => {
275
+ let nestedForm = form;
276
+ const keys = key.split(".");
277
+ keys.forEach((key2, index) => {
278
+ if (index === keys.length - 1) nestedForm[key2] = value;
279
+ else {
280
+ if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) nestedForm[key2] = /* @__PURE__ */ Object.create(null);
281
+ nestedForm = nestedForm[key2];
282
+ }
283
+ });
284
+ };
285
+
286
+ //#endregion
287
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/url.js
288
+ var splitPath = (path$2) => {
289
+ const paths = path$2.split("/");
290
+ if (paths[0] === "") paths.shift();
291
+ return paths;
292
+ };
293
+ var splitRoutingPath = (routePath) => {
294
+ const { groups, path: path$2 } = extractGroupsFromPath(routePath);
295
+ const paths = splitPath(path$2);
296
+ return replaceGroupMarks(paths, groups);
297
+ };
298
+ var extractGroupsFromPath = (path$2) => {
299
+ const groups = [];
300
+ path$2 = path$2.replace(/\{[^}]+\}/g, (match, index) => {
301
+ const mark = `@${index}`;
302
+ groups.push([mark, match]);
303
+ return mark;
304
+ });
305
+ return {
306
+ groups,
307
+ path: path$2
308
+ };
309
+ };
310
+ var replaceGroupMarks = (paths, groups) => {
311
+ for (let i = groups.length - 1; i >= 0; i--) {
312
+ const [mark] = groups[i];
313
+ for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
314
+ paths[j] = paths[j].replace(mark, groups[i][1]);
315
+ break;
316
+ }
317
+ }
318
+ return paths;
319
+ };
320
+ var patternCache = {};
321
+ var getPattern = (label) => {
322
+ if (label === "*") return "*";
323
+ const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
324
+ if (match) {
325
+ if (!patternCache[label]) if (match[2]) patternCache[label] = [
326
+ label,
327
+ match[1],
328
+ new RegExp("^" + match[2] + "$")
329
+ ];
330
+ else patternCache[label] = [
331
+ label,
332
+ match[1],
333
+ true
334
+ ];
335
+ return patternCache[label];
336
+ }
337
+ return null;
338
+ };
339
+ var tryDecodeURI = (str) => {
340
+ try {
341
+ return decodeURI(str);
342
+ } catch {
343
+ return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
344
+ try {
345
+ return decodeURI(match);
346
+ } catch {
347
+ return match;
348
+ }
349
+ });
350
+ }
351
+ };
352
+ var getPath = (request) => {
353
+ const url$1 = request.url;
354
+ const start = url$1.indexOf("/", 8);
355
+ let i = start;
356
+ for (; i < url$1.length; i++) {
357
+ const charCode = url$1.charCodeAt(i);
358
+ if (charCode === 37) {
359
+ const queryIndex = url$1.indexOf("?", i);
360
+ const path$2 = url$1.slice(start, queryIndex === -1 ? void 0 : queryIndex);
361
+ return tryDecodeURI(path$2.includes("%25") ? path$2.replace(/%25/g, "%2525") : path$2);
362
+ } else if (charCode === 63) break;
363
+ }
364
+ return url$1.slice(start, i);
365
+ };
366
+ var getPathNoStrict = (request) => {
367
+ const result = getPath(request);
368
+ return result.length > 1 && result[result.length - 1] === "/" ? result.slice(0, -1) : result;
369
+ };
370
+ var mergePath = (...paths) => {
371
+ let p = "";
372
+ let endsWithSlash = false;
373
+ for (let path$2 of paths) {
374
+ if (p[p.length - 1] === "/") {
375
+ p = p.slice(0, -1);
376
+ endsWithSlash = true;
377
+ }
378
+ if (path$2[0] !== "/") path$2 = `/${path$2}`;
379
+ if (path$2 === "/" && endsWithSlash) p = `${p}/`;
380
+ else if (path$2 !== "/") p = `${p}${path$2}`;
381
+ if (path$2 === "/" && p === "") p = "/";
382
+ }
383
+ return p;
384
+ };
385
+ var checkOptionalParameter = (path$2) => {
386
+ if (!path$2.match(/\:.+\?$/)) return null;
387
+ const segments = path$2.split("/");
388
+ const results = [];
389
+ let basePath = "";
390
+ segments.forEach((segment) => {
391
+ if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
392
+ else if (/\:/.test(segment)) if (/\?/.test(segment)) {
393
+ if (results.length === 0 && basePath === "") results.push("/");
394
+ else results.push(basePath);
395
+ const optionalSegment = segment.replace("?", "");
396
+ basePath += "/" + optionalSegment;
397
+ results.push(basePath);
398
+ } else basePath += "/" + segment;
399
+ });
400
+ return results.filter((v, i, a) => a.indexOf(v) === i);
401
+ };
402
+ var _decodeURI = (value) => {
403
+ if (!/[%+]/.test(value)) return value;
404
+ if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
405
+ return /%/.test(value) ? decodeURIComponent_(value) : value;
406
+ };
407
+ var _getQueryParam = (url$1, key, multiple) => {
408
+ let encoded;
409
+ if (!multiple && key && !/[%+]/.test(key)) {
410
+ let keyIndex2 = url$1.indexOf(`?${key}`, 8);
411
+ if (keyIndex2 === -1) keyIndex2 = url$1.indexOf(`&${key}`, 8);
412
+ while (keyIndex2 !== -1) {
413
+ const trailingKeyCode = url$1.charCodeAt(keyIndex2 + key.length + 1);
414
+ if (trailingKeyCode === 61) {
415
+ const valueIndex = keyIndex2 + key.length + 2;
416
+ const endIndex = url$1.indexOf("&", valueIndex);
417
+ return _decodeURI(url$1.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
418
+ } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
419
+ keyIndex2 = url$1.indexOf(`&${key}`, keyIndex2 + 1);
420
+ }
421
+ encoded = /[%+]/.test(url$1);
422
+ if (!encoded) return void 0;
423
+ }
424
+ const results = {};
425
+ encoded ??= /[%+]/.test(url$1);
426
+ let keyIndex = url$1.indexOf("?", 8);
427
+ while (keyIndex !== -1) {
428
+ const nextKeyIndex = url$1.indexOf("&", keyIndex + 1);
429
+ let valueIndex = url$1.indexOf("=", keyIndex);
430
+ if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
431
+ let name = url$1.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
432
+ if (encoded) name = _decodeURI(name);
433
+ keyIndex = nextKeyIndex;
434
+ if (name === "") continue;
435
+ let value;
436
+ if (valueIndex === -1) value = "";
437
+ else {
438
+ value = url$1.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
439
+ if (encoded) value = _decodeURI(value);
440
+ }
441
+ if (multiple) {
442
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
443
+ results[name].push(value);
444
+ } else results[name] ??= value;
445
+ }
446
+ return key ? results[key] : results;
447
+ };
448
+ var getQueryParam = _getQueryParam;
449
+ var getQueryParams = (url$1, key) => {
450
+ return _getQueryParam(url$1, key, true);
451
+ };
452
+ var decodeURIComponent_ = decodeURIComponent;
453
+
454
+ //#endregion
455
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/request.js
456
+ var HonoRequest = class {
457
+ raw;
458
+ #validatedData;
459
+ #matchResult;
460
+ routeIndex = 0;
461
+ path;
462
+ bodyCache = {};
463
+ constructor(request, path$2 = "/", matchResult = [[]]) {
464
+ this.raw = request;
465
+ this.path = path$2;
466
+ this.#matchResult = matchResult;
467
+ this.#validatedData = {};
468
+ }
469
+ param(key) {
470
+ return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
471
+ }
472
+ getDecodedParam(key) {
473
+ const paramKey = this.#matchResult[0][this.routeIndex][1][key];
474
+ const param = this.getParamValue(paramKey);
475
+ return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
476
+ }
477
+ getAllDecodedParams() {
478
+ const decoded = {};
479
+ const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
480
+ for (const key of keys) {
481
+ const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
482
+ if (value && typeof value === "string") decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
483
+ }
484
+ return decoded;
485
+ }
486
+ getParamValue(paramKey) {
487
+ return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
488
+ }
489
+ query(key) {
490
+ return getQueryParam(this.url, key);
491
+ }
492
+ queries(key) {
493
+ return getQueryParams(this.url, key);
494
+ }
495
+ header(name) {
496
+ if (name) return this.raw.headers.get(name.toLowerCase()) ?? void 0;
497
+ const headerData = {};
498
+ this.raw.headers.forEach((value, key) => {
499
+ headerData[key] = value;
500
+ });
501
+ return headerData;
502
+ }
503
+ async parseBody(options) {
504
+ return this.bodyCache.parsedBody ??= await parseBody(this, options);
505
+ }
506
+ cachedBody = (key) => {
507
+ const { bodyCache, raw: raw$1 } = this;
508
+ const cachedBody = bodyCache[key];
509
+ if (cachedBody) return cachedBody;
510
+ const anyCachedKey = Object.keys(bodyCache)[0];
511
+ if (anyCachedKey) return bodyCache[anyCachedKey].then((body) => {
512
+ if (anyCachedKey === "json") body = JSON.stringify(body);
513
+ return new Response(body)[key]();
514
+ });
515
+ return bodyCache[key] = raw$1[key]();
516
+ };
517
+ json() {
518
+ return this.cachedBody("json");
519
+ }
520
+ text() {
521
+ return this.cachedBody("text");
522
+ }
523
+ arrayBuffer() {
524
+ return this.cachedBody("arrayBuffer");
525
+ }
526
+ blob() {
527
+ return this.cachedBody("blob");
528
+ }
529
+ formData() {
530
+ return this.cachedBody("formData");
531
+ }
532
+ addValidatedData(target, data) {
533
+ this.#validatedData[target] = data;
534
+ }
535
+ valid(target) {
536
+ return this.#validatedData[target];
537
+ }
538
+ get url() {
539
+ return this.raw.url;
540
+ }
541
+ get method() {
542
+ return this.raw.method;
543
+ }
544
+ get matchedRoutes() {
545
+ return this.#matchResult[0].map(([[, route]]) => route);
546
+ }
547
+ get routePath() {
548
+ return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
549
+ }
550
+ };
551
+
552
+ //#endregion
553
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/html.js
554
+ var HtmlEscapedCallbackPhase = {
555
+ Stringify: 1,
556
+ BeforeStream: 2,
557
+ Stream: 3
558
+ };
559
+ var raw = (value, callbacks) => {
560
+ const escapedString = new String(value);
561
+ escapedString.isEscaped = true;
562
+ escapedString.callbacks = callbacks;
563
+ return escapedString;
564
+ };
565
+ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
566
+ if (typeof str === "object" && !(str instanceof String)) {
567
+ if (!(str instanceof Promise)) str = str.toString();
568
+ if (str instanceof Promise) str = await str;
569
+ }
570
+ const callbacks = str.callbacks;
571
+ if (!callbacks?.length) return Promise.resolve(str);
572
+ if (buffer) buffer[0] += str;
573
+ else buffer = [str];
574
+ const resStr = Promise.all(callbacks.map((c) => c({
575
+ phase,
576
+ buffer,
577
+ context
578
+ }))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
579
+ if (preserveCallbacks) return raw(await resStr, callbacks);
580
+ else return resStr;
581
+ };
582
+
583
+ //#endregion
584
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/context.js
585
+ var TEXT_PLAIN = "text/plain; charset=UTF-8";
586
+ var setHeaders = (headers, map = {}) => {
587
+ Object.entries(map).forEach(([key, value]) => headers.set(key, value));
588
+ return headers;
589
+ };
590
+ var Context = class {
591
+ #rawRequest;
592
+ #req;
593
+ env = {};
594
+ #var;
595
+ finalized = false;
596
+ error;
597
+ #status = 200;
598
+ #executionCtx;
599
+ #headers;
600
+ #preparedHeaders;
601
+ #res;
602
+ #isFresh = true;
603
+ #layout;
604
+ #renderer;
605
+ #notFoundHandler;
606
+ #matchResult;
607
+ #path;
608
+ constructor(req, options) {
609
+ this.#rawRequest = req;
610
+ if (options) {
611
+ this.#executionCtx = options.executionCtx;
612
+ this.env = options.env;
613
+ this.#notFoundHandler = options.notFoundHandler;
614
+ this.#path = options.path;
615
+ this.#matchResult = options.matchResult;
616
+ }
617
+ }
618
+ get req() {
619
+ this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
620
+ return this.#req;
621
+ }
622
+ get event() {
623
+ if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
624
+ else throw Error("This context has no FetchEvent");
625
+ }
626
+ get executionCtx() {
627
+ if (this.#executionCtx) return this.#executionCtx;
628
+ else throw Error("This context has no ExecutionContext");
629
+ }
630
+ get res() {
631
+ this.#isFresh = false;
632
+ return this.#res ||= new Response("404 Not Found", { status: 404 });
633
+ }
634
+ set res(_res) {
635
+ this.#isFresh = false;
636
+ if (this.#res && _res) try {
637
+ for (const [k, v] of this.#res.headers.entries()) {
638
+ if (k === "content-type") continue;
639
+ if (k === "set-cookie") {
640
+ const cookies = this.#res.headers.getSetCookie();
641
+ _res.headers.delete("set-cookie");
642
+ for (const cookie of cookies) _res.headers.append("set-cookie", cookie);
643
+ } else _res.headers.set(k, v);
644
+ }
645
+ } catch (e) {
646
+ if (e instanceof TypeError && e.message.includes("immutable")) {
647
+ this.res = new Response(_res.body, {
648
+ headers: _res.headers,
649
+ status: _res.status
650
+ });
651
+ return;
652
+ } else throw e;
653
+ }
654
+ this.#res = _res;
655
+ this.finalized = true;
656
+ }
657
+ render = (...args) => {
658
+ this.#renderer ??= (content) => this.html(content);
659
+ return this.#renderer(...args);
660
+ };
661
+ setLayout = (layout) => this.#layout = layout;
662
+ getLayout = () => this.#layout;
663
+ setRenderer = (renderer) => {
664
+ this.#renderer = renderer;
665
+ };
666
+ header = (name, value, options) => {
667
+ if (value === void 0) {
668
+ if (this.#headers) this.#headers.delete(name);
669
+ else if (this.#preparedHeaders) delete this.#preparedHeaders[name.toLocaleLowerCase()];
670
+ if (this.finalized) this.res.headers.delete(name);
671
+ return;
672
+ }
673
+ if (options?.append) {
674
+ if (!this.#headers) {
675
+ this.#isFresh = false;
676
+ this.#headers = new Headers(this.#preparedHeaders);
677
+ this.#preparedHeaders = {};
678
+ }
679
+ this.#headers.append(name, value);
680
+ } else if (this.#headers) this.#headers.set(name, value);
681
+ else {
682
+ this.#preparedHeaders ??= {};
683
+ this.#preparedHeaders[name.toLowerCase()] = value;
684
+ }
685
+ if (this.finalized) if (options?.append) this.res.headers.append(name, value);
686
+ else this.res.headers.set(name, value);
687
+ };
688
+ status = (status) => {
689
+ this.#isFresh = false;
690
+ this.#status = status;
691
+ };
692
+ set = (key, value) => {
693
+ this.#var ??= /* @__PURE__ */ new Map();
694
+ this.#var.set(key, value);
695
+ };
696
+ get = (key) => {
697
+ return this.#var ? this.#var.get(key) : void 0;
698
+ };
699
+ get var() {
700
+ if (!this.#var) return {};
701
+ return Object.fromEntries(this.#var);
702
+ }
703
+ newResponse = (data, arg, headers) => {
704
+ if (this.#isFresh && !headers && !arg && this.#status === 200) return new Response(data, { headers: this.#preparedHeaders });
705
+ if (arg && typeof arg !== "number") {
706
+ const header = new Headers(arg.headers);
707
+ if (this.#headers) this.#headers.forEach((v, k) => {
708
+ if (k === "set-cookie") header.append(k, v);
709
+ else header.set(k, v);
710
+ });
711
+ const headers2 = setHeaders(header, this.#preparedHeaders);
712
+ return new Response(data, {
713
+ headers: headers2,
714
+ status: arg.status ?? this.#status
715
+ });
716
+ }
717
+ const status = typeof arg === "number" ? arg : this.#status;
718
+ this.#preparedHeaders ??= {};
719
+ this.#headers ??= new Headers();
720
+ setHeaders(this.#headers, this.#preparedHeaders);
721
+ if (this.#res) {
722
+ this.#res.headers.forEach((v, k) => {
723
+ if (k === "set-cookie") this.#headers?.append(k, v);
724
+ else this.#headers?.set(k, v);
725
+ });
726
+ setHeaders(this.#headers, this.#preparedHeaders);
727
+ }
728
+ headers ??= {};
729
+ for (const [k, v] of Object.entries(headers)) if (typeof v === "string") this.#headers.set(k, v);
730
+ else {
731
+ this.#headers.delete(k);
732
+ for (const v2 of v) this.#headers.append(k, v2);
733
+ }
734
+ return new Response(data, {
735
+ status,
736
+ headers: this.#headers
737
+ });
738
+ };
739
+ body = (data, arg, headers) => {
740
+ return typeof arg === "number" ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
741
+ };
742
+ text = (text, arg, headers) => {
743
+ if (!this.#preparedHeaders) {
744
+ if (this.#isFresh && !headers && !arg) return new Response(text);
745
+ this.#preparedHeaders = {};
746
+ }
747
+ this.#preparedHeaders["content-type"] = TEXT_PLAIN;
748
+ return typeof arg === "number" ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
749
+ };
750
+ json = (object, arg, headers) => {
751
+ const body = JSON.stringify(object);
752
+ this.#preparedHeaders ??= {};
753
+ this.#preparedHeaders["content-type"] = "application/json; charset=UTF-8";
754
+ return typeof arg === "number" ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
755
+ };
756
+ html = (html, arg, headers) => {
757
+ this.#preparedHeaders ??= {};
758
+ this.#preparedHeaders["content-type"] = "text/html; charset=UTF-8";
759
+ if (typeof html === "object") return resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then((html2) => {
760
+ return typeof arg === "number" ? this.newResponse(html2, arg, headers) : this.newResponse(html2, arg);
761
+ });
762
+ return typeof arg === "number" ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
763
+ };
764
+ redirect = (location, status) => {
765
+ this.#headers ??= new Headers();
766
+ this.#headers.set("Location", location);
767
+ return this.newResponse(null, status ?? 302);
768
+ };
769
+ notFound = () => {
770
+ this.#notFoundHandler ??= () => new Response();
771
+ return this.#notFoundHandler(this);
772
+ };
773
+ };
774
+
775
+ //#endregion
776
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/compose.js
777
+ var compose = (middleware, onError, onNotFound) => {
778
+ return (context, next) => {
779
+ let index = -1;
780
+ return dispatch(0);
781
+ async function dispatch(i) {
782
+ if (i <= index) throw new Error("next() called multiple times");
783
+ index = i;
784
+ let res;
785
+ let isError = false;
786
+ let handler;
787
+ if (middleware[i]) {
788
+ handler = middleware[i][0][0];
789
+ if (context instanceof Context) context.req.routeIndex = i;
790
+ } else handler = i === middleware.length && next || void 0;
791
+ if (!handler) {
792
+ if (context instanceof Context && context.finalized === false && onNotFound) res = await onNotFound(context);
793
+ } else try {
794
+ res = await handler(context, () => {
795
+ return dispatch(i + 1);
796
+ });
797
+ } catch (err) {
798
+ if (err instanceof Error && context instanceof Context && onError) {
799
+ context.error = err;
800
+ res = await onError(err, context);
801
+ isError = true;
802
+ } else throw err;
803
+ }
804
+ if (res && (context.finalized === false || isError)) context.res = res;
805
+ return context;
806
+ }
807
+ };
808
+ };
809
+
810
+ //#endregion
811
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router.js
812
+ var METHOD_NAME_ALL = "ALL";
813
+ var METHOD_NAME_ALL_LOWERCASE = "all";
814
+ var METHODS = [
815
+ "get",
816
+ "post",
817
+ "put",
818
+ "delete",
819
+ "options",
820
+ "patch"
821
+ ];
822
+ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
823
+ var UnsupportedPathError = class extends Error {};
824
+
825
+ //#endregion
826
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/hono-base.js
827
+ var COMPOSED_HANDLER = Symbol("composedHandler");
828
+ var notFoundHandler = (c) => {
829
+ return c.text("404 Not Found", 404);
830
+ };
831
+ var errorHandler = (err, c) => {
832
+ if ("getResponse" in err) return err.getResponse();
833
+ console.error(err);
834
+ return c.text("Internal Server Error", 500);
835
+ };
836
+ var Hono$1 = class {
837
+ get;
838
+ post;
839
+ put;
840
+ delete;
841
+ options;
842
+ patch;
843
+ all;
844
+ on;
845
+ use;
846
+ router;
847
+ getPath;
848
+ _basePath = "/";
849
+ #path = "/";
850
+ routes = [];
851
+ constructor(options = {}) {
852
+ const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
853
+ allMethods.forEach((method) => {
854
+ this[method] = (args1, ...args) => {
855
+ if (typeof args1 === "string") this.#path = args1;
856
+ else this.addRoute(method, this.#path, args1);
857
+ args.forEach((handler) => {
858
+ if (typeof handler !== "string") this.addRoute(method, this.#path, handler);
859
+ });
860
+ return this;
861
+ };
862
+ });
863
+ this.on = (method, path$2, ...handlers) => {
864
+ for (const p of [path$2].flat()) {
865
+ this.#path = p;
866
+ for (const m of [method].flat()) handlers.map((handler) => {
867
+ this.addRoute(m.toUpperCase(), this.#path, handler);
868
+ });
869
+ }
870
+ return this;
871
+ };
872
+ this.use = (arg1, ...handlers) => {
873
+ if (typeof arg1 === "string") this.#path = arg1;
874
+ else {
875
+ this.#path = "*";
876
+ handlers.unshift(arg1);
877
+ }
878
+ handlers.forEach((handler) => {
879
+ this.addRoute(METHOD_NAME_ALL, this.#path, handler);
880
+ });
881
+ return this;
882
+ };
883
+ const strict = options.strict ?? true;
884
+ delete options.strict;
885
+ Object.assign(this, options);
886
+ this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
887
+ }
888
+ clone() {
889
+ const clone = new Hono$1({
890
+ router: this.router,
891
+ getPath: this.getPath
892
+ });
893
+ clone.routes = this.routes;
894
+ return clone;
895
+ }
896
+ notFoundHandler = notFoundHandler;
897
+ errorHandler = errorHandler;
898
+ route(path$2, app$1) {
899
+ const subApp = this.basePath(path$2);
900
+ app$1.routes.map((r) => {
901
+ let handler;
902
+ if (app$1.errorHandler === errorHandler) handler = r.handler;
903
+ else {
904
+ handler = async (c, next) => (await compose([], app$1.errorHandler)(c, () => r.handler(c, next))).res;
905
+ handler[COMPOSED_HANDLER] = r.handler;
906
+ }
907
+ subApp.addRoute(r.method, r.path, handler);
908
+ });
909
+ return this;
910
+ }
911
+ basePath(path$2) {
912
+ const subApp = this.clone();
913
+ subApp._basePath = mergePath(this._basePath, path$2);
914
+ return subApp;
915
+ }
916
+ onError = (handler) => {
917
+ this.errorHandler = handler;
918
+ return this;
919
+ };
920
+ notFound = (handler) => {
921
+ this.notFoundHandler = handler;
922
+ return this;
923
+ };
924
+ mount(path$2, applicationHandler, options) {
925
+ let replaceRequest;
926
+ let optionHandler;
927
+ if (options) if (typeof options === "function") optionHandler = options;
928
+ else {
929
+ optionHandler = options.optionHandler;
930
+ replaceRequest = options.replaceRequest;
931
+ }
932
+ const getOptions = optionHandler ? (c) => {
933
+ const options2 = optionHandler(c);
934
+ return Array.isArray(options2) ? options2 : [options2];
935
+ } : (c) => {
936
+ let executionContext = void 0;
937
+ try {
938
+ executionContext = c.executionCtx;
939
+ } catch {}
940
+ return [c.env, executionContext];
941
+ };
942
+ replaceRequest ||= (() => {
943
+ const mergedPath = mergePath(this._basePath, path$2);
944
+ const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
945
+ return (request) => {
946
+ const url$1 = new URL(request.url);
947
+ url$1.pathname = url$1.pathname.slice(pathPrefixLength) || "/";
948
+ return new Request(url$1, request);
949
+ };
950
+ })();
951
+ const handler = async (c, next) => {
952
+ const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
953
+ if (res) return res;
954
+ await next();
955
+ };
956
+ this.addRoute(METHOD_NAME_ALL, mergePath(path$2, "*"), handler);
957
+ return this;
958
+ }
959
+ addRoute(method, path$2, handler) {
960
+ method = method.toUpperCase();
961
+ path$2 = mergePath(this._basePath, path$2);
962
+ const r = {
963
+ path: path$2,
964
+ method,
965
+ handler
966
+ };
967
+ this.router.add(method, path$2, [handler, r]);
968
+ this.routes.push(r);
969
+ }
970
+ matchRoute(method, path$2) {
971
+ return this.router.match(method, path$2);
972
+ }
973
+ handleError(err, c) {
974
+ if (err instanceof Error) return this.errorHandler(err, c);
975
+ throw err;
976
+ }
977
+ dispatch(request, executionCtx, env, method) {
978
+ if (method === "HEAD") return (async () => new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
979
+ const path$2 = this.getPath(request, { env });
980
+ const matchResult = this.matchRoute(method, path$2);
981
+ const c = new Context(request, {
982
+ path: path$2,
983
+ matchResult,
984
+ env,
985
+ executionCtx,
986
+ notFoundHandler: this.notFoundHandler
987
+ });
988
+ if (matchResult[0].length === 1) {
989
+ let res;
990
+ try {
991
+ res = matchResult[0][0][0][0](c, async () => {
992
+ c.res = await this.notFoundHandler(c);
993
+ });
994
+ } catch (err) {
995
+ return this.handleError(err, c);
996
+ }
997
+ 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);
998
+ }
999
+ const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
1000
+ return (async () => {
1001
+ try {
1002
+ const context = await composed(c);
1003
+ if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
1004
+ return context.res;
1005
+ } catch (err) {
1006
+ return this.handleError(err, c);
1007
+ }
1008
+ })();
1009
+ }
1010
+ fetch = (request, ...rest) => {
1011
+ return this.dispatch(request, rest[1], rest[0], request.method);
1012
+ };
1013
+ request = (input, requestInit, Env, executionCtx) => {
1014
+ if (input instanceof Request) {
1015
+ if (requestInit !== void 0) input = new Request(input, requestInit);
1016
+ return this.fetch(input, Env, executionCtx);
1017
+ }
1018
+ input = input.toString();
1019
+ const path$2 = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`;
1020
+ const req = new Request(path$2, requestInit);
1021
+ return this.fetch(req, Env, executionCtx);
1022
+ };
1023
+ fire = () => {
1024
+ addEventListener("fetch", (event) => {
1025
+ event.respondWith(this.dispatch(event.request, event, void 0, event.request.method));
1026
+ });
1027
+ };
1028
+ };
1029
+
1030
+ //#endregion
1031
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/reg-exp-router/node.js
1032
+ var LABEL_REG_EXP_STR = "[^/]+";
1033
+ var ONLY_WILDCARD_REG_EXP_STR = ".*";
1034
+ var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1035
+ var PATH_ERROR = Symbol();
1036
+ var regExpMetaChars = new Set(".\\+*[^]$()");
1037
+ function compareKey(a, b) {
1038
+ if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
1039
+ if (b.length === 1) return 1;
1040
+ if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) return 1;
1041
+ else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) return -1;
1042
+ if (a === LABEL_REG_EXP_STR) return 1;
1043
+ else if (b === LABEL_REG_EXP_STR) return -1;
1044
+ return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
1045
+ }
1046
+ var Node$1 = class {
1047
+ index;
1048
+ varIndex;
1049
+ children = /* @__PURE__ */ Object.create(null);
1050
+ insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
1051
+ if (tokens.length === 0) {
1052
+ if (this.index !== void 0) throw PATH_ERROR;
1053
+ if (pathErrorCheckOnly) return;
1054
+ this.index = index;
1055
+ return;
1056
+ }
1057
+ const [token, ...restTokens] = tokens;
1058
+ const pattern = token === "*" ? restTokens.length === 0 ? [
1059
+ "",
1060
+ "",
1061
+ ONLY_WILDCARD_REG_EXP_STR
1062
+ ] : [
1063
+ "",
1064
+ "",
1065
+ LABEL_REG_EXP_STR
1066
+ ] : token === "/*" ? [
1067
+ "",
1068
+ "",
1069
+ TAIL_WILDCARD_REG_EXP_STR
1070
+ ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1071
+ let node;
1072
+ if (pattern) {
1073
+ const name = pattern[1];
1074
+ let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
1075
+ if (name && pattern[2]) {
1076
+ regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1077
+ if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1078
+ }
1079
+ node = this.children[regexpStr];
1080
+ if (!node) {
1081
+ if (Object.keys(this.children).some((k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1082
+ if (pathErrorCheckOnly) return;
1083
+ node = this.children[regexpStr] = new Node$1();
1084
+ if (name !== "") node.varIndex = context.varIndex++;
1085
+ }
1086
+ if (!pathErrorCheckOnly && name !== "") paramMap.push([name, node.varIndex]);
1087
+ } else {
1088
+ node = this.children[token];
1089
+ if (!node) {
1090
+ 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;
1091
+ if (pathErrorCheckOnly) return;
1092
+ node = this.children[token] = new Node$1();
1093
+ }
1094
+ }
1095
+ node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
1096
+ }
1097
+ buildRegExpStr() {
1098
+ const childKeys = Object.keys(this.children).sort(compareKey);
1099
+ const strList = childKeys.map((k) => {
1100
+ const c = this.children[k];
1101
+ return (typeof c.varIndex === "number" ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
1102
+ });
1103
+ if (typeof this.index === "number") strList.unshift(`#${this.index}`);
1104
+ if (strList.length === 0) return "";
1105
+ if (strList.length === 1) return strList[0];
1106
+ return "(?:" + strList.join("|") + ")";
1107
+ }
1108
+ };
1109
+
1110
+ //#endregion
1111
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/reg-exp-router/trie.js
1112
+ var Trie = class {
1113
+ context = { varIndex: 0 };
1114
+ root = new Node$1();
1115
+ insert(path$2, index, pathErrorCheckOnly) {
1116
+ const paramAssoc = [];
1117
+ const groups = [];
1118
+ for (let i = 0;;) {
1119
+ let replaced = false;
1120
+ path$2 = path$2.replace(/\{[^}]+\}/g, (m) => {
1121
+ const mark = `@\\${i}`;
1122
+ groups[i] = [mark, m];
1123
+ i++;
1124
+ replaced = true;
1125
+ return mark;
1126
+ });
1127
+ if (!replaced) break;
1128
+ }
1129
+ const tokens = path$2.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1130
+ for (let i = groups.length - 1; i >= 0; i--) {
1131
+ const [mark] = groups[i];
1132
+ for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
1133
+ tokens[j] = tokens[j].replace(mark, groups[i][1]);
1134
+ break;
1135
+ }
1136
+ }
1137
+ this.root.insert(tokens, index, paramAssoc, this.context, pathErrorCheckOnly);
1138
+ return paramAssoc;
1139
+ }
1140
+ buildRegExp() {
1141
+ let regexp = this.root.buildRegExpStr();
1142
+ if (regexp === "") return [
1143
+ /^$/,
1144
+ [],
1145
+ []
1146
+ ];
1147
+ let captureIndex = 0;
1148
+ const indexReplacementMap = [];
1149
+ const paramReplacementMap = [];
1150
+ regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex) => {
1151
+ if (typeof handlerIndex !== "undefined") {
1152
+ indexReplacementMap[++captureIndex] = Number(handlerIndex);
1153
+ return "$()";
1154
+ }
1155
+ if (typeof paramIndex !== "undefined") {
1156
+ paramReplacementMap[Number(paramIndex)] = ++captureIndex;
1157
+ return "";
1158
+ }
1159
+ return "";
1160
+ });
1161
+ return [
1162
+ new RegExp(`^${regexp}`),
1163
+ indexReplacementMap,
1164
+ paramReplacementMap
1165
+ ];
1166
+ }
1167
+ };
1168
+
1169
+ //#endregion
1170
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/reg-exp-router/router.js
1171
+ var emptyParam = [];
1172
+ var nullMatcher = [
1173
+ /^$/,
1174
+ [],
1175
+ /* @__PURE__ */ Object.create(null)
1176
+ ];
1177
+ var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1178
+ function buildWildcardRegExp(path$2) {
1179
+ return wildcardRegExpCache[path$2] ??= new RegExp(path$2 === "*" ? "" : `^${path$2.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
1180
+ }
1181
+ function clearWildcardRegExpCache() {
1182
+ wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1183
+ }
1184
+ function buildMatcherFromPreprocessedRoutes(routes) {
1185
+ const trie = new Trie();
1186
+ const handlerData = [];
1187
+ if (routes.length === 0) return nullMatcher;
1188
+ const routesWithStaticPathFlag = routes.map((route) => [!/\*|\/:/.test(route[0]), ...route]).sort(([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
1189
+ const staticMap = /* @__PURE__ */ Object.create(null);
1190
+ for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
1191
+ const [pathErrorCheckOnly, path$2, handlers] = routesWithStaticPathFlag[i];
1192
+ if (pathErrorCheckOnly) staticMap[path$2] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
1193
+ else j++;
1194
+ let paramAssoc;
1195
+ try {
1196
+ paramAssoc = trie.insert(path$2, j, pathErrorCheckOnly);
1197
+ } catch (e) {
1198
+ throw e === PATH_ERROR ? new UnsupportedPathError(path$2) : e;
1199
+ }
1200
+ if (pathErrorCheckOnly) continue;
1201
+ handlerData[j] = handlers.map(([h, paramCount]) => {
1202
+ const paramIndexMap = /* @__PURE__ */ Object.create(null);
1203
+ paramCount -= 1;
1204
+ for (; paramCount >= 0; paramCount--) {
1205
+ const [key, value] = paramAssoc[paramCount];
1206
+ paramIndexMap[key] = value;
1207
+ }
1208
+ return [h, paramIndexMap];
1209
+ });
1210
+ }
1211
+ const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1212
+ for (let i = 0, len = handlerData.length; i < len; i++) for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
1213
+ const map = handlerData[i][j]?.[1];
1214
+ if (!map) continue;
1215
+ const keys = Object.keys(map);
1216
+ for (let k = 0, len3 = keys.length; k < len3; k++) map[keys[k]] = paramReplacementMap[map[keys[k]]];
1217
+ }
1218
+ const handlerMap = [];
1219
+ for (const i in indexReplacementMap) handlerMap[i] = handlerData[indexReplacementMap[i]];
1220
+ return [
1221
+ regexp,
1222
+ handlerMap,
1223
+ staticMap
1224
+ ];
1225
+ }
1226
+ function findMiddleware(middleware, path$2) {
1227
+ if (!middleware) return void 0;
1228
+ for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path$2)) return [...middleware[k]];
1229
+ return void 0;
1230
+ }
1231
+ var RegExpRouter = class {
1232
+ name = "RegExpRouter";
1233
+ middleware;
1234
+ routes;
1235
+ constructor() {
1236
+ this.middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1237
+ this.routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
1238
+ }
1239
+ add(method, path$2, handler) {
1240
+ const { middleware, routes } = this;
1241
+ if (!middleware || !routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1242
+ if (!middleware[method]) [middleware, routes].forEach((handlerMap) => {
1243
+ handlerMap[method] = /* @__PURE__ */ Object.create(null);
1244
+ Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
1245
+ handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
1246
+ });
1247
+ });
1248
+ if (path$2 === "/*") path$2 = "*";
1249
+ const paramCount = (path$2.match(/\/:/g) || []).length;
1250
+ if (/\*$/.test(path$2)) {
1251
+ const re = buildWildcardRegExp(path$2);
1252
+ if (method === METHOD_NAME_ALL) Object.keys(middleware).forEach((m) => {
1253
+ middleware[m][path$2] ||= findMiddleware(middleware[m], path$2) || findMiddleware(middleware[METHOD_NAME_ALL], path$2) || [];
1254
+ });
1255
+ else middleware[method][path$2] ||= findMiddleware(middleware[method], path$2) || findMiddleware(middleware[METHOD_NAME_ALL], path$2) || [];
1256
+ Object.keys(middleware).forEach((m) => {
1257
+ if (method === METHOD_NAME_ALL || method === m) Object.keys(middleware[m]).forEach((p) => {
1258
+ re.test(p) && middleware[m][p].push([handler, paramCount]);
1259
+ });
1260
+ });
1261
+ Object.keys(routes).forEach((m) => {
1262
+ if (method === METHOD_NAME_ALL || method === m) Object.keys(routes[m]).forEach((p) => re.test(p) && routes[m][p].push([handler, paramCount]));
1263
+ });
1264
+ return;
1265
+ }
1266
+ const paths = checkOptionalParameter(path$2) || [path$2];
1267
+ for (let i = 0, len = paths.length; i < len; i++) {
1268
+ const path2 = paths[i];
1269
+ Object.keys(routes).forEach((m) => {
1270
+ if (method === METHOD_NAME_ALL || method === m) {
1271
+ routes[m][path2] ||= [...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []];
1272
+ routes[m][path2].push([handler, paramCount - len + i + 1]);
1273
+ }
1274
+ });
1275
+ }
1276
+ }
1277
+ match(method, path$2) {
1278
+ clearWildcardRegExpCache();
1279
+ const matchers = this.buildAllMatchers();
1280
+ this.match = (method2, path2) => {
1281
+ const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
1282
+ const staticMatch = matcher[2][path2];
1283
+ if (staticMatch) return staticMatch;
1284
+ const match = path2.match(matcher[0]);
1285
+ if (!match) return [[], emptyParam];
1286
+ const index = match.indexOf("", 1);
1287
+ return [matcher[1][index], match];
1288
+ };
1289
+ return this.match(method, path$2);
1290
+ }
1291
+ buildAllMatchers() {
1292
+ const matchers = /* @__PURE__ */ Object.create(null);
1293
+ [...Object.keys(this.routes), ...Object.keys(this.middleware)].forEach((method) => {
1294
+ matchers[method] ||= this.buildMatcher(method);
1295
+ });
1296
+ this.middleware = this.routes = void 0;
1297
+ return matchers;
1298
+ }
1299
+ buildMatcher(method) {
1300
+ const routes = [];
1301
+ let hasOwnRoute = method === METHOD_NAME_ALL;
1302
+ [this.middleware, this.routes].forEach((r) => {
1303
+ const ownRoute = r[method] ? Object.keys(r[method]).map((path$2) => [path$2, r[method][path$2]]) : [];
1304
+ if (ownRoute.length !== 0) {
1305
+ hasOwnRoute ||= true;
1306
+ routes.push(...ownRoute);
1307
+ } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path$2) => [path$2, r[METHOD_NAME_ALL][path$2]]));
1308
+ });
1309
+ if (!hasOwnRoute) return null;
1310
+ else return buildMatcherFromPreprocessedRoutes(routes);
1311
+ }
1312
+ };
1313
+
1314
+ //#endregion
1315
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/smart-router/router.js
1316
+ var SmartRouter = class {
1317
+ name = "SmartRouter";
1318
+ routers = [];
1319
+ routes = [];
1320
+ constructor(init) {
1321
+ Object.assign(this, init);
1322
+ }
1323
+ add(method, path$2, handler) {
1324
+ if (!this.routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1325
+ this.routes.push([
1326
+ method,
1327
+ path$2,
1328
+ handler
1329
+ ]);
1330
+ }
1331
+ match(method, path$2) {
1332
+ if (!this.routes) throw new Error("Fatal error");
1333
+ const { routers, routes } = this;
1334
+ const len = routers.length;
1335
+ let i = 0;
1336
+ let res;
1337
+ for (; i < len; i++) {
1338
+ const router = routers[i];
1339
+ try {
1340
+ routes.forEach((args) => {
1341
+ router.add(...args);
1342
+ });
1343
+ res = router.match(method, path$2);
1344
+ } catch (e) {
1345
+ if (e instanceof UnsupportedPathError) continue;
1346
+ throw e;
1347
+ }
1348
+ this.match = router.match.bind(router);
1349
+ this.routers = [router];
1350
+ this.routes = void 0;
1351
+ break;
1352
+ }
1353
+ if (i === len) throw new Error("Fatal error");
1354
+ this.name = `SmartRouter + ${this.activeRouter.name}`;
1355
+ return res;
1356
+ }
1357
+ get activeRouter() {
1358
+ if (this.routes || this.routers.length !== 1) throw new Error("No active router has been determined yet.");
1359
+ return this.routers[0];
1360
+ }
1361
+ };
1362
+
1363
+ //#endregion
1364
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/trie-router/node.js
1365
+ var Node = class {
1366
+ methods;
1367
+ children;
1368
+ patterns;
1369
+ order = 0;
1370
+ name;
1371
+ params = /* @__PURE__ */ Object.create(null);
1372
+ constructor(method, handler, children) {
1373
+ this.children = children || /* @__PURE__ */ Object.create(null);
1374
+ this.methods = [];
1375
+ this.name = "";
1376
+ if (method && handler) {
1377
+ const m = /* @__PURE__ */ Object.create(null);
1378
+ m[method] = {
1379
+ handler,
1380
+ possibleKeys: [],
1381
+ score: 0,
1382
+ name: this.name
1383
+ };
1384
+ this.methods = [m];
1385
+ }
1386
+ this.patterns = [];
1387
+ }
1388
+ insert(method, path$2, handler) {
1389
+ this.name = `${method} ${path$2}`;
1390
+ this.order = ++this.order;
1391
+ let curNode = this;
1392
+ const parts = splitRoutingPath(path$2);
1393
+ const possibleKeys = [];
1394
+ for (let i = 0, len = parts.length; i < len; i++) {
1395
+ const p = parts[i];
1396
+ if (Object.keys(curNode.children).includes(p)) {
1397
+ curNode = curNode.children[p];
1398
+ const pattern2 = getPattern(p);
1399
+ if (pattern2) possibleKeys.push(pattern2[1]);
1400
+ continue;
1401
+ }
1402
+ curNode.children[p] = new Node();
1403
+ const pattern = getPattern(p);
1404
+ if (pattern) {
1405
+ curNode.patterns.push(pattern);
1406
+ possibleKeys.push(pattern[1]);
1407
+ }
1408
+ curNode = curNode.children[p];
1409
+ }
1410
+ if (!curNode.methods.length) curNode.methods = [];
1411
+ const m = /* @__PURE__ */ Object.create(null);
1412
+ const handlerSet = {
1413
+ handler,
1414
+ possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
1415
+ name: this.name,
1416
+ score: this.order
1417
+ };
1418
+ m[method] = handlerSet;
1419
+ curNode.methods.push(m);
1420
+ return curNode;
1421
+ }
1422
+ gHSets(node, method, nodeParams, params) {
1423
+ const handlerSets = [];
1424
+ for (let i = 0, len = node.methods.length; i < len; i++) {
1425
+ const m = node.methods[i];
1426
+ const handlerSet = m[method] || m[METHOD_NAME_ALL];
1427
+ const processedSet = /* @__PURE__ */ Object.create(null);
1428
+ if (handlerSet !== void 0) {
1429
+ handlerSet.params = /* @__PURE__ */ Object.create(null);
1430
+ handlerSet.possibleKeys.forEach((key) => {
1431
+ const processed = processedSet[handlerSet.name];
1432
+ handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
1433
+ processedSet[handlerSet.name] = true;
1434
+ });
1435
+ handlerSets.push(handlerSet);
1436
+ }
1437
+ }
1438
+ return handlerSets;
1439
+ }
1440
+ search(method, path$2) {
1441
+ const handlerSets = [];
1442
+ this.params = /* @__PURE__ */ Object.create(null);
1443
+ const curNode = this;
1444
+ let curNodes = [curNode];
1445
+ const parts = splitPath(path$2);
1446
+ for (let i = 0, len = parts.length; i < len; i++) {
1447
+ const part = parts[i];
1448
+ const isLast = i === len - 1;
1449
+ const tempNodes = [];
1450
+ for (let j = 0, len2 = curNodes.length; j < len2; j++) {
1451
+ const node = curNodes[j];
1452
+ const nextNode = node.children[part];
1453
+ if (nextNode) {
1454
+ nextNode.params = node.params;
1455
+ if (isLast === true) {
1456
+ if (nextNode.children["*"]) handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null)));
1457
+ handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1458
+ } else tempNodes.push(nextNode);
1459
+ }
1460
+ for (let k = 0, len3 = node.patterns.length; k < len3; k++) {
1461
+ const pattern = node.patterns[k];
1462
+ const params = { ...node.params };
1463
+ if (pattern === "*") {
1464
+ const astNode = node.children["*"];
1465
+ if (astNode) {
1466
+ handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1467
+ tempNodes.push(astNode);
1468
+ }
1469
+ continue;
1470
+ }
1471
+ if (part === "") continue;
1472
+ const [key, name, matcher] = pattern;
1473
+ const child = node.children[key];
1474
+ const restPathString = parts.slice(i).join("/");
1475
+ if (matcher instanceof RegExp && matcher.test(restPathString)) {
1476
+ params[name] = restPathString;
1477
+ handlerSets.push(...this.gHSets(child, method, node.params, params));
1478
+ continue;
1479
+ }
1480
+ if (matcher === true || matcher instanceof RegExp && matcher.test(part)) {
1481
+ if (typeof key === "string") {
1482
+ params[name] = part;
1483
+ if (isLast === true) {
1484
+ handlerSets.push(...this.gHSets(child, method, params, node.params));
1485
+ if (child.children["*"]) handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
1486
+ } else {
1487
+ child.params = params;
1488
+ tempNodes.push(child);
1489
+ }
1490
+ }
1491
+ }
1492
+ }
1493
+ }
1494
+ curNodes = tempNodes;
1495
+ }
1496
+ const results = handlerSets.sort((a, b) => {
1497
+ return a.score - b.score;
1498
+ });
1499
+ return [results.map(({ handler, params }) => [handler, params])];
1500
+ }
1501
+ };
1502
+
1503
+ //#endregion
1504
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/router/trie-router/router.js
1505
+ var TrieRouter = class {
1506
+ name = "TrieRouter";
1507
+ node;
1508
+ constructor() {
1509
+ this.node = new Node();
1510
+ }
1511
+ add(method, path$2, handler) {
1512
+ const results = checkOptionalParameter(path$2);
1513
+ if (results) {
1514
+ for (const p of results) this.node.insert(method, p, handler);
1515
+ return;
1516
+ }
1517
+ this.node.insert(method, path$2, handler);
1518
+ }
1519
+ match(method, path$2) {
1520
+ return this.node.search(method, path$2);
1521
+ }
1522
+ };
1523
+
1524
+ //#endregion
1525
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/hono.js
1526
+ var Hono = class extends Hono$1 {
1527
+ constructor(options = {}) {
1528
+ super(options);
1529
+ this.router = options.router ?? new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
1530
+ }
1531
+ };
1532
+
1533
+ //#endregion
1534
+ //#region ../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.8.3/node_modules/typia/lib/internal/_validateReport.js
1535
+ var require__validateReport = __commonJS({ "../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.8.3/node_modules/typia/lib/internal/_validateReport.js"(exports) {
1536
+ Object.defineProperty(exports, "__esModule", { value: true });
1537
+ exports._validateReport = void 0;
1538
+ const _validateReport = (array) => {
1539
+ const reportable = (path$2) => {
1540
+ if (array.length === 0) return true;
1541
+ const last = array[array.length - 1].path;
1542
+ return path$2.length > last.length || last.substring(0, path$2.length) !== path$2;
1543
+ };
1544
+ return (exceptable, error) => {
1545
+ if (exceptable && reportable(error.path)) array.push(error);
1546
+ return false;
1547
+ };
1548
+ };
1549
+ exports._validateReport = _validateReport;
1550
+ } });
1551
+
1552
+ //#endregion
1553
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/cookie.js
1554
+ var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
1555
+ var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
1556
+ var parse = (cookie, name) => {
1557
+ const pairs = cookie.trim().split(";");
1558
+ return pairs.reduce((parsedCookie, pairStr) => {
1559
+ pairStr = pairStr.trim();
1560
+ const valueStartPos = pairStr.indexOf("=");
1561
+ if (valueStartPos === -1) return parsedCookie;
1562
+ const cookieName = pairStr.substring(0, valueStartPos).trim();
1563
+ if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
1564
+ let cookieValue = pairStr.substring(valueStartPos + 1).trim();
1565
+ if (cookieValue.startsWith("\"") && cookieValue.endsWith("\"")) cookieValue = cookieValue.slice(1, -1);
1566
+ if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = decodeURIComponent_(cookieValue);
1567
+ return parsedCookie;
1568
+ }, {});
1569
+ };
1570
+
1571
+ //#endregion
1572
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/helper/cookie/index.js
1573
+ var getCookie = (c, key, prefix) => {
1574
+ const cookie = c.req.raw.headers.get("Cookie");
1575
+ if (typeof key === "string") {
1576
+ if (!cookie) return void 0;
1577
+ let finalKey = key;
1578
+ if (prefix === "secure") finalKey = "__Secure-" + key;
1579
+ else if (prefix === "host") finalKey = "__Host-" + key;
1580
+ const obj2 = parse(cookie, finalKey);
1581
+ return obj2[finalKey];
1582
+ }
1583
+ if (!cookie) return {};
1584
+ const obj = parse(cookie);
1585
+ return obj;
1586
+ };
1587
+
1588
+ //#endregion
1589
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/http-exception.js
1590
+ var HTTPException = class extends Error {
1591
+ res;
1592
+ status;
1593
+ constructor(status = 500, options) {
1594
+ super(options?.message, { cause: options?.cause });
1595
+ this.res = options?.res;
1596
+ this.status = status;
1597
+ }
1598
+ getResponse() {
1599
+ if (this.res) {
1600
+ const newResponse = new Response(this.res.body, {
1601
+ status: this.status,
1602
+ headers: this.res.headers
1603
+ });
1604
+ return newResponse;
1605
+ }
1606
+ return new Response(this.message, { status: this.status });
1607
+ }
1608
+ };
1609
+
1610
+ //#endregion
1611
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/utils/buffer.js
1612
+ var bufferToFormData = (arrayBuffer, contentType) => {
1613
+ const response = new Response(arrayBuffer, { headers: { "Content-Type": contentType } });
1614
+ return response.formData();
1615
+ };
1616
+
1617
+ //#endregion
1618
+ //#region ../../node_modules/.pnpm/hono@4.6.3/node_modules/hono/dist/validator/validator.js
1619
+ var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1620
+ var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
1621
+ var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1622
+ var validator = (target, validationFunc) => {
1623
+ return async (c, next) => {
1624
+ let value = {};
1625
+ const contentType = c.req.header("Content-Type");
1626
+ switch (target) {
1627
+ case "json":
1628
+ if (!contentType || !jsonRegex.test(contentType)) break;
1629
+ try {
1630
+ value = await c.req.json();
1631
+ } catch {
1632
+ const message = "Malformed JSON in request body";
1633
+ throw new HTTPException(400, { message });
1634
+ }
1635
+ break;
1636
+ case "form": {
1637
+ if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
1638
+ let formData;
1639
+ if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
1640
+ else try {
1641
+ const arrayBuffer = await c.req.arrayBuffer();
1642
+ formData = await bufferToFormData(arrayBuffer, contentType);
1643
+ c.req.bodyCache.formData = formData;
1644
+ } catch (e) {
1645
+ let message = "Malformed FormData request.";
1646
+ message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
1647
+ throw new HTTPException(400, { message });
1648
+ }
1649
+ const form = {};
1650
+ formData.forEach((value2, key) => {
1651
+ if (key.endsWith("[]")) (form[key] ??= []).push(value2);
1652
+ else if (Array.isArray(form[key])) form[key].push(value2);
1653
+ else if (key in form) form[key] = [form[key], value2];
1654
+ else form[key] = value2;
1655
+ });
1656
+ value = form;
1657
+ break;
1658
+ }
1659
+ case "query":
1660
+ value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v]) => {
1661
+ return v.length === 1 ? [k, v[0]] : [k, v];
1662
+ }));
1663
+ break;
1664
+ case "param":
1665
+ value = c.req.param();
1666
+ break;
1667
+ case "header":
1668
+ value = c.req.header();
1669
+ break;
1670
+ case "cookie":
1671
+ value = getCookie(c);
1672
+ break;
1673
+ }
1674
+ const res = await validationFunc(value, c);
1675
+ if (res instanceof Response) return res;
1676
+ c.req.addValidatedData(target, res);
1677
+ await next();
1678
+ };
1679
+ };
1680
+
1681
+ //#endregion
1682
+ //#region ../../node_modules/.pnpm/@hono+typia-validator@0.1.2_hono@4.6.3_typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.8.3_/node_modules/@hono/typia-validator/dist/esm/index.js
1683
+ const typiaValidator = (target, validate, hook) => validator(target, async (value, c) => {
1684
+ const result = validate(value);
1685
+ if (hook) {
1686
+ const hookResult = await hook({
1687
+ ...result,
1688
+ data: value
1689
+ }, c);
1690
+ if (hookResult) {
1691
+ if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
1692
+ if ("response" in hookResult) return hookResult.response;
1693
+ }
1694
+ }
1695
+ if (!result.success) return c.json({
1696
+ success: false,
1697
+ error: result.errors
1698
+ }, 400);
1699
+ return result.data;
1700
+ });
1701
+
1702
+ //#endregion
1703
+ //#region src-server/rpc.ts
1704
+ var import__validateReport = __toESM(require__validateReport(), 1);
1705
+ const queryBundlesSchema = (() => {
1706
+ const _io0 = (input) => (void 0 === input.channel || "string" === typeof input.channel) && (void 0 === input.platform || "ios" === input.platform || "android" === input.platform) && (void 0 === input.limit || "string" === typeof input.limit) && (void 0 === input.offset || "string" === typeof input.offset);
1707
+ const _vo0 = (input, _path, _exceptionable = true) => [
1708
+ void 0 === input.channel || "string" === typeof input.channel || _report(_exceptionable, {
1709
+ path: _path + ".channel",
1710
+ expected: "(string | undefined)",
1711
+ value: input.channel
1712
+ }),
1713
+ void 0 === input.platform || "ios" === input.platform || "android" === input.platform || _report(_exceptionable, {
1714
+ path: _path + ".platform",
1715
+ expected: "(\"android\" | \"ios\" | undefined)",
1716
+ value: input.platform
1717
+ }),
1718
+ void 0 === input.limit || "string" === typeof input.limit || _report(_exceptionable, {
1719
+ path: _path + ".limit",
1720
+ expected: "(string | undefined)",
1721
+ value: input.limit
1722
+ }),
1723
+ void 0 === input.offset || "string" === typeof input.offset || _report(_exceptionable, {
1724
+ path: _path + ".offset",
1725
+ expected: "(string | undefined)",
1726
+ value: input.offset
1727
+ })
1728
+ ].every((flag) => flag);
1729
+ const __is = (input) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
1730
+ let errors;
1731
+ let _report;
1732
+ return (input) => {
1733
+ if (false === __is(input)) {
1734
+ errors = [];
1735
+ _report = import__validateReport._validateReport(errors);
1736
+ ((input$1, _path, _exceptionable = true) => ("object" === typeof input$1 && null !== input$1 && false === Array.isArray(input$1) || _report(true, {
1737
+ path: _path + "",
1738
+ expected: "__type",
1739
+ value: input$1
1740
+ })) && _vo0(input$1, _path + "", true) || _report(true, {
1741
+ path: _path + "",
1742
+ expected: "__type",
1743
+ value: input$1
1744
+ }))(input, "$input", true);
1745
+ const success = 0 === errors.length;
1746
+ return success ? {
1747
+ success,
1748
+ data: input
1749
+ } : {
1750
+ success,
1751
+ errors,
1752
+ data: input
1753
+ };
1754
+ }
1755
+ return {
1756
+ success: true,
1757
+ data: input
1758
+ };
1759
+ };
51
1760
  })();
52
- (()=>{
53
- __webpack_require__.r = (exports1)=>{
54
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
55
- value: 'Module'
56
- });
57
- Object.defineProperty(exports1, '__esModule', {
58
- value: true
59
- });
60
- };
1761
+ const paramBundleIdSchema = (() => {
1762
+ const _io0 = (input) => "string" === typeof input.bundleId;
1763
+ const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.bundleId || _report(_exceptionable, {
1764
+ path: _path + ".bundleId",
1765
+ expected: "string",
1766
+ value: input.bundleId
1767
+ })].every((flag) => flag);
1768
+ const __is = (input) => "object" === typeof input && null !== input && _io0(input);
1769
+ let errors;
1770
+ let _report;
1771
+ return (input) => {
1772
+ if (false === __is(input)) {
1773
+ errors = [];
1774
+ _report = import__validateReport._validateReport(errors);
1775
+ ((input$1, _path, _exceptionable = true) => ("object" === typeof input$1 && null !== input$1 || _report(true, {
1776
+ path: _path + "",
1777
+ expected: "__type",
1778
+ value: input$1
1779
+ })) && _vo0(input$1, _path + "", true) || _report(true, {
1780
+ path: _path + "",
1781
+ expected: "__type",
1782
+ value: input$1
1783
+ }))(input, "$input", true);
1784
+ const success = 0 === errors.length;
1785
+ return success ? {
1786
+ success,
1787
+ data: input
1788
+ } : {
1789
+ success,
1790
+ errors,
1791
+ data: input
1792
+ };
1793
+ }
1794
+ return {
1795
+ success: true,
1796
+ data: input
1797
+ };
1798
+ };
61
1799
  })();
62
- var __webpack_exports__ = {};
63
- (()=>{
64
- __webpack_require__.r(__webpack_exports__);
65
- __webpack_require__.d(__webpack_exports__, {
66
- default: ()=>src_server
67
- });
68
- const external_path_namespaceObject = require("path");
69
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
70
- const external_url_namespaceObject = require("url");
71
- var getFilePath = (options)=>{
72
- let filename = options.filename;
73
- const defaultDocument = options.defaultDocument || "index.html";
74
- if (filename.endsWith("/")) filename = filename.concat(defaultDocument);
75
- else if (!filename.match(/\.[a-zA-Z0-9_-]+$/)) filename = filename.concat("/" + defaultDocument);
76
- const path = getFilePathWithoutDefaultDocument({
77
- root: options.root,
78
- filename
79
- });
80
- return path;
81
- };
82
- var getFilePathWithoutDefaultDocument = (options)=>{
83
- let root = options.root || "";
84
- let filename = options.filename;
85
- if (/(?:^|[\/\\])\.\.(?:$|[\/\\])/.test(filename)) return;
86
- filename = filename.replace(/^\.?[\/\\]/, "");
87
- filename = filename.replace(/\\/, "/");
88
- root = root.replace(/\/$/, "");
89
- let path = root ? root + "/" + filename : filename;
90
- path = path.replace(/^\.?\//, "");
91
- if ("/" !== root[0] && "/" === path[0]) return;
92
- return path;
93
- };
94
- var getMimeType = (filename, mimes = baseMimes)=>{
95
- const regexp = /\.([a-zA-Z0-9]+?)$/;
96
- const match = filename.match(regexp);
97
- if (!match) return;
98
- let mimeType = mimes[match[1]];
99
- if (mimeType && mimeType.startsWith("text") || "application/json" === mimeType) mimeType += "; charset=utf-8";
100
- return mimeType;
101
- };
102
- var baseMimes = {
103
- aac: "audio/aac",
104
- avi: "video/x-msvideo",
105
- avif: "image/avif",
106
- av1: "video/av1",
107
- bin: "application/octet-stream",
108
- bmp: "image/bmp",
109
- css: "text/css",
110
- csv: "text/csv",
111
- eot: "application/vnd.ms-fontobject",
112
- epub: "application/epub+zip",
113
- gif: "image/gif",
114
- gz: "application/gzip",
115
- htm: "text/html",
116
- html: "text/html",
117
- ico: "image/x-icon",
118
- ics: "text/calendar",
119
- jpeg: "image/jpeg",
120
- jpg: "image/jpeg",
121
- js: "text/javascript",
122
- json: "application/json",
123
- jsonld: "application/ld+json",
124
- map: "application/json",
125
- mid: "audio/x-midi",
126
- midi: "audio/x-midi",
127
- mjs: "text/javascript",
128
- mp3: "audio/mpeg",
129
- mp4: "video/mp4",
130
- mpeg: "video/mpeg",
131
- oga: "audio/ogg",
132
- ogv: "video/ogg",
133
- ogx: "application/ogg",
134
- opus: "audio/opus",
135
- otf: "font/otf",
136
- pdf: "application/pdf",
137
- png: "image/png",
138
- rtf: "application/rtf",
139
- svg: "image/svg+xml",
140
- tif: "image/tiff",
141
- tiff: "image/tiff",
142
- ts: "video/mp2t",
143
- ttf: "font/ttf",
144
- txt: "text/plain",
145
- wasm: "application/wasm",
146
- webm: "video/webm",
147
- weba: "audio/webm",
148
- webp: "image/webp",
149
- woff: "font/woff",
150
- woff2: "font/woff2",
151
- xhtml: "application/xhtml+xml",
152
- xml: "application/xml",
153
- zip: "application/zip",
154
- "3gp": "video/3gpp",
155
- "3g2": "video/3gpp2",
156
- gltf: "model/gltf+json",
157
- glb: "model/gltf-binary"
158
- };
159
- const external_fs_namespaceObject = require("fs");
160
- 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;
161
- var ENCODINGS = {
162
- br: ".br",
163
- zstd: ".zst",
164
- gzip: ".gz"
165
- };
166
- var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
167
- var createStreamBody = (stream)=>{
168
- const body = new ReadableStream({
169
- start (controller) {
170
- stream.on("data", (chunk)=>{
171
- controller.enqueue(chunk);
172
- });
173
- stream.on("end", ()=>{
174
- controller.close();
175
- });
176
- },
177
- cancel () {
178
- stream.destroy();
179
- }
180
- });
181
- return body;
182
- };
183
- var addCurrentDirPrefix = (path)=>`./${path}`;
184
- var getStats = (path)=>{
185
- let stats;
186
- try {
187
- stats = (0, external_fs_namespaceObject.lstatSync)(path);
188
- } catch {}
189
- return stats;
190
- };
191
- var serveStatic = (options = {
192
- root: ""
193
- })=>async (c, next)=>{
194
- if (c.finalized) return next();
195
- let filename;
196
- try {
197
- filename = options.path ?? decodeURIComponent(c.req.path);
198
- } catch {
199
- await options.onNotFound?.(c.req.path, c);
200
- return next();
201
- }
202
- let path = getFilePathWithoutDefaultDocument({
203
- filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
204
- root: options.root
205
- });
206
- if (!path) return next();
207
- path = addCurrentDirPrefix(path);
208
- let stats = getStats(path);
209
- if (stats && stats.isDirectory()) {
210
- path = getFilePath({
211
- filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
212
- root: options.root,
213
- defaultDocument: options.index ?? "index.html"
214
- });
215
- if (!path) return next();
216
- path = addCurrentDirPrefix(path);
217
- stats = getStats(path);
218
- }
219
- if (!stats) {
220
- await options.onNotFound?.(path, c);
221
- return next();
222
- }
223
- await options.onFound?.(path, c);
224
- const mimeType = getMimeType(path);
225
- c.header("Content-Type", mimeType || "application/octet-stream");
226
- if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
227
- const acceptEncodingSet = new Set(c.req.header("Accept-Encoding")?.split(",").map((encoding)=>encoding.trim()));
228
- for (const encoding of ENCODINGS_ORDERED_KEYS){
229
- if (!acceptEncodingSet.has(encoding)) continue;
230
- const precompressedStats = getStats(path + ENCODINGS[encoding]);
231
- if (precompressedStats) {
232
- c.header("Content-Encoding", encoding);
233
- c.header("Vary", "Accept-Encoding", {
234
- append: true
235
- });
236
- stats = precompressedStats;
237
- path += ENCODINGS[encoding];
238
- break;
239
- }
240
- }
241
- }
242
- const size = stats.size;
243
- if ("HEAD" == c.req.method || "OPTIONS" == c.req.method) {
244
- c.header("Content-Length", size.toString());
245
- c.status(200);
246
- return c.body(null);
247
- }
248
- const range = c.req.header("range") || "";
249
- if (!range) {
250
- c.header("Content-Length", size.toString());
251
- return c.body(createStreamBody((0, external_fs_namespaceObject.createReadStream)(path)), 200);
252
- }
253
- c.header("Accept-Ranges", "bytes");
254
- c.header("Date", stats.birthtime.toUTCString());
255
- const parts = range.replace(/bytes=/, "").split("-", 2);
256
- const start = parts[0] ? parseInt(parts[0], 10) : 0;
257
- let end = parts[1] ? parseInt(parts[1], 10) : stats.size - 1;
258
- if (size < end - start + 1) end = size - 1;
259
- const chunksize = end - start + 1;
260
- const stream = (0, external_fs_namespaceObject.createReadStream)(path, {
261
- start,
262
- end
263
- });
264
- c.header("Content-Length", chunksize.toString());
265
- c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
266
- return c.body(createStreamBody(stream), 206);
267
- };
268
- var parseBody = async (request, options = /* @__PURE__ */ Object.create(null))=>{
269
- const { all = false, dot = false } = options;
270
- const headers = request instanceof HonoRequest ? request.raw.headers : request.headers;
271
- const contentType = headers.get("Content-Type");
272
- if (contentType?.startsWith("multipart/form-data") || contentType?.startsWith("application/x-www-form-urlencoded")) return parseFormData(request, {
273
- all,
274
- dot
275
- });
276
- return {};
277
- };
278
- async function parseFormData(request, options) {
279
- const formData = await request.formData();
280
- if (formData) return convertFormDataToBodyData(formData, options);
281
- return {};
282
- }
283
- function convertFormDataToBodyData(formData, options) {
284
- const form = /* @__PURE__ */ Object.create(null);
285
- formData.forEach((value, key)=>{
286
- const shouldParseAllValues = options.all || key.endsWith("[]");
287
- if (shouldParseAllValues) handleParsingAllValues(form, key, value);
288
- else form[key] = value;
289
- });
290
- if (options.dot) Object.entries(form).forEach(([key, value])=>{
291
- const shouldParseDotValues = key.includes(".");
292
- if (shouldParseDotValues) {
293
- handleParsingNestedValues(form, key, value);
294
- delete form[key];
295
- }
296
- });
297
- return form;
298
- }
299
- var handleParsingAllValues = (form, key, value)=>{
300
- if (void 0 !== form[key]) if (Array.isArray(form[key])) form[key].push(value);
301
- else form[key] = [
302
- form[key],
303
- value
304
- ];
305
- else form[key] = value;
306
- };
307
- var handleParsingNestedValues = (form, key, value)=>{
308
- let nestedForm = form;
309
- const keys = key.split(".");
310
- keys.forEach((key2, index)=>{
311
- if (index === keys.length - 1) nestedForm[key2] = value;
312
- else {
313
- if (!nestedForm[key2] || "object" != typeof nestedForm[key2] || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) nestedForm[key2] = /* @__PURE__ */ Object.create(null);
314
- nestedForm = nestedForm[key2];
315
- }
316
- });
317
- };
318
- var splitPath = (path)=>{
319
- const paths = path.split("/");
320
- if ("" === paths[0]) paths.shift();
321
- return paths;
322
- };
323
- var splitRoutingPath = (routePath)=>{
324
- const { groups, path } = extractGroupsFromPath(routePath);
325
- const paths = splitPath(path);
326
- return replaceGroupMarks(paths, groups);
327
- };
328
- var extractGroupsFromPath = (path)=>{
329
- const groups = [];
330
- path = path.replace(/\{[^}]+\}/g, (match, index)=>{
331
- const mark = `@${index}`;
332
- groups.push([
333
- mark,
334
- match
335
- ]);
336
- return mark;
337
- });
338
- return {
339
- groups,
340
- path
341
- };
342
- };
343
- var replaceGroupMarks = (paths, groups)=>{
344
- for(let i = groups.length - 1; i >= 0; i--){
345
- const [mark] = groups[i];
346
- for(let j = paths.length - 1; j >= 0; j--)if (paths[j].includes(mark)) {
347
- paths[j] = paths[j].replace(mark, groups[i][1]);
348
- break;
349
- }
350
- }
351
- return paths;
352
- };
353
- var patternCache = {};
354
- var getPattern = (label)=>{
355
- if ("*" === label) return "*";
356
- const match = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
357
- if (match) {
358
- if (!patternCache[label]) if (match[2]) patternCache[label] = [
359
- label,
360
- match[1],
361
- new RegExp("^" + match[2] + "$")
362
- ];
363
- else patternCache[label] = [
364
- label,
365
- match[1],
366
- true
367
- ];
368
- return patternCache[label];
369
- }
370
- return null;
371
- };
372
- var tryDecodeURI = (str)=>{
373
- try {
374
- return decodeURI(str);
375
- } catch {
376
- return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match)=>{
377
- try {
378
- return decodeURI(match);
379
- } catch {
380
- return match;
381
- }
382
- });
383
- }
384
- };
385
- var getPath = (request)=>{
386
- const url = request.url;
387
- const start = url.indexOf("/", 8);
388
- let i = start;
389
- for(; i < url.length; i++){
390
- const charCode = url.charCodeAt(i);
391
- if (37 === charCode) {
392
- const queryIndex = url.indexOf("?", i);
393
- const path = url.slice(start, -1 === queryIndex ? void 0 : queryIndex);
394
- return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
395
- }
396
- if (63 === charCode) break;
397
- }
398
- return url.slice(start, i);
399
- };
400
- var getPathNoStrict = (request)=>{
401
- const result = getPath(request);
402
- return result.length > 1 && "/" === result[result.length - 1] ? result.slice(0, -1) : result;
403
- };
404
- var mergePath = (...paths)=>{
405
- let p = "";
406
- let endsWithSlash = false;
407
- for (let path of paths){
408
- if ("/" === p[p.length - 1]) {
409
- p = p.slice(0, -1);
410
- endsWithSlash = true;
411
- }
412
- if ("/" !== path[0]) path = `/${path}`;
413
- if ("/" === path && endsWithSlash) p = `${p}/`;
414
- else if ("/" !== path) p = `${p}${path}`;
415
- if ("/" === path && "" === p) p = "/";
416
- }
417
- return p;
418
- };
419
- var checkOptionalParameter = (path)=>{
420
- if (!path.match(/\:.+\?$/)) return null;
421
- const segments = path.split("/");
422
- const results = [];
423
- let basePath = "";
424
- segments.forEach((segment)=>{
425
- if ("" === segment || /\:/.test(segment)) {
426
- if (/\:/.test(segment)) if (/\?/.test(segment)) {
427
- if (0 === results.length && "" === basePath) results.push("/");
428
- else results.push(basePath);
429
- const optionalSegment = segment.replace("?", "");
430
- basePath += "/" + optionalSegment;
431
- results.push(basePath);
432
- } else basePath += "/" + segment;
433
- } else basePath += "/" + segment;
434
- });
435
- return results.filter((v, i, a)=>a.indexOf(v) === i);
436
- };
437
- var _decodeURI = (value)=>{
438
- if (!/[%+]/.test(value)) return value;
439
- if (-1 !== value.indexOf("+")) value = value.replace(/\+/g, " ");
440
- return /%/.test(value) ? decodeURIComponent_(value) : value;
441
- };
442
- var _getQueryParam = (url, key, multiple)=>{
443
- let encoded;
444
- if (!multiple && key && !/[%+]/.test(key)) {
445
- let keyIndex2 = url.indexOf(`?${key}`, 8);
446
- if (-1 === keyIndex2) keyIndex2 = url.indexOf(`&${key}`, 8);
447
- while(-1 !== keyIndex2){
448
- const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
449
- if (61 === trailingKeyCode) {
450
- const valueIndex = keyIndex2 + key.length + 2;
451
- const endIndex = url.indexOf("&", valueIndex);
452
- return _decodeURI(url.slice(valueIndex, -1 === endIndex ? void 0 : endIndex));
453
- }
454
- if (38 == trailingKeyCode || isNaN(trailingKeyCode)) return "";
455
- keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
456
- }
457
- encoded = /[%+]/.test(url);
458
- if (!encoded) return;
459
- }
460
- const results = {};
461
- encoded ??= /[%+]/.test(url);
462
- let keyIndex = url.indexOf("?", 8);
463
- while(-1 !== keyIndex){
464
- const nextKeyIndex = url.indexOf("&", keyIndex + 1);
465
- let valueIndex = url.indexOf("=", keyIndex);
466
- if (valueIndex > nextKeyIndex && -1 !== nextKeyIndex) valueIndex = -1;
467
- let name = url.slice(keyIndex + 1, -1 === valueIndex ? -1 === nextKeyIndex ? void 0 : nextKeyIndex : valueIndex);
468
- if (encoded) name = _decodeURI(name);
469
- keyIndex = nextKeyIndex;
470
- if ("" === name) continue;
471
- let value;
472
- if (-1 === valueIndex) value = "";
473
- else {
474
- value = url.slice(valueIndex + 1, -1 === nextKeyIndex ? void 0 : nextKeyIndex);
475
- if (encoded) value = _decodeURI(value);
476
- }
477
- if (multiple) {
478
- if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
479
- results[name].push(value);
480
- } else results[name] ??= value;
481
- }
482
- return key ? results[key] : results;
483
- };
484
- var getQueryParam = _getQueryParam;
485
- var getQueryParams = (url, key)=>_getQueryParam(url, key, true);
486
- var decodeURIComponent_ = decodeURIComponent;
487
- var HonoRequest = class {
488
- raw;
489
- #validatedData;
490
- #matchResult;
491
- routeIndex = 0;
492
- path;
493
- bodyCache = {};
494
- constructor(request, path = "/", matchResult = [
495
- []
496
- ]){
497
- this.raw = request;
498
- this.path = path;
499
- this.#matchResult = matchResult;
500
- this.#validatedData = {};
501
- }
502
- param(key) {
503
- return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
504
- }
505
- getDecodedParam(key) {
506
- const paramKey = this.#matchResult[0][this.routeIndex][1][key];
507
- const param = this.getParamValue(paramKey);
508
- return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
509
- }
510
- getAllDecodedParams() {
511
- const decoded = {};
512
- const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
513
- for (const key of keys){
514
- const value = this.getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
515
- if (value && "string" == typeof value) decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
516
- }
517
- return decoded;
518
- }
519
- getParamValue(paramKey) {
520
- return this.#matchResult[1] ? this.#matchResult[1][paramKey] : paramKey;
521
- }
522
- query(key) {
523
- return getQueryParam(this.url, key);
524
- }
525
- queries(key) {
526
- return getQueryParams(this.url, key);
527
- }
528
- header(name) {
529
- if (name) return this.raw.headers.get(name.toLowerCase()) ?? void 0;
530
- const headerData = {};
531
- this.raw.headers.forEach((value, key)=>{
532
- headerData[key] = value;
533
- });
534
- return headerData;
535
- }
536
- async parseBody(options) {
537
- return this.bodyCache.parsedBody ??= await parseBody(this, options);
538
- }
539
- cachedBody = (key)=>{
540
- const { bodyCache, raw } = this;
541
- const cachedBody = bodyCache[key];
542
- if (cachedBody) return cachedBody;
543
- const anyCachedKey = Object.keys(bodyCache)[0];
544
- if (anyCachedKey) return bodyCache[anyCachedKey].then((body)=>{
545
- if ("json" === anyCachedKey) body = JSON.stringify(body);
546
- return new Response(body)[key]();
547
- });
548
- return bodyCache[key] = raw[key]();
549
- };
550
- json() {
551
- return this.cachedBody("json");
552
- }
553
- text() {
554
- return this.cachedBody("text");
555
- }
556
- arrayBuffer() {
557
- return this.cachedBody("arrayBuffer");
558
- }
559
- blob() {
560
- return this.cachedBody("blob");
561
- }
562
- formData() {
563
- return this.cachedBody("formData");
564
- }
565
- addValidatedData(target, data) {
566
- this.#validatedData[target] = data;
567
- }
568
- valid(target) {
569
- return this.#validatedData[target];
570
- }
571
- get url() {
572
- return this.raw.url;
573
- }
574
- get method() {
575
- return this.raw.method;
576
- }
577
- get matchedRoutes() {
578
- return this.#matchResult[0].map(([[, route]])=>route);
579
- }
580
- get routePath() {
581
- return this.#matchResult[0].map(([[, route]])=>route)[this.routeIndex].path;
582
- }
583
- };
584
- var HtmlEscapedCallbackPhase = {
585
- Stringify: 1,
586
- BeforeStream: 2,
587
- Stream: 3
588
- };
589
- var html_raw = (value, callbacks)=>{
590
- const escapedString = new String(value);
591
- escapedString.isEscaped = true;
592
- escapedString.callbacks = callbacks;
593
- return escapedString;
594
- };
595
- var resolveCallback = async (str, phase, preserveCallbacks, context, buffer)=>{
596
- if ("object" == typeof str && !(str instanceof String)) {
597
- if (!(str instanceof Promise)) str = str.toString();
598
- if (str instanceof Promise) str = await str;
599
- }
600
- const callbacks = str.callbacks;
601
- if (!callbacks?.length) return Promise.resolve(str);
602
- if (buffer) buffer[0] += str;
603
- else buffer = [
604
- str
605
- ];
606
- const resStr = Promise.all(callbacks.map((c)=>c({
607
- phase,
608
- buffer,
609
- context
610
- }))).then((res)=>Promise.all(res.filter(Boolean).map((str2)=>resolveCallback(str2, phase, false, context, buffer))).then(()=>buffer[0]));
611
- if (preserveCallbacks) return html_raw(await resStr, callbacks);
612
- return resStr;
613
- };
614
- var TEXT_PLAIN = "text/plain; charset=UTF-8";
615
- var setHeaders = (headers, map = {})=>{
616
- Object.entries(map).forEach(([key, value])=>headers.set(key, value));
617
- return headers;
618
- };
619
- var Context = class {
620
- #rawRequest;
621
- #req;
622
- env = {};
623
- #var;
624
- finalized = false;
625
- error;
626
- #status = 200;
627
- #executionCtx;
628
- #headers;
629
- #preparedHeaders;
630
- #res;
631
- #isFresh = true;
632
- #layout;
633
- #renderer;
634
- #notFoundHandler;
635
- #matchResult;
636
- #path;
637
- constructor(req, options){
638
- this.#rawRequest = req;
639
- if (options) {
640
- this.#executionCtx = options.executionCtx;
641
- this.env = options.env;
642
- this.#notFoundHandler = options.notFoundHandler;
643
- this.#path = options.path;
644
- this.#matchResult = options.matchResult;
645
- }
646
- }
647
- get req() {
648
- this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
649
- return this.#req;
650
- }
651
- get event() {
652
- if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
653
- throw Error("This context has no FetchEvent");
654
- }
655
- get executionCtx() {
656
- if (this.#executionCtx) return this.#executionCtx;
657
- throw Error("This context has no ExecutionContext");
658
- }
659
- get res() {
660
- this.#isFresh = false;
661
- return this.#res ||= new Response("404 Not Found", {
662
- status: 404
663
- });
664
- }
665
- set res(_res) {
666
- this.#isFresh = false;
667
- if (this.#res && _res) try {
668
- for (const [k, v] of this.#res.headers.entries())if ("content-type" !== k) if ("set-cookie" === k) {
669
- const cookies = this.#res.headers.getSetCookie();
670
- _res.headers.delete("set-cookie");
671
- for (const cookie of cookies)_res.headers.append("set-cookie", cookie);
672
- } else _res.headers.set(k, v);
673
- } catch (e) {
674
- if (e instanceof TypeError && e.message.includes("immutable")) {
675
- this.res = new Response(_res.body, {
676
- headers: _res.headers,
677
- status: _res.status
678
- });
679
- return;
680
- }
681
- throw e;
682
- }
683
- this.#res = _res;
684
- this.finalized = true;
685
- }
686
- render = (...args)=>{
687
- this.#renderer ??= (content)=>this.html(content);
688
- return this.#renderer(...args);
689
- };
690
- setLayout = (layout)=>this.#layout = layout;
691
- getLayout = ()=>this.#layout;
692
- setRenderer = (renderer)=>{
693
- this.#renderer = renderer;
694
- };
695
- header = (name, value, options)=>{
696
- if (void 0 === value) {
697
- if (this.#headers) this.#headers.delete(name);
698
- else if (this.#preparedHeaders) delete this.#preparedHeaders[name.toLocaleLowerCase()];
699
- if (this.finalized) this.res.headers.delete(name);
700
- return;
701
- }
702
- if (options?.append) {
703
- if (!this.#headers) {
704
- this.#isFresh = false;
705
- this.#headers = new Headers(this.#preparedHeaders);
706
- this.#preparedHeaders = {};
707
- }
708
- this.#headers.append(name, value);
709
- } else if (this.#headers) this.#headers.set(name, value);
710
- else {
711
- this.#preparedHeaders ??= {};
712
- this.#preparedHeaders[name.toLowerCase()] = value;
713
- }
714
- if (this.finalized) if (options?.append) this.res.headers.append(name, value);
715
- else this.res.headers.set(name, value);
716
- };
717
- status = (status)=>{
718
- this.#isFresh = false;
719
- this.#status = status;
720
- };
721
- set = (key, value)=>{
722
- this.#var ??= /* @__PURE__ */ new Map();
723
- this.#var.set(key, value);
724
- };
725
- get = (key)=>this.#var ? this.#var.get(key) : void 0;
726
- get var() {
727
- if (!this.#var) return {};
728
- return Object.fromEntries(this.#var);
729
- }
730
- newResponse = (data, arg, headers)=>{
731
- if (this.#isFresh && !headers && !arg && 200 === this.#status) return new Response(data, {
732
- headers: this.#preparedHeaders
733
- });
734
- if (arg && "number" != typeof arg) {
735
- const header = new Headers(arg.headers);
736
- if (this.#headers) this.#headers.forEach((v, k)=>{
737
- if ("set-cookie" === k) header.append(k, v);
738
- else header.set(k, v);
739
- });
740
- const headers2 = setHeaders(header, this.#preparedHeaders);
741
- return new Response(data, {
742
- headers: headers2,
743
- status: arg.status ?? this.#status
744
- });
745
- }
746
- const status = "number" == typeof arg ? arg : this.#status;
747
- this.#preparedHeaders ??= {};
748
- this.#headers ??= new Headers();
749
- setHeaders(this.#headers, this.#preparedHeaders);
750
- if (this.#res) {
751
- this.#res.headers.forEach((v, k)=>{
752
- if ("set-cookie" === k) this.#headers?.append(k, v);
753
- else this.#headers?.set(k, v);
754
- });
755
- setHeaders(this.#headers, this.#preparedHeaders);
756
- }
757
- headers ??= {};
758
- for (const [k, v] of Object.entries(headers))if ("string" == typeof v) this.#headers.set(k, v);
759
- else {
760
- this.#headers.delete(k);
761
- for (const v2 of v)this.#headers.append(k, v2);
762
- }
763
- return new Response(data, {
764
- status,
765
- headers: this.#headers
766
- });
767
- };
768
- body = (data, arg, headers)=>"number" == typeof arg ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
769
- text = (text, arg, headers)=>{
770
- if (!this.#preparedHeaders) {
771
- if (this.#isFresh && !headers && !arg) return new Response(text);
772
- this.#preparedHeaders = {};
773
- }
774
- this.#preparedHeaders["content-type"] = TEXT_PLAIN;
775
- return "number" == typeof arg ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
776
- };
777
- json = (object, arg, headers)=>{
778
- const body = JSON.stringify(object);
779
- this.#preparedHeaders ??= {};
780
- this.#preparedHeaders["content-type"] = "application/json; charset=UTF-8";
781
- return "number" == typeof arg ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
782
- };
783
- html = (html, arg, headers)=>{
784
- this.#preparedHeaders ??= {};
785
- this.#preparedHeaders["content-type"] = "text/html; charset=UTF-8";
786
- if ("object" == typeof html) return resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then((html2)=>"number" == typeof arg ? this.newResponse(html2, arg, headers) : this.newResponse(html2, arg));
787
- return "number" == typeof arg ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
788
- };
789
- redirect = (location, status)=>{
790
- this.#headers ??= new Headers();
791
- this.#headers.set("Location", location);
792
- return this.newResponse(null, status ?? 302);
793
- };
794
- notFound = ()=>{
795
- this.#notFoundHandler ??= ()=>new Response();
796
- return this.#notFoundHandler(this);
797
- };
798
- };
799
- var compose = (middleware, onError, onNotFound)=>(context, next)=>{
800
- let index = -1;
801
- return dispatch(0);
802
- async function dispatch(i) {
803
- if (i <= index) throw new Error("next() called multiple times");
804
- index = i;
805
- let res;
806
- let isError = false;
807
- let handler;
808
- if (middleware[i]) {
809
- handler = middleware[i][0][0];
810
- if (context instanceof Context) context.req.routeIndex = i;
811
- } else handler = i === middleware.length && next || void 0;
812
- if (handler) try {
813
- res = await handler(context, ()=>dispatch(i + 1));
814
- } catch (err) {
815
- if (err instanceof Error && context instanceof Context && onError) {
816
- context.error = err;
817
- res = await onError(err, context);
818
- isError = true;
819
- } else throw err;
820
- }
821
- else if (context instanceof Context && false === context.finalized && onNotFound) res = await onNotFound(context);
822
- if (res && (false === context.finalized || isError)) context.res = res;
823
- return context;
824
- }
825
- };
826
- var METHOD_NAME_ALL = "ALL";
827
- var METHOD_NAME_ALL_LOWERCASE = "all";
828
- var METHODS = [
829
- "get",
830
- "post",
831
- "put",
832
- "delete",
833
- "options",
834
- "patch"
835
- ];
836
- var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
837
- var UnsupportedPathError = class extends Error {
838
- };
839
- var COMPOSED_HANDLER = Symbol("composedHandler");
840
- var notFoundHandler = (c)=>c.text("404 Not Found", 404);
841
- var errorHandler = (err, c)=>{
842
- if ("getResponse" in err) return err.getResponse();
843
- console.error(err);
844
- return c.text("Internal Server Error", 500);
845
- };
846
- var Hono = class {
847
- get;
848
- post;
849
- put;
850
- delete;
851
- options;
852
- patch;
853
- all;
854
- on;
855
- use;
856
- router;
857
- getPath;
858
- _basePath = "/";
859
- #path = "/";
860
- routes = [];
861
- constructor(options = {}){
862
- const allMethods = [
863
- ...METHODS,
864
- METHOD_NAME_ALL_LOWERCASE
865
- ];
866
- allMethods.forEach((method)=>{
867
- this[method] = (args1, ...args)=>{
868
- if ("string" == typeof args1) this.#path = args1;
869
- else this.addRoute(method, this.#path, args1);
870
- args.forEach((handler)=>{
871
- if ("string" != typeof handler) this.addRoute(method, this.#path, handler);
872
- });
873
- return this;
874
- };
875
- });
876
- this.on = (method, path, ...handlers)=>{
877
- for (const p of [
878
- path
879
- ].flat()){
880
- this.#path = p;
881
- for (const m of [
882
- method
883
- ].flat())handlers.map((handler)=>{
884
- this.addRoute(m.toUpperCase(), this.#path, handler);
885
- });
886
- }
887
- return this;
888
- };
889
- this.use = (arg1, ...handlers)=>{
890
- if ("string" == typeof arg1) this.#path = arg1;
891
- else {
892
- this.#path = "*";
893
- handlers.unshift(arg1);
894
- }
895
- handlers.forEach((handler)=>{
896
- this.addRoute(METHOD_NAME_ALL, this.#path, handler);
897
- });
898
- return this;
899
- };
900
- const strict = options.strict ?? true;
901
- delete options.strict;
902
- Object.assign(this, options);
903
- this.getPath = strict ? options.getPath ?? getPath : getPathNoStrict;
904
- }
905
- clone() {
906
- const clone = new Hono({
907
- router: this.router,
908
- getPath: this.getPath
909
- });
910
- clone.routes = this.routes;
911
- return clone;
912
- }
913
- notFoundHandler = notFoundHandler;
914
- errorHandler = errorHandler;
915
- route(path, app) {
916
- const subApp = this.basePath(path);
917
- app.routes.map((r)=>{
918
- let handler;
919
- if (app.errorHandler === errorHandler) handler = r.handler;
920
- else {
921
- handler = async (c, next)=>(await compose([], app.errorHandler)(c, ()=>r.handler(c, next))).res;
922
- handler[COMPOSED_HANDLER] = r.handler;
923
- }
924
- subApp.addRoute(r.method, r.path, handler);
925
- });
926
- return this;
927
- }
928
- basePath(path) {
929
- const subApp = this.clone();
930
- subApp._basePath = mergePath(this._basePath, path);
931
- return subApp;
932
- }
933
- onError = (handler)=>{
934
- this.errorHandler = handler;
935
- return this;
936
- };
937
- notFound = (handler)=>{
938
- this.notFoundHandler = handler;
939
- return this;
940
- };
941
- mount(path, applicationHandler, options) {
942
- let replaceRequest;
943
- let optionHandler;
944
- if (options) if ("function" == typeof options) optionHandler = options;
945
- else {
946
- optionHandler = options.optionHandler;
947
- replaceRequest = options.replaceRequest;
948
- }
949
- const getOptions = optionHandler ? (c)=>{
950
- const options2 = optionHandler(c);
951
- return Array.isArray(options2) ? options2 : [
952
- options2
953
- ];
954
- } : (c)=>{
955
- let executionContext;
956
- try {
957
- executionContext = c.executionCtx;
958
- } catch {}
959
- return [
960
- c.env,
961
- executionContext
962
- ];
963
- };
964
- replaceRequest ||= (()=>{
965
- const mergedPath = mergePath(this._basePath, path);
966
- const pathPrefixLength = "/" === mergedPath ? 0 : mergedPath.length;
967
- return (request)=>{
968
- const url = new URL(request.url);
969
- url.pathname = url.pathname.slice(pathPrefixLength) || "/";
970
- return new Request(url, request);
971
- };
972
- })();
973
- const handler = async (c, next)=>{
974
- const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
975
- if (res) return res;
976
- await next();
977
- };
978
- this.addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
979
- return this;
980
- }
981
- addRoute(method, path, handler) {
982
- method = method.toUpperCase();
983
- path = mergePath(this._basePath, path);
984
- const r = {
985
- path,
986
- method,
987
- handler
988
- };
989
- this.router.add(method, path, [
990
- handler,
991
- r
992
- ]);
993
- this.routes.push(r);
994
- }
995
- matchRoute(method, path) {
996
- return this.router.match(method, path);
997
- }
998
- handleError(err, c) {
999
- if (err instanceof Error) return this.errorHandler(err, c);
1000
- throw err;
1001
- }
1002
- dispatch(request, executionCtx, env, method) {
1003
- if ("HEAD" === method) return (async ()=>new Response(null, await this.dispatch(request, executionCtx, env, "GET")))();
1004
- const path = this.getPath(request, {
1005
- env
1006
- });
1007
- const matchResult = this.matchRoute(method, path);
1008
- const c = new Context(request, {
1009
- path,
1010
- matchResult,
1011
- env,
1012
- executionCtx,
1013
- notFoundHandler: this.notFoundHandler
1014
- });
1015
- if (1 === matchResult[0].length) {
1016
- let res;
1017
- try {
1018
- res = matchResult[0][0][0][0](c, async ()=>{
1019
- c.res = await this.notFoundHandler(c);
1020
- });
1021
- } catch (err) {
1022
- return this.handleError(err, c);
1023
- }
1024
- 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);
1025
- }
1026
- const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
1027
- return (async ()=>{
1028
- try {
1029
- const context = await composed(c);
1030
- if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
1031
- return context.res;
1032
- } catch (err) {
1033
- return this.handleError(err, c);
1034
- }
1035
- })();
1036
- }
1037
- fetch = (request, ...rest)=>this.dispatch(request, rest[1], rest[0], request.method);
1038
- request = (input, requestInit, Env, executionCtx)=>{
1039
- if (input instanceof Request) {
1040
- if (void 0 !== requestInit) input = new Request(input, requestInit);
1041
- return this.fetch(input, Env, executionCtx);
1042
- }
1043
- input = input.toString();
1044
- const path = /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`;
1045
- const req = new Request(path, requestInit);
1046
- return this.fetch(req, Env, executionCtx);
1047
- };
1048
- fire = ()=>{
1049
- addEventListener("fetch", (event)=>{
1050
- event.respondWith(this.dispatch(event.request, event, void 0, event.request.method));
1051
- });
1052
- };
1053
- };
1054
- var LABEL_REG_EXP_STR = "[^/]+";
1055
- var ONLY_WILDCARD_REG_EXP_STR = ".*";
1056
- var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1057
- var PATH_ERROR = Symbol();
1058
- var regExpMetaChars = new Set(".\\+*[^]$()");
1059
- function compareKey(a, b) {
1060
- if (1 === a.length) return 1 === b.length ? a < b ? -1 : 1 : -1;
1061
- if (1 === b.length) return 1;
1062
- if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) return 1;
1063
- if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) return -1;
1064
- if (a === LABEL_REG_EXP_STR) return 1;
1065
- if (b === LABEL_REG_EXP_STR) return -1;
1066
- return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
1067
- }
1068
- var Node = class {
1069
- index;
1070
- varIndex;
1071
- children = /* @__PURE__ */ Object.create(null);
1072
- insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
1073
- if (0 === tokens.length) {
1074
- if (void 0 !== this.index) throw PATH_ERROR;
1075
- if (pathErrorCheckOnly) return;
1076
- this.index = index;
1077
- return;
1078
- }
1079
- const [token, ...restTokens] = tokens;
1080
- const pattern = "*" === token ? 0 === restTokens.length ? [
1081
- "",
1082
- "",
1083
- ONLY_WILDCARD_REG_EXP_STR
1084
- ] : [
1085
- "",
1086
- "",
1087
- LABEL_REG_EXP_STR
1088
- ] : "/*" === token ? [
1089
- "",
1090
- "",
1091
- TAIL_WILDCARD_REG_EXP_STR
1092
- ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
1093
- let node;
1094
- if (pattern) {
1095
- const name = pattern[1];
1096
- let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
1097
- if (name && pattern[2]) {
1098
- regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1099
- if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1100
- }
1101
- node = this.children[regexpStr];
1102
- if (!node) {
1103
- if (Object.keys(this.children).some((k)=>k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) throw PATH_ERROR;
1104
- if (pathErrorCheckOnly) return;
1105
- node = this.children[regexpStr] = new Node();
1106
- if ("" !== name) node.varIndex = context.varIndex++;
1107
- }
1108
- if (!pathErrorCheckOnly && "" !== name) paramMap.push([
1109
- name,
1110
- node.varIndex
1111
- ]);
1112
- } else {
1113
- node = this.children[token];
1114
- if (!node) {
1115
- 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;
1116
- if (pathErrorCheckOnly) return;
1117
- node = this.children[token] = new Node();
1118
- }
1119
- }
1120
- node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
1121
- }
1122
- buildRegExpStr() {
1123
- const childKeys = Object.keys(this.children).sort(compareKey);
1124
- const strList = childKeys.map((k)=>{
1125
- const c = this.children[k];
1126
- return ("number" == typeof c.varIndex ? `(${k})@${c.varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
1127
- });
1128
- if ("number" == typeof this.index) strList.unshift(`#${this.index}`);
1129
- if (0 === strList.length) return "";
1130
- if (1 === strList.length) return strList[0];
1131
- return "(?:" + strList.join("|") + ")";
1132
- }
1133
- };
1134
- var Trie = class {
1135
- context = {
1136
- varIndex: 0
1137
- };
1138
- root = new Node();
1139
- insert(path, index, pathErrorCheckOnly) {
1140
- const paramAssoc = [];
1141
- const groups = [];
1142
- for(let i = 0;;){
1143
- let replaced = false;
1144
- path = path.replace(/\{[^}]+\}/g, (m)=>{
1145
- const mark = `@\\${i}`;
1146
- groups[i] = [
1147
- mark,
1148
- m
1149
- ];
1150
- i++;
1151
- replaced = true;
1152
- return mark;
1153
- });
1154
- if (!replaced) break;
1155
- }
1156
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1157
- for(let i = groups.length - 1; i >= 0; i--){
1158
- const [mark] = groups[i];
1159
- for(let j = tokens.length - 1; j >= 0; j--)if (-1 !== tokens[j].indexOf(mark)) {
1160
- tokens[j] = tokens[j].replace(mark, groups[i][1]);
1161
- break;
1162
- }
1163
- }
1164
- this.root.insert(tokens, index, paramAssoc, this.context, pathErrorCheckOnly);
1165
- return paramAssoc;
1166
- }
1167
- buildRegExp() {
1168
- let regexp = this.root.buildRegExpStr();
1169
- if ("" === regexp) return [
1170
- /^$/,
1171
- [],
1172
- []
1173
- ];
1174
- let captureIndex = 0;
1175
- const indexReplacementMap = [];
1176
- const paramReplacementMap = [];
1177
- regexp = regexp.replace(/#(\d+)|@(\d+)|\.\*\$/g, (_, handlerIndex, paramIndex)=>{
1178
- if (void 0 !== handlerIndex) {
1179
- indexReplacementMap[++captureIndex] = Number(handlerIndex);
1180
- return "$()";
1181
- }
1182
- if (void 0 !== paramIndex) paramReplacementMap[Number(paramIndex)] = ++captureIndex;
1183
- return "";
1184
- });
1185
- return [
1186
- new RegExp(`^${regexp}`),
1187
- indexReplacementMap,
1188
- paramReplacementMap
1189
- ];
1190
- }
1191
- };
1192
- var emptyParam = [];
1193
- var nullMatcher = [
1194
- /^$/,
1195
- [],
1196
- /* @__PURE__ */ Object.create(null)
1197
- ];
1198
- var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1199
- function buildWildcardRegExp(path) {
1200
- return wildcardRegExpCache[path] ??= new RegExp("*" === path ? "" : `^${path.replace(/\/\*$|([.\\+*[^\]$()])/g, (_, metaChar)=>metaChar ? `\\${metaChar}` : "(?:|/.*)")}$`);
1201
- }
1202
- function clearWildcardRegExpCache() {
1203
- wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
1204
- }
1205
- function buildMatcherFromPreprocessedRoutes(routes) {
1206
- const trie = new Trie();
1207
- const handlerData = [];
1208
- if (0 === routes.length) return nullMatcher;
1209
- const routesWithStaticPathFlag = routes.map((route)=>[
1210
- !/\*|\/:/.test(route[0]),
1211
- ...route
1212
- ]).sort(([isStaticA, pathA], [isStaticB, pathB])=>isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
1213
- const staticMap = /* @__PURE__ */ Object.create(null);
1214
- for(let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++){
1215
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
1216
- if (pathErrorCheckOnly) staticMap[path] = [
1217
- handlers.map(([h])=>[
1218
- h,
1219
- /* @__PURE__ */ Object.create(null)
1220
- ]),
1221
- emptyParam
1222
- ];
1223
- else j++;
1224
- let paramAssoc;
1225
- try {
1226
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
1227
- } catch (e) {
1228
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
1229
- }
1230
- if (!pathErrorCheckOnly) handlerData[j] = handlers.map(([h, paramCount])=>{
1231
- const paramIndexMap = /* @__PURE__ */ Object.create(null);
1232
- paramCount -= 1;
1233
- for(; paramCount >= 0; paramCount--){
1234
- const [key, value] = paramAssoc[paramCount];
1235
- paramIndexMap[key] = value;
1236
- }
1237
- return [
1238
- h,
1239
- paramIndexMap
1240
- ];
1241
- });
1242
- }
1243
- const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1244
- for(let i = 0, len = handlerData.length; i < len; i++)for(let j = 0, len2 = handlerData[i].length; j < len2; j++){
1245
- const map = handlerData[i][j]?.[1];
1246
- if (!map) continue;
1247
- const keys = Object.keys(map);
1248
- for(let k = 0, len3 = keys.length; k < len3; k++)map[keys[k]] = paramReplacementMap[map[keys[k]]];
1249
- }
1250
- const handlerMap = [];
1251
- for(const i in indexReplacementMap)handlerMap[i] = handlerData[indexReplacementMap[i]];
1252
- return [
1253
- regexp,
1254
- handlerMap,
1255
- staticMap
1256
- ];
1257
- }
1258
- function findMiddleware(middleware, path) {
1259
- if (!middleware) return;
1260
- for (const k of Object.keys(middleware).sort((a, b)=>b.length - a.length))if (buildWildcardRegExp(k).test(path)) return [
1261
- ...middleware[k]
1262
- ];
1263
- }
1264
- var RegExpRouter = class {
1265
- name = "RegExpRouter";
1266
- middleware;
1267
- routes;
1268
- constructor(){
1269
- this.middleware = {
1270
- [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
1271
- };
1272
- this.routes = {
1273
- [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null)
1274
- };
1275
- }
1276
- add(method, path, handler) {
1277
- const { middleware, routes } = this;
1278
- if (!middleware || !routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1279
- if (!middleware[method]) [
1280
- middleware,
1281
- routes
1282
- ].forEach((handlerMap)=>{
1283
- handlerMap[method] = /* @__PURE__ */ Object.create(null);
1284
- Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p)=>{
1285
- handlerMap[method][p] = [
1286
- ...handlerMap[METHOD_NAME_ALL][p]
1287
- ];
1288
- });
1289
- });
1290
- if ("/*" === path) path = "*";
1291
- const paramCount = (path.match(/\/:/g) || []).length;
1292
- if (/\*$/.test(path)) {
1293
- const re = buildWildcardRegExp(path);
1294
- if (method === METHOD_NAME_ALL) Object.keys(middleware).forEach((m)=>{
1295
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
1296
- });
1297
- else middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
1298
- Object.keys(middleware).forEach((m)=>{
1299
- if (method === METHOD_NAME_ALL || method === m) Object.keys(middleware[m]).forEach((p)=>{
1300
- re.test(p) && middleware[m][p].push([
1301
- handler,
1302
- paramCount
1303
- ]);
1304
- });
1305
- });
1306
- Object.keys(routes).forEach((m)=>{
1307
- if (method === METHOD_NAME_ALL || method === m) Object.keys(routes[m]).forEach((p)=>re.test(p) && routes[m][p].push([
1308
- handler,
1309
- paramCount
1310
- ]));
1311
- });
1312
- return;
1313
- }
1314
- const paths = checkOptionalParameter(path) || [
1315
- path
1316
- ];
1317
- for(let i = 0, len = paths.length; i < len; i++){
1318
- const path2 = paths[i];
1319
- Object.keys(routes).forEach((m)=>{
1320
- if (method === METHOD_NAME_ALL || method === m) {
1321
- routes[m][path2] ||= [
1322
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
1323
- ];
1324
- routes[m][path2].push([
1325
- handler,
1326
- paramCount - len + i + 1
1327
- ]);
1328
- }
1329
- });
1330
- }
1331
- }
1332
- match(method, path) {
1333
- clearWildcardRegExpCache();
1334
- const matchers = this.buildAllMatchers();
1335
- this.match = (method2, path2)=>{
1336
- const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
1337
- const staticMatch = matcher[2][path2];
1338
- if (staticMatch) return staticMatch;
1339
- const match = path2.match(matcher[0]);
1340
- if (!match) return [
1341
- [],
1342
- emptyParam
1343
- ];
1344
- const index = match.indexOf("", 1);
1345
- return [
1346
- matcher[1][index],
1347
- match
1348
- ];
1349
- };
1350
- return this.match(method, path);
1351
- }
1352
- buildAllMatchers() {
1353
- const matchers = /* @__PURE__ */ Object.create(null);
1354
- [
1355
- ...Object.keys(this.routes),
1356
- ...Object.keys(this.middleware)
1357
- ].forEach((method)=>{
1358
- matchers[method] ||= this.buildMatcher(method);
1359
- });
1360
- this.middleware = this.routes = void 0;
1361
- return matchers;
1362
- }
1363
- buildMatcher(method) {
1364
- const routes = [];
1365
- let hasOwnRoute = method === METHOD_NAME_ALL;
1366
- [
1367
- this.middleware,
1368
- this.routes
1369
- ].forEach((r)=>{
1370
- const ownRoute = r[method] ? Object.keys(r[method]).map((path)=>[
1371
- path,
1372
- r[method][path]
1373
- ]) : [];
1374
- if (0 !== ownRoute.length) {
1375
- hasOwnRoute ||= true;
1376
- routes.push(...ownRoute);
1377
- } else if (method !== METHOD_NAME_ALL) routes.push(...Object.keys(r[METHOD_NAME_ALL]).map((path)=>[
1378
- path,
1379
- r[METHOD_NAME_ALL][path]
1380
- ]));
1381
- });
1382
- if (!hasOwnRoute) return null;
1383
- return buildMatcherFromPreprocessedRoutes(routes);
1384
- }
1385
- };
1386
- var SmartRouter = class {
1387
- name = "SmartRouter";
1388
- routers = [];
1389
- routes = [];
1390
- constructor(init){
1391
- Object.assign(this, init);
1392
- }
1393
- add(method, path, handler) {
1394
- if (!this.routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1395
- this.routes.push([
1396
- method,
1397
- path,
1398
- handler
1399
- ]);
1400
- }
1401
- match(method, path) {
1402
- if (!this.routes) throw new Error("Fatal error");
1403
- const { routers, routes } = this;
1404
- const len = routers.length;
1405
- let i = 0;
1406
- let res;
1407
- for(; i < len; i++){
1408
- const router = routers[i];
1409
- try {
1410
- routes.forEach((args)=>{
1411
- router.add(...args);
1412
- });
1413
- res = router.match(method, path);
1414
- } catch (e) {
1415
- if (e instanceof UnsupportedPathError) continue;
1416
- throw e;
1417
- }
1418
- this.match = router.match.bind(router);
1419
- this.routers = [
1420
- router
1421
- ];
1422
- this.routes = void 0;
1423
- break;
1424
- }
1425
- if (i === len) throw new Error("Fatal error");
1426
- this.name = `SmartRouter + ${this.activeRouter.name}`;
1427
- return res;
1428
- }
1429
- get activeRouter() {
1430
- if (this.routes || 1 !== this.routers.length) throw new Error("No active router has been determined yet.");
1431
- return this.routers[0];
1432
- }
1433
- };
1434
- var node_Node = class {
1435
- methods;
1436
- children;
1437
- patterns;
1438
- order = 0;
1439
- name;
1440
- params = /* @__PURE__ */ Object.create(null);
1441
- constructor(method, handler, children){
1442
- this.children = children || /* @__PURE__ */ Object.create(null);
1443
- this.methods = [];
1444
- this.name = "";
1445
- if (method && handler) {
1446
- const m = /* @__PURE__ */ Object.create(null);
1447
- m[method] = {
1448
- handler,
1449
- possibleKeys: [],
1450
- score: 0,
1451
- name: this.name
1452
- };
1453
- this.methods = [
1454
- m
1455
- ];
1456
- }
1457
- this.patterns = [];
1458
- }
1459
- insert(method, path, handler) {
1460
- this.name = `${method} ${path}`;
1461
- this.order = ++this.order;
1462
- let curNode = this;
1463
- const parts = splitRoutingPath(path);
1464
- const possibleKeys = [];
1465
- for(let i = 0, len = parts.length; i < len; i++){
1466
- const p = parts[i];
1467
- if (Object.keys(curNode.children).includes(p)) {
1468
- curNode = curNode.children[p];
1469
- const pattern2 = getPattern(p);
1470
- if (pattern2) possibleKeys.push(pattern2[1]);
1471
- continue;
1472
- }
1473
- curNode.children[p] = new node_Node();
1474
- const pattern = getPattern(p);
1475
- if (pattern) {
1476
- curNode.patterns.push(pattern);
1477
- possibleKeys.push(pattern[1]);
1478
- }
1479
- curNode = curNode.children[p];
1480
- }
1481
- if (!curNode.methods.length) curNode.methods = [];
1482
- const m = /* @__PURE__ */ Object.create(null);
1483
- const handlerSet = {
1484
- handler,
1485
- possibleKeys: possibleKeys.filter((v, i, a)=>a.indexOf(v) === i),
1486
- name: this.name,
1487
- score: this.order
1488
- };
1489
- m[method] = handlerSet;
1490
- curNode.methods.push(m);
1491
- return curNode;
1492
- }
1493
- gHSets(node, method, nodeParams, params) {
1494
- const handlerSets = [];
1495
- for(let i = 0, len = node.methods.length; i < len; i++){
1496
- const m = node.methods[i];
1497
- const handlerSet = m[method] || m[METHOD_NAME_ALL];
1498
- const processedSet = /* @__PURE__ */ Object.create(null);
1499
- if (void 0 !== handlerSet) {
1500
- handlerSet.params = /* @__PURE__ */ Object.create(null);
1501
- handlerSet.possibleKeys.forEach((key)=>{
1502
- const processed = processedSet[handlerSet.name];
1503
- handlerSet.params[key] = params[key] && !processed ? params[key] : nodeParams[key] ?? params[key];
1504
- processedSet[handlerSet.name] = true;
1505
- });
1506
- handlerSets.push(handlerSet);
1507
- }
1508
- }
1509
- return handlerSets;
1510
- }
1511
- search(method, path) {
1512
- const handlerSets = [];
1513
- this.params = /* @__PURE__ */ Object.create(null);
1514
- const curNode = this;
1515
- let curNodes = [
1516
- curNode
1517
- ];
1518
- const parts = splitPath(path);
1519
- for(let i = 0, len = parts.length; i < len; i++){
1520
- const part = parts[i];
1521
- const isLast = i === len - 1;
1522
- const tempNodes = [];
1523
- for(let j = 0, len2 = curNodes.length; j < len2; j++){
1524
- const node = curNodes[j];
1525
- const nextNode = node.children[part];
1526
- if (nextNode) {
1527
- nextNode.params = node.params;
1528
- if (true === isLast) {
1529
- if (nextNode.children["*"]) handlerSets.push(...this.gHSets(nextNode.children["*"], method, node.params, /* @__PURE__ */ Object.create(null)));
1530
- handlerSets.push(...this.gHSets(nextNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1531
- } else tempNodes.push(nextNode);
1532
- }
1533
- for(let k = 0, len3 = node.patterns.length; k < len3; k++){
1534
- const pattern = node.patterns[k];
1535
- const params = {
1536
- ...node.params
1537
- };
1538
- if ("*" === pattern) {
1539
- const astNode = node.children["*"];
1540
- if (astNode) {
1541
- handlerSets.push(...this.gHSets(astNode, method, node.params, /* @__PURE__ */ Object.create(null)));
1542
- tempNodes.push(astNode);
1543
- }
1544
- continue;
1545
- }
1546
- if ("" === part) continue;
1547
- const [key, name, matcher] = pattern;
1548
- const child = node.children[key];
1549
- const restPathString = parts.slice(i).join("/");
1550
- if (matcher instanceof RegExp && matcher.test(restPathString)) {
1551
- params[name] = restPathString;
1552
- handlerSets.push(...this.gHSets(child, method, node.params, params));
1553
- continue;
1554
- }
1555
- if (true === matcher || matcher instanceof RegExp && matcher.test(part)) {
1556
- if ("string" == typeof key) {
1557
- params[name] = part;
1558
- if (true === isLast) {
1559
- handlerSets.push(...this.gHSets(child, method, params, node.params));
1560
- if (child.children["*"]) handlerSets.push(...this.gHSets(child.children["*"], method, params, node.params));
1561
- } else {
1562
- child.params = params;
1563
- tempNodes.push(child);
1564
- }
1565
- }
1566
- }
1567
- }
1568
- }
1569
- curNodes = tempNodes;
1570
- }
1571
- const results = handlerSets.sort((a, b)=>a.score - b.score);
1572
- return [
1573
- results.map(({ handler, params })=>[
1574
- handler,
1575
- params
1576
- ])
1577
- ];
1578
- }
1579
- };
1580
- var TrieRouter = class {
1581
- name = "TrieRouter";
1582
- node;
1583
- constructor(){
1584
- this.node = new node_Node();
1585
- }
1586
- add(method, path, handler) {
1587
- const results = checkOptionalParameter(path);
1588
- if (results) {
1589
- for (const p of results)this.node.insert(method, p, handler);
1590
- return;
1591
- }
1592
- this.node.insert(method, path, handler);
1593
- }
1594
- match(method, path) {
1595
- return this.node.search(method, path);
1596
- }
1597
- };
1598
- var hono_Hono = class extends Hono {
1599
- constructor(options = {}){
1600
- super(options);
1601
- this.router = options.router ?? new SmartRouter({
1602
- routers: [
1603
- new RegExpRouter(),
1604
- new TrieRouter()
1605
- ]
1606
- });
1607
- }
1608
- };
1609
- var _validateReport = __webpack_require__("../../node_modules/.pnpm/typia@8.0.3_@samchon+openapi@3.1.0_typescript@5.8.3/node_modules/typia/lib/internal/_validateReport.js");
1610
- var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
1611
- var validCookieValueRegEx = /^[ !#-:<-[\]-~]*$/;
1612
- var parse = (cookie, name)=>{
1613
- const pairs = cookie.trim().split(";");
1614
- return pairs.reduce((parsedCookie, pairStr)=>{
1615
- pairStr = pairStr.trim();
1616
- const valueStartPos = pairStr.indexOf("=");
1617
- if (-1 === valueStartPos) return parsedCookie;
1618
- const cookieName = pairStr.substring(0, valueStartPos).trim();
1619
- if (name && name !== cookieName || !validCookieNameRegEx.test(cookieName)) return parsedCookie;
1620
- let cookieValue = pairStr.substring(valueStartPos + 1).trim();
1621
- if (cookieValue.startsWith('"') && cookieValue.endsWith('"')) cookieValue = cookieValue.slice(1, -1);
1622
- if (validCookieValueRegEx.test(cookieValue)) parsedCookie[cookieName] = decodeURIComponent_(cookieValue);
1623
- return parsedCookie;
1624
- }, {});
1625
- };
1626
- var getCookie = (c, key, prefix)=>{
1627
- const cookie = c.req.raw.headers.get("Cookie");
1628
- if ("string" == typeof key) {
1629
- if (!cookie) return;
1630
- let finalKey = key;
1631
- if ("secure" === prefix) finalKey = "__Secure-" + key;
1632
- else if ("host" === prefix) finalKey = "__Host-" + key;
1633
- const obj2 = parse(cookie, finalKey);
1634
- return obj2[finalKey];
1635
- }
1636
- if (!cookie) return {};
1637
- const obj = parse(cookie);
1638
- return obj;
1639
- };
1640
- var HTTPException = class extends Error {
1641
- res;
1642
- status;
1643
- constructor(status = 500, options){
1644
- super(options?.message, {
1645
- cause: options?.cause
1646
- });
1647
- this.res = options?.res;
1648
- this.status = status;
1649
- }
1650
- getResponse() {
1651
- if (this.res) {
1652
- const newResponse = new Response(this.res.body, {
1653
- status: this.status,
1654
- headers: this.res.headers
1655
- });
1656
- return newResponse;
1657
- }
1658
- return new Response(this.message, {
1659
- status: this.status
1660
- });
1661
- }
1662
- };
1663
- var bufferToFormData = (arrayBuffer, contentType)=>{
1664
- const response = new Response(arrayBuffer, {
1665
- headers: {
1666
- "Content-Type": contentType
1667
- }
1668
- });
1669
- return response.formData();
1670
- };
1671
- var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1672
- var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
1673
- var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
1674
- var validator = (target, validationFunc)=>async (c, next)=>{
1675
- let value = {};
1676
- const contentType = c.req.header("Content-Type");
1677
- switch(target){
1678
- case "json":
1679
- if (!contentType || !jsonRegex.test(contentType)) break;
1680
- try {
1681
- value = await c.req.json();
1682
- } catch {
1683
- const message = "Malformed JSON in request body";
1684
- throw new HTTPException(400, {
1685
- message
1686
- });
1687
- }
1688
- break;
1689
- case "form":
1690
- {
1691
- if (!contentType || !(multipartRegex.test(contentType) || urlencodedRegex.test(contentType))) break;
1692
- let formData;
1693
- if (c.req.bodyCache.formData) formData = await c.req.bodyCache.formData;
1694
- else try {
1695
- const arrayBuffer = await c.req.arrayBuffer();
1696
- formData = await bufferToFormData(arrayBuffer, contentType);
1697
- c.req.bodyCache.formData = formData;
1698
- } catch (e) {
1699
- let message = "Malformed FormData request.";
1700
- message += e instanceof Error ? ` ${e.message}` : ` ${String(e)}`;
1701
- throw new HTTPException(400, {
1702
- message
1703
- });
1704
- }
1705
- const form = {};
1706
- formData.forEach((value2, key)=>{
1707
- if (key.endsWith("[]")) (form[key] ??= []).push(value2);
1708
- else if (Array.isArray(form[key])) form[key].push(value2);
1709
- else if (key in form) form[key] = [
1710
- form[key],
1711
- value2
1712
- ];
1713
- else form[key] = value2;
1714
- });
1715
- value = form;
1716
- break;
1717
- }
1718
- case "query":
1719
- value = Object.fromEntries(Object.entries(c.req.queries()).map(([k, v])=>1 === v.length ? [
1720
- k,
1721
- v[0]
1722
- ] : [
1723
- k,
1724
- v
1725
- ]));
1726
- break;
1727
- case "param":
1728
- value = c.req.param();
1729
- break;
1730
- case "header":
1731
- value = c.req.header();
1732
- break;
1733
- case "cookie":
1734
- value = getCookie(c);
1735
- break;
1736
- }
1737
- const res = await validationFunc(value, c);
1738
- if (res instanceof Response) return res;
1739
- c.req.addValidatedData(target, res);
1740
- await next();
1741
- };
1742
- const typiaValidator = (target, validate, hook)=>validator(target, async (value, c)=>{
1743
- const result = validate(value);
1744
- if (hook) {
1745
- const hookResult = await hook({
1746
- ...result,
1747
- data: value
1748
- }, c);
1749
- if (hookResult) {
1750
- if (hookResult instanceof Response || hookResult instanceof Promise) return hookResult;
1751
- if ('response' in hookResult) return hookResult.response;
1752
- }
1753
- }
1754
- if (!result.success) return c.json({
1755
- success: false,
1756
- error: result.errors
1757
- }, 400);
1758
- return result.data;
1759
- });
1760
- const plugin_core_namespaceObject = require("@hot-updater/plugin-core");
1761
- const queryBundlesSchema = (()=>{
1762
- const _io0 = (input)=>(void 0 === input.channel || "string" == typeof input.channel) && (void 0 === input.platform || "ios" === input.platform || "android" === input.platform) && (void 0 === input.limit || "string" == typeof input.limit) && (void 0 === input.offset || "string" == typeof input.offset);
1763
- const _vo0 = (input, _path, _exceptionable = true)=>[
1764
- void 0 === input.channel || "string" == typeof input.channel || _report(_exceptionable, {
1765
- path: _path + ".channel",
1766
- expected: "(string | undefined)",
1767
- value: input.channel
1768
- }),
1769
- void 0 === input.platform || "ios" === input.platform || "android" === input.platform || _report(_exceptionable, {
1770
- path: _path + ".platform",
1771
- expected: "(\"android\" | \"ios\" | undefined)",
1772
- value: input.platform
1773
- }),
1774
- void 0 === input.limit || "string" == typeof input.limit || _report(_exceptionable, {
1775
- path: _path + ".limit",
1776
- expected: "(string | undefined)",
1777
- value: input.limit
1778
- }),
1779
- void 0 === input.offset || "string" == typeof input.offset || _report(_exceptionable, {
1780
- path: _path + ".offset",
1781
- expected: "(string | undefined)",
1782
- value: input.offset
1783
- })
1784
- ].every((flag)=>flag);
1785
- const __is = (input)=>"object" == typeof input && null !== input && false === Array.isArray(input) && _io0(input);
1786
- let errors;
1787
- let _report;
1788
- return (input)=>{
1789
- if (false === __is(input)) {
1790
- errors = [];
1791
- _report = _validateReport._validateReport(errors);
1792
- ((input, _path, _exceptionable = true)=>("object" == typeof input && null !== input && false === Array.isArray(input) || _report(true, {
1793
- path: _path + "",
1794
- expected: "__type",
1795
- value: input
1796
- })) && _vo0(input, _path + "", true) || _report(true, {
1797
- path: _path + "",
1798
- expected: "__type",
1799
- value: input
1800
- }))(input, "$input", true);
1801
- const success = 0 === errors.length;
1802
- return success ? {
1803
- success,
1804
- data: input
1805
- } : {
1806
- success,
1807
- errors,
1808
- data: input
1809
- };
1810
- }
1811
- return {
1812
- success: true,
1813
- data: input
1814
- };
1815
- };
1816
- })();
1817
- const paramBundleIdSchema = (()=>{
1818
- const _io0 = (input)=>"string" == typeof input.bundleId;
1819
- const _vo0 = (input, _path, _exceptionable = true)=>[
1820
- "string" == typeof input.bundleId || _report(_exceptionable, {
1821
- path: _path + ".bundleId",
1822
- expected: "string",
1823
- value: input.bundleId
1824
- })
1825
- ].every((flag)=>flag);
1826
- const __is = (input)=>"object" == typeof input && null !== input && _io0(input);
1827
- let errors;
1828
- let _report;
1829
- return (input)=>{
1830
- if (false === __is(input)) {
1831
- errors = [];
1832
- _report = _validateReport._validateReport(errors);
1833
- ((input, _path, _exceptionable = true)=>("object" == typeof input && null !== input || _report(true, {
1834
- path: _path + "",
1835
- expected: "__type",
1836
- value: input
1837
- })) && _vo0(input, _path + "", true) || _report(true, {
1838
- path: _path + "",
1839
- expected: "__type",
1840
- value: input
1841
- }))(input, "$input", true);
1842
- const success = 0 === errors.length;
1843
- return success ? {
1844
- success,
1845
- data: input
1846
- } : {
1847
- success,
1848
- errors,
1849
- data: input
1850
- };
1851
- }
1852
- return {
1853
- success: true,
1854
- data: input
1855
- };
1856
- };
1857
- })();
1858
- const updateBundleSchema = (()=>{
1859
- const _io0 = (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.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) && (void 0 === input.channel || "string" == typeof input.channel);
1860
- const _vo0 = (input, _path, _exceptionable = true)=>[
1861
- void 0 === input.id || "string" == typeof input.id || _report(_exceptionable, {
1862
- path: _path + ".id",
1863
- expected: "(string | undefined)",
1864
- value: input.id
1865
- }),
1866
- void 0 === input.platform || "ios" === input.platform || "android" === input.platform || _report(_exceptionable, {
1867
- path: _path + ".platform",
1868
- expected: "(\"android\" | \"ios\" | undefined)",
1869
- value: input.platform
1870
- }),
1871
- void 0 === input.targetAppVersion || "string" == typeof input.targetAppVersion || _report(_exceptionable, {
1872
- path: _path + ".targetAppVersion",
1873
- expected: "(string | undefined)",
1874
- value: input.targetAppVersion
1875
- }),
1876
- void 0 === input.shouldForceUpdate || "boolean" == typeof input.shouldForceUpdate || _report(_exceptionable, {
1877
- path: _path + ".shouldForceUpdate",
1878
- expected: "(boolean | undefined)",
1879
- value: input.shouldForceUpdate
1880
- }),
1881
- void 0 === input.enabled || "boolean" == typeof input.enabled || _report(_exceptionable, {
1882
- path: _path + ".enabled",
1883
- expected: "(boolean | undefined)",
1884
- value: input.enabled
1885
- }),
1886
- void 0 === input.fileHash || "string" == typeof input.fileHash || _report(_exceptionable, {
1887
- path: _path + ".fileHash",
1888
- expected: "(string | undefined)",
1889
- value: input.fileHash
1890
- }),
1891
- null === input.gitCommitHash || void 0 === input.gitCommitHash || "string" == typeof input.gitCommitHash || _report(_exceptionable, {
1892
- path: _path + ".gitCommitHash",
1893
- expected: "(null | string | undefined)",
1894
- value: input.gitCommitHash
1895
- }),
1896
- null === input.message || void 0 === input.message || "string" == typeof input.message || _report(_exceptionable, {
1897
- path: _path + ".message",
1898
- expected: "(null | string | undefined)",
1899
- value: input.message
1900
- }),
1901
- void 0 === input.channel || "string" == typeof input.channel || _report(_exceptionable, {
1902
- path: _path + ".channel",
1903
- expected: "(string | undefined)",
1904
- value: input.channel
1905
- })
1906
- ].every((flag)=>flag);
1907
- const __is = (input)=>"object" == typeof input && null !== input && false === Array.isArray(input) && _io0(input);
1908
- let errors;
1909
- let _report;
1910
- return (input)=>{
1911
- if (false === __is(input)) {
1912
- errors = [];
1913
- _report = _validateReport._validateReport(errors);
1914
- ((input, _path, _exceptionable = true)=>("object" == typeof input && null !== input && false === Array.isArray(input) || _report(true, {
1915
- path: _path + "",
1916
- expected: "Partial<Bundle>",
1917
- value: input
1918
- })) && _vo0(input, _path + "", true) || _report(true, {
1919
- path: _path + "",
1920
- expected: "Partial<Bundle>",
1921
- value: input
1922
- }))(input, "$input", true);
1923
- const success = 0 === errors.length;
1924
- return success ? {
1925
- success,
1926
- data: input
1927
- } : {
1928
- success,
1929
- errors,
1930
- data: input
1931
- };
1932
- }
1933
- return {
1934
- success: true,
1935
- data: input
1936
- };
1937
- };
1938
- })();
1939
- let configPromise = null;
1940
- const prepareConfig = async ()=>{
1941
- if (!configPromise) configPromise = (async ()=>{
1942
- try {
1943
- const config = await (0, plugin_core_namespaceObject.loadConfig)(null);
1944
- const databasePlugin = await config?.database({
1945
- cwd: (0, plugin_core_namespaceObject.getCwd)()
1946
- }) ?? null;
1947
- if (!databasePlugin) throw new Error("Database plugin initialization failed");
1948
- return {
1949
- config,
1950
- databasePlugin
1951
- };
1952
- } catch (error) {
1953
- console.error("Error during configuration initialization:", error);
1954
- throw error;
1955
- }
1956
- })();
1957
- return configPromise;
1958
- };
1959
- const rpc = new hono_Hono().get("/config", async (c)=>{
1960
- try {
1961
- const { config } = await prepareConfig();
1962
- return c.json({
1963
- console: config.console
1964
- });
1965
- } catch (error) {
1966
- console.error("Error during config retrieval:", error);
1967
- throw error;
1968
- }
1969
- }).get("/channels", async (c)=>{
1970
- try {
1971
- const { databasePlugin } = await prepareConfig();
1972
- const channels = await databasePlugin.getChannels();
1973
- return c.json(channels ?? []);
1974
- } catch (error) {
1975
- console.error("Error during channel retrieval:", error);
1976
- throw error;
1977
- }
1978
- }).get("/config-loaded", (c)=>{
1979
- try {
1980
- const isLoaded = !!configPromise;
1981
- return c.json({
1982
- configLoaded: isLoaded
1983
- });
1984
- } catch (error) {
1985
- console.error("Error during config loaded retrieval:", error);
1986
- throw error;
1987
- }
1988
- }).get("/bundles", typiaValidator("query", queryBundlesSchema), async (c)=>{
1989
- try {
1990
- const query = c.req.valid("query");
1991
- const { databasePlugin } = await prepareConfig();
1992
- const bundles = await databasePlugin.getBundles({
1993
- where: {
1994
- channel: query.channel ?? void 0,
1995
- platform: query.platform ?? void 0
1996
- },
1997
- limit: query.limit ? Number(query.limit) : void 0,
1998
- offset: query.offset ? Number(query.offset) : void 0
1999
- });
2000
- return c.json(bundles ?? []);
2001
- } catch (error) {
2002
- console.error("Error during bundle retrieval:", error);
2003
- throw error;
2004
- }
2005
- }).get("/bundles/:bundleId", typiaValidator("param", paramBundleIdSchema), async (c)=>{
2006
- try {
2007
- const { bundleId } = c.req.valid("param");
2008
- const { databasePlugin } = await prepareConfig();
2009
- const bundle = await databasePlugin.getBundleById(bundleId);
2010
- return c.json(bundle ?? null);
2011
- } catch (error) {
2012
- console.error("Error during bundle retrieval:", error);
2013
- throw error;
2014
- }
2015
- }).patch("/bundles/:bundleId", typiaValidator("json", updateBundleSchema), async (c)=>{
2016
- try {
2017
- const bundleId = c.req.param("bundleId");
2018
- const partialBundle = c.req.valid("json");
2019
- if (!bundleId) return c.json({
2020
- error: "Target bundle ID is required"
2021
- }, 400);
2022
- const { databasePlugin } = await prepareConfig();
2023
- await databasePlugin.updateBundle(bundleId, partialBundle);
2024
- await databasePlugin.commitBundle();
2025
- return c.json({
2026
- success: true
2027
- });
2028
- } catch (error) {
2029
- console.error("Error during bundle update:", error);
2030
- if (error && "object" == typeof error && "message" in error) return c.json({
2031
- error: error.message
2032
- }, 500);
2033
- return c.json({
2034
- error: "Unknown error"
2035
- }, 500);
2036
- }
2037
- });
2038
- const src_server_dirname = external_path_default().dirname((0, external_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
2039
- const relativePathToScript = external_path_default().relative(process.cwd(), src_server_dirname);
2040
- const src_server_app = new hono_Hono().get("/ping", (c)=>c.text("pong")).route("/rpc", rpc).use("/assets/*", serveStatic({
2041
- root: relativePathToScript
2042
- })).get("*", serveStatic({
2043
- root: relativePathToScript,
2044
- path: "index.html"
2045
- }));
2046
- const src_server = src_server_app;
1800
+ const updateBundleSchema = (() => {
1801
+ const _io0 = (input) => (void 0 === input.id || "string" === typeof input.id) && (void 0 === input.platform || "ios" === input.platform || "android" === input.platform) && (void 0 === input.shouldForceUpdate || "boolean" === typeof input.shouldForceUpdate) && (void 0 === input.enabled || "boolean" === typeof input.enabled) && (void 0 === input.fileHash || "string" === typeof input.fileHash) && (void 0 === input.storageUri || "string" === typeof input.storageUri) && (null === input.gitCommitHash || void 0 === input.gitCommitHash || "string" === typeof input.gitCommitHash) && (null === input.message || void 0 === input.message || "string" === typeof input.message) && (void 0 === input.channel || "string" === typeof input.channel) && (null === input.targetAppVersion || void 0 === input.targetAppVersion || "string" === typeof input.targetAppVersion) && (null === input.fingerprintHash || void 0 === input.fingerprintHash || "string" === typeof input.fingerprintHash) && (void 0 === input.metadata || "object" === typeof input.metadata && null !== input.metadata && false === Array.isArray(input.metadata) && _io1(input.metadata));
1802
+ const _io1 = (input) => void 0 === input.app_version || "string" === typeof input.app_version;
1803
+ const _vo0 = (input, _path, _exceptionable = true) => [
1804
+ void 0 === input.id || "string" === typeof input.id || _report(_exceptionable, {
1805
+ path: _path + ".id",
1806
+ expected: "(string | undefined)",
1807
+ value: input.id
1808
+ }),
1809
+ void 0 === input.platform || "ios" === input.platform || "android" === input.platform || _report(_exceptionable, {
1810
+ path: _path + ".platform",
1811
+ expected: "(\"android\" | \"ios\" | undefined)",
1812
+ value: input.platform
1813
+ }),
1814
+ void 0 === input.shouldForceUpdate || "boolean" === typeof input.shouldForceUpdate || _report(_exceptionable, {
1815
+ path: _path + ".shouldForceUpdate",
1816
+ expected: "(boolean | undefined)",
1817
+ value: input.shouldForceUpdate
1818
+ }),
1819
+ void 0 === input.enabled || "boolean" === typeof input.enabled || _report(_exceptionable, {
1820
+ path: _path + ".enabled",
1821
+ expected: "(boolean | undefined)",
1822
+ value: input.enabled
1823
+ }),
1824
+ void 0 === input.fileHash || "string" === typeof input.fileHash || _report(_exceptionable, {
1825
+ path: _path + ".fileHash",
1826
+ expected: "(string | undefined)",
1827
+ value: input.fileHash
1828
+ }),
1829
+ void 0 === input.storageUri || "string" === typeof input.storageUri || _report(_exceptionable, {
1830
+ path: _path + ".storageUri",
1831
+ expected: "(string | undefined)",
1832
+ value: input.storageUri
1833
+ }),
1834
+ null === input.gitCommitHash || void 0 === input.gitCommitHash || "string" === typeof input.gitCommitHash || _report(_exceptionable, {
1835
+ path: _path + ".gitCommitHash",
1836
+ expected: "(null | string | undefined)",
1837
+ value: input.gitCommitHash
1838
+ }),
1839
+ null === input.message || void 0 === input.message || "string" === typeof input.message || _report(_exceptionable, {
1840
+ path: _path + ".message",
1841
+ expected: "(null | string | undefined)",
1842
+ value: input.message
1843
+ }),
1844
+ void 0 === input.channel || "string" === typeof input.channel || _report(_exceptionable, {
1845
+ path: _path + ".channel",
1846
+ expected: "(string | undefined)",
1847
+ value: input.channel
1848
+ }),
1849
+ null === input.targetAppVersion || void 0 === input.targetAppVersion || "string" === typeof input.targetAppVersion || _report(_exceptionable, {
1850
+ path: _path + ".targetAppVersion",
1851
+ expected: "(null | string | undefined)",
1852
+ value: input.targetAppVersion
1853
+ }),
1854
+ null === input.fingerprintHash || void 0 === input.fingerprintHash || "string" === typeof input.fingerprintHash || _report(_exceptionable, {
1855
+ path: _path + ".fingerprintHash",
1856
+ expected: "(null | string | undefined)",
1857
+ value: input.fingerprintHash
1858
+ }),
1859
+ void 0 === input.metadata || ("object" === typeof input.metadata && null !== input.metadata && false === Array.isArray(input.metadata) || _report(_exceptionable, {
1860
+ path: _path + ".metadata",
1861
+ expected: "(BundleMetadata | undefined)",
1862
+ value: input.metadata
1863
+ })) && _vo1(input.metadata, _path + ".metadata", _exceptionable) || _report(_exceptionable, {
1864
+ path: _path + ".metadata",
1865
+ expected: "(BundleMetadata | undefined)",
1866
+ value: input.metadata
1867
+ })
1868
+ ].every((flag) => flag);
1869
+ const _vo1 = (input, _path, _exceptionable = true) => [void 0 === input.app_version || "string" === typeof input.app_version || _report(_exceptionable, {
1870
+ path: _path + ".app_version",
1871
+ expected: "(string | undefined)",
1872
+ value: input.app_version
1873
+ })].every((flag) => flag);
1874
+ const __is = (input) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
1875
+ let errors;
1876
+ let _report;
1877
+ return (input) => {
1878
+ if (false === __is(input)) {
1879
+ errors = [];
1880
+ _report = import__validateReport._validateReport(errors);
1881
+ ((input$1, _path, _exceptionable = true) => ("object" === typeof input$1 && null !== input$1 && false === Array.isArray(input$1) || _report(true, {
1882
+ path: _path + "",
1883
+ expected: "Partial<Bundle>",
1884
+ value: input$1
1885
+ })) && _vo0(input$1, _path + "", true) || _report(true, {
1886
+ path: _path + "",
1887
+ expected: "Partial<Bundle>",
1888
+ value: input$1
1889
+ }))(input, "$input", true);
1890
+ const success = 0 === errors.length;
1891
+ return success ? {
1892
+ success,
1893
+ data: input
1894
+ } : {
1895
+ success,
1896
+ errors,
1897
+ data: input
1898
+ };
1899
+ }
1900
+ return {
1901
+ success: true,
1902
+ data: input
1903
+ };
1904
+ };
2047
1905
  })();
2048
- exports["default"] = __webpack_exports__["default"];
2049
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
2050
- "default"
2051
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
2052
- Object.defineProperty(exports, '__esModule', {
2053
- value: true
1906
+ let configPromise = null;
1907
+ const prepareConfig = async () => {
1908
+ if (!configPromise) configPromise = (async () => {
1909
+ try {
1910
+ const config = await (0, __hot_updater_plugin_core.loadConfig)(null);
1911
+ const databasePlugin = await config?.database({ cwd: (0, __hot_updater_plugin_core.getCwd)() }) ?? null;
1912
+ if (!databasePlugin) throw new Error("Database plugin initialization failed");
1913
+ return {
1914
+ config,
1915
+ databasePlugin
1916
+ };
1917
+ } catch (error) {
1918
+ console.error("Error during configuration initialization:", error);
1919
+ throw error;
1920
+ }
1921
+ })();
1922
+ return configPromise;
1923
+ };
1924
+ const rpc = new Hono().get("/config", async (c) => {
1925
+ try {
1926
+ const { config } = await prepareConfig();
1927
+ return c.json({ console: config.console });
1928
+ } catch (error) {
1929
+ console.error("Error during config retrieval:", error);
1930
+ throw error;
1931
+ }
1932
+ }).get("/channels", async (c) => {
1933
+ try {
1934
+ const { databasePlugin } = await prepareConfig();
1935
+ const channels = await databasePlugin.getChannels();
1936
+ return c.json(channels ?? []);
1937
+ } catch (error) {
1938
+ console.error("Error during channel retrieval:", error);
1939
+ throw error;
1940
+ }
1941
+ }).get("/config-loaded", (c) => {
1942
+ try {
1943
+ const isLoaded = !!configPromise;
1944
+ return c.json({ configLoaded: isLoaded });
1945
+ } catch (error) {
1946
+ console.error("Error during config loaded retrieval:", error);
1947
+ throw error;
1948
+ }
1949
+ }).get("/bundles", typiaValidator("query", queryBundlesSchema), async (c) => {
1950
+ try {
1951
+ const query = c.req.valid("query");
1952
+ const { databasePlugin } = await prepareConfig();
1953
+ const bundles = await databasePlugin.getBundles({
1954
+ where: {
1955
+ channel: query.channel ?? void 0,
1956
+ platform: query.platform ?? void 0
1957
+ },
1958
+ limit: query.limit ? Number(query.limit) : void 0,
1959
+ offset: query.offset ? Number(query.offset) : void 0
1960
+ });
1961
+ return c.json(bundles ?? []);
1962
+ } catch (error) {
1963
+ console.error("Error during bundle retrieval:", error);
1964
+ throw error;
1965
+ }
1966
+ }).get("/bundles/:bundleId", typiaValidator("param", paramBundleIdSchema), async (c) => {
1967
+ try {
1968
+ const { bundleId } = c.req.valid("param");
1969
+ const { databasePlugin } = await prepareConfig();
1970
+ const bundle = await databasePlugin.getBundleById(bundleId);
1971
+ return c.json(bundle ?? null);
1972
+ } catch (error) {
1973
+ console.error("Error during bundle retrieval:", error);
1974
+ throw error;
1975
+ }
1976
+ }).patch("/bundles/:bundleId", typiaValidator("json", updateBundleSchema), async (c) => {
1977
+ try {
1978
+ const bundleId = c.req.param("bundleId");
1979
+ const partialBundle = c.req.valid("json");
1980
+ if (!bundleId) return c.json({ error: "Target bundle ID is required" }, 400);
1981
+ const { databasePlugin } = await prepareConfig();
1982
+ await databasePlugin.updateBundle(bundleId, partialBundle);
1983
+ await databasePlugin.commitBundle();
1984
+ return c.json({ success: true });
1985
+ } catch (error) {
1986
+ console.error("Error during bundle update:", error);
1987
+ if (error && typeof error === "object" && "message" in error) return c.json({ error: error.message }, 500);
1988
+ return c.json({ error: "Unknown error" }, 500);
1989
+ }
2054
1990
  });
1991
+
1992
+ //#endregion
1993
+ //#region src-server/index.ts
1994
+ const __dirname$1 = path.default.dirname((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
1995
+ const relativePathToScript = path.default.relative(process.cwd(), __dirname$1);
1996
+ const app = new Hono().get("/ping", (c) => c.text("pong")).route("/rpc", rpc).use("/assets/*", serveStatic({ root: relativePathToScript })).get("*", serveStatic({
1997
+ root: relativePathToScript,
1998
+ path: "index.html"
1999
+ }));
2000
+ var src_server_default = app;
2001
+
2002
+ //#endregion
2003
+ module.exports = src_server_default;