@commentray/render 0.0.2 → 0.0.5

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.
Files changed (59) hide show
  1. package/dist/block-stretch-layout.d.ts +30 -0
  2. package/dist/block-stretch-layout.d.ts.map +1 -0
  3. package/dist/block-stretch-layout.js +104 -0
  4. package/dist/block-stretch-layout.js.map +1 -0
  5. package/dist/build-commentray-nav-search.d.ts +62 -0
  6. package/dist/build-commentray-nav-search.d.ts.map +1 -0
  7. package/dist/build-commentray-nav-search.js +98 -0
  8. package/dist/build-commentray-nav-search.js.map +1 -0
  9. package/dist/build-stamp.d.ts +6 -0
  10. package/dist/build-stamp.d.ts.map +1 -0
  11. package/dist/build-stamp.js +23 -0
  12. package/dist/build-stamp.js.map +1 -0
  13. package/dist/code-browser-client.bundle.js +12 -5
  14. package/dist/code-browser-client.js +825 -97
  15. package/dist/code-browser-client.js.map +1 -1
  16. package/dist/code-browser-embedded-payload.d.ts +10 -0
  17. package/dist/code-browser-embedded-payload.d.ts.map +1 -0
  18. package/dist/code-browser-embedded-payload.js +18 -0
  19. package/dist/code-browser-embedded-payload.js.map +1 -0
  20. package/dist/code-browser-encoding.d.ts +9 -0
  21. package/dist/code-browser-encoding.d.ts.map +1 -0
  22. package/dist/code-browser-encoding.js +24 -0
  23. package/dist/code-browser-encoding.js.map +1 -0
  24. package/dist/code-browser-scroll-sync.d.ts +6 -0
  25. package/dist/code-browser-scroll-sync.d.ts.map +1 -1
  26. package/dist/code-browser-scroll-sync.js +1 -0
  27. package/dist/code-browser-scroll-sync.js.map +1 -1
  28. package/dist/code-browser-search.d.ts +5 -0
  29. package/dist/code-browser-search.d.ts.map +1 -1
  30. package/dist/code-browser-search.js +28 -0
  31. package/dist/code-browser-search.js.map +1 -1
  32. package/dist/code-browser-web-storage.d.ts +7 -0
  33. package/dist/code-browser-web-storage.d.ts.map +1 -0
  34. package/dist/code-browser-web-storage.js +21 -0
  35. package/dist/code-browser-web-storage.js.map +1 -0
  36. package/dist/code-browser.d.ts +76 -1
  37. package/dist/code-browser.d.ts.map +1 -1
  38. package/dist/code-browser.js +809 -111
  39. package/dist/code-browser.js.map +1 -1
  40. package/dist/highlighted-code-lines.d.ts +19 -0
  41. package/dist/highlighted-code-lines.d.ts.map +1 -0
  42. package/dist/highlighted-code-lines.js +61 -0
  43. package/dist/highlighted-code-lines.js.map +1 -0
  44. package/dist/index.d.ts +3 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +1 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/markdown-pipeline.d.ts.map +1 -1
  49. package/dist/markdown-pipeline.js +13 -1
  50. package/dist/markdown-pipeline.js.map +1 -1
  51. package/dist/mermaid-runtime-html.d.ts +7 -0
  52. package/dist/mermaid-runtime-html.d.ts.map +1 -0
  53. package/dist/mermaid-runtime-html.js +26 -0
  54. package/dist/mermaid-runtime-html.js.map +1 -0
  55. package/dist/side-by-side.d.ts +2 -0
  56. package/dist/side-by-side.d.ts.map +1 -1
  57. package/dist/side-by-side.js +7 -7
  58. package/dist/side-by-side.js.map +1 -1
  59. package/package.json +6 -4
