cf-nix-cache 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { DurableObject, WorkerEntrypoint, WorkflowEntrypoint } from "cloudflare:workers";
2
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/request/constants.js
2
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/request/constants.js
3
3
  var GET_MATCH_RESULT = Symbol();
4
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/utils/buffer.js
4
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/buffer.js
5
5
  var bufferToFormData = (arrayBuffer, contentType) => {
6
6
  return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
7
7
  };
8
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/utils/body.js
8
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/body.js
9
9
  var MAX_NESTED_OBJECTS = 1e4;
10
10
  var isRawRequest = (request) => "headers" in request;
11
11
  var parseBody = async (request, options = Object.create(null)) => {
@@ -97,7 +97,7 @@ var handleParsingNestedValues = (form, key, value, state) => {
97
97
  var throwNestingLimitExceeded = () => {
98
98
  throw new Error("Nesting limit exceeded");
99
99
  };
100
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/utils/url.js
100
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/url.js
101
101
  var splitPath = (path) => {
102
102
  const paths = path.split("/");
103
103
  if (paths[0] === "") paths.shift();
@@ -198,6 +198,15 @@ var getPathNoStrict = (request) => {
198
198
  const result = getPath$1(request);
199
199
  return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
200
200
  };
201
+ var stripPathPrefix = (rawPath, decodedPath, prefixLength) => {
202
+ if (rawPath.at(-1) === "/" && decodedPath.at(-1) !== "/") rawPath = rawPath.slice(0, -1);
203
+ let index = 0;
204
+ for (let i = decodedPath.indexOf("/"); i !== -1 && i < prefixLength; i = decodedPath.indexOf("/", i + 1)) {
205
+ index = rawPath.indexOf("/", index + 1);
206
+ if (index === -1) return "/";
207
+ }
208
+ return rawPath.slice(index) || "/";
209
+ };
201
210
  /**
202
211
  * Merge paths.
203
212
  * @param {string[]} ...paths - The paths to merge.
@@ -290,7 +299,7 @@ var getQueryParams = (url, key) => {
290
299
  return _getQueryParam(url, key, true);
291
300
  };
292
301
  var decodeURIComponent_ = decodeURIComponent;
293
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/request.js
302
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/request.js
294
303
  var HonoRequest = class {
295
304
  /**
296
305
  * `.raw` can get the raw Request object.
@@ -559,7 +568,7 @@ var HonoRequest = class {
559
568
  return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
560
569
  }
561
570
  };
562
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/utils/html.js
571
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/html.js
563
572
  /**
564
573
  * @module
565
574
  * HTML utility.
@@ -592,7 +601,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
592
601
  if (preserveCallbacks) return raw(await resStr, callbacks);
593
602
  else return resStr;
594
603
  };
595
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/context.js
604
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/context.js
596
605
  var TEXT_PLAIN = "text/plain; charset=UTF-8";
597
606
  var setDefaultContentType = (contentType, headers) => {
598
607
  return {
@@ -789,7 +798,7 @@ var Context = class {
789
798
  * ```
790
799
  */
791
800
  header = (name, value, options) => {
792
- if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
801
+ if (this.finalized && !this.#res.bodyUsed) this.#res = createResponseInstance(this.#res.body, this.#res);
793
802
  const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
794
803
  if (value === void 0) headers.delete(name);
795
804
  else if (options?.append) headers.append(name, value);
@@ -968,7 +977,7 @@ var Context = class {
968
977
  return this.#notFoundHandler(this);
969
978
  };
970
979
  };
971
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/compose.js
980
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/compose.js
972
981
  /**
973
982
  * Compose middleware functions into a single function based on `koa-compose` package.
974
983
  *
@@ -1016,7 +1025,7 @@ var compose = (middleware, onError, onNotFound) => {
1016
1025
  }
1017
1026
  };
1018
1027
  };
1019
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router.js
1028
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router.js
1020
1029
  /**
1021
1030
  * Array of supported HTTP methods.
1022
1031
  */
@@ -1037,12 +1046,42 @@ var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is
1037
1046
  * Error class representing an unsupported path error.
1038
1047
  */
1039
1048
  var UnsupportedPathError = class extends Error {};
1040
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/utils/constants.js
1049
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/constants.js
1041
1050
  /**
1042
1051
  * Constant used to mark a composed handler.
1043
1052
  */
1044
1053
  var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
1045
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/hono-base.js
1054
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/utils/mount.js
1055
+ var getPathPrefixLength = (c, pathPrefix, routePath) => {
1056
+ if (!/[:*]/.test(pathPrefix)) return pathPrefix.length;
1057
+ const path = c.req.path;
1058
+ const matchResult = c.req[GET_MATCH_RESULT];
1059
+ const paramNames = /* @__PURE__ */ new Set();
1060
+ let length = 0;
1061
+ for (const part of splitRoutingPath(pathPrefix)) {
1062
+ const pattern = getPattern(part);
1063
+ if (pattern && pattern !== "*") {
1064
+ const name = pattern[1];
1065
+ if (paramNames.has(name)) throw new Error(`mount(): Duplicate path parameter "${name}" in "${routePath}".`);
1066
+ paramNames.add(name);
1067
+ }
1068
+ if (pattern && pattern !== "*" && pattern[2] !== true) {
1069
+ const value = matchResult.length === 2 ? matchResult[1][matchResult[0][c.req.routeIndex][1][pattern[1]]] : matchResult[0][c.req.routeIndex][1][pattern[1]];
1070
+ length += value.length + 1;
1071
+ } else if (pattern || part.endsWith("*")) {
1072
+ const end = path.indexOf("/", length + 1);
1073
+ length = end === -1 ? path.length : end;
1074
+ } else length += part.length + 1;
1075
+ }
1076
+ return length;
1077
+ };
1078
+ var createMountedRequest = (c, pathPrefix, routePath) => {
1079
+ if (/[^/]\*$/.test(routePath)) throw new Error(`mount(): Wildcard must follow "/" in "${routePath}".`);
1080
+ const url = new URL(c.req.raw.url);
1081
+ url.pathname = stripPathPrefix(url.pathname, c.req.path, getPathPrefixLength(c, pathPrefix, routePath));
1082
+ return new Request(url, c.req.raw);
1083
+ };
1084
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/hono-base.js
1046
1085
  /**
1047
1086
  * @module
1048
1087
  * This module is the base module for the Hono object.
@@ -1266,17 +1305,10 @@ var Hono$1 = class Hono {
1266
1305
  } catch {}
1267
1306
  return [c.env, executionContext];
1268
1307
  };
1269
- replaceRequest ||= (() => {
1270
- const mergedPath = mergePath(this._basePath, path);
1271
- const pathPrefixLength = mergedPath === "/" ? 0 : mergedPath.length;
1272
- return (request) => {
1273
- const url = new URL(request.url);
1274
- url.pathname = this.getPath(request).slice(pathPrefixLength) || "/";
1275
- return new Request(url, request);
1276
- };
1277
- })();
1308
+ const mergedPath = mergePath(this._basePath, path);
1309
+ const defaultReplaceRequest = (c) => createMountedRequest(c, mergedPath.replace(/\/$/, ""), mergePath(mergedPath, "*"));
1278
1310
  const handler = async (c, next) => {
1279
- const res = await applicationHandler(replaceRequest(c.req.raw), ...getOptions(c));
1311
+ const res = await applicationHandler(replaceRequest ? replaceRequest(c.req.raw) : defaultReplaceRequest(c), ...getOptions(c));
1280
1312
  if (res) return res;
1281
1313
  await next();
1282
1314
  };
@@ -1385,9 +1417,9 @@ var Hono$1 = class Hono {
1385
1417
  });
1386
1418
  };
1387
1419
  };
1388
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/utils.js
1420
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/utils.js
1389
1421
  var createNullObject = () => Object.create(null);
1390
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/reg-exp-router/matcher.js
1422
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/reg-exp-router/matcher.js
1391
1423
  var emptyParam = [];
1392
1424
  function match(method, path) {
1393
1425
  const matchers = this.buildAllMatchers();
@@ -1403,9 +1435,10 @@ function match(method, path) {
1403
1435
  this.match = match;
1404
1436
  return match(method, path);
1405
1437
  }
1406
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/reg-exp-router/node.js
1438
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/reg-exp-router/node.js
1407
1439
  var LABEL_REG_EXP_STR = "[^/]+";
1408
- var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
1440
+ var ONLY_WILDCARD_REG_EXP_STR = "[^]*";
1441
+ var TAIL_WILDCARD_REG_EXP_STR = "(?:|/[^]*)";
1409
1442
  var PATH_ERROR = Symbol();
1410
1443
  var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
1411
1444
  /**
@@ -1418,8 +1451,8 @@ var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
1418
1451
  function compareKey(a, b) {
1419
1452
  if (a.length === 1) return b.length === 1 ? a < b ? -1 : 1 : -1;
1420
1453
  if (b.length === 1) return 1;
1421
- if (a === ".*" || a === "(?:|/.*)") return b === "(?:|/.*)" ? -1 : 1;
1422
- else if (b === ".*" || b === "(?:|/.*)") return -1;
1454
+ if (a === "[^]*" || a === "(?:|/[^]*)") return b === "[^]*" ? -1 : 1;
1455
+ else if (b === "[^]*" || b === "(?:|/[^]*)") return -1;
1423
1456
  if (a === "[^/]+") return 1;
1424
1457
  else if (b === "[^/]+") return -1;
1425
1458
  return a.length === b.length ? a < b ? -1 : 1 : b.length - a.length;
@@ -1428,14 +1461,14 @@ var Node$1 = class Node {
1428
1461
  #index;
1429
1462
  #varIndex;
1430
1463
  #children = createNullObject();
1431
- insert(tokens, index, paramMap, context, isStatic) {
1464
+ insert(tokens, index, paramMap, context, keys) {
1432
1465
  let node = this;
1433
1466
  for (let i = 0, len = tokens.length; i < len; i++) {
1434
1467
  const token = tokens[i];
1435
1468
  const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? [
1436
1469
  "",
1437
1470
  "",
1438
- ".*"
1471
+ ONLY_WILDCARD_REG_EXP_STR
1439
1472
  ] : [
1440
1473
  "",
1441
1474
  "",
@@ -1450,15 +1483,16 @@ var Node$1 = class Node {
1450
1483
  const name = pattern[1];
1451
1484
  let regexpStr = pattern[2] || "[^/]+";
1452
1485
  if (name && pattern[2]) {
1453
- if (regexpStr === ".*") throw PATH_ERROR;
1486
+ if (new RegExp(regexpStr).test("")) throw PATH_ERROR;
1454
1487
  regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
1455
1488
  if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
1456
1489
  if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
1457
1490
  }
1491
+ keys.push(regexpStr);
1458
1492
  nextNode = node.#children[regexpStr];
1459
1493
  if (!nextNode) {
1460
- if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
1461
- for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
1494
+ if (regexpStr !== "[^]*" && regexpStr !== "(?:|/[^]*)") {
1495
+ for (const k in node.#children) if ((regexpStr.length > 1 || k.length > 1) && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
1462
1496
  }
1463
1497
  nextNode = node.#children[regexpStr] = new Node();
1464
1498
  }
@@ -1467,16 +1501,17 @@ var Node$1 = class Node {
1467
1501
  paramMap.push([name, nextNode.#varIndex]);
1468
1502
  }
1469
1503
  } else {
1504
+ keys.push(token);
1470
1505
  nextNode = node.#children[token];
1471
1506
  if (!nextNode) {
1472
- for (const k in node.#children) if (k.length > 1 && k !== ".*" && k !== "(?:|/.*)") throw PATH_ERROR;
1507
+ for (const k in node.#children) if (k.length > 1 && k !== "[^]*" && k !== "(?:|/[^]*)") throw PATH_ERROR;
1473
1508
  nextNode = node.#children[token] = new Node();
1474
1509
  }
1475
1510
  }
1476
1511
  node = nextNode;
1477
1512
  }
1478
1513
  if (node.#index !== void 0) throw PATH_ERROR;
1479
- node.#index = isStatic ? -1 : index;
1514
+ node.#index = index;
1480
1515
  }
1481
1516
  buildRegExpStr() {
1482
1517
  const strList = Object.keys(this.#children).sort(compareKey).map((k) => {
@@ -1490,15 +1525,21 @@ var Node$1 = class Node {
1490
1525
  return "(?:" + strList.join("|") + ")";
1491
1526
  }
1492
1527
  };
1493
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/reg-exp-router/trie.js
1528
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/reg-exp-router/trie.js
1494
1529
  var Trie = class {
1495
1530
  #context = { varIndex: 0 };
1496
1531
  #root = new Node$1();
1497
1532
  #index = 0;
1498
1533
  paths = createNullObject();
1499
1534
  insert(path, isStatic) {
1535
+ const keys = [];
1500
1536
  if (isStatic) {
1501
- this.#root.insert(path.split(""), 0, [], this.#context, true);
1537
+ this.#root.insert(path.split(""), -1, [], this.#context, keys);
1538
+ this.paths[path] = [
1539
+ -1,
1540
+ [],
1541
+ keys
1542
+ ];
1502
1543
  return;
1503
1544
  }
1504
1545
  const paramAssoc = [];
@@ -1506,7 +1547,7 @@ var Trie = class {
1506
1547
  let markedPath = path;
1507
1548
  for (let i = 0;;) {
1508
1549
  let replaced = false;
1509
- markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
1550
+ markedPath = markedPath.replace(/\{(?:\{[\d,]+\}|[^}])+\}/g, (m) => {
1510
1551
  const mark = `@\\${i}`;
1511
1552
  groups[i] = [mark, m];
1512
1553
  i++;
@@ -1520,7 +1561,7 @@ var Trie = class {
1520
1561
  * - /* wildcard
1521
1562
  * - character
1522
1563
  */
1523
- const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
1564
+ const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./gs) || [];
1524
1565
  for (let i = groups.length - 1; i >= 0; i--) {
1525
1566
  const [mark] = groups[i];
1526
1567
  for (let j = tokens.length - 1; j >= 0; j--) if (tokens[j].indexOf(mark) !== -1) {
@@ -1528,8 +1569,12 @@ var Trie = class {
1528
1569
  break;
1529
1570
  }
1530
1571
  }
1531
- this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
1532
- this.paths[path] = [this.#index++, paramAssoc];
1572
+ this.#root.insert(tokens, this.#index, paramAssoc, this.#context, keys);
1573
+ this.paths[path] = [
1574
+ this.#index++,
1575
+ paramAssoc,
1576
+ keys
1577
+ ];
1533
1578
  }
1534
1579
  buildRegExp() {
1535
1580
  let regexp = this.#root.buildRegExpStr();
@@ -1559,22 +1604,22 @@ var Trie = class {
1559
1604
  ];
1560
1605
  }
1561
1606
  };
1562
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/reg-exp-router/router.js
1563
- var wildcardRegExpCache = createNullObject();
1564
- function buildWildcardRegExp(path) {
1565
- return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match, metaChar) => metaChar ? `\\${metaChar}` : match === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
1607
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/reg-exp-router/router.js
1608
+ function endsWithWildcard(keys) {
1609
+ const tail = keys[keys.length - 1];
1610
+ return tail === "[^]*" || tail === "(?:|/[^]*)";
1566
1611
  }
1567
- function findMiddleware(middleware, path) {
1568
- for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) if (buildWildcardRegExp(k).test(path)) return [...middleware[k]];
1612
+ function covers(wildcard, target) {
1613
+ const last = wildcard.length - 1;
1614
+ for (let i = 0; i < last; i++) if (wildcard[i] !== target[i]) return false;
1615
+ return wildcard[last] === "[^]*" || target.length === last || target[last] === "/";
1569
1616
  }
1570
1617
  var RegExpRouter = class {
1571
1618
  name = "RegExpRouter";
1572
- #middleware;
1573
- #routes;
1619
+ #handlers;
1574
1620
  #tries;
1575
1621
  constructor() {
1576
- this.#middleware = { ["ALL"]: createNullObject() };
1577
- this.#routes = { ["ALL"]: createNullObject() };
1622
+ this.#handlers = { ["ALL"]: [] };
1578
1623
  this.#tries = { ["ALL"]: new Trie() };
1579
1624
  }
1580
1625
  #insertPath(method, path) {
@@ -1585,65 +1630,53 @@ var RegExpRouter = class {
1585
1630
  }
1586
1631
  }
1587
1632
  add(method, path, handler) {
1588
- const middleware = this.#middleware;
1589
- const routes = this.#routes;
1590
- if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1591
- if (!middleware[method]) {
1592
- this.#tries[method] = new Trie();
1593
- for (const handlerMap of [middleware, routes]) {
1594
- handlerMap[method] = createNullObject();
1595
- for (const p in handlerMap["ALL"]) {
1596
- handlerMap[method][p] = [...handlerMap["ALL"][p]];
1597
- this.#insertPath(method, p);
1598
- }
1599
- }
1633
+ const handlers = this.#handlers;
1634
+ if (!handlers) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
1635
+ const tries = this.#tries;
1636
+ if (!handlers[method]) {
1637
+ tries[method] = new Trie();
1638
+ handlers[method] = [...handlers["ALL"]];
1639
+ for (const p in tries["ALL"].paths) this.#insertPath(method, p);
1600
1640
  }
1601
1641
  if (path === "/*") path = "*";
1602
- const methods = method === "ALL" ? Object.keys(middleware) : [method];
1603
- if (/\*$/.test(path)) {
1604
- const re = buildWildcardRegExp(path);
1605
- for (const m of methods) if (!middleware[m][path]) {
1606
- this.#insertPath(m, path);
1607
- middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
1608
- }
1609
- for (const handlerMap of [middleware, routes]) for (const m of methods) for (const p in handlerMap[m]) re.test(p) && handlerMap[m][p].push([handler, path]);
1610
- return;
1611
- }
1642
+ const methods = method === "ALL" ? Object.keys(handlers) : [method];
1612
1643
  const paths = checkOptionalParameter(path) || [path];
1613
1644
  for (const path of paths) for (const m of methods) {
1614
- if (!routes[m][path]) {
1615
- this.#insertPath(m, path);
1616
- routes[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware["ALL"], path) || [];
1617
- }
1618
- routes[m][path].push([handler, path]);
1645
+ if (!tries[m].paths[path]) this.#insertPath(m, path);
1646
+ handlers[m].push([handler, path]);
1619
1647
  }
1620
1648
  }
1621
1649
  match = match;
1622
1650
  buildAllMatchers() {
1623
1651
  const matchers = createNullObject();
1624
- for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
1625
- this.#middleware = this.#routes = this.#tries = void 0;
1626
- wildcardRegExpCache = createNullObject();
1652
+ for (const method of Object.keys(this.#handlers)) matchers[method] = this.#buildMatcher(method);
1653
+ this.#handlers = this.#tries = void 0;
1627
1654
  return matchers;
1628
1655
  }
1629
1656
  #buildMatcher(method) {
1630
- const middleware = this.#middleware[method];
1631
- const routes = this.#routes[method];
1657
+ const handlers = this.#handlers[method];
1632
1658
  const trie = this.#tries[method];
1633
1659
  const staticMap = createNullObject();
1634
1660
  const handlerData = [];
1635
1661
  const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
1636
- for (const r of [middleware, routes]) for (const path in r) {
1637
- const handlers = r[path];
1638
- const pathData = trie.paths[path];
1639
- if (!pathData) {
1640
- staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
1641
- continue;
1642
- }
1643
- handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [h, trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
1644
- map[key] = paramReplacementMap[pathData[1][i][1]];
1662
+ const own = createNullObject();
1663
+ const entries = handlers.map(([h, p], i) => {
1664
+ (own[p] ??= []).push(i);
1665
+ return [h, trie.paths[p][1].reduceRight((map, [key, varIndex]) => {
1666
+ map[key] = paramReplacementMap[varIndex];
1645
1667
  return map;
1646
- }, createNullObject())]);
1668
+ }, createNullObject())];
1669
+ });
1670
+ const wildcards = Object.keys(own).filter((p) => endsWithWildcard(trie.paths[p][2]));
1671
+ for (const path in trie.paths) {
1672
+ const [index, , keys] = trie.paths[path];
1673
+ const indexes = [...own[path]];
1674
+ for (const p of wildcards) if (p !== path && covers(trie.paths[p][2], keys)) indexes.push(...own[p]);
1675
+ const data = indexes.sort((a, b) => a - b).map((i) => entries[i]);
1676
+ if (index === -1) {
1677
+ const last = Math.max(-1, ...data.flatMap(([, map]) => Object.values(map)));
1678
+ staticMap[path] = [data, last === -1 ? emptyParam : path.match(regexp).slice(0, last + 1)];
1679
+ } else handlerData[index] = data;
1647
1680
  }
1648
1681
  return [
1649
1682
  regexp,
@@ -1652,7 +1685,7 @@ var RegExpRouter = class {
1652
1685
  ];
1653
1686
  }
1654
1687
  };
1655
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/smart-router/router.js
1688
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/smart-router/router.js
1656
1689
  var SmartRouter = class {
1657
1690
  name = "SmartRouter";
1658
1691
  #routers = [];
@@ -1698,7 +1731,7 @@ var SmartRouter = class {
1698
1731
  return this.#routers[0];
1699
1732
  }
1700
1733
  };
1701
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/trie-router/node.js
1734
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/trie-router/node.js
1702
1735
  var emptyParams = createNullObject();
1703
1736
  var order = 0;
1704
1737
  var Node = class Node {
@@ -1827,7 +1860,7 @@ var Node = class Node {
1827
1860
  return [handlerSets.map(({ handler, params }) => [handler, params])];
1828
1861
  }
1829
1862
  };
1830
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/router/trie-router/router.js
1863
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/router/trie-router/router.js
1831
1864
  var TrieRouter = class {
1832
1865
  name = "TrieRouter";
1833
1866
  #node = new Node();
@@ -1838,7 +1871,7 @@ var TrieRouter = class {
1838
1871
  return this.#node.search(method, path);
1839
1872
  }
1840
1873
  };
1841
- // ../../node_modules/.pnpm/hono@4.13.14/node_modules/hono/dist/hono.js
1874
+ // ../../node_modules/.pnpm/hono@4.13.16/node_modules/hono/dist/hono.js
1842
1875
  /**
1843
1876
  * The Hono class extends the functionality of the HonoBase class.
1844
1877
  * It sets up routing and allows for custom options to be passed.
@@ -1899,7 +1932,7 @@ var PublicationError = class extends Error {
1899
1932
  this.retryable = retryable;
1900
1933
  }
1901
1934
  };
1902
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/buffer_utils.js
1935
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/buffer_utils.js
1903
1936
  var encoder$2 = new TextEncoder();
1904
1937
  var decoder$1 = new TextDecoder();
1905
1938
  var strictDecoder = new TextDecoder("utf-8", { fatal: !0 });
@@ -1943,7 +1976,7 @@ function decodeBase64(encoded, url = !1) {
1943
1976
  for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
1944
1977
  return bytes;
1945
1978
  }
1946
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/util/errors.js
1979
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/util/errors.js
1947
1980
  var JOSEError = class extends Error {
1948
1981
  static code = "ERR_JOSE_GENERIC";
1949
1982
  code = "ERR_JOSE_GENERIC";
@@ -2021,7 +2054,7 @@ var JWSSignatureVerificationFailed = class extends JOSEError {
2021
2054
  super(message, options);
2022
2055
  }
2023
2056
  };
2024
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/util/base64url.js
2057
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/util/base64url.js
2025
2058
  var invalid$1 = "The input to be decoded is not correctly encoded.";
2026
2059
  function decode(input) {
2027
2060
  try {
@@ -2033,7 +2066,7 @@ function decode(input) {
2033
2066
  function encode(input) {
2034
2067
  return encodeBase64(typeof input == "string" ? encoder$2.encode(input) : input, !0);
2035
2068
  }
2036
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/validate.js
2069
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/validate.js
2037
2070
  function isObject(input) {
2038
2071
  if (typeof input != "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]") return !1;
2039
2072
  const prototype = Object.getPrototypeOf(input);
@@ -2123,7 +2156,7 @@ function serializeJoseHeader(Err, header) {
2123
2156
  if (!isObject(parsed)) throw new Err("JOSE Header is not a JSON object");
2124
2157
  return [parsed, serialized];
2125
2158
  }
2126
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/key.js
2159
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/key.js
2127
2160
  var tag = (key) => key[Symbol.toStringTag];
2128
2161
  var jwkMatchesOp = (entry, key, usage) => {
2129
2162
  const { alg } = entry;
@@ -2255,7 +2288,7 @@ async function jwkToKey(entry, jwk, extractable) {
2255
2288
  async function rawKey(key, expected, usage, extractable = !1) {
2256
2289
  return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
2257
2290
  }
2258
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/key_descriptor.js
2291
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/key_descriptor.js
2259
2292
  function table(entries) {
2260
2293
  const out = { __proto__: null };
2261
2294
  for (const alg in entries) out[alg] = {
@@ -2264,7 +2297,7 @@ function table(entries) {
2264
2297
  };
2265
2298
  return out;
2266
2299
  }
2267
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/jwe_algorithms.js
2300
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/jwe_algorithms.js
2268
2301
  var wrap = [["encrypt", "wrapKey"], ["decrypt", "unwrapKey"]];
2269
2302
  var derive = [[], ["deriveBits"]];
2270
2303
  var none = [[], []];
@@ -2371,7 +2404,7 @@ table({
2371
2404
  "A192CBC-HS384": contentEncryption(384, !0),
2372
2405
  "A256CBC-HS512": contentEncryption(512, !0)
2373
2406
  });
2374
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/jws_algorithms.js
2407
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/jws_algorithms.js
2375
2408
  var sig = [["verify"], ["sign"]];
2376
2409
  function hmac(bits) {
2377
2410
  const subtle = {
@@ -2460,7 +2493,7 @@ function jwsAlgorithm(alg) {
2460
2493
  if (!entry) throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
2461
2494
  return entry;
2462
2495
  }
2463
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/jws_verify.js
2496
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/jws_verify.js
2464
2497
  function prepareVerify(options) {
2465
2498
  return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
2466
2499
  }
@@ -2514,7 +2547,7 @@ async function verifyCompact(jws, shared, key) {
2514
2547
  signature
2515
2548
  }, shared, key, encodeCompactUnencodedPayload);
2516
2549
  }
2517
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
2550
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
2518
2551
  var epoch = (date) => Math.floor(date.getTime() / 1e3);
2519
2552
  var multipliers = {
2520
2553
  s: 1,
@@ -2641,7 +2674,7 @@ var JWTClaimsBuilder = class {
2641
2674
  return value === void 0 ? claimsSet.iat = epoch(/* @__PURE__ */ new Date()) : typeof value == "string" ? claimsSet.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value)) : claimsSet.iat = numericDate(value, "setIssuedAt"), this;
