@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.
- package/dist/index.cjs +1907 -2265
- package/dist/index.html +1 -1
- package/dist/index.js +1866 -2248
- package/dist/src/App.d.ts +2 -0
- package/dist/src/components/spash-screen.d.ts +1 -0
- package/dist/src/components/ui/button.d.ts +15 -0
- package/dist/src/components/ui/label.d.ts +3 -0
- package/dist/src/components/ui/navigation-menu.d.ts +35 -0
- package/dist/src/components/ui/pagination.d.ts +27 -0
- package/dist/src/components/ui/sheet.d.ts +26 -0
- package/dist/src/components/ui/sonner.d.ts +5 -0
- package/dist/src/components/ui/switch.d.ts +20 -0
- package/dist/src/components/ui/table.d.ts +10 -0
- package/dist/src/components/ui/text-field.d.ts +26 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/{index.d.cts → src/lib/api.d.ts} +40 -46
- package/dist/src/lib/extract-timestamp-from-uuidv7.d.ts +1 -0
- package/dist/src/lib/utils.d.ts +2 -0
- package/dist/src/routes/_components/columns.d.ts +3 -0
- package/dist/src/routes/_components/data-table.d.ts +9 -0
- package/dist/src/routes/_components/edit-bundle-sheet-content.d.ts +5 -0
- package/dist/src/routes/index.d.ts +1 -0
- package/dist/{index.d.ts → src-server/index.d.ts} +30 -22
- package/dist/src-server/rpc.d.ts +112 -0
- package/dist/src-server/type.test.d.ts +1 -0
- package/dist/static/css/index.4ed6b07e.css +1 -0
- package/dist/static/js/742.e04944e6.js +5 -0
- package/dist/static/js/index.7055a4a0.js +1 -0
- package/package.json +8 -5
- package/dist/static/css/index.8b7116d7.css +0 -1
- package/dist/static/js/85.cfaeff33.js +0 -5
- package/dist/static/js/index.b8c9ef11.js +0 -1
- /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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return next();
|
|
165
|
-
}
|
|
166
|
-
let filename;
|
|
119
|
+
var addCurrentDirPrefix = (path)=>`./${path}`;
|
|
120
|
+
var getStats = (path)=>{
|
|
121
|
+
let stats;
|
|
167
122
|
try {
|
|
168
|
-
|
|
169
|
-
} catch
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
return
|
|
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
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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 = (
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
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
|
|
395
|
-
|
|
396
|
-
|
|
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
|
|
399
|
-
|
|
400
|
-
|
|
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
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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
|
|
521
|
-
|
|
522
|
-
|
|
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
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
-
|
|
638
|
-
|
|
639
|
-
|
|
526
|
+
Stringify: 1,
|
|
527
|
+
BeforeStream: 2,
|
|
528
|
+
Stream: 3
|
|
640
529
|
};
|
|
641
|
-
var
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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
|
-
|
|
681
|
-
|
|
556
|
+
var setHeaders = (headers, map = {})=>{
|
|
557
|
+
Object.entries(map).forEach(([key, value])=>headers.set(key, value));
|
|
558
|
+
return headers;
|
|
682
559
|
};
|
|
683
|
-
var
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
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
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
return;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
if (
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
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
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
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
|
-
|
|
742
|
-
|
|
743
|
-
|
|
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
|
-
|
|
776
|
-
|
|
777
|
-
|
|
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
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
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
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
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
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
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
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
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
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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
|
-
|
|
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 = [
|
|
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
|
-
|
|
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
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
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
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
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
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
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
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
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
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
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
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
|
|
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
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
return 1;
|
|
1219
|
-
|
|
1220
|
-
|
|
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
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
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
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
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
|
|
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
|
-
|
|
1308
|
-
|
|
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
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
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
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
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 = [
|
|
1140
|
+
var nullMatcher = [
|
|
1141
|
+
/^$/,
|
|
1142
|
+
[],
|
|
1143
|
+
/* @__PURE__ */ Object.create(null)
|
|
1144
|
+
];
|
|
1375
1145
|
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
1376
|
-
function buildWildcardRegExp(
|
|
1377
|
-
|
|
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
|
-
|
|
1150
|
+
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
1386
1151
|
}
|
|
1387
1152
|
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
(
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
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,
|
|
1445
|
-
|
|
1446
|
-
return
|
|
1447
|
-
|
|
1448
|
-
|
|
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
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
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
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
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
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
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
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
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
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
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
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
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
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
curNode
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
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
|
-
|
|
1721
|
-
} else {
|
|
1722
|
-
tempNodes.push(nextNode);
|
|
1723
|
-
}
|
|
1426
|
+
curNode = curNode.children[p];
|
|
1724
1427
|
}
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
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
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
if (
|
|
1753
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
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
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
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
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
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
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
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
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
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
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
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
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
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
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
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
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
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
|
-
|
|
1699
|
+
return store2?.get(lang);
|
|
1980
1700
|
}
|
|
1981
1701
|
var store3;
|
|
1982
1702
|
function getSchemaMessage(lang) {
|
|
1983
|
-
|
|
1703
|
+
return store3?.get(lang);
|
|
1984
1704
|
}
|
|
1985
1705
|
var store4;
|
|
1986
1706
|
function getSpecificMessage(reference, lang) {
|
|
1987
|
-
|
|
1707
|
+
return store4?.get(reference)?.get(lang);
|
|
1988
1708
|
}
|
|
1989
1709
|
function _stringify(input) {
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
return
|
|
1993
|
-
|
|
1994
|
-
|
|
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
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
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
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
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
|
-
|
|
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
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
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
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
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
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
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
|
-
|
|
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
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
dataset
|
|
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
|
-
|
|
2172
|
-
_addIssue(this, "type", dataset, config2);
|
|
2173
|
-
}
|
|
2174
|
-
return dataset;
|
|
2175
|
-
}
|
|
2176
|
-
};
|
|
1853
|
+
};
|
|
2177
1854
|
}
|
|
2178
1855
|
function optional(wrapped, ...args) {
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
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
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
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
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1939
|
+
if (untypedDatasets?.length === 1) return untypedDatasets[0];
|
|
1940
|
+
_addIssue(this, "type", dataset, config2, {
|
|
1941
|
+
issues: _subIssues(untypedDatasets)
|
|
1942
|
+
});
|
|
2266
1943
|
}
|
|
2267
|
-
|
|
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
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
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
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
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
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
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
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
)
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
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
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
}).get("/
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
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 (!
|
|
2386
|
-
|
|
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
|
-
)
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
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 (!
|
|
2406
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|