@texuli/blocks 0.0.0-stage → 0.1.0-next.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 (257) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -2
  3. package/dist/code/CodeBlockView.svelte +135 -0
  4. package/dist/code/CodeBlockView.svelte.d.ts +5 -0
  5. package/dist/code/check.d.ts +15 -0
  6. package/dist/code/check.js +14 -0
  7. package/dist/code/code.css +201 -0
  8. package/dist/code/code.css.d.ts +1 -0
  9. package/dist/code/engine-entry.d.ts +10 -0
  10. package/dist/code/engine-entry.js +10 -0
  11. package/dist/code/engine.d.ts +18 -0
  12. package/dist/code/engine.js +18 -0
  13. package/dist/code/family-engine.d.ts +23 -0
  14. package/dist/code/family-engine.js +4 -0
  15. package/dist/code/family.d.ts +7 -0
  16. package/dist/code/family.js +5 -0
  17. package/dist/code/grammars.d.ts +12 -0
  18. package/dist/code/grammars.js +83 -0
  19. package/dist/code/highlight.d.ts +15 -0
  20. package/dist/code/highlight.js +53 -0
  21. package/dist/code/index.d.ts +13 -0
  22. package/dist/code/index.js +12 -0
  23. package/dist/code/labels.d.ts +27 -0
  24. package/dist/code/labels.js +24 -0
  25. package/dist/code/languages/bash.d.ts +3 -0
  26. package/dist/code/languages/bash.js +48 -0
  27. package/dist/code/languages/css.d.ts +10 -0
  28. package/dist/code/languages/css.js +67 -0
  29. package/dist/code/languages/html.d.ts +6 -0
  30. package/dist/code/languages/html.js +35 -0
  31. package/dist/code/languages/javascript.d.ts +3 -0
  32. package/dist/code/languages/javascript.js +113 -0
  33. package/dist/code/languages/json.d.ts +3 -0
  34. package/dist/code/languages/json.js +24 -0
  35. package/dist/code/languages/python.d.ts +3 -0
  36. package/dist/code/languages/python.js +35 -0
  37. package/dist/code/languages/shared.d.ts +22 -0
  38. package/dist/code/languages/shared.js +37 -0
  39. package/dist/code/languages/sql.d.ts +3 -0
  40. package/dist/code/languages/sql.js +32 -0
  41. package/dist/code/languages/yaml.d.ts +7 -0
  42. package/dist/code/languages/yaml.js +36 -0
  43. package/dist/code/renderers.d.ts +5 -0
  44. package/dist/code/renderers.js +5 -0
  45. package/dist/code/token-styles.d.ts +25 -0
  46. package/dist/code/token-styles.js +51 -0
  47. package/dist/code/tokenize-code.d.ts +17 -0
  48. package/dist/code/tokenize-code.js +34 -0
  49. package/dist/code/tokenizer.d.ts +76 -0
  50. package/dist/code/tokenizer.js +171 -0
  51. package/dist/core/catalog/entries.d.ts +10 -0
  52. package/dist/core/catalog/entries.js +589 -0
  53. package/dist/core/catalog/index.d.ts +4 -0
  54. package/dist/core/catalog/index.js +2 -0
  55. package/dist/core/catalog/types.d.ts +36 -0
  56. package/dist/core/catalog/types.js +1 -0
  57. package/dist/core/catalog/validate.d.ts +15 -0
  58. package/dist/core/catalog/validate.js +46 -0
  59. package/dist/core/formula/evaluate.d.ts +14 -0
  60. package/dist/core/formula/evaluate.js +181 -0
  61. package/dist/core/formula/index.d.ts +8 -0
  62. package/dist/core/formula/index.js +6 -0
  63. package/dist/core/formula/parse.d.ts +19 -0
  64. package/dist/core/formula/parse.js +452 -0
  65. package/dist/core/formula/types.d.ts +76 -0
  66. package/dist/core/formula/types.js +7 -0
  67. package/dist/core/index.d.ts +14 -0
  68. package/dist/core/index.js +13 -0
  69. package/dist/core/limits.d.ts +27 -0
  70. package/dist/core/limits.js +26 -0
  71. package/dist/core/safety.d.ts +30 -0
  72. package/dist/core/safety.js +110 -0
  73. package/dist/core/schema/blocks.d.ts +138 -0
  74. package/dist/core/schema/blocks.js +181 -0
  75. package/dist/core/schema/code-family.d.ts +4 -0
  76. package/dist/core/schema/code-family.js +75 -0
  77. package/dist/core/schema/line-spec.d.ts +7 -0
  78. package/dist/core/schema/line-spec.js +19 -0
  79. package/dist/core/schema/media-family.d.ts +4 -0
  80. package/dist/core/schema/media-family.js +260 -0
  81. package/dist/core/schema/parse-family.d.ts +14 -0
  82. package/dist/core/schema/parse-family.js +37 -0
  83. package/dist/core/schema/primitives.d.ts +73 -0
  84. package/dist/core/schema/primitives.js +140 -0
  85. package/dist/core/schema/text-family.d.ts +4 -0
  86. package/dist/core/schema/text-family.js +121 -0
  87. package/dist/core/schema/vocabulary.d.ts +20 -0
  88. package/dist/core/schema/vocabulary.js +33 -0
  89. package/dist/core/text.d.ts +31 -0
  90. package/dist/core/text.js +139 -0
  91. package/dist/core/untrusted.d.ts +20 -0
  92. package/dist/core/untrusted.js +377 -0
  93. package/dist/css-modules.d.ts +1 -0
  94. package/dist/css.d.ts +1 -0
  95. package/dist/data/ChartBlockView.svelte +77 -0
  96. package/dist/data/ChartBlockView.svelte.d.ts +10 -0
  97. package/dist/data/DataBlockView.svelte +109 -0
  98. package/dist/data/DataBlockView.svelte.d.ts +5 -0
  99. package/dist/data/check.d.ts +10 -0
  100. package/dist/data/check.js +9 -0
  101. package/dist/data/engine.d.ts +18 -0
  102. package/dist/data/engine.js +10 -0
  103. package/dist/data/family.d.ts +6 -0
  104. package/dist/data/family.js +4 -0
  105. package/dist/data/index.d.ts +9 -0
  106. package/dist/data/index.js +8 -0
  107. package/dist/data/labels.d.ts +8 -0
  108. package/dist/data/labels.js +8 -0
  109. package/dist/data/renderers.d.ts +2 -0
  110. package/dist/data/renderers.js +2 -0
  111. package/dist/data/schema.d.ts +84 -0
  112. package/dist/data/schema.js +385 -0
  113. package/dist/diagram/BoardDiagram.svelte +48 -0
  114. package/dist/diagram/BoardDiagram.svelte.d.ts +8 -0
  115. package/dist/diagram/DiagramFamily.svelte +46 -0
  116. package/dist/diagram/DiagramFamily.svelte.d.ts +10 -0
  117. package/dist/diagram/FlowDiagram.svelte +108 -0
  118. package/dist/diagram/FlowDiagram.svelte.d.ts +8 -0
  119. package/dist/diagram/TerminalDiagram.svelte +38 -0
  120. package/dist/diagram/TerminalDiagram.svelte.d.ts +8 -0
  121. package/dist/diagram/TreeDiagram.svelte +149 -0
  122. package/dist/diagram/TreeDiagram.svelte.d.ts +8 -0
  123. package/dist/diagram/diagram.css +287 -0
  124. package/dist/diagram/diagram.css.d.ts +1 -0
  125. package/dist/diagram/engine.d.ts +16 -0
  126. package/dist/diagram/engine.js +14 -0
  127. package/dist/diagram/family.d.ts +7 -0
  128. package/dist/diagram/family.js +5 -0
  129. package/dist/diagram/index.d.ts +10 -0
  130. package/dist/diagram/index.js +9 -0
  131. package/dist/diagram/layout.d.ts +26 -0
  132. package/dist/diagram/layout.js +165 -0
  133. package/dist/diagram/schema.d.ts +74 -0
  134. package/dist/diagram/schema.js +358 -0
  135. package/dist/diagram/tones.d.ts +6 -0
  136. package/dist/diagram/tones.js +16 -0
  137. package/dist/embed/EmbedApp.svelte +138 -0
  138. package/dist/embed/EmbedApp.svelte.d.ts +17 -0
  139. package/dist/embed/EmbedBlockView.svelte +32 -0
  140. package/dist/embed/EmbedBlockView.svelte.d.ts +5 -0
  141. package/dist/embed/LinkPreview.svelte +48 -0
  142. package/dist/embed/LinkPreview.svelte.d.ts +10 -0
  143. package/dist/embed/engine.d.ts +30 -0
  144. package/dist/embed/engine.js +17 -0
  145. package/dist/embed/family.d.ts +7 -0
  146. package/dist/embed/family.js +5 -0
  147. package/dist/embed/index.d.ts +5 -0
  148. package/dist/embed/index.js +3 -0
  149. package/dist/embed/renderers.d.ts +3 -0
  150. package/dist/embed/renderers.js +3 -0
  151. package/dist/embed/sandbox.d.ts +86 -0
  152. package/dist/embed/sandbox.js +114 -0
  153. package/dist/embed/schema.d.ts +30 -0
  154. package/dist/embed/schema.js +217 -0
  155. package/dist/index.d.ts +16 -0
  156. package/dist/index.js +15 -0
  157. package/dist/interactive/CalculatorBlock.svelte +61 -0
  158. package/dist/interactive/CalculatorBlock.svelte.d.ts +10 -0
  159. package/dist/interactive/ChecklistBlock.svelte +44 -0
  160. package/dist/interactive/ChecklistBlock.svelte.d.ts +10 -0
  161. package/dist/interactive/InteractiveBlockView.svelte +31 -0
  162. package/dist/interactive/InteractiveBlockView.svelte.d.ts +5 -0
  163. package/dist/interactive/PollBlock.svelte +111 -0
  164. package/dist/interactive/PollBlock.svelte.d.ts +10 -0
  165. package/dist/interactive/QuizBlock.svelte +75 -0
  166. package/dist/interactive/QuizBlock.svelte.d.ts +10 -0
  167. package/dist/interactive/check.d.ts +10 -0
  168. package/dist/interactive/check.js +9 -0
  169. package/dist/interactive/engine.d.ts +19 -0
  170. package/dist/interactive/engine.js +12 -0
  171. package/dist/interactive/family.d.ts +6 -0
  172. package/dist/interactive/family.js +4 -0
  173. package/dist/interactive/index.d.ts +13 -0
  174. package/dist/interactive/index.js +13 -0
  175. package/dist/interactive/interactive.css +97 -0
  176. package/dist/interactive/interactive.css.d.ts +1 -0
  177. package/dist/interactive/labels.d.ts +16 -0
  178. package/dist/interactive/labels.js +16 -0
  179. package/dist/interactive/renderers.d.ts +9 -0
  180. package/dist/interactive/renderers.js +9 -0
  181. package/dist/interactive/schema.d.ts +76 -0
  182. package/dist/interactive/schema.js +324 -0
  183. package/dist/map/MapBlockView.svelte +465 -0
  184. package/dist/map/MapBlockView.svelte.d.ts +5 -0
  185. package/dist/map/check.d.ts +11 -0
  186. package/dist/map/check.js +6 -0
  187. package/dist/map/engine.d.ts +19 -0
  188. package/dist/map/engine.js +8 -0
  189. package/dist/map/family.d.ts +7 -0
  190. package/dist/map/family.js +5 -0
  191. package/dist/map/index.d.ts +11 -0
  192. package/dist/map/index.js +10 -0
  193. package/dist/map/labels.d.ts +27 -0
  194. package/dist/map/labels.js +21 -0
  195. package/dist/map/renderers.d.ts +2 -0
  196. package/dist/map/renderers.js +2 -0
  197. package/dist/map/schema.d.ts +41 -0
  198. package/dist/map/schema.js +176 -0
  199. package/dist/map/view-model.d.ts +55 -0
  200. package/dist/map/view-model.js +168 -0
  201. package/dist/media/MediaBlockView.svelte +258 -0
  202. package/dist/media/MediaBlockView.svelte.d.ts +5 -0
  203. package/dist/media/check.d.ts +14 -0
  204. package/dist/media/check.js +13 -0
  205. package/dist/media/engine.d.ts +18 -0
  206. package/dist/media/engine.js +10 -0
  207. package/dist/media/family.d.ts +7 -0
  208. package/dist/media/family.js +5 -0
  209. package/dist/media/index.d.ts +11 -0
  210. package/dist/media/index.js +10 -0
  211. package/dist/media/labels.d.ts +7 -0
  212. package/dist/media/labels.js +12 -0
  213. package/dist/media/renderers.d.ts +5 -0
  214. package/dist/media/renderers.js +5 -0
  215. package/dist/media/resolve.d.ts +6 -0
  216. package/dist/media/resolve.js +15 -0
  217. package/dist/structure/NestedBlocks.svelte +65 -0
  218. package/dist/structure/NestedBlocks.svelte.d.ts +11 -0
  219. package/dist/structure/SafeBody.svelte +13 -0
  220. package/dist/structure/SafeBody.svelte.d.ts +7 -0
  221. package/dist/structure/StructureFamily.svelte +157 -0
  222. package/dist/structure/StructureFamily.svelte.d.ts +5 -0
  223. package/dist/structure/check.d.ts +14 -0
  224. package/dist/structure/check.js +27 -0
  225. package/dist/structure/engine.d.ts +18 -0
  226. package/dist/structure/engine.js +18 -0
  227. package/dist/structure/family.d.ts +7 -0
  228. package/dist/structure/family.js +5 -0
  229. package/dist/structure/index.d.ts +11 -0
  230. package/dist/structure/index.js +10 -0
  231. package/dist/structure/labels.d.ts +11 -0
  232. package/dist/structure/labels.js +11 -0
  233. package/dist/structure/renderers.d.ts +5 -0
  234. package/dist/structure/renderers.js +5 -0
  235. package/dist/structure/schema.d.ts +71 -0
  236. package/dist/structure/schema.js +327 -0
  237. package/dist/structure/structure.css +182 -0
  238. package/dist/structure/structure.css.d.ts +1 -0
  239. package/dist/text/RichText.svelte +169 -0
  240. package/dist/text/RichText.svelte.d.ts +13 -0
  241. package/dist/text/TextBlockView.svelte +177 -0
  242. package/dist/text/TextBlockView.svelte.d.ts +5 -0
  243. package/dist/text/check.d.ts +14 -0
  244. package/dist/text/check.js +13 -0
  245. package/dist/text/engine.d.ts +17 -0
  246. package/dist/text/engine.js +10 -0
  247. package/dist/text/family.d.ts +7 -0
  248. package/dist/text/family.js +5 -0
  249. package/dist/text/index.d.ts +12 -0
  250. package/dist/text/index.js +11 -0
  251. package/dist/text/labels.d.ts +22 -0
  252. package/dist/text/labels.js +29 -0
  253. package/dist/text/markdown.d.ts +80 -0
  254. package/dist/text/markdown.js +361 -0
  255. package/dist/text/renderers.d.ts +6 -0
  256. package/dist/text/renderers.js +6 -0
  257. package/package.json +167 -4
