@brett_lamy/docstream 1.18.1 → 1.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -19
- package/dist/docs/DocsRenderer.d.ts.map +1 -1
- package/dist/docs/DocsRenderer.js +14 -3
- package/dist/docs/DocsRenderer.js.map +1 -1
- package/dist/gitbook/parse.js +10 -2
- package/dist/gitbook/parse.js.map +1 -1
- package/dist/openapi/OpenApiOperation.d.ts.map +1 -1
- package/dist/openapi/OpenApiOperation.js +13 -5
- package/dist/openapi/OpenApiOperation.js.map +1 -1
- package/dist/replay/ReplayStageImpl.d.ts.map +1 -1
- package/dist/replay/ReplayStageImpl.js +4 -1
- package/dist/replay/ReplayStageImpl.js.map +1 -1
- package/dist/site/DocsSite.d.ts +74 -0
- package/dist/site/DocsSite.d.ts.map +1 -0
- package/dist/site/DocsSite.js +479 -0
- package/dist/site/DocsSite.js.map +1 -0
- package/dist/site/index.d.ts +7 -0
- package/dist/site/index.d.ts.map +1 -0
- package/dist/site/index.js +5 -0
- package/dist/site/index.js.map +1 -0
- package/dist/site/search.d.ts +28 -0
- package/dist/site/search.d.ts.map +1 -0
- package/dist/site/search.js +125 -0
- package/dist/site/search.js.map +1 -0
- package/dist/site/site.css +816 -0
- package/dist/site/tree.d.ts +105 -0
- package/dist/site/tree.d.ts.map +1 -0
- package/dist/site/tree.js +411 -0
- package/dist/site/tree.js.map +1 -0
- package/dist/styles.css +1 -0
- package/package.json +8 -1
- package/src/docs/DocsRenderer.tsx +14 -3
- package/src/gitbook/parse.ts +10 -2
- package/src/openapi/OpenApiOperation.tsx +13 -5
- package/src/replay/ReplayStageImpl.tsx +4 -1
- package/src/site/DocsSite.tsx +958 -0
- package/src/site/index.ts +18 -0
- package/src/site/search.ts +138 -0
- package/src/site/site.css +816 -0
- package/src/site/tree.ts +482 -0
- package/src/styles.css +1 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/** A file's contents: text, or a `Blob` for binary assets (images, models). Pages must be text. */
|
|
2
|
+
export type DocsFileContent = string | Blob;
|
|
3
|
+
export type DocsFiles = Record<string, DocsFileContent> | ReadonlyArray<{
|
|
4
|
+
path: string;
|
|
5
|
+
content: DocsFileContent;
|
|
6
|
+
}>;
|
|
7
|
+
export interface DocsPage {
|
|
8
|
+
/** Source path relative to the docs root, e.g. `01-guides/02-install.md`. */
|
|
9
|
+
path: string;
|
|
10
|
+
/** URL path without leading slash: `guides/install`, `""` for the home page. */
|
|
11
|
+
slug: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
/** The file as written (frontmatter included). */
|
|
15
|
+
markdown: string;
|
|
16
|
+
/** The page body as the site renders it: no site-only frontmatter, no leading `# title`. */
|
|
17
|
+
body: string;
|
|
18
|
+
/** Frontmatter (all keys), `{}` when there is none. */
|
|
19
|
+
frontmatter: Record<string, unknown>;
|
|
20
|
+
hidden: boolean;
|
|
21
|
+
/** Titles of the sidebar groups/folders above the page, outermost first. */
|
|
22
|
+
breadcrumbs: string[];
|
|
23
|
+
}
|
|
24
|
+
export type DocsNavItem = {
|
|
25
|
+
kind: "group";
|
|
26
|
+
title: string;
|
|
27
|
+
children: DocsNavItem[];
|
|
28
|
+
} | {
|
|
29
|
+
kind: "page";
|
|
30
|
+
title: string;
|
|
31
|
+
slug: string;
|
|
32
|
+
children: DocsNavItem[];
|
|
33
|
+
} | {
|
|
34
|
+
kind: "folder";
|
|
35
|
+
title: string;
|
|
36
|
+
children: DocsNavItem[];
|
|
37
|
+
} | {
|
|
38
|
+
kind: "link";
|
|
39
|
+
title: string;
|
|
40
|
+
href: string;
|
|
41
|
+
};
|
|
42
|
+
export interface DocsTree {
|
|
43
|
+
/** Every page, sidebar order first, then pages the sidebar leaves out. */
|
|
44
|
+
pages: DocsPage[];
|
|
45
|
+
/** Pages in reading order (what Previous / Next walk): listed, not hidden. */
|
|
46
|
+
order: DocsPage[];
|
|
47
|
+
nav: DocsNavItem[];
|
|
48
|
+
bySlug: Map<string, DocsPage>;
|
|
49
|
+
byPath: Map<string, DocsPage>;
|
|
50
|
+
/** The common folder stripped from every input path (`"docs/"`), or `""`. */
|
|
51
|
+
root: string;
|
|
52
|
+
/** Every non-Markdown file under the root, by path relative to it (`specs/api.json`). */
|
|
53
|
+
assets: Map<string, DocsFileContent>;
|
|
54
|
+
}
|
|
55
|
+
export interface BuildDocsTreeOptions {
|
|
56
|
+
/** Folder to treat as the docs root; default: the deepest folder shared by every Markdown file. */
|
|
57
|
+
root?: string;
|
|
58
|
+
/** Extra file filter, applied after the Markdown filter. */
|
|
59
|
+
include?: (path: string) => boolean;
|
|
60
|
+
/** Use `SUMMARY.md` when there is one (default true). */
|
|
61
|
+
summary?: boolean;
|
|
62
|
+
/** Sidebar title for a folder without a README, given its name with the prefix removed. */
|
|
63
|
+
folderTitle?: (name: string, path: string) => string;
|
|
64
|
+
}
|
|
65
|
+
/** Frontmatter keys that describe the page to the site rather than the reader. */
|
|
66
|
+
export declare const SITE_FRONTMATTER_KEYS: readonly ["title", "description", "order", "hidden", "icon"];
|
|
67
|
+
export declare function isMarkdownPath(path: string): boolean;
|
|
68
|
+
/** `./docs//a/../b.md` → `docs/b.md`. Leading slashes and `.` segments are dropped. */
|
|
69
|
+
export declare function normalizePath(path: string): string;
|
|
70
|
+
/** `"03-quick-start"` → `{ name: "quick-start", order: 3 }`. */
|
|
71
|
+
export declare function stripOrderPrefix(name: string): {
|
|
72
|
+
name: string;
|
|
73
|
+
order?: number;
|
|
74
|
+
};
|
|
75
|
+
/** `"quick-start"` → `"Quick start"`; `"api_reference"` → `"Api reference"`. */
|
|
76
|
+
export declare function humanize(name: string): string;
|
|
77
|
+
/** The URL slug for a source path: `01-guides/README.md` → `guides`, `README.md` → `""`. */
|
|
78
|
+
export declare function slugForPath(path: string): string;
|
|
79
|
+
/** Resolve `href` (as written in `fromPath`'s Markdown) against the docs root; null when external. */
|
|
80
|
+
export declare function resolveRelativePath(fromPath: string, href: string): {
|
|
81
|
+
path: string;
|
|
82
|
+
hash: string;
|
|
83
|
+
} | null;
|
|
84
|
+
interface Frontmatter {
|
|
85
|
+
values: Record<string, unknown>;
|
|
86
|
+
/** Byte length of the `---` block (and the blank lines after it), 0 when absent. */
|
|
87
|
+
length: number;
|
|
88
|
+
}
|
|
89
|
+
export declare function readFrontmatter(markdown: string): Frontmatter;
|
|
90
|
+
/** Inline Markdown in a heading → plain text for the sidebar and `<title>`. */
|
|
91
|
+
export declare function plainTitle(text: string): string;
|
|
92
|
+
/** Build pages and the sidebar from a set of files. Non-Markdown files are ignored. */
|
|
93
|
+
export declare function buildDocsTree(files: DocsFiles, options?: BuildDocsTreeOptions): DocsTree;
|
|
94
|
+
/** The asset (non-Markdown file) `href` names from `from`, with its root-relative path; null when none. */
|
|
95
|
+
export declare function findLinkedAsset(tree: DocsTree, from: DocsPage, href: string): {
|
|
96
|
+
path: string;
|
|
97
|
+
content: DocsFileContent;
|
|
98
|
+
} | null;
|
|
99
|
+
/** The page `href` points at from `from` — a relative `.md` path, a folder, or a slug. */
|
|
100
|
+
export declare function findLinkedPage(tree: DocsTree, from: DocsPage, href: string): {
|
|
101
|
+
page: DocsPage;
|
|
102
|
+
hash: string;
|
|
103
|
+
} | null;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/site/tree.ts"],"names":[],"mappings":"AAmBA,mGAAmG;AACnG,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,IAAI,CAAA;AAE3C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC,CAAA;AAEnH,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,IAAI,EAAE,MAAM,CA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;AAuCD,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/C;AAqND,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,oBAAyB,GAAG,QAAQ,CAoC5F;AAED,2GAA2G;AAC3G,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,GAAG,IAAI,CAK/H;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAapH"}
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/* A docs site from a virtual file system: every Markdown file becomes a page, and the
|
|
2
|
+
folder structure (or a GitBook `SUMMARY.md`) becomes the sidebar.
|
|
3
|
+
|
|
4
|
+
Conventions, GitBook's where it has one:
|
|
5
|
+
- `README.md` (or `index.md`) is its folder's page; the top-level one is the home page.
|
|
6
|
+
- `SUMMARY.md` at the root, when present, *is* the sidebar: `## Group` headings and
|
|
7
|
+
nested `* [Title](path.md)` lists. Pages it leaves out stay reachable by URL.
|
|
8
|
+
- Without one, top-level folders become sidebar groups and deeper folders nest.
|
|
9
|
+
- Numeric prefixes (`01-intro.md`, `2_guides/`) order entries and are dropped from URLs
|
|
10
|
+
and titles. Frontmatter `order` overrides the prefix.
|
|
11
|
+
- A page's title is, in order: its SUMMARY.md label, frontmatter `title`, its first
|
|
12
|
+
`# heading`, then the file name (`quick-start.md` → "Quick start"). Frontmatter
|
|
13
|
+
`description` is its lede and `hidden: true` keeps it out of the sidebar.
|
|
14
|
+
- Every other file in the docs root is an asset (`tree.assets`): DocsSite serves it to the
|
|
15
|
+
pages, so `` or an OpenAPI block's `[api](specs/api.json)` loads
|
|
16
|
+
the file from the VFS.
|
|
17
|
+
Everything here is pure (no React, no DOM), so a static build or a test can use it. */
|
|
18
|
+
import { parseDocument, isMap } from "yaml";
|
|
19
|
+
/** Frontmatter keys that describe the page to the site rather than the reader. */
|
|
20
|
+
export const SITE_FRONTMATTER_KEYS = ["title", "description", "order", "hidden", "icon"];
|
|
21
|
+
const MARKDOWN = /\.(md|markdown|mdx)$/i;
|
|
22
|
+
const INDEX = /^(readme|index)$/i;
|
|
23
|
+
const PREFIX = /^(\d+)[-_. ]+(?=.)/;
|
|
24
|
+
const isBlob = (v) => typeof Blob !== "undefined" && v instanceof Blob;
|
|
25
|
+
export function isMarkdownPath(path) {
|
|
26
|
+
return MARKDOWN.test(path);
|
|
27
|
+
}
|
|
28
|
+
/** `./docs//a/../b.md` → `docs/b.md`. Leading slashes and `.` segments are dropped. */
|
|
29
|
+
export function normalizePath(path) {
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const part of path.replace(/\\/g, "/").split("/")) {
|
|
32
|
+
if (!part || part === ".")
|
|
33
|
+
continue;
|
|
34
|
+
if (part === "..")
|
|
35
|
+
out.pop();
|
|
36
|
+
else
|
|
37
|
+
out.push(part);
|
|
38
|
+
}
|
|
39
|
+
return out.join("/");
|
|
40
|
+
}
|
|
41
|
+
/** `"03-quick-start"` → `{ name: "quick-start", order: 3 }`. */
|
|
42
|
+
export function stripOrderPrefix(name) {
|
|
43
|
+
const m = PREFIX.exec(name);
|
|
44
|
+
return m ? { name: name.slice(m[0].length), order: Number(m[1]) } : { name };
|
|
45
|
+
}
|
|
46
|
+
/** `"quick-start"` → `"Quick start"`; `"api_reference"` → `"Api reference"`. */
|
|
47
|
+
export function humanize(name) {
|
|
48
|
+
const words = name.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
|
|
49
|
+
return words ? words[0].toUpperCase() + words.slice(1) : name;
|
|
50
|
+
}
|
|
51
|
+
const segmentSlug = (segment) => encodeURIComponent(stripOrderPrefix(segment).name.replace(/\s+/g, "-")).replace(/%2F/g, "/");
|
|
52
|
+
/** The URL slug for a source path: `01-guides/README.md` → `guides`, `README.md` → `""`. */
|
|
53
|
+
export function slugForPath(path) {
|
|
54
|
+
const parts = normalizePath(path).replace(MARKDOWN, "").split("/");
|
|
55
|
+
if (INDEX.test(parts[parts.length - 1] ?? ""))
|
|
56
|
+
parts.pop();
|
|
57
|
+
return parts.map(segmentSlug).join("/");
|
|
58
|
+
}
|
|
59
|
+
/** Resolve `href` (as written in `fromPath`'s Markdown) against the docs root; null when external. */
|
|
60
|
+
export function resolveRelativePath(fromPath, href) {
|
|
61
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//"))
|
|
62
|
+
return null;
|
|
63
|
+
const hashAt = href.indexOf("#");
|
|
64
|
+
const raw = hashAt >= 0 ? href.slice(0, hashAt) : href;
|
|
65
|
+
const hash = hashAt >= 0 ? href.slice(hashAt + 1) : "";
|
|
66
|
+
const clean = raw.split("?")[0];
|
|
67
|
+
let decoded = clean;
|
|
68
|
+
try {
|
|
69
|
+
decoded = decodeURI(clean);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// keep as written
|
|
73
|
+
}
|
|
74
|
+
if (!decoded)
|
|
75
|
+
return { path: normalizePath(fromPath), hash };
|
|
76
|
+
const dir = fromPath.includes("/") ? fromPath.slice(0, fromPath.lastIndexOf("/")) : "";
|
|
77
|
+
const path = decoded.startsWith("/") ? normalizePath(decoded) : normalizePath(`${dir}/${decoded}`);
|
|
78
|
+
return { path, hash };
|
|
79
|
+
}
|
|
80
|
+
const FRONTMATTER = /^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
81
|
+
export function readFrontmatter(markdown) {
|
|
82
|
+
const m = FRONTMATTER.exec(markdown);
|
|
83
|
+
if (!m)
|
|
84
|
+
return { values: {}, length: 0 };
|
|
85
|
+
let values = {};
|
|
86
|
+
try {
|
|
87
|
+
const doc = parseDocument(m[1]);
|
|
88
|
+
if (!doc.errors.length && isMap(doc.contents))
|
|
89
|
+
values = (doc.toJS() ?? {});
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// Unreadable YAML stays in the body, where the property sheet reports it.
|
|
93
|
+
return { values: {}, length: 0 };
|
|
94
|
+
}
|
|
95
|
+
const rest = markdown.slice(m[0].length);
|
|
96
|
+
return { values, length: m[0].length + (rest.length - rest.replace(/^(?:[ \t]*\r?\n)+/, "").length) };
|
|
97
|
+
}
|
|
98
|
+
const H1 = /^#[ \t]+(.+?)[ \t]*#*[ \t]*$/;
|
|
99
|
+
const FENCE = /^(`{3,}|~{3,})/;
|
|
100
|
+
/** The first line that is a `# heading` before any other content, with its offsets. */
|
|
101
|
+
function leadingH1(body) {
|
|
102
|
+
let offset = 0;
|
|
103
|
+
for (const line of body.split("\n")) {
|
|
104
|
+
const t = line.replace(/\r$/, "");
|
|
105
|
+
if (t.trim() === "") {
|
|
106
|
+
offset += line.length + 1;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const m = H1.exec(t);
|
|
110
|
+
if (!m)
|
|
111
|
+
return null;
|
|
112
|
+
const after = body.slice(offset + line.length + 1);
|
|
113
|
+
return { text: m[1], end: offset + line.length + 1 + (after.length - after.replace(/^(?:[ \t]*\r?\n)+/, "").length) };
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
/** The first `# heading` anywhere outside code fences (for titles only). */
|
|
118
|
+
function firstH1(body) {
|
|
119
|
+
let fence = null;
|
|
120
|
+
for (const line of body.split("\n")) {
|
|
121
|
+
const f = FENCE.exec(line.trim());
|
|
122
|
+
if (f) {
|
|
123
|
+
if (!fence)
|
|
124
|
+
fence = f[1][0];
|
|
125
|
+
else if (f[1][0] === fence)
|
|
126
|
+
fence = null;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (fence)
|
|
130
|
+
continue;
|
|
131
|
+
const m = H1.exec(line.replace(/\r$/, ""));
|
|
132
|
+
if (m)
|
|
133
|
+
return m[1];
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
/** Inline Markdown in a heading → plain text for the sidebar and `<title>`. */
|
|
138
|
+
export function plainTitle(text) {
|
|
139
|
+
return text
|
|
140
|
+
.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
141
|
+
.replace(/\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
142
|
+
.replace(/`([^`]*)`/g, "$1")
|
|
143
|
+
.replace(/(\*\*|__|\*|_|~~)(.+?)\1/g, "$2")
|
|
144
|
+
.replace(/\\([\\`*_{}[\]()#+\-.!@])/g, "$1")
|
|
145
|
+
.trim();
|
|
146
|
+
}
|
|
147
|
+
function toEntries(files) {
|
|
148
|
+
return Array.isArray(files)
|
|
149
|
+
? files.map((f) => ({ path: f.path, content: f.content }))
|
|
150
|
+
: Object.entries(files).map(([path, content]) => ({ path, content }));
|
|
151
|
+
}
|
|
152
|
+
function commonRoot(paths) {
|
|
153
|
+
if (!paths.length)
|
|
154
|
+
return "";
|
|
155
|
+
const dirs = paths.map((p) => p.split("/").slice(0, -1));
|
|
156
|
+
const first = dirs[0];
|
|
157
|
+
let n = first.length;
|
|
158
|
+
for (const d of dirs) {
|
|
159
|
+
let i = 0;
|
|
160
|
+
while (i < n && i < d.length && d[i] === first[i])
|
|
161
|
+
i++;
|
|
162
|
+
n = i;
|
|
163
|
+
}
|
|
164
|
+
return n ? `${first.slice(0, n).join("/")}/` : "";
|
|
165
|
+
}
|
|
166
|
+
function draftPage(path, markdown) {
|
|
167
|
+
const fm = readFrontmatter(markdown);
|
|
168
|
+
const fmKeys = Object.keys(fm.values);
|
|
169
|
+
const siteOnly = fmKeys.every((k) => SITE_FRONTMATTER_KEYS.includes(k));
|
|
170
|
+
let body = siteOnly ? markdown.slice(fm.length) : markdown;
|
|
171
|
+
const fmTitle = typeof fm.values.title === "string" ? fm.values.title : undefined;
|
|
172
|
+
let title = fmTitle;
|
|
173
|
+
// The site renders the title itself, so a leading `# Title` leaves the body.
|
|
174
|
+
if (siteOnly) {
|
|
175
|
+
const h1 = leadingH1(body);
|
|
176
|
+
if (h1) {
|
|
177
|
+
title ??= plainTitle(h1.text);
|
|
178
|
+
body = body.slice(h1.end);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
title ??= (() => {
|
|
182
|
+
const h = firstH1(markdown.slice(fm.length));
|
|
183
|
+
return h ? plainTitle(h) : undefined;
|
|
184
|
+
})();
|
|
185
|
+
const parts = path.replace(MARKDOWN, "").split("/");
|
|
186
|
+
const file = parts[parts.length - 1];
|
|
187
|
+
const named = INDEX.test(file) ? parts[parts.length - 2] : file;
|
|
188
|
+
const fromFile = !title;
|
|
189
|
+
title ??= named ? humanize(stripOrderPrefix(named).name) : "Home";
|
|
190
|
+
const order = typeof fm.values.order === "number" ? fm.values.order : stripOrderPrefix(INDEX.test(file) ? (parts[parts.length - 2] ?? "") : file).order;
|
|
191
|
+
return {
|
|
192
|
+
path,
|
|
193
|
+
slug: slugForPath(path),
|
|
194
|
+
title,
|
|
195
|
+
description: typeof fm.values.description === "string" ? fm.values.description : undefined,
|
|
196
|
+
markdown,
|
|
197
|
+
body,
|
|
198
|
+
frontmatter: fm.values,
|
|
199
|
+
hidden: fm.values.hidden === true,
|
|
200
|
+
breadcrumbs: [],
|
|
201
|
+
order,
|
|
202
|
+
titleFromFile: fromFile,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
const byOrder = (a, b) => (a.order ?? Number.POSITIVE_INFINITY) - (b.order ?? Number.POSITIVE_INFINITY) || a.title.localeCompare(b.title);
|
|
206
|
+
function folderTree(drafts) {
|
|
207
|
+
const root = { name: "", path: "", pages: [], folders: new Map() };
|
|
208
|
+
for (const d of drafts) {
|
|
209
|
+
const parts = d.path.split("/");
|
|
210
|
+
const file = parts.pop();
|
|
211
|
+
let node = root;
|
|
212
|
+
for (const part of parts) {
|
|
213
|
+
let next = node.folders.get(part);
|
|
214
|
+
if (!next) {
|
|
215
|
+
next = { name: part, path: node.path ? `${node.path}/${part}` : part, pages: [], folders: new Map() };
|
|
216
|
+
node.folders.set(part, next);
|
|
217
|
+
}
|
|
218
|
+
node = next;
|
|
219
|
+
}
|
|
220
|
+
if (INDEX.test(file.replace(MARKDOWN, "")) && !node.index)
|
|
221
|
+
node.index = d;
|
|
222
|
+
else
|
|
223
|
+
node.pages.push(d);
|
|
224
|
+
}
|
|
225
|
+
return root;
|
|
226
|
+
}
|
|
227
|
+
function autoNav(root, folderTitle) {
|
|
228
|
+
const folderItem = (f, crumbs) => {
|
|
229
|
+
const title = f.index && !f.index.titleFromFile ? f.index.title : folderTitle(stripOrderPrefix(f.name).name, f.path);
|
|
230
|
+
const children = entries(f, [...crumbs, title]);
|
|
231
|
+
if (f.index)
|
|
232
|
+
f.index.breadcrumbs = crumbs;
|
|
233
|
+
const order = f.index?.frontmatter.order ?? stripOrderPrefix(f.name).order;
|
|
234
|
+
return {
|
|
235
|
+
item: f.index && !f.index.hidden ? { kind: "page", title, slug: f.index.slug, children } : { kind: "folder", title, children },
|
|
236
|
+
order,
|
|
237
|
+
title,
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
const entries = (f, crumbs) => {
|
|
241
|
+
const list = [];
|
|
242
|
+
for (const p of f.pages) {
|
|
243
|
+
p.breadcrumbs = crumbs;
|
|
244
|
+
if (!p.hidden)
|
|
245
|
+
list.push({ item: { kind: "page", title: p.title, slug: p.slug, children: [] }, order: p.order, title: p.title });
|
|
246
|
+
}
|
|
247
|
+
for (const sub of f.folders.values()) {
|
|
248
|
+
const e = folderItem(sub, crumbs);
|
|
249
|
+
if (e.item.kind === "page" || (e.item.kind === "folder" && e.item.children.length))
|
|
250
|
+
list.push(e);
|
|
251
|
+
}
|
|
252
|
+
return list.sort(byOrder).map((e) => e.item);
|
|
253
|
+
};
|
|
254
|
+
const top = [];
|
|
255
|
+
if (root.index) {
|
|
256
|
+
root.index.breadcrumbs = [];
|
|
257
|
+
if (!root.index.hidden)
|
|
258
|
+
top.push({ kind: "page", title: root.index.title, slug: root.index.slug, children: [] });
|
|
259
|
+
}
|
|
260
|
+
// Loose top-level pages come first, then one group per top-level folder.
|
|
261
|
+
const loose = [];
|
|
262
|
+
for (const p of root.pages) {
|
|
263
|
+
p.breadcrumbs = [];
|
|
264
|
+
if (!p.hidden)
|
|
265
|
+
loose.push({ item: { kind: "page", title: p.title, slug: p.slug, children: [] }, order: p.order, title: p.title });
|
|
266
|
+
}
|
|
267
|
+
top.push(...loose.sort(byOrder).map((e) => e.item));
|
|
268
|
+
const groups = [...root.folders.values()]
|
|
269
|
+
.map((f) => {
|
|
270
|
+
const title = f.index && !f.index.titleFromFile ? f.index.title : folderTitle(stripOrderPrefix(f.name).name, f.path);
|
|
271
|
+
const children = entries(f, [title]);
|
|
272
|
+
if (f.index) {
|
|
273
|
+
f.index.breadcrumbs = [title];
|
|
274
|
+
if (!f.index.hidden)
|
|
275
|
+
children.unshift({ kind: "page", title: "Overview", slug: f.index.slug, children: [] });
|
|
276
|
+
}
|
|
277
|
+
return { item: { kind: "group", title, children }, order: f.index?.frontmatter.order ?? stripOrderPrefix(f.name).order, title };
|
|
278
|
+
})
|
|
279
|
+
.filter((g) => g.item.kind === "group" && g.item.children.length)
|
|
280
|
+
.sort(byOrder);
|
|
281
|
+
top.push(...groups.map((g) => g.item));
|
|
282
|
+
return top;
|
|
283
|
+
}
|
|
284
|
+
const LIST_ITEM = /^(\s*)[*+-][ \t]+\[([^\]]*)\]\(([^)\s]*)(?:\s+"[^"]*")?\)\s*$/;
|
|
285
|
+
const GROUP = /^#{1,6}[ \t]+(.+?)[ \t]*#*[ \t]*$/;
|
|
286
|
+
/** GitBook's SUMMARY.md: `## Group` headings, nested `* [Title](path.md)` lists, `---` ignored. */
|
|
287
|
+
function summaryNav(summary, summaryPath, byPath) {
|
|
288
|
+
const top = [];
|
|
289
|
+
let group = null;
|
|
290
|
+
const stack = [];
|
|
291
|
+
let firstHeading = true;
|
|
292
|
+
for (const line of summary.split("\n")) {
|
|
293
|
+
const t = line.replace(/\r$/, "");
|
|
294
|
+
const g = GROUP.exec(t);
|
|
295
|
+
if (g) {
|
|
296
|
+
// The first `# Table of contents` heading is the file's own title, not a group.
|
|
297
|
+
if (firstHeading && /^#\s/.test(t) && /contents|summary/i.test(g[1])) {
|
|
298
|
+
firstHeading = false;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
firstHeading = false;
|
|
302
|
+
group = { kind: "group", title: plainTitle(g[1]), children: [] };
|
|
303
|
+
top.push(group);
|
|
304
|
+
stack.length = 0;
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
const m = LIST_ITEM.exec(t);
|
|
308
|
+
if (!m)
|
|
309
|
+
continue;
|
|
310
|
+
firstHeading = false;
|
|
311
|
+
const indent = m[1].replace(/\t/g, " ").length;
|
|
312
|
+
const label = plainTitle(m[2]);
|
|
313
|
+
const href = m[3];
|
|
314
|
+
while (stack.length && stack[stack.length - 1].indent >= indent)
|
|
315
|
+
stack.pop();
|
|
316
|
+
const parent = stack[stack.length - 1];
|
|
317
|
+
const siblings = parent ? parent.children : group ? group.children : top;
|
|
318
|
+
const crumbs = parent ? parent.crumbs : group ? [group.title] : [];
|
|
319
|
+
const resolved = resolveRelativePath(summaryPath, href);
|
|
320
|
+
const page = resolved ? byPath.get(resolved.path) : undefined;
|
|
321
|
+
let item;
|
|
322
|
+
if (page) {
|
|
323
|
+
page.title = label || page.title;
|
|
324
|
+
page.breadcrumbs = crumbs;
|
|
325
|
+
item = { kind: "page", title: page.title, slug: page.slug, children: [] };
|
|
326
|
+
}
|
|
327
|
+
else if (!href || !resolved) {
|
|
328
|
+
item = href ? { kind: "link", title: label, href } : { kind: "folder", title: label, children: [] };
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
siblings.push(item);
|
|
334
|
+
if (item.kind === "page" || item.kind === "folder")
|
|
335
|
+
stack.push({ indent, children: item.children, crumbs: [...crumbs, label] });
|
|
336
|
+
}
|
|
337
|
+
return top;
|
|
338
|
+
}
|
|
339
|
+
function walkPages(nav, bySlug, out = []) {
|
|
340
|
+
for (const item of nav) {
|
|
341
|
+
if (item.kind === "page") {
|
|
342
|
+
const p = bySlug.get(item.slug);
|
|
343
|
+
if (p && !out.includes(p))
|
|
344
|
+
out.push(p);
|
|
345
|
+
}
|
|
346
|
+
if (item.kind !== "link")
|
|
347
|
+
walkPages(item.children, bySlug, out);
|
|
348
|
+
}
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
/** Build pages and the sidebar from a set of files. Non-Markdown files are ignored. */
|
|
352
|
+
export function buildDocsTree(files, options = {}) {
|
|
353
|
+
const all = toEntries(files)
|
|
354
|
+
.map((f) => ({ path: normalizePath(f.path), content: f.content }))
|
|
355
|
+
.filter((f) => !options.include || options.include(f.path));
|
|
356
|
+
const entries = all.filter((f) => isMarkdownPath(f.path) && typeof f.content === "string");
|
|
357
|
+
const root = options.root !== undefined ? (normalizePath(options.root) ? `${normalizePath(options.root)}/` : "") : commonRoot(entries.map((f) => f.path));
|
|
358
|
+
const inRoot = entries.filter((f) => f.path.startsWith(root)).map((f) => ({ path: f.path.slice(root.length), content: f.content }));
|
|
359
|
+
const assets = new Map();
|
|
360
|
+
for (const f of all) {
|
|
361
|
+
if (!isMarkdownPath(f.path) && f.path.startsWith(root) && (typeof f.content === "string" || isBlob(f.content))) {
|
|
362
|
+
assets.set(f.path.slice(root.length), f.content);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const summaryFile = options.summary === false ? undefined : inRoot.find((f) => /^summary\.md$/i.test(f.path));
|
|
366
|
+
const drafts = inRoot.filter((f) => f !== summaryFile).map((f) => draftPage(f.path, f.content));
|
|
367
|
+
const byPath = new Map(drafts.map((d) => [d.path, d]));
|
|
368
|
+
const folderTitle = options.folderTitle ?? ((name) => humanize(name));
|
|
369
|
+
const nav = summaryFile ? summaryNav(summaryFile.content, summaryFile.path, byPath) : autoNav(folderTree(drafts), folderTitle);
|
|
370
|
+
const bySlug = new Map();
|
|
371
|
+
for (const d of drafts)
|
|
372
|
+
if (!bySlug.has(d.slug))
|
|
373
|
+
bySlug.set(d.slug, d);
|
|
374
|
+
const listed = walkPages(nav, bySlug);
|
|
375
|
+
const pages = [...listed, ...drafts.filter((d) => !listed.includes(d))].map(({ order: _order, titleFromFile: _fromFile, ...page }) => page);
|
|
376
|
+
// Keep the maps pointing at the cleaned objects.
|
|
377
|
+
const finalBySlug = new Map();
|
|
378
|
+
const finalByPath = new Map();
|
|
379
|
+
for (const p of pages) {
|
|
380
|
+
if (!finalBySlug.has(p.slug))
|
|
381
|
+
finalBySlug.set(p.slug, p);
|
|
382
|
+
finalByPath.set(p.path, p);
|
|
383
|
+
}
|
|
384
|
+
const order = listed.map((p) => finalBySlug.get(p.slug)).filter((p) => !p.hidden);
|
|
385
|
+
return { pages, order, nav, bySlug: finalBySlug, byPath: finalByPath, root, assets };
|
|
386
|
+
}
|
|
387
|
+
/** The asset (non-Markdown file) `href` names from `from`, with its root-relative path; null when none. */
|
|
388
|
+
export function findLinkedAsset(tree, from, href) {
|
|
389
|
+
const resolved = resolveRelativePath(from.path, href);
|
|
390
|
+
if (!resolved)
|
|
391
|
+
return null;
|
|
392
|
+
const content = tree.assets.get(resolved.path);
|
|
393
|
+
return content === undefined ? null : { path: resolved.path, content };
|
|
394
|
+
}
|
|
395
|
+
/** The page `href` points at from `from` — a relative `.md` path, a folder, or a slug. */
|
|
396
|
+
export function findLinkedPage(tree, from, href) {
|
|
397
|
+
const resolved = resolveRelativePath(from.path, href);
|
|
398
|
+
if (!resolved)
|
|
399
|
+
return null;
|
|
400
|
+
const { path, hash } = resolved;
|
|
401
|
+
if (!href.split("#")[0])
|
|
402
|
+
return { page: from, hash };
|
|
403
|
+
const direct = tree.byPath.get(path) ??
|
|
404
|
+
tree.byPath.get(`${path}/README.md`) ??
|
|
405
|
+
tree.byPath.get(`${path}/readme.md`) ??
|
|
406
|
+
tree.byPath.get(`${path}/index.md`) ??
|
|
407
|
+
tree.bySlug.get(path) ??
|
|
408
|
+
tree.bySlug.get(slugForPath(path));
|
|
409
|
+
return direct ? { page: direct, hash } : null;
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.js","sourceRoot":"","sources":["../../src/site/tree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;yFAgByF;AACzF,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAwD3C,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAU,CAAA;AAEjG,MAAM,QAAQ,GAAG,uBAAuB,CAAA;AACxC,MAAM,KAAK,GAAG,mBAAmB,CAAA;AACjC,MAAM,MAAM,GAAG,oBAAoB,CAAA;AAEnC,MAAM,MAAM,GAAG,CAAC,CAAU,EAAa,EAAE,CAAC,OAAO,IAAI,KAAK,WAAW,IAAI,CAAC,YAAY,IAAI,CAAA;AAE1F,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG;YAAE,SAAQ;QACnC,I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xE,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,cAAc,CAAC,IAAc,EAAE,IAAc,EAAE,IAAY;IACzE,MAAM,QAAQ,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACrD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC1B,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAA;IAC/B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IACpD,MAAM,MAAM,GACV,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,YAAY,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,YAAY,CAAC;QACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,WAAW,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;IACpC,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/C,CAAC"}
|
package/dist/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brett_lamy/docstream",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.1",
|
|
4
4
|
"description": "GitBook-aware readonly markdown and AI stream renderer.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -136,6 +136,13 @@
|
|
|
136
136
|
"import": "./dist/vite/index.js",
|
|
137
137
|
"default": "./dist/vite/index.js"
|
|
138
138
|
},
|
|
139
|
+
"./site": {
|
|
140
|
+
"source": "./src/site/index.ts",
|
|
141
|
+
"types": "./dist/site/index.d.ts",
|
|
142
|
+
"import": "./dist/site/index.js",
|
|
143
|
+
"default": "./dist/site/index.js"
|
|
144
|
+
},
|
|
145
|
+
"./site/styles.css": "./dist/site/site.css",
|
|
139
146
|
"./styles.css": "./dist/styles.css"
|
|
140
147
|
},
|
|
141
148
|
"dependencies": {
|
|
@@ -358,8 +358,10 @@ function BlockView({ block, liveRenderer, sourceRenderer }: { block: Block } & R
|
|
|
358
358
|
}
|
|
359
359
|
case "heading": {
|
|
360
360
|
const Tag = `h${block.level}` as const
|
|
361
|
+
// The same anchor `documentOutline` reports, so a table of contents can link to it.
|
|
362
|
+
const text = plainText(block.children)
|
|
361
363
|
return (
|
|
362
|
-
<Tag>
|
|
364
|
+
<Tag id={text ? slugify(text) : undefined}>
|
|
363
365
|
<InlineText nodes={block.children} />
|
|
364
366
|
</Tag>
|
|
365
367
|
)
|
|
@@ -483,7 +485,7 @@ function BlockView({ block, liveRenderer, sourceRenderer }: { block: Block } & R
|
|
|
483
485
|
<a className="docs-content-ref" href={block.url}>
|
|
484
486
|
<File className="size-4" />
|
|
485
487
|
<span>
|
|
486
|
-
<InlineText nodes={block.children} />
|
|
488
|
+
<InlineText nodes={withoutLinks(block.children)} />
|
|
487
489
|
</span>
|
|
488
490
|
<ChevronRight className="size-4 ml-auto" />
|
|
489
491
|
</a>
|
|
@@ -520,7 +522,7 @@ function BlockView({ block, liveRenderer, sourceRenderer }: { block: Block } & R
|
|
|
520
522
|
case "list": {
|
|
521
523
|
const Tag = block.ordered ? "ol" : "ul"
|
|
522
524
|
return (
|
|
523
|
-
<Tag className={block.task ? "docs-tasklist" : undefined}>
|
|
525
|
+
<Tag className={block.task ? "docs-tasklist" : undefined} start={block.ordered && block.start !== undefined && block.start !== 1 ? block.start : undefined}>
|
|
524
526
|
{block.items.map((item, i) => (
|
|
525
527
|
<li key={i} data-task-state={block.task ? getTaskState(item) : undefined}>
|
|
526
528
|
{block.task && <TaskCheckbox state={getTaskState(item)} label={item.children.filter((b) => b.type === "paragraph").map((b) => b.type === "paragraph" ? plainText(b.children) : "").join(" ") || "Task"}
|
|
@@ -662,6 +664,15 @@ function Blocks({ blocks, inline, liveRenderer, sourceRenderer }: { blocks: Bloc
|
|
|
662
664
|
)
|
|
663
665
|
}
|
|
664
666
|
|
|
667
|
+
/** A card that is itself a link shows its label's links as text: an `<a>` can't hold another. */
|
|
668
|
+
function withoutLinks(nodes: Inline[]): Inline[] {
|
|
669
|
+
return nodes.map((n) => {
|
|
670
|
+
if (n.type === "reference" || !("link" in n) || n.link === undefined) return n
|
|
671
|
+
const { link: _link, ...rest } = n as Inline & { link?: string }
|
|
672
|
+
return rest as Inline
|
|
673
|
+
})
|
|
674
|
+
}
|
|
675
|
+
|
|
665
676
|
export interface DocRenderOptions {
|
|
666
677
|
/** Make rendered task checkboxes interactive. Update the supplied item and re-render to persist a choice. */
|
|
667
678
|
onTaskStateChange?: TaskStateChangeHandler
|