@brett_lamy/docstream 1.3.0 → 1.4.0

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 (207) hide show
  1. package/README.md +25 -5
  2. package/dist/assets.d.ts +3 -0
  3. package/dist/assets.d.ts.map +1 -0
  4. package/dist/assets.js +20 -0
  5. package/dist/assets.js.map +1 -0
  6. package/dist/demo/DemoViewer.d.ts +64 -0
  7. package/dist/demo/DemoViewer.d.ts.map +1 -0
  8. package/dist/demo/DemoViewer.js +426 -0
  9. package/dist/demo/DemoViewer.js.map +1 -0
  10. package/dist/demo/context.d.ts +14 -0
  11. package/dist/demo/context.d.ts.map +1 -0
  12. package/dist/demo/context.js +25 -0
  13. package/dist/demo/context.js.map +1 -0
  14. package/dist/demo/glob.d.ts +60 -0
  15. package/dist/demo/glob.d.ts.map +1 -0
  16. package/dist/demo/glob.js +158 -0
  17. package/dist/demo/glob.js.map +1 -0
  18. package/dist/demo/index.d.ts +10 -0
  19. package/dist/demo/index.d.ts.map +1 -0
  20. package/dist/demo/index.js +6 -0
  21. package/dist/demo/index.js.map +1 -0
  22. package/dist/demo/markdown.d.ts +60 -0
  23. package/dist/demo/markdown.d.ts.map +1 -0
  24. package/dist/demo/markdown.js +181 -0
  25. package/dist/demo/markdown.js.map +1 -0
  26. package/dist/demo/surface.d.ts +11 -0
  27. package/dist/demo/surface.d.ts.map +1 -0
  28. package/dist/demo/surface.js +69 -0
  29. package/dist/demo/surface.js.map +1 -0
  30. package/dist/demo/types.d.ts +91 -0
  31. package/dist/demo/types.d.ts.map +1 -0
  32. package/dist/demo/types.js +2 -0
  33. package/dist/demo/types.js.map +1 -0
  34. package/dist/docs/CollapsibleCode.d.ts +14 -0
  35. package/dist/docs/CollapsibleCode.d.ts.map +1 -0
  36. package/dist/docs/CollapsibleCode.js +19 -0
  37. package/dist/docs/CollapsibleCode.js.map +1 -0
  38. package/dist/docs/DocsRenderer.d.ts +49 -0
  39. package/dist/docs/DocsRenderer.d.ts.map +1 -0
  40. package/dist/docs/DocsRenderer.js +277 -0
  41. package/dist/docs/DocsRenderer.js.map +1 -0
  42. package/dist/docs/HighlightedCode.d.ts +6 -0
  43. package/dist/docs/HighlightedCode.d.ts.map +1 -0
  44. package/dist/docs/HighlightedCode.js +40 -0
  45. package/dist/docs/HighlightedCode.js.map +1 -0
  46. package/dist/docs/Mermaid.d.ts +7 -0
  47. package/dist/docs/Mermaid.d.ts.map +1 -0
  48. package/dist/docs/Mermaid.js +39 -0
  49. package/dist/docs/Mermaid.js.map +1 -0
  50. package/dist/docs/PageActions.d.ts +33 -0
  51. package/dist/docs/PageActions.d.ts.map +1 -0
  52. package/dist/docs/PageActions.js +115 -0
  53. package/dist/docs/PageActions.js.map +1 -0
  54. package/dist/docs/controls.d.ts +29 -0
  55. package/dist/docs/controls.d.ts.map +1 -0
  56. package/dist/docs/controls.js +46 -0
  57. package/dist/docs/controls.js.map +1 -0
  58. package/dist/docs/copy.d.ts +24 -0
  59. package/dist/docs/copy.d.ts.map +1 -0
  60. package/dist/docs/copy.js +62 -0
  61. package/dist/docs/copy.js.map +1 -0
  62. package/dist/docs/math.d.ts +3 -0
  63. package/dist/docs/math.d.ts.map +1 -0
  64. package/dist/docs/math.js +12 -0
  65. package/dist/docs/math.js.map +1 -0
  66. package/dist/docs/reference.d.ts +27 -0
  67. package/dist/docs/reference.d.ts.map +1 -0
  68. package/dist/docs/reference.js +73 -0
  69. package/dist/docs/reference.js.map +1 -0
  70. package/dist/docs/tabs-sync.d.ts +5 -0
  71. package/dist/docs/tabs-sync.d.ts.map +1 -0
  72. package/dist/docs/tabs-sync.js +58 -0
  73. package/dist/docs/tabs-sync.js.map +1 -0
  74. package/dist/gitbook/ast.d.ts +506 -0
  75. package/dist/gitbook/ast.d.ts.map +1 -0
  76. package/dist/gitbook/ast.js +8 -0
  77. package/dist/gitbook/ast.js.map +1 -0
  78. package/dist/gitbook/attrs.d.ts +14 -0
  79. package/dist/gitbook/attrs.d.ts.map +1 -0
  80. package/dist/gitbook/attrs.js +36 -0
  81. package/dist/gitbook/attrs.js.map +1 -0
  82. package/dist/gitbook/flatten.d.ts +14 -0
  83. package/dist/gitbook/flatten.d.ts.map +1 -0
  84. package/dist/gitbook/flatten.js +45 -0
  85. package/dist/gitbook/flatten.js.map +1 -0
  86. package/dist/gitbook/index.d.ts +10 -0
  87. package/dist/gitbook/index.d.ts.map +1 -0
  88. package/dist/gitbook/index.js +8 -0
  89. package/dist/gitbook/index.js.map +1 -0
  90. package/dist/gitbook/inline.d.ts +28 -0
  91. package/dist/gitbook/inline.d.ts.map +1 -0
  92. package/dist/gitbook/inline.js +956 -0
  93. package/dist/gitbook/inline.js.map +1 -0
  94. package/dist/gitbook/outline.d.ts +16 -0
  95. package/dist/gitbook/outline.d.ts.map +1 -0
  96. package/dist/gitbook/outline.js +44 -0
  97. package/dist/gitbook/outline.js.map +1 -0
  98. package/dist/gitbook/package-managers.d.ts +12 -0
  99. package/dist/gitbook/package-managers.d.ts.map +1 -0
  100. package/dist/gitbook/package-managers.js +93 -0
  101. package/dist/gitbook/package-managers.js.map +1 -0
  102. package/dist/gitbook/parse.d.ts +44 -0
  103. package/dist/gitbook/parse.d.ts.map +1 -0
  104. package/dist/gitbook/parse.js +1113 -0
  105. package/dist/gitbook/parse.js.map +1 -0
  106. package/dist/gitbook/serialize.d.ts +23 -0
  107. package/dist/gitbook/serialize.d.ts.map +1 -0
  108. package/dist/gitbook/serialize.js +498 -0
  109. package/dist/gitbook/serialize.js.map +1 -0
  110. package/dist/index.d.ts +34 -0
  111. package/dist/index.d.ts.map +1 -0
  112. package/dist/index.js +24 -0
  113. package/dist/index.js.map +1 -0
  114. package/dist/openapi/OpenApiOperation.d.ts +6 -0
  115. package/dist/openapi/OpenApiOperation.d.ts.map +1 -0
  116. package/dist/openapi/OpenApiOperation.js +112 -0
  117. package/dist/openapi/OpenApiOperation.js.map +1 -0
  118. package/dist/playground/InlineDemoPreview.d.ts +24 -0
  119. package/dist/playground/InlineDemoPreview.d.ts.map +1 -0
  120. package/dist/playground/InlineDemoPreview.js +48 -0
  121. package/dist/playground/InlineDemoPreview.js.map +1 -0
  122. package/dist/playground/PlaygroundStreamdown.d.ts +16 -0
  123. package/dist/playground/PlaygroundStreamdown.d.ts.map +1 -0
  124. package/dist/playground/PlaygroundStreamdown.js +22 -0
  125. package/dist/playground/PlaygroundStreamdown.js.map +1 -0
  126. package/dist/playground/ReactCodePreview.d.ts +64 -0
  127. package/dist/playground/ReactCodePreview.d.ts.map +1 -0
  128. package/dist/playground/ReactCodePreview.js +108 -0
  129. package/dist/playground/ReactCodePreview.js.map +1 -0
  130. package/dist/playground/filesystem.d.ts +27 -0
  131. package/dist/playground/filesystem.d.ts.map +1 -0
  132. package/dist/playground/filesystem.js +65 -0
  133. package/dist/playground/filesystem.js.map +1 -0
  134. package/dist/playground/index.d.ts +9 -0
  135. package/dist/playground/index.d.ts.map +1 -0
  136. package/dist/playground/index.js +7 -0
  137. package/dist/playground/index.js.map +1 -0
  138. package/dist/playground/project.d.ts +57 -0
  139. package/dist/playground/project.d.ts.map +1 -0
  140. package/dist/playground/project.js +137 -0
  141. package/dist/playground/project.js.map +1 -0
  142. package/dist/replay/NativeReplay.d.ts +9 -0
  143. package/dist/replay/NativeReplay.d.ts.map +1 -0
  144. package/dist/replay/NativeReplay.js +173 -0
  145. package/dist/replay/NativeReplay.js.map +1 -0
  146. package/dist/replay/ReplayPreview.d.ts +33 -0
  147. package/dist/replay/ReplayPreview.d.ts.map +1 -0
  148. package/dist/replay/ReplayPreview.js +91 -0
  149. package/dist/replay/ReplayPreview.js.map +1 -0
  150. package/dist/replay/index.d.ts +5 -0
  151. package/dist/replay/index.d.ts.map +1 -0
  152. package/dist/replay/index.js +4 -0
  153. package/dist/replay/index.js.map +1 -0
  154. package/dist/replay/sanitize.d.ts +4 -0
  155. package/dist/replay/sanitize.d.ts.map +1 -0
  156. package/dist/replay/sanitize.js +86 -0
  157. package/dist/replay/sanitize.js.map +1 -0
  158. package/dist/replay/url.d.ts +8 -0
  159. package/dist/replay/url.d.ts.map +1 -0
  160. package/dist/replay/url.js +41 -0
  161. package/dist/replay/url.js.map +1 -0
  162. package/dist/source/SourcePreview.d.ts +13 -0
  163. package/dist/source/SourcePreview.d.ts.map +1 -0
  164. package/dist/source/SourcePreview.js +47 -0
  165. package/dist/source/SourcePreview.js.map +1 -0
  166. package/dist/source/client.d.ts +7 -0
  167. package/dist/source/client.d.ts.map +1 -0
  168. package/dist/source/client.js +52 -0
  169. package/dist/source/client.js.map +1 -0
  170. package/dist/source/index.d.ts +6 -0
  171. package/dist/source/index.d.ts.map +1 -0
  172. package/dist/source/index.js +3 -0
  173. package/dist/source/index.js.map +1 -0
  174. package/dist/source/types.d.ts +33 -0
  175. package/dist/source/types.d.ts.map +1 -0
  176. package/dist/source/types.js +2 -0
  177. package/dist/source/types.js.map +1 -0
  178. package/dist/streamdown.d.ts +19 -0
  179. package/dist/streamdown.d.ts.map +1 -0
  180. package/dist/streamdown.js +15 -0
  181. package/dist/streamdown.js.map +1 -0
  182. package/dist/styles.css +2441 -0
  183. package/dist/video/VideoEmbed.d.ts +17 -0
  184. package/dist/video/VideoEmbed.d.ts.map +1 -0
  185. package/dist/video/VideoEmbed.js +12 -0
  186. package/dist/video/VideoEmbed.js.map +1 -0
  187. package/dist/video/index.d.ts +3 -0
  188. package/dist/video/index.d.ts.map +1 -0
  189. package/dist/video/index.js +2 -0
  190. package/dist/video/index.js.map +1 -0
  191. package/dist/vite/index.d.ts +21 -0
  192. package/dist/vite/index.d.ts.map +1 -0
  193. package/dist/vite/index.js +137 -0
  194. package/dist/vite/index.js.map +1 -0
  195. package/dist/viz/VizEmbed.d.ts +18 -0
  196. package/dist/viz/VizEmbed.d.ts.map +1 -0
  197. package/dist/viz/VizEmbed.js +12 -0
  198. package/dist/viz/VizEmbed.js.map +1 -0
  199. package/dist/viz/index.d.ts +4 -0
  200. package/dist/viz/index.d.ts.map +1 -0
  201. package/dist/viz/index.js +3 -0
  202. package/dist/viz/index.js.map +1 -0
  203. package/package.json +62 -32
  204. package/src/docs/Mermaid.tsx +5 -3
  205. package/src/replay/ReplayPreview.tsx +0 -1
  206. package/src/styles.css +91 -0
  207. package/src/replay/styles.css +0 -87