@@ -0,0 +1,177 @@
1
+ <script lang="ts">
2
+ import { checkTextBlock } from './check.js';
3
+ import type { TextBlockViewProps } from './family.js';
4
+ import { resolveTextBlockLabels } from './labels.js';
5
+ import RichText from './RichText.svelte';
6
+
7
+ /**
8
+ * The text family renderer: heading, text (paragraphs and rich text), list,
9
+ * quote and callout. It takes untrusted data and renders only what
10
+ * `checkTextBlock` accepts; anything else becomes an inert notice.
11
+ */
12
+ let { block, labels, oninvalid }: TextBlockViewProps = $props();
13
+
14
+ const check = $derived(checkTextBlock(block));
15
+ const text = $derived(resolveTextBlockLabels(labels));
16
+
17
+ $effect(() => {
18
+ if (!check.ok) oninvalid?.(check.issues);
19
+ });
20
+ </script>
21
+
22
+ {#if !check.ok}
23
+ <p class="tx-block tx-block-invalid" role="note" data-tx-block="invalid">{text.invalid}</p>
24
+ {:else}
25
+ {@const b = check.block}
26
+ {#if b.type === 'heading'}
27
+ <hgroup class="tx-block tx-heading" data-tx-block="heading" data-tone={b.tone}>
28
+ {#if b.eyebrow}<p class="tx-heading-eyebrow">{b.eyebrow}</p>{/if}
29
+ <svelte:element this={`h${b.level}`} class="tx-heading-title" id={b.id}>{b.text}</svelte:element>
30
+ {#if b.subtitle}<p class="tx-heading-subtitle">{b.subtitle}</p>{/if}
31
+ </hgroup>
32
+ {:else if b.type === 'text'}
33
+ <div class="tx-block tx-text" data-tx-block="text" data-tone={b.tone}>
34
+ <RichText source={b.markdown} labels={text} />
35
+ </div>
36
+ {:else if b.type === 'list'}
37
+ <svelte:element
38
+ this={b.ordered ? 'ol' : 'ul'}
39
+ class="tx-block tx-list"
40
+ data-tx-block="list"
41
+ data-tone={b.tone}
42
+ >
43
+ {#each b.items as item, i (i)}
44
+ <li><RichText source={item.text} compact labels={text} /></li>
45
+ {/each}
46
+ </svelte:element>
47
+ {:else if b.type === 'quote'}
48
+ <figure class="tx-block tx-quote" data-tx-block="quote" data-tone={b.tone}>
49
+ <blockquote class="tx-quote-body"><RichText source={b.quote} labels={text} /></blockquote>
50
+ {#if b.cite}<figcaption class="tx-quote-cite"><cite>{b.cite}</cite></figcaption>{/if}
51
+ </figure>
52
+ {:else}
53
+ {@const tone = b.tone ?? 'neutral'}
54
+ <div class="tx-block tx-callout" role="note" data-tx-block="callout" data-tone={tone}>
55
+ {#if text.tones[tone] || b.title}
56
+ <p class="tx-callout-head">
57
+ {#if text.tones[tone]}<span class="tx-callout-tone">{text.tones[tone]}</span>{/if}
58
+ {#if b.title}<strong class="tx-callout-title">{b.title}</strong>{/if}
59
+ </p>
60
+ {/if}
61
+ <div class="tx-callout-body"><RichText source={b.body} labels={text} /></div>
62
+ </div>
63
+ {/if}
64
+ {/if}
65
+
66
+ <style>
67
+ .tx-block {
68
+ --tx-block-tone: var(--tx-color-border-strong, currentColor);
69
+ margin: 0;
70
+ overflow-wrap: anywhere;
71
+ }
72
+ /*
73
+ * Tone colors mark borders and tints only (non-text, 3:1 against both light
74
+ * and dark surfaces); tone text inherits the page color, so a callout reads
75
+ * at the host's contrast in any scheme. Tokens override the fallbacks.
76
+ */
77
+ [data-tone='accent'] {
78
+ --tx-block-tone: var(--tx-color-accent, #7c3aed);
79
+ }
80
+ [data-tone='info'] {
81
+ --tx-block-tone: var(--tx-color-info, #2563eb);
82
+ }
83
+ [data-tone='success'] {
84
+ --tx-block-tone: var(--tx-color-success, #16a34a);
85
+ }
86
+ [data-tone='warning'] {
87
+ --tx-block-tone: var(--tx-color-warning, #d97706);
88
+ }
89
+ [data-tone='danger'] {
90
+ --tx-block-tone: var(--tx-color-danger, #dc2626);
91
+ }
92
+
93
+ .tx-heading-eyebrow {
94
+ margin: 0 0 0.25em;
95
+ font-size: 0.8125rem;
96
+ font-weight: 600;
97
+ letter-spacing: 0.06em;
98
+ text-transform: uppercase;
99
+ }
100
+ .tx-heading-title {
101
+ margin: 0;
102
+ font-weight: 650;
103
+ line-height: 1.2;
104
+ text-wrap: balance;
105
+ }
106
+ .tx-heading-subtitle {
107
+ margin: 0.5em 0 0;
108
+ font-size: 1.125rem;
109
+ }
110
+
111
+ .tx-text {
112
+ line-height: 1.6;
113
+ }
114
+
115
+ .tx-list {
116
+ padding-inline-start: 1.5em;
117
+ line-height: 1.6;
118
+ }
119
+ .tx-list > li + li {
120
+ margin-block-start: 0.375em;
121
+ }
122
+
123
+ .tx-quote {
124
+ padding-inline-start: 1em;
125
+ border-inline-start: 3px solid var(--tx-block-tone);
126
+ }
127
+ .tx-quote-body {
128
+ margin: 0;
129
+ font-size: 1.125em;
130
+ font-style: italic;
131
+ }
132
+ .tx-quote-cite {
133
+ margin-block-start: 0.5em;
134
+ }
135
+ .tx-quote-cite cite {
136
+ font-style: normal;
137
+ font-weight: 600;
138
+ }
139
+
140
+ .tx-callout {
141
+ padding-block: 0.75em;
142
+ padding-inline: 1em;
143
+ border: 1px solid color-mix(in srgb, var(--tx-block-tone) 45%, transparent);
144
+ border-inline-start: 4px solid var(--tx-block-tone);
145
+ border-radius: 0.5em;
146
+ background: color-mix(in srgb, var(--tx-block-tone) 8%, transparent);
147
+ }
148
+ .tx-callout-head {
149
+ display: flex;
150
+ flex-wrap: wrap;
151
+ gap: 0.5em;
152
+ align-items: baseline;
153
+ margin: 0 0 0.375em;
154
+ }
155
+ .tx-callout-tone {
156
+ font-size: 0.8125em;
157
+ font-weight: 700;
158
+ letter-spacing: 0.04em;
159
+ text-transform: uppercase;
160
+ }
161
+
162
+ .tx-block-invalid {
163
+ padding: 0.5em 0.75em;
164
+ border: 1px dashed currentColor;
165
+ border-radius: 0.375em;
166
+ font-size: 0.875em;
167
+ }
168
+
169
+ @media (forced-colors: active) {
170
+ .tx-block {
171
+ --tx-block-tone: CanvasText;
172
+ }
173
+ .tx-callout {
174
+ border-color: CanvasText;
175
+ }
176
+ }
177
+ </style>
@@ -0,0 +1,5 @@
1
+ /// <reference path="../css-modules.d.ts" />
2
+ import type { TextBlockViewProps } from './family.js';
3
+ declare const TextBlockView: import("svelte").Component<TextBlockViewProps, {}, "">;
4
+ type TextBlockView = ReturnType<typeof TextBlockView>;
5
+ export default TextBlockView;
@@ -0,0 +1,14 @@
1
+ import type { FieldIssue } from '../core/schema/primitives.js';
2
+ import type { TextFamilyBlock } from './engine.js';
3
+ export type TextBlockCheck = {
4
+ ok: true;
5
+ block: TextFamilyBlock;
6
+ } | {
7
+ ok: false;
8
+ issues: FieldIssue[];
9
+ };
10
+ /**
11
+ * The only way data reaches a text renderer: untrusted input runs through the
12
+ * block schemas, then must be one of the text family types.
13
+ */
14
+ export declare function checkTextBlock(value: unknown): TextBlockCheck;
@@ -0,0 +1,13 @@
1
+ import { parseFamilyBlock } from "../core/schema/parse-family.js";
2
+ import { parseTextFamilyBlock } from "../core/schema/text-family.js";
3
+ /**
4
+ * The only way data reaches a text renderer: untrusted input runs through the
5
+ * block schemas, then must be one of the text family types.
6
+ */
7
+ export function checkTextBlock(value) {
8
+ // Only this family's parser: the renderer does not bundle every family's rules.
9
+ const parsed = parseFamilyBlock(value, [parseTextFamilyBlock], 'text');
10
+ if (!parsed.success)
11
+ return { ok: false, issues: parsed.issues };
12
+ return { ok: true, block: parsed.data };
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `@texuli/blocks/text/engine` — Svelte-free text family types, guards and labels.
3
+ * Markdown parser: `@texuli/blocks/text/markdown`. Renderers: `./renderers`.
4
+ */
5
+ import type { Block, CalloutBlock, FieldIssue, HeadingBlock, ListBlock, QuoteBlock, TextBlock } from '../core/index.js';
6
+ import type { TextBlockLabelOverrides } from './labels.js';
7
+ export { checkTextBlock, type TextBlockCheck } from './check.js';
8
+ export { DEFAULT_TEXT_BLOCK_LABELS, resolveTextBlockLabels, type TextBlockLabelOverrides, type TextBlockLabels, } from './labels.js';
9
+ export declare const TEXT_BLOCK_TYPES: readonly ["heading", "text", "list", "quote", "callout"];
10
+ export type TextFamilyBlockType = (typeof TEXT_BLOCK_TYPES)[number];
11
+ export type TextFamilyBlock = HeadingBlock | TextBlock | ListBlock | QuoteBlock | CalloutBlock;
12
+ export declare function isTextFamilyBlock(block: Block): block is TextFamilyBlock;
13
+ export interface TextBlockViewProps {
14
+ block: unknown;
15
+ labels?: TextBlockLabelOverrides;
16
+ oninvalid?: (issues: FieldIssue[]) => void;
17
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `@texuli/blocks/text/engine` — Svelte-free text family types, guards and labels.
3
+ * Markdown parser: `@texuli/blocks/text/markdown`. Renderers: `./renderers`.
4
+ */
5
+ export { checkTextBlock } from "./check.js";
6
+ export { DEFAULT_TEXT_BLOCK_LABELS, resolveTextBlockLabels, } from "./labels.js";
7
+ export const TEXT_BLOCK_TYPES = ['heading', 'text', 'list', 'quote', 'callout'];
8
+ export function isTextFamilyBlock(block) {
9
+ return TEXT_BLOCK_TYPES.includes(block.type);
10
+ }
@@ -0,0 +1,7 @@
1
+ import type { Component } from 'svelte';
2
+ import type { TextBlockViewProps } from './engine.js';
3
+ export { isTextFamilyBlock, TEXT_BLOCK_TYPES, type TextBlockViewProps, type TextFamilyBlock, type TextFamilyBlockType, } from './engine.js';
4
+ /** Lazily loads the text family renderer (its own chunk). */
5
+ export declare function loadTextFamily(): Promise<{
6
+ default: Component<TextBlockViewProps>;
7
+ }>;
@@ -0,0 +1,5 @@
1
+ export { isTextFamilyBlock, TEXT_BLOCK_TYPES, } from "./engine.js";
2
+ /** Lazily loads the text family renderer (its own chunk). */
3
+ export function loadTextFamily() {
4
+ return import('./TextBlockView.svelte');
5
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference path="../css-modules.d.ts" />
2
+ /**
3
+ * `@texuli/blocks` text family (T-blocks-text): heading, text (paragraphs and
4
+ * rich text), list, quote and callout. No Svelte is imported eagerly:
5
+ * renderers load through `loadTextFamily()` (its own chunk) or directly from
6
+ * `@texuli/blocks/text/renderers`. The package root re-exports only the lazy
7
+ * entry, the guard and the types. The Markdown parser has its own subpath,
8
+ * `@texuli/blocks/text/markdown`, so neither entry pulls it in eagerly.
9
+ */
10
+ export { checkTextBlock, type TextBlockCheck } from './check.js';
11
+ export { isTextFamilyBlock, loadTextFamily, TEXT_BLOCK_TYPES, type TextBlockViewProps, type TextFamilyBlock, type TextFamilyBlockType, } from './family.js';
12
+ export { DEFAULT_TEXT_BLOCK_LABELS, resolveTextBlockLabels, type TextBlockLabelOverrides, type TextBlockLabels, } from './labels.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `@texuli/blocks` text family (T-blocks-text): heading, text (paragraphs and
3
+ * rich text), list, quote and callout. No Svelte is imported eagerly:
4
+ * renderers load through `loadTextFamily()` (its own chunk) or directly from
5
+ * `@texuli/blocks/text/renderers`. The package root re-exports only the lazy
6
+ * entry, the guard and the types. The Markdown parser has its own subpath,
7
+ * `@texuli/blocks/text/markdown`, so neither entry pulls it in eagerly.
8
+ */
9
+ export { checkTextBlock } from "./check.js";
10
+ export { isTextFamilyBlock, loadTextFamily, TEXT_BLOCK_TYPES, } from "./family.js";
11
+ export { DEFAULT_TEXT_BLOCK_LABELS, resolveTextBlockLabels, } from "./labels.js";
@@ -0,0 +1,22 @@
1
+ import type { BlockTone } from '../core/index.js';
2
+ /**
3
+ * Every visible or announced string the text family renders that does not
4
+ * come from the block itself. Hosts pass translations; English is the default.
5
+ */
6
+ export interface TextBlockLabels {
7
+ /** Shown in place of a block that failed validation. */
8
+ invalid: string;
9
+ /** Accessible name of a scrollable code fence. */
10
+ codeBlock: string;
11
+ /** Accessible state of a checked and an open task item. */
12
+ taskDone: string;
13
+ taskOpen: string;
14
+ /** Visible tone label on callouts (not color alone). Empty hides it. */
15
+ tones: Record<BlockTone, string>;
16
+ }
17
+ export declare const DEFAULT_TEXT_BLOCK_LABELS: Readonly<TextBlockLabels>;
18
+ /** Merges host overrides over the English defaults (tones merge per key). */
19
+ export declare function resolveTextBlockLabels(overrides?: Partial<Omit<TextBlockLabels, 'tones'>> & {
20
+ tones?: Partial<Record<BlockTone, string>>;
21
+ }): TextBlockLabels;
22
+ export type TextBlockLabelOverrides = Parameters<typeof resolveTextBlockLabels>[0];
@@ -0,0 +1,29 @@
1
+ export const DEFAULT_TEXT_BLOCK_LABELS = /* @__PURE__ */ Object.freeze({
2
+ invalid: 'This block could not be shown.',
3
+ codeBlock: 'Code block',
4
+ taskDone: 'Done',
5
+ taskOpen: 'Not done',
6
+ tones: /* @__PURE__ */ Object.freeze({
7
+ neutral: '',
8
+ accent: 'Note',
9
+ info: 'Info',
10
+ success: 'Success',
11
+ warning: 'Warning',
12
+ danger: 'Important',
13
+ }),
14
+ });
15
+ /** Merges host overrides over the English defaults (tones merge per key). */
16
+ export function resolveTextBlockLabels(overrides = {}) {
17
+ const merged = { ...DEFAULT_TEXT_BLOCK_LABELS.tones };
18
+ for (const [tone, label] of Object.entries(overrides.tones ?? {})) {
19
+ if (typeof label === 'string' && tone in merged)
20
+ merged[tone] = label;
21
+ }
22
+ return {
23
+ invalid: overrides.invalid ?? DEFAULT_TEXT_BLOCK_LABELS.invalid,
24
+ codeBlock: overrides.codeBlock ?? DEFAULT_TEXT_BLOCK_LABELS.codeBlock,
25
+ taskDone: overrides.taskDone ?? DEFAULT_TEXT_BLOCK_LABELS.taskDone,
26
+ taskOpen: overrides.taskOpen ?? DEFAULT_TEXT_BLOCK_LABELS.taskOpen,
27
+ tones: merged,
28
+ };
29
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Owned, closed Markdown subset for text blocks (T-blocks-text). It turns
3
+ * already-validated block text into a small tree the Svelte renderers walk.
4
+ * Nothing here produces HTML: raw tags stay literal text, every link goes
5
+ * through `safeHref` (untrusted tier), and images render as their alt text
6
+ * (pictures belong to the media family, which applies `safeImageSrc`).
7
+ *
8
+ * Supported: paragraphs, `#` headings, `-`/`*`/`+` and `1.` lists (nested by
9
+ * indentation, `[ ]`/`[x]` task items), `>` quotes, fenced code, thematic
10
+ * breaks; inline `**strong**`, `*em*`, `~~del~~`, `` `code` ``, `[text](href)`,
11
+ * `<https://…>` autolinks, backslash escapes and hard breaks.
12
+ */
13
+ export type MdInline = {
14
+ type: 'text';
15
+ text: string;
16
+ } | {
17
+ type: 'code';
18
+ text: string;
19
+ } | {
20
+ type: 'break';
21
+ } | {
22
+ type: 'strong' | 'em' | 'del';
23
+ children: MdInline[];
24
+ } | {
25
+ type: 'link';
26
+ href: string | undefined;
27
+ children: MdInline[];
28
+ };
29
+ export type MdListItem = {
30
+ checked: boolean | null;
31
+ children: MdBlock[];
32
+ };
33
+ export type MdBlock = {
34
+ type: 'paragraph';
35
+ children: MdInline[];
36
+ } | {
37
+ type: 'heading';
38
+ level: 1 | 2 | 3 | 4 | 5 | 6;
39
+ children: MdInline[];
40
+ } | {
41
+ type: 'list';
42
+ ordered: boolean;
43
+ start: number;
44
+ items: MdListItem[];
45
+ } | {
46
+ type: 'quote';
47
+ children: MdBlock[];
48
+ } | {
49
+ type: 'code';
50
+ lang: string | undefined;
51
+ text: string;
52
+ } | {
53
+ type: 'rule';
54
+ };
55
+ export interface MdDocument {
56
+ blocks: MdBlock[];
57
+ }
58
+ /** Nesting and size caps: hostile input degrades to literal text, never recursion blowups. */
59
+ export declare const MARKDOWN_LIMITS: Readonly<{
60
+ /**
61
+ * Longest source parsed, equal to the schema's markdown cap. Pathological
62
+ * inline input stays under ~50 ms at this size.
63
+ */
64
+ source: 4000;
65
+ /** Nested quotes and lists. */
66
+ blockDepth: 4;
67
+ /** Nested emphasis and links. */
68
+ inlineDepth: 6;
69
+ }>;
70
+ /** Parses validated block text into the closed Markdown tree. */
71
+ export declare function parseMarkdown(source: string): MdDocument;
72
+ /** Parses inline Markdown; `depth` caps nested emphasis and links. */
73
+ export declare function parseInline(source: string, depth: number, inLink?: boolean): MdInline[];
74
+ /** Plain text of an inline tree (for accessible names and summaries). */
75
+ export declare function inlineText(nodes: readonly MdInline[]): string;
76
+ /**
77
+ * Distinct heading levels used anywhere in the tree, ascending. Renderers map
78
+ * them onto consecutive outline levels (`##` then `####` become h3 then h4).
79
+ */
80
+ export declare function headingLevels(blocks: readonly MdBlock[]): number[];