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