2642
2675
  }
2643
2676
  };
2644
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/jwt/verify.js
2677
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/jwt/verify.js
2645
2678
  async function jwtVerify(jwt, key, options) {
2646
2679
  const [verified, b64] = await verifyCompact(jwt, prepareVerify(options), key);
2647
2680
  if (!b64) throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
@@ -2651,7 +2684,7 @@ async function jwtVerify(jwt, key, options) {
2651
2684
  payload
2652
2685
  };
2653
2686
  }
2654
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/jws_sign.js
2687
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/jws_sign.js
2655
2688
  async function createSignature(input, key, rejectUnencoded) {
2656
2689
  let [payload, protectedHeader, unprotectedHeader, crit] = input, encodedProtectedHeader = "";
2657
2690
  if (protectedHeader !== void 0) {
@@ -2693,7 +2726,7 @@ async function createCompactSignature(payload, protectedHeader, crit, key, rejec
2693
2726
  ], key, rejectUnencoded);
2694
2727
  return `${jws.protected}.${jws.payload}.${jws.signature}`;
2695
2728
  }
2696
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/jwt/sign.js
2729
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/jwt/sign.js
2697
2730
  var SignJWT_base = JWTClaimsBuilder;
2698
2731
  var SignJWT = class extends SignJWT_base {
2699
2732
  #protectedHeader;
@@ -2706,14 +2739,14 @@ var SignJWT = class extends SignJWT_base {
2706
2739
  });
