@diegopluna/narvi 0.1.0 → 0.2.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 (259) hide show
  1. package/README.md +102 -41
  2. package/dist/base.css +2 -2
  3. package/dist/color.d.ts +1 -1
  4. package/dist/color.js +1 -1
  5. package/dist/components/activity/ActivityContent.svelte +3 -15
  6. package/dist/components/activity/ActivityStep.svelte +12 -12
  7. package/dist/components/activity/ActivityThought.svelte +4 -4
  8. package/dist/components/activity/ActivityTrigger.svelte +3 -3
  9. package/dist/components/app-shell/AppShellBar.svelte +89 -0
  10. package/dist/components/app-shell/AppShellBar.svelte.d.ts +20 -0
  11. package/dist/components/app-shell/AppShellHeader.svelte +17 -16
  12. package/dist/components/app-shell/AppShellHeader.svelte.d.ts +2 -2
  13. package/dist/components/app-shell/AppShellMain.svelte +4 -20
  14. package/dist/components/app-shell/AppShellPanel.svelte +21 -19
  15. package/dist/components/app-shell/AppShellPanes.svelte +58 -0
  16. package/dist/components/app-shell/AppShellPanes.svelte.d.ts +11 -0
  17. package/dist/components/app-shell/AppShellRail.svelte +85 -0
  18. package/dist/components/app-shell/AppShellRail.svelte.d.ts +11 -0
  19. package/dist/components/app-shell/AppShellRoot.svelte +50 -24
  20. package/dist/components/app-shell/AppShellRoot.svelte.d.ts +8 -6
  21. package/dist/components/app-shell/AppShellSheet.svelte +95 -0
  22. package/dist/components/app-shell/AppShellSheet.svelte.d.ts +17 -0
  23. package/dist/components/app-shell/AppShellSidebar.svelte +37 -61
  24. package/dist/components/app-shell/AppShellSidebar.svelte.d.ts +1 -5
  25. package/dist/components/app-shell/AppShellToggle.svelte +62 -23
  26. package/dist/components/app-shell/AppShellToggle.svelte.d.ts +2 -0
  27. package/dist/components/app-shell/context.d.ts +6 -0
  28. package/dist/components/app-shell/index.d.ts +9 -1
  29. package/dist/components/app-shell/index.js +5 -1
  30. package/dist/components/approval/Approval.svelte +91 -19
  31. package/dist/components/approval/Approval.svelte.d.ts +7 -0
  32. package/dist/components/avatar/AvatarFallback.svelte +1 -2
  33. package/dist/components/avatar/AvatarRoot.svelte +2 -2
  34. package/dist/components/badge/Badge.svelte +5 -5
  35. package/dist/components/button/Button.svelte +219 -40
  36. package/dist/components/button/Button.svelte.d.ts +38 -2
  37. package/dist/components/card/Card.svelte +15 -26
  38. package/dist/components/change-stats/ChangeStats.svelte +1 -2
  39. package/dist/components/changes-summary/ChangesSummary.svelte +14 -15
  40. package/dist/components/checkbox/Checkbox.svelte +18 -15
  41. package/dist/components/checkbox/Checkbox.svelte.d.ts +5 -0
  42. package/dist/components/code/Code.svelte +1 -2
  43. package/dist/components/collapsible/CollapsibleTrigger.svelte +2 -2
  44. package/dist/components/command/CommandItem.svelte +1 -1
  45. package/dist/components/command/styles.d.ts +3 -2
  46. package/dist/components/command/styles.js +13 -10
  47. package/dist/components/composer/ComposerAttachButton.svelte +1 -1
  48. package/dist/components/composer/ComposerAttachment.svelte +9 -12
  49. package/dist/components/composer/ComposerModelPicker.svelte +18 -20
  50. package/dist/components/composer/ComposerRoot.svelte +8 -7
  51. package/dist/components/composer/ComposerSubmit.svelte +8 -15
  52. package/dist/components/composer/ComposerTextarea.svelte +1 -1
  53. package/dist/components/composer/ComposerToggle.svelte +9 -11
  54. package/dist/components/composer/ComposerTray.svelte +78 -0
  55. package/dist/components/composer/ComposerTray.svelte.d.ts +15 -0
  56. package/dist/components/composer/index.d.ts +3 -1
  57. package/dist/components/composer/index.js +3 -2
  58. package/dist/components/conversation/ConversationContent.svelte +3 -2
  59. package/dist/components/conversation/ConversationEmpty.svelte +1 -1
  60. package/dist/components/conversation/ConversationScrollButton.svelte +3 -3
  61. package/dist/components/dialog/ConfirmDialog.svelte +1 -1
  62. package/dist/components/dialog/styles.d.ts +2 -3
  63. package/dist/components/dialog/styles.js +5 -6
  64. package/dist/components/divider/Divider.svelte +3 -3
  65. package/dist/components/empty-state/EmptyState.svelte +4 -5
  66. package/dist/components/field/Field.svelte +4 -4
  67. package/dist/components/frame/Frame.svelte +6 -7
  68. package/dist/components/frame/Frame.svelte.d.ts +1 -1
  69. package/dist/components/heading/Heading.svelte +2 -2
  70. package/dist/components/kbd/Kbd.svelte +12 -7
  71. package/dist/components/link/Link.svelte +7 -3
  72. package/dist/components/link/Link.svelte.d.ts +4 -1
  73. package/dist/components/markdown/Markdown.svelte +714 -0
  74. package/dist/components/markdown/Markdown.svelte.d.ts +80 -0
  75. package/dist/components/markdown/MarkdownBlock.svelte +231 -0
  76. package/dist/components/markdown/MarkdownBlock.svelte.d.ts +11 -0
  77. package/dist/components/markdown/MarkdownBlocks.svelte +115 -0
  78. package/dist/components/markdown/MarkdownBlocks.svelte.d.ts +15 -0
  79. package/dist/components/markdown/MarkdownCode.svelte +583 -0
  80. package/dist/components/markdown/MarkdownCode.svelte.d.ts +23 -0
  81. package/dist/components/markdown/MarkdownDiagram.svelte +310 -0
  82. package/dist/components/markdown/MarkdownDiagram.svelte.d.ts +6 -0
  83. package/dist/components/markdown/MarkdownFile.svelte +134 -0
  84. package/dist/components/markdown/MarkdownFile.svelte.d.ts +19 -0
  85. package/dist/components/markdown/MarkdownFootnotes.svelte +61 -0
  86. package/dist/components/markdown/MarkdownFootnotes.svelte.d.ts +8 -0
  87. package/dist/components/markdown/MarkdownFresh.svelte +69 -0
  88. package/dist/components/markdown/MarkdownFresh.svelte.d.ts +6 -0
  89. package/dist/components/markdown/MarkdownHtml.svelte +72 -0
  90. package/dist/components/markdown/MarkdownHtml.svelte.d.ts +7 -0
  91. package/dist/components/markdown/MarkdownImage.svelte +150 -0
  92. package/dist/components/markdown/MarkdownImage.svelte.d.ts +8 -0
  93. package/dist/components/markdown/MarkdownInlines.svelte +225 -0
  94. package/dist/components/markdown/MarkdownInlines.svelte.d.ts +7 -0
  95. package/dist/components/markdown/MarkdownLink.svelte +120 -0
  96. package/dist/components/markdown/MarkdownLink.svelte.d.ts +25 -0
  97. package/dist/components/markdown/MarkdownMath.svelte +138 -0
  98. package/dist/components/markdown/MarkdownMath.svelte.d.ts +7 -0
  99. package/dist/components/markdown/MarkdownTable.svelte +265 -0
  100. package/dist/components/markdown/MarkdownTable.svelte.d.ts +17 -0
  101. package/dist/components/markdown/caret.d.ts +14 -0
  102. package/dist/components/markdown/caret.js +67 -0
  103. package/dist/components/markdown/context.d.ts +93 -0
  104. package/dist/components/markdown/context.js +128 -0
  105. package/dist/components/markdown/copy.d.ts +13 -0
  106. package/dist/components/markdown/copy.js +74 -0
  107. package/dist/components/markdown/hidden.d.ts +12 -0
  108. package/dist/components/markdown/hidden.js +31 -0
  109. package/dist/components/markdown/kept.d.ts +32 -0
  110. package/dist/components/markdown/kept.js +71 -0
  111. package/dist/components/markdown/labels.d.ts +46 -0
  112. package/dist/components/markdown/labels.js +35 -0
  113. package/dist/components/markdown/save.d.ts +11 -0
  114. package/dist/components/markdown/save.js +58 -0
  115. package/dist/components/markdown/scrollable.d.ts +24 -0
  116. package/dist/components/markdown/scrollable.js +152 -0
  117. package/dist/components/markdown/static.d.ts +37 -0
  118. package/dist/components/markdown/static.js +233 -0
  119. package/dist/components/markdown/styles.d.ts +328 -0
  120. package/dist/components/markdown/styles.js +302 -0
  121. package/dist/components/menu/MenuRadioItem.svelte +3 -3
  122. package/dist/components/menu/index.d.ts +23 -0
  123. package/dist/components/menu/index.js +3 -1
  124. package/dist/components/message/MessageAction.svelte +22 -2
  125. package/dist/components/message/MessageAction.svelte.d.ts +9 -0
  126. package/dist/components/message/MessageContent.svelte +2 -3
  127. package/dist/components/message/MessageCopy.svelte +62 -3
  128. package/dist/components/message/MessageCopy.svelte.d.ts +17 -1
  129. package/dist/components/message/MessageHeader.svelte +3 -3
  130. package/dist/components/message/MessagePending.svelte +1 -1
  131. package/dist/components/message/MessageTime.svelte +1 -1
  132. package/dist/components/notice/Notice.svelte +14 -10
  133. package/dist/components/plan/Plan.svelte +22 -17
  134. package/dist/components/progress/Progress.svelte +31 -33
  135. package/dist/components/questionnaire/Questionnaire.svelte +19 -22
  136. package/dist/components/queued-message/QueuedMessage.svelte +14 -7
  137. package/dist/components/rail/RailItem.svelte +37 -34
  138. package/dist/components/rail/RailItem.svelte.d.ts +3 -1
  139. package/dist/components/rail/RailRoot.svelte +18 -4
  140. package/dist/components/rail/RailRoot.svelte.d.ts +1 -1
  141. package/dist/components/rail/RailSeparator.svelte +17 -0
  142. package/dist/components/rail/RailSeparator.svelte.d.ts +18 -0
  143. package/dist/components/rail/index.d.ts +2 -1
  144. package/dist/components/rail/index.js +2 -1
  145. package/dist/components/reasoning/ReasoningContent.svelte +4 -8
  146. package/dist/components/reasoning/ReasoningTrigger.svelte +2 -2
  147. package/dist/components/resize-handle/ResizeHandle.svelte +2 -3
  148. package/dist/components/segmented/SegmentedControl.svelte +7 -8
  149. package/dist/components/select/Select.svelte +1 -1
  150. package/dist/components/separator/Separator.svelte +1 -1
  151. package/dist/components/settings-row/SettingsRow.svelte +5 -5
  152. package/dist/components/shimmer/Shimmer.svelte +34 -21
  153. package/dist/components/sidebar/SidebarContent.svelte +1 -1
  154. package/dist/components/sidebar/SidebarFolder.svelte +142 -0
  155. package/dist/components/sidebar/SidebarFolder.svelte.d.ts +19 -0
  156. package/dist/components/sidebar/SidebarFooter.svelte +1 -1
  157. package/dist/components/sidebar/SidebarGroup.svelte +36 -32
  158. package/dist/components/sidebar/SidebarGroup.svelte.d.ts +3 -3
  159. package/dist/components/sidebar/SidebarHeader.svelte +12 -6
  160. package/dist/components/sidebar/SidebarHeader.svelte.d.ts +4 -1
  161. package/dist/components/sidebar/SidebarItem.svelte +26 -32
  162. package/dist/components/sidebar/SidebarRoot.svelte +62 -0
  163. package/dist/components/sidebar/SidebarRoot.svelte.d.ts +14 -0
  164. package/dist/components/sidebar/index.d.ts +5 -1
  165. package/dist/components/sidebar/index.js +3 -1
  166. package/dist/components/skeleton/Skeleton.svelte +26 -15
  167. package/dist/components/slider/Slider.svelte +11 -10
  168. package/dist/components/spinner/Spinner.svelte +4 -11
  169. package/dist/components/status-indicator/StatusIndicator.svelte +1 -1
  170. package/dist/components/suggestions/SuggestionsItem.svelte +5 -5
  171. package/dist/components/switch/Switch.svelte +9 -14
  172. package/dist/components/tab-strip/TabStrip.svelte +340 -0
  173. package/dist/components/tab-strip/TabStrip.svelte.d.ts +31 -0
  174. package/dist/components/tabs/Tabs.svelte +13 -9
  175. package/dist/components/tabs/Tabs.svelte.d.ts +4 -0
  176. package/dist/components/text/Text.svelte +31 -23
  177. package/dist/components/text/Text.svelte.d.ts +8 -4
  178. package/dist/components/toast/Toaster.svelte +5 -5
  179. package/dist/components/tool/ToolContent.svelte +3 -8
  180. package/dist/components/tool/ToolSection.svelte +4 -5
  181. package/dist/components/tool/ToolTrigger.svelte +10 -9
  182. package/dist/components/tooltip/TooltipContent.svelte +3 -3
  183. package/dist/components/work-fold/WorkFold.svelte +5 -9
  184. package/dist/index.d.ts +16 -8
  185. package/dist/index.js +17 -10
  186. package/dist/internal/Code.svelte +3 -4
  187. package/dist/internal/Glyph.svelte +16 -0
  188. package/dist/internal/Glyph.svelte.d.ts +6 -0
  189. package/dist/internal/Tile.svelte +17 -37
  190. package/dist/internal/control.d.ts +4 -4
  191. package/dist/internal/control.js +20 -17
  192. package/dist/internal/layer.d.ts +3 -5
  193. package/dist/internal/layer.js +10 -12
  194. package/dist/internal/markers.stylex.d.ts +8 -0
  195. package/dist/internal/markers.stylex.js +4 -0
  196. package/dist/internal/plugin-order.d.ts +8 -0
  197. package/dist/internal/plugin-order.js +16 -0
  198. package/dist/internal/roving.js +5 -2
  199. package/dist/internal/shared.d.ts +8 -1
  200. package/dist/internal/shared.js +21 -5
  201. package/dist/internal/sx.d.ts +1 -1
  202. package/dist/internal/toggle.d.ts +1 -2
  203. package/dist/internal/toggle.js +8 -12
  204. package/dist/internal/visible.d.ts +32 -0
  205. package/dist/internal/visible.js +44 -0
  206. package/dist/markdown/ast.d.ts +209 -0
  207. package/dist/markdown/ast.js +10 -0
  208. package/dist/markdown/blocks.d.ts +177 -0
  209. package/dist/markdown/blocks.js +1489 -0
  210. package/dist/markdown/code-info.d.ts +10 -0
  211. package/dist/markdown/code-info.js +16 -0
  212. package/dist/markdown/common.d.ts +25 -0
  213. package/dist/markdown/common.js +107 -0
  214. package/dist/markdown/diagrams.d.ts +2 -0
  215. package/dist/markdown/diagrams.js +18 -0
  216. package/dist/markdown/file-paths.d.ts +29 -0
  217. package/dist/markdown/file-paths.js +80 -0
  218. package/dist/markdown/files.d.ts +16 -0
  219. package/dist/markdown/files.js +133 -0
  220. package/dist/markdown/highlight.d.ts +30 -0
  221. package/dist/markdown/highlight.js +127 -0
  222. package/dist/markdown/html.d.ts +23 -0
  223. package/dist/markdown/html.js +289 -0
  224. package/dist/markdown/images.d.ts +15 -0
  225. package/dist/markdown/images.js +45 -0
  226. package/dist/markdown/index.d.ts +12 -0
  227. package/dist/markdown/index.js +5 -0
  228. package/dist/markdown/inlines.d.ts +48 -0
  229. package/dist/markdown/inlines.js +1714 -0
  230. package/dist/markdown/math.d.ts +2 -0
  231. package/dist/markdown/math.js +22 -0
  232. package/dist/markdown/parse.d.ts +81 -0
  233. package/dist/markdown/parse.js +204 -0
  234. package/dist/markdown/plugin.d.ts +178 -0
  235. package/dist/markdown/plugin.js +160 -0
  236. package/dist/markdown/sanitize.d.ts +78 -0
  237. package/dist/markdown/sanitize.js +522 -0
  238. package/dist/markdown/share.d.ts +12 -0
  239. package/dist/markdown/share.js +59 -0
  240. package/dist/markdown/table.d.ts +13 -0
  241. package/dist/markdown/table.js +60 -0
  242. package/dist/preset.d.ts +40 -16
  243. package/dist/preset.js +169 -51
  244. package/dist/tokens.stylex.d.ts +55 -37
  245. package/dist/tokens.stylex.js +107 -62
  246. package/dist/typography.d.ts +48 -0
  247. package/dist/typography.js +55 -0
  248. package/dist/vite.d.ts +7 -1
  249. package/dist/vite.js +27 -2
  250. package/package.json +53 -6
  251. package/skills/building-ui/SKILL.md +242 -0
  252. package/skills/building-ui/references/components.md +207 -0
  253. package/skills/markdown/SKILL.md +452 -0
  254. package/skills/markdown/references/plugins.md +103 -0
  255. package/skills/setup/SKILL.md +191 -0
  256. package/skills/styling/SKILL.md +269 -0
  257. package/skills/theming/SKILL.md +184 -0
  258. package/dist/internal/loop.d.ts +0 -35
  259. package/dist/internal/loop.js +0 -72