@@ -0,0 +1,30 @@
1
+ import { type CommentrayIndex } from "@commentray/core";
2
+ import { type CommentrayOutputUrlOptions } from "./markdown-pipeline.js";
3
+ export type BlockStretchTableOptions = {
4
+ code: string;
5
+ language: string;
6
+ commentrayMarkdown: string;
7
+ index: CommentrayIndex;
8
+ sourceRelative: string;
9
+ commentrayPathRel: string;
10
+ commentrayOutputUrls?: CommentrayOutputUrlOptions;
11
+ };
12
+ export declare function splitCommentrayMarkdownSegments(markdown: string): {
13
+ preamble: string;
14
+ segments: {
15
+ id: string;
16
+ body: string;
17
+ }[];
18
+ };
19
+ /**
20
+ * When index blocks + markdown markers align, builds a two-column table in the spirit of
21
+ * GitHub **blame**: **one row per block** (plus one row per unmapped source line). The code
22
+ * and commentary cells share the **same row height** — whichever side is taller sets the
23
+ * row; the shorter side is top-aligned with natural empty space below inside its cell.
24
+ * A single outer scroll (`shell--stretch-rows`) keeps both columns in lockstep.
25
+ */
26
+ export declare function tryBuildBlockStretchTableHtml(opts: BlockStretchTableOptions): Promise<{
27
+ preambleHtml: string;
28
+ tableInnerHtml: string;
29
+ } | null>;
30
+ //# sourceMappingURL=block-stretch-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-stretch-layout.d.ts","sourceRoot":"","sources":["../src/block-stretch-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAGrB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,KAAK,0BAA0B,EAAwB,MAAM,wBAAwB,CAAC;AAO/F,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,eAAe,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,0BAA0B,CAAC;CACnD,CAAC;AAEF,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC1C,CA6BA;AAgBD;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CA8ElE"}
@@ -0,0 +1,104 @@
1
+ import { MARKER_ID_BODY, buildBlockScrollLinks, } from "@commentray/core";
2
+ import { escapeHtml } from "./html-utils.js";
3
+ import { renderHighlightedCodeLineRows } from "./highlighted-code-lines.js";
4
+ import { renderMarkdownToHtml } from "./markdown-pipeline.js";
5
+ const BLOCK_MARKER_LINE = new RegExp(`^<!--\\s*commentray:block\\s+id=(${MARKER_ID_BODY})\\s*-->$`, "i");
6
+ export function splitCommentrayMarkdownSegments(markdown) {
7
+ const lines = markdown.split("\n");
8
+ const preambleLines = [];
9
+ const segments = [];
10
+ let seenMarker = false;
11
+ let currentId = null;
12
+ const currentBody = [];
13
+ function flush() {
14
+ if (currentId !== null) {
15
+ segments.push({ id: currentId, body: currentBody.join("\n").trimEnd() });
16
+ currentBody.length = 0;
17
+ }
18
+ }
19
+ for (const line of lines) {
20
+ const m = BLOCK_MARKER_LINE.exec(line);
21
+ if (m && m[1] !== undefined) {
22
+ seenMarker = true;
23
+ flush();
24
+ currentId = m[1];
25
+ }
26
+ else if (!seenMarker) {
27
+ preambleLines.push(line);
28
+ }
29
+ else {
30
+ currentBody.push(line);
31
+ }
32
+ }
33
+ flush();
34
+ return { preamble: preambleLines.join("\n").trimEnd(), segments };
35
+ }
36
+ /** Renders a contiguous 0-based inclusive range of source lines into one stacked column. */
37
+ async function renderCodeLineStack(lines, startLine0, endLine0, language) {
38
+ const slice = lines.slice(startLine0, endLine0 + 1).join("\n");
39
+ const inner = await renderHighlightedCodeLineRows(slice, language, {
40
+ lineIndexOffset: startLine0,
41
+ });
42
+ return `<div class="stretch-code-stack">${inner}</div>`;
43
+ }
44
+ /**
45
+ * When index blocks + markdown markers align, builds a two-column table in the spirit of
46
+ * GitHub **blame**: **one row per block** (plus one row per unmapped source line). The code
47
+ * and commentary cells share the **same row height** — whichever side is taller sets the
48
+ * row; the shorter side is top-aligned with natural empty space below inside its cell.
49
+ * A single outer scroll (`shell--stretch-rows`) keeps both columns in lockstep.
50
+ */
51
+ export async function tryBuildBlockStretchTableHtml(opts) {
52
+ const links = buildBlockScrollLinks(opts.index, opts.sourceRelative, opts.commentrayPathRel, opts.commentrayMarkdown, opts.code);
53
+ if (links.length === 0)
54
+ return null;
55
+ const { preamble, segments } = splitCommentrayMarkdownSegments(opts.commentrayMarkdown);
56
+ const mdOpts = { commentrayOutputUrls: opts.commentrayOutputUrls };
57
+ const renderedById = new Map();
58
+ for (const s of segments) {
59
+ renderedById.set(s.id, await renderMarkdownToHtml(s.body.trim().length > 0 ? s.body : " ", mdOpts));
60
+ }
61
+ const lines = opts.code.split("\n");
62
+ const lineToBlock = new Map();
63
+ for (const b of links) {
64
+ for (let L = b.sourceStart; L <= b.sourceEnd; L++) {
65
+ lineToBlock.set(L, b);
66
+ }
67
+ }
68
+ const rows = [];
69
+ let i = 0;
70
+ while (i < lines.length) {
71
+ const L = i + 1;
72
+ const b = lineToBlock.get(L);
73
+ if (!b) {
74
+ const codeLineHtml = await renderHighlightedCodeLineRows(lines[i] ?? "", opts.language, {
75
+ lineIndexOffset: i,
76
+ omitLineStackWrapper: true,
77
+ });
78
+ rows.push(`<tr class="stretch-row stretch-row--gap"><td class="stretch-code">${codeLineHtml}</td>` +
79
+ `<td class="stretch-doc stretch-doc--gap"><span class="stretch-gap-mark" aria-hidden="true">—</span></td></tr>`);
80
+ i += 1;
81
+ continue;
82
+ }
83
+ if (i !== b.sourceStart - 1) {
84
+ throw new Error(`block-stretch desync at 0-based index ${String(i)} (block ${b.id} should start at index ${String(b.sourceStart - 1)})`);
85
+ }
86
+ const start0 = b.sourceStart - 1;
87
+ const end0 = b.sourceEnd - 1;
88
+ const stackHtml = await renderCodeLineStack(lines, start0, end0, opts.language);
89
+ const docInner = renderedById.get(b.id) ??
90
+ `<p class="stretch-doc-missing"><em>No commentary segment for block <code>${escapeHtml(b.id)}</code>.</em></p>`;
91
+ rows.push(`<tr class="stretch-row stretch-row--block"><td class="stretch-code">${stackHtml}</td>` +
92
+ `<td class="stretch-doc"><div class="stretch-doc-inner">${docInner}</div></td></tr>`);
93
+ i = end0 + 1;
94
+ }
95
+ const preambleHtml = preamble.trim().length > 0
96
+ ? `<section class="stretch-preamble" aria-label="Introduction">${await renderMarkdownToHtml(preamble, mdOpts)}</section>`
97
+ : "";
98
+ const tableInnerHtml = `<table class="block-stretch pane--code" id="code-pane" role="presentation">` +
99
+ `<colgroup><col class="stretch-col-code" /><col class="stretch-col-doc" /></colgroup>` +
100
+ `<tbody>\n${rows.join("\n")}\n</tbody>` +
101
+ `</table>`;
102
+ return { preambleHtml, tableInnerHtml };
103
+ }
104
+ //# sourceMappingURL=block-stretch-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block-stretch-layout.js","sourceRoot":"","sources":["../src/block-stretch-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACd,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAmC,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,MAAM,iBAAiB,GAAG,IAAI,MAAM,CAClC,oCAAoC,cAAc,WAAW,EAC7D,GAAG,CACJ,CAAC;AAYF,MAAM,UAAU,+BAA+B,CAAC,QAAgB;IAI9D,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAmC,EAAE,CAAC;IACpD,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,SAAS,GAAkB,IAAI,CAAC;IACpC,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,SAAS,KAAK;QACZ,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACzE,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,KAAK,MAAM,IAAI,IAA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Ac,GAClB,6EAA6E;QAC7E,sFAAsF;QACtF,YAAY,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY;QACvC,UAAU,CAAC;IAEb,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,62 @@
1
+ export declare const COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION: 1;
2
+ /** One searchable unit for a future hub or external tooling — never primary source lines. */
3
+ export type CommentrayNavSearchRow = {
4
+ kind: "sourcePath";
5
+ sourcePath: string;
6
+ commentrayPath: string;
7
+ } | {
8
+ kind: "commentrayPath";
9
+ sourcePath: string;
10
+ commentrayPath: string;
11
+ } | {
12
+ kind: "commentrayLine";
13
+ sourcePath: string;
14
+ commentrayPath: string;
15
+ line: number;
16
+ text: string;
17
+ };
18
+ /** One indexed source ↔ commentray pair with absolute GitHub blob links for static hub pages. */
19
+ export type DocumentedPairNav = {
20
+ sourcePath: string;
21
+ commentrayPath: string;
22
+ sourceOnGithub: string;
23
+ commentrayOnGithub: string;
24
+ /**
25
+ * When the static Pages build emits per-pair browse HTML (e.g. `_site/browse/…html`), a URL
26
+ * relative to the site root `index.html` (e.g. `./browse/x.html`) so the hub can open the same
27
+ * Commentray UI for other files without leaving the site.
28
+ */
29
+ staticBrowseUrl?: string;
30
+ };
31
+ export type CommentrayNavSearchDocument = {
32
+ schemaVersion: typeof COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION;
33
+ rows: CommentrayNavSearchRow[];
34
+ /** Present when `githubBlobBase` was passed to the builder — drives the documented-files tree. */
35
+ documentedPairs?: DocumentedPairNav[];
36
+ };
37
+ export type BuildCommentrayNavSearchFallback = {
38
+ /** Repo-relative primary path (toolbar / manifest label). */
39
+ sourcePath: string;
40
+ /** Repo-relative commentray Markdown path. */
41
+ commentrayPath: string;
42
+ /** Absolute path to that Markdown file on disk. */
43
+ markdownAbs: string;
44
+ };
45
+ export type BuildCommentrayNavSearchGithubBlobBase = {
46
+ owner: string;
47
+ repo: string;
48
+ branch: string;
49
+ };
50
+ /**
51
+ * Builds a JSON-serialisable search corpus: **filenames / paths** plus **commentray Markdown lines**
52
+ * for each indexed pair. Primary source file contents are intentionally omitted.
53
+ *
54
+ * When `githubBlobBase` is set, `documentedPairs` lists every pair with GitHub **blob** URLs for
55
+ * the static hub tree and outbound links.
56
+ *
57
+ * Pairs are merged from the metadata index, a walk of the configured storage `source` tree for
58
+ * every `*.md` companion (flat or Angles layout), and an optional single-page `fallback`. For the
59
+ * same `commentrayPath`, the index wins over disk-inferred paths.
60
+ */
61
+ export declare function buildCommentrayNavSearchDocument(repoRoot: string, fallback?: BuildCommentrayNavSearchFallback, githubBlobBase?: BuildCommentrayNavSearchGithubBlobBase, storageDir?: string): Promise<CommentrayNavSearchDocument>;
62
+ //# sourceMappingURL=build-commentray-nav-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-commentray-nav-search.d.ts","sourceRoot":"","sources":["../src/build-commentray-nav-search.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,oCAAoC,EAAG,CAAU,CAAC;AAE/D,6FAA6F;AAC7F,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAClE;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GACtE;IACE,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,iGAAiG;AACjG,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,aAAa,EAAE,OAAO,oCAAoC,CAAC;IAC3D,IAAI,EAAE,sBAAsB,EAAE,CAAC;IAC/B,kGAAkG;IAClG,eAAe,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmFF;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,gCAAgC,EAC3C,cAAc,CAAC,EAAE,sCAAsC,EACvD,UAAU,SAAgB,GACzB,OAAO,CAAC,2BAA2B,CAAC,CAmCtC"}
@@ -0,0 +1,98 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { discoverCommentrayPairsOnDisk, githubRepoBlobFileUrl, readIndex, resolvePathUnderRepoRoot, } from "@commentray/core";
3
+ export const COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION = 1;
4
+ function buildDocumentedPairs(pairs, gh) {
5
+ const { owner, repo, branch } = gh;
6
+ const uniq = new Map();
7
+ for (const { sourcePath, commentrayPath } of pairs) {
8
+ const key = `${sourcePath}\0${commentrayPath}`;
9
+ if (uniq.has(key))
10
+ continue;
11
+ uniq.set(key, {
12
+ sourcePath,
13
+ commentrayPath,
14
+ sourceOnGithub: githubRepoBlobFileUrl(owner, repo, branch, sourcePath),
15
+ commentrayOnGithub: githubRepoBlobFileUrl(owner, repo, branch, commentrayPath),
16
+ });
17
+ }
18
+ return [...uniq.values()].sort((a, b) => a.sourcePath === b.sourcePath
19
+ ? a.commentrayPath.localeCompare(b.commentrayPath)
20
+ : a.sourcePath.localeCompare(b.sourcePath));
21
+ }
22
+ function mergeNavSearchPairs(indexPairs, diskPairs, fallback) {
23
+ const byCr = new Map();
24
+ for (const p of diskPairs) {
25
+ byCr.set(p.commentrayPath, { sourcePath: p.sourcePath, commentrayPath: p.commentrayPath });
26
+ }
27
+ for (const e of indexPairs) {
28
+ byCr.set(e.commentrayPath, { sourcePath: e.sourcePath, commentrayPath: e.commentrayPath });
29
+ }
30
+ if (fallback !== undefined) {
31
+ const fp = {
32
+ sourcePath: fallback.sourcePath,
33
+ commentrayPath: fallback.commentrayPath,
34
+ };
35
+ if (!byCr.has(fp.commentrayPath)) {
36
+ byCr.set(fp.commentrayPath, fp);
37
+ }
38
+ }
39
+ return [...byCr.values()].sort((a, b) => a.commentrayPath.localeCompare(b.commentrayPath));
40
+ }
41
+ function markdownAbsForMergedPair(repoRoot, pair, fallback) {
42
+ if (fallback !== undefined &&
43
+ pair.commentrayPath === fallback.commentrayPath &&
44
+ pair.sourcePath === fallback.sourcePath) {
45
+ return fallback.markdownAbs;
46
+ }
47
+ return resolvePathUnderRepoRoot(repoRoot, pair.commentrayPath);
48
+ }
49
+ async function appendPairRowsSync(rows, sourcePath, commentrayPath, markdownAbs) {
50
+ rows.push({ kind: "sourcePath", sourcePath, commentrayPath });
51
+ rows.push({ kind: "commentrayPath", sourcePath, commentrayPath });
52
+ try {
53
+ const md = await readFile(markdownAbs, "utf8");
54
+ const lines = md.split("\n");
55
+ for (let i = 0; i < lines.length; i++) {
56
+ rows.push({ kind: "commentrayLine", sourcePath, commentrayPath, line: i, text: lines[i] });
57
+ }
58
+ }
59
+ catch {
60
+ /* keep path rows when the companion file is missing */
61
+ }
62
+ }
63
+ /**
64
+ * Builds a JSON-serialisable search corpus: **filenames / paths** plus **commentray Markdown lines**
65
+ * for each indexed pair. Primary source file contents are intentionally omitted.
66
+ *
67
+ * When `githubBlobBase` is set, `documentedPairs` lists every pair with GitHub **blob** URLs for
68
+ * the static hub tree and outbound links.
69
+ *
70
+ * Pairs are merged from the metadata index, a walk of the configured storage `source` tree for
71
+ * every `*.md` companion (flat or Angles layout), and an optional single-page `fallback`. For the
72
+ * same `commentrayPath`, the index wins over disk-inferred paths.
73
+ */
74
+ export async function buildCommentrayNavSearchDocument(repoRoot, fallback, githubBlobBase, storageDir = ".commentray") {
75
+ const rows = [];
76
+ const idx = await readIndex(repoRoot);
77
+ const indexPairs = idx !== null && Object.keys(idx.byCommentrayPath).length > 0
78
+ ? Object.entries(idx.byCommentrayPath).map(([crPath, e]) => ({
79
+ commentrayPath: crPath,
80
+ sourcePath: e.sourcePath,
81
+ }))
82
+ : [];
83
+ const diskPairs = await discoverCommentrayPairsOnDisk(repoRoot, storageDir);
84
+ const merged = mergeNavSearchPairs(indexPairs, diskPairs, fallback);
85
+ if (merged.length === 0) {
86
+ return { schemaVersion: COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION, rows };
87
+ }
88
+ for (const p of merged) {
89
+ await appendPairRowsSync(rows, p.sourcePath, p.commentrayPath, markdownAbsForMergedPair(repoRoot, p, fallback));
90
+ }
91
+ const documentedPairs = githubBlobBase !== undefined ? buildDocumentedPairs(merged, githubBlobBase) : undefined;
92
+ return {
93
+ schemaVersion: COMMENTRAY_NAV_SEARCH_SCHEMA_VERSION,
94
+ rows,
95
+ ...(documentedPairs ? { documentedPairs } : {}),
96
+ };
97
+ }
98
+ //# sourceMappingURL=build-commentray-nav-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-commentray-nav-search.js","sourceRoot":"","sources":["../src/build-commentray-nav-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EACL,6BAA6B,EAC7B,qB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E,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzD,cAAc,EAAE,MAAM;YACtB,UAAU,EAAE,CAAC,CAAC,UAAU;SACzB,CAAC,CAAC;QACL,CAAC,CAAC,EAAE,CAAC;IAET,MAAM,SAAS,GAAG,MAAM,6BAA6B,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC5E,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;IAEpE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,aAAa,EAAE,oCAAoC,EAAE,IAAI,EAAE,CAAC;IACvE,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,kBAAkB,CACtB,IAAI,EACJ,CAAC,CAAC,UAAU,EACZ,CAAC,CAAC,cAAc,EAChB,wBAAwB,CAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,CAAC,CAChD,CAAC;IACJ,CAAC;IAED,MAAM,eAAe,GACnB,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE1F,OAAO;QACL,aAAa,EAAE,oCAAoC;QACnD,IAAI;QACJ,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAChD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Human-readable “when was this HTML built” line for static pages, using the
3
+ * **Node process** local timezone and a zone name/offset from `Intl` (not UTC-only).
4
+ */
5
+ export declare function formatCommentrayBuiltAtLocal(date: Date): string;
6
+ //# sourceMappingURL=build-stamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-stamp.d.ts","sourceRoot":"","sources":["../src/build-stamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAgB/D"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Human-readable “when was this HTML built” line for static pages, using the
3
+ * **Node process** local timezone and a zone name/offset from `Intl` (not UTC-only).
4
+ */
5
+ export function formatCommentrayBuiltAtLocal(date) {
6
+ try {
7
+ return new Intl.DateTimeFormat(undefined, {
8
+ weekday: "short",
9
+ year: "numeric",
10
+ month: "short",
11
+ day: "numeric",
12
+ hour: "2-digit",
13
+ minute: "2-digit",
14
+ second: "2-digit",
15
+ hour12: false,
16
+ timeZoneName: "longOffset",
17
+ }).format(date);
18
+ }
19
+ catch {
20
+ return date.toISOString();
21
+ }
22
+ }
23
+ //# sourceMappingURL=build-stamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-stamp.js","sourceRoot":"","sources":["../src/build-stamp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAU;IACrD,IAAI,CAAC;QACH,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE;YACxC,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,OAAO;YACd,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,KAAK;YACb,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}