@@ -0,0 +1,506 @@
1
+ export type HintStyle = "info" | "success" | "warning" | "danger";
2
+ /**
3
+ * Formatting every inline carries — text runs, chips and inline images alike, so emphasis and links can span
4
+ * them (`**ask @brett**`, `*see ![i](s)*`, `[![badge](b.svg)](url)`) — plus how the source spelled it.
5
+ */
6
+ export interface InlineMarks {
7
+ bold?: boolean;
8
+ italic?: boolean;
9
+ strike?: boolean;
10
+ link?: string;
11
+ /**
12
+ * The link sits inside the emphasis (`**[x](url)**`) rather than around it
13
+ * (`[**x**](url)`, the default). Kept so the source round-trips byte-for-byte.
14
+ */
15
+ linkInner?: true;
16
+ /**
17
+ * How the source spelled this inline's formatting, outermost → innermost, when that differs from the default
18
+ * output (`_italic_`, `**bold**`, `~~strike~~`, link around its emphasis, bare autolinks). Each entry is an
19
+ * emphasis marker, or a link form (see {@link LinkForm}). E.g. `**_x_**` → `["**", "_"]`, `***x***` →
20
+ * `["*", "**"]`, `*x*` → `["*"]`, `*a *b* c*` → `["*", "*"]` for `b`.
21
+ *
22
+ * A hint only — the boolean marks and `link` stay authoritative: entries for marks the run no longer has are
23
+ * ignored, marks it has without an entry get the default spelling and position. Absent on runs that
24
+ * serialize the default way and on programmatically created nodes.
25
+ */
26
+ delims?: InlineDelimiter[];
27
+ /** The link's title as written between the quotes: `[x](url "title")`. */
28
+ linkTitle?: string;
29
+ /**
30
+ * The reference label of a reference-style link, as written: `ref` for `[text][ref]`, and the link text
31
+ * for the collapsed `[text][]` and shortcut `[text]` forms.
32
+ */
33
+ linkRef?: string;
34
+ /** The opening tag of an inline HTML link as written (`<a href="…" target="_blank">`). */
35
+ linkTag?: string;
36
+ /** The closing tag of an inline HTML link, when not `</a>` (`</A>`). */
37
+ linkTagEnd?: string;
38
+ /**
39
+ * Link identity: set on the runs of a link that directly follows another link to the same target
40
+ * (`[a](u)[b](u)`), so the two stay distinct instead of merging into one. Runs of one link share it.
41
+ */
42
+ linkId?: number;
43
+ }
44
+ export interface TextNode extends InlineMarks {
45
+ type: "text";
46
+ text: string;
47
+ code?: boolean;
48
+ /**
49
+ * The source wrote every character of this run backslash-escaped (`snake\_case` → `snake`, `_` escaped,
50
+ * `case`). Only ASCII punctuation can be escaped. Kept so author escapes survive even where they aren't
51
+ * needed; the text itself is the literal characters.
52
+ */
53
+ escaped?: true;
54
+ /**
55
+ * Code span in a GFM table cell: offsets (in `text`) of the `|` characters the source wrote bare instead
56
+ * of as `\|`. Serialization escapes every other pipe.
57
+ */
58
+ barePipes?: number[];
59
+ /** A code span's backtick count as written, when longer than serialization needs (```` ```x``` ````). */
60
+ ticks?: number;
61
+ }
62
+ /** An emphasis marker as written in the source. */
63
+ export type EmphasisDelimiter = "**" | "__" | "*" | "_" | "~~";
64
+ /**
65
+ * How a link is written: `"link"` `[x](url)`, `"<>"` `<url>`, `"url"` a bare autolink, `"ref"` `[x][label]`,
66
+ * `"collapsed"` `[x][]`, `"shortcut"` `[x]` (the last three resolved through a `[label]: url` definition),
67
+ * `"html"` `<a href="url">x</a>`.
68
+ */
69
+ export type LinkForm = "link" | "<>" | "url" | "ref" | "collapsed" | "shortcut" | "html";
70
+ /** An entry of {@link InlineMarks.delims}: an emphasis marker or a link form. */
71
+ export type InlineDelimiter = EmphasisDelimiter | LinkForm;
72
+ /**
73
+ * Inline image: `![alt](src "title")` (`syntax: "markdown"`), or HTML `<img …>` / `<a href><img …></a>`
74
+ * (GitHub README badge style, the default).
75
+ *
76
+ * `link` without a link form in `delims` is the HTML `<a href>` around the `<img>`; with one
77
+ * (`[![a](s)](url)`) it is an ordinary link mark that may span neighbouring text.
78
+ */
79
+ export interface InlineImageNode extends InlineMarks {
80
+ type: "image";
81
+ src: string;
82
+ alt?: string;
83
+ width?: string;
84
+ height?: string;
85
+ /** `![alt](src "title")`'s title, as written between the quotes. */
86
+ title?: string;
87
+ /** Written as Markdown `![alt](src)`. Absent: HTML `<img>`. */
88
+ syntax?: "markdown";
89
+ /**
90
+ * A Markdown image whose source comes from a definition: `![alt][label]` (`"ref"`), `![alt][]`
91
+ * (`"collapsed"`) or `![alt]` (`"shortcut"`), with `srcRef` the label as written.
92
+ */
93
+ srcForm?: "ref" | "collapsed" | "shortcut";
94
+ srcRef?: string;
95
+ /**
96
+ * The HTML as written (`<img …>`, or `<a href><img …></a>` for a linked image). Serialization reuses it
97
+ * while it still says the same src / alt / width / height / link; otherwise it writes fresh HTML.
98
+ */
99
+ html?: string;
100
+ }
101
+ export type ReferenceKind = "mention" | "tag" | "codebase" | "citation";
102
+ /**
103
+ * Inline reference chip: `@mention`, `#tag`, or footnote-style citation `[^id]`.
104
+ * `id` carries no sigil. Citations resolve `url`/`label` from their
105
+ * `[^id]: url "Label"` definition at parse time when one exists.
106
+ *
107
+ * The inherited `link` is a link *around* the chip (`[@brett](url)`); `url` is the citation's target.
108
+ */
109
+ export interface ReferenceNode extends InlineMarks {
110
+ type: "reference";
111
+ kind: ReferenceKind;
112
+ id: string;
113
+ url?: string;
114
+ label?: string;
115
+ }
116
+ /** A footnote citation definition (`[^id]: url "Label"`), collected doc-level. */
117
+ export interface CitationDef {
118
+ id: string;
119
+ url: string;
120
+ label?: string;
121
+ }
122
+ export type Inline = TextNode | InlineImageNode | ReferenceNode;
123
+ /**
124
+ * Layout the source used around a block, recorded only where it differs from the serializer's default so
125
+ * pages round-trip byte-for-byte.
126
+ */
127
+ export interface BlockSpacing {
128
+ /**
129
+ * Blank lines before this block (or tab / step / column / update / list item): by default 1 between
130
+ * siblings and 0 before the first child of a container (1 after an expandable's `<summary>`).
131
+ */
132
+ gap?: number;
133
+ /** Those blank lines as written, when some hold whitespace. */
134
+ blanks?: string[];
135
+ }
136
+ /** A `{% tag %}` container's opening and closing lines as written, reused while they still say the same. */
137
+ export interface TagLines {
138
+ /** The opening tag line, when not the one serialization writes (quote style, spacing, extra attributes). */
139
+ opening?: string;
140
+ /** The closing tag line, when not the canonical `{% endtag %}` ("" when the input ended first). */
141
+ closing?: string;
142
+ }
143
+ /** A block's source lines as written, where they aren't what serialization writes; reused while they still parse to the same block. */
144
+ export interface RawSource {
145
+ raw?: string;
146
+ }
147
+ /** Spacing inside a container, before its closing line. */
148
+ export interface ContainerSpacing extends BlockSpacing {
149
+ /** Blank lines between the last child and the closing tag (default 0; 1 in an expandable). */
150
+ gapEnd?: number;
151
+ }
152
+ export interface ParagraphNode extends BlockSpacing {
153
+ type: "paragraph";
154
+ children: Inline[];
155
+ /** Whitespace before the paragraph's first line, as written (continuation lines keep theirs in the text). */
156
+ indent?: string;
157
+ }
158
+ export interface HeadingNode extends BlockSpacing {
159
+ type: "heading";
160
+ level: 1 | 2 | 3 | 4 | 5 | 6;
161
+ children: Inline[];
162
+ /** A setext heading's underline as written (`===`, `---`); absent for `#` headings. */
163
+ setext?: string;
164
+ }
165
+ export interface CodeBlockNode extends BlockSpacing {
166
+ type: "code";
167
+ language: string | null;
168
+ title: string | null;
169
+ /**
170
+ * Show line numbers. Defaults (when the fence doesn't say) to on for titled fences and
171
+ * off for untitled ones; `lineNumbers="true"` / `"false"` overrides.
172
+ */
173
+ lineNumbers: boolean;
174
+ /**
175
+ * The source wrote `lineNumbers` (or `showLineNumbers`) explicitly: the serializer keeps
176
+ * the attribute even when it matches the default, so pages round-trip byte-for-byte.
177
+ */
178
+ lineNumbersExplicit?: boolean;
179
+ code: string;
180
+ /** Run a React/JSX/TSX entry file in the optional almost-node preview. */
181
+ live?: boolean;
182
+ /** Project-relative entry file used by a live preview. */
183
+ entry?: string | null;
184
+ /** Source lines visible before an expandable code preview is opened. */
185
+ collapsedCodeLines?: number;
186
+ /** Maximum source lines visible before expanded code scrolls. */
187
+ expandedCodeLines?: number;
188
+ /** The opening fence as written when not ```` ``` ```` (`~~~`, ````` ```` `````). */
189
+ fence?: string;
190
+ /** The info string as written after the fence, when it isn't the one serialization writes. */
191
+ info?: string;
192
+ /** The closing fence line as written, when it isn't the opening fence ("" when the input ended first). */
193
+ closingFence?: string;
194
+ /** An indented (four-space) code block rather than a fence. */
195
+ indented?: true;
196
+ /** The block as written when it isn't a plain fence (a `{% code %}` wrapper), reused while it still says the same. */
197
+ raw?: string;
198
+ }
199
+ export interface HintNode extends ContainerSpacing, TagLines {
200
+ type: "hint";
201
+ style: HintStyle;
202
+ children: Block[];
203
+ }
204
+ export interface TabNode extends ContainerSpacing, TagLines {
205
+ type: "tab";
206
+ title: string;
207
+ children: Block[];
208
+ }
209
+ export interface TabsNode extends ContainerSpacing, TagLines {
210
+ type: "tabs";
211
+ tabs: TabNode[];
212
+ /**
213
+ * Sync group (`{% tabs sync="pm" %}`). Every tab set with the same key follows
214
+ * the reader's last choice (matched by tab title), remembered across pages.
215
+ */
216
+ sync?: string;
217
+ /**
218
+ * Section title (`{% tabs title="Installation" %}`). The tab set renders as a
219
+ * section: this title as a heading (with an anchor id), the tab switch as pill
220
+ * tabs right-aligned in that header, and the active tab's blocks below.
221
+ */
222
+ title?: string;
223
+ /** Heading level of `title` (`level="3"`). Defaults to 2. */
224
+ level?: 2 | 3 | 4;
225
+ }
226
+ export type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
227
+ /**
228
+ * A package-manager command box: `{% command %}npm install x{% endcommand %}`.
229
+ * The author writes one canonical npm / npx command; renderers derive the pnpm,
230
+ * yarn and bun forms (see `packageManagerCommands`), unless overridden per
231
+ * manager (`pnpm="…"`). The reader's manager is synced page-wide (and across
232
+ * pages) under `sync` — `"pm"` by default, the same key install `{% tabs %}` use.
233
+ */
234
+ export interface CommandNode extends BlockSpacing, RawSource {
235
+ type: "command";
236
+ /** The npm / npx command (may span lines). */
237
+ command: string;
238
+ /** Explicit commands for other managers, used verbatim instead of the derived ones. */
239
+ overrides?: Partial<Record<Exclude<PackageManager, "npm">, string>>;
240
+ /** Sync key. Omitted means `"pm"`. */
241
+ sync?: string;
242
+ }
243
+ export interface ExpandableNode extends ContainerSpacing {
244
+ /** The closing line, when not `</details>`. */
245
+ closing?: string;
246
+ type: "expandable";
247
+ summary: string;
248
+ children: Block[];
249
+ /**
250
+ * The lines from `<details>` through `</summary>` as written, when not `<details>`, a blank line,
251
+ * `<summary>…</summary>`. Reused while they still say the same summary.
252
+ */
253
+ opening?: string;
254
+ }
255
+ export interface StepNode extends ContainerSpacing, TagLines {
256
+ type: "step";
257
+ title: string;
258
+ children: Block[];
259
+ /**
260
+ * The title heading as written (and any blank lines before it), when not `### title` — `## Title`,
261
+ * `### **Bold** title`. Reused while it still gives the same title.
262
+ */
263
+ heading?: string;
264
+ }
265
+ export interface StepperNode extends ContainerSpacing, TagLines {
266
+ type: "stepper";
267
+ steps: StepNode[];
268
+ }
269
+ export interface EmbedNode extends BlockSpacing {
270
+ type: "embed";
271
+ url: string;
272
+ title?: string;
273
+ autoplay?: boolean;
274
+ loop?: boolean;
275
+ muted?: boolean;
276
+ controls?: boolean;
277
+ poster?: string;
278
+ /** The tag as written (with its `{% endembed %}`), reused while it still says the same. */
279
+ raw?: string;
280
+ }
281
+ export interface ContentRefNode extends BlockSpacing {
282
+ type: "content-ref";
283
+ url: string;
284
+ children: Inline[];
285
+ /** The block as written when it isn't the canonical `{% content-ref %}` (a `{% file %}` tag), reused while it still says the same. */
286
+ raw?: string;
287
+ }
288
+ export type SourceReferenceKind = "component" | "story";
289
+ /**
290
+ * A reference to an export in a real source file. The source file remains the
291
+ * authority; Markdown only stores the composition and presentation metadata.
292
+ */
293
+ export interface SourceRefNode extends BlockSpacing {
294
+ type: "source-ref";
295
+ /** Name of the directory mounted by the Docstream Vite plugin. */
296
+ mount: string;
297
+ /** POSIX-style path relative to the mounted source directory. */
298
+ path: string;
299
+ /** Named export to render. Defaults to `default`. */
300
+ exportName: string;
301
+ kind: SourceReferenceKind;
302
+ title?: string;
303
+ /** The tag as written (`{% component … %}`, an end tag), reused while it still says the same. */
304
+ raw?: string;
305
+ }
306
+ export type DemoLayout = "auto" | "single" | "multi";
307
+ export type DemoViewport = "desktop" | "tablet" | "phone";
308
+ export interface DemoVariantOption {
309
+ id: string;
310
+ label: string;
311
+ }
312
+ /** One source file carried inline by a `{% demo %}` block (a titled fence). */
313
+ export interface DemoInlineFile {
314
+ /** Path relative to the demo folder, from the fence's `title` (`index.tsx`, `parts/Card.tsx`). */
315
+ path: string;
316
+ content: string;
317
+ /** The fence's info-string language, when it has one. */
318
+ language?: string;
319
+ }
320
+ /**
321
+ * A live demo: `{% demo src="<page>/<example>" %}`. With a host `DemoResolver`
322
+ * that knows `src`, the example folder is the authority for the component, its
323
+ * source files and its defaults; attributes here override the folder's
324
+ * `meta.json` field by field (tag attribute first, then `meta.json`, then the built-in
325
+ * default) — including the look attributes `status`, `bleed`, `className`, `surface` and
326
+ * `variantsWidth`, which Copy page writes so the block renders the same without the resolver.
327
+ * The block form carries the files inline so the Markdown renders anywhere, resolver
328
+ * or not:
329
+ *
330
+ * {% demo src="composer/scroll-fab" title="Scroll → FAB" %}
331
+ * ```tsx title="index.tsx"
332
+ * …
333
+ * ```
334
+ * {% enddemo %}
335
+ */
336
+ export interface DemoNode extends BlockSpacing, RawSource {
337
+ type: "demo";
338
+ /** `<page>/<example>` folder id understood by the host's resolver. */
339
+ src: string;
340
+ title?: string;
341
+ description?: string;
342
+ /** Preview height, kept verbatim (`"420"`, `"60vh"`, `"auto"`). */
343
+ height?: string;
344
+ layout?: DemoLayout;
345
+ /** `variants="full:Full,compact:Compact"`. */
346
+ variants?: DemoVariantOption[];
347
+ /** Initial preview viewport for the multi-file viewer. */
348
+ viewport?: DemoViewport;
349
+ /** Entry file among the inline files (`entry="App.tsx"`). Defaults to the first file. */
350
+ entry?: string;
351
+ /** Short status shown in the demo header (`status="Live"`). */
352
+ status?: string;
353
+ /** Drop the padded preview surface (`bleed="true"`) for demos with their own full-bleed frame. */
354
+ bleed?: boolean;
355
+ /** Extra class on the preview canvas (`className="brand-surface"`). */
356
+ className?: string;
357
+ /**
358
+ * Inline style for the preview canvas as CSS declarations, kept verbatim:
359
+ * `surface="background: var(--brand-50); --demo-gap: 12px"`.
360
+ */
361
+ surface?: string;
362
+ /** Width of the variant switch, kept verbatim (`"240"`, `"16rem"`). */
363
+ variantsWidth?: string;
364
+ /** Files carried inline by the block form, in document order. */
365
+ files?: DemoInlineFile[];
366
+ /**
367
+ * Set while streaming when the block's `{% enddemo %}` has not arrived yet: the
368
+ * files may still be growing, so renderers show code but hold off running it.
369
+ * Never serialized.
370
+ */
371
+ open?: true;
372
+ }
373
+ export interface ColumnNode extends ContainerSpacing, TagLines {
374
+ type: "column";
375
+ children: Block[];
376
+ }
377
+ export interface ColumnsNode extends ContainerSpacing, TagLines {
378
+ type: "columns";
379
+ columns: ColumnNode[];
380
+ }
381
+ export interface FigureNode extends BlockSpacing {
382
+ type: "figure";
383
+ src: string;
384
+ alt: string;
385
+ caption: string;
386
+ /** `![alt](src "title")`'s title. */
387
+ title?: string;
388
+ /**
389
+ * The line(s) as written (`![alt](src)`, `<img …>`, `<figure>…</figure>`). Serialization reuses them while
390
+ * they still parse to the same src / alt / caption / title; otherwise it writes a `<figure>`.
391
+ */
392
+ raw?: string;
393
+ }
394
+ export interface ListItemNode extends ContainerSpacing {
395
+ type: "listItem";
396
+ children: Block[];
397
+ checked?: boolean;
398
+ /** The item's marker as written (`*`, `3.`), when it isn't the one its list's pattern gives it. */
399
+ marker?: string;
400
+ /** Spaces between the marker and the content (default 1). */
401
+ pad?: number;
402
+ /** Indent of the item's continuation lines, relative to its marker (default 2). */
403
+ indent?: number;
404
+ /** A checked task written `[X]`. */
405
+ checkMark?: "X";
406
+ }
407
+ export interface ListNode extends BlockSpacing {
408
+ type: "list";
409
+ ordered: boolean;
410
+ task: boolean;
411
+ items: ListItemNode[];
412
+ /** Bullet marker of an unordered list (default `-`). */
413
+ bullet?: "*" | "+";
414
+ /** Number of an ordered list's first item (default 1). */
415
+ start?: number;
416
+ /** Ordered-list delimiter (default `.`). */
417
+ delimiter?: ")";
418
+ /** Whitespace before the list's markers, as written. */
419
+ indent?: string;
420
+ }
421
+ export interface BlockquoteNode extends ContainerSpacing {
422
+ type: "blockquote";
423
+ children: Block[];
424
+ /** Each line's `>` prefix as written (indent, spacing), when not `> ` (`>` on empty lines). */
425
+ markers?: string[];
426
+ }
427
+ export interface DividerNode extends BlockSpacing {
428
+ type: "divider";
429
+ /** The rule as written when not `---` (`***`, `___`, `-----`). */
430
+ marker?: string;
431
+ }
432
+ export interface TableNode extends BlockSpacing {
433
+ type: "table";
434
+ header: Inline[][];
435
+ rows: Inline[][][];
436
+ /** GitBook table view, e.g. "cards" for <table data-view="cards"> */
437
+ view?: string;
438
+ /** Written as an HTML `<table>` (without a view). */
439
+ html?: true;
440
+ /** Column alignment from the delimiter row (`:---`, `:---:`, `---:`); null = default. */
441
+ align?: Array<"left" | "center" | "right" | null>;
442
+ /** The delimiter row as written (`|:--|--:|`), reused while it still says the same `align`. */
443
+ delimiterRow?: string;
444
+ /** An HTML table as written, reused while it still parses to the same cells. */
445
+ raw?: string;
446
+ /** GFM rows as written (header first), each reused while it still parses to the same cells. */
447
+ rawRows?: string[];
448
+ }
449
+ export interface UpdateNode extends ContainerSpacing, TagLines {
450
+ type: "update";
451
+ date: string;
452
+ children: Block[];
453
+ }
454
+ export interface UpdatesNode extends ContainerSpacing, TagLines {
455
+ type: "updates";
456
+ format: string | null;
457
+ updates: UpdateNode[];
458
+ }
459
+ export interface OpenApiOperationNode extends BlockSpacing, RawSource {
460
+ type: "openapi-operation";
461
+ spec: string;
462
+ path: string;
463
+ method: string;
464
+ specUrl: string;
465
+ label: string;
466
+ }
467
+ /**
468
+ * A reference-style link definition, `[label]: url "title"`, where the source put it. Links written
469
+ * `[text][label]`, `[text][]` or `[label]` resolve through it.
470
+ */
471
+ export interface DefinitionNode extends BlockSpacing {
472
+ type: "definition";
473
+ /** The label as written (matched case-insensitively). */
474
+ label: string;
475
+ url: string;
476
+ title?: string;
477
+ /** The line as written, reused while it still says the same label / url / title. */
478
+ raw?: string;
479
+ }
480
+ /**
481
+ * A line docstream keeps verbatim but doesn't model — an unknown `{% tag %}` (GitBook tags from other
482
+ * integrations). Renders nothing; serialized as written.
483
+ */
484
+ export interface RawNode extends BlockSpacing {
485
+ type: "raw";
486
+ markdown: string;
487
+ }
488
+ export interface MathNode extends BlockSpacing, RawSource {
489
+ type: "math";
490
+ formula: string;
491
+ }
492
+ export type Block = ParagraphNode | HeadingNode | CodeBlockNode | HintNode | TabsNode | CommandNode | ExpandableNode | StepperNode | EmbedNode | ContentRefNode | SourceRefNode | DemoNode | ColumnsNode | FigureNode | ListNode | BlockquoteNode | DividerNode | TableNode | MathNode | UpdatesNode | OpenApiOperationNode | DefinitionNode | RawNode;
493
+ export interface DocumentNode {
494
+ type: "doc";
495
+ children: Block[];
496
+ /** Footnote citation definitions, in definition order. */
497
+ citations?: CitationDef[];
498
+ /** Blank lines before the trailing footnote definitions (default 1). */
499
+ citationsGap?: number;
500
+ /** Line ending of the source when it used `\r\n` throughout. */
501
+ lineEnding?: "\r\n";
502
+ /** What the source ended with after its last line, when more than a single newline (`"\n\n"`). */
503
+ end?: string;
504
+ }
505
+ export declare const text: (t: string, marks?: Partial<Omit<TextNode, "type" | "text">>) => TextNode;
506
+ //# sourceMappingURL=ast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/gitbook/ast.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEjE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB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AQ,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM,KAAG,QAIrF,CAAA"}
@@ -0,0 +1,8 @@
1
+ // AST for GitBook-flavored markdown. This is the single source of truth that
2
+ // the parser, serializer, TipTap converters, and docs renderer all share.
3
+ export const text = (t, marks = {}) => ({
4
+ type: "text",
5
+ text: t,
6
+ ...marks,
7
+ });
8
+ //# sourceMappingURL=ast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/gitbook/ast.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,0EAA0E;AAikB1E,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,QAAkD,EAAE,EAAY,EAAE,CAAC,CAAC;IAClG,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,CAAC;IACP,GAAG,KAAK;CACT,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /** Escape one attribute value for a double-quoted `name="…"` pair. */
2
+ export declare function escapeAttr(value: string): string;
3
+ /** Undo `escapeAttr`. */
4
+ export declare function unescapeAttr(raw: string): string;
5
+ /** ` name="value"` with the value escaped (leading space included). */
6
+ export declare function attr(name: string, value: string | number | boolean): string;
7
+ /** Every `name="value"` pair in `raw` (escapes honoured, values unescaped). */
8
+ export declare function parseAttrs(raw: string | undefined): Record<string, string>;
9
+ /**
10
+ * The attribute part of a `{% name … %}` tag, as a regex source: anything up to the
11
+ * closing `%}` (a lone `%` is fine; `%}` inside a value is always escaped as `%\}`).
12
+ */
13
+ export declare const TAG_ATTRS: string;
14
+ //# sourceMappingURL=attrs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.d.ts","sourceRoot":"","sources":["../../src/gitbook/attrs.ts"],"names":[],"mappings":"AASA,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,yBAAyB;AACzB,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,uEAAuE;AACvE,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAE3E;AAED,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO1E;AAED;;;GAGG;AACH,eAAO,MAAM,SAAS,QAAmC,CAAA"}
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Tag and fence attribute values (`{% demo title="…" %}`, ```` ```ts title="…" ````).
3
+ *
4
+ * Values are double-quoted. On serialize a backslash becomes `\\`, a double quote `\"`,
5
+ * and the tag terminator `%}` becomes `%\}` — so a value can never end its tag early or
6
+ * truncate at a quote. On parse `\\`, `\"` and `\}` are unescaped; any other backslash is
7
+ * kept literally (so `C:\temp` written by hand still reads as written).
8
+ */
9
+ /** Escape one attribute value for a double-quoted `name="…"` pair. */
10
+ export function escapeAttr(value) {
11
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/%\}/g, "%\\}");
12
+ }
13
+ /** Undo `escapeAttr`. */
14
+ export function unescapeAttr(raw) {
15
+ return raw.replace(/\\(["\\}])/g, "$1");
16
+ }
17
+ /** ` name="value"` with the value escaped (leading space included). */
18
+ export function attr(name, value) {
19
+ return ` ${name}="${escapeAttr(String(value))}"`;
20
+ }
21
+ /** Every `name="value"` pair in `raw` (escapes honoured, values unescaped). */
22
+ export function parseAttrs(raw) {
23
+ const attrs = {};
24
+ if (!raw)
25
+ return attrs;
26
+ for (const m of raw.matchAll(/([\w-]+)="((?:[^"\\]|\\.)*)"/g)) {
27
+ attrs[m[1]] = unescapeAttr(m[2]);
28
+ }
29
+ return attrs;
30
+ }
31
+ /**
32
+ * The attribute part of a `{% name … %}` tag, as a regex source: anything up to the
33
+ * closing `%}` (a lone `%` is fine; `%}` inside a value is always escaped as `%\}`).
34
+ */
35
+ export const TAG_ATTRS = String.raw `(?:[^%\n]|%(?!\}))*?`;
36
+ //# sourceMappingURL=attrs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrs.js","sourceRoot":"","sources":["../../src/gitbook/attrs.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,sEAAsE;AACtE,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAClF,CAAC;AAED,yBAAyB;AACzB,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;AACzC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,IAAI,CAAC,IAAY,EAAE,KAAgC;IACjE,OAAO,IAAI,IAAI,KAAK,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAA;AAClD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,UAAU,CAAC,GAAuB;IAChD,MAAM,KAAK,GAA2B,EAAE,CAAA;IACxC,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAA;IACtB,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QAC9D,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClC,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA,sBAAsB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { Block, DocumentNode } from "./ast.js";
2
+ /**
3
+ * docstream-only presentation blocks as plain Markdown, for LLM prompts and tools that don't
4
+ * know docstream (`resolveDemosToMarkdown(…, { format: "plain" })`):
5
+ *
6
+ * - `{% command %}` → a ```` ```sh ```` fence with the npm command;
7
+ * - titled `{% tabs title="Installation" %}` → a `## Installation` heading, then each tab as a
8
+ * bold label followed by its blocks.
9
+ *
10
+ * Everything else is kept (GitBook tags included — they're GitBook, not docstream).
11
+ */
12
+ export declare function flattenForPlainMarkdown(doc: DocumentNode): DocumentNode;
13
+ export declare function flattenBlocks(blocks: Block[]): Block[];
14
+ //# sourceMappingURL=flatten.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../src/gitbook/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAGhD;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAEvE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CA6BtD"}
@@ -0,0 +1,45 @@
1
+ import { text } from "./ast.js";
2
+ /**
3
+ * docstream-only presentation blocks as plain Markdown, for LLM prompts and tools that don't
4
+ * know docstream (`resolveDemosToMarkdown(…, { format: "plain" })`):
5
+ *
6
+ * - `{% command %}` → a ```` ```sh ```` fence with the npm command;
7
+ * - titled `{% tabs title="Installation" %}` → a `## Installation` heading, then each tab as a
8
+ * bold label followed by its blocks.
9
+ *
10
+ * Everything else is kept (GitBook tags included — they're GitBook, not docstream).
11
+ */
12
+ export function flattenForPlainMarkdown(doc) {
13
+ return { ...doc, children: flattenBlocks(doc.children) };
14
+ }
15
+ export function flattenBlocks(blocks) {
16
+ return blocks.flatMap((b) => {
17
+ switch (b.type) {
18
+ case "command":
19
+ return [{ type: "code", language: "sh", title: null, lineNumbers: false, code: b.command }];
20
+ case "tabs":
21
+ if (b.title) {
22
+ return [
23
+ { type: "heading", level: b.level ?? 2, children: [text(b.title)] },
24
+ ...b.tabs.flatMap((t) => [{ type: "paragraph", children: [text(t.title, { bold: true })] }, ...flattenBlocks(t.children)]),
25
+ ];
26
+ }
27
+ return [{ ...b, tabs: b.tabs.map((t) => ({ ...t, children: flattenBlocks(t.children) })) }];
28
+ case "hint":
29
+ case "expandable":
30
+ case "blockquote":
31
+ return [{ ...b, children: flattenBlocks(b.children) }];
32
+ case "stepper":
33
+ return [{ ...b, steps: b.steps.map((s) => ({ ...s, children: flattenBlocks(s.children) })) }];
34
+ case "columns":
35
+ return [{ ...b, columns: b.columns.map((c) => ({ ...c, children: flattenBlocks(c.children) })) }];
36
+ case "list":
37
+ return [{ ...b, items: b.items.map((item) => ({ ...item, children: flattenBlocks(item.children) })) }];
38
+ case "updates":
39
+ return [{ ...b, updates: b.updates.map((u) => ({ ...u, children: flattenBlocks(u.children) })) }];
40
+ default:
41
+ return [b];
42
+ }
43
+ });
44
+ }
45
+ //# sourceMappingURL=flatten.js.map