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