@fuzdev/fuz_ui 0.204.0 → 0.205.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/ApiModule.svelte +14 -1
  2. package/dist/ApiModule.svelte.d.ts.map +1 -1
  3. package/dist/Breadcrumb.svelte +2 -2
  4. package/dist/Card.svelte +1 -7
  5. package/dist/ColorSchemeInput.svelte +1 -2
  6. package/dist/ContextmenuEntry.svelte +1 -3
  7. package/dist/ContextmenuLinkEntry.svelte +1 -4
  8. package/dist/ContextmenuSeparator.svelte +1 -1
  9. package/dist/ContextmenuSubmenu.svelte +1 -2
  10. package/dist/CopyToClipboard.svelte +5 -5
  11. package/dist/CopyToClipboard.svelte.d.ts.map +1 -1
  12. package/dist/DeclarationDetail.svelte +15 -4
  13. package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
  14. package/dist/Dialog.svelte +1 -2
  15. package/dist/DialogContent.svelte +1 -1
  16. package/dist/DocsList.svelte +1 -1
  17. package/dist/DocsMenu.svelte +1 -1
  18. package/dist/DocsPageLinks.svelte +9 -8
  19. package/dist/DocsPageLinks.svelte.d.ts.map +1 -1
  20. package/dist/DocsPrimaryNav.svelte +1 -1
  21. package/dist/DocsSecondaryNav.svelte +1 -1
  22. package/dist/EcosystemLinks.svelte +1 -1
  23. package/dist/LibraryDetail.svelte +10 -7
  24. package/dist/LibraryDetail.svelte.d.ts.map +1 -1
  25. package/dist/LibrarySummary.svelte +1 -2
  26. package/dist/PendingAnimation.svelte +6 -4
  27. package/dist/PendingAnimation.svelte.d.ts.map +1 -1
  28. package/dist/PendingButton.svelte +1 -2
  29. package/dist/StyleVariableButton.svelte +1 -2
  30. package/dist/Svg.svelte +1 -1
  31. package/dist/ThemeInput.svelte +1 -2
  32. package/dist/TomeSectionHeader.svelte +1 -1
  33. package/package.json +14 -38
  34. package/dist/Mdz.svelte +0 -34
  35. package/dist/Mdz.svelte.d.ts +0 -11
  36. package/dist/Mdz.svelte.d.ts.map +0 -1
  37. package/dist/MdzNodeView.svelte +0 -107
  38. package/dist/MdzNodeView.svelte.d.ts +0 -9
  39. package/dist/MdzNodeView.svelte.d.ts.map +0 -1
  40. package/dist/MdzPrecompiled.svelte +0 -30
  41. package/dist/MdzPrecompiled.svelte.d.ts +0 -11
  42. package/dist/MdzPrecompiled.svelte.d.ts.map +0 -1
  43. package/dist/MdzRoot.svelte +0 -30
  44. package/dist/MdzRoot.svelte.d.ts +0 -12
  45. package/dist/MdzRoot.svelte.d.ts.map +0 -1
  46. package/dist/MdzStream.svelte +0 -32
  47. package/dist/MdzStream.svelte.d.ts +0 -12
  48. package/dist/MdzStream.svelte.d.ts.map +0 -1
  49. package/dist/MdzStreamNodeView.svelte +0 -106
  50. package/dist/MdzStreamNodeView.svelte.d.ts +0 -9
  51. package/dist/MdzStreamNodeView.svelte.d.ts.map +0 -1
  52. package/dist/mdz.d.ts +0 -112
  53. package/dist/mdz.d.ts.map +0 -1
  54. package/dist/mdz.js +0 -1186
  55. package/dist/mdz_components.d.ts +0 -63
  56. package/dist/mdz_components.d.ts.map +0 -1
  57. package/dist/mdz_components.js +0 -32
  58. package/dist/mdz_helpers.d.ts +0 -164
  59. package/dist/mdz_helpers.d.ts.map +0 -1
  60. package/dist/mdz_helpers.js +0 -424
  61. package/dist/mdz_lexer.d.ts +0 -93
  62. package/dist/mdz_lexer.d.ts.map +0 -1
  63. package/dist/mdz_lexer.js +0 -732
  64. package/dist/mdz_opcodes.d.ts +0 -174
  65. package/dist/mdz_opcodes.d.ts.map +0 -1
  66. package/dist/mdz_opcodes.js +0 -14
  67. package/dist/mdz_opcodes_to_nodes.d.ts +0 -20
  68. package/dist/mdz_opcodes_to_nodes.d.ts.map +0 -1
  69. package/dist/mdz_opcodes_to_nodes.js +0 -332
  70. package/dist/mdz_stream_parser.d.ts +0 -80
  71. package/dist/mdz_stream_parser.d.ts.map +0 -1
  72. package/dist/mdz_stream_parser.js +0 -354
  73. package/dist/mdz_stream_parser_block.d.ts +0 -76
  74. package/dist/mdz_stream_parser_block.d.ts.map +0 -1
  75. package/dist/mdz_stream_parser_block.js +0 -458
  76. package/dist/mdz_stream_parser_inline.d.ts +0 -52
  77. package/dist/mdz_stream_parser_inline.d.ts.map +0 -1
  78. package/dist/mdz_stream_parser_inline.js +0 -378
  79. package/dist/mdz_stream_parser_link.d.ts +0 -22
  80. package/dist/mdz_stream_parser_link.d.ts.map +0 -1
  81. package/dist/mdz_stream_parser_link.js +0 -215
  82. package/dist/mdz_stream_parser_state.d.ts +0 -187
  83. package/dist/mdz_stream_parser_state.d.ts.map +0 -1
  84. package/dist/mdz_stream_parser_state.js +0 -398
  85. package/dist/mdz_stream_parser_text.d.ts +0 -14
  86. package/dist/mdz_stream_parser_text.d.ts.map +0 -1
  87. package/dist/mdz_stream_parser_text.js +0 -50
  88. package/dist/mdz_stream_parser_url.d.ts +0 -60
  89. package/dist/mdz_stream_parser_url.d.ts.map +0 -1
  90. package/dist/mdz_stream_parser_url.js +0 -307
  91. package/dist/mdz_stream_state.svelte.d.ts +0 -44
  92. package/dist/mdz_stream_state.svelte.d.ts.map +0 -1
  93. package/dist/mdz_stream_state.svelte.js +0 -357
  94. package/dist/mdz_to_svelte.d.ts +0 -41
  95. package/dist/mdz_to_svelte.d.ts.map +0 -1
  96. package/dist/mdz_to_svelte.js +0 -100
  97. package/dist/mdz_token_parser.d.ts +0 -14
  98. package/dist/mdz_token_parser.d.ts.map +0 -1
  99. package/dist/mdz_token_parser.js +0 -344
  100. package/dist/svelte_preprocess_mdz.d.ts +0 -65
  101. package/dist/svelte_preprocess_mdz.d.ts.map +0 -1
  102. package/dist/svelte_preprocess_mdz.js +0 -529
  103. package/dist/tsdoc_mdz.d.ts +0 -45
  104. package/dist/tsdoc_mdz.d.ts.map +0 -1
  105. package/dist/tsdoc_mdz.js +0 -88
  106. package/src/lib/mdz.ts +0 -1532
  107. package/src/lib/mdz_components.ts +0 -64
  108. package/src/lib/mdz_helpers.ts +0 -449
  109. package/src/lib/mdz_lexer.ts +0 -1012
  110. package/src/lib/mdz_opcodes.ts +0 -205
  111. package/src/lib/mdz_opcodes_to_nodes.ts +0 -375
  112. package/src/lib/mdz_stream_parser.ts +0 -415
  113. package/src/lib/mdz_stream_parser_block.ts +0 -532
  114. package/src/lib/mdz_stream_parser_inline.ts +0 -414
  115. package/src/lib/mdz_stream_parser_link.ts +0 -271
  116. package/src/lib/mdz_stream_parser_state.ts +0 -539
  117. package/src/lib/mdz_stream_parser_text.ts +0 -77
  118. package/src/lib/mdz_stream_parser_url.ts +0 -365
  119. package/src/lib/mdz_stream_state.svelte.ts +0 -387
  120. package/src/lib/mdz_to_svelte.ts +0 -141
  121. package/src/lib/mdz_token_parser.ts +0 -434
  122. package/src/lib/svelte_preprocess_mdz.ts +0 -742
  123. package/src/lib/tsdoc_mdz.ts +0 -97
