@hot-updater/cloudflare 1.1.21 → 1.1.22

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.
@@ -1877,8 +1877,8 @@ var verifyRows = /* @__PURE__ */ __name((table, request, rows) => {
1877
1877
  if (!matchesQuery(table, index, request, row)) fail(`${table.name}.${index.name} returned a row outside the request.`);
1878
1878
  const tuple = indexOrderTuple(table, index, row);
1879
1879
  if (previous !== void 0) {
1880
- const order = compareTuples(previous, tuple);
1881
- if (request.order === "asc" ? order >= 0 : order <= 0) fail(`${table.name}.${index.name} returned rows out of order.`);
1880
+ const order2 = compareTuples(previous, tuple);
1881
+ if (request.order === "asc" ? order2 >= 0 : order2 <= 0) fail(`${table.name}.${index.name} returned rows out of order.`);
1882
1882
  }
1883
1883
  previous = tuple;
1884
1884
  }
@@ -2221,8 +2221,8 @@ var pruneStatements = /* @__PURE__ */ __name((dialect, table, tablePrefix, limit
2221
2221
  const quote = /* @__PURE__ */ __name((name2) => quoteSql(dialect, name2), "quote");
2222
2222
  const name = quote(`${tablePrefix}${table.name}`);
2223
2223
  const at = quote(table.retention.column);
2224
- const order = retentionOrder(table).columns.map(quote);
2225
- const list = /* @__PURE__ */ __name((alias, direction = "") => order.map((column) => `${alias}.${column}${direction}`).join(", "), "list");
2224
+ const order2 = retentionOrder(table).columns.map(quote);
2225
+ const list = /* @__PURE__ */ __name((alias, direction = "") => order2.map((column) => `${alias}.${column}${direction}`).join(", "), "list");
2226
2226
  const oldest = /* @__PURE__ */ __name((before) => `SELECT ${list("i")} FROM ${name} i WHERE i.${at} <= ${before()} ORDER BY ${list("i", " ASC")} LIMIT ${limit}`, "oldest");
2227
2227
  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");
2228
2228
  const entries = table.indexes.filter((index) => isMultiIndex(table, index)).map((index) => quote(`${tablePrefix}${table.name}__${index.name}`));
@@ -2235,7 +2235,7 @@ var pruneStatements = /* @__PURE__ */ __name((dialect, table, tablePrefix, limit
2235
2235
  const into = quote(`${tablePrefix}${table.name}__${index.name}`);
2236
2236
  return (before) => `DELETE FROM ${into} WHERE (${columns.map(quote).join(", ")}) IN (SELECT ${values.join(", ")} FROM ${name} b${each.join("")} WHERE ${doomed("b", before)})`;
2237
2237
  }), (before) => `DELETE FROM ${name} WHERE ${doomed(name, before)}`];
2238
- 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 ${order.join(", ")} LIMIT ${limit}`];
2238
+ 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}`];
2239
2239
  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)}`];
2240
2240
  }, "pruneStatements");
2241
2241
 
@@ -4055,7 +4055,7 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
4055
4055
  if (index === void 0) throw new DatabaseQueryError(`${table.name} has no index ${input.index}.`);
4056
4056
  const where = input.where ?? {};
4057
4057
  if (!sameFields(Object.keys(where), index.eq)) throw new DatabaseQueryError(`${table.name}.${index.name} reads need where on exactly: ${index.eq.join(", ") || "(none)"}.`);
4058
- const { limit, order = "asc", range } = input;
4058
+ const { limit, order: order2 = "asc", range } = input;
4059
4059
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxPageSize) throw new DatabaseQueryError(`limit must be 1\u2013${maxPageSize}.`);
4060
4060
  const columns = indexOrderColumns(table, index);
4061
4061
  const eq = index.eq.map((field) => keyValue(where[field], `${table.name}.${field}`));
@@ -4063,14 +4063,14 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
4063
4063
  table.name,
4064
4064
  index.name,
4065
4065
  eq,
4066
- order,
4066
+ order2,
4067
4067
  range
4068
4068
  ]);
4069
4069
  let lower = bound(range?.gt, range?.gte, columns);
4070
4070
  let upper = bound(range?.lt, range?.lte, columns);
4071
4071
  if (input.cursor !== void 0) {
4072
4072
  const values = decodeCursor(scope, input.cursor);
4073
- if (order === "asc") lower = {
4073
+ if (order2 === "asc") lower = {
4074
4074
  values,
4075
4075
  inclusive: false
4076
4076
  };
@@ -4083,7 +4083,7 @@ var createEngineReads = /* @__PURE__ */ __name(({ adapter, schema, maxPageSize:
4083
4083
  request: {
4084
4084
  index: index.name,
4085
4085
  eq,
4086
- order,
4086
+ order: order2,
4087
4087
  limit,
4088
4088
  ...lower === void 0 ? {} : { lower },
4089
4089
  ...upper === void 0 ? {} : { upper }
@@ -4420,9 +4420,9 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4420
4420
  if (!isMultiIndex(table, index) || changed && !columns.some((column) => changed.includes(column))) return [];
4421
4421
  const into = tableOf(table, index);
4422
4422
  const found = row ? indexEntries(table, index, row) : [];
4423
- const order = found.length > 0 ? indexOrderTuple(table, index, row) : [];
4423
+ const order2 = found.length > 0 ? indexOrderTuple(table, index, row) : [];
4424
4424
  return [...stale ? [sql((bind) => `DELETE FROM ${into} WHERE ${where(bind, key)}`)] : [], ...found.map((eq) => sql((bind) => {
4425
- const values = [...eq, ...order].map((value) => bind(value));
4425
+ const values = [...eq, ...order2].map((value) => bind(value));
4426
4426
  return insert(bind, into, columns, values);
4427
4427
  }))];
4428
4428
  }), "entries");
@@ -4511,17 +4511,17 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4511
4511
  async query(table, request) {
4512
4512
  const index = findPhysicalIndex(table, request.index);
4513
4513
  if (!Number.isSafeInteger(request.limit) || request.limit < 1) throw new RangeError("query limit must be a positive integer.");
4514
- const order = indexOrderColumns(table, index);
4514
+ const order2 = indexOrderColumns(table, index);
4515
4515
  const multi = isMultiIndex(table, index);
4516
4516
  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`;
4517
4517
  const direction = request.order === "asc" ? "ASC" : "DESC";
4518
4518
  const statement = sql((bind) => {
4519
4519
  const conditions = [
4520
4520
  ...index.eq.map((column, position) => `i.${quote(column)} = ${bind(request.eq[position])}`),
4521
- ...request.lower ? [compare2(bind, order, request.lower, ">")] : [],
4522
- ...request.upper ? [compare2(bind, order, request.upper, "<")] : []
4521
+ ...request.lower ? [compare2(bind, order2, request.lower, ">")] : [],
4522
+ ...request.upper ? [compare2(bind, order2, request.upper, "<")] : []
4523
4523
  ];
4524
- return `SELECT ${multi ? "b" : "i"}.* FROM ${source}${conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : ""} ORDER BY ${order.map((column) => `i.${quote(column)} ${direction}`).join(", ")} LIMIT ${request.limit}`;
4524
+ 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}`;
4525
4525
  });
4526
4526
  return read(table, statement);
4527
4527
  },
@@ -4587,7 +4587,7 @@ var createSqlAdapter = /* @__PURE__ */ __name(({ executor, tablePrefix = "", max
4587
4587
  }, "createSqlAdapter");
4588
4588
 
4589
4589
  // ../../packages/server/dist/package.mjs
4590
- var version = "1.1.21";
4590
+ var version = "1.1.22";
4591
4591
 
4592
4592
  // ../../packages/server/dist/version.mjs
4593
4593
  var HOT_UPDATER_SERVER_VERSION = version;
@@ -6466,14 +6466,14 @@ var LIMITS = {
6466
6466
  maxValue: 500
6467
6467
  };
6468
6468
  var keyset = /* @__PURE__ */ __name((url, maxValue = LIMITS.maxValue) => {
6469
- const order = url.searchParams.get("order") ?? "desc";
6470
- if (order !== "asc" && order !== "desc") throw new HandlerBadRequestError("order must be 'asc' or 'desc'.");
6469
+ const order2 = url.searchParams.get("order") ?? "desc";
6470
+ if (order2 !== "asc" && order2 !== "desc") throw new HandlerBadRequestError("order must be 'asc' or 'desc'.");
6471
6471
  const limitParam = url.searchParams.get("limit");
6472
6472
  const limit = limitParam === null ? Math.min(LIMITS.defaultValue, maxValue) : Number(limitParam);
6473
6473
  if (!Number.isSafeInteger(limit) || limit < 1 || limit > maxValue) throw new HandlerBadRequestError(`limit must be between 1 and ${maxValue}.`);
6474
6474
  const cursor = url.searchParams.get("cursor");
6475
6475
  return {
6476
- order,
6476
+ order: order2,
6477
6477
  limit,
6478
6478
  ...cursor === null ? {} : { after: cursor }
6479
6479
  };
@@ -11031,163 +11031,119 @@ var remoteConfig = /* @__PURE__ */ __name(() => {
11031
11031
  // worker/src/index.ts
11032
11032
  import { env } from "cloudflare:workers";
11033
11033
 
11034
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/compose.js
11035
- var compose = /* @__PURE__ */ __name((middleware, onError, onNotFound) => {
11036
- return (context, next) => {
11037
- let index = -1;
11038
- return dispatch(0);
11039
- async function dispatch(i) {
11040
- if (i <= index) {
11041
- throw new Error("next() called multiple times");
11042
- }
11043
- index = i;
11044
- let res;
11045
- let isError = false;
11046
- let handler;
11047
- if (middleware[i]) {
11048
- handler = middleware[i][0][0];
11049
- context.req.routeIndex = i;
11050
- } else {
11051
- handler = i === middleware.length && next || void 0;
11052
- }
11053
- if (handler) {
11054
- try {
11055
- res = await handler(context, () => dispatch(i + 1));
11056
- } catch (err) {
11057
- if (err instanceof Error && onError) {
11058
- context.error = err;
11059
- res = await onError(err, context);
11060
- isError = true;
11061
- } else {
11062
- throw err;
11063
- }
11064
- }
11065
- } else {
11066
- if (context.finalized === false && onNotFound) {
11067
- res = await onNotFound(context);
11068
- }
11069
- }
11070
- if (res && (context.finalized === false || isError)) {
11071
- context.res = res;
11072
- }
11073
- return context;
11074
- }
11075
- __name(dispatch, "dispatch");
11076
- };
11077
- }, "compose");
11034
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/http-exception.js
11035
+ var HTTPException = class extends Error {
11036
+ static {
11037
+ __name(this, "HTTPException");
11038
+ }
11039
+ res;
11040
+ status;
11041
+ /**
11042
+ * Creates an instance of `HTTPException`.
11043
+ * @param status - HTTP status code for the exception. Defaults to 500.
11044
+ * @param options - Additional options for the exception.
11045
+ */
11046
+ constructor(status = 500, options) {
11047
+ super(options?.message, { cause: options?.cause });
11048
+ this.res = options?.res;
11049
+ this.status = status;
11050
+ }
11051
+ /**
11052
+ * Returns the response object associated with the exception.
11053
+ * If a response object is not provided, a new response is created with the error message and status code.
11054
+ * @returns The response object.
11055
+ */
11056
+ getResponse() {
11057
+ if (this.res) return new Response(this.res.body, {
11058
+ status: this.status,
11059
+ headers: this.res.headers
11060
+ });
11061
+ return new Response(this.message, { status: this.status });
11062
+ }
11063
+ };
11078
11064
 
11079
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/request/constants.js
11065
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/request/constants.js
11080
11066
  var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
11081
11067
 
11082
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/buffer.js
11068
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/buffer.js
11083
11069
  var bufferToFormData = /* @__PURE__ */ __name((arrayBuffer, contentType) => {
11084
- const response = new Response(arrayBuffer, {
11085
- headers: {
11086
- // Normalize the media type (case-insensitive) while keeping parameters like the boundary
11087
- "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
11088
- }
11089
- });
11090
- return response.formData();
11070
+ return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
11091
11071
  }, "bufferToFormData");
11092
11072
 
11093
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/body.js
11073
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/body.js
11074
+ var MAX_NESTED_OBJECTS = 1e4;
11094
11075
  var isRawRequest = /* @__PURE__ */ __name((request) => "headers" in request, "isRawRequest");
11095
11076
  var parseBody = /* @__PURE__ */ __name(async (request, options = /* @__PURE__ */ Object.create(null)) => {
11096
11077
  const { all = false, dot = false } = options;
11097
- const headers = isRawRequest(request) ? request.headers : request.raw.headers;
11098
- const contentType = headers.get("Content-Type");
11099
- const mediaType = contentType?.split(";")[0].trim().toLowerCase();
11100
- if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") {
11101
- return parseFormData(request, { all, dot });
11102
- }
11078
+ const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
11079
+ if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
11080
+ all,
11081
+ dot
11082
+ });
11103
11083
  return {};
11104
11084
  }, "parseBody");
11105
11085
  async function parseFormData(request, options) {
11106
- if (!isRawRequest(request) && request.bodyCache.formData) {
11107
- return convertFormDataToBodyData(
11108
- await request.bodyCache.formData,
11109
- options
11110
- );
11111
- }
11086
+ if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
11112
11087
  const headers = isRawRequest(request) ? request.headers : request.raw.headers;
11113
11088
  const arrayBuffer = await request.arrayBuffer();
11114
11089
  const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
11115
- if (!isRawRequest(request)) {
11116
- request.bodyCache.formData = formDataPromise;
11117
- }
11090
+ if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
11118
11091
  const formData = await formDataPromise;
11119
- if (formData) {
11120
- return convertFormDataToBodyData(formData, options);
11121
- }
11092
+ if (formData) return convertFormDataToBodyData(formData, options);
11122
11093
  return {};
11123
11094
  }
11124
11095
  __name(parseFormData, "parseFormData");
11125
11096
  function convertFormDataToBodyData(formData, options) {
11126
11097
  const form = /* @__PURE__ */ Object.create(null);
11098
+ const nestingState = { count: 0 };
11127
11099
  formData.forEach((value, key) => {
11128
- const shouldParseAllValues = options.all || key.endsWith("[]");
11129
- if (!shouldParseAllValues) {
11130
- form[key] = value;
11131
- } else {
11132
- handleParsingAllValues(form, key, value);
11100
+ if (!(options.all || key.endsWith("[]"))) form[key] = value;
11101
+ else handleParsingAllValues(form, key, value);
11102
+ });
11103
+ if (options.dot) Object.entries(form).forEach(([key, value]) => {
11104
+ if (key.includes(".")) {
11105
+ handleParsingNestedValues(form, key, value, nestingState);
11106
+ delete form[key];
11133
11107
  }
11134
11108
  });
11135
- if (options.dot) {
11136
- Object.entries(form).forEach(([key, value]) => {
11137
- const shouldParseDotValues = key.includes(".");
11138
- if (shouldParseDotValues) {
11139
- handleParsingNestedValues(form, key, value);
11140
- delete form[key];
11141
- }
11142
- });
11143
- }
11144
11109
  return form;
11145
11110
  }
11146
11111
  __name(convertFormDataToBodyData, "convertFormDataToBodyData");
11147
11112
  var handleParsingAllValues = /* @__PURE__ */ __name((form, key, value) => {
11148
11113
  if (form[key] !== void 0) {
11149
- if (Array.isArray(form[key])) {
11150
- ;
11151
- form[key].push(value);
11152
- } else {
11153
- form[key] = [form[key], value];
11154
- }
11155
- } else {
11156
- if (!key.endsWith("[]")) {
11157
- form[key] = value;
11158
- } else {
11159
- form[key] = [value];
11160
- }
11161
- }
11114
+ if (Array.isArray(form[key])) form[key].push(value);
11115
+ else form[key] = [form[key], value];
11116
+ } else if (!key.endsWith("[]")) form[key] = value;
11117
+ else form[key] = [value];
11162
11118
  }, "handleParsingAllValues");
11163
- var handleParsingNestedValues = /* @__PURE__ */ __name((form, key, value) => {
11164
- if (/(?:^|\.)__proto__\./.test(key)) {
11165
- return;
11166
- }
11119
+ var handleParsingNestedValues = /* @__PURE__ */ __name((form, key, value, state) => {
11120
+ if (/(?:^|\.)__proto__\./.test(key)) return;
11167
11121
  let nestedForm = form;
11168
- const keys = key.split(".");
11122
+ const keys = key.split(".", 34);
11123
+ if (keys.length > 33) throwNestingLimitExceeded();
11169
11124
  keys.forEach((key2, index) => {
11170
- if (index === keys.length - 1) {
11171
- nestedForm[key2] = value;
11172
- } else {
11125
+ if (index === keys.length - 1) nestedForm[key2] = value;
11126
+ else {
11173
11127
  if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
11128
+ if (state.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
11174
11129
  nestedForm[key2] = /* @__PURE__ */ Object.create(null);
11175
11130
  }
11176
11131
  nestedForm = nestedForm[key2];
11177
11132
  }
11178
11133
  });
11179
11134
  }, "handleParsingNestedValues");
11135
+ var throwNestingLimitExceeded = /* @__PURE__ */ __name(() => {
11136
+ throw new Error("Nesting limit exceeded");
11137
+ }, "throwNestingLimitExceeded");
11180
11138
 
11181
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/url.js
11139
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/url.js
11182
11140
  var splitPath = /* @__PURE__ */ __name((path) => {
11183
11141
  const paths = path.split("/");
11184
- if (paths[0] === "") {
11185
- paths.shift();
11186
- }
11142
+ if (paths[0] === "") paths.shift();
11187
11143
  return paths;
11188
11144
  }, "splitPath");
11189
- var splitRoutingPath = /* @__PURE__ */ __name((routePath) => {
11190
- const { groups, path } = extractGroupsFromPath(routePath);
11145
+ var splitRoutingPath = /* @__PURE__ */ __name((routePath2) => {
11146
+ const { groups, path } = extractGroupsFromPath(routePath2);
11191
11147
  const paths = splitPath(path);
11192
11148
  return replaceGroupMarks(paths, groups);
11193
11149
  }, "splitRoutingPath");
@@ -11198,34 +11154,42 @@ var extractGroupsFromPath = /* @__PURE__ */ __name((path) => {
11198
11154
  groups.push([mark, match2]);
11199
11155
  return mark;
11200
11156
  });
11201
- return { groups, path };
11157
+ return {
11158
+ groups,
11159
+ path
11160
+ };
11202
11161
  }, "extractGroupsFromPath");
11203
11162
  var replaceGroupMarks = /* @__PURE__ */ __name((paths, groups) => {
11204
11163
  for (let i = groups.length - 1; i >= 0; i--) {
11205
11164
  const [mark] = groups[i];
11206
- for (let j = paths.length - 1; j >= 0; j--) {
11207
- if (paths[j].includes(mark)) {
11208
- paths[j] = paths[j].replace(mark, groups[i][1]);
11209
- break;
11210
- }
11165
+ for (let j = paths.length - 1; j >= 0; j--) if (paths[j].includes(mark)) {
11166
+ paths[j] = paths[j].replace(mark, groups[i][1]);
11167
+ break;
11211
11168
  }
11212
11169
  }
11213
11170
  return paths;
11214
11171
  }, "replaceGroupMarks");
11215
11172
  var patternCache = {};
11216
11173
  var getPattern = /* @__PURE__ */ __name((label, next) => {
11217
- if (label === "*") {
11218
- return "*";
11219
- }
11174
+ if (label === "*") return "*";
11220
11175
  const match2 = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
11221
11176
  if (match2) {
11222
11177
  const cacheKey = `${label}#${next}`;
11223
11178
  if (!patternCache[cacheKey]) {
11224
- if (match2[2]) {
11225
- patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [cacheKey, match2[1], new RegExp(`^${match2[2]}(?=/${next})`)] : [label, match2[1], new RegExp(`^${match2[2]}$`)];
11226
- } else {
11227
- patternCache[cacheKey] = [label, match2[1], true];
11228
- }
11179
+ if (match2[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
11180
+ cacheKey,
11181
+ match2[1],
11182
+ new RegExp(`^${match2[2]}(?=/${next})`)
11183
+ ] : [
11184
+ label,
11185
+ match2[1],
11186
+ new RegExp(`^${match2[2]}$`)
11187
+ ];
11188
+ else patternCache[cacheKey] = [
11189
+ label,
11190
+ match2[1],
11191
+ true
11192
+ ];
11229
11193
  }
11230
11194
  return patternCache[cacheKey];
11231
11195
  }
@@ -11244,7 +11208,7 @@ var tryDecode = /* @__PURE__ */ __name((str, decoder2) => {
11244
11208
  });
11245
11209
  }
