@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,344 +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 { extract_single_tag, mdz_heading_id, mdz_merge_adjacent_text, mdz_push_merging_text, } from './mdz_helpers.js';
10
- import { MdzLexer, } from './mdz_lexer.js';
11
- /**
12
- * Parses text to an array of `MdzNode` using a two-phase lexer+parser approach.
13
- */
14
- export const mdz_parse_lexer = (text) => {
15
- const tokens = new MdzLexer(text).tokenize();
16
- return new MdzTokenParser(tokens).parse();
17
- };
18
- class MdzTokenParser {
19
- #tokens;
20
- #index = 0;
21
- constructor(tokens) {
22
- this.#tokens = tokens;
23
- }
24
- parse() {
25
- const root_nodes = [];
26
- const paragraph_children = [];
27
- while (this.#index < this.#tokens.length) {
28
- const token = this.#tokens[this.#index];
29
- // Block-level tokens
30
- if (token.type === 'heading_start') {
31
- const flushed = this.#flush_paragraph(paragraph_children, true);
32
- if (flushed)
33
- root_nodes.push(flushed);
34
- root_nodes.push(this.#parse_heading());
35
- continue;
36
- }
37
- if (token.type === 'hr') {
38
- const flushed = this.#flush_paragraph(paragraph_children, true);
39
- if (flushed)
40
- root_nodes.push(flushed);
41
- root_nodes.push({ type: 'Hr', start: token.start, end: token.end });
42
- this.#index++;
43
- continue;
44
- }
45
- if (token.type === 'codeblock') {
46
- const flushed = this.#flush_paragraph(paragraph_children, true);
47
- if (flushed)
48
- root_nodes.push(flushed);
49
- root_nodes.push({
50
- type: 'Codeblock',
51
- lang: token.lang,
52
- content: token.content,
53
- start: token.start,
54
- end: token.end,
55
- });
56
- this.#index++;
57
- continue;
58
- }
59
- if (token.type === 'paragraph_break') {
60
- const flushed = this.#flush_paragraph(paragraph_children, true);
61
- if (flushed)
62
- root_nodes.push(flushed);
63
- this.#index++;
64
- continue;
65
- }
66
- // Inline tokens → paragraph children
67
- const node = this.#parse_inline();
68
- if (node)
69
- paragraph_children.push(node);
70
- }
71
- // Flush remaining content
72
- const final_paragraph = this.#flush_paragraph(paragraph_children, true);
73
- if (final_paragraph)
74
- root_nodes.push(final_paragraph);
75
- return root_nodes;
76
- }
77
- #parse_heading() {
78
- const token = this.#tokens[this.#index];
79
- const start = token.start;
80
- const level = token.level;
81
- this.#index++;
82
- const children = [];
83
- // Collect inline nodes until heading_end marker
84
- while (this.#index < this.#tokens.length) {
85
- const t = this.#tokens[this.#index];
86
- if (t.type === 'heading_end') {
87
- this.#index++; // consume the marker
88
- break;
89
- }
90
- const node = this.#parse_inline();
91
- if (node)
92
- children.push(node);
93
- }
94
- const merged = mdz_merge_adjacent_text(children);
95
- const end = merged.length > 0 ? merged[merged.length - 1].end : start + level + 1;
96
- return { type: 'Heading', level, id: mdz_heading_id(merged), children: merged, start, end };
97
- }
98
- #parse_inline() {
99
- if (this.#index >= this.#tokens.length)
100
- return null;
101
- const token = this.#tokens[this.#index];
102
- switch (token.type) {
103
- case 'text':
104
- this.#index++;
105
- return { type: 'Text', content: token.content, start: token.start, end: token.end };
106
- case 'code':
107
- this.#index++;
108
- return { type: 'Code', content: token.content, start: token.start, end: token.end };
109
- case 'bold_open':
110
- return this.#parse_bold();
111
- case 'italic_open':
112
- return this.#parse_italic();
113
- case 'strikethrough_open':
114
- return this.#parse_strikethrough();
115
- case 'link_text_open':
116
- return this.#parse_link();
117
- case 'autolink':
118
- return this.#parse_autolink();
119
- case 'tag_open':
120
- return this.#parse_tag_node();
121
- case 'tag_self_close':
122
- return this.#parse_self_close_tag();
123
- // Orphaned close tokens - treat as text
124
- case 'bold_close':
125
- this.#index++;
126
- return { type: 'Text', content: '**', start: token.start, end: token.end };
127
- case 'italic_close':
128
- this.#index++;
129
- return { type: 'Text', content: '_', start: token.start, end: token.end };
130
- case 'strikethrough_close':
131
- this.#index++;
132
- return { type: 'Text', content: '~', start: token.start, end: token.end };
133
- case 'link_text_close':
134
- this.#index++;
135
- return { type: 'Text', content: ']', start: token.start, end: token.end };
136
- case 'link_ref':
137
- this.#index++;
138
- return {
139
- type: 'Text',
140
- content: `(${token.reference})`,
141
- start: token.start,
142
- end: token.end,
143
- };
144
- case 'tag_close':
145
- this.#index++;
146
- return {
147
- type: 'Text',
148
- content: `</${token.name}>`,
149
- start: token.start,
150
- end: token.end,
151
- };
152
- default:
153
- this.#index++;
154
- return null;
155
- }
156
- }
157
- #parse_bold() {
158
- const token = this.#tokens[this.#index];
159
- const start = token.start;
160
- this.#index++;
161
- const children = [];
162
- while (this.#index < this.#tokens.length) {
163
- const t = this.#tokens[this.#index];
164
- if (t.type === 'bold_close') {
165
- this.#index++;
166
- return { type: 'Bold', children, start, end: t.end };
167
- }
168
- if (t.type === 'paragraph_break' ||
169
- t.type === 'heading_start' ||
170
- t.type === 'hr' ||
171
- t.type === 'codeblock') {
172
- break;
173
- }
174
- const node = this.#parse_inline();
175
- if (node)
176
- mdz_push_merging_text(children, node);
177
- }
178
- // Unclosed - treat as text
179
- return { type: 'Text', content: '**', start, end: start + 2 };
180
- }
181
- #parse_italic() {
182
- const token = this.#tokens[this.#index];
183
- const start = token.start;
184
- this.#index++;
185
- const children = [];
186
- while (this.#index < this.#tokens.length) {
187
- const t = this.#tokens[this.#index];
188
- if (t.type === 'italic_close') {
189
- this.#index++;
190
- return { type: 'Italic', children, start, end: t.end };
191
- }
192
- if (t.type === 'paragraph_break' ||
193
- t.type === 'heading_start' ||
194
- t.type === 'hr' ||
195
- t.type === 'codeblock') {
196
- break;
197
- }
198
- const node = this.#parse_inline();
199
- if (node)
200
- mdz_push_merging_text(children, node);
201
- }
202
- return { type: 'Text', content: '_', start, end: start + 1 };
203
- }
204
- #parse_strikethrough() {
205
- const token = this.#tokens[this.#index];
206
- const start = token.start;
207
- this.#index++;
208
- const children = [];
209
- while (this.#index < this.#tokens.length) {
210
- const t = this.#tokens[this.#index];
211
- if (t.type === 'strikethrough_close') {
212
- this.#index++;
213
- return { type: 'Strikethrough', children, start, end: t.end };
214
- }
215
- if (t.type === 'paragraph_break' ||
216
- t.type === 'heading_start' ||
217
- t.type === 'hr' ||
218
- t.type === 'codeblock') {
219
- break;
220
- }
221
- const node = this.#parse_inline();
222
- if (node)
223
- mdz_push_merging_text(children, node);
224
- }
225
- return { type: 'Text', content: '~', start, end: start + 1 };
226
- }
227
- #parse_link() {
228
- const open_token = this.#tokens[this.#index];
229
- const start = open_token.start;
230
- this.#index++;
231
- const children = [];
232
- while (this.#index < this.#tokens.length) {
233
- const t = this.#tokens[this.#index];
234
- if (t.type === 'link_text_close') {
235
- this.#index++;
236
- // Expect link_ref next
237
- if (this.#index < this.#tokens.length && this.#tokens[this.#index].type === 'link_ref') {
238
- const ref_token = this.#tokens[this.#index];
239
- this.#index++;
240
- return {
241
- type: 'Link',
242
- reference: ref_token.reference,
243
- children,
244
- link_type: ref_token.link_type,
245
- start,
246
- end: ref_token.end,
247
- };
248
- }
249
- // No link_ref - treat as text
250
- return { type: 'Text', content: '[', start, end: start + 1 };
251
- }
252
- if (t.type === 'paragraph_break' ||
253
- t.type === 'heading_start' ||
254
- t.type === 'hr' ||
255
- t.type === 'codeblock') {
256
- break;
257
- }
258
- const node = this.#parse_inline();
259
- if (node)
260
- mdz_push_merging_text(children, node);
261
- }
262
- return { type: 'Text', content: '[', start, end: start + 1 };
263
- }
264
- #parse_autolink() {
265
- const token = this.#tokens[this.#index];
266
- this.#index++;
267
- return {
268
- type: 'Link',
269
- reference: token.reference,
270
- children: [{ type: 'Text', content: token.reference, start: token.start, end: token.end }],
271
- link_type: token.link_type,
272
- start: token.start,
273
- end: token.end,
274
- };
275
- }
276
- #parse_tag_node() {
277
- const open_token = this.#tokens[this.#index];
278
- const start = open_token.start;
279
- const tag_name = open_token.name;
280
- const node_type = open_token.is_component ? 'Component' : 'Element';
281
- this.#index++;
282
- const children = [];
283
- while (this.#index < this.#tokens.length) {
284
- const t = this.#tokens[this.#index];
285
- if (t.type === 'tag_close' && t.name === tag_name) {
286
- this.#index++;
287
- return { type: node_type, name: tag_name, children, start, end: t.end };
288
- }
289
- const node = this.#parse_inline();
290
- if (node)
291
- mdz_push_merging_text(children, node);
292
- }
293
- // Unclosed tag
294
- return { type: 'Text', content: '<', start, end: start + 1 };
295
- }
296
- #parse_self_close_tag() {
297
- const token = this.#tokens[this.#index];
298
- const node_type = token.is_component ? 'Component' : 'Element';
299
- this.#index++;
300
- return { type: node_type, name: token.name, children: [], start: token.start, end: token.end };
301
- }
302
- // -- Paragraph flushing --
303
- #flush_paragraph(paragraph_children, trim_trailing = false) {
304
- if (paragraph_children.length === 0)
305
- return null;
306
- if (trim_trailing) {
307
- // Trim trailing newlines from last text node
308
- const last = paragraph_children[paragraph_children.length - 1];
309
- if (last.type === 'Text') {
310
- const trimmed = last.content.replace(/\n+$/, '');
311
- if (trimmed) {
312
- last.content = trimmed;
313
- last.end = last.start + trimmed.length;
314
- }
315
- else {
316
- paragraph_children.pop();
317
- }
318
- }
319
- // Skip whitespace-only paragraphs
320
- const has_content = paragraph_children.some((n) => n.type !== 'Text' || n.content.trim().length > 0);
321
- if (!has_content) {
322
- paragraph_children.length = 0;
323
- return null;
324
- }
325
- }
326
- // Single tag extraction (MDX convention)
327
- const single_tag = extract_single_tag(paragraph_children);
328
- if (single_tag) {
329
- paragraph_children.length = 0;
330
- return single_tag;
331
- }
332
- // Merge adjacent text nodes
333
- const merged = mdz_merge_adjacent_text(paragraph_children.slice());
334
- paragraph_children.length = 0;
335
- if (merged.length === 0)
336
- return null;
337
- return {
338
- type: 'Paragraph',
339
- children: merged,
340
- start: merged[0].start,
341
- end: merged[merged.length - 1].end,
342
- };
343
- }
344
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * Svelte preprocessor that compiles static `Mdz` content to Svelte markup at build time.
3
- *
4
- * Detects `Mdz` components with static string `content` props, parses the mdz content,
5
- * renders each `MdzNode` to equivalent Svelte markup via `mdz_to_svelte`, and replaces
6
- * the `Mdz` with `MdzPrecompiled` containing pre-rendered children.
7
- *
8
- * Also handles ternary chains (`content={a ? 'x' : b ? 'y' : 'z'}`) where all leaf
9
- * values are statically resolvable strings, emitting `{#if a}markup_x{:else if b}markup_y{:else}markup_z{/if}`
10
- * as children of a single `MdzPrecompiled`.
11
- *
12
- * Truly dynamic `content` props are left untouched.
13
- *
14
- * @module
15
- */
16
- import { type PreprocessorGroup } from 'svelte/compiler';
17
- /**
18
- * Options for `svelte_preprocess_mdz`.
19
- */
20
- export interface SveltePreprocessMdzOptions {
21
- /** File patterns to exclude. */
22
- exclude?: Array<string | RegExp>;
23
- /**
24
- * Component import mapping for mdz content.
25
- * Key: component name as used in mdz (e.g., 'Alert').
26
- * Value: import path (e.g., '$lib/Alert.svelte').
27
- *
28
- * If mdz content references a component not in this map,
29
- * that `Mdz` usage is skipped (left as runtime).
30
- */
31
- components?: Record<string, string>;
32
- /**
33
- * Allowed HTML elements in mdz content.
34
- * If mdz content references an element not in this list,
35
- * that `Mdz` usage is skipped (left as runtime).
36
- */
37
- elements?: Array<string>;
38
- /**
39
- * Import sources that resolve to the `Mdz` component.
40
- * Used to verify that `Mdz` in templates refers to fuz_ui's `Mdz.svelte`.
41
- *
42
- * @default ['@fuzdev/fuz_ui/Mdz.svelte']
43
- */
44
- component_imports?: Array<string>;
45
- /**
46
- * Import path for the precompiled wrapper component.
47
- *
48
- * @default '@fuzdev/fuz_ui/MdzPrecompiled.svelte'
49
- */
50
- compiled_component_import?: string;
51
- /**
52
- * How to handle errors during mdz parsing or rendering.
53
- *
54
- * @default 'throw' in CI, 'log' otherwise
55
- */
56
- on_error?: 'log' | 'throw';
57
- }
58
- /**
59
- * Creates a Svelte preprocessor that compiles static `Mdz` content at build time.
60
- *
61
- * @param options - configuration for component/element resolution and file filtering
62
- * @returns a Svelte `PreprocessorGroup` for use in `svelte.config.js`
63
- */
64
- export declare const svelte_preprocess_mdz: (options?: SveltePreprocessMdzOptions) => PreprocessorGroup;
65
- //# sourceMappingURL=svelte_preprocess_mdz.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"svelte_preprocess_mdz.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte_preprocess_mdz.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAQ,KAAK,iBAAiB,EAAW,MAAM,iBAAiB,CAAC;AA+BxE;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,gCAAgC;IAChC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEjC;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAEzB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAElC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;CAC3B;AAID;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GACjC,UAAS,0BAA+B,KACtC,iBAsFF,CAAC"}