2707
2740
  }
2708
2741
  };
2709
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/lib/key_algorithm.js
2742
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/lib/key_algorithm.js
2710
2743
  function unsupportedAlg(source = "JWK \"alg\" (Algorithm) Parameter") {
2711
2744
  throw new JOSENotSupported(`Invalid or unsupported ${source} value`);
2712
2745
  }
2713
2746
  function keyAlgorithm(alg, source) {
2714
2747
  return (typeof alg == "string" ? JWS[alg] ?? JWE[alg] : void 0) ?? unsupportedAlg(source);
2715
2748
  }
2716
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/jwks/local.js
2749
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/jwks/local.js
2717
2750
  function isUsableJWK(jwk, entry, alg, kid) {
2718
2751
  const { kty, key_ops: keyOps, ext, kid: jwkKid, alg: jwkAlg, use, crv } = jwk;
2719
2752
  return (ext === void 0 || typeof ext == "boolean") && (keyOps === void 0 || Array.isArray(keyOps) && keyOps.every((operation, index) => typeof operation == "string" && keyOps.indexOf(operation) === index) && keyOps.includes("verify")) && entry.kty.includes(kty) && (kid === void 0 || typeof kid == "string" && kid === jwkKid) && (jwkAlg === void 0 ? kty !== "AKP" : alg === jwkAlg) && (use === void 0 || use === "sig") && (!entry.crv || crv === entry.crv);
@@ -2762,7 +2795,7 @@ function createLocalJWKSet(jwks) {
2762
2795
  return importWithAlgCache(cached, jwk, entry);
2763
2796
  }, "jwks", { value: () => structuredClone(snapshot) });
2764
2797
  }
2765
- // ../../node_modules/.pnpm/jose@6.2.13/node_modules/jose/dist/webapi/key/import.js
2798
+ // ../../node_modules/.pnpm/jose@6.2.14/node_modules/jose/dist/webapi/key/import.js
2766
2799
  async function importJWK(jwk, alg, options) {
2767
2800
  if (!isObject(jwk)) throw new TypeError("JWK must be an object");
2768
2801
  const normalized = normalizeJwk(jwk), extractable = validateExtractableOption(options?.extractable), { alg: jwkAlg } = normalized;