@fuzdev/fuz_ui 0.204.0 → 0.205.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 (95) hide show
  1. package/dist/ApiModule.svelte +14 -1
  2. package/dist/ApiModule.svelte.d.ts.map +1 -1
  3. package/dist/DeclarationDetail.svelte +15 -4
  4. package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
  5. package/package.json +12 -36
  6. package/dist/Mdz.svelte +0 -34
  7. package/dist/Mdz.svelte.d.ts +0 -11
  8. package/dist/Mdz.svelte.d.ts.map +0 -1
  9. package/dist/MdzNodeView.svelte +0 -107
  10. package/dist/MdzNodeView.svelte.d.ts +0 -9
  11. package/dist/MdzNodeView.svelte.d.ts.map +0 -1
  12. package/dist/MdzPrecompiled.svelte +0 -30
  13. package/dist/MdzPrecompiled.svelte.d.ts +0 -11
  14. package/dist/MdzPrecompiled.svelte.d.ts.map +0 -1
  15. package/dist/MdzRoot.svelte +0 -30
  16. package/dist/MdzRoot.svelte.d.ts +0 -12
  17. package/dist/MdzRoot.svelte.d.ts.map +0 -1
  18. package/dist/MdzStream.svelte +0 -32
  19. package/dist/MdzStream.svelte.d.ts +0 -12
  20. package/dist/MdzStream.svelte.d.ts.map +0 -1
  21. package/dist/MdzStreamNodeView.svelte +0 -106
  22. package/dist/MdzStreamNodeView.svelte.d.ts +0 -9
  23. package/dist/MdzStreamNodeView.svelte.d.ts.map +0 -1
  24. package/dist/mdz.d.ts +0 -112
  25. package/dist/mdz.d.ts.map +0 -1
  26. package/dist/mdz.js +0 -1186
  27. package/dist/mdz_components.d.ts +0 -63
  28. package/dist/mdz_components.d.ts.map +0 -1
  29. package/dist/mdz_components.js +0 -32
  30. package/dist/mdz_helpers.d.ts +0 -164
  31. package/dist/mdz_helpers.d.ts.map +0 -1
  32. package/dist/mdz_helpers.js +0 -424
  33. package/dist/mdz_lexer.d.ts +0 -93
  34. package/dist/mdz_lexer.d.ts.map +0 -1
  35. package/dist/mdz_lexer.js +0 -732
  36. package/dist/mdz_opcodes.d.ts +0 -174
  37. package/dist/mdz_opcodes.d.ts.map +0 -1
  38. package/dist/mdz_opcodes.js +0 -14
  39. package/dist/mdz_opcodes_to_nodes.d.ts +0 -20
  40. package/dist/mdz_opcodes_to_nodes.d.ts.map +0 -1
  41. package/dist/mdz_opcodes_to_nodes.js +0 -332
  42. package/dist/mdz_stream_parser.d.ts +0 -80
  43. package/dist/mdz_stream_parser.d.ts.map +0 -1
  44. package/dist/mdz_stream_parser.js +0 -354
  45. package/dist/mdz_stream_parser_block.d.ts +0 -76
  46. package/dist/mdz_stream_parser_block.d.ts.map +0 -1
  47. package/dist/mdz_stream_parser_block.js +0 -458
  48. package/dist/mdz_stream_parser_inline.d.ts +0 -52
  49. package/dist/mdz_stream_parser_inline.d.ts.map +0 -1
  50. package/dist/mdz_stream_parser_inline.js +0 -378
  51. package/dist/mdz_stream_parser_link.d.ts +0 -22
  52. package/dist/mdz_stream_parser_link.d.ts.map +0 -1
  53. package/dist/mdz_stream_parser_link.js +0 -215
  54. package/dist/mdz_stream_parser_state.d.ts +0 -187
  55. package/dist/mdz_stream_parser_state.d.ts.map +0 -1
  56. package/dist/mdz_stream_parser_state.js +0 -398
  57. package/dist/mdz_stream_parser_text.d.ts +0 -14
  58. package/dist/mdz_stream_parser_text.d.ts.map +0 -1
  59. package/dist/mdz_stream_parser_text.js +0 -50
  60. package/dist/mdz_stream_parser_url.d.ts +0 -60
  61. package/dist/mdz_stream_parser_url.d.ts.map +0 -1
  62. package/dist/mdz_stream_parser_url.js +0 -307
  63. package/dist/mdz_stream_state.svelte.d.ts +0 -44
  64. package/dist/mdz_stream_state.svelte.d.ts.map +0 -1
  65. package/dist/mdz_stream_state.svelte.js +0 -357
  66. package/dist/mdz_to_svelte.d.ts +0 -41
  67. package/dist/mdz_to_svelte.d.ts.map +0 -1
  68. package/dist/mdz_to_svelte.js +0 -100
  69. package/dist/mdz_token_parser.d.ts +0 -14
  70. package/dist/mdz_token_parser.d.ts.map +0 -1
  71. package/dist/mdz_token_parser.js +0 -344
  72. package/dist/svelte_preprocess_mdz.d.ts +0 -65
  73. package/dist/svelte_preprocess_mdz.d.ts.map +0 -1
  74. package/dist/svelte_preprocess_mdz.js +0 -529
  75. package/dist/tsdoc_mdz.d.ts +0 -45
  76. package/dist/tsdoc_mdz.d.ts.map +0 -1
  77. package/dist/tsdoc_mdz.js +0 -88
  78. package/src/lib/mdz.ts +0 -1532
  79. package/src/lib/mdz_components.ts +0 -64
  80. package/src/lib/mdz_helpers.ts +0 -449
  81. package/src/lib/mdz_lexer.ts +0 -1012
  82. package/src/lib/mdz_opcodes.ts +0 -205
  83. package/src/lib/mdz_opcodes_to_nodes.ts +0 -375
  84. package/src/lib/mdz_stream_parser.ts +0 -415
  85. package/src/lib/mdz_stream_parser_block.ts +0 -532
  86. package/src/lib/mdz_stream_parser_inline.ts +0 -414
  87. package/src/lib/mdz_stream_parser_link.ts +0 -271
  88. package/src/lib/mdz_stream_parser_state.ts +0 -539
  89. package/src/lib/mdz_stream_parser_text.ts +0 -77
  90. package/src/lib/mdz_stream_parser_url.ts +0 -365
  91. package/src/lib/mdz_stream_state.svelte.ts +0 -387
  92. package/src/lib/mdz_to_svelte.ts +0 -141
  93. package/src/lib/mdz_token_parser.ts +0 -434
  94. package/src/lib/svelte_preprocess_mdz.ts +0 -742
  95. package/src/lib/tsdoc_mdz.ts +0 -97