@@ -0,0 +1,209 @@
1
+ /**
2
+ * The Markdown document tree.
3
+ *
4
+ * Every block has an `id` that is stable for as long as the block exists: while a reply
5
+ * streams, a block that is already finished keeps both its id and its object, so a renderer
6
+ * keyed by id never touches it again. Inline nodes have no ids; they belong to their block.
7
+ *
8
+ * A block's `from` and `to` are offsets into the source text, `to` exclusive.
9
+ */
10
+ export type Point = {
11
+ from: number;
12
+ to: number;
13
+ };
14
+ export type Document = Point & {
15
+ type: 'document';
16
+ id: number;
17
+ children: Block[];
18
+ /** Footnote definitions, in the order they are first referenced. */
19
+ footnotes: FootnoteDefinition[];
20
+ /**
21
+ * The YAML front matter a file starts with, between its `---` lines, as written. Read only
22
+ * with the `frontmatter` option, and then left out of `children`.
23
+ */
24
+ frontmatter?: string;
25
+ };
26
+ export type Paragraph = Point & {
27
+ type: 'paragraph';
28
+ id: number;
29
+ children: Inline[];
30
+ };
31
+ export type Heading = Point & {
32
+ type: 'heading';
33
+ id: number;
34
+ depth: 1 | 2 | 3 | 4 | 5 | 6;
35
+ children: Inline[];
36
+ };
37
+ export type ThematicBreak = Point & {
38
+ type: 'thematicBreak';
39
+ id: number;
40
+ };
41
+ /** The kinds of GitHub alert: a block quote that opens with `[!NOTE]` and the like. */
42
+ export type AlertKind = 'note' | 'tip' | 'important' | 'warning' | 'caution';
43
+ export type Blockquote = Point & {
44
+ type: 'blockquote';
45
+ id: number;
46
+ /** Set when the quote is a GitHub alert; its `[!NOTE]` line is then left out of the children. */
47
+ alert?: AlertKind;
48
+ children: Block[];
49
+ };
50
+ export type List = Point & {
51
+ type: 'list';
52
+ id: number;
53
+ ordered: boolean;
54
+ /** The first number of an ordered list. */
55
+ start: number | null;
56
+ /** A tight list has no blank lines between its items; its paragraphs are not wrapped. */
57
+ tight: boolean;
58
+ children: ListItem[];
59
+ };
60
+ export type ListItem = Point & {
61
+ type: 'listItem';
62
+ id: number;
63
+ /** A GFM task item: `[ ]` is false, `[x]` is true. Null for an ordinary item. */
64
+ checked: boolean | null;
65
+ /** Where the `[` of a task item's `[ ]` is in the source, for ticking it there. Null otherwise. */
66
+ checkedAt: number | null;
67
+ children: Block[];
68
+ };
69
+ export type CodeBlock = Point & {
70
+ type: 'code';
71
+ id: number;
72
+ /** The first word of the info string, unescaped. */
73
+ lang: string | null;
74
+ /** The rest of the info string. */
75
+ meta: string | null;
76
+ value: string;
77
+ /** True for a fenced block that has not seen its closing fence yet. */
78
+ open: boolean;
79
+ };
80
+ export type HtmlBlock = Point & {
81
+ type: 'html';
82
+ id: number;
83
+ value: string;
84
+ };
85
+ /** A formula set on lines of its own, between `$$` and `$$` or `\\[` and `\\]`. */
86
+ export type MathBlock = Point & {
87
+ type: 'math';
88
+ id: number;
89
+ /** The TeX source, without its delimiters. */
90
+ value: string;
91
+ /** True until its closing delimiter arrives. */
92
+ open: boolean;
93
+ };
94
+ export type Table = Point & {
95
+ type: 'table';
96
+ id: number;
97
+ align: Array<'left' | 'right' | 'center' | null>;
98
+ /** True while more rows may still arrive. */
99
+ open: boolean;
100
+ /** The first row is the header. */
101
+ children: TableRow[];
102
+ };
103
+ export type TableRow = Point & {
104
+ type: 'tableRow';
105
+ id: number;
106
+ children: TableCell[];
107
+ };
108
+ export type TableCell = Point & {
109
+ type: 'tableCell';
110
+ id: number;
111
+ /** The cell as written, trimmed, with `\\|` read as a pipe. */
112
+ source: string;
113
+ children: Inline[];
114
+ };
115
+ export type FootnoteDefinition = Point & {
116
+ type: 'footnoteDefinition';
117
+ id: number;
118
+ /** The label as written. */
119
+ label: string;
120
+ children: Block[];
121
+ };
122
+ export type Block = Paragraph | Heading | ThematicBreak | Blockquote | List | ListItem | CodeBlock | HtmlBlock | MathBlock | Table | FootnoteDefinition;
123
+ export type Text = {
124
+ type: 'text';
125
+ value: string;
126
+ };
127
+ export type Emphasis = {
128
+ type: 'emphasis';
129
+ children: Inline[];
130
+ };
131
+ export type Strong = {
132
+ type: 'strong';
133
+ children: Inline[];
134
+ };
135
+ export type Delete = {
136
+ type: 'delete';
137
+ children: Inline[];
138
+ };
139
+ export type InlineCode = {
140
+ type: 'inlineCode';
141
+ value: string;
142
+ };
143
+ export type Break = {
144
+ type: 'break';
145
+ };
146
+ export type SoftBreak = {
147
+ type: 'softBreak';
148
+ };
149
+ export type InlineHtml = {
150
+ type: 'inlineHtml';
151
+ value: string;
152
+ };
153
+ /** A formula in running text: `$x$` or `\\(x\\)`, and `$$x$$` or `\\[x\\]` with `display`. */
154
+ export type InlineMath = {
155
+ type: 'inlineMath';
156
+ value: string;
157
+ display: boolean;
158
+ };
159
+ export type Link = {
160
+ type: 'link';
161
+ url: string;
162
+ title: string | null;
163
+ children: Inline[];
164
+ /** How it was written: `[a](b)`, `[a][b]`, `<https://…>` or a bare `www.…`. */
165
+ kind: 'inline' | 'reference' | 'autolink' | 'literal';
166
+ /**
167
+ * A link whose address is still being written, in a tidied preview: `[the docs](https://na`.
168
+ * It has its words and no address yet. Drawn as a link that goes nowhere.
169
+ */
170
+ pending?: boolean;
171
+ };
172
+ export type Image = {
173
+ type: 'image';
174
+ url: string;
175
+ title: string | null;
176
+ /** The alt text, as plain text. */
177
+ alt: string;
178
+ /** The size an HTML `<img>` asked for. A Markdown image has none. */
179
+ width?: string;
180
+ height?: string;
181
+ /**
182
+ * Whether it is a video: an HTML `<video>`, or an image a transform marked as one, such
183
+ * as a link to an `.mp4`. It is drawn with controls, and nothing of it loads until it is played.
184
+ */
185
+ video?: boolean;
186
+ children: Inline[];
187
+ };
188
+ /** A reference to a footnote. Its number comes from the document's `footnotes`, in order. */
189
+ export type FootnoteReference = {
190
+ type: 'footnoteReference';
191
+ label: string;
192
+ };
193
+ /**
194
+ * A node a plugin's transform puts in: a file chip, a mention. The plugin's component for
195
+ * `name` draws it; without one, its children show.
196
+ */
197
+ export type InlineCustom = {
198
+ type: 'custom';
199
+ name: string;
200
+ data: Readonly<Record<string, unknown>>;
201
+ children: Inline[];
202
+ };
203
+ export type Inline = Text | Emphasis | Strong | Delete | InlineCode | Break | SoftBreak | InlineHtml | InlineMath | Link | Image | FootnoteReference | InlineCustom;
204
+ export type Node = Document | Block | TableRow | TableCell | Inline;
205
+ /** A link reference definition: `[label]: url "title"`. */
206
+ export type Definition = {
207
+ url: string;
208
+ title: string | null;
209
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The Markdown document tree.
3
+ *
4
+ * Every block has an `id` that is stable for as long as the block exists: while a reply
5
+ * streams, a block that is already finished keeps both its id and its object, so a renderer
6
+ * keyed by id never touches it again. Inline nodes have no ids; they belong to their block.
7
+ *
8
+ * A block's `from` and `to` are offsets into the source text, `to` exclusive.
9
+ */
10
+ export {};
@@ -0,0 +1,177 @@
1
+ /**
2
+ * The block parser: lines in, a tree of blocks out.
3
+ *
4
+ * It follows the parsing strategy in the appendix of the CommonMark spec, and the structure
5
+ * of commonmark.js (BSD-2-Clause), with three changes for text that arrives as it is written:
6
+ *
7
+ * - **It keeps its state between chunks.** Each complete line is read once. A block that is
8
+ * closed is never touched again, and keeps its id and its converted node, so a renderer
9
+ * keyed by id leaves it alone.
10
+ * - **The unfinished end is a preview.** `snapshot()` copies only the blocks that are still
11
+ * open (the path from the document to the deepest open block), feeds the partial last line
12
+ * to the copy, closes the copy and converts it. The real state is not changed.
13
+ * - **Definitions are document-wide.** A link reference definition can arrive after the links
14
+ * that use it. Blocks remember which labels they looked up and missed, and only those are
15
+ * converted again when such a definition arrives.
16
+ */
17
+ import type { Block, Definition, Document, FootnoteDefinition, TableRow } from './ast.js';
18
+ type BlockType = 'document' | 'blockquote' | 'list' | 'item' | 'paragraph' | 'heading' | 'thematicBreak' | 'code' | 'html' | 'math' | 'table' | 'footnote';
19
+ type ListData = {
20
+ type: 'bullet' | 'ordered';
21
+ tight: boolean;
22
+ bulletChar: string;
23
+ start: number | null;
24
+ delimiter: string | null;
25
+ padding: number;
26
+ markerOffset: number;
27
+ };
28
+ type TableLine = {
29
+ text: string;
30
+ from: number;
31
+ to: number;
32
+ id: number;
33
+ cache?: TableRow;
34
+ };
35
+ /** A block while it is parsed. Converted to the immutable `ast.ts` nodes for the outside. */
36
+ declare class Node {
37
+ id: number;
38
+ type: BlockType;
39
+ parent: Node | null;
40
+ children: Node[];
41
+ open: boolean;
42
+ from: number;
43
+ to: number;
44
+ /** The lines it spans, from 0. */
45
+ startLine: number;
46
+ endLine: number;
47
+ /** Text gathered for a leaf: a paragraph, a heading or a code block. */
48
+ content: string;
49
+ /** The last line added to `content`, and where its text starts in the source. */
50
+ lastLine: string;
51
+ lastLineFrom: number;
52
+ /** A paragraph that so far has opened a `$$` or a `\\[` it has not closed. */
53
+ dollarsOpen: boolean;
54
+ bracketOpen: boolean;
55
+ /** A paragraph whose text is taken as written: no link definitions are read from it. */
56
+ plain: boolean;
57
+ level: number;
58
+ setext: boolean;
59
+ fenced: boolean;
60
+ fenceChar: string;
61
+ fenceLength: number;
62
+ fenceOffset: number;
63
+ info: string;
64
+ /** A fenced block closed by its fence, not by the end of its container. */
65
+ closedByFence: boolean;
66
+ htmlBlockType: number;
67
+ mathClose: string;
68
+ listData: ListData | null;
69
+ checked: boolean | null;
70
+ /** Where a task item's `[` is in the source. */
71
+ taskAt: number;
72
+ align: Array<'left' | 'right' | 'center' | null>;
73
+ rows: TableLine[];
74
+ /** Rows a preview added: the line still being written, which must not be kept. */
75
+ ephemeralRows: Set<TableLine> | null;
76
+ label: string;
77
+ /** Made while previewing the unfinished end: never cached. */
78
+ ephemeral: boolean;
79
+ /** The block the preview ends in, whose text may be unfinished. */
80
+ tail: boolean;
81
+ /** Still open when the preview was taken: more of it may arrive. */
82
+ live: boolean;
83
+ /** The lines of paragraphs that held only definitions and were taken out, for telling a loose list. */
84
+ ghosts: Array<[number, number]> | null;
85
+ /** The footnote definitions at or under this block, kept with its converted node. */
86
+ notes: FootnoteDefinition[] | null;
87
+ /** The converted node, once the block is closed. */
88
+ cache: Block | null;
89
+ /** Reference labels a converted leaf looked up and did not find. */
90
+ missed: Set<string> | null;
91
+ constructor(type: BlockType, id: number, from: number, line: number);
92
+ appendChild(child: Node): void;
93
+ get lastChild(): Node | null;
94
+ unlink(): void;
95
+ }
96
+ /** Splits a table row into cell texts, honouring `\|` escapes. */
97
+ export declare function splitTableRow(text: string): string[];
98
+ /** What the parser needs from the rest of the library to convert a block. */
99
+ export type BlockOptions = {
100
+ /** GFM extensions: tables, task lists, strikethrough, autolinks, footnotes. On by default. */
101
+ gfm?: boolean;
102
+ /**
103
+ * Formulas: `$x$` and `\\(x\\)` in running text, `$$` and `\\[` for display. Off by default,
104
+ * since it changes what a dollar sign and an escaped bracket mean.
105
+ */
106
+ math?: boolean;
107
+ /**
108
+ * Whether `~text~` strikes through, as `~~text~~` does. GitHub allows it, but in a reply
109
+ * a tilde far more often means "about", as in "~5 minutes", so it is off by default.
110
+ */
111
+ singleTilde?: boolean;
112
+ };
113
+ export declare class BlockParser {
114
+ doc: Node;
115
+ tip: Node;
116
+ oldtip: Node;
117
+ currentLine: string;
118
+ /** The current line's number, from 0. */
119
+ lineNumber: number;
120
+ /** Where each line starts and ends in the source, before its line ending. */
121
+ lineStarts: number[];
122
+ lineEnds: number[];
123
+ /** A fork's own last line, which the shared arrays above do not hold. */
124
+ forkLine: {
125
+ number: number;
126
+ start: number;
127
+ end: number;
128
+ } | null;
129
+ offset: number;
130
+ column: number;
131
+ nextNonspace: number;
132
+ nextNonspaceColumn: number;
133
+ indent: number;
134
+ indented: boolean;
135
+ blank: boolean;
136
+ partiallyConsumedTab: boolean;
137
+ /** Set by a block start to make the rest of the line plain text. */
138
+ plainRest: boolean;
139
+ /** The paragraph this line starts is a task's text. */
140
+ plainParagraph: boolean;
141
+ allClosed: boolean;
142
+ lastMatchedContainer: Node;
143
+ lastLineLength: number;
144
+ definitions: Map<string, Definition>;
145
+ footnoteLabels: Set<string>;
146
+ /** Leaves that missed a label, by label, so a later definition can convert them again. */
147
+ missedBy: Map<string, Set<Node>>;
148
+ ids: number;
149
+ ephemeral: boolean;
150
+ options: Required<BlockOptions>;
151
+ constructor(options?: BlockOptions);
152
+ nextId(): number;
153
+ lineStartOf(line: number): number;
154
+ lineEndOf(line: number): number;
155
+ define(label: string, definition: Definition): void;
156
+ defineFootnote(label: string): void;
157
+ /** Converts again the blocks that looked for this label and did not find it. */
158
+ private invalidate;
159
+ addLine(): void;
160
+ addChild(type: BlockType, offset: number): Node;
161
+ closeUnmatchedBlocks(): void;
162
+ findNextNonspace(): void;
163
+ advanceNextNonspace(): void;
164
+ advanceOffset(count: number, columns?: boolean): void;
165
+ /** Reads one line, without its line ending, that starts at `start` in the source. */
166
+ incorporateLine(line: string, start: number): void;
167
+ /** Closes a block whose last line is `line`. */
168
+ finalize(block: Node, line: number): void;
169
+ /** Marks the deepest open block as the one the preview ends in. */
170
+ markTail(): void;
171
+ /** Closes every open block, as at the end of the document. */
172
+ closeAll(): void;
173
+ /** A copy that shares every closed block, for previewing the unfinished end. */
174
+ fork(): BlockParser;
175
+ toDocument(base?: BlockParser, tidy?: boolean): Document;
176
+ }
177
+ export {};