@@ -1,357 +0,0 @@
1
- /**
2
- * Reactive state for the mdz streaming renderer.
3
- *
4
- * Maintains a reactive tree of `MdzStreamNode` objects that Svelte 5 can
5
- * efficiently update. Opcodes from `MdzStreamParser` are applied via
6
- * `apply()` or `apply_batch()`, mutating the tree in place.
7
- *
8
- * @module
9
- */
10
- import { DEV } from 'esm-env';
11
- /**
12
- * A reactive node in the stream renderer tree.
13
- * Fields are `$state` so Svelte re-renders only what changes.
14
- */
15
- export class MdzStreamNode {
16
- id;
17
- type;
18
- content = $state('');
19
- children = $state([]);
20
- // metadata
21
- level;
22
- reference = $state();
23
- link_type = $state();
24
- name;
25
- lang;
26
- heading_id = $state();
27
- constructor(id, type) {
28
- this.id = id;
29
- this.type = type;
30
- }
31
- }
32
- /**
33
- * Reactive state manager for streaming mdz content.
34
- * Apply opcodes to incrementally build and update the render tree.
35
- */
36
- export class MdzStreamState {
37
- root = $state([]);
38
- /** Node lookup by ID. */
39
- #nodes = new Map();
40
- /** Parent tracking for re-parenting during revert. */
41
- #parents = new Map();
42
- /** Stack of open container IDs (for knowing current parent). */
43
- #stack = [];
44
- /**
45
- * Register a new node and attach it to its current parent (innermost open
46
- * container, or root). Shared by `open`, `text`, and `void` paths.
47
- */
48
- #attach(node) {
49
- this.#nodes.set(node.id, node);
50
- const parent_id = this.#stack.length > 0 ? this.#stack[this.#stack.length - 1] : null;
51
- this.#parents.set(node.id, parent_id);
52
- if (parent_id !== null) {
53
- const parent = this.#nodes.get(parent_id);
54
- if (DEV && !parent) {
55
- throw new Error(`MdzStreamState: parent id ${parent_id} on stack but missing from nodes`);
56
- }
57
- if (parent)
58
- parent.children.push(node);
59
- }
60
- else {
61
- this.root.push(node);
62
- }
63
- }
64
- /**
65
- * Apply a single opcode.
66
- */
67
- apply(opcode) {
68
- switch (opcode.type) {
69
- case 'open': {
70
- if (DEV && this.#nodes.has(opcode.id)) {
71
- throw new Error(`MdzStreamState: duplicate open for id ${opcode.id} (node_type '${opcode.node_type}')`);
72
- }
73
- const node = new MdzStreamNode(opcode.id, opcode.node_type);
74
- if (opcode.level !== undefined)
75
- node.level = opcode.level;
76
- if (opcode.name !== undefined)
77
- node.name = opcode.name;
78
- if (opcode.lang !== undefined)
79
- node.lang = opcode.lang;
80
- this.#attach(node);
81
- this.#stack.push(opcode.id);
82
- break;
83
- }
84
- case 'close': {
85
- if (DEV) {
86
- if (!this.#nodes.has(opcode.id)) {
87
- throw new Error(`MdzStreamState: close for unknown id ${opcode.id}`);
88
- }
89
- if (!this.#stack.includes(opcode.id)) {
90
- throw new Error(`MdzStreamState: close for id ${opcode.id} which is not on the stack`);
91
- }
92
- }
93
- const node = this.#nodes.get(opcode.id);
94
- if (node) {
95
- if (opcode.discard) {
96
- // drop the node and its descendants from its parent's children
97
- const parent_id = this.#parents.get(opcode.id);
98
- const parent_children = parent_id !== null && parent_id !== undefined
99
- ? this.#nodes.get(parent_id)?.children
100
- : this.root;
101
- if (parent_children) {
102
- const idx = parent_children.indexOf(node);
103
- if (idx !== -1)
104
- parent_children.splice(idx, 1);
105
- }
106
- }
107
- else {
108
- // apply deferred metadata
109
- if (opcode.reference !== undefined)
110
- node.reference = opcode.reference;
111
- if (opcode.link_type !== undefined)
112
- node.link_type = opcode.link_type;
113
- if (opcode.heading_id !== undefined)
114
- node.heading_id = opcode.heading_id;
115
- // Code/Codeblock: collapse text children into `content` so renderers
116
- // can read it directly without walking children every render.
117
- if (node.type === 'Code' || node.type === 'Codeblock') {
118
- let content = '';
119
- for (const child of node.children)
120
- content += child.content;
121
- node.content = content;
122
- }
123
- }
124
- }
125
- // pop from stack
126
- const idx = this.#stack.lastIndexOf(opcode.id);
127
- if (idx !== -1)
128
- this.#stack.splice(idx, 1);
129
- // cleanup: closed nodes have no further opcode interactions.
130
- // children are retained in the render tree via children arrays
131
- // (discarded nodes' subtrees also need full cleanup, which the
132
- // traversal in `#cleanup_node` already handles).
133
- this.#cleanup_node(opcode.id);
134
- break;
135
- }
136
- case 'text': {
137
- if (DEV && this.#nodes.has(opcode.id)) {
138
- throw new Error(`MdzStreamState: duplicate text for id ${opcode.id} (text_type '${opcode.text_type}')`);
139
- }
140
- const node = new MdzStreamNode(opcode.id, opcode.text_type);
141
- node.content = opcode.content;
142
- this.#attach(node);
143
- break;
144
- }
145
- case 'append_text': {
146
- if (DEV && !this.#nodes.has(opcode.id)) {
147
- throw new Error(`MdzStreamState: append_text for unknown id ${opcode.id}`);
148
- }
149
- const node = this.#nodes.get(opcode.id);
150
- if (node) {
151
- node.content += opcode.content;
152
- }
153
- break;
154
- }
155
- case 'trim_text': {
156
- if (DEV && !this.#nodes.has(opcode.id)) {
157
- throw new Error(`MdzStreamState: trim_text for unknown id ${opcode.id}`);
158
- }
159
- const node = this.#nodes.get(opcode.id);
160
- if (node) {
161
- node.content = node.content.slice(0, node.content.length - opcode.count);
162
- if (node.content.length === 0) {
163
- const parent_id = this.#parents.get(opcode.id);
164
- const parent_children = parent_id !== null && parent_id !== undefined
165
- ? this.#nodes.get(parent_id)?.children
166
- : this.root;
167
- if (parent_children) {
168
- const idx = parent_children.indexOf(node);
169
- if (idx !== -1)
170
- parent_children.splice(idx, 1);
171
- }
172
- this.#nodes.delete(opcode.id);
173
- this.#parents.delete(opcode.id);
174
- }
175
- }
176
- break;
177
- }
178
- case 'void': {
179
- if (DEV && this.#nodes.has(opcode.id)) {
180
- throw new Error(`MdzStreamState: duplicate void for id ${opcode.id} (node_type '${opcode.node_type}')`);
181
- }
182
- const node = new MdzStreamNode(opcode.id, opcode.node_type);
183
- this.#attach(node);
184
- break;
185
- }
186
- case 'revert': {
187
- if (DEV) {
188
- if (!this.#nodes.has(opcode.id)) {
189
- throw new Error(`MdzStreamState: revert for unknown id ${opcode.id}`);
190
- }
191
- if (!this.#stack.includes(opcode.id)) {
192
- throw new Error(`MdzStreamState: revert for id ${opcode.id} which is not on the stack`);
193
- }
194
- }
195
- const node = this.#nodes.get(opcode.id);
196
- if (!node)
197
- break;
198
- const parent_id = this.#parents.get(opcode.id);
199
- const parent_children = parent_id !== null && parent_id !== undefined
200
- ? this.#nodes.get(parent_id)?.children
201
- : this.root;
202
- if (!parent_children) {
203
- if (DEV) {
204
- throw new Error(`MdzStreamState: revert for id ${opcode.id} but parent has no children array`);
205
- }
206
- break;
207
- }
208
- // find the node in parent's children
209
- let node_idx = -1;
210
- for (let i = 0; i < parent_children.length; i++) {
211
- if (parent_children[i].id === opcode.id) {
212
- node_idx = i;
213
- break;
214
- }
215
- }
216
- if (node_idx === -1) {
217
- if (DEV) {
218
- throw new Error(`MdzStreamState: revert for id ${opcode.id} but node not found in parent's children`);
219
- }
220
- break;
221
- }
222
- // collect replacement content: literal delimiter text + re-parented children
223
- const replacement_nodes = [];
224
- if (opcode.replacement_text) {
225
- const text_node = new MdzStreamNode(opcode.id, 'Text');
226
- text_node.content = opcode.replacement_text;
227
- replacement_nodes.push(text_node);
228
- }
229
- for (const child of node.children) {
230
- replacement_nodes.push(child);
231
- }
232
- if (opcode.wrap_node_type != null && opcode.wrap_id != null) {
233
- if (DEV && this.#nodes.has(opcode.wrap_id)) {
234
- throw new Error(`MdzStreamState: revert wrap_id ${opcode.wrap_id} already exists in nodes`);
235
- }
236
- // block-level revert: wrap content in a new container and push onto stack
237
- const wrapper = new MdzStreamNode(opcode.wrap_id, opcode.wrap_node_type);
238
- for (const rn of replacement_nodes) {
239
- wrapper.children.push(rn);
240
- }
241
- for (const child of node.children) {
242
- this.#parents.set(child.id, opcode.wrap_id);
243
- }
244
- this.#nodes.set(opcode.wrap_id, wrapper);
245
- this.#parents.set(opcode.wrap_id, parent_id ?? null);
246
- parent_children.splice(node_idx, 1, wrapper);
247
- this.#stack.push(opcode.wrap_id);
248
- }
249
- else {
250
- // inline revert: re-parent directly to grandparent
251
- for (const child of node.children) {
252
- this.#parents.set(child.id, parent_id ?? null);
253
- }
254
- parent_children.splice(node_idx, 1, ...replacement_nodes);
255
- }
256
- // remove reverted node from stack
257
- const stack_idx = this.#stack.lastIndexOf(opcode.id);
258
- if (stack_idx !== -1)
259
- this.#stack.splice(stack_idx, 1);
260
- // cleanup
261
- this.#nodes.delete(opcode.id);
262
- this.#parents.delete(opcode.id);
263
- break;
264
- }
265
- case 'wrap': {
266
- if (DEV) {
267
- if (!this.#nodes.has(opcode.target_id)) {
268
- throw new Error(`MdzStreamState: wrap target_id ${opcode.target_id} not in nodes`);
269
- }
270
- if (this.#nodes.has(opcode.id)) {
271
- throw new Error(`MdzStreamState: wrap id ${opcode.id} already exists in nodes`);
272
- }
273
- }
274
- const target = this.#nodes.get(opcode.target_id);
275
- if (!target)
276
- break;
277
- const parent_id = this.#parents.get(opcode.target_id);
278
- const parent_children = parent_id !== null && parent_id !== undefined
279
- ? this.#nodes.get(parent_id)?.children
280
- : this.root;
281
- if (!parent_children)
282
- break;
283
- // find target in parent's children
284
- let target_idx = -1;
285
- for (let i = 0; i < parent_children.length; i++) {
286
- if (parent_children[i].id === opcode.target_id) {
287
- target_idx = i;
288
- break;
289
- }
290
- }
291
- if (target_idx === -1)
292
- break;
293
- // handle trailing punctuation trim
294
- let trimmed_node = null;
295
- if (opcode.trim_end && opcode.trim_end > 0 && opcode.trim_id != null) {
296
- const trimmed_content = target.content.slice(target.content.length - opcode.trim_end);
297
- target.content = target.content.slice(0, target.content.length - opcode.trim_end);
298
- trimmed_node = new MdzStreamNode(opcode.trim_id, 'Text');
299
- trimmed_node.content = trimmed_content;
300
- this.#nodes.set(opcode.trim_id, trimmed_node);
301
- this.#parents.set(opcode.trim_id, parent_id ?? null);
302
- }
303
- // create Link wrapper containing target
304
- const link = new MdzStreamNode(opcode.id, opcode.node_type);
305
- link.reference = opcode.reference;
306
- link.link_type = opcode.link_type;
307
- link.children.push(target);
308
- this.#nodes.set(opcode.id, link);
309
- this.#parents.set(opcode.id, parent_id ?? null);
310
- this.#parents.set(opcode.target_id, opcode.id);
311
- // replace target with [Link, trimmed?] in parent's children
312
- if (trimmed_node) {
313
- parent_children.splice(target_idx, 1, link, trimmed_node);
314
- }
315
- else {
316
- parent_children[target_idx] = link;
317
- }
318
- // cleanup: Link is complete (no close opcode coming).
319
- // trim_id (if any) stays in maps — cleaned when parent closes.
320
- this.#cleanup_node(opcode.id);
321
- break;
322
- }
323
- }
324
- }
325
- /**
326
- * Remove a node and its descendants from the lookup maps. Iterative to avoid
327
- * stack overflow on deep trees.
328
- *
329
- * Parser invariant: once a container closes, no future opcode targets that
330
- * subtree (no `append_text` to a closed Text, no nested `wrap`/`revert`).
331
- * Children stay reachable via `parent.children` arrays — only the lookup
332
- * maps are pruned. If this invariant is violated, the misbehaving opcode
333
- * triggers a DEV throw in `apply()` and silently no-ops in production.
334
- */
335
- #cleanup_node(id) {
336
- const queue = [id];
337
- while (queue.length > 0) {
338
- const current_id = queue.pop();
339
- const node = this.#nodes.get(current_id);
340
- if (node) {
341
- for (const child of node.children) {
342
- queue.push(child.id);
343
- }
344
- }
345
- this.#nodes.delete(current_id);
346
- this.#parents.delete(current_id);
347
- }
348
- }
349
- /**
350
- * Apply a batch of opcodes.
351
- */
352
- apply_batch(opcodes) {
353
- for (const op of opcodes) {
354
- this.apply(op);
355
- }
356
- }
357
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Converts parsed `MdzNode` arrays to Svelte markup strings.
3
- *
4
- * Used by the `svelte_preprocess_mdz` preprocessor to expand static `<Mdz content="...">` usages
5
- * into pre-rendered Svelte markup at build time. The output for each node type matches what
6
- * `MdzNodeView.svelte` renders at runtime, so precompiled and runtime rendering are identical.
7
- *
8
- * @module
9
- */
10
- import type { MdzNode } from './mdz.js';
11
- /**
12
- * Result of converting `MdzNode` arrays to Svelte markup.
13
- */
14
- export interface MdzToSvelteResult {
15
- /** Generated Svelte markup string. */
16
- markup: string;
17
- /** Required imports: `Map<local_name, {path, kind}>`. */
18
- imports: Map<string, {
19
- path: string;
20
- kind: 'default' | 'named';
21
- }>;
22
- /** Whether content references unconfigured Component or Element tags. */
23
- has_unconfigured_tags: boolean;
24
- }
25
- /**
26
- * Converts an array of `MdzNode` to a Svelte markup string.
27
- *
28
- * Each node type produces output matching what `MdzNodeView.svelte` renders at runtime.
29
- * Collects required imports and flags unconfigured component/element references.
30
- *
31
- * @param nodes - parsed mdz nodes to render
32
- * @param components - Component name to import path mapping (e.g., `{Alert: '$lib/Alert.svelte'}`)
33
- * If content references a component not in this map, `has_unconfigured_tags` is set.
34
- * @param elements - Allowed HTML element names (e.g., `new Set(['aside', 'details'])`)
35
- * If content references an element not in this set, `has_unconfigured_tags` is set.
36
- * @param base - Base path for resolving relative links (e.g., `'/docs/mdz/'`)
37
- * When provided, relative references (`./`, `../`) are resolved to absolute paths
38
- * and passed through `resolve()`. Trailing slash recommended.
39
- */
40
- export declare const mdz_to_svelte: (nodes: Array<MdzNode>, components: Record<string, string>, elements: ReadonlySet<string>, base?: string) => MdzToSvelteResult;
41
- //# sourceMappingURL=mdz_to_svelte.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mdz_to_svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_to_svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAGtC;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,sCAAsC;IACtC,MAAM,EAAE,MAAM,CAAC;IAEf,yDAAyD;IACzD,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAC,CAAC,CAAC;IAEhE,yEAAyE;IACzE,qBAAqB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,GACzB,OAAO,KAAK,CAAC,OAAO,CAAC,EACrB,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,UAAU,WAAW,CAAC,MAAM,CAAC,EAC7B,OAAO,MAAM,KACX,iBAyFF,CAAC"}
@@ -1,100 +0,0 @@
1
- /**
2
- * Converts parsed `MdzNode` arrays to Svelte markup strings.
3
- *
4
- * Used by the `svelte_preprocess_mdz` preprocessor to expand static `<Mdz content="...">` usages
5
- * into pre-rendered Svelte markup at build time. The output for each node type matches what
6
- * `MdzNodeView.svelte` renders at runtime, so precompiled and runtime rendering are identical.
7
- *
8
- * @module
9
- */
10
- import { UnreachableError } from '@fuzdev/fuz_util/error.js';
11
- import { escape_svelte_text } from '@fuzdev/fuz_util/svelte_preprocess_helpers.js';
12
- import { escape_js_string } from '@fuzdev/fuz_util/string.js';
13
- import { resolve_relative_path } from './mdz_helpers.js';
14
- /**
15
- * Converts an array of `MdzNode` to a Svelte markup string.
16
- *
17
- * Each node type produces output matching what `MdzNodeView.svelte` renders at runtime.
18
- * Collects required imports and flags unconfigured component/element references.
19
- *
20
- * @param nodes - parsed mdz nodes to render
21
- * @param components - Component name to import path mapping (e.g., `{Alert: '$lib/Alert.svelte'}`)
22
- * If content references a component not in this map, `has_unconfigured_tags` is set.
23
- * @param elements - Allowed HTML element names (e.g., `new Set(['aside', 'details'])`)
24
- * If content references an element not in this set, `has_unconfigured_tags` is set.
25
- * @param base - Base path for resolving relative links (e.g., `'/docs/mdz/'`)
26
- * When provided, relative references (`./`, `../`) are resolved to absolute paths
27
- * and passed through `resolve()`. Trailing slash recommended.
28
- */
29
- export const mdz_to_svelte = (nodes, components, elements, base) => {
30
- const imports = new Map();
31
- let has_unconfigured_tags = false;
32
- const render_nodes = (children) => {
33
- return children.map((child) => render_node(child)).join('');
34
- };
35
- const render_node = (node) => {
36
- switch (node.type) {
37
- case 'Text':
38
- return escape_svelte_text(node.content);
39
- case 'Code':
40
- imports.set('DocsLink', { path: '@fuzdev/fuz_ui/DocsLink.svelte', kind: 'default' });
41
- return `<DocsLink reference={'${escape_js_string(node.content)}'} />`;
42
- case 'Codeblock': {
43
- imports.set('Code', { path: '@fuzdev/fuz_code/Code.svelte', kind: 'default' });
44
- const lang_attr = node.lang === null ? 'lang={null}' : `lang={'${escape_js_string(node.lang)}'}`;
45
- return `<Code ${lang_attr} content={'${escape_js_string(node.content)}'} />`;
46
- }
47
- case 'Bold':
48
- return `<strong>${render_nodes(node.children)}</strong>`;
49
- case 'Italic':
50
- return `<em>${render_nodes(node.children)}</em>`;
51
- case 'Strikethrough':
52
- return `<s>${render_nodes(node.children)}</s>`;
53
- case 'Link': {
54
- const children_markup = render_nodes(node.children);
55
- if (node.link_type === 'internal') {
56
- if (node.reference.startsWith('.') && base) {
57
- const resolved = resolve_relative_path(node.reference, base);
58
- imports.set('resolve', { path: '$app/paths', kind: 'named' });
59
- return `<a href={resolve('${escape_js_string(resolved)}')}>${children_markup}</a>`;
60
- }
61
- if (node.reference.startsWith('#') ||
62
- node.reference.startsWith('?') ||
63
- node.reference.startsWith('.')) {
64
- return `<a href={'${escape_js_string(node.reference)}'}>${children_markup}</a>`;
65
- }
66
- imports.set('resolve', { path: '$app/paths', kind: 'named' });
67
- return `<a href={resolve('${escape_js_string(node.reference)}')}>${children_markup}</a>`;
68
- }
69
- // External link — matches MdzNodeView: target="_blank" rel="noopener"
70
- return `<a href={'${escape_js_string(node.reference)}'} target="_blank" rel="noopener">${children_markup}</a>`;
71
- }
72
- case 'Paragraph':
73
- return `<p>${render_nodes(node.children)}</p>`;
74
- case 'Hr':
75
- return '<hr />';
76
- case 'Heading':
77
- return `<h${node.level}>${render_nodes(node.children)}</h${node.level}>`;
78
- case 'Element': {
79
- if (!elements.has(node.name)) {
80
- has_unconfigured_tags = true;
81
- return '';
82
- }
83
- return `<${node.name}>${render_nodes(node.children)}</${node.name}>`;
84
- }
85
- case 'Component': {
86
- const import_path = components[node.name];
87
- if (!import_path) {
88
- has_unconfigured_tags = true;
89
- return '';
90
- }
91
- imports.set(node.name, { path: import_path, kind: 'default' });
92
- return `<${node.name}>${render_nodes(node.children)}</${node.name}>`;
93
- }
94
- default:
95
- throw new UnreachableError(node);
96
- }
97
- };
98
- const markup = render_nodes(nodes);
99
- return { markup, imports, has_unconfigured_tags };
100
- };
@@ -1,14 +0,0 @@
1
- /**
2
- * mdz token parser — consumes a `MdzToken[]` stream to build the `MdzNode[]` AST.
3
- *
4
- * Phase 2 of the two-phase lexer+parser alternative to the single-pass parser
5
- * in `mdz.ts`. Phase 1 (lexer) is in `mdz_lexer.ts`.
6
- *
7
- * @module
8
- */
9
- import type { MdzNode } from './mdz.js';
10
- /**
11
- * Parses text to an array of `MdzNode` using a two-phase lexer+parser approach.
12
- */
13
- export declare const mdz_parse_lexer: (text: string) => Array<MdzNode>;
14
- //# sourceMappingURL=mdz_token_parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mdz_token_parser.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/mdz_token_parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACX,OAAO,EASP,MAAM,UAAU,CAAC;AAqBlB;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,KAAK,CAAC,OAAO,CAG3D,CAAC"}