@@ -1,434 +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
-
10
- import type {
11
- MdzNode,
12
- MdzTextNode,
13
- MdzBoldNode,
14
- MdzItalicNode,
15
- MdzStrikethroughNode,
16
- MdzLinkNode,
17
- MdzHeadingNode,
18
- MdzElementNode,
19
- MdzComponentNode,
20
- } from './mdz.js';
21
- import {
22
- extract_single_tag,
23
- mdz_heading_id,
24
- mdz_merge_adjacent_text,
25
- mdz_push_merging_text,
26
- } from './mdz_helpers.js';
27
- import {
28
- MdzLexer,
29
- type MdzToken,
30
- type MdzTokenHeadingStart,
31
- type MdzTokenBoldOpen,
32
- type MdzTokenItalicOpen,
33
- type MdzTokenStrikethroughOpen,
34
- type MdzTokenLinkTextOpen,
35
- type MdzTokenLinkRef,
36
- type MdzTokenAutolink,
37
- type MdzTokenTagOpen,
38
- type MdzTokenTagSelfClose,
39
- } from './mdz_lexer.js';
40
-
41
- /**
42
- * Parses text to an array of `MdzNode` using a two-phase lexer+parser approach.
43
- */
44
- export const mdz_parse_lexer = (text: string): Array<MdzNode> => {
45
- const tokens = new MdzLexer(text).tokenize();
46
- return new MdzTokenParser(tokens).parse();
47
- };
48
-
49
- class MdzTokenParser {
50
- #tokens: Array<MdzToken>;
51
- #index: number = 0;
52
-
53
- constructor(tokens: Array<MdzToken>) {
54
- this.#tokens = tokens;
55
- }
56
-
57
- parse(): Array<MdzNode> {
58
- const root_nodes: Array<MdzNode> = [];
59
- const paragraph_children: Array<MdzNode> = [];
60
-
61
- while (this.#index < this.#tokens.length) {
62
- const token = this.#tokens[this.#index]!;
63
-
64
- // Block-level tokens
65
- if (token.type === 'heading_start') {
66
- const flushed = this.#flush_paragraph(paragraph_children, true);
67
- if (flushed) root_nodes.push(flushed);
68
- root_nodes.push(this.#parse_heading());
69
- continue;
70
- }
71
-
72
- if (token.type === 'hr') {
73
- const flushed = this.#flush_paragraph(paragraph_children, true);
74
- if (flushed) root_nodes.push(flushed);
75
- root_nodes.push({type: 'Hr', start: token.start, end: token.end});
76
- this.#index++;
77
- continue;
78
- }
79
-
80
- if (token.type === 'codeblock') {
81
- const flushed = this.#flush_paragraph(paragraph_children, true);
82
- if (flushed) root_nodes.push(flushed);
83
- root_nodes.push({
84
- type: 'Codeblock',
85
- lang: token.lang,
86
- content: token.content,
87
- start: token.start,
88
- end: token.end,
89
- });
90
- this.#index++;
91
- continue;
92
- }
93
-
94
- if (token.type === 'paragraph_break') {
95
- const flushed = this.#flush_paragraph(paragraph_children, true);
96
- if (flushed) root_nodes.push(flushed);
97
- this.#index++;
98
- continue;
99
- }
100
-
101
- // Inline tokens → paragraph children
102
- const node = this.#parse_inline();
103
- if (node) paragraph_children.push(node);
104
- }
105
-
106
- // Flush remaining content
107
- const final_paragraph = this.#flush_paragraph(paragraph_children, true);
108
- if (final_paragraph) root_nodes.push(final_paragraph);
109
-
110
- return root_nodes;
111
- }
112
-
113
- #parse_heading(): MdzHeadingNode {
114
- const token = this.#tokens[this.#index]! as MdzTokenHeadingStart;
115
- const start = token.start;
116
- const level = token.level;
117
- this.#index++;
118
-
119
- const children: Array<MdzNode> = [];
120
-
121
- // Collect inline nodes until heading_end marker
122
- while (this.#index < this.#tokens.length) {
123
- const t = this.#tokens[this.#index]!;
124
- if (t.type === 'heading_end') {
125
- this.#index++; // consume the marker
126
- break;
127
- }
128
- const node = this.#parse_inline();
129
- if (node) children.push(node);
130
- }
131
-
132
- const merged = mdz_merge_adjacent_text(children);
133
- const end = merged.length > 0 ? merged[merged.length - 1]!.end : start + level + 1;
134
-
135
- return {type: 'Heading', level, id: mdz_heading_id(merged), children: merged, start, end};
136
- }
137
-
138
- #parse_inline(): MdzNode | null {
139
- if (this.#index >= this.#tokens.length) return null;
140
-
141
- const token = this.#tokens[this.#index]!;
142
-
143
- switch (token.type) {
144
- case 'text':
145
- this.#index++;
146
- return {type: 'Text', content: token.content, start: token.start, end: token.end};
147
-
148
- case 'code':
149
- this.#index++;
150
- return {type: 'Code', content: token.content, start: token.start, end: token.end};
151
-
152
- case 'bold_open':
153
- return this.#parse_bold();
154
-
155
- case 'italic_open':
156
- return this.#parse_italic();
157
-
158
- case 'strikethrough_open':
159
- return this.#parse_strikethrough();
160
-
161
- case 'link_text_open':
162
- return this.#parse_link();
163
-
164
- case 'autolink':
165
- return this.#parse_autolink();
166
-
167
- case 'tag_open':
168
- return this.#parse_tag_node();
169
-
170
- case 'tag_self_close':
171
- return this.#parse_self_close_tag();
172
-
173
- // Orphaned close tokens - treat as text
174
- case 'bold_close':
175
- this.#index++;
176
- return {type: 'Text', content: '**', start: token.start, end: token.end};
177
-
178
- case 'italic_close':
179
- this.#index++;
180
- return {type: 'Text', content: '_', start: token.start, end: token.end};
181
-
182
- case 'strikethrough_close':
183
- this.#index++;
184
- return {type: 'Text', content: '~', start: token.start, end: token.end};
185
-
186
- case 'link_text_close':
187
- this.#index++;
188
- return {type: 'Text', content: ']', start: token.start, end: token.end};
189
-
190
- case 'link_ref':
191
- this.#index++;
192
- return {
193
- type: 'Text',
194
- content: `(${token.reference})`,
195
- start: token.start,
196
- end: token.end,
197
- };
198
-
199
- case 'tag_close':
200
- this.#index++;
201
- return {
202
- type: 'Text',
203
- content: `</${token.name}>`,
204
- start: token.start,
205
- end: token.end,
206
- };
207
-
208
- default:
209
- this.#index++;
210
- return null;
211
- }
212
- }
213
-
214
- #parse_bold(): MdzBoldNode | MdzTextNode {
215
- const token = this.#tokens[this.#index]! as MdzTokenBoldOpen;
216
- const start = token.start;
217
- this.#index++;
218
-
219
- const children: Array<MdzNode> = [];
220
-
221
- while (this.#index < this.#tokens.length) {
222
- const t = this.#tokens[this.#index]!;
223
- if (t.type === 'bold_close') {
224
- this.#index++;
225
- return {type: 'Bold', children, start, end: t.end};
226
- }
227
- if (
228
- t.type === 'paragraph_break' ||
229
- t.type === 'heading_start' ||
230
- t.type === 'hr' ||
231
- t.type === 'codeblock'
232
- ) {
233
- break;
234
- }
235
- const node = this.#parse_inline();
236
- if (node) mdz_push_merging_text(children, node);
237
- }
238
-
239
- // Unclosed - treat as text
240
- return {type: 'Text', content: '**', start, end: start + 2};
241
- }
242
-
243
- #parse_italic(): MdzItalicNode | MdzTextNode {
244
- const token = this.#tokens[this.#index]! as MdzTokenItalicOpen;
245
- const start = token.start;
246
- this.#index++;
247
-
248
- const children: Array<MdzNode> = [];
249
-
250
- while (this.#index < this.#tokens.length) {
251
- const t = this.#tokens[this.#index]!;
252
- if (t.type === 'italic_close') {
253
- this.#index++;
254
- return {type: 'Italic', children, start, end: t.end};
255
- }
256
- if (
257
- t.type === 'paragraph_break' ||
258
- t.type === 'heading_start' ||
259
- t.type === 'hr' ||
260
- t.type === 'codeblock'
261
- ) {
262
- break;
263
- }
264
- const node = this.#parse_inline();
265
- if (node) mdz_push_merging_text(children, node);
266
- }
267
-
268
- return {type: 'Text', content: '_', start, end: start + 1};
269
- }
270
-
271
- #parse_strikethrough(): MdzStrikethroughNode | MdzTextNode {
272
- const token = this.#tokens[this.#index]! as MdzTokenStrikethroughOpen;
273
- const start = token.start;
274
- this.#index++;
275
-
276
- const children: Array<MdzNode> = [];
277
-
278
- while (this.#index < this.#tokens.length) {
279
- const t = this.#tokens[this.#index]!;
280
- if (t.type === 'strikethrough_close') {
281
- this.#index++;
282
- return {type: 'Strikethrough', children, start, end: t.end};
283
- }
284
- if (
285
- t.type === 'paragraph_break' ||
286
- t.type === 'heading_start' ||
287
- t.type === 'hr' ||
288
- t.type === 'codeblock'
289
- ) {
290
- break;
291
- }
292
- const node = this.#parse_inline();
293
- if (node) mdz_push_merging_text(children, node);
294
- }
295
-
296
- return {type: 'Text', content: '~', start, end: start + 1};
297
- }
298
-
299
- #parse_link(): MdzLinkNode | MdzTextNode {
300
- const open_token = this.#tokens[this.#index]! as MdzTokenLinkTextOpen;
301
- const start = open_token.start;
302
- this.#index++;
303
-
304
- const children: Array<MdzNode> = [];
305
-
306
- while (this.#index < this.#tokens.length) {
307
- const t = this.#tokens[this.#index]!;
308
- if (t.type === 'link_text_close') {
309
- this.#index++;
310
-
311
- // Expect link_ref next
312
- if (this.#index < this.#tokens.length && this.#tokens[this.#index]!.type === 'link_ref') {
313
- const ref_token = this.#tokens[this.#index]! as MdzTokenLinkRef;
314
- this.#index++;
315
- return {
316
- type: 'Link',
317
- reference: ref_token.reference,
318
- children,
319
- link_type: ref_token.link_type,
320
- start,
321
- end: ref_token.end,
322
- };
323
- }
324
-
325
- // No link_ref - treat as text
326
- return {type: 'Text', content: '[', start, end: start + 1};
327
- }
328
- if (
329
- t.type === 'paragraph_break' ||
330
- t.type === 'heading_start' ||
331
- t.type === 'hr' ||
332
- t.type === 'codeblock'
333
- ) {
334
- break;
335
- }
336
- const node = this.#parse_inline();
337
- if (node) mdz_push_merging_text(children, node);
338
- }
339
-
340
- return {type: 'Text', content: '[', start, end: start + 1};
341
- }
342
-
343
- #parse_autolink(): MdzLinkNode {
344
- const token = this.#tokens[this.#index]! as MdzTokenAutolink;
345
- this.#index++;
346
- return {
347
- type: 'Link',
348
- reference: token.reference,
349
- children: [{type: 'Text', content: token.reference, start: token.start, end: token.end}],
350
- link_type: token.link_type,
351
- start: token.start,
352
- end: token.end,
353
- };
354
- }
355
-
356
- #parse_tag_node(): MdzElementNode | MdzComponentNode | MdzTextNode {
357
- const open_token = this.#tokens[this.#index]! as MdzTokenTagOpen;
358
- const start = open_token.start;
359
- const tag_name = open_token.name;
360
- const node_type: 'Component' | 'Element' = open_token.is_component ? 'Component' : 'Element';
361
- this.#index++;
362
-
363
- const children: Array<MdzNode> = [];
364
-
365
- while (this.#index < this.#tokens.length) {
366
- const t = this.#tokens[this.#index]!;
367
- if (t.type === 'tag_close' && t.name === tag_name) {
368
- this.#index++;
369
- return {type: node_type, name: tag_name, children, start, end: t.end};
370
- }
371
- const node = this.#parse_inline();
372
- if (node) mdz_push_merging_text(children, node);
373
- }
374
-
375
- // Unclosed tag
376
- return {type: 'Text', content: '<', start, end: start + 1};
377
- }
378
-
379
- #parse_self_close_tag(): MdzElementNode | MdzComponentNode {
380
- const token = this.#tokens[this.#index]! as MdzTokenTagSelfClose;
381
- const node_type: 'Component' | 'Element' = token.is_component ? 'Component' : 'Element';
382
- this.#index++;
383
- return {type: node_type, name: token.name, children: [], start: token.start, end: token.end};
384
- }
385
-
386
- // -- Paragraph flushing --
387
-
388
- #flush_paragraph(paragraph_children: Array<MdzNode>, trim_trailing = false): MdzNode | null {
389
- if (paragraph_children.length === 0) return null;
390
-
391
- if (trim_trailing) {
392
- // Trim trailing newlines from last text node
393
- const last = paragraph_children[paragraph_children.length - 1]!;
394
- if (last.type === 'Text') {
395
- const trimmed = last.content.replace(/\n+$/, '');
396
- if (trimmed) {
397
- last.content = trimmed;
398
- last.end = last.start + trimmed.length;
399
- } else {
400
- paragraph_children.pop();
401
- }
402
- }
403
-
404
- // Skip whitespace-only paragraphs
405
- const has_content = paragraph_children.some(
406
- (n) => n.type !== 'Text' || n.content.trim().length > 0,
407
- );
408
- if (!has_content) {
409
- paragraph_children.length = 0;
410
- return null;
411
- }
412
- }
413
-
414
- // Single tag extraction (MDX convention)
415
- const single_tag = extract_single_tag(paragraph_children);
416
- if (single_tag) {
417
- paragraph_children.length = 0;
418
- return single_tag;
419
- }
420
-
421
- // Merge adjacent text nodes
422
- const merged = mdz_merge_adjacent_text(paragraph_children.slice());
423
- paragraph_children.length = 0;
424
-
425
- if (merged.length === 0) return null;
426
-
427
- return {
428
- type: 'Paragraph',
429
- children: merged,
430
- start: merged[0]!.start,
431
- end: merged[merged.length - 1]!.end,
432
- };
433
- }
434
- }