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