11246
11210
  }, "tryDecode");
11247
- var tryDecodeURI = /* @__PURE__ */ __name((str) => tryDecode(str, decodeURI), "tryDecodeURI");
11211
+ var decodeURIWithPreservedPercent = /* @__PURE__ */ __name((value) => decodeURI(value.includes("%25") ? value.replace(/%25/g, "%2525") : value), "decodeURIWithPreservedPercent");
11248
11212
  var getPath = /* @__PURE__ */ __name((request) => {
11249
11213
  const url = request.url;
11250
11214
  const start = url.indexOf("/", url.indexOf(":") + 4);
@@ -11256,10 +11220,14 @@ var getPath = /* @__PURE__ */ __name((request) => {
11256
11220
  const hashIndex = url.indexOf("#", i);
11257
11221
  const end = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
11258
11222
  const path = url.slice(start, end);
11259
- return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
11260
- } else if (charCode === 63 || charCode === 35) {
11261
- break;
11262
- }
11223
+ const decoded = tryDecode(path, decodeURIWithPreservedPercent);
11224
+ if (/%(?![0-9A-Fa-f]{2})/.test(path)) {
11225
+ const rewritten = new URL("http://localhost");
11226
+ rewritten.pathname = decoded.replace(/[\\\t\n\r]/g, encodeURIComponent);
11227
+ if (tryDecode(rewritten.pathname, decodeURIWithPreservedPercent) !== decoded) return tryDecode(path.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"), decodeURIWithPreservedPercent);
11228
+ }
11229
+ return decoded;
11230
+ } else if (charCode === 63 || charCode === 35) break;
11263
11231
  }
11264
11232
  return url.slice(start, i);
11265
11233
  }, "getPath");
@@ -11268,72 +11236,57 @@ var getPathNoStrict = /* @__PURE__ */ __name((request) => {
11268
11236
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
11269
11237
  }, "getPathNoStrict");
11270
11238
  var mergePath = /* @__PURE__ */ __name((base, sub, ...rest) => {
11271
- if (rest.length) {
11272
- sub = mergePath(sub, ...rest);
11273
- }
11239
+ if (rest.length) sub = mergePath(sub, ...rest);
11274
11240
  return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
11275
11241
  }, "mergePath");
11276
11242
  var checkOptionalParameter = /* @__PURE__ */ __name((path) => {
11277
- if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) {
11278
- return null;
11279
- }
11243
+ if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
11280
11244
  const segments = path.split("/");
11281
11245
  const results = [];
11282
11246
  let basePath = "";
11283
11247
  segments.forEach((segment) => {
11284
- if (segment !== "" && !/\:/.test(segment)) {
11285
- basePath += "/" + segment;
11286
- } else if (/\:/.test(segment)) {
11287
- if (/\?/.test(segment)) {
11288
- if (results.length === 0 && basePath === "") {
11289
- results.push("/");
11290
- } else {
11291
- results.push(basePath);
11292
- }
11293
- const optionalSegment = segment.replace("?", "");
11248
+ if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
11249
+ else if (/\:/.test(segment)) {
11250
+ if (segment.charCodeAt(segment.length - 1) === 63) {
11251
+ if (results.length === 0 && basePath === "") results.push("/");
11252
+ else results.push(basePath);
11253
+ const optionalSegment = segment.slice(0, -1);
11294
11254
  basePath += "/" + optionalSegment;
11295
11255
  results.push(basePath);
11296
- } else {
11297
- basePath += "/" + segment;
11298
- }
11256
+ } else basePath += "/" + segment;
11299
11257
  }
11300
11258
  });
11301
11259
  return results.filter((v, i, a) => a.indexOf(v) === i);
11302
11260
  }, "checkOptionalParameter");
