@cerefox/memory 1.14.2 → 1.14.4
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/AGENT_GUIDE.md +1 -1
- package/dist/bin/cerefox.js +657 -418
- package/dist/server-assets/_shared/ef-meta/index.ts +3 -3
- package/dist/server-assets/_shared/mcp-tools/_utils.ts +38 -6
- package/dist/server-assets/_shared/mcp-tools/metadata-search.ts +103 -21
- package/dist/server-assets/_shared/mcp-tools/search.ts +256 -66
- package/dist/server-assets/supabase/functions/cerefox-metadata-search/index.ts +81 -4
- package/dist/server-assets/supabase/functions/cerefox-search/index.ts +50 -16
- package/docs/guides/connect-agents.md +21 -8
- package/docs/guides/response-limits.md +64 -9
- package/package.json +3 -3
package/dist/bin/cerefox.js
CHANGED
|
@@ -7400,7 +7400,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
7400
7400
|
});
|
|
7401
7401
|
|
|
7402
7402
|
// src/meta.ts
|
|
7403
|
-
var PKG_VERSION = "1.14.
|
|
7403
|
+
var PKG_VERSION = "1.14.4";
|
|
7404
7404
|
var init_meta = () => {};
|
|
7405
7405
|
|
|
7406
7406
|
// ../../_shared/config/paths.ts
|
|
@@ -23278,23 +23278,6 @@ function getConfiguredSearchAlpha() {
|
|
|
23278
23278
|
function getMinTermCoverage() {
|
|
23279
23279
|
return;
|
|
23280
23280
|
}
|
|
23281
|
-
function applyByteBudget(rows, maxBytes) {
|
|
23282
|
-
const accepted = [];
|
|
23283
|
-
let usedBytes = 0;
|
|
23284
|
-
let truncated = false;
|
|
23285
|
-
let cut = rows.length;
|
|
23286
|
-
for (const [i, row] of rows.entries()) {
|
|
23287
|
-
const rowBytes = new TextEncoder().encode(JSON.stringify(row)).length;
|
|
23288
|
-
if (usedBytes + rowBytes > maxBytes) {
|
|
23289
|
-
truncated = true;
|
|
23290
|
-
cut = i;
|
|
23291
|
-
break;
|
|
23292
|
-
}
|
|
23293
|
-
accepted.push(row);
|
|
23294
|
-
usedBytes += rowBytes;
|
|
23295
|
-
}
|
|
23296
|
-
return { accepted, dropped: rows.slice(cut), truncated, usedBytes };
|
|
23297
|
-
}
|
|
23298
23281
|
function extractConflictHashes(message) {
|
|
23299
23282
|
return {
|
|
23300
23283
|
expected: message.match(/expected hash ([0-9a-f]{64})/)?.[1] ?? "unknown",
|
|
@@ -23334,6 +23317,14 @@ function logUsage(supabase, params) {
|
|
|
23334
23317
|
p_extra: params.extra ?? {}
|
|
23335
23318
|
})).catch(() => {});
|
|
23336
23319
|
}
|
|
23320
|
+
function resolveByteBudget(requested, ceiling) {
|
|
23321
|
+
if (requested === null || requested === undefined || requested === "")
|
|
23322
|
+
return ceiling;
|
|
23323
|
+
const n = Math.floor(Number(requested));
|
|
23324
|
+
if (!Number.isFinite(n))
|
|
23325
|
+
return ceiling;
|
|
23326
|
+
return Math.min(Math.max(n, 1), ceiling);
|
|
23327
|
+
}
|
|
23337
23328
|
var MAX_RESPONSE_BYTES = 200000, DEFAULT_MIN_SEARCH_SCORE = 0.5, DEFAULT_MIN_SEARCH_SCORE_LOCAL = 0.6, DEFAULT_SEARCH_ALPHA = 0.7;
|
|
23338
23329
|
var init__utils = __esm(() => {
|
|
23339
23330
|
init_audit_ops();
|
|
@@ -25776,7 +25767,7 @@ var init_bundled_docs = __esm(() => {
|
|
|
25776
25767
|
});
|
|
25777
25768
|
|
|
25778
25769
|
// ../../_shared/ef-meta/index.ts
|
|
25779
|
-
var EF_VERSION = "1.14.
|
|
25770
|
+
var EF_VERSION = "1.14.4", CEREFOX_VERSION = "1.14.4", EF_LAST_CHANGED = "1.14.4";
|
|
25780
25771
|
var init_ef_meta = () => {};
|
|
25781
25772
|
|
|
25782
25773
|
// ../../_shared/compatibility/index.ts
|
|
@@ -56411,7 +56402,7 @@ async function handler10(supabase, args, ctx) {
|
|
|
56411
56402
|
const project_name = args.project_name;
|
|
56412
56403
|
const updated_since = args.updated_since;
|
|
56413
56404
|
const created_since = args.created_since;
|
|
56414
|
-
const limit = args.limit
|
|
56405
|
+
const limit = Math.min(Math.max(1, Math.floor(Number(args.limit)) || 10), 500);
|
|
56415
56406
|
const include_content = args.include_content ?? false;
|
|
56416
56407
|
const requested_max_bytes = args.max_bytes;
|
|
56417
56408
|
if (metadata_filter !== undefined && (typeof metadata_filter !== "object" || Array.isArray(metadata_filter))) {
|
|
@@ -56428,7 +56419,7 @@ async function handler10(supabase, args, ctx) {
|
|
|
56428
56419
|
throw new Error(`Project not found: ${project_name}`);
|
|
56429
56420
|
}
|
|
56430
56421
|
const ceiling = getMaxResponseBytes();
|
|
56431
|
-
const max_bytes = include_content ?
|
|
56422
|
+
const max_bytes = include_content ? resolveByteBudget(requested_max_bytes, ceiling) : null;
|
|
56432
56423
|
const params = {
|
|
56433
56424
|
p_metadata_filter: metadata_filter ?? {},
|
|
56434
56425
|
p_project_id: projectId,
|
|
@@ -56443,31 +56434,51 @@ async function handler10(supabase, args, ctx) {
|
|
|
56443
56434
|
if (error)
|
|
56444
56435
|
throw new Error(`RPC error: ${error.message}`);
|
|
56445
56436
|
const rows = data ?? [];
|
|
56446
|
-
logUsage(supabase, {
|
|
56437
|
+
const log = (result_count, extra) => logUsage(supabase, {
|
|
56447
56438
|
operation: "metadata_search",
|
|
56448
56439
|
accessPath: ctx.accessPath,
|
|
56449
56440
|
requestor: callerIdentity(args),
|
|
56450
56441
|
query_text: JSON.stringify(metadata_filter ?? {}),
|
|
56451
56442
|
project_id: projectId,
|
|
56452
|
-
result_count
|
|
56443
|
+
result_count,
|
|
56444
|
+
...extra ? { extra } : {}
|
|
56453
56445
|
});
|
|
56454
56446
|
if (rows.length === 0) {
|
|
56455
56447
|
if (include_content && max_bytes !== null) {
|
|
56456
|
-
const { data: headers } = await supabase.rpc("cerefox_metadata_search", {
|
|
56457
|
-
|
|
56458
|
-
|
|
56459
|
-
|
|
56460
|
-
}
|
|
56448
|
+
const { data: headers, error: probeError } = await supabase.rpc("cerefox_metadata_search", { ...params, p_include_content: false, p_max_bytes: null });
|
|
56449
|
+
if (probeError) {
|
|
56450
|
+
log(0, { degraded_probe_failed: true });
|
|
56451
|
+
return `⚠ Nothing fit max_bytes=${max_bytes} with include_content, and the ` + `follow-up query that lists what matched failed: ${probeError.message}. ` + `This is NOT a confirmed empty result — retry with a larger max_bytes, ` + `or with include_content: false.`;
|
|
56452
|
+
}
|
|
56461
56453
|
const headerRows = headers ?? [];
|
|
56462
56454
|
if (headerRows.length > 0) {
|
|
56463
|
-
|
|
56464
|
-
|
|
56465
|
-
|
|
56466
|
-
|
|
56455
|
+
const lead = `⚠ ${headerRows.length} document(s) match, but none fit max_bytes=${max_bytes} ` + `with include_content. This is NOT an empty result. Listing them without ` + `content — raise max_bytes, or read one with cerefox_get_document ` + `(outline: true for structure).`;
|
|
56456
|
+
const lines = [];
|
|
56457
|
+
let used = new TextEncoder().encode(lead).length;
|
|
56458
|
+
for (const r of headerRows) {
|
|
56459
|
+
const line = `## ${r.title} [id: ${r.document_id}]`;
|
|
56460
|
+
const size = new TextEncoder().encode(line).length + 1;
|
|
56461
|
+
if (used + size > max_bytes)
|
|
56462
|
+
break;
|
|
56463
|
+
lines.push(line);
|
|
56464
|
+
used += size;
|
|
56465
|
+
}
|
|
56466
|
+
log(headerRows.length, { returned: lines.length, degraded: true });
|
|
56467
|
+
return lines.length > 0 ? `${lead}
|
|
56468
|
+
${lines.join(`
|
|
56469
|
+
`)}` : lead;
|
|
56467
56470
|
}
|
|
56468
56471
|
}
|
|
56472
|
+
log(0);
|
|
56469
56473
|
return "No documents match the given criteria.";
|
|
56470
56474
|
}
|
|
56475
|
+
let matched = rows.length;
|
|
56476
|
+
if (include_content && max_bytes !== null && rows.length < limit) {
|
|
56477
|
+
const { data: headers, error: probeError } = await supabase.rpc("cerefox_metadata_search", { ...params, p_include_content: false, p_max_bytes: null });
|
|
56478
|
+
if (!probeError)
|
|
56479
|
+
matched = Math.max(rows.length, (headers ?? []).length);
|
|
56480
|
+
}
|
|
56481
|
+
log(matched, matched > rows.length ? { returned: rows.length, truncated: true } : undefined);
|
|
56471
56482
|
const showReview = await reviewWorkflowEnabled(supabase);
|
|
56472
56483
|
const parts = rows.map((row) => {
|
|
56473
56484
|
const projects = row.project_names?.length ? ` | projects: ${row.project_names.join(", ")}` : "";
|
|
@@ -56483,6 +56494,16 @@ ${row.content}`;
|
|
|
56483
56494
|
}
|
|
56484
56495
|
return header;
|
|
56485
56496
|
});
|
|
56497
|
+
if (matched > rows.length) {
|
|
56498
|
+
const held = matched - rows.length;
|
|
56499
|
+
return `${parts.join(`
|
|
56500
|
+
|
|
56501
|
+
---
|
|
56502
|
+
|
|
56503
|
+
`)}
|
|
56504
|
+
|
|
56505
|
+
` + `[${rows.length} of ${matched} document(s) shown; ${held} did not fit ` + `max_bytes=${max_bytes}. Raise max_bytes, lower limit, or use ` + `include_content: false to list them all.]`;
|
|
56506
|
+
}
|
|
56486
56507
|
return parts.join(`
|
|
56487
56508
|
|
|
56488
56509
|
---
|
|
@@ -56539,19 +56560,51 @@ var init_metadata_search = __esm(() => {
|
|
|
56539
56560
|
});
|
|
56540
56561
|
|
|
56541
56562
|
// ../../_shared/mcp-tools/search.ts
|
|
56542
|
-
function
|
|
56543
|
-
|
|
56563
|
+
function rowContent(row) {
|
|
56564
|
+
return row.full_content ?? row.content ?? "";
|
|
56565
|
+
}
|
|
56566
|
+
function rowHeading(row) {
|
|
56567
|
+
const doc = row.doc_title ?? "Untitled";
|
|
56568
|
+
const path = [...row.heading_path ?? []];
|
|
56569
|
+
if (path.length > 0 && path[0] === doc)
|
|
56570
|
+
path.shift();
|
|
56571
|
+
const section = path.length ? path.filter(Boolean).join(" › ") : row.title && row.title !== doc ? row.title : "";
|
|
56544
56572
|
const docId = row.document_id ? ` [id: ${row.document_id}]` : "";
|
|
56573
|
+
const chunk = row.chunk_index != null ? ` (chunk ${row.chunk_index})` : "";
|
|
56574
|
+
return `${doc}${section ? ` › ${section}` : ""}${docId}${chunk}`;
|
|
56575
|
+
}
|
|
56576
|
+
function shortLabel(row) {
|
|
56577
|
+
const doc = row.doc_title ?? "Untitled";
|
|
56578
|
+
const path = [...row.heading_path ?? []];
|
|
56579
|
+
if (path.length > 0 && path[0] === doc)
|
|
56580
|
+
path.shift();
|
|
56581
|
+
const leaf = path.filter(Boolean).at(-1) ?? (row.title && row.title !== doc ? row.title : "");
|
|
56582
|
+
const chunk = row.chunk_index != null ? ` (chunk ${row.chunk_index})` : "";
|
|
56583
|
+
const id = row.document_id ? ` [id: ${row.document_id}]` : "";
|
|
56584
|
+
return `${leaf ? `${doc} › ${leaf}` : doc}${chunk}${id}`;
|
|
56585
|
+
}
|
|
56586
|
+
function renderRow(row) {
|
|
56587
|
+
const raw = row.best_score ?? row.score;
|
|
56588
|
+
const score = raw != null ? ` (score: ${raw.toFixed(3)})` : "";
|
|
56589
|
+
const partial = row.is_partial ? ` -- partial (${row.chunk_count} of ${(row.total_chars ?? 0).toLocaleString()} chars)` : "";
|
|
56590
|
+
const hash = row.content_hash ? `
|
|
56591
|
+
hash: ${row.content_hash}` : "";
|
|
56592
|
+
return `## ${rowHeading(row)}${score}${partial}${hash}
|
|
56593
|
+
|
|
56594
|
+
${rowContent(row)}`;
|
|
56595
|
+
}
|
|
56596
|
+
function headerLine(row) {
|
|
56545
56597
|
const raw = row.best_score ?? row.score;
|
|
56546
56598
|
const score = raw != null ? ` (score: ${raw.toFixed(3)})` : "";
|
|
56547
56599
|
const size = row.total_chars != null ? ` -- ${row.total_chars.toLocaleString()} chars` : "";
|
|
56548
56600
|
const hash = row.content_hash ? `
|
|
56549
56601
|
hash: ${row.content_hash}` : "";
|
|
56550
|
-
return `## ${
|
|
56602
|
+
return `## ${rowHeading(row)}${score}${size}${hash}`;
|
|
56551
56603
|
}
|
|
56552
|
-
function degradedToHeaders(matched, maxBytes) {
|
|
56553
|
-
const biggest = Math.max(...
|
|
56554
|
-
const
|
|
56604
|
+
function degradedToHeaders(matched, rendered, maxBytes, belowConfidence) {
|
|
56605
|
+
const biggest = Math.max(...rendered.map((t) => new TextEncoder().encode(t).length));
|
|
56606
|
+
const confidence = belowConfidence ? "None of these cleared the confidence threshold — they are the closest " + "candidates, so judge relevance from the scores. " : "";
|
|
56607
|
+
const lead = `⚠ ${matched.length} result(s) matched, but none fit max_bytes=${maxBytes} ` + `(the largest is ${biggest.toLocaleString()} bytes). ${confidence}This is NOT an ` + `empty knowledge base. Listing what matched, without content — raise max_bytes ` + `to read it, or read one document with cerefox_get_document (outline: true for ` + `structure, or section: "## Heading" for one part).`;
|
|
56555
56608
|
const lines = [];
|
|
56556
56609
|
let used = new TextEncoder().encode(lead).length;
|
|
56557
56610
|
for (const row of matched) {
|
|
@@ -56571,7 +56624,7 @@ ${lines.join(`
|
|
|
56571
56624
|
async function handler11(supabase, args, ctx) {
|
|
56572
56625
|
const query = args.query;
|
|
56573
56626
|
const project_name = args.project_name;
|
|
56574
|
-
const match_count = args.match_count
|
|
56627
|
+
const match_count = Math.min(Math.max(1, Math.floor(Number(args.match_count)) || 5), 200);
|
|
56575
56628
|
const mode = args.mode ?? "docs";
|
|
56576
56629
|
const alpha = args.alpha ?? getConfiguredSearchAlpha();
|
|
56577
56630
|
const min_score = args.min_score ?? getConfiguredMinSearchScore();
|
|
@@ -56582,7 +56635,7 @@ async function handler11(supabase, args, ctx) {
|
|
|
56582
56635
|
const metadata_filter = args.metadata_filter ?? null;
|
|
56583
56636
|
const requested_max_bytes = args.max_bytes;
|
|
56584
56637
|
const ceiling = getMaxResponseBytes();
|
|
56585
|
-
const max_bytes =
|
|
56638
|
+
const max_bytes = resolveByteBudget(requested_max_bytes, ceiling);
|
|
56586
56639
|
if (metadata_filter !== null && metadata_filter !== undefined && (typeof metadata_filter !== "object" || Array.isArray(metadata_filter))) {
|
|
56587
56640
|
throw new McpInvalidParams("metadata_filter must be a JSON object or null");
|
|
56588
56641
|
}
|
|
@@ -56643,50 +56696,102 @@ async function handler11(supabase, args, ctx) {
|
|
|
56643
56696
|
if (error)
|
|
56644
56697
|
throw new Error(`RPC error: ${error.message}`);
|
|
56645
56698
|
const matched = data ?? [];
|
|
56646
|
-
const
|
|
56647
|
-
|
|
56648
|
-
|
|
56649
|
-
|
|
56650
|
-
|
|
56651
|
-
|
|
56652
|
-
|
|
56653
|
-
|
|
56654
|
-
|
|
56655
|
-
|
|
56656
|
-
if (matched.length === 0)
|
|
56699
|
+
const belowConfidence = matched.length > 0 && matched.every((r) => r.below_confidence === true);
|
|
56700
|
+
if (matched.length === 0) {
|
|
56701
|
+
logUsage(supabase, {
|
|
56702
|
+
operation: "search",
|
|
56703
|
+
accessPath: ctx.accessPath,
|
|
56704
|
+
requestor: callerIdentity(args),
|
|
56705
|
+
query_text: query,
|
|
56706
|
+
project_id: projectId,
|
|
56707
|
+
result_count: 0
|
|
56708
|
+
});
|
|
56657
56709
|
return "No results found.";
|
|
56658
|
-
if (accepted.length === 0) {
|
|
56659
|
-
return degradedToHeaders(matched, max_bytes);
|
|
56660
56710
|
}
|
|
56661
|
-
const
|
|
56662
|
-
const
|
|
56663
|
-
const
|
|
56664
|
-
const title = row.doc_title ?? "Untitled";
|
|
56665
|
-
const docId = row.document_id ? ` [id: ${row.document_id}]` : "";
|
|
56666
|
-
const rawScore = row.best_score ?? row.score;
|
|
56667
|
-
const score = rawScore != null ? ` (score: ${rawScore.toFixed(3)})` : "";
|
|
56668
|
-
const partial = row.is_partial ? ` -- partial (${row.chunk_count} of ${(row.total_chars ?? 0).toLocaleString()} chars)` : "";
|
|
56669
|
-
const hash = row.content_hash ? `
|
|
56670
|
-
hash: ${row.content_hash}` : "";
|
|
56671
|
-
return `## ${title}${docId}${score}${partial}${hash}
|
|
56672
|
-
|
|
56673
|
-
${row.full_content ?? ""}`;
|
|
56674
|
-
});
|
|
56675
|
-
let output = parts.join(`
|
|
56711
|
+
const rendered = matched.map(renderRow);
|
|
56712
|
+
const size = (t) => new TextEncoder().encode(t).length;
|
|
56713
|
+
const SEP = `
|
|
56676
56714
|
|
|
56677
56715
|
---
|
|
56678
56716
|
|
|
56679
|
-
|
|
56680
|
-
|
|
56681
|
-
output = `⚠ No results cleared the confidence threshold. Showing the closest ${rows.length} ` + `candidate(s) with scores — judge relevance yourself; a low score means weak signal, ` + `not necessarily absent knowledge.
|
|
56717
|
+
`;
|
|
56718
|
+
const banner = (take, short) => !belowConfidence ? "" : short ? `⚠ Below the confidence threshold — judge relevance from the scores.
|
|
56682
56719
|
|
|
56683
|
-
` +
|
|
56684
|
-
}
|
|
56685
|
-
if (truncated) {
|
|
56686
|
-
output += `
|
|
56720
|
+
` : `⚠ No results cleared the confidence threshold. Showing the closest ${take} ` + `candidate(s) with scores — judge relevance yourself; a low score means weak ` + `signal, not necessarily absent knowledge.
|
|
56687
56721
|
|
|
56688
|
-
|
|
56722
|
+
`;
|
|
56723
|
+
const assemble = (keptCount, short) => {
|
|
56724
|
+
const kept = keptIdx.slice(0, keptCount);
|
|
56725
|
+
const body = banner(keptCount, short) + kept.map((i) => rendered[i]).join(SEP);
|
|
56726
|
+
if (kept.length === matched.length)
|
|
56727
|
+
return body;
|
|
56728
|
+
const droppedRows = matched.filter((_, i) => !kept.includes(i));
|
|
56729
|
+
const room = max_bytes - size(body);
|
|
56730
|
+
const footer = (named) => {
|
|
56731
|
+
const labels = droppedRows.slice(0, named).map(shortLabel);
|
|
56732
|
+
const rest = droppedRows.length - labels.length;
|
|
56733
|
+
const naming = labels.length ? `: ${labels.join(", ")}${rest > 0 ? ` and ${rest} more` : ""}` : "";
|
|
56734
|
+
return `
|
|
56735
|
+
|
|
56736
|
+
[${kept.length} of ${matched.length} result(s) shown; ${droppedRows.length} did ` + `not fit max_bytes=${max_bytes}${naming}. Raise max_bytes, narrow the query, or ` + `lower match_count.]`;
|
|
56737
|
+
};
|
|
56738
|
+
for (let named = Math.min(5, droppedRows.length);named >= 1; named--) {
|
|
56739
|
+
const candidate = footer(named);
|
|
56740
|
+
if (size(candidate) <= room)
|
|
56741
|
+
return body + candidate;
|
|
56742
|
+
}
|
|
56743
|
+
const bare = footer(0);
|
|
56744
|
+
if (size(bare) <= room)
|
|
56745
|
+
return body + bare;
|
|
56746
|
+
return body + `
|
|
56747
|
+
|
|
56748
|
+
[${kept.length} of ${matched.length} shown; raise max_bytes]`;
|
|
56749
|
+
};
|
|
56750
|
+
const sepBytes = size(SEP);
|
|
56751
|
+
const keptIdx = [];
|
|
56752
|
+
let acc = 0;
|
|
56753
|
+
for (let i = 0;i < rendered.length; i++) {
|
|
56754
|
+
const add = size(rendered[i]) + (keptIdx.length > 0 ? sepBytes : 0);
|
|
56755
|
+
if (acc + add > max_bytes)
|
|
56756
|
+
continue;
|
|
56757
|
+
acc += add;
|
|
56758
|
+
keptIdx.push(i);
|
|
56689
56759
|
}
|
|
56760
|
+
if (keptIdx.length === 0) {
|
|
56761
|
+
logUsage(supabase, {
|
|
56762
|
+
operation: "search",
|
|
56763
|
+
accessPath: ctx.accessPath,
|
|
56764
|
+
requestor: callerIdentity(args),
|
|
56765
|
+
query_text: query,
|
|
56766
|
+
project_id: projectId,
|
|
56767
|
+
result_count: matched.length,
|
|
56768
|
+
extra: { returned: 0, truncated: true, degraded: true }
|
|
56769
|
+
});
|
|
56770
|
+
return degradedToHeaders(matched, rendered, max_bytes, belowConfidence);
|
|
56771
|
+
}
|
|
56772
|
+
let keptCount = keptIdx.length;
|
|
56773
|
+
let short = false;
|
|
56774
|
+
let output = assemble(keptCount, short);
|
|
56775
|
+
while (size(output) > max_bytes) {
|
|
56776
|
+
if (belowConfidence && !short)
|
|
56777
|
+
short = true;
|
|
56778
|
+
else if (keptCount > 1) {
|
|
56779
|
+
keptCount -= 1;
|
|
56780
|
+
short = belowConfidence;
|
|
56781
|
+
} else
|
|
56782
|
+
break;
|
|
56783
|
+
output = assemble(keptCount, short);
|
|
56784
|
+
}
|
|
56785
|
+
const take = keptCount;
|
|
56786
|
+
logUsage(supabase, {
|
|
56787
|
+
operation: "search",
|
|
56788
|
+
accessPath: ctx.accessPath,
|
|
56789
|
+
requestor: callerIdentity(args),
|
|
56790
|
+
query_text: query,
|
|
56791
|
+
project_id: projectId,
|
|
56792
|
+
result_count: matched.length,
|
|
56793
|
+
...take < matched.length ? { extra: { returned: take, truncated: true } } : {}
|
|
56794
|
+
});
|
|
56690
56795
|
return output;
|
|
56691
56796
|
}
|
|
56692
56797
|
var searchTool;
|
|
@@ -56711,7 +56816,7 @@ var init_search = __esm(() => {
|
|
|
56711
56816
|
query: { type: "string", description: "Natural-language search query" },
|
|
56712
56817
|
match_count: {
|
|
56713
56818
|
type: "integer",
|
|
56714
|
-
description: "Maximum number of documents to return (default: 5)"
|
|
56819
|
+
description: "Maximum number of documents to return (default: 5, maximum: 200)"
|
|
56715
56820
|
},
|
|
56716
56821
|
project_name: {
|
|
56717
56822
|
type: "string",
|
|
@@ -80525,10 +80630,28 @@ async function action28(options) {
|
|
|
80525
80630
|
};
|
|
80526
80631
|
if (options.includeContent)
|
|
80527
80632
|
params.p_max_bytes = maxBytes;
|
|
80528
|
-
|
|
80633
|
+
let rows = await client.rpc("cerefox_metadata_search", params);
|
|
80529
80634
|
if (rows === null) {
|
|
80530
80635
|
throw systemError("cerefox_metadata_search: RPC returned no data.");
|
|
80531
80636
|
}
|
|
80637
|
+
let heldBack = 0;
|
|
80638
|
+
if (options.includeContent && rows.length < limit) {
|
|
80639
|
+
const all = await client.rpc("cerefox_metadata_search", {
|
|
80640
|
+
...params,
|
|
80641
|
+
p_include_content: false,
|
|
80642
|
+
p_max_bytes: null
|
|
80643
|
+
});
|
|
80644
|
+
if (all !== null && all.length > rows.length) {
|
|
80645
|
+
const withContent = new Map(rows.map((r) => [r.document_id, r]));
|
|
80646
|
+
heldBack = all.length - rows.length;
|
|
80647
|
+
const merged = all.map((h) => withContent.get(h.document_id) ?? { ...h, content: null });
|
|
80648
|
+
const seen = new Set(merged.map((r) => r.document_id));
|
|
80649
|
+
for (const r of rows)
|
|
80650
|
+
if (!seen.has(r.document_id))
|
|
80651
|
+
merged.push(r);
|
|
80652
|
+
rows = merged;
|
|
80653
|
+
}
|
|
80654
|
+
}
|
|
80532
80655
|
const requestor = resolveRequestor(options.author ?? options.requestor);
|
|
80533
80656
|
client.raw.rpc("cerefox_log_usage", {
|
|
80534
80657
|
p_operation: "metadata_search",
|
|
@@ -80550,6 +80673,10 @@ async function action28(options) {
|
|
|
80550
80673
|
println("No documents match the metadata filter.");
|
|
80551
80674
|
return;
|
|
80552
80675
|
}
|
|
80676
|
+
if (heldBack > 0) {
|
|
80677
|
+
println(c.dim(`(${rows.length - heldBack} of ${rows.length} document(s) have content here; ` + `${heldBack} did not fit --max-bytes ${maxBytes} and are listed without it)`));
|
|
80678
|
+
println("");
|
|
80679
|
+
}
|
|
80553
80680
|
for (const row of rows) {
|
|
80554
80681
|
const projects = row.project_names?.length ? ` | projects: ${row.project_names.join(", ")}` : "";
|
|
80555
80682
|
const meta = Object.entries(row.doc_metadata ?? {}).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
@@ -81088,7 +81215,7 @@ async function action32(query, options) {
|
|
|
81088
81215
|
const rowBytes = Buffer.byteLength(JSON.stringify(row), "utf8");
|
|
81089
81216
|
if (usedBytes + rowBytes > maxBytes && accepted.length > 0) {
|
|
81090
81217
|
truncated = true;
|
|
81091
|
-
|
|
81218
|
+
continue;
|
|
81092
81219
|
}
|
|
81093
81220
|
accepted.push(row);
|
|
81094
81221
|
usedBytes += rowBytes;
|
|
@@ -81169,7 +81296,8 @@ async function action32(query, options) {
|
|
|
81169
81296
|
}
|
|
81170
81297
|
}
|
|
81171
81298
|
if (truncated) {
|
|
81172
|
-
|
|
81299
|
+
const held = results.length - accepted.length;
|
|
81300
|
+
println(c.dim(`(${accepted.length} of ${results.length} result(s) shown; ${held} did not fit ` + `${usedBytes} bytes used of --max-bytes ${maxBytes} — raise it to see the rest)`));
|
|
81173
81301
|
}
|
|
81174
81302
|
}
|
|
81175
81303
|
function registerSearch(program) {
|
|
@@ -81389,7 +81517,7 @@ function envGitignoreWarning(path) {
|
|
|
81389
81517
|
// src/web/auth.ts
|
|
81390
81518
|
import { existsSync as existsSync16 } from "node:fs";
|
|
81391
81519
|
|
|
81392
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
81520
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/conninfo.mjs
|
|
81393
81521
|
var getConnInfo = (c) => {
|
|
81394
81522
|
const bindings = c.env.server ? c.env.server : c.env;
|
|
81395
81523
|
const address = bindings.incoming.socket.remoteAddress;
|
|
@@ -81732,15 +81860,15 @@ init_sync_self_docs();
|
|
|
81732
81860
|
init_cli_core();
|
|
81733
81861
|
import { readFileSync as readFileSync20 } from "node:fs";
|
|
81734
81862
|
|
|
81735
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
81863
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
|
|
81736
81864
|
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
81737
81865
|
|
|
81738
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
81866
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/index.mjs
|
|
81739
81867
|
import { STATUS_CODES, createServer } from "node:http";
|
|
81740
81868
|
import { Http2ServerRequest, constants } from "node:http2";
|
|
81741
81869
|
import { Readable } from "node:stream";
|
|
81742
81870
|
|
|
81743
|
-
// ../../node_modules/.bun/hono@4.
|
|
81871
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/helper/websocket/index.js
|
|
81744
81872
|
var defineWebSocketHelper = (handler) => {
|
|
81745
81873
|
return (...args) => {
|
|
81746
81874
|
if (typeof args[0] === "function") {
|
|
@@ -81766,13 +81894,174 @@ var defineWebSocketHelper = (handler) => {
|
|
|
81766
81894
|
};
|
|
81767
81895
|
};
|
|
81768
81896
|
|
|
81769
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
81897
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/index.mjs
|
|
81770
81898
|
var RequestError = class extends Error {
|
|
81771
81899
|
constructor(message, options) {
|
|
81772
81900
|
super(message, options);
|
|
81773
81901
|
this.name = "RequestError";
|
|
81774
81902
|
}
|
|
81775
81903
|
};
|
|
81904
|
+
var nonJoinedHeaders = new Set([
|
|
81905
|
+
"age",
|
|
81906
|
+
"authorization",
|
|
81907
|
+
"content-length",
|
|
81908
|
+
"content-type",
|
|
81909
|
+
"etag",
|
|
81910
|
+
"expires",
|
|
81911
|
+
"from",
|
|
81912
|
+
"host",
|
|
81913
|
+
"if-modified-since",
|
|
81914
|
+
"if-unmodified-since",
|
|
81915
|
+
"last-modified",
|
|
81916
|
+
"location",
|
|
81917
|
+
"max-forwards",
|
|
81918
|
+
"proxy-authorization",
|
|
81919
|
+
"referer",
|
|
81920
|
+
"retry-after",
|
|
81921
|
+
"server",
|
|
81922
|
+
"user-agent"
|
|
81923
|
+
]);
|
|
81924
|
+
var validHeaderName = /^[!#$%&'*+\-.^_`|~\dA-Za-z]+$/;
|
|
81925
|
+
var isHttpWhitespace = (code) => code === 9 || code === 10 || code === 13 || code === 32;
|
|
81926
|
+
var normalizeHeaderValue = (value) => {
|
|
81927
|
+
if (!isHttpWhitespace(value.charCodeAt(0)) && !isHttpWhitespace(value.charCodeAt(value.length - 1)))
|
|
81928
|
+
return value;
|
|
81929
|
+
let start = 0;
|
|
81930
|
+
let end = value.length;
|
|
81931
|
+
while (start < end && isHttpWhitespace(value.charCodeAt(start)))
|
|
81932
|
+
start++;
|
|
81933
|
+
while (end > start && isHttpWhitespace(value.charCodeAt(end - 1)))
|
|
81934
|
+
end--;
|
|
81935
|
+
return value.slice(start, end);
|
|
81936
|
+
};
|
|
81937
|
+
var forbiddenHeaderValue = /[\0\r\n]/;
|
|
81938
|
+
var GlobalHeaders = globalThis.Headers;
|
|
81939
|
+
var materializeHeaders = (rawHeaders, HeadersCtor = GlobalHeaders) => {
|
|
81940
|
+
const headers = new HeadersCtor;
|
|
81941
|
+
for (let i = 0;i < rawHeaders.length; i += 2) {
|
|
81942
|
+
const name = rawHeaders[i];
|
|
81943
|
+
if (!name.startsWith(":"))
|
|
81944
|
+
headers.append(name, rawHeaders[i + 1]);
|
|
81945
|
+
}
|
|
81946
|
+
return headers;
|
|
81947
|
+
};
|
|
81948
|
+
var RequestHeaders = class {
|
|
81949
|
+
#incoming;
|
|
81950
|
+
#rawHeaders;
|
|
81951
|
+
#headers;
|
|
81952
|
+
#invalidValue;
|
|
81953
|
+
constructor(incoming) {
|
|
81954
|
+
this.#incoming = incoming;
|
|
81955
|
+
if (incoming instanceof Http2ServerRequest)
|
|
81956
|
+
this.#rawHeaders = incoming.rawHeaders.slice();
|
|
81957
|
+
}
|
|
81958
|
+
get #lazyRawHeaders() {
|
|
81959
|
+
return this.#rawHeaders ??= this.#incoming.rawHeaders.slice();
|
|
81960
|
+
}
|
|
81961
|
+
get #native() {
|
|
81962
|
+
if (!this.#headers) {
|
|
81963
|
+
this.#headers = materializeHeaders(this.#lazyRawHeaders);
|
|
81964
|
+
this.#rawHeaders = undefined;
|
|
81965
|
+
}
|
|
81966
|
+
return this.#headers;
|
|
81967
|
+
}
|
|
81968
|
+
#normalizedName(name) {
|
|
81969
|
+
if (typeof name !== "string")
|
|
81970
|
+
return;
|
|
81971
|
+
if (!validHeaderName.test(name))
|
|
81972
|
+
throw new TypeError(`Invalid header name: ${name}`);
|
|
81973
|
+
return name.toLowerCase();
|
|
81974
|
+
}
|
|
81975
|
+
#lookupHttp1(lowerName) {
|
|
81976
|
+
const headers = this.#incoming instanceof Http2ServerRequest ? undefined : this.#incoming.headers;
|
|
81977
|
+
if (!headers || nonJoinedHeaders.has(lowerName) || lowerName === "set-cookie" || lowerName === "__proto__")
|
|
81978
|
+
return;
|
|
81979
|
+
if (!Object.hasOwn(headers, lowerName))
|
|
81980
|
+
return null;
|
|
81981
|
+
const rawValue = headers[lowerName];
|
|
81982
|
+
if (typeof rawValue === "string") {
|
|
81983
|
+
const value = normalizeHeaderValue(rawValue);
|
|
81984
|
+
return forbiddenHeaderValue.test(value) ? undefined : value;
|
|
81985
|
+
}
|
|
81986
|
+
}
|
|
81987
|
+
#lookup(rawHeaders, lowerName) {
|
|
81988
|
+
const separator = lowerName === "cookie" ? "; " : ", ";
|
|
81989
|
+
let value = null;
|
|
81990
|
+
for (let i = 0;i < rawHeaders.length; i += 2) {
|
|
81991
|
+
const rawName = rawHeaders[i];
|
|
81992
|
+
if (rawName.length === lowerName.length && rawName.toLowerCase() === lowerName) {
|
|
81993
|
+
const rawValue = normalizeHeaderValue(rawHeaders[i + 1]);
|
|
81994
|
+
if (forbiddenHeaderValue.test(rawValue)) {
|
|
81995
|
+
this.#invalidValue = true;
|
|
81996
|
+
return;
|
|
81997
|
+
}
|
|
81998
|
+
value = value === null ? rawValue : value + separator + rawValue;
|
|
81999
|
+
}
|
|
82000
|
+
}
|
|
82001
|
+
return value;
|
|
82002
|
+
}
|
|
82003
|
+
append(name, value) {
|
|
82004
|
+
this.#native.append(name, value);
|
|
82005
|
+
}
|
|
82006
|
+
delete(name) {
|
|
82007
|
+
this.#native.delete(name);
|
|
82008
|
+
}
|
|
82009
|
+
get(name) {
|
|
82010
|
+
const lowerName = this.#normalizedName(name);
|
|
82011
|
+
if (lowerName && !this.#headers && !this.#invalidValue) {
|
|
82012
|
+
const http1Value = this.#lookupHttp1(lowerName);
|
|
82013
|
+
if (http1Value !== undefined)
|
|
82014
|
+
return http1Value;
|
|
82015
|
+
const value = this.#lookup(this.#lazyRawHeaders, lowerName);
|
|
82016
|
+
if (value !== undefined)
|
|
82017
|
+
return value;
|
|
82018
|
+
}
|
|
82019
|
+
return this.#native.get(name);
|
|
82020
|
+
}
|
|
82021
|
+
has(name) {
|
|
82022
|
+
const lowerName = this.#normalizedName(name);
|
|
82023
|
+
if (lowerName && !this.#headers && !this.#invalidValue) {
|
|
82024
|
+
const http1Value = this.#lookupHttp1(lowerName);
|
|
82025
|
+
if (http1Value !== undefined)
|
|
82026
|
+
return http1Value !== null;
|
|
82027
|
+
const value = this.#lookup(this.#lazyRawHeaders, lowerName);
|
|
82028
|
+
if (value !== undefined)
|
|
82029
|
+
return value !== null;
|
|
82030
|
+
}
|
|
82031
|
+
return this.#native.has(name);
|
|
82032
|
+
}
|
|
82033
|
+
set(name, value) {
|
|
82034
|
+
this.#native.set(name, value);
|
|
82035
|
+
}
|
|
82036
|
+
getSetCookie() {
|
|
82037
|
+
return this.#native.getSetCookie();
|
|
82038
|
+
}
|
|
82039
|
+
keys() {
|
|
82040
|
+
return this.#native.keys();
|
|
82041
|
+
}
|
|
82042
|
+
values() {
|
|
82043
|
+
return this.#native.values();
|
|
82044
|
+
}
|
|
82045
|
+
entries() {
|
|
82046
|
+
return this.#native.entries();
|
|
82047
|
+
}
|
|
82048
|
+
forEach(callback, thisArg) {
|
|
82049
|
+
this.#native.forEach((value, key) => {
|
|
82050
|
+
callback.call(thisArg, value, key, this);
|
|
82051
|
+
});
|
|
82052
|
+
}
|
|
82053
|
+
[Symbol.iterator]() {
|
|
82054
|
+
return this.entries();
|
|
82055
|
+
}
|
|
82056
|
+
};
|
|
82057
|
+
Object.defineProperty(RequestHeaders.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
82058
|
+
return `Headers (lightweight) ${inspectFn(Object.fromEntries(this), {
|
|
82059
|
+
...options,
|
|
82060
|
+
depth: depth == null ? null : depth - 1
|
|
82061
|
+
})}`;
|
|
82062
|
+
} });
|
|
82063
|
+
Object.setPrototypeOf(RequestHeaders.prototype, GlobalHeaders.prototype);
|
|
82064
|
+
var newHeadersFromIncoming = (incoming) => globalThis.Headers === GlobalHeaders ? new RequestHeaders(incoming) : materializeHeaders(incoming.rawHeaders, globalThis.Headers);
|
|
81776
82065
|
var reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
|
|
81777
82066
|
var reDotSegment = /\/\.\.?(?:[/?#]|$)/;
|
|
81778
82067
|
var reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
|
|
@@ -81812,16 +82101,6 @@ var Request$1 = class extends GlobalRequest {
|
|
|
81812
82101
|
super(input, options);
|
|
81813
82102
|
}
|
|
81814
82103
|
};
|
|
81815
|
-
var newHeadersFromIncoming = (incoming) => {
|
|
81816
|
-
const headerRecord = [];
|
|
81817
|
-
const rawHeaders = incoming.rawHeaders;
|
|
81818
|
-
for (let i = 0, len = rawHeaders.length;i < len; i += 2) {
|
|
81819
|
-
const key = rawHeaders[i];
|
|
81820
|
-
if (key.charCodeAt(0) !== 58)
|
|
81821
|
-
headerRecord.push([key, rawHeaders[i + 1]]);
|
|
81822
|
-
}
|
|
81823
|
-
return new Headers(headerRecord);
|
|
81824
|
-
};
|
|
81825
82104
|
var wrapBodyStream = Symbol("wrapBodyStream");
|
|
81826
82105
|
var byteExactEncodings = new Set([
|
|
81827
82106
|
"latin1",
|
|
@@ -82522,8 +82801,12 @@ var drainIncoming = (incoming) => {
|
|
|
82522
82801
|
const forceClose = () => {
|
|
82523
82802
|
cleanup();
|
|
82524
82803
|
const socket = incoming.socket;
|
|
82525
|
-
if (socket && !socket.destroyed)
|
|
82526
|
-
socket.destroySoon
|
|
82804
|
+
if (socket && !socket.destroyed) {
|
|
82805
|
+
if (typeof socket.destroySoon === "function")
|
|
82806
|
+
socket.destroySoon();
|
|
82807
|
+
else if (typeof socket.destroy === "function")
|
|
82808
|
+
socket.destroy();
|
|
82809
|
+
}
|
|
82527
82810
|
};
|
|
82528
82811
|
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
82529
82812
|
timer.unref?.();
|
|
@@ -83040,7 +83323,7 @@ var serve = (options, listeningListener) => {
|
|
|
83040
83323
|
return server;
|
|
83041
83324
|
};
|
|
83042
83325
|
|
|
83043
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
83326
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/utils/stream.mjs
|
|
83044
83327
|
import { Readable as Readable2 } from "node:stream";
|
|
83045
83328
|
import { versions as versions2 } from "node:process";
|
|
83046
83329
|
var pr54206Applied = () => {
|
|
@@ -83106,7 +83389,7 @@ var createStreamBody = (stream, useNativeReadableToWeb = useReadableToWeb) => {
|
|
|
83106
83389
|
});
|
|
83107
83390
|
};
|
|
83108
83391
|
|
|
83109
|
-
// ../../node_modules/.bun/hono@4.
|
|
83392
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/mime.js
|
|
83110
83393
|
var getMimeType = (filename, mimes = baseMimes) => {
|
|
83111
83394
|
const regexp = /\.([a-zA-Z0-9]+?)$/;
|
|
83112
83395
|
const match = filename.match(regexp);
|
|
@@ -83175,7 +83458,7 @@ var _baseMimes = {
|
|
|
83175
83458
|
};
|
|
83176
83459
|
var baseMimes = _baseMimes;
|
|
83177
83460
|
|
|
83178
|
-
// ../../node_modules/.bun/@hono+node-server@2.
|
|
83461
|
+
// ../../node_modules/.bun/@hono+node-server@2.1.1+2ac783cc5e75a70c/node_modules/@hono/node-server/dist/serve-static.mjs
|
|
83179
83462
|
import { createReadStream, existsSync as existsSync17, statSync as statSync5 } from "node:fs";
|
|
83180
83463
|
import { join as join14 } from "node:path";
|
|
83181
83464
|
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
@@ -83337,7 +83620,7 @@ import { existsSync as existsSync21 } from "node:fs";
|
|
|
83337
83620
|
import { readFileSync as readFileSync19, statSync as statSync8 } from "node:fs";
|
|
83338
83621
|
import { join as join18 } from "node:path";
|
|
83339
83622
|
|
|
83340
|
-
// ../../node_modules/.bun/hono@4.
|
|
83623
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/compose.js
|
|
83341
83624
|
var compose = (middleware, onError, onNotFound) => {
|
|
83342
83625
|
return (context, next) => {
|
|
83343
83626
|
let index = -1;
|
|
@@ -83381,10 +83664,10 @@ var compose = (middleware, onError, onNotFound) => {
|
|
|
83381
83664
|
};
|
|
83382
83665
|
};
|
|
83383
83666
|
|
|
83384
|
-
// ../../node_modules/.bun/hono@4.
|
|
83667
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/request/constants.js
|
|
83385
83668
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
83386
83669
|
|
|
83387
|
-
// ../../node_modules/.bun/hono@4.
|
|
83670
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/buffer.js
|
|
83388
83671
|
var bufferToFormData = (arrayBuffer, contentType) => {
|
|
83389
83672
|
const response = new Response(arrayBuffer, {
|
|
83390
83673
|
headers: {
|
|
@@ -83394,7 +83677,9 @@ var bufferToFormData = (arrayBuffer, contentType) => {
|
|
|
83394
83677
|
return response.formData();
|
|
83395
83678
|
};
|
|
83396
83679
|
|
|
83397
|
-
// ../../node_modules/.bun/hono@4.
|
|
83680
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/body.js
|
|
83681
|
+
var MAX_NESTING_DEPTH = 32;
|
|
83682
|
+
var MAX_NESTED_OBJECTS = 1e4;
|
|
83398
83683
|
var isRawRequest = (request) => ("headers" in request);
|
|
83399
83684
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
83400
83685
|
const { all = false, dot = false } = options;
|
|
@@ -83424,6 +83709,7 @@ async function parseFormData(request, options) {
|
|
|
83424
83709
|
}
|
|
83425
83710
|
function convertFormDataToBodyData(formData, options) {
|
|
83426
83711
|
const form = /* @__PURE__ */ Object.create(null);
|
|
83712
|
+
const nestingState = { count: 0 };
|
|
83427
83713
|
formData.forEach((value, key) => {
|
|
83428
83714
|
const shouldParseAllValues = options.all || key.endsWith("[]");
|
|
83429
83715
|
if (!shouldParseAllValues) {
|
|
@@ -83436,7 +83722,7 @@ function convertFormDataToBodyData(formData, options) {
|
|
|
83436
83722
|
Object.entries(form).forEach(([key, value]) => {
|
|
83437
83723
|
const shouldParseDotValues = key.includes(".");
|
|
83438
83724
|
if (shouldParseDotValues) {
|
|
83439
|
-
handleParsingNestedValues(form, key, value);
|
|
83725
|
+
handleParsingNestedValues(form, key, value, nestingState);
|
|
83440
83726
|
delete form[key];
|
|
83441
83727
|
}
|
|
83442
83728
|
});
|
|
@@ -83458,25 +83744,34 @@ var handleParsingAllValues = (form, key, value) => {
|
|
|
83458
83744
|
}
|
|
83459
83745
|
}
|
|
83460
83746
|
};
|
|
83461
|
-
var handleParsingNestedValues = (form, key, value) => {
|
|
83747
|
+
var handleParsingNestedValues = (form, key, value, state) => {
|
|
83462
83748
|
if (/(?:^|\.)__proto__\./.test(key)) {
|
|
83463
83749
|
return;
|
|
83464
83750
|
}
|
|
83465
83751
|
let nestedForm = form;
|
|
83466
|
-
const keys = key.split(".");
|
|
83752
|
+
const keys = key.split(".", MAX_NESTING_DEPTH + 2);
|
|
83753
|
+
if (keys.length > MAX_NESTING_DEPTH + 1) {
|
|
83754
|
+
throwNestingLimitExceeded();
|
|
83755
|
+
}
|
|
83467
83756
|
keys.forEach((key2, index) => {
|
|
83468
83757
|
if (index === keys.length - 1) {
|
|
83469
83758
|
nestedForm[key2] = value;
|
|
83470
83759
|
} else {
|
|
83471
83760
|
if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
|
|
83761
|
+
if (state.count++ >= MAX_NESTED_OBJECTS) {
|
|
83762
|
+
throwNestingLimitExceeded();
|
|
83763
|
+
}
|
|
83472
83764
|
nestedForm[key2] = /* @__PURE__ */ Object.create(null);
|
|
83473
83765
|
}
|
|
83474
83766
|
nestedForm = nestedForm[key2];
|
|
83475
83767
|
}
|
|
83476
83768
|
});
|
|
83477
83769
|
};
|
|
83770
|
+
var throwNestingLimitExceeded = () => {
|
|
83771
|
+
throw new Error("Nesting limit exceeded");
|
|
83772
|
+
};
|
|
83478
83773
|
|
|
83479
|
-
// ../../node_modules/.bun/hono@4.
|
|
83774
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/url.js
|
|
83480
83775
|
var splitPath = (path) => {
|
|
83481
83776
|
const paths = path.split("/");
|
|
83482
83777
|
if (paths[0] === "") {
|
|
@@ -83582,13 +83877,13 @@ var checkOptionalParameter = (path) => {
|
|
|
83582
83877
|
if (segment !== "" && !/\:/.test(segment)) {
|
|
83583
83878
|
basePath += "/" + segment;
|
|
83584
83879
|
} else if (/\:/.test(segment)) {
|
|
83585
|
-
if (
|
|
83880
|
+
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
83586
83881
|
if (results.length === 0 && basePath === "") {
|
|
83587
83882
|
results.push("/");
|
|
83588
83883
|
} else {
|
|
83589
83884
|
results.push(basePath);
|
|
83590
83885
|
}
|
|
83591
|
-
const optionalSegment = segment.
|
|
83886
|
+
const optionalSegment = segment.slice(0, -1);
|
|
83592
83887
|
basePath += "/" + optionalSegment;
|
|
83593
83888
|
results.push(basePath);
|
|
83594
83889
|
} else {
|
|
@@ -83598,18 +83893,20 @@ var checkOptionalParameter = (path) => {
|
|
|
83598
83893
|
});
|
|
83599
83894
|
return results.filter((v, i, a) => a.indexOf(v) === i);
|
|
83600
83895
|
};
|
|
83896
|
+
var tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode2(str, decodeURIComponent_) : str;
|
|
83601
83897
|
var _decodeURI = (value) => {
|
|
83602
|
-
if (!/[%+]/.test(value)) {
|
|
83603
|
-
return value;
|
|
83604
|
-
}
|
|
83605
83898
|
if (value.indexOf("+") !== -1) {
|
|
83606
83899
|
value = value.replace(/\+/g, " ");
|
|
83607
83900
|
}
|
|
83608
|
-
return
|
|
83901
|
+
return tryDecodeURIComponent(value);
|
|
83609
83902
|
};
|
|
83610
83903
|
var _getQueryParam = (url, key, multiple) => {
|
|
83904
|
+
const hashIndex = url.indexOf("#", 8);
|
|
83905
|
+
if (hashIndex !== -1) {
|
|
83906
|
+
url = url.slice(0, hashIndex);
|
|
83907
|
+
}
|
|
83611
83908
|
let encoded;
|
|
83612
|
-
if (!multiple && key &&
|
|
83909
|
+
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
83613
83910
|
let keyIndex2 = url.indexOf("?", 8);
|
|
83614
83911
|
if (keyIndex2 === -1) {
|
|
83615
83912
|
return;
|
|
@@ -83676,8 +83973,7 @@ var getQueryParams = (url, key) => {
|
|
|
83676
83973
|
};
|
|
83677
83974
|
var decodeURIComponent_ = decodeURIComponent;
|
|
83678
83975
|
|
|
83679
|
-
// ../../node_modules/.bun/hono@4.
|
|
83680
|
-
var tryDecodeURIComponent = (str) => tryDecode2(str, decodeURIComponent_);
|
|
83976
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/request.js
|
|
83681
83977
|
var HonoRequest = class {
|
|
83682
83978
|
raw;
|
|
83683
83979
|
#validatedData;
|
|
@@ -83689,23 +83985,22 @@ var HonoRequest = class {
|
|
|
83689
83985
|
this.raw = request;
|
|
83690
83986
|
this.path = path;
|
|
83691
83987
|
this.#matchResult = matchResult;
|
|
83692
|
-
this.#validatedData = {};
|
|
83693
83988
|
}
|
|
83694
83989
|
param(key) {
|
|
83695
83990
|
return key ? this.#getDecodedParam(key) : this.#getAllDecodedParams();
|
|
83696
83991
|
}
|
|
83697
83992
|
#getDecodedParam(key) {
|
|
83698
|
-
const paramKey = this.#matchResult[0][this.routeIndex][1][key];
|
|
83993
|
+
const paramKey = this.#matchResult[0][this.routeIndex]?.[1][key];
|
|
83699
83994
|
const param = this.#getParamValue(paramKey);
|
|
83700
|
-
return param &&
|
|
83995
|
+
return param && tryDecodeURIComponent(param);
|
|
83701
83996
|
}
|
|
83702
83997
|
#getAllDecodedParams() {
|
|
83703
83998
|
const decoded = {};
|
|
83704
|
-
const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
|
|
83999
|
+
const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
|
|
83705
84000
|
for (const key of keys) {
|
|
83706
84001
|
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
|
|
83707
84002
|
if (value !== undefined) {
|
|
83708
|
-
decoded[key] =
|
|
84003
|
+
decoded[key] = tryDecodeURIComponent(value);
|
|
83709
84004
|
}
|
|
83710
84005
|
}
|
|
83711
84006
|
return decoded;
|
|
@@ -83738,8 +84033,7 @@ var HonoRequest = class {
|
|
|
83738
84033
|
if (cachedBody) {
|
|
83739
84034
|
return cachedBody;
|
|
83740
84035
|
}
|
|
83741
|
-
const anyCachedKey
|
|
83742
|
-
if (anyCachedKey) {
|
|
84036
|
+
for (const anyCachedKey in bodyCache) {
|
|
83743
84037
|
return bodyCache[anyCachedKey].then((body) => {
|
|
83744
84038
|
if (anyCachedKey === "json") {
|
|
83745
84039
|
body = JSON.stringify(body);
|
|
@@ -83768,10 +84062,10 @@ var HonoRequest = class {
|
|
|
83768
84062
|
return this.#cachedBody("formData");
|
|
83769
84063
|
}
|
|
83770
84064
|
addValidatedData(target, data) {
|
|
83771
|
-
this.#validatedData[target] = data;
|
|
84065
|
+
(this.#validatedData ??= {})[target] = data;
|
|
83772
84066
|
}
|
|
83773
84067
|
valid(target) {
|
|
83774
|
-
return this.#validatedData[target];
|
|
84068
|
+
return this.#validatedData?.[target];
|
|
83775
84069
|
}
|
|
83776
84070
|
get url() {
|
|
83777
84071
|
return this.raw.url;
|
|
@@ -83790,7 +84084,7 @@ var HonoRequest = class {
|
|
|
83790
84084
|
}
|
|
83791
84085
|
};
|
|
83792
84086
|
|
|
83793
|
-
// ../../node_modules/.bun/hono@4.
|
|
84087
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/html.js
|
|
83794
84088
|
var HtmlEscapedCallbackPhase = {
|
|
83795
84089
|
Stringify: 1,
|
|
83796
84090
|
BeforeStream: 2,
|
|
@@ -83828,7 +84122,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
83828
84122
|
}
|
|
83829
84123
|
};
|
|
83830
84124
|
|
|
83831
|
-
// ../../node_modules/.bun/hono@4.
|
|
84125
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/context.js
|
|
83832
84126
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
83833
84127
|
var setDefaultContentType = (contentType, headers) => {
|
|
83834
84128
|
return {
|
|
@@ -83946,11 +84240,11 @@ var Context = class {
|
|
|
83946
84240
|
return Object.fromEntries(this.#var);
|
|
83947
84241
|
}
|
|
83948
84242
|
#newResponse(data, arg, headers) {
|
|
83949
|
-
|
|
83950
|
-
if (typeof arg === "object" &&
|
|
83951
|
-
|
|
83952
|
-
for (const [key, value] of
|
|
83953
|
-
if (key
|
|
84243
|
+
let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
|
|
84244
|
+
if (typeof arg === "object" && arg.headers) {
|
|
84245
|
+
responseHeaders ??= new Headers;
|
|
84246
|
+
for (const [key, value] of new Headers(arg.headers)) {
|
|
84247
|
+
if (key === "set-cookie") {
|
|
83954
84248
|
responseHeaders.append(key, value);
|
|
83955
84249
|
} else {
|
|
83956
84250
|
responseHeaders.set(key, value);
|
|
@@ -83958,19 +84252,34 @@ var Context = class {
|
|
|
83958
84252
|
}
|
|
83959
84253
|
}
|
|
83960
84254
|
if (headers) {
|
|
83961
|
-
|
|
83962
|
-
|
|
83963
|
-
|
|
83964
|
-
|
|
83965
|
-
|
|
83966
|
-
|
|
83967
|
-
|
|
84255
|
+
if (!responseHeaders) {
|
|
84256
|
+
let count = 0;
|
|
84257
|
+
for (const k in headers) {
|
|
84258
|
+
if (++count > 1 || typeof headers[k] !== "string") {
|
|
84259
|
+
responseHeaders = new Headers;
|
|
84260
|
+
break;
|
|
84261
|
+
}
|
|
84262
|
+
}
|
|
84263
|
+
}
|
|
84264
|
+
if (responseHeaders) {
|
|
84265
|
+
for (const k in headers) {
|
|
84266
|
+
const v = headers[k];
|
|
84267
|
+
if (typeof v === "string") {
|
|
84268
|
+
responseHeaders.set(k, v);
|
|
84269
|
+
} else {
|
|
84270
|
+
responseHeaders.delete(k);
|
|
84271
|
+
for (const v2 of v) {
|
|
84272
|
+
responseHeaders.append(k, v2);
|
|
84273
|
+
}
|
|
83968
84274
|
}
|
|
83969
84275
|
}
|
|
83970
84276
|
}
|
|
83971
84277
|
}
|
|
83972
84278
|
const status = typeof arg === "number" ? arg : arg?.status ?? this.#status;
|
|
83973
|
-
return createResponseInstance(data, {
|
|
84279
|
+
return createResponseInstance(data, {
|
|
84280
|
+
status,
|
|
84281
|
+
headers: responseHeaders ?? headers
|
|
84282
|
+
});
|
|
83974
84283
|
}
|
|
83975
84284
|
newResponse = (...args) => this.#newResponse(...args);
|
|
83976
84285
|
body = (data, arg, headers) => this.#newResponse(data, arg, headers);
|
|
@@ -83995,18 +84304,18 @@ var Context = class {
|
|
|
83995
84304
|
};
|
|
83996
84305
|
};
|
|
83997
84306
|
|
|
83998
|
-
// ../../node_modules/.bun/hono@4.
|
|
84307
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router.js
|
|
83999
84308
|
var METHOD_NAME_ALL = "ALL";
|
|
84000
84309
|
var METHOD_NAME_ALL_LOWERCASE = "all";
|
|
84001
|
-
var METHODS = ["get", "post", "put", "delete", "options", "patch"];
|
|
84310
|
+
var METHODS = ["get", "post", "put", "delete", "options", "patch", "query"];
|
|
84002
84311
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
84003
84312
|
var UnsupportedPathError = class extends Error {
|
|
84004
84313
|
};
|
|
84005
84314
|
|
|
84006
|
-
// ../../node_modules/.bun/hono@4.
|
|
84315
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/constants.js
|
|
84007
84316
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
84008
84317
|
|
|
84009
|
-
// ../../node_modules/.bun/hono@4.
|
|
84318
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/hono-base.js
|
|
84010
84319
|
var notFoundHandler = (c) => {
|
|
84011
84320
|
return c.text("404 Not Found", 404);
|
|
84012
84321
|
};
|
|
@@ -84025,6 +84334,7 @@ var Hono = class _Hono {
|
|
|
84025
84334
|
delete;
|
|
84026
84335
|
options;
|
|
84027
84336
|
patch;
|
|
84337
|
+
query;
|
|
84028
84338
|
all;
|
|
84029
84339
|
on;
|
|
84030
84340
|
use;
|
|
@@ -84037,13 +84347,14 @@ var Hono = class _Hono {
|
|
|
84037
84347
|
const allMethods = [...METHODS, METHOD_NAME_ALL_LOWERCASE];
|
|
84038
84348
|
allMethods.forEach((method) => {
|
|
84039
84349
|
this[method] = (args1, ...args) => {
|
|
84350
|
+
const methodName = method.toUpperCase();
|
|
84040
84351
|
if (typeof args1 === "string") {
|
|
84041
84352
|
this.#path = args1;
|
|
84042
84353
|
} else {
|
|
84043
|
-
this.#addRoute(
|
|
84354
|
+
this.#addRoute(methodName, this.#path, args1);
|
|
84044
84355
|
}
|
|
84045
84356
|
args.forEach((handler) => {
|
|
84046
|
-
this.#addRoute(
|
|
84357
|
+
this.#addRoute(methodName, this.#path, handler);
|
|
84047
84358
|
});
|
|
84048
84359
|
return this;
|
|
84049
84360
|
};
|
|
@@ -84052,9 +84363,10 @@ var Hono = class _Hono {
|
|
|
84052
84363
|
for (const p of [path].flat()) {
|
|
84053
84364
|
this.#path = p;
|
|
84054
84365
|
for (const m of [method].flat()) {
|
|
84055
|
-
|
|
84056
|
-
|
|
84057
|
-
|
|
84366
|
+
const methodName = m.toUpperCase();
|
|
84367
|
+
for (const handler of handlers) {
|
|
84368
|
+
this.#addRoute(methodName, this.#path, handler);
|
|
84369
|
+
}
|
|
84058
84370
|
}
|
|
84059
84371
|
}
|
|
84060
84372
|
return this;
|
|
@@ -84159,7 +84471,6 @@ var Hono = class _Hono {
|
|
|
84159
84471
|
return this;
|
|
84160
84472
|
}
|
|
84161
84473
|
#addRoute(method, path, handler, baseRoutePath) {
|
|
84162
|
-
method = method.toUpperCase();
|
|
84163
84474
|
path = mergePath(this._basePath, path);
|
|
84164
84475
|
const r = {
|
|
84165
84476
|
basePath: baseRoutePath !== undefined ? mergePath(this._basePath, baseRoutePath) : this._basePath,
|
|
@@ -84230,7 +84541,10 @@ var Hono = class _Hono {
|
|
|
84230
84541
|
};
|
|
84231
84542
|
};
|
|
84232
84543
|
|
|
84233
|
-
// ../../node_modules/.bun/hono@4.
|
|
84544
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/utils.js
|
|
84545
|
+
var createNullObject = () => /* @__PURE__ */ Object.create(null);
|
|
84546
|
+
|
|
84547
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
84234
84548
|
var emptyParam = [];
|
|
84235
84549
|
function match(method, path) {
|
|
84236
84550
|
const matchers = this.buildAllMatchers();
|
|
@@ -84251,7 +84565,7 @@ function match(method, path) {
|
|
|
84251
84565
|
return match2(method, path);
|
|
84252
84566
|
}
|
|
84253
84567
|
|
|
84254
|
-
// ../../node_modules/.bun/hono@4.
|
|
84568
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
84255
84569
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
84256
84570
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
84257
84571
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -84265,7 +84579,7 @@ function compareKey(a, b) {
|
|
|
84265
84579
|
return 1;
|
|
84266
84580
|
}
|
|
84267
84581
|
if (a === ONLY_WILDCARD_REG_EXP_STR || a === TAIL_WILDCARD_REG_EXP_STR) {
|
|
84268
|
-
return 1;
|
|
84582
|
+
return b === TAIL_WILDCARD_REG_EXP_STR ? -1 : 1;
|
|
84269
84583
|
} else if (b === ONLY_WILDCARD_REG_EXP_STR || b === TAIL_WILDCARD_REG_EXP_STR) {
|
|
84270
84584
|
return -1;
|
|
84271
84585
|
}
|
|
@@ -84279,70 +84593,69 @@ function compareKey(a, b) {
|
|
|
84279
84593
|
var Node = class _Node {
|
|
84280
84594
|
#index;
|
|
84281
84595
|
#varIndex;
|
|
84282
|
-
#children =
|
|
84283
|
-
insert(tokens, index, paramMap, context,
|
|
84284
|
-
|
|
84285
|
-
|
|
84286
|
-
|
|
84287
|
-
}
|
|
84288
|
-
|
|
84289
|
-
|
|
84290
|
-
|
|
84291
|
-
|
|
84292
|
-
|
|
84293
|
-
|
|
84294
|
-
|
|
84295
|
-
|
|
84296
|
-
|
|
84297
|
-
|
|
84298
|
-
|
|
84299
|
-
|
|
84300
|
-
|
|
84301
|
-
|
|
84302
|
-
|
|
84303
|
-
}
|
|
84304
|
-
|
|
84305
|
-
if (
|
|
84306
|
-
|
|
84307
|
-
|
|
84308
|
-
|
|
84309
|
-
|
|
84310
|
-
|
|
84311
|
-
|
|
84312
|
-
|
|
84313
|
-
|
|
84314
|
-
if (pathErrorCheckOnly) {
|
|
84315
|
-
return;
|
|
84596
|
+
#children = createNullObject();
|
|
84597
|
+
insert(tokens, index, paramMap, context, isStatic) {
|
|
84598
|
+
let node = this;
|
|
84599
|
+
for (let i = 0, len = tokens.length;i < len; i++) {
|
|
84600
|
+
const token = tokens[i];
|
|
84601
|
+
const pattern = token.length === 1 ? token === "*" ? i === len - 1 ? ["", "", ONLY_WILDCARD_REG_EXP_STR] : ["", "", LABEL_REG_EXP_STR] : null : token === "/*" ? ["", "", TAIL_WILDCARD_REG_EXP_STR] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
84602
|
+
let nextNode;
|
|
84603
|
+
if (pattern) {
|
|
84604
|
+
const name = pattern[1];
|
|
84605
|
+
let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
|
|
84606
|
+
if (name && pattern[2]) {
|
|
84607
|
+
if (regexpStr === ".*") {
|
|
84608
|
+
throw PATH_ERROR;
|
|
84609
|
+
}
|
|
84610
|
+
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
84611
|
+
if (/\((?!\?:)/.test(regexpStr)) {
|
|
84612
|
+
throw PATH_ERROR;
|
|
84613
|
+
}
|
|
84614
|
+
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) {
|
|
84615
|
+
throw PATH_ERROR;
|
|
84616
|
+
}
|
|
84617
|
+
}
|
|
84618
|
+
nextNode = node.#children[regexpStr];
|
|
84619
|
+
if (!nextNode) {
|
|
84620
|
+
if (regexpStr !== ONLY_WILDCARD_REG_EXP_STR && regexpStr !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
84621
|
+
for (const k in node.#children) {
|
|
84622
|
+
if ((regexpStr.length > 1 || k.length > 1) && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
84623
|
+
throw PATH_ERROR;
|
|
84624
|
+
}
|
|
84625
|
+
}
|
|
84626
|
+
}
|
|
84627
|
+
nextNode = node.#children[regexpStr] = new _Node;
|
|
84316
84628
|
}
|
|
84317
|
-
node = this.#children[regexpStr] = new _Node;
|
|
84318
84629
|
if (name !== "") {
|
|
84319
|
-
|
|
84320
|
-
|
|
84321
|
-
}
|
|
84322
|
-
if (!pathErrorCheckOnly && name !== "") {
|
|
84323
|
-
paramMap.push([name, node.#varIndex]);
|
|
84324
|
-
}
|
|
84325
|
-
} else {
|
|
84326
|
-
node = this.#children[token];
|
|
84327
|
-
if (!node) {
|
|
84328
|
-
if (Object.keys(this.#children).some((k) => k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR)) {
|
|
84329
|
-
throw PATH_ERROR;
|
|
84630
|
+
nextNode.#varIndex ??= context.varIndex++;
|
|
84631
|
+
paramMap.push([name, nextNode.#varIndex]);
|
|
84330
84632
|
}
|
|
84331
|
-
|
|
84332
|
-
|
|
84633
|
+
} else {
|
|
84634
|
+
nextNode = node.#children[token];
|
|
84635
|
+
if (!nextNode) {
|
|
84636
|
+
for (const k in node.#children) {
|
|
84637
|
+
if (k.length > 1 && k !== ONLY_WILDCARD_REG_EXP_STR && k !== TAIL_WILDCARD_REG_EXP_STR) {
|
|
84638
|
+
throw PATH_ERROR;
|
|
84639
|
+
}
|
|
84640
|
+
}
|
|
84641
|
+
nextNode = node.#children[token] = new _Node;
|
|
84333
84642
|
}
|
|
84334
|
-
node = this.#children[token] = new _Node;
|
|
84335
84643
|
}
|
|
84644
|
+
node = nextNode;
|
|
84336
84645
|
}
|
|
84337
|
-
node
|
|
84646
|
+
if (node.#index !== undefined) {
|
|
84647
|
+
throw PATH_ERROR;
|
|
84648
|
+
}
|
|
84649
|
+
node.#index = isStatic ? -1 : index;
|
|
84338
84650
|
}
|
|
84339
84651
|
buildRegExpStr() {
|
|
84340
84652
|
const childKeys = Object.keys(this.#children).sort(compareKey);
|
|
84341
84653
|
const strList = childKeys.map((k) => {
|
|
84342
84654
|
const c = this.#children[k];
|
|
84343
|
-
|
|
84344
|
-
|
|
84345
|
-
|
|
84655
|
+
const childStr = c.buildRegExpStr();
|
|
84656
|
+
return childStr === "" ? "" : (typeof c.#varIndex === "number" ? `(${k})@${c.#varIndex}` : regExpMetaChars.has(k) ? `\\${k}` : k) + childStr;
|
|
84657
|
+
}).filter(Boolean);
|
|
84658
|
+
if (typeof this.#index === "number" && this.#index !== -1) {
|
|
84346
84659
|
strList.unshift(`#${this.#index}`);
|
|
84347
84660
|
}
|
|
84348
84661
|
if (strList.length === 0) {
|
|
@@ -84355,16 +84668,23 @@ var Node = class _Node {
|
|
|
84355
84668
|
}
|
|
84356
84669
|
};
|
|
84357
84670
|
|
|
84358
|
-
// ../../node_modules/.bun/hono@4.
|
|
84671
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
84359
84672
|
var Trie = class {
|
|
84360
84673
|
#context = { varIndex: 0 };
|
|
84361
84674
|
#root = new Node;
|
|
84362
|
-
|
|
84675
|
+
#index = 0;
|
|
84676
|
+
paths = createNullObject();
|
|
84677
|
+
insert(path, isStatic) {
|
|
84678
|
+
if (isStatic) {
|
|
84679
|
+
this.#root.insert(path.split(""), 0, [], this.#context, true);
|
|
84680
|
+
return;
|
|
84681
|
+
}
|
|
84363
84682
|
const paramAssoc = [];
|
|
84364
84683
|
const groups = [];
|
|
84684
|
+
let markedPath = path;
|
|
84365
84685
|
for (let i = 0;; ) {
|
|
84366
84686
|
let replaced = false;
|
|
84367
|
-
|
|
84687
|
+
markedPath = markedPath.replace(/\{[^}]+\}/g, (m) => {
|
|
84368
84688
|
const mark = `@\\${i}`;
|
|
84369
84689
|
groups[i] = [mark, m];
|
|
84370
84690
|
i++;
|
|
@@ -84375,7 +84695,7 @@ var Trie = class {
|
|
|
84375
84695
|
break;
|
|
84376
84696
|
}
|
|
84377
84697
|
}
|
|
84378
|
-
const tokens =
|
|
84698
|
+
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
84379
84699
|
for (let i = groups.length - 1;i >= 0; i--) {
|
|
84380
84700
|
const [mark] = groups[i];
|
|
84381
84701
|
for (let j = tokens.length - 1;j >= 0; j--) {
|
|
@@ -84385,8 +84705,8 @@ var Trie = class {
|
|
|
84385
84705
|
}
|
|
84386
84706
|
}
|
|
84387
84707
|
}
|
|
84388
|
-
this.#root.insert(tokens, index, paramAssoc, this.#context,
|
|
84389
|
-
|
|
84708
|
+
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
|
|
84709
|
+
this.paths[path] = [this.#index++, paramAssoc];
|
|
84390
84710
|
}
|
|
84391
84711
|
buildRegExp() {
|
|
84392
84712
|
let regexp = this.#root.buildRegExpStr();
|
|
@@ -84411,72 +84731,12 @@ var Trie = class {
|
|
|
84411
84731
|
}
|
|
84412
84732
|
};
|
|
84413
84733
|
|
|
84414
|
-
// ../../node_modules/.bun/hono@4.
|
|
84415
|
-
var
|
|
84416
|
-
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
84734
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
84735
|
+
var wildcardRegExpCache = createNullObject();
|
|
84417
84736
|
function buildWildcardRegExp(path) {
|
|
84418
|
-
return wildcardRegExpCache[path] ??= new RegExp(
|
|
84419
|
-
}
|
|
84420
|
-
function clearWildcardRegExpCache() {
|
|
84421
|
-
wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
|
|
84422
|
-
}
|
|
84423
|
-
function buildMatcherFromPreprocessedRoutes(routes) {
|
|
84424
|
-
const trie = new Trie;
|
|
84425
|
-
const handlerData = [];
|
|
84426
|
-
if (routes.length === 0) {
|
|
84427
|
-
return nullMatcher;
|
|
84428
|
-
}
|
|
84429
|
-
const routesWithStaticPathFlag = routes.map((route) => [!/\*|\/:/.test(route[0]), ...route]).sort(([isStaticA, pathA], [isStaticB, pathB]) => isStaticA ? 1 : isStaticB ? -1 : pathA.length - pathB.length);
|
|
84430
|
-
const staticMap = /* @__PURE__ */ Object.create(null);
|
|
84431
|
-
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length;i < len; i++) {
|
|
84432
|
-
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
|
|
84433
|
-
if (pathErrorCheckOnly) {
|
|
84434
|
-
staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
|
|
84435
|
-
} else {
|
|
84436
|
-
j++;
|
|
84437
|
-
}
|
|
84438
|
-
let paramAssoc;
|
|
84439
|
-
try {
|
|
84440
|
-
paramAssoc = trie.insert(path, j, pathErrorCheckOnly);
|
|
84441
|
-
} catch (e) {
|
|
84442
|
-
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
84443
|
-
}
|
|
84444
|
-
if (pathErrorCheckOnly) {
|
|
84445
|
-
continue;
|
|
84446
|
-
}
|
|
84447
|
-
handlerData[j] = handlers.map(([h, paramCount]) => {
|
|
84448
|
-
const paramIndexMap = /* @__PURE__ */ Object.create(null);
|
|
84449
|
-
paramCount -= 1;
|
|
84450
|
-
for (;paramCount >= 0; paramCount--) {
|
|
84451
|
-
const [key, value] = paramAssoc[paramCount];
|
|
84452
|
-
paramIndexMap[key] = value;
|
|
84453
|
-
}
|
|
84454
|
-
return [h, paramIndexMap];
|
|
84455
|
-
});
|
|
84456
|
-
}
|
|
84457
|
-
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
84458
|
-
for (let i = 0, len = handlerData.length;i < len; i++) {
|
|
84459
|
-
for (let j = 0, len2 = handlerData[i].length;j < len2; j++) {
|
|
84460
|
-
const map = handlerData[i][j]?.[1];
|
|
84461
|
-
if (!map) {
|
|
84462
|
-
continue;
|
|
84463
|
-
}
|
|
84464
|
-
const keys = Object.keys(map);
|
|
84465
|
-
for (let k = 0, len3 = keys.length;k < len3; k++) {
|
|
84466
|
-
map[keys[k]] = paramReplacementMap[map[keys[k]]];
|
|
84467
|
-
}
|
|
84468
|
-
}
|
|
84469
|
-
}
|
|
84470
|
-
const handlerMap = [];
|
|
84471
|
-
for (const i in indexReplacementMap) {
|
|
84472
|
-
handlerMap[i] = handlerData[indexReplacementMap[i]];
|
|
84473
|
-
}
|
|
84474
|
-
return [regexp, handlerMap, staticMap];
|
|
84737
|
+
return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ONLY_WILDCARD_REG_EXP_STR : `/:${LABEL_REG_EXP_STR}`)}$`);
|
|
84475
84738
|
}
|
|
84476
84739
|
function findMiddleware(middleware, path) {
|
|
84477
|
-
if (!middleware) {
|
|
84478
|
-
return;
|
|
84479
|
-
}
|
|
84480
84740
|
for (const k of Object.keys(middleware).sort((a, b) => b.length - a.length)) {
|
|
84481
84741
|
if (buildWildcardRegExp(k).test(path)) {
|
|
84482
84742
|
return [...middleware[k]];
|
|
@@ -84488,95 +84748,106 @@ var RegExpRouter = class {
|
|
|
84488
84748
|
name = "RegExpRouter";
|
|
84489
84749
|
#middleware;
|
|
84490
84750
|
#routes;
|
|
84751
|
+
#tries;
|
|
84491
84752
|
constructor() {
|
|
84492
|
-
this.#middleware = { [METHOD_NAME_ALL]:
|
|
84493
|
-
this.#routes = { [METHOD_NAME_ALL]:
|
|
84753
|
+
this.#middleware = { [METHOD_NAME_ALL]: createNullObject() };
|
|
84754
|
+
this.#routes = { [METHOD_NAME_ALL]: createNullObject() };
|
|
84755
|
+
this.#tries = { [METHOD_NAME_ALL]: new Trie };
|
|
84756
|
+
}
|
|
84757
|
+
#insertPath(method, path) {
|
|
84758
|
+
try {
|
|
84759
|
+
this.#tries[method].insert(path, !/\*|\/:/.test(path));
|
|
84760
|
+
} catch (e) {
|
|
84761
|
+
throw e === PATH_ERROR ? new UnsupportedPathError(path) : e;
|
|
84762
|
+
}
|
|
84494
84763
|
}
|
|
84495
84764
|
add(method, path, handler) {
|
|
84496
84765
|
const middleware = this.#middleware;
|
|
84497
84766
|
const routes = this.#routes;
|
|
84498
|
-
if (!middleware
|
|
84767
|
+
if (!middleware) {
|
|
84499
84768
|
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
84500
84769
|
}
|
|
84501
84770
|
if (!middleware[method]) {
|
|
84502
|
-
[
|
|
84503
|
-
|
|
84504
|
-
|
|
84771
|
+
this.#tries[method] = new Trie;
|
|
84772
|
+
for (const handlerMap of [middleware, routes]) {
|
|
84773
|
+
handlerMap[method] = createNullObject();
|
|
84774
|
+
for (const p in handlerMap[METHOD_NAME_ALL]) {
|
|
84505
84775
|
handlerMap[method][p] = [...handlerMap[METHOD_NAME_ALL][p]];
|
|
84506
|
-
|
|
84507
|
-
|
|
84776
|
+
this.#insertPath(method, p);
|
|
84777
|
+
}
|
|
84778
|
+
}
|
|
84508
84779
|
}
|
|
84509
84780
|
if (path === "/*") {
|
|
84510
84781
|
path = "*";
|
|
84511
84782
|
}
|
|
84512
|
-
const
|
|
84783
|
+
const methods = method === METHOD_NAME_ALL ? Object.keys(middleware) : [method];
|
|
84513
84784
|
if (/\*$/.test(path)) {
|
|
84514
84785
|
const re = buildWildcardRegExp(path);
|
|
84515
|
-
|
|
84516
|
-
|
|
84517
|
-
|
|
84518
|
-
|
|
84519
|
-
} else {
|
|
84520
|
-
middleware[method][path] ||= findMiddleware(middleware[method], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
84521
|
-
}
|
|
84522
|
-
Object.keys(middleware).forEach((m) => {
|
|
84523
|
-
if (method === METHOD_NAME_ALL || method === m) {
|
|
84524
|
-
Object.keys(middleware[m]).forEach((p) => {
|
|
84525
|
-
re.test(p) && middleware[m][p].push([handler, paramCount]);
|
|
84526
|
-
});
|
|
84786
|
+
for (const m of methods) {
|
|
84787
|
+
if (!middleware[m][path]) {
|
|
84788
|
+
this.#insertPath(m, path);
|
|
84789
|
+
middleware[m][path] = findMiddleware(middleware[m], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
84527
84790
|
}
|
|
84528
|
-
}
|
|
84529
|
-
|
|
84530
|
-
|
|
84531
|
-
|
|
84791
|
+
}
|
|
84792
|
+
for (const handlerMap of [middleware, routes]) {
|
|
84793
|
+
for (const m of methods) {
|
|
84794
|
+
for (const p in handlerMap[m]) {
|
|
84795
|
+
re.test(p) && handlerMap[m][p].push([handler, path]);
|
|
84796
|
+
}
|
|
84532
84797
|
}
|
|
84533
|
-
}
|
|
84798
|
+
}
|
|
84534
84799
|
return;
|
|
84535
84800
|
}
|
|
84536
84801
|
const paths = checkOptionalParameter(path) || [path];
|
|
84537
|
-
for (
|
|
84538
|
-
const
|
|
84539
|
-
|
|
84540
|
-
|
|
84541
|
-
routes[m][path2]
|
|
84542
|
-
...findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || []
|
|
84543
|
-
];
|
|
84544
|
-
routes[m][path2].push([handler, paramCount - len + i + 1]);
|
|
84802
|
+
for (const path2 of paths) {
|
|
84803
|
+
for (const m of methods) {
|
|
84804
|
+
if (!routes[m][path2]) {
|
|
84805
|
+
this.#insertPath(m, path2);
|
|
84806
|
+
routes[m][path2] = findMiddleware(middleware[m], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || [];
|
|
84545
84807
|
}
|
|
84546
|
-
|
|
84808
|
+
routes[m][path2].push([handler, path2]);
|
|
84809
|
+
}
|
|
84547
84810
|
}
|
|
84548
84811
|
}
|
|
84549
84812
|
match = match;
|
|
84550
84813
|
buildAllMatchers() {
|
|
84551
|
-
const matchers =
|
|
84552
|
-
Object.keys(this.#routes)
|
|
84553
|
-
matchers[method]
|
|
84554
|
-
}
|
|
84555
|
-
this.#middleware = this.#routes = undefined;
|
|
84556
|
-
|
|
84814
|
+
const matchers = createNullObject();
|
|
84815
|
+
for (const method of Object.keys(this.#routes)) {
|
|
84816
|
+
matchers[method] = this.#buildMatcher(method);
|
|
84817
|
+
}
|
|
84818
|
+
this.#middleware = this.#routes = this.#tries = undefined;
|
|
84819
|
+
wildcardRegExpCache = createNullObject();
|
|
84557
84820
|
return matchers;
|
|
84558
84821
|
}
|
|
84559
84822
|
#buildMatcher(method) {
|
|
84560
|
-
const
|
|
84561
|
-
|
|
84562
|
-
|
|
84563
|
-
|
|
84564
|
-
|
|
84565
|
-
|
|
84566
|
-
|
|
84567
|
-
|
|
84568
|
-
|
|
84823
|
+
const middleware = this.#middleware[method];
|
|
84824
|
+
const routes = this.#routes[method];
|
|
84825
|
+
const trie = this.#tries[method];
|
|
84826
|
+
const staticMap = createNullObject();
|
|
84827
|
+
const handlerData = [];
|
|
84828
|
+
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
84829
|
+
for (const r of [middleware, routes]) {
|
|
84830
|
+
for (const path in r) {
|
|
84831
|
+
const handlers = r[path];
|
|
84832
|
+
const pathData = trie.paths[path];
|
|
84833
|
+
if (!pathData) {
|
|
84834
|
+
staticMap[path] = [handlers.map(([h]) => [h, createNullObject()]), emptyParam];
|
|
84835
|
+
continue;
|
|
84836
|
+
}
|
|
84837
|
+
handlerData[pathData[0]] = handlers.map(([h, handlerPath]) => [
|
|
84838
|
+
h,
|
|
84839
|
+
trie.paths[handlerPath][1].reduceRight((map, [key], i) => {
|
|
84840
|
+
map[key] = paramReplacementMap[pathData[1][i][1]];
|
|
84841
|
+
return map;
|
|
84842
|
+
}, createNullObject())
|
|
84843
|
+
]);
|
|
84569
84844
|
}
|
|
84570
|
-
});
|
|
84571
|
-
if (!hasOwnRoute) {
|
|
84572
|
-
return null;
|
|
84573
|
-
} else {
|
|
84574
|
-
return buildMatcherFromPreprocessedRoutes(routes);
|
|
84575
84845
|
}
|
|
84846
|
+
return [regexp, indexReplacementMap.map((i) => handlerData[i]), staticMap];
|
|
84576
84847
|
}
|
|
84577
84848
|
};
|
|
84578
84849
|
|
|
84579
|
-
// ../../node_modules/.bun/hono@4.
|
|
84850
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/smart-router/router.js
|
|
84580
84851
|
var SmartRouter = class {
|
|
84581
84852
|
name = "SmartRouter";
|
|
84582
84853
|
#routers = [];
|
|
@@ -84631,78 +84902,53 @@ var SmartRouter = class {
|
|
|
84631
84902
|
}
|
|
84632
84903
|
};
|
|
84633
84904
|
|
|
84634
|
-
// ../../node_modules/.bun/hono@4.
|
|
84635
|
-
var emptyParams =
|
|
84636
|
-
var
|
|
84637
|
-
for (const _ in children) {
|
|
84638
|
-
return true;
|
|
84639
|
-
}
|
|
84640
|
-
return false;
|
|
84641
|
-
};
|
|
84905
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/trie-router/node.js
|
|
84906
|
+
var emptyParams = createNullObject();
|
|
84907
|
+
var order = 0;
|
|
84642
84908
|
var Node2 = class _Node {
|
|
84643
|
-
#methods;
|
|
84644
|
-
#children;
|
|
84645
|
-
#patterns;
|
|
84646
|
-
#
|
|
84909
|
+
#methods = [];
|
|
84910
|
+
#children = createNullObject();
|
|
84911
|
+
#patterns = [];
|
|
84912
|
+
#pattern;
|
|
84647
84913
|
#params = emptyParams;
|
|
84648
|
-
constructor(method, handler, children) {
|
|
84649
|
-
this.#children = children || /* @__PURE__ */ Object.create(null);
|
|
84650
|
-
this.#methods = [];
|
|
84651
|
-
if (method && handler) {
|
|
84652
|
-
const m = /* @__PURE__ */ Object.create(null);
|
|
84653
|
-
m[method] = { handler, possibleKeys: [], score: 0 };
|
|
84654
|
-
this.#methods = [m];
|
|
84655
|
-
}
|
|
84656
|
-
this.#patterns = [];
|
|
84657
|
-
}
|
|
84658
84914
|
insert(method, path, handler) {
|
|
84659
|
-
this.#order = ++this.#order;
|
|
84660
84915
|
let curNode = this;
|
|
84661
84916
|
const parts = splitRoutingPath(path);
|
|
84662
|
-
const possibleKeys =
|
|
84663
|
-
|
|
84664
|
-
|
|
84665
|
-
const nextP = parts[i
|
|
84666
|
-
const pattern = getPattern(p, nextP);
|
|
84667
|
-
const
|
|
84668
|
-
|
|
84669
|
-
|
|
84670
|
-
|
|
84671
|
-
|
|
84672
|
-
|
|
84673
|
-
continue;
|
|
84917
|
+
const possibleKeys = /* @__PURE__ */ new Set;
|
|
84918
|
+
let i = 0;
|
|
84919
|
+
for (const p of parts) {
|
|
84920
|
+
const nextP = parts[++i];
|
|
84921
|
+
const pattern = getPattern(p, nextP) || (nextP === undefined && p && p.indexOf("*") === p.length - 1 ? p : null);
|
|
84922
|
+
const isParam = Array.isArray(pattern);
|
|
84923
|
+
const key = isParam ? pattern[0] : pattern || p;
|
|
84924
|
+
const child = curNode.#children[key] ||= new _Node;
|
|
84925
|
+
if (pattern && !child.#pattern) {
|
|
84926
|
+
child.#pattern = pattern;
|
|
84927
|
+
curNode.#patterns.push(child);
|
|
84674
84928
|
}
|
|
84675
|
-
curNode
|
|
84676
|
-
if (
|
|
84677
|
-
|
|
84678
|
-
possibleKeys.push(pattern[1]);
|
|
84929
|
+
curNode = child;
|
|
84930
|
+
if (isParam) {
|
|
84931
|
+
possibleKeys.add(pattern[1]);
|
|
84679
84932
|
}
|
|
84680
|
-
curNode = curNode.#children[key];
|
|
84681
84933
|
}
|
|
84682
84934
|
curNode.#methods.push({
|
|
84683
84935
|
[method]: {
|
|
84684
84936
|
handler,
|
|
84685
|
-
possibleKeys: possibleKeys
|
|
84686
|
-
score:
|
|
84937
|
+
possibleKeys: [...possibleKeys],
|
|
84938
|
+
score: ++order
|
|
84687
84939
|
}
|
|
84688
84940
|
});
|
|
84689
|
-
return curNode;
|
|
84690
84941
|
}
|
|
84691
84942
|
#pushHandlerSets(handlerSets, node, method, nodeParams, params) {
|
|
84692
84943
|
for (let i = 0, len = node.#methods.length;i < len; i++) {
|
|
84693
84944
|
const m = node.#methods[i];
|
|
84694
84945
|
const handlerSet = m[method] || m[METHOD_NAME_ALL];
|
|
84695
|
-
|
|
84696
|
-
|
|
84697
|
-
handlerSet.params = /* @__PURE__ */ Object.create(null);
|
|
84946
|
+
if (handlerSet) {
|
|
84947
|
+
handlerSet.params = createNullObject();
|
|
84698
84948
|
handlerSets.push(handlerSet);
|
|
84699
|
-
|
|
84700
|
-
|
|
84701
|
-
|
|
84702
|
-
const processed = processedSet[handlerSet.score];
|
|
84703
|
-
handlerSet.params[key] = params?.[key] && !processed ? params[key] : nodeParams[key] ?? params?.[key];
|
|
84704
|
-
processedSet[handlerSet.score] = true;
|
|
84705
|
-
}
|
|
84949
|
+
for (let i2 = 0, len2 = handlerSet.possibleKeys.length;i2 < len2; i2++) {
|
|
84950
|
+
const key = handlerSet.possibleKeys[i2];
|
|
84951
|
+
handlerSet.params[key] = params?.[key] && !i2 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
84706
84952
|
}
|
|
84707
84953
|
}
|
|
84708
84954
|
}
|
|
@@ -84734,33 +84980,33 @@ var Node2 = class _Node {
|
|
|
84734
84980
|
tempNodes.push(nextNode);
|
|
84735
84981
|
}
|
|
84736
84982
|
}
|
|
84737
|
-
for (
|
|
84738
|
-
const pattern =
|
|
84983
|
+
for (const child of node.#patterns) {
|
|
84984
|
+
const pattern = child.#pattern;
|
|
84739
84985
|
const params = node.#params === emptyParams ? {} : { ...node.#params };
|
|
84740
|
-
if (pattern === "
|
|
84741
|
-
|
|
84742
|
-
|
|
84743
|
-
|
|
84744
|
-
|
|
84745
|
-
|
|
84986
|
+
if (typeof pattern === "string") {
|
|
84987
|
+
if (pattern === "*" || part.startsWith(pattern.slice(0, -1))) {
|
|
84988
|
+
this.#pushHandlerSets(handlerSets, child, method, node.#params);
|
|
84989
|
+
if (pattern === "*") {
|
|
84990
|
+
child.#params = params;
|
|
84991
|
+
tempNodes.push(child);
|
|
84992
|
+
}
|
|
84746
84993
|
}
|
|
84747
84994
|
continue;
|
|
84748
84995
|
}
|
|
84749
|
-
const [
|
|
84750
|
-
if (!part &&
|
|
84996
|
+
const [, name, matcher] = pattern;
|
|
84997
|
+
if (!part && matcher === true) {
|
|
84751
84998
|
continue;
|
|
84752
84999
|
}
|
|
84753
|
-
|
|
84754
|
-
|
|
84755
|
-
|
|
84756
|
-
partOffsets = new Array(len);
|
|
85000
|
+
if (matcher !== true) {
|
|
85001
|
+
if (!partOffsets) {
|
|
85002
|
+
partOffsets = [];
|
|
84757
85003
|
let offset = path[0] === "/" ? 1 : 0;
|
|
84758
85004
|
for (let p = 0;p < len; p++) {
|
|
84759
85005
|
partOffsets[p] = offset;
|
|
84760
85006
|
offset += parts[p].length + 1;
|
|
84761
85007
|
}
|
|
84762
85008
|
}
|
|
84763
|
-
const restPathString = path.
|
|
85009
|
+
const restPathString = path.slice(partOffsets[i]);
|
|
84764
85010
|
const m = matcher.exec(restPathString);
|
|
84765
85011
|
if (m) {
|
|
84766
85012
|
params[name] = m[0];
|
|
@@ -84768,11 +85014,12 @@ var Node2 = class _Node {
|
|
|
84768
85014
|
if (m[0].length === restPathString.length && child.#children["*"]) {
|
|
84769
85015
|
this.#pushHandlerSets(handlerSets, child.#children["*"], method, node.#params, params);
|
|
84770
85016
|
}
|
|
84771
|
-
|
|
85017
|
+
for (const _ in child.#children) {
|
|
84772
85018
|
child.#params = params;
|
|
84773
|
-
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
85019
|
+
const componentCount = m[0].match(/\//g)?.length ?? 0;
|
|
84774
85020
|
const targetCurNodes = curNodesQueue[componentCount] ||= [];
|
|
84775
85021
|
targetCurNodes.push(child);
|
|
85022
|
+
break;
|
|
84776
85023
|
}
|
|
84777
85024
|
continue;
|
|
84778
85025
|
}
|
|
@@ -84794,7 +85041,7 @@ var Node2 = class _Node {
|
|
|
84794
85041
|
const shifted = curNodesQueue.shift();
|
|
84795
85042
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
84796
85043
|
}
|
|
84797
|
-
if (handlerSets
|
|
85044
|
+
if (handlerSets[1]) {
|
|
84798
85045
|
handlerSets.sort((a, b) => {
|
|
84799
85046
|
return a.score - b.score;
|
|
84800
85047
|
});
|
|
@@ -84803,29 +85050,21 @@ var Node2 = class _Node {
|
|
|
84803
85050
|
}
|
|
84804
85051
|
};
|
|
84805
85052
|
|
|
84806
|
-
// ../../node_modules/.bun/hono@4.
|
|
85053
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/router/trie-router/router.js
|
|
84807
85054
|
var TrieRouter = class {
|
|
84808
85055
|
name = "TrieRouter";
|
|
84809
|
-
#node;
|
|
84810
|
-
constructor() {
|
|
84811
|
-
this.#node = new Node2;
|
|
84812
|
-
}
|
|
85056
|
+
#node = new Node2;
|
|
84813
85057
|
add(method, path, handler) {
|
|
84814
|
-
const
|
|
84815
|
-
|
|
84816
|
-
for (let i = 0, len = results.length;i < len; i++) {
|
|
84817
|
-
this.#node.insert(method, results[i], handler);
|
|
84818
|
-
}
|
|
84819
|
-
return;
|
|
85058
|
+
for (const result of checkOptionalParameter(path) || [path]) {
|
|
85059
|
+
this.#node.insert(method, result, handler);
|
|
84820
85060
|
}
|
|
84821
|
-
this.#node.insert(method, path, handler);
|
|
84822
85061
|
}
|
|
84823
85062
|
match(method, path) {
|
|
84824
85063
|
return this.#node.search(method, path);
|
|
84825
85064
|
}
|
|
84826
85065
|
};
|
|
84827
85066
|
|
|
84828
|
-
// ../../node_modules/.bun/hono@4.
|
|
85067
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/hono.js
|
|
84829
85068
|
var Hono2 = class extends Hono {
|
|
84830
85069
|
constructor(options = {}) {
|
|
84831
85070
|
super(options);
|
|
@@ -84835,7 +85074,7 @@ var Hono2 = class extends Hono {
|
|
|
84835
85074
|
}
|
|
84836
85075
|
};
|
|
84837
85076
|
|
|
84838
|
-
// ../../node_modules/.bun/hono@4.
|
|
85077
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/utils/color.js
|
|
84839
85078
|
function getColorEnabled() {
|
|
84840
85079
|
const { process: process2, Deno: Deno2 } = globalThis;
|
|
84841
85080
|
const isNoColor = typeof Deno2?.noColor === "boolean" ? Deno2.noColor : process2 !== undefined ? "NO_COLOR" in process2?.env : false;
|
|
@@ -84854,7 +85093,7 @@ async function getColorEnabledAsync() {
|
|
|
84854
85093
|
return !isNoColor;
|
|
84855
85094
|
}
|
|
84856
85095
|
|
|
84857
|
-
// ../../node_modules/.bun/hono@4.
|
|
85096
|
+
// ../../node_modules/.bun/hono@4.13.7/node_modules/hono/dist/middleware/logger/index.js
|
|
84858
85097
|
var humanize = (times) => {
|
|
84859
85098
|
const [delimiter, separator] = [",", "."];
|
|
84860
85099
|
const orderTimes = times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter));
|