@hot-updater/cloudflare 1.2.0-rc.59 → 1.2.0-rc.60
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/package.json +8 -8
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +1101 -1347
- package/worker/dist/index.js.map +4 -4
package/worker/dist/index.js
CHANGED
|
@@ -1949,8 +1949,8 @@ var verifyRows = /* @__PURE__ */ __name((table, request, rows) => {
|
|
|
1949
1949
|
if (!matchesQuery(table, index, request, row)) fail(`${table.name}.${index.name} returned a row outside the request.`);
|
|
1950
1950
|
const tuple = indexOrderTuple(table, index, row);
|
|
1951
1951
|
if (previous !== void 0) {
|
|
1952
|
-
const
|
|
1953
|
-
if (request.order === "asc" ?
|
|
1952
|
+
const order2 = compareTuples(previous, tuple);
|
|
1953
|
+
if (request.order === "asc" ? order2 >= 0 : order2 <= 0) fail(`${table.name}.${index.name} returned rows out of order.`);
|
|
1954
1954
|
}
|
|
1955
1955
|
previous = tuple;
|
|
1956
1956
|
}
|
|
@@ -2316,8 +2316,8 @@ var pruneStatements = /* @__PURE__ */ __name((dialect, table, tablePrefix, limit
|
|
|
2316
2316
|
const quote = /* @__PURE__ */ __name((name2) => quoteSql(dialect, name2), "quote");
|
|
2317
2317
|
const name = quote(`${tablePrefix}${table.name}`);
|
|
2318
2318
|
const at = quote(table.retention.column);
|
|
2319
|
-
const
|
|
2320
|
-
const list = /* @__PURE__ */ __name((alias, direction = "") =>
|
|
2319
|
+
const order2 = retentionOrder(table).columns.map(quote);
|
|
2320
|
+
const list = /* @__PURE__ */ __name((alias, direction = "") => order2.map((column) => `${alias}.${column}${direction}`).join(", "), "list");
|
|
2321
2321
|
const oldest = /* @__PURE__ */ __name((before) => `SELECT ${list("i")} FROM ${name} i WHERE i.${at} <= ${before()} ORDER BY ${list("i", " ASC")} LIMIT ${limit}`, "oldest");
|
|
2322
2322
|
const doomed = /* @__PURE__ */ __name((alias, before) => `(${list(alias)}) <= (SELECT ${list("b")} FROM (${oldest(before)}) b ORDER BY ${list("b", " DESC")} LIMIT 1) AND ${alias}.${at} <= ${before()}`, "doomed");
|
|
2323
2323
|
const entries = table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => quote(`${tablePrefix}${table.name}__${index.name}`));
|
|
@@ -2330,7 +2330,7 @@ var pruneStatements = /* @__PURE__ */ __name((dialect, table, tablePrefix, limit
|
|
|
2330
2330
|
const into = quote(`${tablePrefix}${table.name}__${index.name}`);
|
|
2331
2331
|
return (before) => `DELETE FROM ${into} WHERE (${columns.map(quote).join(", ")}) IN (SELECT ${values.join(", ")} FROM ${name} b${each.join("")} WHERE ${doomed("b", before)})`;
|
|
2332
2332
|
}), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
|
|
2333
|
-
if (dialect === "mysql") return [...entries.map((index) => (before) => `DELETE e FROM ${index} e JOIN (${oldest(before)}) d ON ${keyOf("e", "d")}`), (before) => `DELETE FROM ${name} WHERE ${at} <= ${before()} ORDER BY ${
|
|
2333
|
+
if (dialect === "mysql") return [...entries.map((index) => (before) => `DELETE e FROM ${index} e JOIN (${oldest(before)}) d ON ${keyOf("e", "d")}`), (before) => `DELETE FROM ${name} WHERE ${at} <= ${before()} ORDER BY ${order2.join(", ")} LIMIT ${limit}`];
|
|
2334
2334
|
return [...entries.map((index) => (before) => `DELETE FROM ${index} WHERE EXISTS (SELECT * FROM ${name} b WHERE ${keyOf("b", index)} AND ${doomed("b", before)})`), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
|
|
2335
2335
|
}, "pruneStatements");
|
|
2336
2336
|
|
|
@@ -4479,7 +4479,7 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
|
|
|
4479
4479
|
if (index === void 0) throw new DatabaseQueryError(`${table.name} has no index ${input.index}.`);
|
|
4480
4480
|
const where = input.where ?? {};
|
|
4481
4481
|
if (!sameFields(Object.keys(where), index.eq)) throw new DatabaseQueryError(`${table.name}.${index.name} reads need where on exactly: ${index.eq.join(", ") || "(none)"}.`);
|
|
4482
|
-
const { limit, order = "asc", range } = input;
|
|
4482
|
+
const { limit, order: order2 = "asc", range } = input;
|
|
4483
4483
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxPageSize) throw new DatabaseQueryError(`limit must be 1\u2013${maxPageSize}.`);
|
|
4484
4484
|
const columns = indexOrderColumns(table, index);
|
|
4485
4485
|
const eq = index.eq.map((field) => keyValue(where[field], `${table.name}.${field}`));
|
|
@@ -4487,14 +4487,14 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
|
|
|
4487
4487
|
table.name,
|
|
4488
4488
|
index.name,
|
|
4489
4489
|
eq,
|
|
4490
|
-
|
|
4490
|
+
order2,
|
|
4491
4491
|
range
|
|
4492
4492
|
]);
|
|
4493
4493
|
let lower = bound(range?.gt, range?.gte, columns);
|
|
4494
4494
|
let upper = bound(range?.lt, range?.lte, columns);
|
|
4495
4495
|
if (input.cursor !== void 0) {
|
|
4496
4496
|
const values = decodeCursor(scope, input.cursor);
|
|
4497
|
-
if (
|
|
4497
|
+
if (order2 === "asc") lower = {
|
|
4498
4498
|
values,
|
|
4499
4499
|
inclusive: false
|
|
4500
4500
|
};
|
|
@@ -4507,7 +4507,7 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
|
|
|
4507
4507
|
request: {
|
|
4508
4508
|
index: index.name,
|
|
4509
4509
|
eq,
|
|
4510
|
-
order,
|
|
4510
|
+
order: order2,
|
|
4511
4511
|
limit,
|
|
4512
4512
|
...lower === void 0 ? {} : { lower },
|
|
4513
4513
|
...upper === void 0 ? {} : { upper }
|
|
@@ -4840,9 +4840,9 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
4840
4840
|
if (!isMultiIndex(table, index) || changed && !columns.some((column) => changed.includes(column))) return [];
|
|
4841
4841
|
const into = tableOf(table, index);
|
|
4842
4842
|
const found = row ? indexEntries(table, index, row) : [];
|
|
4843
|
-
const
|
|
4843
|
+
const order2 = found.length > 0 ? indexOrderTuple(table, index, row) : [];
|
|
4844
4844
|
return [...stale ? [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`)] : [], ...found.map((eq) => sql((bind) => {
|
|
4845
|
-
const values = [...eq, ...
|
|
4845
|
+
const values = [...eq, ...order2].map((value) => bind(value));
|
|
4846
4846
|
return insert(bind, into, columns, values);
|
|
4847
4847
|
}))];
|
|
4848
4848
|
}), "entries");
|
|
@@ -4931,17 +4931,17 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
4931
4931
|
async query(table, request) {
|
|
4932
4932
|
const index = findPhysicalIndex(table, request.index);
|
|
4933
4933
|
if (!Number.isSafeInteger(request.limit) || request.limit < 1) throw new RangeError("query limit must be a positive integer.");
|
|
4934
|
-
const
|
|
4934
|
+
const order2 = indexOrderColumns(table, index);
|
|
4935
4935
|
const multi = isMultiIndex(table, index);
|
|
4936
4936
|
const source = multi ? `${tableOf(table, index)} i JOIN ${tableOf(table)} b ON ${table.key.map((column) => `b.${quote(column)} = i.${quote(column)}`).join(" AND ")}` : `${tableOf(table)} i`;
|
|
4937
4937
|
const direction = request.order === "asc" ? "ASC" : "DESC";
|
|
4938
4938
|
const statement = sql((bind) => {
|
|
4939
4939
|
const conditions = [
|
|
4940
4940
|
...index.eq.map((column, position) => `i.${quote(column)} = ${bind(request.eq[position])}`),
|
|
4941
|
-
...request.lower ? [compare2(bind,
|
|
4942
|
-
...request.upper ? [compare2(bind,
|
|
4941
|
+
...request.lower ? [compare2(bind, order2, request.lower, ">")] : [],
|
|
4942
|
+
...request.upper ? [compare2(bind, order2, request.upper, "<")] : []
|
|
4943
4943
|
];
|
|
4944
|
-
return `SELECT ${multi ? "b" : "i"}.* FROM ${source}${conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : ""} ORDER BY ${
|
|
4944
|
+
return `SELECT ${multi ? "b" : "i"}.* FROM ${source}${conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : ""} ORDER BY ${order2.map((column) => `i.${quote(column)} ${direction}`).join(", ")} LIMIT ${request.limit}`;
|
|
4945
4945
|
});
|
|
4946
4946
|
return read(table, statement);
|
|
4947
4947
|
},
|
|
@@ -5025,7 +5025,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
|
|
|
5025
5025
|
}, "createSqlAdapter");
|
|
5026
5026
|
|
|
5027
5027
|
// ../../packages/server/dist/package.mjs
|
|
5028
|
-
var version = "1.2.0-rc.
|
|
5028
|
+
var version = "1.2.0-rc.60";
|
|
5029
5029
|
|
|
5030
5030
|
// ../../packages/server/dist/version.mjs
|
|
5031
5031
|
var HOT_UPDATER_SERVER_VERSION = version;
|
|
@@ -8066,15 +8066,15 @@ var LIMITS = {
|
|
|
8066
8066
|
};
|
|
8067
8067
|
var MAX_IDS = 100;
|
|
8068
8068
|
var keyset = /* @__PURE__ */ __name((url, maxValue = LIMITS.maxValue, defaultOrder = "desc") => {
|
|
8069
|
-
const
|
|
8070
|
-
if (
|
|
8069
|
+
const order2 = url.searchParams.get("order") ?? defaultOrder;
|
|
8070
|
+
if (order2 !== "asc" && order2 !== "desc") throw new HandlerBadRequestError("order must be 'asc' or 'desc'.");
|
|
8071
8071
|
const limitParam = url.searchParams.get("limit");
|
|
8072
8072
|
const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
|
|
8073
8073
|
if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
|
|
8074
8074
|
const cursor = url.searchParams.get("cursor");
|
|
8075
8075
|
const through = url.searchParams.get("through");
|
|
8076
8076
|
return {
|
|
8077
|
-
order,
|
|
8077
|
+
order: order2,
|
|
8078
8078
|
limit,
|
|
8079
8079
|
...cursor === null ? {} : { after: cursor },
|
|
8080
8080
|
...through === null ? {} : { through }
|
|
@@ -9018,7 +9018,7 @@ var createRequestHandler = /* @__PURE__ */ __name(({ api, clientPolicy, privateR
|
|
|
9018
9018
|
try {
|
|
9019
9019
|
authenticated = await clientPolicy.authenticate(request);
|
|
9020
9020
|
} catch (error) {
|
|
9021
|
-
console.error("Hot Updater client authentication
|
|
9021
|
+
console.error("Hot Updater client authentication error:", error);
|
|
9022
9022
|
return errorResponse("Service unavailable", 503);
|
|
9023
9023
|
}
|
|
9024
9024
|
if (!authenticated) return errorResponse("Unauthorized", 401);
|
|
@@ -13099,163 +13099,119 @@ var remoteConfig = /* @__PURE__ */ __name(() => {
|
|
|
13099
13099
|
// worker/src/index.ts
|
|
13100
13100
|
import { env } from "cloudflare:workers";
|
|
13101
13101
|
|
|
13102
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13103
|
-
var
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13130
|
-
|
|
13131
|
-
|
|
13132
|
-
}
|
|
13133
|
-
} else {
|
|
13134
|
-
if (context.finalized === false && onNotFound) {
|
|
13135
|
-
res = await onNotFound(context);
|
|
13136
|
-
}
|
|
13137
|
-
}
|
|
13138
|
-
if (res && (context.finalized === false || isError)) {
|
|
13139
|
-
context.res = res;
|
|
13140
|
-
}
|
|
13141
|
-
return context;
|
|
13142
|
-
}
|
|
13143
|
-
__name(dispatch, "dispatch");
|
|
13144
|
-
};
|
|
13145
|
-
}, "compose");
|
|
13102
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/http-exception.js
|
|
13103
|
+
var HTTPException = class extends Error {
|
|
13104
|
+
static {
|
|
13105
|
+
__name(this, "HTTPException");
|
|
13106
|
+
}
|
|
13107
|
+
res;
|
|
13108
|
+
status;
|
|
13109
|
+
/**
|
|
13110
|
+
* Creates an instance of `HTTPException`.
|
|
13111
|
+
* @param status - HTTP status code for the exception. Defaults to 500.
|
|
13112
|
+
* @param options - Additional options for the exception.
|
|
13113
|
+
*/
|
|
13114
|
+
constructor(status = 500, options) {
|
|
13115
|
+
super(options?.message, { cause: options?.cause });
|
|
13116
|
+
this.res = options?.res;
|
|
13117
|
+
this.status = status;
|
|
13118
|
+
}
|
|
13119
|
+
/**
|
|
13120
|
+
* Returns the response object associated with the exception.
|
|
13121
|
+
* If a response object is not provided, a new response is created with the error message and status code.
|
|
13122
|
+
* @returns The response object.
|
|
13123
|
+
*/
|
|
13124
|
+
getResponse() {
|
|
13125
|
+
if (this.res) return new Response(this.res.body, {
|
|
13126
|
+
status: this.status,
|
|
13127
|
+
headers: this.res.headers
|
|
13128
|
+
});
|
|
13129
|
+
return new Response(this.message, { status: this.status });
|
|
13130
|
+
}
|
|
13131
|
+
};
|
|
13146
13132
|
|
|
13147
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13133
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/request/constants.js
|
|
13148
13134
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
13149
13135
|
|
|
13150
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13136
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/buffer.js
|
|
13151
13137
|
var bufferToFormData = /* @__PURE__ */ __name((arrayBuffer, contentType) => {
|
|
13152
|
-
|
|
13153
|
-
headers: {
|
|
13154
|
-
// Normalize the media type (case-insensitive) while keeping parameters like the boundary
|
|
13155
|
-
"Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
|
|
13156
|
-
}
|
|
13157
|
-
});
|
|
13158
|
-
return response.formData();
|
|
13138
|
+
return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
|
|
13159
13139
|
}, "bufferToFormData");
|
|
13160
13140
|
|
|
13161
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13141
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/body.js
|
|
13142
|
+
var MAX_NESTED_OBJECTS = 1e4;
|
|
13162
13143
|
var isRawRequest = /* @__PURE__ */ __name((request) => "headers" in request, "isRawRequest");
|
|
13163
13144
|
var parseBody = /* @__PURE__ */ __name(async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
13164
13145
|
const { all = false, dot = false } = options;
|
|
13165
|
-
const
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
}
|
|
13146
|
+
const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
13147
|
+
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
|
|
13148
|
+
all,
|
|
13149
|
+
dot
|
|
13150
|
+
});
|
|
13171
13151
|
return {};
|
|
13172
13152
|
}, "parseBody");
|
|
13173
13153
|
async function parseFormData(request, options) {
|
|
13174
|
-
if (!isRawRequest(request) && request.bodyCache.formData)
|
|
13175
|
-
return convertFormDataToBodyData(
|
|
13176
|
-
await request.bodyCache.formData,
|
|
13177
|
-
options
|
|
13178
|
-
);
|
|
13179
|
-
}
|
|
13154
|
+
if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
|
|
13180
13155
|
const headers = isRawRequest(request) ? request.headers : request.raw.headers;
|
|
13181
13156
|
const arrayBuffer = await request.arrayBuffer();
|
|
13182
13157
|
const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
|
|
13183
|
-
if (!isRawRequest(request))
|
|
13184
|
-
request.bodyCache.formData = formDataPromise;
|
|
13185
|
-
}
|
|
13158
|
+
if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
|
|
13186
13159
|
const formData = await formDataPromise;
|
|
13187
|
-
if (formData)
|
|
13188
|
-
return convertFormDataToBodyData(formData, options);
|
|
13189
|
-
}
|
|
13160
|
+
if (formData) return convertFormDataToBodyData(formData, options);
|
|
13190
13161
|
return {};
|
|
13191
13162
|
}
|
|
13192
13163
|
__name(parseFormData, "parseFormData");
|
|
13193
13164
|
function convertFormDataToBodyData(formData, options) {
|
|
13194
13165
|
const form = /* @__PURE__ */ Object.create(null);
|
|
13166
|
+
const nestingState = { count: 0 };
|
|
13195
13167
|
formData.forEach((value, key) => {
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13168
|
+
if (!(options.all || key.endsWith("[]"))) form[key] = value;
|
|
13169
|
+
else handleParsingAllValues(form, key, value);
|
|
13170
|
+
});
|
|
13171
|
+
if (options.dot) Object.entries(form).forEach(([key, value]) => {
|
|
13172
|
+
if (key.includes(".")) {
|
|
13173
|
+
handleParsingNestedValues(form, key, value, nestingState);
|
|
13174
|
+
delete form[key];
|
|
13201
13175
|
}
|
|
13202
13176
|
});
|
|
13203
|
-
if (options.dot) {
|
|
13204
|
-
Object.entries(form).forEach(([key, value]) => {
|
|
13205
|
-
const shouldParseDotValues = key.includes(".");
|
|
13206
|
-
if (shouldParseDotValues) {
|
|
13207
|
-
handleParsingNestedValues(form, key, value);
|
|
13208
|
-
delete form[key];
|
|
13209
|
-
}
|
|
13210
|
-
});
|
|
13211
|
-
}
|
|
13212
13177
|
return form;
|
|
13213
13178
|
}
|
|
13214
13179
|
__name(convertFormDataToBodyData, "convertFormDataToBodyData");
|
|
13215
13180
|
var handleParsingAllValues = /* @__PURE__ */ __name((form, key, value) => {
|
|
13216
13181
|
if (form[key] !== void 0) {
|
|
13217
|
-
if (Array.isArray(form[key]))
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
form[key] = [form[key], value];
|
|
13222
|
-
}
|
|
13223
|
-
} else {
|
|
13224
|
-
if (!key.endsWith("[]")) {
|
|
13225
|
-
form[key] = value;
|
|
13226
|
-
} else {
|
|
13227
|
-
form[key] = [value];
|
|
13228
|
-
}
|
|
13229
|
-
}
|
|
13182
|
+
if (Array.isArray(form[key])) form[key].push(value);
|
|
13183
|
+
else form[key] = [form[key], value];
|
|
13184
|
+
} else if (!key.endsWith("[]")) form[key] = value;
|
|
13185
|
+
else form[key] = [value];
|
|
13230
13186
|
}, "handleParsingAllValues");
|
|
13231
|
-
var handleParsingNestedValues = /* @__PURE__ */ __name((form, key, value) => {
|
|
13232
|
-
if (/(?:^|\.)__proto__\./.test(key))
|
|
13233
|
-
return;
|
|
13234
|
-
}
|
|
13187
|
+
var handleParsingNestedValues = /* @__PURE__ */ __name((form, key, value, state) => {
|
|
13188
|
+
if (/(?:^|\.)__proto__\./.test(key)) return;
|
|
13235
13189
|
let nestedForm = form;
|
|
13236
|
-
const keys = key.split(".");
|
|
13190
|
+
const keys = key.split(".", 34);
|
|
13191
|
+
if (keys.length > 33) throwNestingLimitExceeded();
|
|
13237
13192
|
keys.forEach((key2, index) => {
|
|
13238
|
-
if (index === keys.length - 1)
|
|
13239
|
-
|
|
13240
|
-
} else {
|
|
13193
|
+
if (index === keys.length - 1) nestedForm[key2] = value;
|
|
13194
|
+
else {
|
|
13241
13195
|
if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
|
|
13196
|
+
if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
|
|
13242
13197
|
nestedForm[key2] = /* @__PURE__ */ Object.create(null);
|
|
13243
13198
|
}
|
|
13244
13199
|
nestedForm = nestedForm[key2];
|
|
13245
13200
|
}
|
|
13246
13201
|
});
|
|
13247
13202
|
}, "handleParsingNestedValues");
|
|
13203
|
+
var throwNestingLimitExceeded = /* @__PURE__ */ __name(() => {
|
|
13204
|
+
throw new Error("Nesting limit exceeded");
|
|
13205
|
+
}, "throwNestingLimitExceeded");
|
|
13248
13206
|
|
|
13249
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13207
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/url.js
|
|
13250
13208
|
var splitPath = /* @__PURE__ */ __name((path) => {
|
|
13251
13209
|
const paths = path.split("/");
|
|
13252
|
-
if (paths[0] === "")
|
|
13253
|
-
paths.shift();
|
|
13254
|
-
}
|
|
13210
|
+
if (paths[0] === "") paths.shift();
|
|
13255
13211
|
return paths;
|
|
13256
13212
|
}, "splitPath");
|
|
13257
|
-
var splitRoutingPath = /* @__PURE__ */ __name((
|
|
13258
|
-
const { groups, path } = extractGroupsFromPath(
|
|
13213
|
+
var splitRoutingPath = /* @__PURE__ */ __name((routePath2) => {
|
|
13214
|
+
const { groups, path } = extractGroupsFromPath(routePath2);
|
|
13259
13215
|
const paths = splitPath(path);
|
|
13260
13216
|
return replaceGroupMarks(paths, groups);
|
|
13261
13217
|
}, "splitRoutingPath");
|
|
@@ -13266,34 +13222,42 @@ var extractGroupsFromPath = /* @__PURE__ */ __name((path) => {
|
|
|
13266
13222
|
groups.push([mark, match2]);
|
|
13267
13223
|
return mark;
|
|
13268
13224
|
});
|
|
13269
|
-
return {
|
|
13225
|
+
return {
|
|
13226
|
+
groups,
|
|
13227
|
+
path
|
|
13228
|
+
};
|
|
13270
13229
|
}, "extractGroupsFromPath");
|
|
13271
13230
|
var replaceGroupMarks = /* @__PURE__ */ __name((paths, groups) => {
|
|
13272
13231
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
13273
13232
|
const [mark] = groups[i];
|
|
13274
|
-
for (let j = paths.length - 1; j >= 0; j--) {
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
break;
|
|
13278
|
-
}
|
|
13233
|
+
for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
|
|
13234
|
+
paths[j] = paths[j].replace(mark, groups[i][1]);
|
|
13235
|
+
break;
|
|
13279
13236
|
}
|
|
13280
13237
|
}
|
|
13281
13238
|
return paths;
|
|
13282
13239
|
}, "replaceGroupMarks");
|
|
13283
13240
|
var patternCache = {};
|
|
13284
13241
|
var getPattern = /* @__PURE__ */ __name((label, next) => {
|
|
13285
|
-
if (label === "*")
|
|
13286
|
-
return "*";
|
|
13287
|
-
}
|
|
13242
|
+
if (label === "*") return "*";
|
|
13288
13243
|
const match2 = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
13289
13244
|
if (match2) {
|
|
13290
13245
|
const cacheKey = `${label}#${next}`;
|
|
13291
13246
|
if (!patternCache[cacheKey]) {
|
|
13292
|
-
if (match2[2])
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
13247
|
+
if (match2[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
|
|
13248
|
+
cacheKey,
|
|
13249
|
+
match2[1],
|
|
13250
|
+
new RegExp(`^${match2[2]}(?=/${next})`)
|
|
13251
|
+
] : [
|
|
13252
|
+
label,
|
|
13253
|
+
match2[1],
|
|
13254
|
+
new RegExp(`^${match2[2]}$`)
|
|
13255
|
+
];
|
|
13256
|
+
else patternCache[cacheKey] = [
|
|
13257
|
+
label,
|
|
13258
|
+
match2[1],
|
|
13259
|
+
true
|
|
13260
|
+
];
|
|
13297
13261
|
}
|
|
13298
13262
|
return patternCache[cacheKey];
|
|
13299
13263
|
}
|
|
@@ -13312,7 +13276,7 @@ var tryDecode = /* @__PURE__ */ __name((str, decoder2) => {
|
|
|
13312
13276
|
});
|
|
13313
13277
|
}
|
|
13314
13278
|
}, "tryDecode");
|
|
13315
|
-
var
|
|
13279
|
+
var decodeURIWithPreservedPercent = /* @__PURE__ */ __name((value) => decodeURI(value.includes("%25") ? value.replace(/%25/g, "%2525") : value), "decodeURIWithPreservedPercent");
|
|
13316
13280
|
var getPath = /* @__PURE__ */ __name((request) => {
|
|
13317
13281
|
const url = request.url;
|
|
13318
13282
|
const start = url.indexOf("/", url.indexOf(":") + 4);
|
|
@@ -13324,10 +13288,14 @@ var getPath = /* @__PURE__ */ __name((request) => {
|
|
|
13324
13288
|
const hashIndex = url.indexOf("#", i);
|
|
13325
13289
|
const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
13326
13290
|
const path = url.slice(start, end);
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13291
|
+
const decoded = tryDecode(path, decodeURIWithPreservedPercent);
|
|
13292
|
+
if (/%(?![0-9A-Fa-f]{2})/.test(path)) {
|
|
13293
|
+
const rewritten = new URL("http://localhost");
|
|
13294
|
+
rewritten.pathname = decoded.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
13295
|
+
if (tryDecode(rewritten.pathname, decodeURIWithPreservedPercent) !== decoded) return tryDecode(path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), decodeURIWithPreservedPercent);
|
|
13296
|
+
}
|
|
13297
|
+
return decoded;
|
|
13298
|
+
} else if (charCode === 63 || charCode === 35) break;
|
|
13331
13299
|
}
|
|
13332
13300
|
return url.slice(start, i);
|
|
13333
13301
|
}, "getPath");
|
|
@@ -13336,72 +13304,57 @@ var getPathNoStrict = /* @__PURE__ */ __name((request) => {
|
|
|
13336
13304
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
13337
13305
|
}, "getPathNoStrict");
|
|
13338
13306
|
var mergePath = /* @__PURE__ */ __name((base, sub, ...rest) => {
|
|
13339
|
-
if (rest.length)
|
|
13340
|
-
sub = mergePath(sub, ...rest);
|
|
13341
|
-
}
|
|
13307
|
+
if (rest.length) sub = mergePath(sub, ...rest);
|
|
13342
13308
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
13343
13309
|
}, "mergePath");
|
|
13344
13310
|
var checkOptionalParameter = /* @__PURE__ */ __name((path) => {
|
|
13345
|
-
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":"))
|
|
13346
|
-
return null;
|
|
13347
|
-
}
|
|
13311
|
+
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
|
|
13348
13312
|
const segments = path.split("/");
|
|
13349
13313
|
const results = [];
|
|
13350
13314
|
let basePath = "";
|
|
13351
13315
|
segments.forEach((segment) => {
|
|
13352
|
-
if (segment !== "" && !/\:/.test(segment))
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
} else {
|
|
13359
|
-
results.push(basePath);
|
|
13360
|
-
}
|
|
13361
|
-
const optionalSegment = segment.replace("?", "");
|
|
13316
|
+
if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
|
|
13317
|
+
else if (/\:/.test(segment)) {
|
|
13318
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
13319
|
+
if (results.length === 0 && basePath === "") results.push("/");
|
|
13320
|
+
else results.push(basePath);
|
|
13321
|
+
const optionalSegment = segment.slice(0, -1);
|
|
13362
13322
|
basePath += "/" + optionalSegment;
|
|
13363
13323
|
results.push(basePath);
|
|
13364
|
-
} else
|
|
13365
|
-
basePath += "/" + segment;
|
|
13366
|
-
}
|
|
13324
|
+
} else basePath += "/" + segment;
|
|
13367
13325
|
}
|
|
13368
13326
|
});
|
|
13369
13327
|
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
13370
13328
|
}, "checkOptionalParameter");
|
|
13329
|
+
var tryDecodeURIComponent = /* @__PURE__ */ __name((str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str, "tryDecodeURIComponent");
|
|
13371
13330
|
var _decodeURI = /* @__PURE__ */ __name((value) => {
|
|
13372
|
-
if (
|
|
13373
|
-
|
|
13374
|
-
}
|
|
13375
|
-
if (value.indexOf("+") !== -1) {
|
|
13376
|
-
value = value.replace(/\+/g, " ");
|
|
13377
|
-
}
|
|
13378
|
-
return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value;
|
|
13331
|
+
if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
|
|
13332
|
+
return tryDecodeURIComponent(value);
|
|
13379
13333
|
}, "_decodeURI");
|
|
13380
13334
|
var _getQueryParam = /* @__PURE__ */ __name((url, key, multiple) => {
|
|
13335
|
+
const hashIndex = url.indexOf("#", 8);
|
|
13336
|
+
if (hashIndex !== -1) url = url.slice(0, hashIndex);
|
|
13381
13337
|
let encoded;
|
|
13382
|
-
if (!multiple && key && !/[
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
}
|
|
13387
|
-
if (!url.startsWith(key, keyIndex2 + 1)) {
|
|
13388
|
-
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
13389
|
-
}
|
|
13338
|
+
if (!multiple && key && !/[%+&=]/.test(key)) {
|
|
13339
|
+
const queryIndex = url.indexOf("?", 8);
|
|
13340
|
+
let keyIndex2 = queryIndex;
|
|
13341
|
+
if (keyIndex2 === -1) return;
|
|
13342
|
+
if (!url.startsWith(key, keyIndex2 + 1)) keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
13390
13343
|
while (keyIndex2 !== -1) {
|
|
13391
13344
|
const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
|
|
13392
|
-
if (trailingKeyCode === 61) {
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13345
|
+
if (trailingKeyCode === 61 || trailingKeyCode === 38 || isNaN(trailingKeyCode)) {
|
|
13346
|
+
if (keyIndex2 > queryIndex && /(?:^|&)[^=&]*[%+]/.test(url.slice(queryIndex + 1, keyIndex2))) break;
|
|
13347
|
+
if (trailingKeyCode === 61) {
|
|
13348
|
+
const valueIndex = keyIndex2 + key.length + 2;
|
|
13349
|
+
const endIndex = url.indexOf("&", valueIndex);
|
|
13350
|
+
return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
|
|
13351
|
+
}
|
|
13397
13352
|
return "";
|
|
13398
13353
|
}
|
|
13399
13354
|
keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
|
|
13400
13355
|
}
|
|
13401
13356
|
encoded = /[%+]/.test(url);
|
|
13402
|
-
if (!encoded)
|
|
13403
|
-
return void 0;
|
|
13404
|
-
}
|
|
13357
|
+
if (!encoded) return;
|
|
13405
13358
|
}
|
|
13406
13359
|
const results = /* @__PURE__ */ Object.create(null);
|
|
13407
13360
|
encoded ??= /[%+]/.test(url);
|
|
@@ -13409,38 +13362,21 @@ var _getQueryParam = /* @__PURE__ */ __name((url, key, multiple) => {
|
|
|
13409
13362
|
while (keyIndex !== -1) {
|
|
13410
13363
|
const nextKeyIndex = url.indexOf("&", keyIndex + 1);
|
|
13411
13364
|
let valueIndex = url.indexOf("=", keyIndex);
|
|
13412
|
-
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1)
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
let name = url.slice(
|
|
13416
|
-
keyIndex + 1,
|
|
13417
|
-
valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex
|
|
13418
|
-
);
|
|
13419
|
-
if (encoded) {
|
|
13420
|
-
name = _decodeURI(name);
|
|
13421
|
-
}
|
|
13365
|
+
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
|
|
13366
|
+
let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
|
|
13367
|
+
if (encoded) name = _decodeURI(name);
|
|
13422
13368
|
keyIndex = nextKeyIndex;
|
|
13423
|
-
if (name === "")
|
|
13424
|
-
continue;
|
|
13425
|
-
}
|
|
13369
|
+
if (name === "") continue;
|
|
13426
13370
|
let value;
|
|
13427
|
-
if (valueIndex === -1)
|
|
13428
|
-
|
|
13429
|
-
} else {
|
|
13371
|
+
if (valueIndex === -1) value = "";
|
|
13372
|
+
else {
|
|
13430
13373
|
value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
|
|
13431
|
-
if (encoded)
|
|
13432
|
-
value = _decodeURI(value);
|
|
13433
|
-
}
|
|
13374
|
+
if (encoded) value = _decodeURI(value);
|
|
13434
13375
|
}
|
|
13435
13376
|
if (multiple) {
|
|
13436
|
-
if (!(results[name] && Array.isArray(results[name])))
|
|
13437
|
-
results[name] = [];
|
|
13438
|
-
}
|
|
13439
|
-
;
|
|
13377
|
+
if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
|
|
13440
13378
|
results[name].push(value);
|
|
13441
|
-
} else
|
|
13442
|
-
results[name] ??= value;
|
|
13443
|
-
}
|
|
13379
|
+
} else results[name] ??= value;
|
|
13444
13380
|
}
|
|
13445
13381
|
return key ? results[key] : results;
|
|
13446
13382
|
}, "_getQueryParam");
|
|
@@ -13450,67 +13386,62 @@ var getQueryParams = /* @__PURE__ */ __name((url, key) => {
|
|
|
13450
13386
|
}, "getQueryParams");
|
|
13451
13387
|
var decodeURIComponent_ = decodeURIComponent;
|
|
13452
13388
|
|
|
13453
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13454
|
-
var tryDecodeURIComponent = /* @__PURE__ */ __name((str) => tryDecode(str, decodeURIComponent_), "tryDecodeURIComponent");
|
|
13389
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/request.js
|
|
13455
13390
|
var HonoRequest = class {
|
|
13456
13391
|
static {
|
|
13457
13392
|
__name(this, "HonoRequest");
|
|
13458
13393
|
}
|
|
13459
13394
|
/**
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13395
|
+
* `.raw` can get the raw Request object.
|
|
13396
|
+
*
|
|
13397
|
+
* @see {@link https://hono.dev/docs/api/request#raw}
|
|
13398
|
+
*
|
|
13399
|
+
* @example
|
|
13400
|
+
* ```ts
|
|
13401
|
+
* // For Cloudflare Workers
|
|
13402
|
+
* app.post('/', async (c) => {
|
|
13403
|
+
* const metadata = c.req.raw.cf?.hostMetadata?
|
|
13404
|
+
* ...
|
|
13405
|
+
* })
|
|
13406
|
+
* ```
|
|
13407
|
+
*/
|
|
13473
13408
|
raw;
|
|
13474
13409
|
#validatedData;
|
|
13475
|
-
// Short name of validatedData
|
|
13476
13410
|
#matchResult;
|
|
13477
13411
|
routeIndex = 0;
|
|
13478
13412
|
/**
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13487
|
-
|
|
13488
|
-
|
|
13489
|
-
|
|
13413
|
+
* `.path` can get the pathname of the request.
|
|
13414
|
+
*
|
|
13415
|
+
* @see {@link https://hono.dev/docs/api/request#path}
|
|
13416
|
+
*
|
|
13417
|
+
* @example
|
|
13418
|
+
* ```ts
|
|
13419
|
+
* app.get('/about/me', (c) => {
|
|
13420
|
+
* const pathname = c.req.path // `/about/me`
|
|
13421
|
+
* })
|
|
13422
|
+
* ```
|
|
13423
|
+
*/
|
|
13490
13424
|
path;
|
|
13491
13425
|
bodyCache = {};
|
|
13492
13426
|
constructor(request, path = "/", matchResult = [[]]) {
|
|
13493
13427
|
this.raw = request;
|
|
13494
13428
|
this.path = path;
|
|
13495
13429
|
this.#matchResult = matchResult;
|
|
13496
|
-
this.#validatedData = {};
|
|
13497
13430
|
}
|
|
13498
13431
|
param(key) {
|
|
13499
13432
|
return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
|
|
13500
13433
|
}
|
|
13501
13434
|
#getDecodedParam(key) {
|
|
13502
|
-
const paramKey = this.#matchResult[0][this.routeIndex][1][key];
|
|
13435
|
+
const paramKey = this.#matchResult[0][this.routeIndex]?.[1][key];
|
|
13503
13436
|
const param = this.#getParamValue(paramKey);
|
|
13504
|
-
return param &&
|
|
13437
|
+
return param && tryDecodeURIComponent(param);
|
|
13505
13438
|
}
|
|
13506
13439
|
#getAllDecodedParams() {
|
|
13507
13440
|
const decoded = {};
|
|
13508
|
-
const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
|
|
13441
|
+
const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
|
|
13509
13442
|
for (const key of keys) {
|
|
13510
13443
|
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
|
|
13511
|
-
if (value !== void 0)
|
|
13512
|
-
decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
|
|
13513
|
-
}
|
|
13444
|
+
if (value !== void 0) decoded[key] = tryDecodeURIComponent(value);
|
|
13514
13445
|
}
|
|
13515
13446
|
return decoded;
|
|
13516
13447
|
}
|
|
@@ -13524,9 +13455,7 @@ var HonoRequest = class {
|
|
|
13524
13455
|
return getQueryParams(this.url, key);
|
|
13525
13456
|
}
|
|
13526
13457
|
header(name) {
|
|
13527
|
-
if (name)
|
|
13528
|
-
return this.raw.headers.get(name) ?? void 0;
|
|
13529
|
-
}
|
|
13458
|
+
if (name) return this.raw.headers.get(name) ?? void 0;
|
|
13530
13459
|
const headerData = /* @__PURE__ */ Object.create(null);
|
|
13531
13460
|
this.raw.headers.forEach((value, key) => {
|
|
13532
13461
|
headerData[key] = value;
|
|
@@ -13539,146 +13468,140 @@ var HonoRequest = class {
|
|
|
13539
13468
|
#cachedBody = /* @__PURE__ */ __name((key) => {
|
|
13540
13469
|
const { bodyCache, raw: raw2 } = this;
|
|
13541
13470
|
const cachedBody = bodyCache[key];
|
|
13542
|
-
if (cachedBody)
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
if (anyCachedKey === "json") {
|
|
13549
|
-
body2 = JSON.stringify(body2);
|
|
13550
|
-
}
|
|
13551
|
-
return new Response(body2)[key]();
|
|
13552
|
-
});
|
|
13553
|
-
}
|
|
13471
|
+
if (cachedBody) return cachedBody;
|
|
13472
|
+
for (const anyCachedKey in bodyCache) return bodyCache[anyCachedKey].then((body2) => {
|
|
13473
|
+
if (anyCachedKey === "json") body2 = JSON.stringify(body2);
|
|
13474
|
+
const contentType = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
|
|
13475
|
+
return new Response(body2, { headers: contentType ? { "Content-Type": contentType } : void 0 })[key]();
|
|
13476
|
+
});
|
|
13554
13477
|
return bodyCache[key] = raw2[key]();
|
|
13555
13478
|
}, "#cachedBody");
|
|
13556
13479
|
/**
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13480
|
+
* `.json()` can parse Request body of type `application/json`
|
|
13481
|
+
*
|
|
13482
|
+
* @see {@link https://hono.dev/docs/api/request#json}
|
|
13483
|
+
*
|
|
13484
|
+
* @example
|
|
13485
|
+
* ```ts
|
|
13486
|
+
* app.post('/entry', async (c) => {
|
|
13487
|
+
* const body = await c.req.json()
|
|
13488
|
+
* })
|
|
13489
|
+
* ```
|
|
13490
|
+
*/
|
|
13568
13491
|
json() {
|
|
13569
13492
|
return this.#cachedBody("text").then((text) => JSON.parse(text));
|
|
13570
13493
|
}
|
|
13571
13494
|
/**
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13495
|
+
* `.text()` can parse Request body of type `text/plain`
|
|
13496
|
+
*
|
|
13497
|
+
* @see {@link https://hono.dev/docs/api/request#text}
|
|
13498
|
+
*
|
|
13499
|
+
* @example
|
|
13500
|
+
* ```ts
|
|
13501
|
+
* app.post('/entry', async (c) => {
|
|
13502
|
+
* const body = await c.req.text()
|
|
13503
|
+
* })
|
|
13504
|
+
* ```
|
|
13505
|
+
*/
|
|
13583
13506
|
text() {
|
|
13584
13507
|
return this.#cachedBody("text");
|
|
13585
13508
|
}
|
|
13586
13509
|
/**
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13510
|
+
* `.arrayBuffer()` parse Request body as an `ArrayBuffer`
|
|
13511
|
+
*
|
|
13512
|
+
* @see {@link https://hono.dev/docs/api/request#arraybuffer}
|
|
13513
|
+
*
|
|
13514
|
+
* @example
|
|
13515
|
+
* ```ts
|
|
13516
|
+
* app.post('/entry', async (c) => {
|
|
13517
|
+
* const body = await c.req.arrayBuffer()
|
|
13518
|
+
* })
|
|
13519
|
+
* ```
|
|
13520
|
+
*/
|
|
13598
13521
|
arrayBuffer() {
|
|
13599
13522
|
return this.#cachedBody("arrayBuffer");
|
|
13600
13523
|
}
|
|
13601
13524
|
/**
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13525
|
+
* `.bytes()` parses the request body as a `Uint8Array`.
|
|
13526
|
+
*
|
|
13527
|
+
* @see {@link https://hono.dev/docs/api/request#bytes}
|
|
13528
|
+
*
|
|
13529
|
+
* @example
|
|
13530
|
+
* ```ts
|
|
13531
|
+
* app.post('/entry', async (c) => {
|
|
13532
|
+
* const body = await c.req.bytes()
|
|
13533
|
+
* })
|
|
13534
|
+
* ```
|
|
13535
|
+
*/
|
|
13613
13536
|
bytes() {
|
|
13614
13537
|
return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
|
|
13615
13538
|
}
|
|
13616
13539
|
/**
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13540
|
+
* Parses the request body as a `Blob`.
|
|
13541
|
+
* @example
|
|
13542
|
+
* ```ts
|
|
13543
|
+
* app.post('/entry', async (c) => {
|
|
13544
|
+
* const body = await c.req.blob();
|
|
13545
|
+
* });
|
|
13546
|
+
* ```
|
|
13547
|
+
* @see https://hono.dev/docs/api/request#blob
|
|
13548
|
+
*/
|
|
13626
13549
|
blob() {
|
|
13627
13550
|
return this.#cachedBody("blob");
|
|
13628
13551
|
}
|
|
13629
13552
|
/**
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13553
|
+
* Parses the request body as `FormData`.
|
|
13554
|
+
* @example
|
|
13555
|
+
* ```ts
|
|
13556
|
+
* app.post('/entry', async (c) => {
|
|
13557
|
+
* const body = await c.req.formData();
|
|
13558
|
+
* });
|
|
13559
|
+
* ```
|
|
13560
|
+
* @see https://hono.dev/docs/api/request#formdata
|
|
13561
|
+
*/
|
|
13639
13562
|
formData() {
|
|
13640
13563
|
return this.#cachedBody("formData");
|
|
13641
13564
|
}
|
|
13642
13565
|
/**
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13566
|
+
* Adds validated data to the request.
|
|
13567
|
+
*
|
|
13568
|
+
* @param target - The target of the validation.
|
|
13569
|
+
* @param data - The validated data to add.
|
|
13570
|
+
*/
|
|
13648
13571
|
addValidatedData(target, data) {
|
|
13649
|
-
this.#validatedData[target] = data;
|
|
13572
|
+
(this.#validatedData ??= {})[target] = data;
|
|
13650
13573
|
}
|
|
13651
13574
|
valid(target) {
|
|
13652
|
-
return this.#validatedData[target];
|
|
13575
|
+
return this.#validatedData?.[target];
|
|
13653
13576
|
}
|
|
13654
13577
|
/**
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13578
|
+
* `.url` can get the request url strings.
|
|
13579
|
+
*
|
|
13580
|
+
* @see {@link https://hono.dev/docs/api/request#url}
|
|
13581
|
+
*
|
|
13582
|
+
* @example
|
|
13583
|
+
* ```ts
|
|
13584
|
+
* app.get('/about/me', (c) => {
|
|
13585
|
+
* const url = c.req.url // `http://localhost:8787/about/me`
|
|
13586
|
+
* ...
|
|
13587
|
+
* })
|
|
13588
|
+
* ```
|
|
13589
|
+
*/
|
|
13667
13590
|
get url() {
|
|
13668
13591
|
return this.raw.url;
|
|
13669
13592
|
}
|
|
13670
13593
|
/**
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13594
|
+
* `.method` can get the method name of the request.
|
|
13595
|
+
*
|
|
13596
|
+
* @see {@link https://hono.dev/docs/api/request#method}
|
|
13597
|
+
*
|
|
13598
|
+
* @example
|
|
13599
|
+
* ```ts
|
|
13600
|
+
* app.get('/about/me', (c) => {
|
|
13601
|
+
* const method = c.req.method // `GET`
|
|
13602
|
+
* })
|
|
13603
|
+
* ```
|
|
13604
|
+
*/
|
|
13682
13605
|
get method() {
|
|
13683
13606
|
return this.raw.method;
|
|
13684
13607
|
}
|
|
@@ -13686,57 +13609,57 @@ var HonoRequest = class {
|
|
|
13686
13609
|
return this.#matchResult;
|
|
13687
13610
|
}
|
|
13688
13611
|
/**
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13612
|
+
* `.matchedRoutes` can return a matched route in the handler
|
|
13613
|
+
*
|
|
13614
|
+
* @deprecated
|
|
13615
|
+
*
|
|
13616
|
+
* Use matchedRoutes helper defined in "hono/route" instead.
|
|
13617
|
+
*
|
|
13618
|
+
* @see {@link https://hono.dev/docs/api/request#matchedroutes}
|
|
13619
|
+
*
|
|
13620
|
+
* @example
|
|
13621
|
+
* ```ts
|
|
13622
|
+
* app.use('*', async function logger(c, next) {
|
|
13623
|
+
* await next()
|
|
13624
|
+
* c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
|
|
13625
|
+
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
|
|
13626
|
+
* console.log(
|
|
13627
|
+
* method,
|
|
13628
|
+
* ' ',
|
|
13629
|
+
* path,
|
|
13630
|
+
* ' '.repeat(Math.max(10 - path.length, 0)),
|
|
13631
|
+
* name,
|
|
13632
|
+
* i === c.req.routeIndex ? '<- respond from here' : ''
|
|
13633
|
+
* )
|
|
13634
|
+
* })
|
|
13635
|
+
* })
|
|
13636
|
+
* ```
|
|
13637
|
+
*/
|
|
13715
13638
|
get matchedRoutes() {
|
|
13716
13639
|
return this.#matchResult[0].map(([[, route]]) => route);
|
|
13717
13640
|
}
|
|
13718
13641
|
/**
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13642
|
+
* `.routePath` can retrieve the path registered within the handler
|
|
13643
|
+
*
|
|
13644
|
+
* @deprecated
|
|
13645
|
+
*
|
|
13646
|
+
* Use routePath helper defined in "hono/route" instead.
|
|
13647
|
+
*
|
|
13648
|
+
* @see {@link https://hono.dev/docs/api/request#routepath}
|
|
13649
|
+
*
|
|
13650
|
+
* @example
|
|
13651
|
+
* ```ts
|
|
13652
|
+
* app.get('/posts/:id', (c) => {
|
|
13653
|
+
* return c.json({ path: c.req.routePath })
|
|
13654
|
+
* })
|
|
13655
|
+
* ```
|
|
13656
|
+
*/
|
|
13734
13657
|
get routePath() {
|
|
13735
13658
|
return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
|
|
13736
13659
|
}
|
|
13737
13660
|
};
|
|
13738
13661
|
|
|
13739
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13662
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/html.js
|
|
13740
13663
|
var HtmlEscapedCallbackPhase = {
|
|
13741
13664
|
Stringify: 1,
|
|
13742
13665
|
BeforeStream: 2,
|
|
@@ -13750,35 +13673,23 @@ var raw = /* @__PURE__ */ __name((value, callbacks) => {
|
|
|
13750
13673
|
}, "raw");
|
|
13751
13674
|
var resolveCallback = /* @__PURE__ */ __name(async (str, phase, preserveCallbacks, context, buffer) => {
|
|
13752
13675
|
if (typeof str === "object" && !(str instanceof String)) {
|
|
13753
|
-
if (!(str instanceof Promise))
|
|
13754
|
-
|
|
13755
|
-
}
|
|
13756
|
-
if (str instanceof Promise) {
|
|
13757
|
-
str = await str;
|
|
13758
|
-
}
|
|
13676
|
+
if (!(str instanceof Promise)) str = str.toString();
|
|
13677
|
+
if (str instanceof Promise) str = await str;
|
|
13759
13678
|
}
|
|
13760
13679
|
const callbacks = str.callbacks;
|
|
13761
|
-
if (!callbacks?.length)
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
}
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))
|
|
13772
|
-
).then(() => buffer[0])
|
|
13773
|
-
);
|
|
13774
|
-
if (preserveCallbacks) {
|
|
13775
|
-
return raw(await resStr, callbacks);
|
|
13776
|
-
} else {
|
|
13777
|
-
return resStr;
|
|
13778
|
-
}
|
|
13680
|
+
if (!callbacks?.length) return Promise.resolve(str);
|
|
13681
|
+
if (buffer) buffer[0] += str;
|
|
13682
|
+
else buffer = [str];
|
|
13683
|
+
const resStr = Promise.all(callbacks.map((c) => c({
|
|
13684
|
+
phase,
|
|
13685
|
+
buffer,
|
|
13686
|
+
context
|
|
13687
|
+
}))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
|
|
13688
|
+
if (preserveCallbacks) return raw(await resStr, callbacks);
|
|
13689
|
+
else return resStr;
|
|
13779
13690
|
}, "resolveCallback");
|
|
13780
13691
|
|
|
13781
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
13692
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/context.js
|
|
13782
13693
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
13783
13694
|
var setDefaultContentType = /* @__PURE__ */ __name((contentType, headers) => {
|
|
13784
13695
|
return {
|
|
@@ -13794,36 +13705,36 @@ var Context = class {
|
|
|
13794
13705
|
#rawRequest;
|
|
13795
13706
|
#req;
|
|
13796
13707
|
/**
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13708
|
+
* `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
|
|
13709
|
+
*
|
|
13710
|
+
* @see {@link https://hono.dev/docs/api/context#env}
|
|
13711
|
+
*
|
|
13712
|
+
* @example
|
|
13713
|
+
* ```ts
|
|
13714
|
+
* // Environment object for Cloudflare Workers
|
|
13715
|
+
* app.get('*', async c => {
|
|
13716
|
+
* const counter = c.env.COUNTER
|
|
13717
|
+
* })
|
|
13718
|
+
* ```
|
|
13719
|
+
*/
|
|
13809
13720
|
env = {};
|
|
13810
13721
|
#var;
|
|
13811
13722
|
finalized = false;
|
|
13812
13723
|
/**
|
|
13813
|
-
|
|
13814
|
-
|
|
13815
|
-
|
|
13816
|
-
|
|
13817
|
-
|
|
13818
|
-
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
|
|
13824
|
-
|
|
13825
|
-
|
|
13826
|
-
|
|
13724
|
+
* `.error` can get the error object from the middleware if the Handler throws an error.
|
|
13725
|
+
*
|
|
13726
|
+
* @see {@link https://hono.dev/docs/api/context#error}
|
|
13727
|
+
*
|
|
13728
|
+
* @example
|
|
13729
|
+
* ```ts
|
|
13730
|
+
* app.use('*', async (c, next) => {
|
|
13731
|
+
* await next()
|
|
13732
|
+
* if (c.error) {
|
|
13733
|
+
* // do something...
|
|
13734
|
+
* }
|
|
13735
|
+
* })
|
|
13736
|
+
* ```
|
|
13737
|
+
*/
|
|
13827
13738
|
error;
|
|
13828
13739
|
#status;
|
|
13829
13740
|
#executionCtx;
|
|
@@ -13835,11 +13746,11 @@ var Context = class {
|
|
|
13835
13746
|
#matchResult;
|
|
13836
13747
|
#path;
|
|
13837
13748
|
/**
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
|
|
13841
|
-
|
|
13842
|
-
|
|
13749
|
+
* Creates an instance of the Context class.
|
|
13750
|
+
*
|
|
13751
|
+
* @param req - The Request object.
|
|
13752
|
+
* @param options - Optional configuration options for the context.
|
|
13753
|
+
*/
|
|
13843
13754
|
constructor(req, options) {
|
|
13844
13755
|
this.#rawRequest = req;
|
|
13845
13756
|
if (options) {
|
|
@@ -13851,347 +13762,360 @@ var Context = class {
|
|
|
13851
13762
|
}
|
|
13852
13763
|
}
|
|
13853
13764
|
/**
|
|
13854
|
-
|
|
13855
|
-
|
|
13765
|
+
* `.req` is the instance of {@link HonoRequest}.
|
|
13766
|
+
*/
|
|
13856
13767
|
get req() {
|
|
13857
13768
|
this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
|
|
13858
13769
|
return this.#req;
|
|
13859
13770
|
}
|
|
13860
13771
|
/**
|
|
13861
|
-
|
|
13862
|
-
|
|
13863
|
-
|
|
13864
|
-
|
|
13865
|
-
|
|
13772
|
+
* @see {@link https://hono.dev/docs/api/context#event}
|
|
13773
|
+
* The FetchEvent associated with the current request.
|
|
13774
|
+
*
|
|
13775
|
+
* @throws Will throw an error if the context does not have a FetchEvent.
|
|
13776
|
+
*/
|
|
13866
13777
|
get event() {
|
|
13867
|
-
if (this.#executionCtx && "respondWith" in this.#executionCtx)
|
|
13868
|
-
|
|
13869
|
-
} else {
|
|
13870
|
-
throw Error("This context has no FetchEvent");
|
|
13871
|
-
}
|
|
13778
|
+
if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
|
|
13779
|
+
else throw Error("This context has no FetchEvent");
|
|
13872
13780
|
}
|
|
13873
13781
|
/**
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13782
|
+
* @see {@link https://hono.dev/docs/api/context#executionctx}
|
|
13783
|
+
* The ExecutionContext associated with the current request.
|
|
13784
|
+
*
|
|
13785
|
+
* @throws Will throw an error if the context does not have an ExecutionContext.
|
|
13786
|
+
*/
|
|
13879
13787
|
get executionCtx() {
|
|
13880
|
-
if (this.#executionCtx)
|
|
13881
|
-
|
|
13882
|
-
} else {
|
|
13883
|
-
throw Error("This context has no ExecutionContext");
|
|
13884
|
-
}
|
|
13788
|
+
if (this.#executionCtx) return this.#executionCtx;
|
|
13789
|
+
else throw Error("This context has no ExecutionContext");
|
|
13885
13790
|
}
|
|
13886
13791
|
/**
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13792
|
+
* @see {@link https://hono.dev/docs/api/context#res}
|
|
13793
|
+
* The Response object for the current request.
|
|
13794
|
+
*/
|
|
13890
13795
|
get res() {
|
|
13891
|
-
return this.#res ||= createResponseInstance(null, {
|
|
13892
|
-
headers: this.#preparedHeaders ??= new Headers()
|
|
13893
|
-
});
|
|
13796
|
+
return this.#res ||= createResponseInstance(null, { headers: this.#preparedHeaders ??= new Headers() });
|
|
13894
13797
|
}
|
|
13895
13798
|
/**
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
13899
|
-
|
|
13799
|
+
* Sets the Response object for the current request.
|
|
13800
|
+
*
|
|
13801
|
+
* @param _res - The Response object to set.
|
|
13802
|
+
*/
|
|
13900
13803
|
set res(_res) {
|
|
13901
13804
|
if (this.#res && _res) {
|
|
13902
13805
|
_res = createResponseInstance(_res.body, _res);
|
|
13903
13806
|
for (const [k, v] of this.#res.headers.entries()) {
|
|
13904
|
-
if (k === "content-type")
|
|
13905
|
-
continue;
|
|
13906
|
-
}
|
|
13807
|
+
if (k === "content-type") continue;
|
|
13907
13808
|
if (k === "set-cookie") {
|
|
13908
13809
|
const cookies = this.#res.headers.getSetCookie();
|
|
13909
13810
|
_res.headers.delete("set-cookie");
|
|
13910
|
-
for (const cookie of cookies)
|
|
13911
|
-
|
|
13912
|
-
}
|
|
13913
|
-
} else {
|
|
13914
|
-
_res.headers.set(k, v);
|
|
13915
|
-
}
|
|
13811
|
+
for (const cookie of cookies) _res.headers.append("set-cookie", cookie);
|
|
13812
|
+
} else _res.headers.set(k, v);
|
|
13916
13813
|
}
|
|
13917
13814
|
}
|
|
13918
13815
|
this.#res = _res;
|
|
13919
13816
|
this.finalized = true;
|
|
13920
13817
|
}
|
|
13921
13818
|
/**
|
|
13922
|
-
|
|
13923
|
-
|
|
13924
|
-
|
|
13925
|
-
|
|
13926
|
-
|
|
13927
|
-
|
|
13928
|
-
|
|
13929
|
-
|
|
13930
|
-
|
|
13931
|
-
|
|
13932
|
-
|
|
13819
|
+
* `.render()` can create a response within a layout.
|
|
13820
|
+
*
|
|
13821
|
+
* @see {@link https://hono.dev/docs/api/context#render-setrenderer}
|
|
13822
|
+
*
|
|
13823
|
+
* @example
|
|
13824
|
+
* ```ts
|
|
13825
|
+
* app.get('/', (c) => {
|
|
13826
|
+
* return c.render('Hello!')
|
|
13827
|
+
* })
|
|
13828
|
+
* ```
|
|
13829
|
+
*/
|
|
13933
13830
|
render = /* @__PURE__ */ __name((...args) => {
|
|
13934
13831
|
this.#renderer ??= (content) => this.html(content);
|
|
13935
13832
|
return this.#renderer(...args);
|
|
13936
13833
|
}, "render");
|
|
13937
13834
|
/**
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13835
|
+
* Sets the layout for the response.
|
|
13836
|
+
*
|
|
13837
|
+
* @param layout - The layout to set.
|
|
13838
|
+
* @returns The layout function.
|
|
13839
|
+
*/
|
|
13943
13840
|
setLayout = /* @__PURE__ */ __name((layout) => this.#layout = layout, "setLayout");
|
|
13944
13841
|
/**
|
|
13945
|
-
|
|
13946
|
-
|
|
13947
|
-
|
|
13948
|
-
|
|
13842
|
+
* Gets the current layout for the response.
|
|
13843
|
+
*
|
|
13844
|
+
* @returns The current layout function.
|
|
13845
|
+
*/
|
|
13949
13846
|
getLayout = /* @__PURE__ */ __name(() => this.#layout, "getLayout");
|
|
13950
13847
|
/**
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
|
|
13955
|
-
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13959
|
-
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13848
|
+
* `.setRenderer()` can set the layout in the custom middleware.
|
|
13849
|
+
*
|
|
13850
|
+
* @see {@link https://hono.dev/docs/api/context#render-setrenderer}
|
|
13851
|
+
*
|
|
13852
|
+
* @example
|
|
13853
|
+
* ```tsx
|
|
13854
|
+
* app.use('*', async (c, next) => {
|
|
13855
|
+
* c.setRenderer((content) => {
|
|
13856
|
+
* return c.html(
|
|
13857
|
+
* <html>
|
|
13858
|
+
* <body>
|
|
13859
|
+
* <p>{content}</p>
|
|
13860
|
+
* </body>
|
|
13861
|
+
* </html>
|
|
13862
|
+
* )
|
|
13863
|
+
* })
|
|
13864
|
+
* await next()
|
|
13865
|
+
* })
|
|
13866
|
+
* ```
|
|
13867
|
+
*/
|
|
13971
13868
|
setRenderer = /* @__PURE__ */ __name((renderer) => {
|
|
13972
13869
|
this.#renderer = renderer;
|
|
13973
13870
|
}, "setRenderer");
|
|
13974
13871
|
/**
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
13978
|
-
|
|
13979
|
-
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13872
|
+
* `.header()` can set headers.
|
|
13873
|
+
*
|
|
13874
|
+
* @see {@link https://hono.dev/docs/api/context#header}
|
|
13875
|
+
*
|
|
13876
|
+
* @example
|
|
13877
|
+
* ```ts
|
|
13878
|
+
* app.get('/welcome', (c) => {
|
|
13879
|
+
* // Set headers
|
|
13880
|
+
* c.header('X-Message', 'Hello!')
|
|
13881
|
+
* c.header('Content-Type', 'text/plain')
|
|
13882
|
+
*
|
|
13883
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
13884
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
13885
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
13886
|
+
*
|
|
13887
|
+
* return c.body('Thank you for coming')
|
|
13888
|
+
* })
|
|
13889
|
+
* ```
|
|
13890
|
+
*/
|
|
13990
13891
|
header = /* @__PURE__ */ __name((name, value, options) => {
|
|
13991
|
-
if (this.finalized)
|
|
13992
|
-
this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
13993
|
-
}
|
|
13892
|
+
if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
13994
13893
|
const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
|
|
13995
|
-
if (value === void 0)
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
headers.append(name, value);
|
|
13999
|
-
} else {
|
|
14000
|
-
headers.set(name, value);
|
|
14001
|
-
}
|
|
13894
|
+
if (value === void 0) headers.delete(name);
|
|
13895
|
+
else if (options?.append) headers.append(name, value);
|
|
13896
|
+
else headers.set(name, value);
|
|
14002
13897
|
}, "header");
|
|
14003
13898
|
status = /* @__PURE__ */ __name((status) => {
|
|
14004
13899
|
this.#status = status;
|
|
14005
13900
|
}, "status");
|
|
14006
13901
|
/**
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
13902
|
+
* `.set()` can set the value specified by the key.
|
|
13903
|
+
*
|
|
13904
|
+
* @see {@link https://hono.dev/docs/api/context#set-get}
|
|
13905
|
+
*
|
|
13906
|
+
* @example
|
|
13907
|
+
* ```ts
|
|
13908
|
+
* app.use('*', async (c, next) => {
|
|
13909
|
+
* c.set('message', 'Hono is hot!!')
|
|
13910
|
+
* await next()
|
|
13911
|
+
* })
|
|
13912
|
+
* ```
|
|
13913
|
+
*/
|
|
14019
13914
|
set = /* @__PURE__ */ __name((key, value) => {
|
|
14020
13915
|
this.#var ??= /* @__PURE__ */ new Map();
|
|
14021
13916
|
this.#var.set(key, value);
|
|
14022
13917
|
}, "set");
|
|
14023
13918
|
/**
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
13919
|
+
* `.get()` can use the value specified by the key.
|
|
13920
|
+
*
|
|
13921
|
+
* @see {@link https://hono.dev/docs/api/context#set-get}
|
|
13922
|
+
*
|
|
13923
|
+
* @example
|
|
13924
|
+
* ```ts
|
|
13925
|
+
* app.get('/', (c) => {
|
|
13926
|
+
* const message = c.get('message')
|
|
13927
|
+
* return c.text(`The message is "${message}"`)
|
|
13928
|
+
* })
|
|
13929
|
+
* ```
|
|
13930
|
+
*/
|
|
14036
13931
|
get = /* @__PURE__ */ __name((key) => {
|
|
14037
13932
|
return this.#var ? this.#var.get(key) : void 0;
|
|
14038
13933
|
}, "get");
|
|
14039
13934
|
/**
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
// c.var.propName is a read-only
|
|
13935
|
+
* `.var` can access the value of a variable.
|
|
13936
|
+
*
|
|
13937
|
+
* @see {@link https://hono.dev/docs/api/context#var}
|
|
13938
|
+
*
|
|
13939
|
+
* @example
|
|
13940
|
+
* ```ts
|
|
13941
|
+
* const result = c.var.client.oneMethod()
|
|
13942
|
+
* ```
|
|
13943
|
+
*/
|
|
14050
13944
|
get var() {
|
|
14051
|
-
if (!this.#var) {
|
|
14052
|
-
return {};
|
|
14053
|
-
}
|
|
13945
|
+
if (!this.#var) return {};
|
|
14054
13946
|
return Object.fromEntries(this.#var);
|
|
14055
13947
|
}
|
|
14056
13948
|
#newResponse(data, arg, headers) {
|
|
14057
|
-
|
|
14058
|
-
if (typeof arg === "object" &&
|
|
14059
|
-
|
|
14060
|
-
for (const [key, value] of
|
|
14061
|
-
|
|
14062
|
-
responseHeaders.append(key, value);
|
|
14063
|
-
} else {
|
|
14064
|
-
responseHeaders.set(key, value);
|
|
14065
|
-
}
|
|
14066
|
-
}
|
|
13949
|
+
let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
|
|
13950
|
+
if (typeof arg === "object" && arg.headers) {
|
|
13951
|
+
responseHeaders ??= new Headers();
|
|
13952
|
+
for (const [key, value] of new Headers(arg.headers)) if (key === "set-cookie") responseHeaders.append(key, value);
|
|
13953
|
+
else responseHeaders.set(key, value);
|
|
14067
13954
|
}
|
|
14068
13955
|
if (headers) {
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
13956
|
+
if (!responseHeaders) {
|
|
13957
|
+
let count = 0;
|
|
13958
|
+
for (const k in headers) if (++count > 1 || typeof headers[k] !== "string") {
|
|
13959
|
+
responseHeaders = new Headers();
|
|
13960
|
+
break;
|
|
13961
|
+
}
|
|
13962
|
+
}
|
|
13963
|
+
if (responseHeaders) for (const k in headers) {
|
|
13964
|
+
const v = headers[k];
|
|
13965
|
+
if (typeof v === "string") responseHeaders.set(k, v);
|
|
13966
|
+
else {
|
|
14073
13967
|
responseHeaders.delete(k);
|
|
14074
|
-
for (const v2 of v)
|
|
14075
|
-
responseHeaders.append(k, v2);
|
|
14076
|
-
}
|
|
13968
|
+
for (const v2 of v) responseHeaders.append(k, v2);
|
|
14077
13969
|
}
|
|
14078
13970
|
}
|
|
14079
13971
|
}
|
|
14080
13972
|
const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
|
|
14081
|
-
return createResponseInstance(data, {
|
|
13973
|
+
return createResponseInstance(data, {
|
|
13974
|
+
status,
|
|
13975
|
+
headers: responseHeaders ?? headers
|
|
13976
|
+
});
|
|
14082
13977
|
}
|
|
14083
13978
|
newResponse = /* @__PURE__ */ __name((...args) => this.#newResponse(...args), "newResponse");
|
|
14084
13979
|
/**
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
13980
|
+
* `.body()` can return the HTTP response.
|
|
13981
|
+
* You can set headers with `.header()` and set HTTP status code with `.status`.
|
|
13982
|
+
* This can also be set in `.text()`, `.json()` and so on.
|
|
13983
|
+
*
|
|
13984
|
+
* @see {@link https://hono.dev/docs/api/context#body}
|
|
13985
|
+
*
|
|
13986
|
+
* @example
|
|
13987
|
+
* ```ts
|
|
13988
|
+
* app.get('/welcome', (c) => {
|
|
13989
|
+
* // Set headers
|
|
13990
|
+
* c.header('X-Message', 'Hello!')
|
|
13991
|
+
* c.header('Content-Type', 'text/plain')
|
|
13992
|
+
* // Set HTTP status code
|
|
13993
|
+
* c.status(201)
|
|
13994
|
+
*
|
|
13995
|
+
* // Return the response body
|
|
13996
|
+
* return c.body('Thank you for coming')
|
|
13997
|
+
* })
|
|
13998
|
+
* ```
|
|
13999
|
+
*/
|
|
14105
14000
|
body = /* @__PURE__ */ __name((data, arg, headers) => this.#newResponse(data, arg, headers), "body");
|
|
14106
14001
|
/**
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14002
|
+
* `.text()` can render text as `Content-Type:text/plain`.
|
|
14003
|
+
*
|
|
14004
|
+
* @see {@link https://hono.dev/docs/api/context#text}
|
|
14005
|
+
*
|
|
14006
|
+
* @example
|
|
14007
|
+
* ```ts
|
|
14008
|
+
* app.get('/say', (c) => {
|
|
14009
|
+
* return c.text('Hello!')
|
|
14010
|
+
* })
|
|
14011
|
+
* ```
|
|
14012
|
+
*/
|
|
14118
14013
|
text = /* @__PURE__ */ __name((text, arg, headers) => {
|
|
14119
|
-
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(
|
|
14120
|
-
text,
|
|
14121
|
-
arg,
|
|
14122
|
-
setDefaultContentType(TEXT_PLAIN, headers)
|
|
14123
|
-
);
|
|
14014
|
+
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(text, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
14124
14015
|
}, "text");
|
|
14125
14016
|
/**
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14017
|
+
* `.json()` can render JSON as `Content-Type:application/json`.
|
|
14018
|
+
*
|
|
14019
|
+
* @see {@link https://hono.dev/docs/api/context#json}
|
|
14020
|
+
*
|
|
14021
|
+
* @example
|
|
14022
|
+
* ```ts
|
|
14023
|
+
* app.get('/api', (c) => {
|
|
14024
|
+
* return c.json({ message: 'Hello!' })
|
|
14025
|
+
* })
|
|
14026
|
+
* ```
|
|
14027
|
+
*/
|
|
14137
14028
|
json = /* @__PURE__ */ __name((object, arg, headers) => {
|
|
14138
|
-
return this.#newResponse(
|
|
14139
|
-
JSON.stringify(object),
|
|
14140
|
-
arg,
|
|
14141
|
-
setDefaultContentType("application/json", headers)
|
|
14142
|
-
);
|
|
14029
|
+
return this.#newResponse(JSON.stringify(object), arg, setDefaultContentType("application/json", headers));
|
|
14143
14030
|
}, "json");
|
|
14144
14031
|
html = /* @__PURE__ */ __name((html, arg, headers) => {
|
|
14145
14032
|
const res = /* @__PURE__ */ __name((html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers)), "res");
|
|
14146
14033
|
return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
14147
14034
|
}, "html");
|
|
14148
14035
|
/**
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14036
|
+
* `.redirect()` can Redirect, default status code is 302.
|
|
14037
|
+
*
|
|
14038
|
+
* @see {@link https://hono.dev/docs/api/context#redirect}
|
|
14039
|
+
*
|
|
14040
|
+
* @example
|
|
14041
|
+
* ```ts
|
|
14042
|
+
* app.get('/redirect', (c) => {
|
|
14043
|
+
* return c.redirect('/')
|
|
14044
|
+
* })
|
|
14045
|
+
* app.get('/redirect-permanently', (c) => {
|
|
14046
|
+
* return c.redirect('/', 301)
|
|
14047
|
+
* })
|
|
14048
|
+
* ```
|
|
14049
|
+
*/
|
|
14163
14050
|
redirect = /* @__PURE__ */ __name((location, status) => {
|
|
14164
14051
|
const locationString = String(location);
|
|
14165
|
-
this.header(
|
|
14166
|
-
"Location",
|
|
14167
|
-
// Multibyes should be encoded
|
|
14168
|
-
// eslint-disable-next-line no-control-regex
|
|
14169
|
-
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
14170
|
-
);
|
|
14052
|
+
this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
|
|
14171
14053
|
return this.newResponse(null, status ?? 302);
|
|
14172
14054
|
}, "redirect");
|
|
14173
14055
|
/**
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14056
|
+
* `.notFound()` can return the Not Found Response.
|
|
14057
|
+
*
|
|
14058
|
+
* @see {@link https://hono.dev/docs/api/context#notfound}
|
|
14059
|
+
*
|
|
14060
|
+
* @example
|
|
14061
|
+
* ```ts
|
|
14062
|
+
* app.get('/notfound', (c) => {
|
|
14063
|
+
* return c.notFound()
|
|
14064
|
+
* })
|
|
14065
|
+
* ```
|
|
14066
|
+
*/
|
|
14185
14067
|
notFound = /* @__PURE__ */ __name(() => {
|
|
14186
14068
|
this.#notFoundHandler ??= () => createResponseInstance();
|
|
14187
14069
|
return this.#notFoundHandler(this);
|
|
14188
14070
|
}, "notFound");
|
|
14189
14071
|
};
|
|
14190
14072
|
|
|
14191
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14192
|
-
var
|
|
14193
|
-
|
|
14194
|
-
|
|
14073
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/compose.js
|
|
14074
|
+
var compose = /* @__PURE__ */ __name((middleware, onError, onNotFound) => {
|
|
14075
|
+
return (context, next) => {
|
|
14076
|
+
let index = -1;
|
|
14077
|
+
return dispatch(0);
|
|
14078
|
+
async function dispatch(i) {
|
|
14079
|
+
if (i <= index) throw new Error("next() called multiple times");
|
|
14080
|
+
index = i;
|
|
14081
|
+
let res;
|
|
14082
|
+
let isError = false;
|
|
14083
|
+
let handler;
|
|
14084
|
+
if (middleware[i]) {
|
|
14085
|
+
handler = middleware[i][0][0];
|
|
14086
|
+
context.req.routeIndex = i;
|
|
14087
|
+
} else handler = i === middleware.length && next || void 0;
|
|
14088
|
+
if (handler) try {
|
|
14089
|
+
res = await handler(context, () => dispatch(i + 1));
|
|
14090
|
+
} catch (err) {
|
|
14091
|
+
if (err instanceof Error && onError) {
|
|
14092
|
+
context.error = err;
|
|
14093
|
+
res = await onError(err, context);
|
|
14094
|
+
isError = true;
|
|
14095
|
+
} else throw err;
|
|
14096
|
+
}
|
|
14097
|
+
else if (context.finalized === false && onNotFound) res = await onNotFound(context);
|
|
14098
|
+
if (res && (context.finalized === false || isError)) context.res = res;
|
|
14099
|
+
return context;
|
|
14100
|
+
}
|
|
14101
|
+
__name(dispatch, "dispatch");
|
|
14102
|
+
};
|
|
14103
|
+
}, "compose");
|
|
14104
|
+
|
|
14105
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/helper/route/index.js
|
|
14106
|
+
var matchedRoutes = /* @__PURE__ */ __name((c) => c.req[GET_MATCH_RESULT][0].map(([[, route]]) => route), "matchedRoutes");
|
|
14107
|
+
var routePath = /* @__PURE__ */ __name((c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "", "routePath");
|
|
14108
|
+
|
|
14109
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router.js
|
|
14110
|
+
var METHODS2 = [
|
|
14111
|
+
"get",
|
|
14112
|
+
"post",
|
|
14113
|
+
"put",
|
|
14114
|
+
"delete",
|
|
14115
|
+
"options",
|
|
14116
|
+
"patch",
|
|
14117
|
+
"query"
|
|
14118
|
+
];
|
|
14195
14119
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
14196
14120
|
var UnsupportedPathError = class extends Error {
|
|
14197
14121
|
static {
|
|
@@ -14199,10 +14123,57 @@ var UnsupportedPathError = class extends Error {
|
|
|
14199
14123
|
}
|
|
14200
14124
|
};
|
|
14201
14125
|
|
|
14202
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14126
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/constants.js
|
|
14203
14127
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
14204
14128
|
|
|
14205
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14129
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/mount.js
|
|
14130
|
+
var countTrailingSlashes = /* @__PURE__ */ __name((path) => {
|
|
14131
|
+
let index = path.length;
|
|
14132
|
+
while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
|
|
14133
|
+
return path.length - index;
|
|
14134
|
+
}, "countTrailingSlashes");
|
|
14135
|
+
var getPathPrefixLength = /* @__PURE__ */ __name((c, pathPrefix, routePath2) => {
|
|
14136
|
+
if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
|
|
14137
|
+
const path = c.req.path;
|
|
14138
|
+
const matchResult = c.req[GET_MATCH_RESULT];
|
|
14139
|
+
const paramNames = /* @__PURE__ */ new Set();
|
|
14140
|
+
let length = 0;
|
|
14141
|
+
for (const part of splitRoutingPath(pathPrefix)) {
|
|
14142
|
+
if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath2}".`);
|
|
14143
|
+
const pattern = getPattern(part);
|
|
14144
|
+
if (pattern && pattern !== "*") {
|
|
14145
|
+
const name = pattern[1];
|
|
14146
|
+
if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath2}".`);
|
|
14147
|
+
paramNames.add(name);
|
|
14148
|
+
}
|
|
14149
|
+
if (pattern && pattern !== "*" && pattern[2] !== true) {
|
|
14150
|
+
const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c.req.routeIndex][1][pattern[1]]] : matchResult[0][c.req.routeIndex][1][pattern[1]];
|
|
14151
|
+
length += value.length + 1;
|
|
14152
|
+
} else if (pattern || part.endsWith("*")) {
|
|
14153
|
+
const end = path.indexOf("/", length + 1);
|
|
14154
|
+
length = end === -1 ? path.length : end;
|
|
14155
|
+
} else length += part.length + 1;
|
|
14156
|
+
}
|
|
14157
|
+
return length;
|
|
14158
|
+
}, "getPathPrefixLength");
|
|
14159
|
+
var createMountedRequest = /* @__PURE__ */ __name((c, pathPrefix, routePath2) => {
|
|
14160
|
+
if (/[^/]\*$/.test(routePath2)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath2}".`);
|
|
14161
|
+
const prefixLength = getPathPrefixLength(c, pathPrefix, routePath2);
|
|
14162
|
+
const path = c.req.path.slice(prefixLength) || "/";
|
|
14163
|
+
if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
14164
|
+
const rawUrl = c.req.raw.url;
|
|
14165
|
+
if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
14166
|
+
const rawPathEnd = rawUrl.search(/[?#]/);
|
|
14167
|
+
const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
|
|
14168
|
+
if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new HTTPException(400, { message: "Invalid mounted path" });
|
|
14169
|
+
const url = new URL(rawUrl);
|
|
14170
|
+
url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
|
|
14171
|
+
if (path.includes("%")) {
|
|
14172
|
+
}
|
|
14173
|
+
return new Request(url, c.req.raw);
|
|
14174
|
+
}, "createMountedRequest");
|
|
14175
|
+
|
|
14176
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/hono-base.js
|
|
14206
14177
|
var notFoundHandler = /* @__PURE__ */ __name((c) => {
|
|
14207
14178
|
return c.text("404 Not Found", 404);
|
|
14208
14179
|
}, "notFoundHandler");
|
|
@@ -14214,9 +14185,9 @@ var errorHandler = /* @__PURE__ */ __name((err, c) => {
|
|
|
14214
14185
|
console.error(err);
|
|
14215
14186
|
return c.text("Internal Server Error", 500);
|
|
14216
14187
|
}, "errorHandler");
|
|
14217
|
-
var Hono = class
|
|
14188
|
+
var Hono = class Hono2 {
|
|
14218
14189
|
static {
|
|
14219
|
-
__name(this, "
|
|
14190
|
+
__name(this, "Hono");
|
|
14220
14191
|
}
|
|
14221
14192
|
get;
|
|
14222
14193
|
post;
|
|
@@ -14224,30 +14195,23 @@ var Hono = class _Hono {
|
|
|
14224
14195
|
delete;
|
|
14225
14196
|
options;
|
|
14226
14197
|
patch;
|
|
14198
|
+
query;
|
|
14227
14199
|
all;
|
|
14228
14200
|
on;
|
|
14229
14201
|
use;
|
|
14230
|
-
/*
|
|
14231
|
-
This class is like an abstract class and does not have a router.
|
|
14232
|
-
To use it, inherit the class and implement router in the constructor.
|
|
14233
|
-
*/
|
|
14234
14202
|
router;
|
|
14235
14203
|
getPath;
|
|
14236
|
-
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
14237
14204
|
_basePath = "/";
|
|
14238
14205
|
#path = "/";
|
|
14239
14206
|
routes = [];
|
|
14240
14207
|
constructor(options = {}) {
|
|
14241
|
-
|
|
14242
|
-
allMethods.forEach((method) => {
|
|
14208
|
+
[...METHODS2, "all"].forEach((method) => {
|
|
14243
14209
|
this[method] = (args1, ...args) => {
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
this.#addRoute(method, this.#path, args1);
|
|
14248
|
-
}
|
|
14210
|
+
const methodName = method.toUpperCase();
|
|
14211
|
+
if (typeof args1 === "string") this.#path = args1;
|
|
14212
|
+
else this.#addRoute(methodName, this.#path, args1);
|
|
14249
14213
|
args.forEach((handler) => {
|
|
14250
|
-
this.#addRoute(
|
|
14214
|
+
this.#addRoute(methodName, this.#path, handler);
|
|
14251
14215
|
});
|
|
14252
14216
|
return this;
|
|
14253
14217
|
};
|
|
@@ -14256,22 +14220,20 @@ var Hono = class _Hono {
|
|
|
14256
14220
|
for (const p of [path].flat()) {
|
|
14257
14221
|
this.#path = p;
|
|
14258
14222
|
for (const m of [method].flat()) {
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
});
|
|
14223
|
+
const methodName = m.toUpperCase();
|
|
14224
|
+
for (const handler of handlers) this.#addRoute(methodName, this.#path, handler);
|
|
14262
14225
|
}
|
|
14263
14226
|
}
|
|
14264
14227
|
return this;
|
|
14265
14228
|
};
|
|
14266
14229
|
this.use = (arg1, ...handlers) => {
|
|
14267
|
-
if (typeof arg1 === "string")
|
|
14268
|
-
|
|
14269
|
-
} else {
|
|
14230
|
+
if (typeof arg1 === "string") this.#path = arg1;
|
|
14231
|
+
else {
|
|
14270
14232
|
this.#path = "*";
|
|
14271
14233
|
handlers.unshift(arg1);
|
|
14272
14234
|
}
|
|
14273
14235
|
handlers.forEach((handler) => {
|
|
14274
|
-
this.#addRoute(
|
|
14236
|
+
this.#addRoute("ALL", this.#path, handler);
|
|
14275
14237
|
});
|
|
14276
14238
|
return this;
|
|
14277
14239
|
};
|
|
@@ -14280,7 +14242,7 @@ var Hono = class _Hono {
|
|
|
14280
14242
|
this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
|
|
14281
14243
|
}
|
|
14282
14244
|
#clone() {
|
|
14283
|
-
const clone = new
|
|
14245
|
+
const clone = new Hono2({
|
|
14284
14246
|
router: this.router,
|
|
14285
14247
|
getPath: this.getPath
|
|
14286
14248
|
});
|
|
@@ -14290,33 +14252,31 @@ var Hono = class _Hono {
|
|
|
14290
14252
|
return clone;
|
|
14291
14253
|
}
|
|
14292
14254
|
#notFoundHandler = notFoundHandler;
|
|
14293
|
-
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
14294
14255
|
errorHandler = errorHandler;
|
|
14295
14256
|
/**
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
|
|
14257
|
+
* `.route()` allows grouping other Hono instance in routes.
|
|
14258
|
+
*
|
|
14259
|
+
* @see {@link https://hono.dev/docs/api/routing#grouping}
|
|
14260
|
+
*
|
|
14261
|
+
* @param {string} path - base Path
|
|
14262
|
+
* @param {Hono} app - other Hono instance
|
|
14263
|
+
* @returns {Hono} routed Hono instance
|
|
14264
|
+
*
|
|
14265
|
+
* @example
|
|
14266
|
+
* ```ts
|
|
14267
|
+
* const app = new Hono()
|
|
14268
|
+
* const app2 = new Hono()
|
|
14269
|
+
*
|
|
14270
|
+
* app2.get("/user", (c) => c.text("user"))
|
|
14271
|
+
* app.route("/api", app2) // GET /api/user
|
|
14272
|
+
* ```
|
|
14273
|
+
*/
|
|
14313
14274
|
route(path, app2) {
|
|
14314
14275
|
const subApp = this.basePath(path);
|
|
14315
14276
|
app2.routes.map((r) => {
|
|
14316
14277
|
let handler;
|
|
14317
|
-
if (app2.errorHandler === errorHandler)
|
|
14318
|
-
|
|
14319
|
-
} else {
|
|
14278
|
+
if (app2.errorHandler === errorHandler) handler = r.handler;
|
|
14279
|
+
else {
|
|
14320
14280
|
handler = /* @__PURE__ */ __name(async (c, next) => (await compose([], app2.errorHandler)(c, () => r.handler(c, next))).res, "handler");
|
|
14321
14281
|
handler[COMPOSED_HANDLER] = r.handler;
|
|
14322
14282
|
}
|
|
@@ -14325,107 +14285,107 @@ var Hono = class _Hono {
|
|
|
14325
14285
|
return this;
|
|
14326
14286
|
}
|
|
14327
14287
|
/**
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
14288
|
+
* `.basePath()` allows base paths to be specified.
|
|
14289
|
+
*
|
|
14290
|
+
* @see {@link https://hono.dev/docs/api/routing#base-path}
|
|
14291
|
+
*
|
|
14292
|
+
* @param {string} path - base Path
|
|
14293
|
+
* @returns {Hono} changed Hono instance
|
|
14294
|
+
*
|
|
14295
|
+
* @example
|
|
14296
|
+
* ```ts
|
|
14297
|
+
* const api = new Hono().basePath('/api')
|
|
14298
|
+
* ```
|
|
14299
|
+
*/
|
|
14340
14300
|
basePath(path) {
|
|
14341
14301
|
const subApp = this.#clone();
|
|
14342
14302
|
subApp._basePath = mergePath(this._basePath, path);
|
|
14343
14303
|
return subApp;
|
|
14344
14304
|
}
|
|
14345
14305
|
/**
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14306
|
+
* `.onError()` handles an error and returns a customized Response.
|
|
14307
|
+
*
|
|
14308
|
+
* @see {@link https://hono.dev/docs/api/hono#error-handling}
|
|
14309
|
+
*
|
|
14310
|
+
* @param {ErrorHandler} handler - request Handler for error
|
|
14311
|
+
* @returns {Hono} changed Hono instance
|
|
14312
|
+
*
|
|
14313
|
+
* @example
|
|
14314
|
+
* ```ts
|
|
14315
|
+
* app.onError((err, c) => {
|
|
14316
|
+
* console.error(`${err}`)
|
|
14317
|
+
* return c.text('Custom Error Message', 500)
|
|
14318
|
+
* })
|
|
14319
|
+
* ```
|
|
14320
|
+
*/
|
|
14361
14321
|
onError = /* @__PURE__ */ __name((handler) => {
|
|
14362
14322
|
this.errorHandler = handler;
|
|
14363
14323
|
return this;
|
|
14364
14324
|
}, "onError");
|
|
14365
14325
|
/**
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14326
|
+
* `.notFound()` allows you to customize a Not Found Response.
|
|
14327
|
+
*
|
|
14328
|
+
* @see {@link https://hono.dev/docs/api/hono#not-found}
|
|
14329
|
+
*
|
|
14330
|
+
* @param {NotFoundHandler} handler - request handler for not-found
|
|
14331
|
+
* @returns {Hono} changed Hono instance
|
|
14332
|
+
*
|
|
14333
|
+
* @example
|
|
14334
|
+
* ```ts
|
|
14335
|
+
* app.notFound((c) => {
|
|
14336
|
+
* return c.text('Custom 404 Message', 404)
|
|
14337
|
+
* })
|
|
14338
|
+
* ```
|
|
14339
|
+
*/
|
|
14380
14340
|
notFound = /* @__PURE__ */ __name((handler) => {
|
|
14381
14341
|
this.#notFoundHandler = handler;
|
|
14382
14342
|
return this;
|
|
14383
14343
|
}, "notFound");
|
|
14384
14344
|
/**
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14345
|
+
* `.mount()` allows you to mount applications built with other frameworks into your Hono application.
|
|
14346
|
+
*
|
|
14347
|
+
* @deprecated Use `mount()` from `hono/mount` instead. `.mount()` will be removed in v5.
|
|
14348
|
+
*
|
|
14349
|
+
* @see {@link https://hono.dev/docs/api/hono#mount}
|
|
14350
|
+
*
|
|
14351
|
+
* @param {string} path - base Path
|
|
14352
|
+
* @param {Function} applicationHandler - other Request Handler
|
|
14353
|
+
* @param {MountOptions} [options] - options of `.mount()`
|
|
14354
|
+
* @returns {Hono} mounted Hono instance
|
|
14355
|
+
* @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
|
|
14356
|
+
* @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
|
|
14357
|
+
*
|
|
14358
|
+
* @example
|
|
14359
|
+
* ```ts
|
|
14360
|
+
* import { Router as IttyRouter } from 'itty-router'
|
|
14361
|
+
* import { Hono } from 'hono'
|
|
14362
|
+
* // Create itty-router application
|
|
14363
|
+
* const ittyRouter = IttyRouter()
|
|
14364
|
+
* // GET /itty-router/hello
|
|
14365
|
+
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
14366
|
+
*
|
|
14367
|
+
* const app = new Hono()
|
|
14368
|
+
* app.mount('/itty-router', ittyRouter.handle)
|
|
14369
|
+
* ```
|
|
14370
|
+
*
|
|
14371
|
+
* @example
|
|
14372
|
+
* ```ts
|
|
14373
|
+
* const app = new Hono()
|
|
14374
|
+
* // Send the request to another application without modification.
|
|
14375
|
+
* app.mount('/app', anotherApp, {
|
|
14376
|
+
* replaceRequest: (req) => req,
|
|
14377
|
+
* })
|
|
14378
|
+
* ```
|
|
14379
|
+
*/
|
|
14416
14380
|
mount(path, applicationHandler, options) {
|
|
14417
14381
|
let replaceRequest;
|
|
14418
14382
|
let optionHandler;
|
|
14419
14383
|
if (options) {
|
|
14420
|
-
if (typeof options === "function")
|
|
14421
|
-
|
|
14422
|
-
} else {
|
|
14384
|
+
if (typeof options === "function") optionHandler = options;
|
|
14385
|
+
else {
|
|
14423
14386
|
optionHandler = options.optionHandler;
|
|
14424
|
-
if (options.replaceRequest === false)
|
|
14425
|
-
|
|
14426
|
-
} else {
|
|
14427
|
-
replaceRequest = options.replaceRequest;
|
|
14428
|
-
}
|
|
14387
|
+
if (options.replaceRequest === false) replaceRequest = /* @__PURE__ */ __name((request) => request, "replaceRequest");
|
|
14388
|
+
else replaceRequest = options.replaceRequest;
|
|
14429
14389
|
}
|
|
14430
14390
|
}
|
|
14431
14391
|
const getOptions = optionHandler ? (c) => {
|
|
@@ -14439,27 +14399,19 @@ var Hono = class _Hono {
|
|
|
14439
14399
|
}
|
|
14440
14400
|
return [c.env, executionContext];
|
|
14441
14401
|
};
|
|
14442
|
-
|
|
14443
|
-
const
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
const url = new URL(request.url);
|
|
14447
|
-
url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
|
|
14448
|
-
return new Request(url, request);
|
|
14449
|
-
};
|
|
14450
|
-
})();
|
|
14402
|
+
const defaultReplaceRequest = /* @__PURE__ */ __name((c) => {
|
|
14403
|
+
const mountedRoutePath = routePath(c);
|
|
14404
|
+
return createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
|
|
14405
|
+
}, "defaultReplaceRequest");
|
|
14451
14406
|
const handler = /* @__PURE__ */ __name(async (c, next) => {
|
|
14452
|
-
const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
|
|
14453
|
-
if (res)
|
|
14454
|
-
return res;
|
|
14455
|
-
}
|
|
14407
|
+
const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
|
|
14408
|
+
if (res) return res;
|
|
14456
14409
|
await next();
|
|
14457
14410
|
}, "handler");
|
|
14458
|
-
this.#addRoute(
|
|
14411
|
+
this.#addRoute("ALL", mergePath(path, "*"), handler);
|
|
14459
14412
|
return this;
|
|
14460
14413
|
}
|
|
14461
14414
|
#addRoute(method, path, handler, baseRoutePath) {
|
|
14462
|
-
method = method.toUpperCase();
|
|
14463
14415
|
path = mergePath(this._basePath, path);
|
|
14464
14416
|
const r = {
|
|
14465
14417
|
basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
|
|
@@ -14471,15 +14423,11 @@ var Hono = class _Hono {
|
|
|
14471
14423
|
this.routes.push(r);
|
|
14472
14424
|
}
|
|
14473
14425
|
#handleError(err, c) {
|
|
14474
|
-
if (err instanceof Error)
|
|
14475
|
-
return this.errorHandler(err, c);
|
|
14476
|
-
}
|
|
14426
|
+
if (err instanceof Error) return this.errorHandler(err, c);
|
|
14477
14427
|
throw err;
|
|
14478
14428
|
}
|
|
14479
14429
|
#dispatch(request, executionCtx, env2, method) {
|
|
14480
|
-
if (method === "HEAD")
|
|
14481
|
-
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
|
|
14482
|
-
}
|
|
14430
|
+
if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
|
|
14483
14431
|
const path = this.getPath(request, { env: env2 });
|
|
14484
14432
|
const matchResult = this.router.match(method, path);
|
|
14485
14433
|
const c = new Context(request, {
|
|
@@ -14498,19 +14446,13 @@ var Hono = class _Hono {
|
|
|
14498
14446
|
} catch (err) {
|
|
14499
14447
|
return this.#handleError(err, c);
|
|
14500
14448
|
}
|
|
14501
|
-
return res instanceof Promise ? res.then(
|
|
14502
|
-
(resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))
|
|
14503
|
-
).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
|
|
14449
|
+
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);
|
|
14504
14450
|
}
|
|
14505
14451
|
const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
|
|
14506
14452
|
return (async () => {
|
|
14507
14453
|
try {
|
|
14508
14454
|
const context = await composed(c);
|
|
14509
|
-
if (!context.finalized)
|
|
14510
|
-
throw new Error(
|
|
14511
|
-
"Context is not finalized. Did you forget to return a Response object or `await next()`?"
|
|
14512
|
-
);
|
|
14513
|
-
}
|
|
14455
|
+
if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
|
|
14514
14456
|
return context.res;
|
|
14515
14457
|
} catch (err) {
|
|
14516
14458
|
return this.#handleError(err, c);
|
|
@@ -14518,62 +14460,53 @@ var Hono = class _Hono {
|
|
|
14518
14460
|
})();
|
|
14519
14461
|
}
|
|
14520
14462
|
/**
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14463
|
+
* `.fetch()` will be entry point of your app.
|
|
14464
|
+
*
|
|
14465
|
+
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
14466
|
+
*
|
|
14467
|
+
* @param {Request} request - request Object of request
|
|
14468
|
+
* @param {Env} env - env Object
|
|
14469
|
+
* @param {ExecutionContext} executionCtx - context of execution
|
|
14470
|
+
* @returns {Response | Promise<Response>} response of request
|
|
14471
|
+
*
|
|
14472
|
+
*/
|
|
14531
14473
|
fetch = /* @__PURE__ */ __name((request, ...rest) => {
|
|
14532
14474
|
return this.#dispatch(request, rest[1], rest[0], request.method);
|
|
14533
14475
|
}, "fetch");
|
|
14534
14476
|
/**
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14477
|
+
* `.request()` is a useful method for testing.
|
|
14478
|
+
* You can pass a URL or pathname to send a GET request.
|
|
14479
|
+
* app will return a Response object.
|
|
14480
|
+
* ```ts
|
|
14481
|
+
* test('GET /hello is ok', async () => {
|
|
14482
|
+
* const res = await app.request('/hello')
|
|
14483
|
+
* expect(res.status).toBe(200)
|
|
14484
|
+
* })
|
|
14485
|
+
* ```
|
|
14486
|
+
* @see https://hono.dev/docs/api/hono#request
|
|
14487
|
+
*/
|
|
14546
14488
|
request = /* @__PURE__ */ __name((input, requestInit, Env, executionCtx) => {
|
|
14547
|
-
if (input instanceof Request)
|
|
14548
|
-
return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
|
|
14549
|
-
}
|
|
14489
|
+
if (input instanceof Request) return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
|
|
14550
14490
|
input = input.toString();
|
|
14551
|
-
return this.fetch(
|
|
14552
|
-
new Request(
|
|
14553
|
-
/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`,
|
|
14554
|
-
requestInit
|
|
14555
|
-
),
|
|
14556
|
-
Env,
|
|
14557
|
-
executionCtx
|
|
14558
|
-
);
|
|
14491
|
+
return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, requestInit), Env, executionCtx);
|
|
14559
14492
|
}, "request");
|
|
14560
14493
|
/**
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14494
|
+
* `.fire()` automatically adds a global fetch event listener.
|
|
14495
|
+
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
14496
|
+
* @deprecated
|
|
14497
|
+
* Use `fire` from `hono/service-worker` instead.
|
|
14498
|
+
* ```ts
|
|
14499
|
+
* import { Hono } from 'hono'
|
|
14500
|
+
* import { fire } from 'hono/service-worker'
|
|
14501
|
+
*
|
|
14502
|
+
* const app = new Hono()
|
|
14503
|
+
* // ...
|
|
14504
|
+
* fire(app)
|
|
14505
|
+
* ```
|
|
14506
|
+
* @see https://hono.dev/docs/api/hono#fire
|
|
14507
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
14508
|
+
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
14509
|
+
*/
|
|
14577
14510
|
fire = /* @__PURE__ */ __name(() => {
|
|
14578
14511
|
addEventListener("fetch", (event) => {
|
|
14579
14512
|
event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));
|
|
@@ -14581,181 +14514,171 @@ var Hono = class _Hono {
|
|
|
14581
14514
|
}, "fire");
|
|
14582
14515
|
};
|
|
14583
14516
|
|
|
14584
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14517
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/utils.js
|
|
14518
|
+
var createNullObject = /* @__PURE__ */ __name(() => /* @__PURE__ */ Object.create(null), "createNullObject");
|
|
14519
|
+
|
|
14520
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
14585
14521
|
var emptyParam = [];
|
|
14586
14522
|
function match(method, path) {
|
|
14587
14523
|
const matchers = this.buildAllMatchers();
|
|
14588
14524
|
const match2 = /* @__PURE__ */ __name(((method2, path2) => {
|
|
14589
|
-
const matcher = matchers[method2] || matchers[
|
|
14525
|
+
const matcher = matchers[method2] || matchers["ALL"];
|
|
14590
14526
|
const staticMatch = matcher[2][path2];
|
|
14591
|
-
if (staticMatch)
|
|
14592
|
-
return staticMatch;
|
|
14593
|
-
}
|
|
14527
|
+
if (staticMatch) return staticMatch;
|
|
14594
14528
|
const match3 = path2.match(matcher[0]);
|
|
14595
|
-
if (!match3)
|
|
14596
|
-
return [[], emptyParam];
|
|
14597
|
-
}
|
|
14529
|
+
if (!match3) return [[], emptyParam];
|
|
14598
14530
|
const index = match3.indexOf("", 1);
|
|
14599
14531
|
return [matcher[1][index], match3];
|
|
14600
|
-
}), "
|
|
14532
|
+
}), "match");
|
|
14601
14533
|
this.match = match2;
|
|
14602
14534
|
return match2(method, path);
|
|
14603
14535
|
}
|
|
14604
14536
|
__name(match, "match");
|
|
14605
14537
|
|
|
14606
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14538
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
14607
14539
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
14608
|
-
var ONLY_WILDCARD_REG_EXP_STR = "
|
|
14609
|
-
var TAIL_WILDCARD_REG_EXP_STR = "(
|
|
14540
|
+
var ONLY_WILDCARD_REG_EXP_STR = "[^]*";
|
|
14541
|
+
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
|
|
14610
14542
|
var PATH_ERROR = /* @__PURE__ */ Symbol();
|
|
14611
|
-
var regExpMetaChars = new Set(".\\+*[^]$()");
|
|
14543
|
+
var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
14612
14544
|
function compareKey(a, b) {
|
|
14613
|
-
if (a.length === 1)
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
if (b
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
|
|
14620
|
-
return 1;
|
|
14621
|
-
} else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
|
|
14622
|
-
return -1;
|
|
14623
|
-
}
|
|
14624
|
-
if (a === LABEL_REG_EXP_STR) {
|
|
14625
|
-
return 1;
|
|
14626
|
-
} else if (b === LABEL_REG_EXP_STR) {
|
|
14627
|
-
return -1;
|
|
14628
|
-
}
|
|
14545
|
+
if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
|
|
14546
|
+
if (b.length === 1) return 1;
|
|
14547
|
+
if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
|
|
14548
|
+
else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
|
|
14549
|
+
if (a === "[^/]+") return 1;
|
|
14550
|
+
else if (b === "[^/]+") return -1;
|
|
14629
14551
|
return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
|
|
14630
14552
|
}
|
|
14631
14553
|
__name(compareKey, "compareKey");
|
|
14632
|
-
var Node = class
|
|
14554
|
+
var Node = class Node2 {
|
|
14633
14555
|
static {
|
|
14634
|
-
__name(this, "
|
|
14556
|
+
__name(this, "Node");
|
|
14635
14557
|
}
|
|
14636
14558
|
#index;
|
|
14637
14559
|
#varIndex;
|
|
14638
|
-
#children =
|
|
14639
|
-
insert(tokens, index, paramMap, context,
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
node = this.#children[regexpStr];
|
|
14666
|
-
if (!node) {
|
|
14667
|
-
if (Object.keys(this.#children).some(
|
|
14668
|
-
(k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
14669
|
-
)) {
|
|
14670
|
-
throw PATH_ERROR;
|
|
14560
|
+
#children = createNullObject();
|
|
14561
|
+
insert(tokens, index, paramMap, context, keys) {
|
|
14562
|
+
let node = this;
|
|
14563
|
+
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
14564
|
+
const token = tokens[i];
|
|
14565
|
+
const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
|
|
14566
|
+
"",
|
|
14567
|
+
"",
|
|
14568
|
+
ONLY_WILDCARD_REG_EXP_STR
|
|
14569
|
+
] : [
|
|
14570
|
+
"",
|
|
14571
|
+
"",
|
|
14572
|
+
LABEL_REG_EXP_STR
|
|
14573
|
+
] : null : token === "/*" ? [
|
|
14574
|
+
"",
|
|
14575
|
+
"",
|
|
14576
|
+
TAIL_WILDCARD_REG_EXP_STR
|
|
14577
|
+
] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
14578
|
+
let nextNode;
|
|
14579
|
+
if (pattern) {
|
|
14580
|
+
const name = pattern[1];
|
|
14581
|
+
let regexpStr = pattern[2] || "[^/]+";
|
|
14582
|
+
if (name && pattern[2]) {
|
|
14583
|
+
if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
|
|
14584
|
+
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
14585
|
+
if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
|
|
14586
|
+
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
|
|
14671
14587
|
}
|
|
14672
|
-
|
|
14673
|
-
|
|
14588
|
+
keys.push(regexpStr);
|
|
14589
|
+
nextNode = node.#children[regexpStr];
|
|
14590
|
+
if (!nextNode) {
|
|
14591
|
+
if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
|
|
14592
|
+
for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
|
|
14593
|
+
}
|
|
14594
|
+
nextNode = node.#children[regexpStr] = new Node2();
|
|
14674
14595
|
}
|
|
14675
|
-
node = this.#children[regexpStr] = new _Node();
|
|
14676
14596
|
if (name !== "") {
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
}
|
|
14680
|
-
if (!pathErrorCheckOnly && name !== "") {
|
|
14681
|
-
paramMap.push([name, node.#varIndex]);
|
|
14682
|
-
}
|
|
14683
|
-
} else {
|
|
14684
|
-
node = this.#children[token];
|
|
14685
|
-
if (!node) {
|
|
14686
|
-
if (Object.keys(this.#children).some(
|
|
14687
|
-
(k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
|
|
14688
|
-
)) {
|
|
14689
|
-
throw PATH_ERROR;
|
|
14597
|
+
nextNode.#varIndex ??= context.varIndex++;
|
|
14598
|
+
paramMap.push([name, nextNode.#varIndex]);
|
|
14690
14599
|
}
|
|
14691
|
-
|
|
14692
|
-
|
|
14600
|
+
} else {
|
|
14601
|
+
keys.push(token);
|
|
14602
|
+
nextNode = node.#children[token];
|
|
14603
|
+
if (!nextNode) {
|
|
14604
|
+
for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
|
|
14605
|
+
nextNode = node.#children[token] = new Node2();
|
|
14693
14606
|
}
|
|
14694
|
-
node = this.#children[token] = new _Node();
|
|
14695
14607
|
}
|
|
14608
|
+
node = nextNode;
|
|
14696
14609
|
}
|
|
14697
|
-
node
|
|
14610
|
+
if (node.#index !== void 0) throw PATH_ERROR;
|
|
14611
|
+
node.#index = index;
|
|
14698
14612
|
}
|
|
14699
14613
|
buildRegExpStr() {
|
|
14700
|
-
const
|
|
14701
|
-
const strList = childKeys.map((k) => {
|
|
14614
|
+
const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
|
|
14702
14615
|
const c = this.#children[k];
|
|
14703
|
-
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
|
|
14707
|
-
|
|
14708
|
-
if (strList.length ===
|
|
14709
|
-
return "";
|
|
14710
|
-
}
|
|
14711
|
-
if (strList.length === 1) {
|
|
14712
|
-
return strList[0];
|
|
14713
|
-
}
|
|
14616
|
+
const childStr = c.buildRegExpStr();
|
|
14617
|
+
return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
|
|
14618
|
+
}).filter(Boolean);
|
|
14619
|
+
if (typeof this.#index === "number" && this.#index !== -1) strList.unshift(`#${this.#index}`);
|
|
14620
|
+
if (strList.length === 0) return "";
|
|
14621
|
+
if (strList.length === 1) return strList[0];
|
|
14714
14622
|
return "(?:" + strList.join("|") + ")";
|
|
14715
14623
|
}
|
|
14716
14624
|
};
|
|
14717
14625
|
|
|
14718
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14626
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
14719
14627
|
var Trie = class {
|
|
14720
14628
|
static {
|
|
14721
14629
|
__name(this, "Trie");
|
|
14722
14630
|
}
|
|
14723
14631
|
#context = { varIndex: 0 };
|
|
14724
14632
|
#root = new Node();
|
|
14725
|
-
|
|
14633
|
+
#index = 0;
|
|
14634
|
+
paths = createNullObject();
|
|
14635
|
+
insert(path, isStatic) {
|
|
14636
|
+
const keys = [];
|
|
14637
|
+
if (isStatic) {
|
|
14638
|
+
this.#root.insert(path.split(""), -1, [], this.#context, keys);
|
|
14639
|
+
this.paths[path] = [
|
|
14640
|
+
-1,
|
|
14641
|
+
[],
|
|
14642
|
+
keys
|
|
14643
|
+
];
|
|
14644
|
+
return;
|
|
14645
|
+
}
|
|
14726
14646
|
const paramAssoc = [];
|
|
14727
14647
|
const groups = [];
|
|
14648
|
+
let markedPath = path;
|
|
14728
14649
|
for (let i = 0; ; ) {
|
|
14729
14650
|
let replaced = false;
|
|
14730
|
-
|
|
14651
|
+
markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
|
|
14731
14652
|
const mark = `@\\${i}`;
|
|
14732
14653
|
groups[i] = [mark, m];
|
|
14733
14654
|
i++;
|
|
14734
14655
|
replaced = true;
|
|
14735
14656
|
return mark;
|
|
14736
14657
|
});
|
|
14737
|
-
if (!replaced)
|
|
14738
|
-
break;
|
|
14739
|
-
}
|
|
14658
|
+
if (!replaced) break;
|
|
14740
14659
|
}
|
|
14741
|
-
const tokens =
|
|
14660
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
|
|
14742
14661
|
for (let i = groups.length - 1; i >= 0; i--) {
|
|
14743
14662
|
const [mark] = groups[i];
|
|
14744
|
-
for (let j = tokens.length - 1; j >= 0; j--) {
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
break;
|
|
14748
|
-
}
|
|
14663
|
+
for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
|
|
14664
|
+
tokens[j] = tokens[j].replace(mark, groups[i][1]);
|
|
14665
|
+
break;
|
|
14749
14666
|
}
|
|
14750
14667
|
}
|
|
14751
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context,
|
|
14752
|
-
|
|
14668
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
|
|
14669
|
+
this.paths[path] = [
|
|
14670
|
+
this.#index++,
|
|
14671
|
+
paramAssoc,
|
|
14672
|
+
keys
|
|
14673
|
+
];
|
|
14753
14674
|
}
|
|
14754
14675
|
buildRegExp() {
|
|
14755
14676
|
let regexp = this.#root.buildRegExpStr();
|
|
14756
|
-
if (regexp === "")
|
|
14757
|
-
|
|
14758
|
-
|
|
14677
|
+
if (regexp === "") return [
|
|
14678
|
+
/^$/,
|
|
14679
|
+
[],
|
|
14680
|
+
[]
|
|
14681
|
+
];
|
|
14759
14682
|
let captureIndex = 0;
|
|
14760
14683
|
const indexReplacementMap = [];
|
|
14761
14684
|
const paramReplacementMap = [];
|
|
@@ -14770,197 +14693,102 @@ var Trie = class {
|
|
|
14770
14693
|
}
|
|
14771
14694
|
return "";
|
|
14772
14695
|
});
|
|
14773
|
-
return [
|
|
14696
|
+
return [
|
|
14697
|
+
new RegExp(`^${regexp}`),
|
|
14698
|
+
indexReplacementMap,
|
|
14699
|
+
paramReplacementMap
|
|
14700
|
+
];
|
|
14774
14701
|
}
|
|
14775
14702
|
};
|
|
14776
14703
|
|
|
14777
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
return wildcardRegExpCache[path] ??= new RegExp(
|
|
14782
|
-
path === "*" ? "" : `^${path.replace(
|
|
14783
|
-
/\/\*$|([.\\+*[^\]$()])/g,
|
|
14784
|
-
(_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
|
|
14785
|
-
)}$`
|
|
14786
|
-
);
|
|
14787
|
-
}
|
|
14788
|
-
__name(buildWildcardRegExp, "buildWildcardRegExp");
|
|
14789
|
-
function clearWildcardRegExpCache() {
|
|
14790
|
-
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
14791
|
-
}
|
|
14792
|
-
__name(clearWildcardRegExpCache, "clearWildcardRegExpCache");
|
|
14793
|
-
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
14794
|
-
const trie = new Trie();
|
|
14795
|
-
const handlerData = [];
|
|
14796
|
-
if (routes.length === 0) {
|
|
14797
|
-
return nullMatcher;
|
|
14798
|
-
}
|
|
14799
|
-
const routesWithStaticPathFlag = routes.map(
|
|
14800
|
-
(route) => [!/\*|\/:/.test(route[0]), ...route]
|
|
14801
|
-
).sort(
|
|
14802
|
-
([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
|
|
14803
|
-
);
|
|
14804
|
-
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
14805
|
-
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
|
|
14806
|
-
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
|
|
14807
|
-
if (pathErrorCheckOnly) {
|
|
14808
|
-
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
14809
|
-
} else {
|
|
14810
|
-
j++;
|
|
14811
|
-
}
|
|
14812
|
-
let paramAssoc;
|
|
14813
|
-
try {
|
|
14814
|
-
paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
|
|
14815
|
-
} catch (e) {
|
|
14816
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
14817
|
-
}
|
|
14818
|
-
if (pathErrorCheckOnly) {
|
|
14819
|
-
continue;
|
|
14820
|
-
}
|
|
14821
|
-
handlerData[j] = handlers.map(([h, paramCount]) => {
|
|
14822
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
14823
|
-
paramCount -= 1;
|
|
14824
|
-
for (; paramCount >= 0; paramCount--) {
|
|
14825
|
-
const [key, value] = paramAssoc[paramCount];
|
|
14826
|
-
paramIndexMap[key] = value;
|
|
14827
|
-
}
|
|
14828
|
-
return [h, paramIndexMap];
|
|
14829
|
-
});
|
|
14830
|
-
}
|
|
14831
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
14832
|
-
for (let i = 0, len = handlerData.length; i < len; i++) {
|
|
14833
|
-
for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
|
|
14834
|
-
const map = handlerData[i][j]?.[1];
|
|
14835
|
-
if (!map) {
|
|
14836
|
-
continue;
|
|
14837
|
-
}
|
|
14838
|
-
const keys = Object.keys(map);
|
|
14839
|
-
for (let k = 0, len3 = keys.length; k < len3; k++) {
|
|
14840
|
-
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
14841
|
-
}
|
|
14842
|
-
}
|
|
14843
|
-
}
|
|
14844
|
-
const handlerMap = [];
|
|
14845
|
-
for (const i in indexReplacementMap) {
|
|
14846
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
14847
|
-
}
|
|
14848
|
-
return [regexp, handlerMap, staticMap];
|
|
14704
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
14705
|
+
function endsWithWildcard(keys) {
|
|
14706
|
+
const tail = keys[keys.length - 1];
|
|
14707
|
+
return tail === "[^]*" || tail === "(?:|/[^]*)";
|
|
14849
14708
|
}
|
|
14850
|
-
__name(
|
|
14851
|
-
function
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
14856
|
-
if (buildWildcardRegExp(k).test(path)) {
|
|
14857
|
-
return [...middleware[k]];
|
|
14858
|
-
}
|
|
14859
|
-
}
|
|
14860
|
-
return void 0;
|
|
14709
|
+
__name(endsWithWildcard, "endsWithWildcard");
|
|
14710
|
+
function covers(wildcard, target) {
|
|
14711
|
+
const last = wildcard.length - 1;
|
|
14712
|
+
for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
|
|
14713
|
+
return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
|
|
14861
14714
|
}
|
|
14862
|
-
__name(
|
|
14715
|
+
__name(covers, "covers");
|
|
14863
14716
|
var RegExpRouter = class {
|
|
14864
14717
|
static {
|
|
14865
14718
|
__name(this, "RegExpRouter");
|
|
14866
14719
|
}
|
|
14867
14720
|
name = "RegExpRouter";
|
|
14868
|
-
#
|
|
14869
|
-
#
|
|
14721
|
+
#handlers;
|
|
14722
|
+
#tries;
|
|
14870
14723
|
constructor() {
|
|
14871
|
-
this.#
|
|
14872
|
-
this.#
|
|
14724
|
+
this.#handlers = { ["ALL"]: [] };
|
|
14725
|
+
this.#tries = { ["ALL"]: new Trie() };
|
|
14873
14726
|
}
|
|
14874
|
-
|
|
14875
|
-
|
|
14876
|
-
|
|
14877
|
-
|
|
14878
|
-
throw new
|
|
14879
|
-
}
|
|
14880
|
-
if (!middleware[method]) {
|
|
14881
|
-
;
|
|
14882
|
-
[middleware, routes].forEach((handlerMap) => {
|
|
14883
|
-
handlerMap[method] = /* @__PURE__ */ Object.create(null);
|
|
14884
|
-
Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
|
|
14885
|
-
handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
|
|
14886
|
-
});
|
|
14887
|
-
});
|
|
14888
|
-
}
|
|
14889
|
-
if (path === "/*") {
|
|
14890
|
-
path = "*";
|
|
14891
|
-
}
|
|
14892
|
-
const paramCount = (path.match(/\/:/g) || []).length;
|
|
14893
|
-
if (/\*$/.test(path)) {
|
|
14894
|
-
const re = buildWildcardRegExp(path);
|
|
14895
|
-
if (method === METHOD_NAME_ALL) {
|
|
14896
|
-
Object.keys(middleware).forEach((m) => {
|
|
14897
|
-
middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
14898
|
-
});
|
|
14899
|
-
} else {
|
|
14900
|
-
middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
14901
|
-
}
|
|
14902
|
-
Object.keys(middleware).forEach((m) => {
|
|
14903
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
14904
|
-
Object.keys(middleware[m]).forEach((p) => {
|
|
14905
|
-
re.test(p) && middleware[m][p].push([handler, paramCount]);
|
|
14906
|
-
});
|
|
14907
|
-
}
|
|
14908
|
-
});
|
|
14909
|
-
Object.keys(routes).forEach((m) => {
|
|
14910
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
14911
|
-
Object.keys(routes[m]).forEach(
|
|
14912
|
-
(p) => re.test(p) && routes[m][p].push([handler, paramCount])
|
|
14913
|
-
);
|
|
14914
|
-
}
|
|
14915
|
-
});
|
|
14916
|
-
return;
|
|
14727
|
+
#insertPath(method, path) {
|
|
14728
|
+
try {
|
|
14729
|
+
this.#tries[method].insert(path, !/\*|\/:/.test(path));
|
|
14730
|
+
} catch (e) {
|
|
14731
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
14917
14732
|
}
|
|
14733
|
+
}
|
|
14734
|
+
add(method, path, handler) {
|
|
14735
|
+
const handlers = this.#handlers;
|
|
14736
|
+
if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
14737
|
+
const tries = this.#tries;
|
|
14738
|
+
if (!handlers[method]) {
|
|
14739
|
+
tries[method] = new Trie();
|
|
14740
|
+
handlers[method] = [...handlers["ALL"]];
|
|
14741
|
+
for (const p in tries["ALL"].paths) this.#insertPath(method, p);
|
|
14742
|
+
}
|
|
14743
|
+
if (path === "/*") path = "*";
|
|
14744
|
+
const methods = method === "ALL" ? Object.keys(handlers) : [method];
|
|
14918
14745
|
const paths = checkOptionalParameter(path) || [path];
|
|
14919
|
-
for (
|
|
14920
|
-
|
|
14921
|
-
|
|
14922
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
14923
|
-
routes[m][path2] ||= [
|
|
14924
|
-
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
|
|
14925
|
-
];
|
|
14926
|
-
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
14927
|
-
}
|
|
14928
|
-
});
|
|
14746
|
+
for (const path2 of paths) for (const m of methods) {
|
|
14747
|
+
if (!tries[m].paths[path2]) this.#insertPath(m, path2);
|
|
14748
|
+
handlers[m].push([handler, path2]);
|
|
14929
14749
|
}
|
|
14930
14750
|
}
|
|
14931
14751
|
match = match;
|
|
14932
14752
|
buildAllMatchers() {
|
|
14933
|
-
const matchers =
|
|
14934
|
-
Object.keys(this.#
|
|
14935
|
-
|
|
14936
|
-
});
|
|
14937
|
-
this.#middleware = this.#routes = void 0;
|
|
14938
|
-
clearWildcardRegExpCache();
|
|
14753
|
+
const matchers = createNullObject();
|
|
14754
|
+
for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
|
|
14755
|
+
this.#handlers = this.#tries = void 0;
|
|
14939
14756
|
return matchers;
|
|
14940
14757
|
}
|
|
14941
14758
|
#buildMatcher(method) {
|
|
14942
|
-
const
|
|
14943
|
-
|
|
14944
|
-
|
|
14945
|
-
|
|
14946
|
-
|
|
14947
|
-
|
|
14948
|
-
|
|
14949
|
-
|
|
14950
|
-
|
|
14951
|
-
|
|
14952
|
-
|
|
14953
|
-
}
|
|
14759
|
+
const handlers = this.#handlers[method];
|
|
14760
|
+
const trie = this.#tries[method];
|
|
14761
|
+
const staticMap = createNullObject();
|
|
14762
|
+
const handlerData = [];
|
|
14763
|
+
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
14764
|
+
const own = createNullObject();
|
|
14765
|
+
const entries = handlers.map(([h, p], i) => {
|
|
14766
|
+
(own[p] ??= []).push(i);
|
|
14767
|
+
return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
|
|
14768
|
+
map[key] = paramReplacementMap[varIndex];
|
|
14769
|
+
return map;
|
|
14770
|
+
}, createNullObject())];
|
|
14954
14771
|
});
|
|
14955
|
-
|
|
14956
|
-
|
|
14957
|
-
|
|
14958
|
-
|
|
14772
|
+
const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
|
|
14773
|
+
for (const path in trie.paths) {
|
|
14774
|
+
const [index, , keys] = trie.paths[path];
|
|
14775
|
+
const indexes = [...own[path]];
|
|
14776
|
+
for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
|
|
14777
|
+
const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
|
|
14778
|
+
if (index === -1) {
|
|
14779
|
+
const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
|
|
14780
|
+
staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
|
|
14781
|
+
} else handlerData[index] = data;
|
|
14959
14782
|
}
|
|
14783
|
+
return [
|
|
14784
|
+
regexp,
|
|
14785
|
+
indexReplacementMap.map((i) => handlerData[i]),
|
|
14786
|
+
staticMap
|
|
14787
|
+
];
|
|
14960
14788
|
}
|
|
14961
14789
|
};
|
|
14962
14790
|
|
|
14963
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14791
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/smart-router/router.js
|
|
14964
14792
|
var SmartRouter = class {
|
|
14965
14793
|
static {
|
|
14966
14794
|
__name(this, "SmartRouter");
|
|
@@ -14972,15 +14800,15 @@ var SmartRouter = class {
|
|
|
14972
14800
|
this.#routers = init.routers;
|
|
14973
14801
|
}
|
|
14974
14802
|
add(method, path, handler) {
|
|
14975
|
-
if (!this.#routes)
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14803
|
+
if (!this.#routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
14804
|
+
this.#routes.push([
|
|
14805
|
+
method,
|
|
14806
|
+
path,
|
|
14807
|
+
handler
|
|
14808
|
+
]);
|
|
14979
14809
|
}
|
|
14980
14810
|
match(method, path) {
|
|
14981
|
-
if (!this.#routes)
|
|
14982
|
-
throw new Error("Fatal error");
|
|
14983
|
-
}
|
|
14811
|
+
if (!this.#routes) throw new Error("Fatal error");
|
|
14984
14812
|
const routers = this.#routers;
|
|
14985
14813
|
const routes = this.#routes;
|
|
14986
14814
|
const len = routers.length;
|
|
@@ -14989,14 +14817,10 @@ var SmartRouter = class {
|
|
|
14989
14817
|
for (; i < len; i++) {
|
|
14990
14818
|
const router = routers[i];
|
|
14991
14819
|
try {
|
|
14992
|
-
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++)
|
|
14993
|
-
router.add(...routes[i2]);
|
|
14994
|
-
}
|
|
14820
|
+
for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) router.add(...routes[i2]);
|
|
14995
14821
|
res = router.match(method, path);
|
|
14996
14822
|
} catch (e) {
|
|
14997
|
-
if (e instanceof UnsupportedPathError)
|
|
14998
|
-
continue;
|
|
14999
|
-
}
|
|
14823
|
+
if (e instanceof UnsupportedPathError) continue;
|
|
15000
14824
|
throw e;
|
|
15001
14825
|
}
|
|
15002
14826
|
this.match = router.match.bind(router);
|
|
@@ -15004,95 +14828,62 @@ var SmartRouter = class {
|
|
|
15004
14828
|
this.#routes = void 0;
|
|
15005
14829
|
break;
|
|
15006
14830
|
}
|
|
15007
|
-
if (i === len)
|
|
15008
|
-
throw new Error("Fatal error");
|
|
15009
|
-
}
|
|
14831
|
+
if (i === len) throw new Error("Fatal error");
|
|
15010
14832
|
this.name = `SmartRouter + ${this.activeRouter.name}`;
|
|
15011
14833
|
return res;
|
|
15012
14834
|
}
|
|
15013
14835
|
get activeRouter() {
|
|
15014
|
-
if (this.#routes || this.#routers.length !== 1)
|
|
15015
|
-
throw new Error("No active router has been determined yet.");
|
|
15016
|
-
}
|
|
14836
|
+
if (this.#routes || this.#routers.length !== 1) throw new Error("No active router has been determined yet.");
|
|
15017
14837
|
return this.#routers[0];
|
|
15018
14838
|
}
|
|
15019
14839
|
};
|
|
15020
14840
|
|
|
15021
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
15022
|
-
var emptyParams =
|
|
15023
|
-
var
|
|
15024
|
-
|
|
15025
|
-
return true;
|
|
15026
|
-
}
|
|
15027
|
-
return false;
|
|
15028
|
-
}, "hasChildren");
|
|
15029
|
-
var Node2 = class _Node2 {
|
|
14841
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/trie-router/node.js
|
|
14842
|
+
var emptyParams = createNullObject();
|
|
14843
|
+
var order = 0;
|
|
14844
|
+
var Node3 = class Node4 {
|
|
15030
14845
|
static {
|
|
15031
|
-
__name(this, "
|
|
14846
|
+
__name(this, "Node");
|
|
15032
14847
|
}
|
|
15033
|
-
#methods;
|
|
15034
|
-
#children;
|
|
15035
|
-
#patterns;
|
|
15036
|
-
#
|
|
14848
|
+
#methods = [];
|
|
14849
|
+
#children = createNullObject();
|
|
14850
|
+
#patterns = [];
|
|
14851
|
+
#pattern;
|
|
15037
14852
|
#params = emptyParams;
|
|
15038
|
-
constructor(method, handler, children) {
|
|
15039
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
15040
|
-
this.#methods = [];
|
|
15041
|
-
if (method && handler) {
|
|
15042
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
15043
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
15044
|
-
this.#methods = [m];
|
|
15045
|
-
}
|
|
15046
|
-
this.#patterns = [];
|
|
15047
|
-
}
|
|
15048
14853
|
insert(method, path, handler) {
|
|
15049
|
-
this.#order = ++this.#order;
|
|
15050
14854
|
let curNode = this;
|
|
15051
14855
|
const parts = splitRoutingPath(path);
|
|
15052
|
-
const possibleKeys =
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
const nextP = parts[i
|
|
15056
|
-
const pattern = getPattern(p, nextP);
|
|
15057
|
-
const
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
|
|
15063
|
-
continue;
|
|
15064
|
-
}
|
|
15065
|
-
curNode.#children[key] = new _Node2();
|
|
15066
|
-
if (pattern) {
|
|
15067
|
-
curNode.#patterns.push(pattern);
|
|
15068
|
-
possibleKeys.push(pattern[1]);
|
|
14856
|
+
const possibleKeys = /* @__PURE__ */ new Set();
|
|
14857
|
+
let i = 0;
|
|
14858
|
+
for (const p of parts) {
|
|
14859
|
+
const nextP = parts[++i];
|
|
14860
|
+
const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
14861
|
+
const isParam = Array.isArray(pattern);
|
|
14862
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
14863
|
+
const child = curNode.#children[key] ||= new Node4();
|
|
14864
|
+
if (pattern && !child.#pattern) {
|
|
14865
|
+
child.#pattern = pattern;
|
|
14866
|
+
curNode.#patterns.push(child);
|
|
15069
14867
|
}
|
|
15070
|
-
curNode =
|
|
14868
|
+
curNode = child;
|
|
14869
|
+
if (isParam) possibleKeys.add(pattern[1]);
|
|
15071
14870
|
}
|
|
15072
|
-
curNode.#methods.push({
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
}
|
|
15078
|
-
});
|
|
15079
|
-
return curNode;
|
|
14871
|
+
curNode.#methods.push({ [method]: {
|
|
14872
|
+
handler,
|
|
14873
|
+
possibleKeys: [...possibleKeys],
|
|
14874
|
+
score: ++order
|
|
14875
|
+
} });
|
|
15080
14876
|
}
|
|
15081
14877
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
15082
14878
|
for (let i = 0, len = node.#methods.length; i < len; i++) {
|
|
15083
14879
|
const m = node.#methods[i];
|
|
15084
|
-
const handlerSet = m[method] || m[
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
14880
|
+
const handlerSet = m[method] || m["ALL"];
|
|
14881
|
+
if (handlerSet) {
|
|
14882
|
+
handlerSet.params = createNullObject();
|
|
15088
14883
|
handlerSets.push(handlerSet);
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
const processed = processedSet[handlerSet.score];
|
|
15093
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
15094
|
-
processedSet[handlerSet.score] = true;
|
|
15095
|
-
}
|
|
14884
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
|
|
14885
|
+
const key = handlerSet.possibleKeys[i2];
|
|
14886
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
15096
14887
|
}
|
|
15097
14888
|
}
|
|
15098
14889
|
}
|
|
@@ -15100,8 +14891,7 @@ var Node2 = class _Node2 {
|
|
|
15100
14891
|
search(method, path) {
|
|
15101
14892
|
const handlerSets = [];
|
|
15102
14893
|
this.#params = emptyParams;
|
|
15103
|
-
|
|
15104
|
-
let curNodes = [curNode];
|
|
14894
|
+
let curNodes = [this];
|
|
15105
14895
|
const parts = splitPath(path);
|
|
15106
14896
|
const curNodesQueue = [];
|
|
15107
14897
|
const len = parts.length;
|
|
@@ -15116,76 +14906,54 @@ var Node2 = class _Node2 {
|
|
|
15116
14906
|
if (nextNode) {
|
|
15117
14907
|
nextNode.#params = node.#params;
|
|
15118
14908
|
if (isLast) {
|
|
15119
|
-
if (nextNode.#children["*"])
|
|
15120
|
-
this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
|
|
15121
|
-
}
|
|
14909
|
+
if (nextNode.#children["*"]) this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
|
|
15122
14910
|
this.#pushHandlerSets(handlerSets, nextNode, method, node.#params);
|
|
15123
|
-
} else
|
|
15124
|
-
tempNodes.push(nextNode);
|
|
15125
|
-
}
|
|
14911
|
+
} else tempNodes.push(nextNode);
|
|
15126
14912
|
}
|
|
15127
|
-
for (
|
|
15128
|
-
const pattern =
|
|
14913
|
+
for (const child of node.#patterns) {
|
|
14914
|
+
const pattern = child.#pattern;
|
|
15129
14915
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
15130
|
-
if (pattern === "
|
|
15131
|
-
|
|
15132
|
-
|
|
15133
|
-
|
|
15134
|
-
|
|
15135
|
-
|
|
14916
|
+
if (typeof pattern === "string") {
|
|
14917
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
14918
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
14919
|
+
if (pattern === "*") {
|
|
14920
|
+
child.#params = params;
|
|
14921
|
+
tempNodes.push(child);
|
|
14922
|
+
}
|
|
15136
14923
|
}
|
|
15137
14924
|
continue;
|
|
15138
14925
|
}
|
|
15139
|
-
const [
|
|
15140
|
-
if (!part &&
|
|
15141
|
-
|
|
15142
|
-
|
|
15143
|
-
|
|
15144
|
-
if (matcher instanceof RegExp) {
|
|
15145
|
-
if (partOffsets === null) {
|
|
15146
|
-
partOffsets = new Array(len);
|
|
14926
|
+
const [, name, matcher] = pattern;
|
|
14927
|
+
if (!part && matcher === true) continue;
|
|
14928
|
+
if (matcher !== true) {
|
|
14929
|
+
if (!partOffsets) {
|
|
14930
|
+
partOffsets = [];
|
|
15147
14931
|
let offset = path[0] === "/" ? 1 : 0;
|
|
15148
14932
|
for (let p = 0; p < len; p++) {
|
|
15149
14933
|
partOffsets[p] = offset;
|
|
15150
14934
|
offset += parts[p].length + 1;
|
|
15151
14935
|
}
|
|
15152
14936
|
}
|
|
15153
|
-
const restPathString = path.
|
|
14937
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
15154
14938
|
const m = matcher.exec(restPathString);
|
|
15155
14939
|
if (m) {
|
|
15156
|
-
params[name] = m[0];
|
|
14940
|
+
if (!Object.hasOwn(params, name)) params[name] = m[0];
|
|
15157
14941
|
this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
|
|
15158
|
-
if (m[0].length === restPathString.length && child.#children["*"])
|
|
15159
|
-
|
|
15160
|
-
handlerSets,
|
|
15161
|
-
child.#children["*"],
|
|
15162
|
-
method,
|
|
15163
|
-
node.#params,
|
|
15164
|
-
params
|
|
15165
|
-
);
|
|
15166
|
-
}
|
|
15167
|
-
if (hasChildren(child.#children)) {
|
|
14942
|
+
if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
|
|
14943
|
+
for (const _ in child.#children) {
|
|
15168
14944
|
child.#params = params;
|
|
15169
|
-
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
15170
|
-
|
|
15171
|
-
|
|
14945
|
+
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
14946
|
+
(curNodesQueue[componentCount] ||= []).push(child);
|
|
14947
|
+
break;
|
|
15172
14948
|
}
|
|
15173
14949
|
continue;
|
|
15174
14950
|
}
|
|
15175
14951
|
}
|
|
15176
14952
|
if (matcher === true || matcher.test(part)) {
|
|
15177
|
-
params[name] = part;
|
|
14953
|
+
if (!Object.hasOwn(params, name)) params[name] = part;
|
|
15178
14954
|
if (isLast) {
|
|
15179
14955
|
this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
|
|
15180
|
-
if (child.#children["*"])
|
|
15181
|
-
this.#pushHandlerSets(
|
|
15182
|
-
handlerSets,
|
|
15183
|
-
child.#children["*"],
|
|
15184
|
-
method,
|
|
15185
|
-
params,
|
|
15186
|
-
node.#params
|
|
15187
|
-
);
|
|
15188
|
-
}
|
|
14956
|
+
if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
|
|
15189
14957
|
} else {
|
|
15190
14958
|
child.#params = params;
|
|
15191
14959
|
tempNodes.push(child);
|
|
@@ -15196,55 +14964,41 @@ var Node2 = class _Node2 {
|
|
|
15196
14964
|
const shifted = curNodesQueue.shift();
|
|
15197
14965
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
15198
14966
|
}
|
|
15199
|
-
if (handlerSets.
|
|
15200
|
-
|
|
15201
|
-
|
|
15202
|
-
});
|
|
15203
|
-
}
|
|
14967
|
+
if (handlerSets[1]) handlerSets.sort((a, b) => {
|
|
14968
|
+
return a.score - b.score;
|
|
14969
|
+
});
|
|
15204
14970
|
return [handlerSets.map(({ handler, params }) => [handler, params])];
|
|
15205
14971
|
}
|
|
15206
14972
|
};
|
|
15207
14973
|
|
|
15208
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
14974
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/trie-router/router.js
|
|
15209
14975
|
var TrieRouter = class {
|
|
15210
14976
|
static {
|
|
15211
14977
|
__name(this, "TrieRouter");
|
|
15212
14978
|
}
|
|
15213
14979
|
name = "TrieRouter";
|
|
15214
|
-
#node;
|
|
15215
|
-
constructor() {
|
|
15216
|
-
this.#node = new Node2();
|
|
15217
|
-
}
|
|
14980
|
+
#node = new Node3();
|
|
15218
14981
|
add(method, path, handler) {
|
|
15219
|
-
const
|
|
15220
|
-
if (results) {
|
|
15221
|
-
for (let i = 0, len = results.length; i < len; i++) {
|
|
15222
|
-
this.#node.insert(method, results[i], handler);
|
|
15223
|
-
}
|
|
15224
|
-
return;
|
|
15225
|
-
}
|
|
15226
|
-
this.#node.insert(method, path, handler);
|
|
14982
|
+
for (const result of checkOptionalParameter(path) || [path]) this.#node.insert(method, result, handler);
|
|
15227
14983
|
}
|
|
15228
14984
|
match(method, path) {
|
|
15229
14985
|
return this.#node.search(method, path);
|
|
15230
14986
|
}
|
|
15231
14987
|
};
|
|
15232
14988
|
|
|
15233
|
-
// ../../node_modules/.pnpm/hono@4.
|
|
15234
|
-
var
|
|
14989
|
+
// ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/hono.js
|
|
14990
|
+
var Hono3 = class extends Hono {
|
|
15235
14991
|
static {
|
|
15236
14992
|
__name(this, "Hono");
|
|
15237
14993
|
}
|
|
15238
14994
|
/**
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
14995
|
+
* Creates an instance of the Hono class.
|
|
14996
|
+
*
|
|
14997
|
+
* @param options - Optional configuration options for the Hono instance.
|
|
14998
|
+
*/
|
|
15243
14999
|
constructor(options = {}) {
|
|
15244
15000
|
super(options);
|
|
15245
|
-
this.router = options.router ?? new SmartRouter({
|
|
15246
|
-
routers: [new RegExpRouter(), new TrieRouter()]
|
|
15247
|
-
});
|
|
15001
|
+
this.router = options.router ?? new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
|
|
15248
15002
|
}
|
|
15249
15003
|
};
|
|
15250
15004
|
|
|
@@ -15548,7 +15302,7 @@ var hotUpdater = createHotUpdater({
|
|
|
15548
15302
|
}
|
|
15549
15303
|
})
|
|
15550
15304
|
});
|
|
15551
|
-
var app = new
|
|
15305
|
+
var app = new Hono3();
|
|
15552
15306
|
app.mount(
|
|
15553
15307
|
HOT_UPDATER_BASE_PATH,
|
|
15554
15308
|
(request) => hotUpdater.handlers.client(request)
|