11261
+ var tryDecodeURIComponent = /* @__PURE__ */ __name((str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str, "tryDecodeURIComponent");
11303
11262
  var _decodeURI = /* @__PURE__ */ __name((value) => {
11304
- if (!/[%+]/.test(value)) {
11305
- return value;
11306
- }
11307
- if (value.indexOf("+") !== -1) {
11308
- value = value.replace(/\+/g, " ");
11309
- }
11310
- return value.indexOf("%") !== -1 ? tryDecode(value, decodeURIComponent_) : value;
11263
+ if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
11264
+ return tryDecodeURIComponent(value);
11311
11265
  }, "_decodeURI");
11312
11266
  var _getQueryParam = /* @__PURE__ */ __name((url, key, multiple) => {
11267
+ const hashIndex = url.indexOf("#", 8);
11268
+ if (hashIndex !== -1) url = url.slice(0, hashIndex);
11313
11269
  let encoded;
11314
- if (!multiple && key && !/[%+]/.test(key)) {
11315
- let keyIndex2 = url.indexOf("?", 8);
11316
- if (keyIndex2 === -1) {
11317
- return void 0;
11318
- }
11319
- if (!url.startsWith(key, keyIndex2 + 1)) {
11320
- keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
11321
- }
11270
+ if (!multiple && key && !/[%+&=]/.test(key)) {
11271
+ const queryIndex = url.indexOf("?", 8);
11272
+ let keyIndex2 = queryIndex;
11273
+ if (keyIndex2 === -1) return;
11274
+ if (!url.startsWith(key, keyIndex2 + 1)) keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
11322
11275
  while (keyIndex2 !== -1) {
11323
11276
  const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
11324
- if (trailingKeyCode === 61) {
11325
- const valueIndex = keyIndex2 + key.length + 2;
11326
- const endIndex = url.indexOf("&", valueIndex);
11327
- return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
11328
- } else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) {
11277
+ if (trailingKeyCode === 61 || trailingKeyCode === 38 || isNaN(trailingKeyCode)) {
11278
+ if (keyIndex2 > queryIndex && /(?:^|&)[^=&]*[%+]/.test(url.slice(queryIndex + 1, keyIndex2))) break;
11279
+ if (trailingKeyCode === 61) {
11280
+ const valueIndex = keyIndex2 + key.length + 2;
11281
+ const endIndex = url.indexOf("&", valueIndex);
11282
+ return _decodeURI(url.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
11283
+ }
11329
11284
  return "";
11330
11285
  }
11331
11286
  keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
11332
11287
  }
11333
11288
  encoded = /[%+]/.test(url);
11334
- if (!encoded) {
11335
- return void 0;
11336
- }
11289
+ if (!encoded) return;
11337
11290
  }
11338
11291
  const results = /* @__PURE__ */ Object.create(null);
11339
11292
  encoded ??= /[%+]/.test(url);
@@ -11341,38 +11294,21 @@ var _getQueryParam = /* @__PURE__ */ __name((url, key, multiple) => {
11341
11294
  while (keyIndex !== -1) {
11342
11295
  const nextKeyIndex = url.indexOf("&", keyIndex + 1);
11343
11296
  let valueIndex = url.indexOf("=", keyIndex);
11344
- if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) {
11345
- valueIndex = -1;
11346
- }
11347
- let name = url.slice(
11348
- keyIndex + 1,
11349
- valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex
11350
- );
11351
- if (encoded) {
11352
- name = _decodeURI(name);
11353
- }
11297
+ if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
11298
+ let name = url.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
11299
+ if (encoded) name = _decodeURI(name);
11354
11300
  keyIndex = nextKeyIndex;
11355
- if (name === "") {
11356
- continue;
11357
- }
11301
+ if (name === "") continue;
11358
11302
  let value;
11359
- if (valueIndex === -1) {
11360
- value = "";
11361
- } else {
11303
+ if (valueIndex === -1) value = "";
11304
+ else {
11362
11305
  value = url.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
11363
- if (encoded) {
11364
- value = _decodeURI(value);
11365
- }
11306
+ if (encoded) value = _decodeURI(value);
11366
11307
  }
11367
11308
  if (multiple) {
11368
- if (!(results[name] && Array.isArray(results[name]))) {
11369
- results[name] = [];
11370
- }
11371
- ;
11309
+ if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
11372
11310
  results[name].push(value);
11373
- } else {
11374
- results[name] ??= value;
11375
- }
11311
+ } else results[name] ??= value;
11376
11312
  }
11377
11313
  return key ? results[key] : results;
11378
11314
  }, "_getQueryParam");
@@ -11382,67 +11318,62 @@ var getQueryParams = /* @__PURE__ */ __name((url, key) => {
11382
11318
  }, "getQueryParams");
11383
11319
  var decodeURIComponent_ = decodeURIComponent;
11384
11320
 
11385
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/request.js
11386
- var tryDecodeURIComponent = /* @__PURE__ */ __name((str) => tryDecode(str, decodeURIComponent_), "tryDecodeURIComponent");
11321
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/request.js
11387
11322
  var HonoRequest = class {
11388
11323
  static {
11389
11324
  __name(this, "HonoRequest");
11390
11325
  }
11391
11326
  /**
11392
- * `.raw` can get the raw Request object.
11393
- *
11394
- * @see {@link https://hono.dev/docs/api/request#raw}
11395
- *
11396
- * @example
11397
- * ```ts
11398
- * // For Cloudflare Workers
11399
- * app.post('/', async (c) => {
11400
- * const metadata = c.req.raw.cf?.hostMetadata?
11401
- * ...
11402
- * })
11403
- * ```
11404
- */
11327
+ * `.raw` can get the raw Request object.
11328
+ *
11329
+ * @see {@link https://hono.dev/docs/api/request#raw}
11330
+ *
11331
+ * @example
11332
+ * ```ts
11333
+ * // For Cloudflare Workers
11334
+ * app.post('/', async (c) => {
11335
+ * const metadata = c.req.raw.cf?.hostMetadata?
11336
+ * ...
11337
+ * })
11338
+ * ```
11339
+ */
11405
11340
  raw;
11406
11341
  #validatedData;
11407
- // Short name of validatedData
11408
11342
  #matchResult;
11409
11343
  routeIndex = 0;
11410
11344
  /**
11411
- * `.path` can get the pathname of the request.
11412
- *
11413
- * @see {@link https://hono.dev/docs/api/request#path}
11414
- *
11415
- * @example
11416
- * ```ts
11417
- * app.get('/about/me', (c) => {
11418
- * const pathname = c.req.path // `/about/me`
11419
- * })
11420
- * ```
11421
- */
11345
+ * `.path` can get the pathname of the request.
11346
+ *
11347
+ * @see {@link https://hono.dev/docs/api/request#path}
11348
+ *
11349
+ * @example
11350
+ * ```ts
11351
+ * app.get('/about/me', (c) => {
11352
+ * const pathname = c.req.path // `/about/me`
11353
+ * })
11354
+ * ```
11355
+ */
11422
11356
  path;
11423
11357
  bodyCache = {};
11424
11358
  constructor(request, path = "/", matchResult = [[]]) {
11425
11359
  this.raw = request;
11426
11360
  this.path = path;
11427
11361
  this.#matchResult = matchResult;
11428
- this.#validatedData = {};
11429
11362
  }
11430
11363
  param(key) {
11431
11364
  return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
11432
11365
  }
11433
11366
  #getDecodedParam(key) {
11434
- const paramKey = this.#matchResult[0][this.routeIndex][1][key];
11367
+ const paramKey = this.#matchResult[0][this.routeIndex]?.[1][key];
11435
11368
  const param = this.#getParamValue(paramKey);
11436
- return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
11369
+ return param && tryDecodeURIComponent(param);
11437
11370
  }
11438
11371
  #getAllDecodedParams() {
11439
11372
  const decoded = {};
11440
- const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
11373
+ const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
11441
11374
  for (const key of keys) {
11442
11375
  const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
11443
- if (value !== void 0) {
11444
- decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
11445
- }
11376
+ if (value !== void 0) decoded[key] = tryDecodeURIComponent(value);
11446
11377
  }
11447
11378
  return decoded;
11448
11379
  }
@@ -11456,9 +11387,7 @@ var HonoRequest = class {
11456
11387
  return getQueryParams(this.url, key);
11457
11388
  }
11458
11389
  header(name) {
11459
- if (name) {
11460
- return this.raw.headers.get(name) ?? void 0;
11461
- }
11390
+ if (name) return this.raw.headers.get(name) ?? void 0;
11462
11391
  const headerData = /* @__PURE__ */ Object.create(null);
11463
11392
  this.raw.headers.forEach((value, key) => {
11464
11393
  headerData[key] = value;
@@ -11471,146 +11400,140 @@ var HonoRequest = class {
11471
11400
  #cachedBody = /* @__PURE__ */ __name((key) => {
11472
11401
  const { bodyCache, raw: raw2 } = this;
11473
11402
  const cachedBody = bodyCache[key];
11474
- if (cachedBody) {
11475
- return cachedBody;
11476
- }
11477
- const anyCachedKey = Object.keys(bodyCache)[0];
11478
- if (anyCachedKey) {
11479
- return bodyCache[anyCachedKey].then((body2) => {
11480
- if (anyCachedKey === "json") {
11481
- body2 = JSON.stringify(body2);
11482
- }
11483
- return new Response(body2)[key]();
11484
- });
11485
- }
11403
+ if (cachedBody) return cachedBody;
11404
+ for (const anyCachedKey in bodyCache) return bodyCache[anyCachedKey].then((body2) => {
11405
+ if (anyCachedKey === "json") body2 = JSON.stringify(body2);
11406
+ const contentType = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
11407
+ return new Response(body2, { headers: contentType ? { "Content-Type": contentType } : void 0 })[key]();
11408
+ });
11486
11409
  return bodyCache[key] = raw2[key]();
11487
11410
  }, "#cachedBody");
11488
11411
  /**
11489
- * `.json()` can parse Request body of type `application/json`
11490
- *
11491
- * @see {@link https://hono.dev/docs/api/request#json}
11492
- *
11493
- * @example
11494
- * ```ts
11495
- * app.post('/entry', async (c) => {
11496
- * const body = await c.req.json()
11497
- * })
11498
- * ```
11499
- */
11412
+ * `.json()` can parse Request body of type `application/json`
11413
+ *
11414
+ * @see {@link https://hono.dev/docs/api/request#json}
11415
+ *
11416
+ * @example
11417
+ * ```ts
11418
+ * app.post('/entry', async (c) => {
11419
+ * const body = await c.req.json()
11420
+ * })
11421
+ * ```
11422
+ */
11500
11423
  json() {
11501
11424
  return this.#cachedBody("text").then((text) => JSON.parse(text));
11502
11425
  }
11503
11426
  /**
11504
- * `.text()` can parse Request body of type `text/plain`
11505
- *
11506
- * @see {@link https://hono.dev/docs/api/request#text}
11507
- *
11508
- * @example
11509
- * ```ts
11510
- * app.post('/entry', async (c) => {
11511
- * const body = await c.req.text()
11512
- * })
11513
- * ```
11514
- */
11427
+ * `.text()` can parse Request body of type `text/plain`
11428
+ *
11429
+ * @see {@link https://hono.dev/docs/api/request#text}
11430
+ *
11431
+ * @example
11432
+ * ```ts
11433
+ * app.post('/entry', async (c) => {
11434
+ * const body = await c.req.text()
11435
+ * })
11436
+ * ```
11437
+ */
11515
11438
  text() {
11516
11439
  return this.#cachedBody("text");
11517
11440
  }
11518
11441
  /**
11519
- * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
11520
- *
11521
- * @see {@link https://hono.dev/docs/api/request#arraybuffer}
11522
- *
11523
- * @example
11524
- * ```ts
11525
- * app.post('/entry', async (c) => {
11526
- * const body = await c.req.arrayBuffer()
11527
- * })
11528
- * ```
11529
- */
11442
+ * `.arrayBuffer()` parse Request body as an `ArrayBuffer`
11443
+ *
11444
+ * @see {@link https://hono.dev/docs/api/request#arraybuffer}
11445
+ *
11446
+ * @example
11447
+ * ```ts
11448
+ * app.post('/entry', async (c) => {
11449
+ * const body = await c.req.arrayBuffer()
11450
+ * })
11451
+ * ```
11452
+ */
11530
11453
  arrayBuffer() {
11531
11454
  return this.#cachedBody("arrayBuffer");
11532
11455
  }
11533
11456
  /**
11534
- * `.bytes()` parses the request body as a `Uint8Array`.
11535
- *
11536
- * @see {@link https://hono.dev/docs/api/request#bytes}
11537
- *
11538
- * @example
11539
- * ```ts
11540
- * app.post('/entry', async (c) => {
11541
- * const body = await c.req.bytes()
11542
- * })
11543
- * ```
11544
- */
11457
+ * `.bytes()` parses the request body as a `Uint8Array`.
11458
+ *
11459
+ * @see {@link https://hono.dev/docs/api/request#bytes}
11460
+ *
11461
+ * @example
11462
+ * ```ts
11463
+ * app.post('/entry', async (c) => {
11464
+ * const body = await c.req.bytes()
11465
+ * })
11466
+ * ```
11467
+ */
11545
11468
  bytes() {
11546
11469
  return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
11547
11470
  }
11548
11471
  /**
11549
- * Parses the request body as a `Blob`.
11550
- * @example
11551
- * ```ts
11552
- * app.post('/entry', async (c) => {
11553
- * const body = await c.req.blob();
11554
- * });
11555
- * ```
11556
- * @see https://hono.dev/docs/api/request#blob
11557
- */
11472
+ * Parses the request body as a `Blob`.
11473
+ * @example
11474
+ * ```ts
11475
+ * app.post('/entry', async (c) => {
11476
+ * const body = await c.req.blob();
11477
+ * });
11478
+ * ```
11479
+ * @see https://hono.dev/docs/api/request#blob
11480
+ */
11558
11481
  blob() {
11559
11482
  return this.#cachedBody("blob");
11560
11483
  }
11561
11484
  /**
11562
- * Parses the request body as `FormData`.
11563
- * @example
11564
- * ```ts
11565
- * app.post('/entry', async (c) => {
11566
- * const body = await c.req.formData();
11567
- * });
11568
- * ```
11569
- * @see https://hono.dev/docs/api/request#formdata
11570
- */
11485
+ * Parses the request body as `FormData`.
11486
+ * @example
11487
+ * ```ts
11488
+ * app.post('/entry', async (c) => {
11489
+ * const body = await c.req.formData();
11490
+ * });
11491
+ * ```
11492
+ * @see https://hono.dev/docs/api/request#formdata
11493
+ */
11571
11494
  formData() {
11572
11495
  return this.#cachedBody("formData");
11573
11496
  }
11574
11497
  /**
11575
- * Adds validated data to the request.
11576
- *
11577
- * @param target - The target of the validation.
11578
- * @param data - The validated data to add.
11579
- */
11498
+ * Adds validated data to the request.
11499
+ *
11500
+ * @param target - The target of the validation.
11501
+ * @param data - The validated data to add.
11502
+ */
11580
11503
  addValidatedData(target, data) {
11581
- this.#validatedData[target] = data;
11504
+ (this.#validatedData ??= {})[target] = data;
11582
11505
  }
11583
11506
  valid(target) {
11584
- return this.#validatedData[target];
11507
+ return this.#validatedData?.[target];
11585
11508
  }
11586
11509
  /**
11587
- * `.url()` can get the request url strings.
11588
- *
11589
- * @see {@link https://hono.dev/docs/api/request#url}
11590
- *
11591
- * @example
11592
- * ```ts
11593
- * app.get('/about/me', (c) => {
11594
- * const url = c.req.url // `http://localhost:8787/about/me`
11595
- * ...
11596
- * })
11597
- * ```
11598
- */
11510
+ * `.url` can get the request url strings.
11511
+ *
11512
+ * @see {@link https://hono.dev/docs/api/request#url}
11513
+ *
11514
+ * @example
11515
+ * ```ts
11516
+ * app.get('/about/me', (c) => {
11517
+ * const url = c.req.url // `http://localhost:8787/about/me`
11518
+ * ...
11519
+ * })
11520
+ * ```
11521
+ */
11599
11522
  get url() {
11600
11523
  return this.raw.url;
11601
11524
  }
11602
11525
  /**
11603
- * `.method()` can get the method name of the request.
11604
- *
11605
- * @see {@link https://hono.dev/docs/api/request#method}
11606
- *
11607
- * @example
11608
- * ```ts
11609
- * app.get('/about/me', (c) => {
11610
- * const method = c.req.method // `GET`
11611
- * })
11612
- * ```
11613
- */
11526
+ * `.method` can get the method name of the request.
11527
+ *
11528
+ * @see {@link https://hono.dev/docs/api/request#method}
11529
+ *
11530
+ * @example
11531
+ * ```ts
11532
+ * app.get('/about/me', (c) => {
11533
+ * const method = c.req.method // `GET`
11534
+ * })
11535
+ * ```
11536
+ */
11614
11537
  get method() {
11615
11538
  return this.raw.method;
11616
11539
  }
@@ -11618,57 +11541,57 @@ var HonoRequest = class {
11618
11541
  return this.#matchResult;
11619
11542
  }
11620
11543
  /**
11621
- * `.matchedRoutes()` can return a matched route in the handler
11622
- *
11623
- * @deprecated
11624
- *
11625
- * Use matchedRoutes helper defined in "hono/route" instead.
11626
- *
11627
- * @see {@link https://hono.dev/docs/api/request#matchedroutes}
11628
- *
11629
- * @example
11630
- * ```ts
11631
- * app.use('*', async function logger(c, next) {
11632
- * await next()
11633
- * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
11634
- * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
11635
- * console.log(
11636
- * method,
11637
- * ' ',
11638
- * path,
11639
- * ' '.repeat(Math.max(10 - path.length, 0)),
11640
- * name,
11641
- * i === c.req.routeIndex ? '<- respond from here' : ''
11642
- * )
11643
- * })
11644
- * })
11645
- * ```
11646
- */
11544
+ * `.matchedRoutes` can return a matched route in the handler
11545
+ *
11546
+ * @deprecated
11547
+ *
11548
+ * Use matchedRoutes helper defined in "hono/route" instead.
11549
+ *
11550
+ * @see {@link https://hono.dev/docs/api/request#matchedroutes}
11551
+ *
11552
+ * @example
11553
+ * ```ts
11554
+ * app.use('*', async function logger(c, next) {
11555
+ * await next()
11556
+ * c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
11557
+ * const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
11558
+ * console.log(
11559
+ * method,
11560
+ * ' ',
11561
+ * path,
11562
+ * ' '.repeat(Math.max(10 - path.length, 0)),
11563
+ * name,
11564
+ * i === c.req.routeIndex ? '<- respond from here' : ''
11565
+ * )
11566
+ * })
11567
+ * })
11568
+ * ```
11569
+ */
11647
11570
  get matchedRoutes() {
11648
11571
  return this.#matchResult[0].map(([[, route]]) => route);
11649
11572
  }
11650
11573
  /**
11651
- * `routePath()` can retrieve the path registered within the handler
11652
- *
11653
- * @deprecated
11654
- *
11655
- * Use routePath helper defined in "hono/route" instead.
11656
- *
11657
- * @see {@link https://hono.dev/docs/api/request#routepath}
11658
- *
11659
- * @example
11660
- * ```ts
11661
- * app.get('/posts/:id', (c) => {
11662
- * return c.json({ path: c.req.routePath })
11663
- * })
11664
- * ```
11665
- */
11574
+ * `.routePath` can retrieve the path registered within the handler
11575
+ *
11576
+ * @deprecated
11577
+ *
11578
+ * Use routePath helper defined in "hono/route" instead.
11579
+ *
11580
+ * @see {@link https://hono.dev/docs/api/request#routepath}
11581
+ *
11582
+ * @example
11583
+ * ```ts
11584
+ * app.get('/posts/:id', (c) => {
11585
+ * return c.json({ path: c.req.routePath })
11586
+ * })
11587
+ * ```
11588
+ */
11666
11589
  get routePath() {
11667
11590
  return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
11668
11591
  }
11669
11592
  };
11670
11593
 
11671
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/html.js
11594
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/html.js
11672
11595
  var HtmlEscapedCallbackPhase = {
11673
11596
  Stringify: 1,
11674
11597
  BeforeStream: 2,
@@ -11682,35 +11605,23 @@ var raw = /* @__PURE__ */ __name((value, callbacks) => {
11682
11605
  }, "raw");
11683
11606
  var resolveCallback = /* @__PURE__ */ __name(async (str, phase, preserveCallbacks, context, buffer) => {
11684
11607
  if (typeof str === "object" && !(str instanceof String)) {
11685
- if (!(str instanceof Promise)) {
11686
- str = str.toString();
11687
- }
11688
- if (str instanceof Promise) {
11689
- str = await str;
11690
- }
11608
+ if (!(str instanceof Promise)) str = str.toString();
11609
+ if (str instanceof Promise) str = await str;
11691
11610
  }
11692
11611
  const callbacks = str.callbacks;
11693
- if (!callbacks?.length) {
11694
- return Promise.resolve(str);
11695
- }
11696
- if (buffer) {
11697
- buffer[0] += str;
11698
- } else {
11699
- buffer = [str];
11700
- }
11701
- const resStr = Promise.all(callbacks.map((c) => c({ phase, buffer, context }))).then(
11702
- (res) => Promise.all(
11703
- res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))
11704
- ).then(() => buffer[0])
11705
- );
11706
- if (preserveCallbacks) {
11707
- return raw(await resStr, callbacks);
11708
- } else {
11709
- return resStr;
11710
- }
11612
+ if (!callbacks?.length) return Promise.resolve(str);
11613
+ if (buffer) buffer[0] += str;
11614
+ else buffer = [str];
11615
+ const resStr = Promise.all(callbacks.map((c) => c({
11616
+ phase,
11617
+ buffer,
11618
+ context
11619
+ }))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
11620
+ if (preserveCallbacks) return raw(await resStr, callbacks);
11621
+ else return resStr;
11711
11622
  }, "resolveCallback");
11712
11623
 
11713
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/context.js
11624
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/context.js
11714
11625
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
11715
11626
  var setDefaultContentType = /* @__PURE__ */ __name((contentType, headers) => {
11716
11627
  return {
@@ -11726,36 +11637,36 @@ var Context = class {
11726
11637
  #rawRequest;
11727
11638
  #req;
11728
11639
  /**
11729
- * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
11730
- *
11731
- * @see {@link https://hono.dev/docs/api/context#env}
11732
- *
11733
- * @example
11734
- * ```ts
11735
- * // Environment object for Cloudflare Workers
11736
- * app.get('*', async c => {
11737
- * const counter = c.env.COUNTER
11738
- * })
11739
- * ```
11740
- */
11640
+ * `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
11641
+ *
11642
+ * @see {@link https://hono.dev/docs/api/context#env}
11643
+ *
11644
+ * @example
11645
+ * ```ts
11646
+ * // Environment object for Cloudflare Workers
11647
+ * app.get('*', async c => {
11648
+ * const counter = c.env.COUNTER
11649
+ * })
11650
+ * ```
11651
+ */
11741
11652
  env = {};
11742
11653
  #var;
11743
11654
  finalized = false;
11744
11655
  /**
11745
- * `.error` can get the error object from the middleware if the Handler throws an error.
11746
- *
11747
- * @see {@link https://hono.dev/docs/api/context#error}
11748
- *
11749
- * @example
11750
- * ```ts
11751
- * app.use('*', async (c, next) => {
11752
- * await next()
11753
- * if (c.error) {
11754
- * // do something...
11755
- * }
11756
- * })
11757
- * ```
11758
- */
11656
+ * `.error` can get the error object from the middleware if the Handler throws an error.
11657
+ *
11658
+ * @see {@link https://hono.dev/docs/api/context#error}
11659
+ *
11660
+ * @example
11661
+ * ```ts
11662
+ * app.use('*', async (c, next) => {
11663
+ * await next()
11664
+ * if (c.error) {
11665
+ * // do something...
11666
+ * }
11667
+ * })
11668
+ * ```
11669
+ */
11759
11670
  error;
11760
11671
  #status;
11761
11672
  #executionCtx;
@@ -11767,11 +11678,11 @@ var Context = class {
11767
11678
  #matchResult;
11768
11679
  #path;
11769
11680
  /**
11770
- * Creates an instance of the Context class.
11771
- *
11772
- * @param req - The Request object.
11773
- * @param options - Optional configuration options for the context.
11774
- */
11681
+ * Creates an instance of the Context class.
11682
+ *
11683
+ * @param req - The Request object.
11684
+ * @param options - Optional configuration options for the context.
11685
+ */
11775
11686
  constructor(req, options) {
11776
11687
  this.#rawRequest = req;
11777
11688
  if (options) {
@@ -11783,347 +11694,360 @@ var Context = class {
11783
11694
  }
11784
11695
  }
11785
11696
  /**
11786
- * `.req` is the instance of {@link HonoRequest}.
11787
- */
11697
+ * `.req` is the instance of {@link HonoRequest}.
11698
+ */
11788
11699
  get req() {
11789
11700
  this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
11790
11701
  return this.#req;
11791
11702
  }
11792
11703
  /**
11793
- * @see {@link https://hono.dev/docs/api/context#event}
11794
- * The FetchEvent associated with the current request.
11795
- *
11796
- * @throws Will throw an error if the context does not have a FetchEvent.
11797
- */
11704
+ * @see {@link https://hono.dev/docs/api/context#event}
11705
+ * The FetchEvent associated with the current request.
11706
+ *
11707
+ * @throws Will throw an error if the context does not have a FetchEvent.
11708
+ */
11798
11709
  get event() {
11799
- if (this.#executionCtx && "respondWith" in this.#executionCtx) {
11800
- return this.#executionCtx;
11801
- } else {
11802
- throw Error("This context has no FetchEvent");
11803
- }
11710
+ if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
11711
+ else throw Error("This context has no FetchEvent");
11804
11712
  }
11805
11713
  /**
11806
- * @see {@link https://hono.dev/docs/api/context#executionctx}
11807
- * The ExecutionContext associated with the current request.
11808
- *
11809
- * @throws Will throw an error if the context does not have an ExecutionContext.
11810
- */
11714
+ * @see {@link https://hono.dev/docs/api/context#executionctx}
11715
+ * The ExecutionContext associated with the current request.
11716
+ *
11717
+ * @throws Will throw an error if the context does not have an ExecutionContext.
11718
+ */
11811
11719
  get executionCtx() {
11812
- if (this.#executionCtx) {
11813
- return this.#executionCtx;
11814
- } else {
11815
- throw Error("This context has no ExecutionContext");
11816
- }
11720
+ if (this.#executionCtx) return this.#executionCtx;
11721
+ else throw Error("This context has no ExecutionContext");
11817
11722
  }
11818
11723
  /**
11819
- * @see {@link https://hono.dev/docs/api/context#res}
11820
- * The Response object for the current request.
11821
- */
11724
+ * @see {@link https://hono.dev/docs/api/context#res}
11725
+ * The Response object for the current request.
11726
+ */
11822
11727
  get res() {
11823
- return this.#res ||= createResponseInstance(null, {
11824
- headers: this.#preparedHeaders ??= new Headers()
11825
- });
11728
+ return this.#res ||= createResponseInstance(null, { headers: this.#preparedHeaders ??= new Headers() });
11826
11729
  }
11827
11730
  /**
11828
- * Sets the Response object for the current request.
11829
- *
11830
- * @param _res - The Response object to set.
11831
- */
11731
+ * Sets the Response object for the current request.
11732
+ *
11733
+ * @param _res - The Response object to set.
11734
+ */
11832
11735
  set res(_res) {
11833
11736
  if (this.#res && _res) {
11834
11737
  _res = createResponseInstance(_res.body, _res);
11835
11738
  for (const [k, v] of this.#res.headers.entries()) {
11836
- if (k === "content-type") {
11837
- continue;
11838
- }
11739
+ if (k === "content-type") continue;
11839
11740
  if (k === "set-cookie") {
11840
11741
  const cookies = this.#res.headers.getSetCookie();
11841
11742
  _res.headers.delete("set-cookie");
11842
- for (const cookie of cookies) {
11843
- _res.headers.append("set-cookie", cookie);
11844
- }
11845
- } else {
11846
- _res.headers.set(k, v);
11847
- }
11743
+ for (const cookie of cookies) _res.headers.append("set-cookie", cookie);
11744
+ } else _res.headers.set(k, v);
11848
11745
  }
11849
11746
  }
11850
11747
  this.#res = _res;
11851
11748
  this.finalized = true;
11852
11749
  }
11853
11750
  /**
11854
- * `.render()` can create a response within a layout.
11855
- *
11856
- * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
11857
- *
11858
- * @example
11859
- * ```ts
11860
- * app.get('/', (c) => {
11861
- * return c.render('Hello!')
11862
- * })
11863
- * ```
11864
- */
11751
+ * `.render()` can create a response within a layout.
11752
+ *
11753
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
11754
+ *
11755
+ * @example
11756
+ * ```ts
11757
+ * app.get('/', (c) => {
11758
+ * return c.render('Hello!')
11759
+ * })
11760
+ * ```
11761
+ */
11865
11762
  render = /* @__PURE__ */ __name((...args) => {
11866
11763
  this.#renderer ??= (content) => this.html(content);
11867
11764
  return this.#renderer(...args);
11868
11765
  }, "render");
11869
11766
  /**
11870
- * Sets the layout for the response.
11871
- *
11872
- * @param layout - The layout to set.
11873
- * @returns The layout function.
11874
- */
11767
+ * Sets the layout for the response.
11768
+ *
11769
+ * @param layout - The layout to set.
11770
+ * @returns The layout function.
11771
+ */
11875
11772
  setLayout = /* @__PURE__ */ __name((layout) => this.#layout = layout, "setLayout");
11876
11773
  /**
11877
- * Gets the current layout for the response.
11878
- *
11879
- * @returns The current layout function.
11880
- */
11774
+ * Gets the current layout for the response.
11775
+ *
11776
+ * @returns The current layout function.
11777
+ */
11881
11778
  getLayout = /* @__PURE__ */ __name(() => this.#layout, "getLayout");
11882
11779
  /**
11883
- * `.setRenderer()` can set the layout in the custom middleware.
11884
- *
11885
- * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
11886
- *
11887
- * @example
11888
- * ```tsx
11889
- * app.use('*', async (c, next) => {
11890
- * c.setRenderer((content) => {
11891
- * return c.html(
11892
- * <html>
11893
- * <body>
11894
- * <p>{content}</p>
11895
- * </body>
11896
- * </html>
11897
- * )
11898
- * })
11899
- * await next()
11900
- * })
11901
- * ```
11902
- */
11780
+ * `.setRenderer()` can set the layout in the custom middleware.
11781
+ *
11782
+ * @see {@link https://hono.dev/docs/api/context#render-setrenderer}
11783
+ *
11784
+ * @example
11785
+ * ```tsx
11786
+ * app.use('*', async (c, next) => {
11787
+ * c.setRenderer((content) => {
11788
+ * return c.html(
11789
+ * <html>
11790
+ * <body>
11791
+ * <p>{content}</p>
11792
+ * </body>
11793
+ * </html>
11794
+ * )
11795
+ * })
11796
+ * await next()
11797
+ * })
11798
+ * ```
11799
+ */
11903
11800
  setRenderer = /* @__PURE__ */ __name((renderer) => {
11904
11801
  this.#renderer = renderer;
11905
11802
  }, "setRenderer");
11906
11803
  /**
11907
- * `.header()` can set headers.
11908
- *
11909
- * @see {@link https://hono.dev/docs/api/context#header}
11910
- *
11911
- * @example
11912
- * ```ts
11913
- * app.get('/welcome', (c) => {
11914
- * // Set headers
11915
- * c.header('X-Message', 'Hello!')
11916
- * c.header('Content-Type', 'text/plain')
11917
- *
11918
- * return c.body('Thank you for coming')
11919
- * })
11920
- * ```
11921
- */
11804
+ * `.header()` can set headers.
11805
+ *
11806
+ * @see {@link https://hono.dev/docs/api/context#header}
11807
+ *
11808
+ * @example
11809
+ * ```ts
11810
+ * app.get('/welcome', (c) => {
11811
+ * // Set headers
11812
+ * c.header('X-Message', 'Hello!')
11813
+ * c.header('Content-Type', 'text/plain')
11814
+ *
11815
+ * // Append multiple headers using the append option (e.g. Vary)
11816
+ * c.header('Vary', 'Accept-Encoding', { append: true })
11817
+ * c.header('Vary', 'User-Agent', { append: true })
11818
+ *
11819
+ * return c.body('Thank you for coming')
11820
+ * })
11821
+ * ```
11822
+ */
11922
11823
  header = /* @__PURE__ */ __name((name, value, options) => {
11923
- if (this.finalized) {
11924
- this.#res = createResponseInstance(this.#res.body, this.#res);
11925
- }
11824
+ if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
11926
11825
  const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
11927
- if (value === void 0) {
11928
- headers.delete(name);
11929
- } else if (options?.append) {
11930
- headers.append(name, value);
11931
- } else {
11932
- headers.set(name, value);
11933
- }
11826
+ if (value === void 0) headers.delete(name);
11827
+ else if (options?.append) headers.append(name, value);
11828
+ else headers.set(name, value);
11934
11829
  }, "header");
11935
11830
  status = /* @__PURE__ */ __name((status) => {
11936
11831
  this.#status = status;
11937
11832
  }, "status");
11938
11833
  /**
11939
- * `.set()` can set the value specified by the key.
11940
- *
11941
- * @see {@link https://hono.dev/docs/api/context#set-get}
11942
- *
11943
- * @example
11944
- * ```ts
11945
- * app.use('*', async (c, next) => {
11946
- * c.set('message', 'Hono is hot!!')
11947
- * await next()
11948
- * })
11949
- * ```
11950
- */
11834
+ * `.set()` can set the value specified by the key.
11835
+ *
11836
+ * @see {@link https://hono.dev/docs/api/context#set-get}
11837
+ *
11838
+ * @example
11839
+ * ```ts
11840
+ * app.use('*', async (c, next) => {
11841
+ * c.set('message', 'Hono is hot!!')
11842
+ * await next()
11843
+ * })
11844
+ * ```
11845
+ */
11951
11846
  set = /* @__PURE__ */ __name((key, value) => {
11952
11847
  this.#var ??= /* @__PURE__ */ new Map();
11953
11848
  this.#var.set(key, value);
11954
11849
  }, "set");
11955
11850
  /**
11956
- * `.get()` can use the value specified by the key.
11957
- *
11958
- * @see {@link https://hono.dev/docs/api/context#set-get}
11959
- *
11960
- * @example
11961
- * ```ts
11962
- * app.get('/', (c) => {
11963
- * const message = c.get('message')
11964
- * return c.text(`The message is "${message}"`)
11965
- * })
11966
- * ```
11967
- */
11851
+ * `.get()` can use the value specified by the key.
11852
+ *
11853
+ * @see {@link https://hono.dev/docs/api/context#set-get}
11854
+ *
11855
+ * @example
11856
+ * ```ts
11857
+ * app.get('/', (c) => {
11858
+ * const message = c.get('message')
11859
+ * return c.text(`The message is "${message}"`)
11860
+ * })
11861
+ * ```
11862
+ */
11968
11863
  get = /* @__PURE__ */ __name((key) => {
11969
11864
  return this.#var ? this.#var.get(key) : void 0;
11970
11865
  }, "get");
11971
11866
  /**
11972
- * `.var` can access the value of a variable.
11973
- *
11974
- * @see {@link https://hono.dev/docs/api/context#var}
11975
- *
11976
- * @example
11977
- * ```ts
11978
- * const result = c.var.client.oneMethod()
11979
- * ```
11980
- */
11981
- // c.var.propName is a read-only
11867
+ * `.var` can access the value of a variable.
11868
+ *
11869
+ * @see {@link https://hono.dev/docs/api/context#var}
11870
+ *
11871
+ * @example
11872
+ * ```ts
11873
+ * const result = c.var.client.oneMethod()
11874
+ * ```
11875
+ */
11982
11876
  get var() {
11983
- if (!this.#var) {
11984
- return {};
11985
- }
11877
+ if (!this.#var) return {};
11986
11878
  return Object.fromEntries(this.#var);
11987
11879
  }
11988
11880
  #newResponse(data, arg, headers) {
11989
- const responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders ?? new Headers();
11990
- if (typeof arg === "object" && "headers" in arg) {
11991
- const argHeaders = arg.headers instanceof Headers ? arg.headers : new Headers(arg.headers);
11992
- for (const [key, value] of argHeaders) {
11993
- if (key.toLowerCase() === "set-cookie") {
11994
- responseHeaders.append(key, value);
11995
- } else {
11996
- responseHeaders.set(key, value);
11997
- }
11998
- }
11881
+ let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
11882
+ if (typeof arg === "object" && arg.headers) {
11883
+ responseHeaders ??= new Headers();
11884
+ for (const [key, value] of new Headers(arg.headers)) if (key === "set-cookie") responseHeaders.append(key, value);
11885
+ else responseHeaders.set(key, value);
11999
11886
  }
12000
11887
  if (headers) {
12001
- for (const [k, v] of Object.entries(headers)) {
12002
- if (typeof v === "string") {
12003
- responseHeaders.set(k, v);
12004
- } else {
11888
+ if (!responseHeaders) {
11889
+ let count = 0;
11890
+ for (const k in headers) if (++count > 1 || typeof headers[k] !== "string") {
11891
+ responseHeaders = new Headers();
11892
+ break;
11893
+ }
11894
+ }
11895
+ if (responseHeaders) for (const k in headers) {
11896
+ const v = headers[k];
11897
+ if (typeof v === "string") responseHeaders.set(k, v);
11898
+ else {
12005
11899
  responseHeaders.delete(k);
12006
- for (const v2 of v) {
12007
- responseHeaders.append(k, v2);
12008
- }
11900
+ for (const v2 of v) responseHeaders.append(k, v2);
12009
11901
  }
12010
11902
  }
12011
11903
  }
12012
11904
  const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
12013
- return createResponseInstance(data, { status, headers: responseHeaders });
11905
+ return createResponseInstance(data, {
11906
+ status,
11907
+ headers: responseHeaders ?? headers
11908
+ });
12014
11909
  }
12015
11910
  newResponse = /* @__PURE__ */ __name((...args) => this.#newResponse(...args), "newResponse");
12016
11911
  /**
12017
- * `.body()` can return the HTTP response.
12018
- * You can set headers with `.header()` and set HTTP status code with `.status`.
12019
- * This can also be set in `.text()`, `.json()` and so on.
12020
- *
12021
- * @see {@link https://hono.dev/docs/api/context#body}
12022
- *
12023
- * @example
12024
- * ```ts
12025
- * app.get('/welcome', (c) => {
12026
- * // Set headers
12027
- * c.header('X-Message', 'Hello!')
12028
- * c.header('Content-Type', 'text/plain')
12029
- * // Set HTTP status code
12030
- * c.status(201)
12031
- *
12032
- * // Return the response body
12033
- * return c.body('Thank you for coming')
12034
- * })
12035
- * ```
12036
- */
11912
+ * `.body()` can return the HTTP response.
11913
+ * You can set headers with `.header()` and set HTTP status code with `.status`.
11914
+ * This can also be set in `.text()`, `.json()` and so on.
11915
+ *
11916
+ * @see {@link https://hono.dev/docs/api/context#body}
11917
+ *
11918
+ * @example
11919
+ * ```ts
11920
+ * app.get('/welcome', (c) => {
11921
+ * // Set headers
11922
+ * c.header('X-Message', 'Hello!')
11923
+ * c.header('Content-Type', 'text/plain')
11924
+ * // Set HTTP status code
11925
+ * c.status(201)
11926
+ *
11927
+ * // Return the response body
11928
+ * return c.body('Thank you for coming')
11929
+ * })
11930
+ * ```
11931
+ */
12037
11932
  body = /* @__PURE__ */ __name((data, arg, headers) => this.#newResponse(data, arg, headers), "body");
12038
11933
  /**
12039
- * `.text()` can render text as `Content-Type:text/plain`.
12040
- *
12041
- * @see {@link https://hono.dev/docs/api/context#text}
12042
- *
12043
- * @example
12044
- * ```ts
12045
- * app.get('/say', (c) => {
12046
- * return c.text('Hello!')
12047
- * })
12048
- * ```
12049
- */
11934
+ * `.text()` can render text as `Content-Type:text/plain`.
11935
+ *
11936
+ * @see {@link https://hono.dev/docs/api/context#text}
11937
+ *
11938
+ * @example
11939
+ * ```ts
11940
+ * app.get('/say', (c) => {
11941
+ * return c.text('Hello!')
11942
+ * })
11943
+ * ```
11944
+ */
12050
11945
  text = /* @__PURE__ */ __name((text, arg, headers) => {
12051
- return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(
12052
- text,
12053
- arg,
12054
- setDefaultContentType(TEXT_PLAIN, headers)
12055
- );
11946
+ return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(text, arg, setDefaultContentType(TEXT_PLAIN, headers));
12056
11947
  }, "text");
12057
11948
  /**
12058
- * `.json()` can render JSON as `Content-Type:application/json`.
12059
- *
12060
- * @see {@link https://hono.dev/docs/api/context#json}
12061
- *
12062
- * @example
12063
- * ```ts
12064
- * app.get('/api', (c) => {
12065
- * return c.json({ message: 'Hello!' })
12066
- * })
12067
- * ```
12068
- */
11949
+ * `.json()` can render JSON as `Content-Type:application/json`.
11950
+ *
11951
+ * @see {@link https://hono.dev/docs/api/context#json}
11952
+ *
11953
+ * @example
11954
+ * ```ts
11955
+ * app.get('/api', (c) => {
11956
+ * return c.json({ message: 'Hello!' })
11957
+ * })
11958
+ * ```
11959
+ */
12069
11960
  json = /* @__PURE__ */ __name((object, arg, headers) => {
12070
- return this.#newResponse(
12071
- JSON.stringify(object),
12072
- arg,
12073
- setDefaultContentType("application/json", headers)
12074
- );
11961
+ return this.#newResponse(JSON.stringify(object), arg, setDefaultContentType("application/json", headers));
12075
11962
  }, "json");
12076
11963
  html = /* @__PURE__ */ __name((html, arg, headers) => {
12077
11964
  const res = /* @__PURE__ */ __name((html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers)), "res");
12078
11965
  return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
12079
11966
  }, "html");
12080
11967
  /**
12081
- * `.redirect()` can Redirect, default status code is 302.
12082
- *
12083
- * @see {@link https://hono.dev/docs/api/context#redirect}
12084
- *
12085
- * @example
12086
- * ```ts
12087
- * app.get('/redirect', (c) => {
12088
- * return c.redirect('/')
12089
- * })
12090
- * app.get('/redirect-permanently', (c) => {
12091
- * return c.redirect('/', 301)
12092
- * })
12093
- * ```
12094
- */
11968
+ * `.redirect()` can Redirect, default status code is 302.
11969
+ *
11970
+ * @see {@link https://hono.dev/docs/api/context#redirect}
11971
+ *
11972
+ * @example
11973
+ * ```ts
11974
+ * app.get('/redirect', (c) => {
11975
+ * return c.redirect('/')
11976
+ * })
11977
+ * app.get('/redirect-permanently', (c) => {
11978
+ * return c.redirect('/', 301)
11979
+ * })
11980
+ * ```
11981
+ */
12095
11982
  redirect = /* @__PURE__ */ __name((location, status) => {
12096
11983
  const locationString = String(location);
12097
- this.header(
12098
- "Location",
12099
- // Multibyes should be encoded
12100
- // eslint-disable-next-line no-control-regex
12101
- !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
12102
- );
11984
+ this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
12103
11985
  return this.newResponse(null, status ?? 302);
12104
11986
  }, "redirect");
12105
11987
  /**
12106
- * `.notFound()` can return the Not Found Response.
12107
- *
12108
- * @see {@link https://hono.dev/docs/api/context#notfound}
12109
- *
12110
- * @example
12111
- * ```ts
12112
- * app.get('/notfound', (c) => {
12113
- * return c.notFound()
12114
- * })
12115
- * ```
12116
- */
11988
+ * `.notFound()` can return the Not Found Response.
11989
+ *
11990
+ * @see {@link https://hono.dev/docs/api/context#notfound}
11991
+ *
11992
+ * @example
11993
+ * ```ts
11994
+ * app.get('/notfound', (c) => {
11995
+ * return c.notFound()
11996
+ * })
11997
+ * ```
11998
+ */
12117
11999
  notFound = /* @__PURE__ */ __name(() => {
12118
12000
  this.#notFoundHandler ??= () => createResponseInstance();
12119
12001
  return this.#notFoundHandler(this);
12120
12002
  }, "notFound");
12121
12003
  };
12122
12004
 
12123
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router.js
12124
- var METHOD_NAME_ALL = "ALL";
12125
- var METHOD_NAME_ALL_LOWERCASE = "all";
12126
- var METHODS2 = ["get", "post", "put", "delete", "options", "patch"];
12005
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/compose.js
12006
+ var compose = /* @__PURE__ */ __name((middleware, onError, onNotFound) => {
12007
+ return (context, next) => {
12008
+ let index = -1;
12009
+ return dispatch(0);
12010
+ async function dispatch(i) {
12011
+ if (i <= index) throw new Error("next() called multiple times");
12012
+ index = i;
12013
+ let res;
12014
+ let isError = false;
12015
+ let handler;
12016
+ if (middleware[i]) {
12017
+ handler = middleware[i][0][0];
12018
+ context.req.routeIndex = i;
12019
+ } else handler = i === middleware.length && next || void 0;
12020
+ if (handler) try {
12021
+ res = await handler(context, () => dispatch(i + 1));
12022
+ } catch (err) {
12023
+ if (err instanceof Error && onError) {
12024
+ context.error = err;
12025
+ res = await onError(err, context);
12026
+ isError = true;
12027
+ } else throw err;
12028
+ }
12029
+ else if (context.finalized === false && onNotFound) res = await onNotFound(context);
12030
+ if (res && (context.finalized === false || isError)) context.res = res;
12031
+ return context;
12032
+ }
12033
+ __name(dispatch, "dispatch");
12034
+ };
12035
+ }, "compose");
12036
+
12037
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/helper/route/index.js
12038
+ var matchedRoutes = /* @__PURE__ */ __name((c) => c.req[GET_MATCH_RESULT][0].map(([[, route]]) => route), "matchedRoutes");
12039
+ var routePath = /* @__PURE__ */ __name((c, index) => matchedRoutes(c).at(index ?? c.req.routeIndex)?.path ?? "", "routePath");
12040
+
12041
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router.js
12042
+ var METHODS2 = [
12043
+ "get",
12044
+ "post",
12045
+ "put",
12046
+ "delete",
12047
+ "options",
12048
+ "patch",
12049
+ "query"
12050
+ ];
12127
12051
  var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
12128
12052
  var UnsupportedPathError = class extends Error {
12129
12053
  static {
@@ -12131,10 +12055,57 @@ var UnsupportedPathError = class extends Error {
12131
12055
  }
12132
12056
  };
12133
12057
 
12134
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/utils/constants.js
12058
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/constants.js
12135
12059
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
12136
12060
 
12137
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/hono-base.js
12061
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/utils/mount.js
12062
+ var countTrailingSlashes = /* @__PURE__ */ __name((path) => {
12063
+ let index = path.length;
12064
+ while (index > 0 && path.charCodeAt(index - 1) === 47) index--;
12065
+ return path.length - index;
12066
+ }, "countTrailingSlashes");
12067
+ var getPathPrefixLength = /* @__PURE__ */ __name((c, pathPrefix, routePath2) => {
12068
+ if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
12069
+ const path = c.req.path;
12070
+ const matchResult = c.req[GET_MATCH_RESULT];
12071
+ const paramNames = /* @__PURE__ */ new Set();
12072
+ let length = 0;
12073
+ for (const part of splitRoutingPath(pathPrefix)) {
12074
+ if (part[0] === ":" && part.endsWith("}?")) throw new Error(`mount(): Optional regular expression parameters are not supported in "${routePath2}".`);
12075
+ const pattern = getPattern(part);
12076
+ if (pattern && pattern !== "*") {
12077
+ const name = pattern[1];
12078
+ if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath2}".`);
12079
+ paramNames.add(name);
12080
+ }
12081
+ if (pattern && pattern !== "*" && pattern[2] !== true) {
12082
+ const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c.req.routeIndex][1][pattern[1]]] : matchResult[0][c.req.routeIndex][1][pattern[1]];
12083
+ length += value.length + 1;
12084
+ } else if (pattern || part.endsWith("*")) {
12085
+ const end = path.indexOf("/", length + 1);
12086
+ length = end === -1 ? path.length : end;
12087
+ } else length += part.length + 1;
12088
+ }
12089
+ return length;
12090
+ }, "getPathPrefixLength");
12091
+ var createMountedRequest = /* @__PURE__ */ __name((c, pathPrefix, routePath2) => {
12092
+ if (/[^/]\*$/.test(routePath2)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath2}".`);
12093
+ const prefixLength = getPathPrefixLength(c, pathPrefix, routePath2);
12094
+ const path = c.req.path.slice(prefixLength) || "/";
12095
+ if (prefixLength > c.req.path.length || path[0] !== "/" || /\/(?:\.|%2e){1,2}(?:\/|$)/i.test(path)) throw new HTTPException(400, { message: "Invalid mounted path" });
12096
+ const rawUrl = c.req.raw.url;
12097
+ if (/^[^/?#]*\/\/[^/?#\\]*[?#\\]/.test(rawUrl)) throw new HTTPException(400, { message: "Invalid mounted path" });
12098
+ const rawPathEnd = rawUrl.search(/[?#]/);
12099
+ const rawTrailingSlashes = countTrailingSlashes(rawPathEnd === -1 ? rawUrl : rawUrl.slice(0, rawPathEnd));
12100
+ if (rawTrailingSlashes > 1 && countTrailingSlashes(c.req.path) === rawTrailingSlashes - 1) throw new HTTPException(400, { message: "Invalid mounted path" });
12101
+ const url = new URL(rawUrl);
12102
+ url.pathname = path.replace(/[\\\t\n\r]/g, encodeURIComponent);
12103
+ if (path.includes("%")) {
12104
+ }
12105
+ return new Request(url, c.req.raw);
12106
+ }, "createMountedRequest");
12107
+
12108
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/hono-base.js
12138
12109
  var notFoundHandler = /* @__PURE__ */ __name((c) => {
12139
12110
  return c.text("404 Not Found", 404);
12140
12111
  }, "notFoundHandler");
@@ -12146,9 +12117,9 @@ var errorHandler = /* @__PURE__ */ __name((err, c) => {
12146
12117
  console.error(err);
12147
12118
  return c.text("Internal Server Error", 500);
12148
12119
  }, "errorHandler");
12149
- var Hono = class _Hono {
12120
+ var Hono = class Hono2 {
12150
12121
  static {
12151
- __name(this, "_Hono");
12122
+ __name(this, "Hono");
12152
12123
  }
12153
12124
  get;
12154
12125
  post;
@@ -12156,30 +12127,23 @@ var Hono = class _Hono {
12156
12127
  delete;
12157
12128
  options;
12158
12129
  patch;
12130
+ query;
12159
12131
  all;
12160
12132
  on;
12161
12133
  use;
12162
- /*
12163
- This class is like an abstract class and does not have a router.
12164
- To use it, inherit the class and implement router in the constructor.
12165
- */
12166
12134
  router;
12167
12135
  getPath;
12168
- // Cannot use `#` because it requires visibility at JavaScript runtime.
12169
12136
  _basePath = "/";
12170
12137
  #path = "/";
12171
12138
  routes = [];
12172
12139
  constructor(options = {}) {
12173
- const allMethods = [...METHODS2, METHOD_NAME_ALL_LOWERCASE];
12174
- allMethods.forEach((method) => {
12140
+ [...METHODS2, "all"].forEach((method) => {
12175
12141
  this[method] = (args1, ...args) => {
12176
- if (typeof args1 === "string") {
12177
- this.#path = args1;
12178
- } else {
12179
- this.#addRoute(method, this.#path, args1);
12180
- }
12142
+ const methodName = method.toUpperCase();
12143
+ if (typeof args1 === "string") this.#path = args1;
12144
+ else this.#addRoute(methodName, this.#path, args1);
12181
12145
  args.forEach((handler) => {
12182
- this.#addRoute(method, this.#path, handler);
12146
+ this.#addRoute(methodName, this.#path, handler);
12183
12147
  });
12184
12148
  return this;
12185
12149
  };
@@ -12188,22 +12152,20 @@ var Hono = class _Hono {
12188
12152
  for (const p of [path].flat()) {
12189
12153
  this.#path = p;
12190
12154
  for (const m of [method].flat()) {
12191
- handlers.map((handler) => {
12192
- this.#addRoute(m.toUpperCase(), this.#path, handler);
12193
- });
12155
+ const methodName = m.toUpperCase();
12156
+ for (const handler of handlers) this.#addRoute(methodName, this.#path, handler);
12194
12157
  }
12195
12158
  }
12196
12159
  return this;
12197
12160
  };
12198
12161
  this.use = (arg1, ...handlers) => {
12199
- if (typeof arg1 === "string") {
12200
- this.#path = arg1;
12201
- } else {
12162
+ if (typeof arg1 === "string") this.#path = arg1;
12163
+ else {
12202
12164
  this.#path = "*";
12203
12165
  handlers.unshift(arg1);
12204
12166
  }
12205
12167
  handlers.forEach((handler) => {
12206
- this.#addRoute(METHOD_NAME_ALL, this.#path, handler);
12168
+ this.#addRoute("ALL", this.#path, handler);
12207
12169
  });
12208
12170
  return this;
12209
12171
  };
@@ -12212,7 +12174,7 @@ var Hono = class _Hono {
12212
12174
  this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
12213
12175
  }
12214
12176
  #clone() {
12215
- const clone = new _Hono({
12177
+ const clone = new Hono2({
12216
12178
  router: this.router,
12217
12179
  getPath: this.getPath
12218
12180
  });
@@ -12222,33 +12184,31 @@ var Hono = class _Hono {
12222
12184
  return clone;
12223
12185
  }
12224
12186
  #notFoundHandler = notFoundHandler;
12225
- // Cannot use `#` because it requires visibility at JavaScript runtime.
12226
12187
  errorHandler = errorHandler;
12227
12188
  /**
12228
- * `.route()` allows grouping other Hono instance in routes.
12229
- *
12230
- * @see {@link https://hono.dev/docs/api/routing#grouping}
12231
- *
12232
- * @param {string} path - base Path
12233
- * @param {Hono} app - other Hono instance
12234
- * @returns {Hono} routed Hono instance
12235
- *
12236
- * @example
12237
- * ```ts
12238
- * const app = new Hono()
12239
- * const app2 = new Hono()
12240
- *
12241
- * app2.get("/user", (c) => c.text("user"))
12242
- * app.route("/api", app2) // GET /api/user
12243
- * ```
12244
- */
12189
+ * `.route()` allows grouping other Hono instance in routes.
12190
+ *
12191
+ * @see {@link https://hono.dev/docs/api/routing#grouping}
12192
+ *
12193
+ * @param {string} path - base Path
12194
+ * @param {Hono} app - other Hono instance
12195
+ * @returns {Hono} routed Hono instance
12196
+ *
12197
+ * @example
12198
+ * ```ts
12199
+ * const app = new Hono()
12200
+ * const app2 = new Hono()
12201
+ *
12202
+ * app2.get("/user", (c) => c.text("user"))
12203
+ * app.route("/api", app2) // GET /api/user
12204
+ * ```
12205
+ */
12245
12206
  route(path, app2) {
12246
12207
  const subApp = this.basePath(path);
12247
12208
  app2.routes.map((r) => {
12248
12209
  let handler;
12249
- if (app2.errorHandler === errorHandler) {
12250
- handler = r.handler;
12251
- } else {
12210
+ if (app2.errorHandler === errorHandler) handler = r.handler;
12211
+ else {
12252
12212
  handler = /* @__PURE__ */ __name(async (c, next) => (await compose([], app2.errorHandler)(c, () => r.handler(c, next))).res, "handler");
12253
12213
  handler[COMPOSED_HANDLER] = r.handler;
12254
12214
  }
@@ -12257,107 +12217,107 @@ var Hono = class _Hono {
12257
12217
  return this;
12258
12218
  }
12259
12219
  /**
12260
- * `.basePath()` allows base paths to be specified.
12261
- *
12262
- * @see {@link https://hono.dev/docs/api/routing#base-path}
12263
- *
12264
- * @param {string} path - base Path
12265
- * @returns {Hono} changed Hono instance
12266
- *
12267
- * @example
12268
- * ```ts
12269
- * const api = new Hono().basePath('/api')
12270
- * ```
12271
- */
12220
+ * `.basePath()` allows base paths to be specified.
12221
+ *
12222
+ * @see {@link https://hono.dev/docs/api/routing#base-path}
12223
+ *
12224
+ * @param {string} path - base Path
12225
+ * @returns {Hono} changed Hono instance
12226
+ *
12227
+ * @example
12228
+ * ```ts
12229
+ * const api = new Hono().basePath('/api')
12230
+ * ```
12231
+ */
12272
12232
  basePath(path) {
12273
12233
  const subApp = this.#clone();
12274
12234
  subApp._basePath = mergePath(this._basePath, path);
12275
12235
  return subApp;
12276
12236
  }
12277
12237
  /**
12278
- * `.onError()` handles an error and returns a customized Response.
12279
- *
12280
- * @see {@link https://hono.dev/docs/api/hono#error-handling}
12281
- *
12282
- * @param {ErrorHandler} handler - request Handler for error
12283
- * @returns {Hono} changed Hono instance
12284
- *
12285
- * @example
12286
- * ```ts
12287
- * app.onError((err, c) => {
12288
- * console.error(`${err}`)
12289
- * return c.text('Custom Error Message', 500)
12290
- * })
12291
- * ```
12292
- */
12238
+ * `.onError()` handles an error and returns a customized Response.
12239
+ *
12240
+ * @see {@link https://hono.dev/docs/api/hono#error-handling}
12241
+ *
12242
+ * @param {ErrorHandler} handler - request Handler for error
12243
+ * @returns {Hono} changed Hono instance
12244
+ *
12245
+ * @example
12246
+ * ```ts
12247
+ * app.onError((err, c) => {
12248
+ * console.error(`${err}`)
12249
+ * return c.text('Custom Error Message', 500)
12250
+ * })
12251
+ * ```
12252
+ */
12293
12253
  onError = /* @__PURE__ */ __name((handler) => {
12294
12254
  this.errorHandler = handler;
12295
12255
  return this;
12296
12256
  }, "onError");
12297
12257
  /**
12298
- * `.notFound()` allows you to customize a Not Found Response.
12299
- *
12300
- * @see {@link https://hono.dev/docs/api/hono#not-found}
12301
- *
12302
- * @param {NotFoundHandler} handler - request handler for not-found
12303
- * @returns {Hono} changed Hono instance
12304
- *
12305
- * @example
12306
- * ```ts
12307
- * app.notFound((c) => {
12308
- * return c.text('Custom 404 Message', 404)
12309
- * })
12310
- * ```
12311
- */
12258
+ * `.notFound()` allows you to customize a Not Found Response.
12259
+ *
12260
+ * @see {@link https://hono.dev/docs/api/hono#not-found}
12261
+ *
12262
+ * @param {NotFoundHandler} handler - request handler for not-found
12263
+ * @returns {Hono} changed Hono instance
12264
+ *
12265
+ * @example
12266
+ * ```ts
12267
+ * app.notFound((c) => {
12268
+ * return c.text('Custom 404 Message', 404)
12269
+ * })
12270
+ * ```
12271
+ */
12312
12272
  notFound = /* @__PURE__ */ __name((handler) => {
12313
12273
  this.#notFoundHandler = handler;
12314
12274
  return this;
12315
12275
  }, "notFound");
12316
12276
  /**
12317
- * `.mount()` allows you to mount applications built with other frameworks into your Hono application.
12318
- *
12319
- * @see {@link https://hono.dev/docs/api/hono#mount}
12320
- *
12321
- * @param {string} path - base Path
12322
- * @param {Function} applicationHandler - other Request Handler
12323
- * @param {MountOptions} [options] - options of `.mount()`
12324
- * @returns {Hono} mounted Hono instance
12325
- *
12326
- * @example
12327
- * ```ts
12328
- * import { Router as IttyRouter } from 'itty-router'
12329
- * import { Hono } from 'hono'
12330
- * // Create itty-router application
12331
- * const ittyRouter = IttyRouter()
12332
- * // GET /itty-router/hello
12333
- * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
12334
- *
12335
- * const app = new Hono()
12336
- * app.mount('/itty-router', ittyRouter.handle)
12337
- * ```
12338
- *
12339
- * @example
12340
- * ```ts
12341
- * const app = new Hono()
12342
- * // Send the request to another application without modification.
12343
- * app.mount('/app', anotherApp, {
12344
- * replaceRequest: (req) => req,
12345
- * })
12346
- * ```
12347
- */
12277
+ * `.mount()` allows you to mount applications built with other frameworks into your Hono application.
12278
+ *
12279
+ * @deprecated Use `mount()` from `hono/mount` instead. `.mount()` will be removed in v5.
12280
+ *
12281
+ * @see {@link https://hono.dev/docs/api/hono#mount}
12282
+ *
12283
+ * @param {string} path - base Path
12284
+ * @param {Function} applicationHandler - other Request Handler
12285
+ * @param {MountOptions} [options] - options of `.mount()`
12286
+ * @returns {Hono} mounted Hono instance
12287
+ * @throws {Error} If automatic request rewriting encounters duplicate path parameter names or an optional regular expression parameter.
12288
+ * @throws {HTTPException} With status 400 if automatic request rewriting cannot safely preserve the routed path.
12289
+ *
12290
+ * @example
12291
+ * ```ts
12292
+ * import { Router as IttyRouter } from 'itty-router'
12293
+ * import { Hono } from 'hono'
12294
+ * // Create itty-router application
12295
+ * const ittyRouter = IttyRouter()
12296
+ * // GET /itty-router/hello
12297
+ * ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
12298
+ *
12299
+ * const app = new Hono()
12300
+ * app.mount('/itty-router', ittyRouter.handle)
12301
+ * ```
12302
+ *
12303
+ * @example
12304
+ * ```ts
12305
+ * const app = new Hono()
12306
+ * // Send the request to another application without modification.
12307
+ * app.mount('/app', anotherApp, {
12308
+ * replaceRequest: (req) => req,
12309
+ * })
12310
+ * ```
12311
+ */
12348
12312
  mount(path, applicationHandler, options) {
12349
12313
  let replaceRequest;
12350
12314
  let optionHandler;
12351
12315
  if (options) {
12352
- if (typeof options === "function") {
12353
- optionHandler = options;
12354
- } else {
12316
+ if (typeof options === "function") optionHandler = options;
12317
+ else {
12355
12318
  optionHandler = options.optionHandler;
12356
- if (options.replaceRequest === false) {
12357
- replaceRequest = /* @__PURE__ */ __name((request) => request, "replaceRequest");
12358
- } else {
12359
- replaceRequest = options.replaceRequest;
12360
- }
12319
+ if (options.replaceRequest === false) replaceRequest = /* @__PURE__ */ __name((request) => request, "replaceRequest");
12320
+ else replaceRequest = options.replaceRequest;
12361
12321
  }
12362
12322
  }
12363
12323
  const getOptions = optionHandler ? (c) => {
@@ -12371,27 +12331,19 @@ var Hono = class _Hono {
12371
12331
  }
12372
12332
  return [c.env, executionContext];
12373
12333
  };
12374
- replaceRequest ||= (() => {
12375
- const mergedPath = mergePath(this._basePath, path);
12376
- const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
12377
- return (request) => {
12378
- const url = new URL(request.url);
12379
- url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
12380
- return new Request(url, request);
12381
- };
12382
- })();
12334
+ const defaultReplaceRequest = /* @__PURE__ */ __name((c) => {
12335
+ const mountedRoutePath = routePath(c);
12336
+ return createMountedRequest(c, mountedRoutePath.replace(/\/?\*$/, ""), mountedRoutePath);
12337
+ }, "defaultReplaceRequest");
12383
12338
  const handler = /* @__PURE__ */ __name(async (c, next) => {
12384
- const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
12385
- if (res) {
12386
- return res;
12387
- }
12339
+ const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
12340
+ if (res) return res;
12388
12341
  await next();
12389
12342
  }, "handler");
12390
- this.#addRoute(METHOD_NAME_ALL, mergePath(path, "*"), handler);
12343
+ this.#addRoute("ALL", mergePath(path, "*"), handler);
12391
12344
  return this;
12392
12345
  }
12393
12346
  #addRoute(method, path, handler, baseRoutePath) {
12394
- method = method.toUpperCase();
12395
12347
  path = mergePath(this._basePath, path);
12396
12348
  const r = {
12397
12349
  basePath: baseRoutePath !== void 0 ? mergePath(this._basePath, baseRoutePath) : this._basePath,
@@ -12403,15 +12355,11 @@ var Hono = class _Hono {
12403
12355
  this.routes.push(r);
12404
12356
  }
12405
12357
  #handleError(err, c) {
12406
- if (err instanceof Error) {
12407
- return this.errorHandler(err, c);
12408
- }
12358
+ if (err instanceof Error) return this.errorHandler(err, c);
12409
12359
  throw err;
12410
12360
  }
12411
12361
  #dispatch(request, executionCtx, env2, method) {
12412
- if (method === "HEAD") {
12413
- return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
12414
- }
12362
+ if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
12415
12363
  const path = this.getPath(request, { env: env2 });
12416
12364
  const matchResult = this.router.match(method, path);
12417
12365
  const c = new Context(request, {
@@ -12430,19 +12378,13 @@ var Hono = class _Hono {
12430
12378
  } catch (err) {
12431
12379
  return this.#handleError(err, c);
12432
12380
  }
12433
- return res instanceof Promise ? res.then(
12434
- (resolved) => resolved || (c.finalized ? c.res : this.#notFoundHandler(c))
12435
- ).catch((err) => this.#handleError(err, c)) : res ?? this.#notFoundHandler(c);
12381
+ 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);
12436
12382
  }
12437
12383
  const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
12438
12384
  return (async () => {
12439
12385
  try {
12440
12386
  const context = await composed(c);
12441
- if (!context.finalized) {
12442
- throw new Error(
12443
- "Context is not finalized. Did you forget to return a Response object or `await next()`?"
12444
- );
12445
- }
12387
+ if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
12446
12388
  return context.res;
12447
12389
  } catch (err) {
12448
12390
  return this.#handleError(err, c);
@@ -12450,62 +12392,53 @@ var Hono = class _Hono {
12450
12392
  })();
12451
12393
  }
12452
12394
  /**
12453
- * `.fetch()` will be entry point of your app.
12454
- *
12455
- * @see {@link https://hono.dev/docs/api/hono#fetch}
12456
- *
12457
- * @param {Request} request - request Object of request
12458
- * @param {Env} Env - env Object
12459
- * @param {ExecutionContext} - context of execution
12460
- * @returns {Response | Promise<Response>} response of request
12461
- *
12462
- */
12395
+ * `.fetch()` will be entry point of your app.
12396
+ *
12397
+ * @see {@link https://hono.dev/docs/api/hono#fetch}
12398
+ *
12399
+ * @param {Request} request - request Object of request
12400
+ * @param {Env} env - env Object
12401
+ * @param {ExecutionContext} executionCtx - context of execution
12402
+ * @returns {Response | Promise<Response>} response of request
12403
+ *
12404
+ */
12463
12405
  fetch = /* @__PURE__ */ __name((request, ...rest) => {
12464
12406
  return this.#dispatch(request, rest[1], rest[0], request.method);
12465
12407
  }, "fetch");
12466
12408
  /**
12467
- * `.request()` is a useful method for testing.
12468
- * You can pass a URL or pathname to send a GET request.
12469
- * app will return a Response object.
12470
- * ```ts
12471
- * test('GET /hello is ok', async () => {
12472
- * const res = await app.request('/hello')
12473
- * expect(res.status).toBe(200)
12474
- * })
12475
- * ```
12476
- * @see https://hono.dev/docs/api/hono#request
12477
- */
12409
+ * `.request()` is a useful method for testing.
12410
+ * You can pass a URL or pathname to send a GET request.
12411
+ * app will return a Response object.
12412
+ * ```ts
12413
+ * test('GET /hello is ok', async () => {
12414
+ * const res = await app.request('/hello')
12415
+ * expect(res.status).toBe(200)
12416
+ * })
12417
+ * ```
12418
+ * @see https://hono.dev/docs/api/hono#request
12419
+ */
12478
12420
  request = /* @__PURE__ */ __name((input, requestInit, Env, executionCtx) => {
12479
- if (input instanceof Request) {
12480
- return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
12481
- }
12421
+ if (input instanceof Request) return this.fetch(requestInit ? new Request(input, requestInit) : input, Env, executionCtx);
12482
12422
  input = input.toString();
12483
- return this.fetch(
12484
- new Request(
12485
- /^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`,
12486
- requestInit
12487
- ),
12488
- Env,
12489
- executionCtx
12490
- );
12423
+ return this.fetch(new Request(/^https?:\/\//.test(input) ? input : `http://localhost${mergePath("/", input)}`, requestInit), Env, executionCtx);
12491
12424
  }, "request");
12492
12425
  /**
12493
- * `.fire()` automatically adds a global fetch event listener.
12494
- * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
12495
- * @deprecated
12496
- * Use `fire` from `hono/service-worker` instead.
12497
- * ```ts
12498
- * import { Hono } from 'hono'
12499
- * import { fire } from 'hono/service-worker'
12500
- *
12501
- * const app = new Hono()
12502
- * // ...
12503
- * fire(app)
12504
- * ```
12505
- * @see https://hono.dev/docs/api/hono#fire
12506
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
12507
- * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
12508
- */
12426
+ * `.fire()` automatically adds a global fetch event listener.
12427
+ * This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
12428
+ * @deprecated
12429
+ * Use `fire` from `hono/service-worker` instead.
12430
+ * ```ts
12431
+ * import { Hono } from 'hono'
12432
+ * import { fire } from 'hono/service-worker'
12433
+ *
12434
+ * const app = new Hono()
12435
+ * // ...
12436
+ * fire(app)
12437
+ * ```
12438
+ * @see https://hono.dev/docs/api/hono#fire
12439
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
12440
+ * @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
12441
+ */
12509
12442
  fire = /* @__PURE__ */ __name(() => {
12510
12443
  addEventListener("fetch", (event) => {
12511
12444
  event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));
@@ -12513,181 +12446,171 @@ var Hono = class _Hono {
12513
12446
  }, "fire");
12514
12447
  };
12515
12448
 
12516
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/matcher.js
12449
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/utils.js
12450
+ var createNullObject = /* @__PURE__ */ __name(() => /* @__PURE__ */ Object.create(null), "createNullObject");
12451
+
12452
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/matcher.js
12517
12453
  var emptyParam = [];
12518
12454
  function match(method, path) {
12519
12455
  const matchers = this.buildAllMatchers();
12520
12456
  const match2 = /* @__PURE__ */ __name(((method2, path2) => {
12521
- const matcher = matchers[method2] || matchers[METHOD_NAME_ALL];
12457
+ const matcher = matchers[method2] || matchers["ALL"];
12522
12458
  const staticMatch = matcher[2][path2];
12523
- if (staticMatch) {
12524
- return staticMatch;
12525
- }
12459
+ if (staticMatch) return staticMatch;
12526
12460
  const match3 = path2.match(matcher[0]);
12527
- if (!match3) {
12528
- return [[], emptyParam];
12529
- }
12461
+ if (!match3) return [[], emptyParam];
12530
12462
  const index = match3.indexOf("", 1);
12531
12463
  return [matcher[1][index], match3];
12532
- }), "match2");
12464
+ }), "match");
12533
12465
  this.match = match2;
12534
12466
  return match2(method, path);
12535
12467
  }
12536
12468
  __name(match, "match");
12537
12469
 
12538
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/node.js
12470
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/node.js
12539
12471
  var LABEL_REG_EXP_STR = "[^/]+";
12540
- var ONLY_WILDCARD_REG_EXP_STR = ".*";
12541
- var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
12472
+ var ONLY_WILDCARD_REG_EXP_STR = "[^]*";
12473
+ var TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
12542
12474
  var PATH_ERROR = /* @__PURE__ */ Symbol();
12543
- var regExpMetaChars = new Set(".\\+*[^]$()");
12475
+ var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
12544
12476
  function compareKey(a, b) {
12545
- if (a.length === 1) {
12546
- return b.length === 1 ? a < b ? -1 : 1 : -1;
12547
- }
12548
- if (b.length === 1) {
12549
- return 1;
12550
- }
12551
- if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
12552
- return 1;
12553
- } else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
12554
- return -1;
12555
- }
12556
- if (a === LABEL_REG_EXP_STR) {
12557
- return 1;
12558
- } else if (b === LABEL_REG_EXP_STR) {
12559
- return -1;
12560
- }
12477
+ if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
12478
+ if (b.length === 1) return 1;
12479
+ if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
12480
+ else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
12481
+ if (a === "[^/]+") return 1;
12482
+ else if (b === "[^/]+") return -1;
12561
12483
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
12562
12484
  }
12563
12485
  __name(compareKey, "compareKey");
12564
- var Node = class _Node {
12486
+ var Node = class Node2 {
12565
12487
  static {
12566
- __name(this, "_Node");
12488
+ __name(this, "Node");
12567
12489
  }
12568
12490
  #index;
12569
12491
  #varIndex;
12570
- #children = /* @__PURE__ */ Object.create(null);
12571
- insert(tokens, index, paramMap, context, pathErrorCheckOnly) {
12572
- if (tokens.length === 0) {
12573
- if (this.#index !== void 0) {
12574
- throw PATH_ERROR;
12575
- }
12576
- if (pathErrorCheckOnly) {
12577
- return;
12578
- }
12579
- this.#index = index;
12580
- return;
12581
- }
12582
- const [token, ...restTokens] = tokens;
12583
- const pattern = token === "*" ? restTokens.length === 0 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
12584
- let node;
12585
- if (pattern) {
12586
- const name = pattern[1];
12587
- let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
12588
- if (name && pattern[2]) {
12589
- if (regexpStr === ".*") {
12590
- throw PATH_ERROR;
12591
- }
12592
- regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
12593
- if (/\((?!\?:)/.test(regexpStr)) {
12594
- throw PATH_ERROR;
12595
- }
12596
- }
12597
- node = this.#children[regexpStr];
12598
- if (!node) {
12599
- if (Object.keys(this.#children).some(
12600
- (k) => k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
12601
- )) {
12602
- throw PATH_ERROR;
12492
+ #children = createNullObject();
12493
+ insert(tokens, index, paramMap, context, keys) {
12494
+ let node = this;
12495
+ for (let i = 0, len = tokens.length; i < len; i++) {
12496
+ const token = tokens[i];
12497
+ const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
12498
+ "",
12499
+ "",
12500
+ ONLY_WILDCARD_REG_EXP_STR
12501
+ ] : [
12502
+ "",
12503
+ "",
12504
+ LABEL_REG_EXP_STR
12505
+ ] : null : token === "/*" ? [
12506
+ "",
12507
+ "",
12508
+ TAIL_WILDCARD_REG_EXP_STR
12509
+ ] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
12510
+ let nextNode;
12511
+ if (pattern) {
12512
+ const name = pattern[1];
12513
+ let regexpStr = pattern[2] || "[^/]+";
12514
+ if (name && pattern[2]) {
12515
+ if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
12516
+ regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
12517
+ if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
12518
+ if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
12603
12519
  }
12604
- if (pathErrorCheckOnly) {
12605
- return;
12520
+ keys.push(regexpStr);
12521
+ nextNode = node.#children[regexpStr];
12522
+ if (!nextNode) {
12523
+ if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
12524
+ for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
12525
+ }
12526
+ nextNode = node.#children[regexpStr] = new Node2();
12606
12527
  }
12607
- node = this.#children[regexpStr] = new _Node();
12608
12528
  if (name !== "") {
12609
- node.#varIndex = context.varIndex++;
12610
- }
12611
- }
12612
- if (!pathErrorCheckOnly && name !== "") {
12613
- paramMap.push([name, node.#varIndex]);
12614
- }
12615
- } else {
12616
- node = this.#children[token];
12617
- if (!node) {
12618
- if (Object.keys(this.#children).some(
12619
- (k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR
12620
- )) {
12621
- throw PATH_ERROR;
12529
+ nextNode.#varIndex ??= context.varIndex++;
12530
+ paramMap.push([name, nextNode.#varIndex]);
12622
12531
  }
12623
- if (pathErrorCheckOnly) {
12624
- return;
12532
+ } else {
12533
+ keys.push(token);
12534
+ nextNode = node.#children[token];
12535
+ if (!nextNode) {
12536
+ for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
12537
+ nextNode = node.#children[token] = new Node2();
12625
12538
  }
12626
- node = this.#children[token] = new _Node();
12627
12539
  }
12540
+ node = nextNode;
12628
12541
  }
12629
- node.insert(restTokens, index, paramMap, context, pathErrorCheckOnly);
12542
+ if (node.#index !== void 0) throw PATH_ERROR;
12543
+ node.#index = index;
12630
12544
  }
12631
12545
  buildRegExpStr() {
12632
- const childKeys = Object.keys(this.#children).sort(compareKey);
12633
- const strList = childKeys.map((k) => {
12546
+ const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
12634
12547
  const c = this.#children[k];
12635
- return (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + c.buildRegExpStr();
12636
- });
12637
- if (typeof this.#index === "number") {
12638
- strList.unshift(`#${this.#index}`);
12639
- }
12640
- if (strList.length === 0) {
12641
- return "";
12642
- }
12643
- if (strList.length === 1) {
12644
- return strList[0];
12645
- }
12548
+ const childStr = c.buildRegExpStr();
12549
+ return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
12550
+ }).filter(Boolean);
12551
+ if (typeof this.#index === "number" && this.#index !== -1) strList.unshift(`#${this.#index}`);
12552
+ if (strList.length === 0) return "";
12553
+ if (strList.length === 1) return strList[0];
12646
12554
  return "(?:" + strList.join("|") + ")";
12647
12555
  }
12648
12556
  };
12649
12557
 
12650
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/trie.js
12558
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/trie.js
12651
12559
  var Trie = class {
12652
12560
  static {
12653
12561
  __name(this, "Trie");
12654
12562
  }
12655
12563
  #context = { varIndex: 0 };
12656
12564
  #root = new Node();
12657
- insert(path, index, pathErrorCheckOnly) {
12565
+ #index = 0;
12566
+ paths = createNullObject();
12567
+ insert(path, isStatic) {
12568
+ const keys = [];
12569
+ if (isStatic) {
12570
+ this.#root.insert(path.split(""), -1, [], this.#context, keys);
12571
+ this.paths[path] = [
12572
+ -1,
12573
+ [],
12574
+ keys
12575
+ ];
12576
+ return;
12577
+ }
12658
12578
  const paramAssoc = [];
12659
12579
  const groups = [];
12580
+ let markedPath = path;
12660
12581
  for (let i = 0; ; ) {
12661
12582
  let replaced = false;
12662
- path = path.replace(/\{[^}]+\}/g, (m) => {
12583
+ markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
12663
12584
  const mark = `@\\${i}`;
12664
12585
  groups[i] = [mark, m];
12665
12586
  i++;
12666
12587
  replaced = true;
12667
12588
  return mark;
12668
12589
  });
12669
- if (!replaced) {
12670
- break;
12671
- }
12590
+ if (!replaced) break;
12672
12591
  }
12673
- const tokens = path.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
12592
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
12674
12593
  for (let i = groups.length - 1; i >= 0; i--) {
12675
12594
  const [mark] = groups[i];
12676
- for (let j = tokens.length - 1; j >= 0; j--) {
12677
- if (tokens[j].indexOf(mark) !== -1) {
12678
- tokens[j] = tokens[j].replace(mark, groups[i][1]);
12679
- break;
12680
- }
12595
+ for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
12596
+ tokens[j] = tokens[j].replace(mark, groups[i][1]);
12597
+ break;
12681
12598
  }
12682
12599
  }
12683
- this.#root.insert(tokens, index, paramAssoc, this.#context, pathErrorCheckOnly);
12684
- return paramAssoc;
12600
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
12601
+ this.paths[path] = [
12602
+ this.#index++,
12603
+ paramAssoc,
12604
+ keys
12605
+ ];
12685
12606
  }
12686
12607
  buildRegExp() {
12687
12608
  let regexp = this.#root.buildRegExpStr();
12688
- if (regexp === "") {
12689
- return [/^$/, [], []];
12690
- }
12609
+ if (regexp === "") return [
12610
+ /^$/,
12611
+ [],
12612
+ []
12613
+ ];
12691
12614
  let captureIndex = 0;
12692
12615
  const indexReplacementMap = [];
12693
12616
  const paramReplacementMap = [];
@@ -12702,197 +12625,102 @@ var Trie = class {
12702
12625
  }
12703
12626
  return "";
12704
12627
  });
12705
- return [new RegExp(`^${regexp}`), indexReplacementMap, paramReplacementMap];
12628
+ return [
12629
+ new RegExp(`^${regexp}`),
12630
+ indexReplacementMap,
12631
+ paramReplacementMap
12632
+ ];
12706
12633
  }
12707
12634
  };
12708
12635
 
12709
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/reg-exp-router/router.js
12710
- var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
12711
- var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
12712
- function buildWildcardRegExp(path) {
12713
- return wildcardRegExpCache[path] ??= new RegExp(
12714
- path === "*" ? "" : `^${path.replace(
12715
- /\/\*$|([.\\+*[^\]$()])/g,
12716
- (_, metaChar) => metaChar ? `\\${metaChar}` : "(?:|/.*)"
12717
- )}$`
12718
- );
12719
- }
12720
- __name(buildWildcardRegExp, "buildWildcardRegExp");
12721
- function clearWildcardRegExpCache() {
12722
- wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
12723
- }
12724
- __name(clearWildcardRegExpCache, "clearWildcardRegExpCache");
12725
- function buildMatcherFromPreprocessedRoutes(routes) {
12726
- const trie = new Trie();
12727
- const handlerData = [];
12728
- if (routes.length === 0) {
12729
- return nullMatcher;
12730
- }
12731
- const routesWithStaticPathFlag = routes.map(
12732
- (route) => [!/\*|\/:/.test(route[0]), ...route]
12733
- ).sort(
12734
- ([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length
12735
- );
12736
- const staticMap = /* @__PURE__ */ Object.create(null);
12737
- for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
12738
- const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
12739
- if (pathErrorCheckOnly) {
12740
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
12741
- } else {
12742
- j++;
12743
- }
12744
- let paramAssoc;
12745
- try {
12746
- paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
12747
- } catch (e) {
12748
- throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
12749
- }
12750
- if (pathErrorCheckOnly) {
12751
- continue;
12752
- }
12753
- handlerData[j] = handlers.map(([h, paramCount]) => {
12754
- const paramIndexMap = /* @__PURE__ */ Object.create(null);
12755
- paramCount -= 1;
12756
- for (; paramCount >= 0; paramCount--) {
12757
- const [key, value] = paramAssoc[paramCount];
12758
- paramIndexMap[key] = value;
12759
- }
12760
- return [h, paramIndexMap];
12761
- });
12762
- }
12763
- const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
12764
- for (let i = 0, len = handlerData.length; i < len; i++) {
12765
- for (let j = 0, len2 = handlerData[i].length; j < len2; j++) {
12766
- const map = handlerData[i][j]?.[1];
12767
- if (!map) {
12768
- continue;
12769
- }
12770
- const keys = Object.keys(map);
12771
- for (let k = 0, len3 = keys.length; k < len3; k++) {
12772
- map[keys[k]] = paramReplacementMap[map[keys[k]]];
12773
- }
12774
- }
12775
- }
12776
- const handlerMap = [];
12777
- for (const i in indexReplacementMap) {
12778
- handlerMap[i] = handlerData[indexReplacementMap[i]];
12779
- }
12780
- return [regexp, handlerMap, staticMap];
12636
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/reg-exp-router/router.js
12637
+ function endsWithWildcard(keys) {
12638
+ const tail = keys[keys.length - 1];
12639
+ return tail === "[^]*" || tail === "(?:|/[^]*)";
12781
12640
  }
12782
- __name(buildMatcherFromPreprocessedRoutes, "buildMatcherFromPreprocessedRoutes");
12783
- function findMiddleware(middleware, path) {
12784
- if (!middleware) {
12785
- return void 0;
12786
- }
12787
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
12788
- if (buildWildcardRegExp(k).test(path)) {
12789
- return [...middleware[k]];
12790
- }
12791
- }
12792
- return void 0;
12641
+ __name(endsWithWildcard, "endsWithWildcard");
12642
+ function covers(wildcard, target) {
12643
+ const last = wildcard.length - 1;
12644
+ for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
12645
+ return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
12793
12646
  }
12794
- __name(findMiddleware, "findMiddleware");
12647
+ __name(covers, "covers");
12795
12648
  var RegExpRouter = class {
12796
12649
  static {
12797
12650
  __name(this, "RegExpRouter");
12798
12651
  }
12799
12652
  name = "RegExpRouter";
12800
- #middleware;
12801
- #routes;
12653
+ #handlers;
12654
+ #tries;
12802
12655
  constructor() {
12803
- this.#middleware = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
12804
- this.#routes = { [METHOD_NAME_ALL]: /* @__PURE__ */ Object.create(null) };
12656
+ this.#handlers = { ["ALL"]: [] };
12657
+ this.#tries = { ["ALL"]: new Trie() };
12805
12658
  }
12806
- add(method, path, handler) {
12807
- const middleware = this.#middleware;
12808
- const routes = this.#routes;
12809
- if (!middleware || !routes) {
12810
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
12811
- }
12812
- if (!middleware[method]) {
12813
- ;
12814
- [middleware, routes].forEach((handlerMap) => {
12815
- handlerMap[method] = /* @__PURE__ */ Object.create(null);
12816
- Object.keys(handlerMap[METHOD_NAME_ALL]).forEach((p) => {
12817
- handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
12818
- });
12819
- });
12820
- }
12821
- if (path === "/*") {
12822
- path = "*";
12823
- }
12824
- const paramCount = (path.match(/\/:/g) || []).length;
12825
- if (/\*$/.test(path)) {
12826
- const re = buildWildcardRegExp(path);
12827
- if (method === METHOD_NAME_ALL) {
12828
- Object.keys(middleware).forEach((m) => {
12829
- middleware[m][path] ||= findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
12830
- });
12831
- } else {
12832
- middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
12833
- }
12834
- Object.keys(middleware).forEach((m) => {
12835
- if (method === METHOD_NAME_ALL || method === m) {
12836
- Object.keys(middleware[m]).forEach((p) => {
12837
- re.test(p) && middleware[m][p].push([handler, paramCount]);
12838
- });
12839
- }
12840
- });
12841
- Object.keys(routes).forEach((m) => {
12842
- if (method === METHOD_NAME_ALL || method === m) {
12843
- Object.keys(routes[m]).forEach(
12844
- (p) => re.test(p) && routes[m][p].push([handler, paramCount])
12845
- );
12846
- }
12847
- });
12848
- return;
12659
+ #insertPath(method, path) {
12660
+ try {
12661
+ this.#tries[method].insert(path, !/\*|\/:/.test(path));
12662
+ } catch (e) {
12663
+ throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
12849
12664
  }
12665
+ }
12666
+ add(method, path, handler) {
12667
+ const handlers = this.#handlers;
12668
+ if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
12669
+ const tries = this.#tries;
12670
+ if (!handlers[method]) {
12671
+ tries[method] = new Trie();
12672
+ handlers[method] = [...handlers["ALL"]];
12673
+ for (const p in tries["ALL"].paths) this.#insertPath(method, p);
12674
+ }
12675
+ if (path === "/*") path = "*";
12676
+ const methods = method === "ALL" ? Object.keys(handlers) : [method];
12850
12677
  const paths = checkOptionalParameter(path) || [path];
12851
- for (let i = 0, len = paths.length; i < len; i++) {
12852
- const path2 = paths[i];
12853
- Object.keys(routes).forEach((m) => {
12854
- if (method === METHOD_NAME_ALL || method === m) {
12855
- routes[m][path2] ||= [
12856
- ...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
12857
- ];
12858
- routes[m][path2].push([handler, paramCount - len + i + 1]);
12859
- }
12860
- });
12678
+ for (const path2 of paths) for (const m of methods) {
12679
+ if (!tries[m].paths[path2]) this.#insertPath(m, path2);
12680
+ handlers[m].push([handler, path2]);
12861
12681
  }
12862
12682
  }
12863
12683
  match = match;
12864
12684
  buildAllMatchers() {
12865
- const matchers = /* @__PURE__ */ Object.create(null);
12866
- Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
12867
- matchers[method] ||= this.#buildMatcher(method);
12868
- });
12869
- this.#middleware = this.#routes = void 0;
12870
- clearWildcardRegExpCache();
12685
+ const matchers = createNullObject();
12686
+ for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
12687
+ this.#handlers = this.#tries = void 0;
12871
12688
  return matchers;
12872
12689
  }
12873
12690
  #buildMatcher(method) {
12874
- const routes = [];
12875
- let hasOwnRoute = method === METHOD_NAME_ALL;
12876
- [this.#middleware, this.#routes].forEach((r) => {
12877
- const ownRoute = r[method] ? Object.keys(r[method]).map((path) => [path, r[method][path]]) : [];
12878
- if (ownRoute.length !== 0) {
12879
- hasOwnRoute ||= true;
12880
- routes.push(...ownRoute);
12881
- } else if (method !== METHOD_NAME_ALL) {
12882
- routes.push(
12883
- ...Object.keys(r[METHOD_NAME_ALL]).map((path) => [path, r[METHOD_NAME_ALL][path]])
12884
- );
12885
- }
12691
+ const handlers = this.#handlers[method];
12692
+ const trie = this.#tries[method];
12693
+ const staticMap = createNullObject();
12694
+ const handlerData = [];
12695
+ const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
12696
+ const own = createNullObject();
12697
+ const entries = handlers.map(([h, p], i) => {
12698
+ (own[p] ??= []).push(i);
12699
+ return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
12700
+ map[key] = paramReplacementMap[varIndex];
12701
+ return map;
12702
+ }, createNullObject())];
12886
12703
  });
12887
- if (!hasOwnRoute) {
12888
- return null;
12889
- } else {
12890
- return buildMatcherFromPreprocessedRoutes(routes);
12704
+ const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
12705
+ for (const path in trie.paths) {
12706
+ const [index, , keys] = trie.paths[path];
12707
+ const indexes = [...own[path]];
12708
+ for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
12709
+ const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
12710
+ if (index === -1) {
12711
+ const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
12712
+ staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
12713
+ } else handlerData[index] = data;
12891
12714
  }
12715
+ return [
12716
+ regexp,
12717
+ indexReplacementMap.map((i) => handlerData[i]),
12718
+ staticMap
12719
+ ];
12892
12720
  }
12893
12721
  };
12894
12722
 
12895
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/smart-router/router.js
12723
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/smart-router/router.js
12896
12724
  var SmartRouter = class {
12897
12725
  static {
12898
12726
  __name(this, "SmartRouter");
@@ -12904,15 +12732,15 @@ var SmartRouter = class {
12904
12732
  this.#routers = init.routers;
12905
12733
  }
12906
12734
  add(method, path, handler) {
12907
- if (!this.#routes) {
12908
- throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
12909
- }
12910
- this.#routes.push([method, path, handler]);
12735
+ if (!this.#routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
12736
+ this.#routes.push([
12737
+ method,
12738
+ path,
12739
+ handler
12740
+ ]);
12911
12741
  }
12912
12742
  match(method, path) {
12913
- if (!this.#routes) {
12914
- throw new Error("Fatal error");
12915
- }
12743
+ if (!this.#routes) throw new Error("Fatal error");
12916
12744
  const routers = this.#routers;
12917
12745
  const routes = this.#routes;
12918
12746
  const len = routers.length;
@@ -12921,14 +12749,10 @@ var SmartRouter = class {
12921
12749
  for (; i < len; i++) {
12922
12750
  const router = routers[i];
12923
12751
  try {
12924
- for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) {
12925
- router.add(...routes[i2]);
12926
- }
12752
+ for (let i2 = 0, len2 = routes.length; i2 < len2; i2++) router.add(...routes[i2]);
12927
12753
  res = router.match(method, path);
12928
12754
  } catch (e) {
12929
- if (e instanceof UnsupportedPathError) {
12930
- continue;
12931
- }
12755
+ if (e instanceof UnsupportedPathError) continue;
12932
12756
  throw e;
12933
12757
  }
12934
12758
  this.match = router.match.bind(router);
@@ -12936,95 +12760,62 @@ var SmartRouter = class {
12936
12760
  this.#routes = void 0;
12937
12761
  break;
12938
12762
  }
12939
- if (i === len) {
12940
- throw new Error("Fatal error");
12941
- }
12763
+ if (i === len) throw new Error("Fatal error");
12942
12764
  this.name = `SmartRouter + ${this.activeRouter.name}`;
12943
12765
  return res;
12944
12766
  }
12945
12767
  get activeRouter() {
12946
- if (this.#routes || this.#routers.length !== 1) {
12947
- throw new Error("No active router has been determined yet.");
12948
- }
12768
+ if (this.#routes || this.#routers.length !== 1) throw new Error("No active router has been determined yet.");
12949
12769
  return this.#routers[0];
12950
12770
  }
12951
12771
  };
12952
12772
 
12953
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/trie-router/node.js
12954
- var emptyParams = /* @__PURE__ */ Object.create(null);
12955
- var hasChildren = /* @__PURE__ */ __name((children) => {
12956
- for (const _ in children) {
12957
- return true;
12958
- }
12959
- return false;
12960
- }, "hasChildren");
12961
- var Node2 = class _Node2 {
12773
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/trie-router/node.js
12774
+ var emptyParams = createNullObject();
12775
+ var order = 0;
12776
+ var Node3 = class Node4 {
12962
12777
  static {
12963
- __name(this, "_Node");
12778
+ __name(this, "Node");
12964
12779
  }
12965
- #methods;
12966
- #children;
12967
- #patterns;
12968
- #order = 0;
12780
+ #methods = [];
12781
+ #children = createNullObject();
12782
+ #patterns = [];
12783
+ #pattern;
12969
12784
  #params = emptyParams;
12970
- constructor(method, handler, children) {
12971
- this.#children = children || /* @__PURE__ */ Object.create(null);
12972
- this.#methods = [];
12973
- if (method && handler) {
12974
- const m = /* @__PURE__ */ Object.create(null);
12975
- m[method] = { handler, possibleKeys: [], score: 0 };
12976
- this.#methods = [m];
12977
- }
12978
- this.#patterns = [];
12979
- }
12980
12785
  insert(method, path, handler) {
12981
- this.#order = ++this.#order;
12982
12786
  let curNode = this;
12983
12787
  const parts = splitRoutingPath(path);
12984
- const possibleKeys = [];
12985
- for (let i = 0, len = parts.length; i < len; i++) {
12986
- const p = parts[i];
12987
- const nextP = parts[i + 1];
12988
- const pattern = getPattern(p, nextP);
12989
- const key = Array.isArray(pattern) ? pattern[0] : p;
12990
- if (key in curNode.#children) {
12991
- curNode = curNode.#children[key];
12992
- if (pattern) {
12993
- possibleKeys.push(pattern[1]);
12994
- }
12995
- continue;
12996
- }
12997
- curNode.#children[key] = new _Node2();
12998
- if (pattern) {
12999
- curNode.#patterns.push(pattern);
13000
- possibleKeys.push(pattern[1]);
12788
+ const possibleKeys = /* @__PURE__ */ new Set();
12789
+ let i = 0;
12790
+ for (const p of parts) {
12791
+ const nextP = parts[++i];
12792
+ const pattern = getPattern(p, nextP) || (nextP === void 0 && p && p.indexOf("*") === p.length - 1 ? p : null);
12793
+ const isParam = Array.isArray(pattern);
12794
+ const key = isParam ? pattern[0] : pattern || p;
12795
+ const child = curNode.#children[key] ||= new Node4();
12796
+ if (pattern && !child.#pattern) {
12797
+ child.#pattern = pattern;
12798
+ curNode.#patterns.push(child);
13001
12799
  }
13002
- curNode = curNode.#children[key];
12800
+ curNode = child;
12801
+ if (isParam) possibleKeys.add(pattern[1]);
13003
12802
  }
13004
- curNode.#methods.push({
13005
- [method]: {
13006
- handler,
13007
- possibleKeys: possibleKeys.filter((v, i, a) => a.indexOf(v) === i),
13008
- score: this.#order
13009
- }
13010
- });
13011
- return curNode;
12803
+ curNode.#methods.push({ [method]: {
12804
+ handler,
12805
+ possibleKeys: [...possibleKeys],
12806
+ score: ++order
12807
+ } });
13012
12808
  }
13013
12809
  #pushHandlerSets(handlerSets, node, method, nodeParams, params) {
13014
12810
  for (let i = 0, len = node.#methods.length; i < len; i++) {
13015
12811
  const m = node.#methods[i];
13016
- const handlerSet = m[method] || m[METHOD_NAME_ALL];
13017
- const processedSet = {};
13018
- if (handlerSet !== void 0) {
13019
- handlerSet.params = /* @__PURE__ */ Object.create(null);
12812
+ const handlerSet = m[method] || m["ALL"];
12813
+ if (handlerSet) {
12814
+ handlerSet.params = createNullObject();
13020
12815
  handlerSets.push(handlerSet);
13021
- if (nodeParams !== emptyParams || params && params !== emptyParams) {
13022
- for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
13023
- const key = handlerSet.possibleKeys[i2];
13024
- const processed = processedSet[handlerSet.score];
13025
- handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
13026
- processedSet[handlerSet.score] = true;
13027
- }
12816
+ for (let i2 = 0, len2 = handlerSet.possibleKeys.length; i2 < len2; i2++) {
12817
+ const key = handlerSet.possibleKeys[i2];
12818
+ handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
13028
12819
  }
13029
12820
  }
13030
12821
  }
@@ -13032,8 +12823,7 @@ var Node2 = class _Node2 {
13032
12823
  search(method, path) {
13033
12824
  const handlerSets = [];
13034
12825
  this.#params = emptyParams;
13035
- const curNode = this;
13036
- let curNodes = [curNode];
12826
+ let curNodes = [this];
13037
12827
  const parts = splitPath(path);
13038
12828
  const curNodesQueue = [];
13039
12829
  const len = parts.length;
@@ -13048,76 +12838,54 @@ var Node2 = class _Node2 {
13048
12838
  if (nextNode) {
13049
12839
  nextNode.#params = node.#params;
13050
12840
  if (isLast) {
13051
- if (nextNode.#children["*"]) {
13052
- this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
13053
- }
12841
+ if (nextNode.#children["*"]) this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node.#params);
13054
12842
  this.#pushHandlerSets(handlerSets, nextNode, method, node.#params);
13055
- } else {
13056
- tempNodes.push(nextNode);
13057
- }
12843
+ } else tempNodes.push(nextNode);
13058
12844
  }
13059
- for (let k = 0, len3 = node.#patterns.length; k < len3; k++) {
13060
- const pattern = node.#patterns[k];
12845
+ for (const child of node.#patterns) {
12846
+ const pattern = child.#pattern;
13061
12847
  const params = node.#params === emptyParams ? {} : { ...node.#params };
13062
- if (pattern === "*") {
13063
- const astNode = node.#children["*"];
13064
- if (astNode) {
13065
- this.#pushHandlerSets(handlerSets, astNode, method, node.#params);
13066
- astNode.#params = params;
13067
- tempNodes.push(astNode);
12848
+ if (typeof pattern === "string") {
12849
+ if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
12850
+ this.#pushHandlerSets(handlerSets, child, method, node.#params);
12851
+ if (pattern === "*") {
12852
+ child.#params = params;
12853
+ tempNodes.push(child);
12854
+ }
13068
12855
  }
13069
12856
  continue;
13070
12857
  }
13071
- const [key, name, matcher] = pattern;
13072
- if (!part && !(matcher instanceof RegExp)) {
13073
- continue;
13074
- }
13075
- const child = node.#children[key];
13076
- if (matcher instanceof RegExp) {
13077
- if (partOffsets === null) {
13078
- partOffsets = new Array(len);
12858
+ const [, name, matcher] = pattern;
12859
+ if (!part && matcher === true) continue;
12860
+ if (matcher !== true) {
12861
+ if (!partOffsets) {
12862
+ partOffsets = [];
13079
12863
  let offset = path[0] === "/" ? 1 : 0;
13080
12864
  for (let p = 0; p < len; p++) {
13081
12865
  partOffsets[p] = offset;
13082
12866
  offset += parts[p].length + 1;
13083
12867
  }
13084
12868
  }
13085
- const restPathString = path.substring(partOffsets[i]);
12869
+ const restPathString = path.slice(partOffsets[i]);
13086
12870
  const m = matcher.exec(restPathString);
13087
12871
  if (m) {
13088
- params[name] = m[0];
12872
+ if (!Object.hasOwn(params, name)) params[name] = m[0];
13089
12873
  this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
13090
- if (m[0].length === restPathString.length && child.#children["*"]) {
13091
- this.#pushHandlerSets(
13092
- handlerSets,
13093
- child.#children["*"],
13094
- method,
13095
- node.#params,
13096
- params
13097
- );
13098
- }
13099
- if (hasChildren(child.#children)) {
12874
+ if (m[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
12875
+ for (const _ in child.#children) {
13100
12876
  child.#params = params;
13101
- const componentCount = m[0].match(/\//)?.length ?? 0;
13102
- const targetCurNodes = curNodesQueue[componentCount] ||= [];
13103
- targetCurNodes.push(child);
12877
+ const componentCount = m[0].match(/\//g)?.length ?? 0;
12878
+ (curNodesQueue[componentCount] ||= []).push(child);
12879
+ break;
13104
12880
  }
13105
12881
  continue;
13106
12882
  }
13107
12883
  }
13108
12884
  if (matcher === true || matcher.test(part)) {
13109
- params[name] = part;
12885
+ if (!Object.hasOwn(params, name)) params[name] = part;
13110
12886
  if (isLast) {
13111
12887
  this.#pushHandlerSets(handlerSets, child, method, params, node.#params);
13112
- if (child.#children["*"]) {
13113
- this.#pushHandlerSets(
13114
- handlerSets,
13115
- child.#children["*"],
13116
- method,
13117
- params,
13118
- node.#params
13119
- );
13120
- }
12888
+ if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node.#params);
13121
12889
  } else {
13122
12890
  child.#params = params;
13123
12891
  tempNodes.push(child);
@@ -13128,55 +12896,41 @@ var Node2 = class _Node2 {
13128
12896
  const shifted = curNodesQueue.shift();
13129
12897
  curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
13130
12898
  }
13131
- if (handlerSets.length > 1) {
13132
- handlerSets.sort((a, b) => {
13133
- return a.score - b.score;
13134
- });
13135
- }
12899
+ if (handlerSets[1]) handlerSets.sort((a, b) => {
12900
+ return a.score - b.score;
12901
+ });
13136
12902
  return [handlerSets.map(({ handler, params }) => [handler, params])];
13137
12903
  }
13138
12904
  };
13139
12905
 
13140
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/router/trie-router/router.js
12906
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/router/trie-router/router.js
13141
12907
  var TrieRouter = class {
13142
12908
  static {
13143
12909
  __name(this, "TrieRouter");
13144
12910
  }
13145
12911
  name = "TrieRouter";
13146
- #node;
13147
- constructor() {
13148
- this.#node = new Node2();
13149
- }
12912
+ #node = new Node3();
13150
12913
  add(method, path, handler) {
13151
- const results = checkOptionalParameter(path);
13152
- if (results) {
13153
- for (let i = 0, len = results.length; i < len; i++) {
13154
- this.#node.insert(method, results[i], handler);
13155
- }
13156
- return;
13157
- }
13158
- this.#node.insert(method, path, handler);
12914
+ for (const result of checkOptionalParameter(path) || [path]) this.#node.insert(method, result, handler);
13159
12915
  }
13160
12916
  match(method, path) {
13161
12917
  return this.#node.search(method, path);
13162
12918
  }
13163
12919
  };
13164
12920
 
13165
- // ../../node_modules/.pnpm/hono@4.12.34/node_modules/hono/dist/hono.js
13166
- var Hono2 = class extends Hono {
12921
+ // ../../node_modules/.pnpm/hono@4.13.21/node_modules/hono/dist/hono.js
12922
+ var Hono3 = class extends Hono {
13167
12923
  static {
13168
12924
  __name(this, "Hono");
13169
12925
  }
13170
12926
  /**
13171
- * Creates an instance of the Hono class.
13172
- *
13173
- * @param options - Optional configuration options for the Hono instance.
13174
- */
12927
+ * Creates an instance of the Hono class.
12928
+ *
12929
+ * @param options - Optional configuration options for the Hono instance.
12930
+ */
13175
12931
  constructor(options = {}) {
13176
12932
  super(options);
13177
- this.router = options.router ?? new SmartRouter({
13178
- routers: [new RegExpRouter(), new TrieRouter()]
13179
- });
12933
+ this.router = options.router ?? new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
13180
12934
  }
13181
12935
  };
13182
12936
 
@@ -13460,7 +13214,7 @@ var hotUpdater = createHotUpdater({
13460
13214
  }
13461
13215
  })
13462
13216
  });
13463
- var app = new Hono2();
13217
+ var app = new Hono3();
13464
13218
  app.mount(
13465
13219
  HOT_UPDATER_BASE_PATH,
13466
13220
  (request) => hotUpdater.handlers.client(request)