@fuzdev/mdz 0.3.0 → 0.4.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 (68) hide show
  1. package/README.md +4 -0
  2. package/dist/Mdz.svelte +8 -7
  3. package/dist/Mdz.svelte.d.ts.map +1 -1
  4. package/dist/MdzNodeView.svelte +20 -12
  5. package/dist/MdzNodeView.svelte.d.ts +1 -2
  6. package/dist/MdzNodeView.svelte.d.ts.map +1 -1
  7. package/dist/MdzPrecompiled.svelte +3 -3
  8. package/dist/MdzPrecompiled.svelte.d.ts.map +1 -1
  9. package/dist/MdzRoot.svelte +3 -3
  10. package/dist/MdzRoot.svelte.d.ts.map +1 -1
  11. package/dist/MdzStream.svelte +3 -3
  12. package/dist/MdzStream.svelte.d.ts.map +1 -1
  13. package/dist/MdzStreamNodeView.svelte +21 -13
  14. package/dist/MdzStreamNodeView.svelte.d.ts +1 -2
  15. package/dist/MdzStreamNodeView.svelte.d.ts.map +1 -1
  16. package/dist/context_helpers.js +1 -1
  17. package/dist/mdz_contexts.d.ts.map +1 -1
  18. package/dist/mdz_debug_work.d.ts.map +1 -1
  19. package/dist/mdz_helpers.d.ts.map +1 -1
  20. package/dist/mdz_helpers.js +2 -2
  21. package/dist/mdz_lexer.d.ts.map +1 -1
  22. package/dist/mdz_lexer.js +27 -17
  23. package/dist/mdz_opcodes.d.ts.map +1 -1
  24. package/dist/mdz_opcodes_to_nodes.d.ts.map +1 -1
  25. package/dist/mdz_opcodes_to_nodes.js +22 -17
  26. package/dist/mdz_stream_parser.d.ts.map +1 -1
  27. package/dist/mdz_stream_parser.js +8 -8
  28. package/dist/mdz_stream_parser_block.js +5 -5
  29. package/dist/mdz_stream_parser_inline.js +4 -4
  30. package/dist/mdz_stream_parser_link.js +3 -3
  31. package/dist/mdz_stream_parser_list.d.ts.map +1 -1
  32. package/dist/mdz_stream_parser_list.js +13 -7
  33. package/dist/mdz_stream_parser_state.d.ts.map +1 -1
  34. package/dist/mdz_stream_parser_state.js +7 -7
  35. package/dist/mdz_stream_parser_table.d.ts.map +1 -1
  36. package/dist/mdz_stream_parser_table.js +8 -8
  37. package/dist/mdz_stream_parser_text.js +2 -2
  38. package/dist/mdz_stream_parser_url.js +7 -7
  39. package/dist/mdz_stream_state.svelte.d.ts.map +1 -1
  40. package/dist/mdz_to_svelte.d.ts +1 -1
  41. package/dist/mdz_to_svelte.d.ts.map +1 -1
  42. package/dist/mdz_token_parser.js +9 -9
  43. package/dist/svelte_preprocess_mdz.d.ts +2 -2
  44. package/dist/svelte_preprocess_mdz.d.ts.map +1 -1
  45. package/dist/svelte_preprocess_mdz.js +11 -11
  46. package/package.json +24 -39
  47. package/src/lib/context_helpers.ts +2 -2
  48. package/src/lib/mdz.ts +2 -2
  49. package/src/lib/mdz_contexts.ts +5 -5
  50. package/src/lib/mdz_debug_work.ts +1 -1
  51. package/src/lib/mdz_helpers.ts +39 -33
  52. package/src/lib/mdz_lexer.ts +77 -67
  53. package/src/lib/mdz_opcodes.ts +1 -1
  54. package/src/lib/mdz_opcodes_to_nodes.ts +35 -30
  55. package/src/lib/mdz_stream_parser.ts +17 -17
  56. package/src/lib/mdz_stream_parser_block.ts +14 -14
  57. package/src/lib/mdz_stream_parser_inline.ts +18 -18
  58. package/src/lib/mdz_stream_parser_link.ts +13 -13
  59. package/src/lib/mdz_stream_parser_list.ts +31 -25
  60. package/src/lib/mdz_stream_parser_state.ts +27 -27
  61. package/src/lib/mdz_stream_parser_table.ts +31 -31
  62. package/src/lib/mdz_stream_parser_text.ts +3 -3
  63. package/src/lib/mdz_stream_parser_url.ts +11 -11
  64. package/src/lib/mdz_stream_state.svelte.ts +8 -8
  65. package/src/lib/mdz_to_svelte.ts +16 -16
  66. package/src/lib/mdz_token_parser.ts +38 -38
  67. package/src/lib/svelte_preprocess_mdz.ts +62 -58
  68. package/src/lib/tsdoc_mdz.ts +1 -1
@@ -22,14 +22,14 @@ import type {
22
22
  MdzNodeTableRow,
23
23
  MdzNodeTableCell,
24
24
  MdzNodeElement,
25
- MdzNodeComponent,
25
+ MdzNodeComponent
26
26
  } from './mdz.ts';
27
27
  import {
28
28
  has_non_whitespace,
29
29
  mdz_extract_single_tag,
30
30
  mdz_heading_id,
31
31
  mdz_merge_adjacent_text,
32
- mdz_push_merging_text,
32
+ mdz_push_merging_text
33
33
  } from './mdz_helpers.ts';
34
34
  import {
35
35
  type MdzToken,
@@ -43,7 +43,7 @@ import {
43
43
  type MdzTokenListItemOpen,
44
44
  type MdzTokenTableOpen,
45
45
  type MdzTokenTableRowOpen,
46
- type MdzTokenTableCellOpen,
46
+ type MdzTokenTableCellOpen
47
47
  } from './mdz_lexer.ts';
48
48
 
49
49
  /**
@@ -134,7 +134,7 @@ export class MdzTokenParser {
134
134
  if (token.type === 'hr') {
135
135
  const flushed = this.#flush_paragraph(paragraph_children, true);
136
136
  if (flushed) nodes.push(flushed);
137
- nodes.push({type: 'Hr', start: token.start, end: token.end});
137
+ nodes.push({ type: 'Hr', start: token.start, end: token.end });
138
138
  this.#index++;
139
139
  continue;
140
140
  }
@@ -147,7 +147,7 @@ export class MdzTokenParser {
147
147
  lang: token.lang,
148
148
  content: token.content,
149
149
  start: token.start,
150
- end: token.end,
150
+ end: token.end
151
151
  });
152
152
  this.#index++;
153
153
  continue;
@@ -200,7 +200,7 @@ export class MdzTokenParser {
200
200
  // children-derived end, like List — no-empty-start means children exist,
201
201
  // with the open's position as a defensive fallback
202
202
  const end = children.length > 0 ? children[children.length - 1]!.end : open.end;
203
- return {type: 'Blockquote', children, start: open.start, end};
203
+ return { type: 'Blockquote', children, start: open.start, end };
204
204
  }
205
205
 
206
206
  #parse_table(): MdzNodeTable {
@@ -223,7 +223,7 @@ export class MdzTokenParser {
223
223
  }
224
224
 
225
225
  const end = rows.length > 0 ? rows[rows.length - 1]!.end : open.end;
226
- return {type: 'Table', align: open.align, children: rows, start: open.start, end};
226
+ return { type: 'Table', align: open.align, children: rows, start: open.start, end };
227
227
  }
228
228
 
229
229
  #parse_table_row(): MdzNodeTableRow {
@@ -241,13 +241,13 @@ export class MdzTokenParser {
241
241
  }
242
242
  if (t.type === 'table_row_close') {
243
243
  this.#index++;
244
- return {type: 'TableRow', header, children: cells, start: open.start, end: t.end};
244
+ return { type: 'TableRow', header, children: cells, start: open.start, end: t.end };
245
245
  }
246
246
  this.#index++; // skip anything unexpected (defensive)
247
247
  }
248
248
 
249
249
  const end = cells.length > 0 ? cells[cells.length - 1]!.end : open.end;
250
- return {type: 'TableRow', header, children: cells, start: open.start, end};
250
+ return { type: 'TableRow', header, children: cells, start: open.start, end };
251
251
  }
252
252
 
253
253
  #parse_table_cell(): MdzNodeTableCell {
@@ -261,14 +261,14 @@ export class MdzTokenParser {
261
261
  const t = this.#tokens[this.#index]!;
262
262
  if (t.type === 'table_cell_close') {
263
263
  this.#index++;
264
- return {type: 'TableCell', children, start, end: t.end};
264
+ return { type: 'TableCell', children, start, end: t.end };
265
265
  }
266
266
  const node = this.#parse_inline();
267
267
  if (node) mdz_push_merging_text(children, node);
268
268
  }
269
269
 
270
270
  const end = children.length > 0 ? children[children.length - 1]!.end : open.end;
271
- return {type: 'TableCell', children, start, end};
271
+ return { type: 'TableCell', children, start, end };
272
272
  }
273
273
 
274
274
  #parse_heading(): MdzNodeHeading {
@@ -293,7 +293,7 @@ export class MdzTokenParser {
293
293
  const merged = mdz_merge_adjacent_text(children);
294
294
  const end = merged.length > 0 ? merged[merged.length - 1]!.end : start + level + 1;
295
295
 
296
- return {type: 'Heading', level, id: mdz_heading_id(merged), children: merged, start, end};
296
+ return { type: 'Heading', level, id: mdz_heading_id(merged), children: merged, start, end };
297
297
  }
298
298
 
299
299
  #parse_list(): MdzNodeList {
@@ -323,10 +323,10 @@ export class MdzTokenParser {
323
323
  start_number: children[0]?.number ?? 1,
324
324
  children,
325
325
  start: open.start,
326
- end,
326
+ end
327
327
  };
328
328
  }
329
- return {type: 'List', ordered: false, children, start: open.start, end};
329
+ return { type: 'List', ordered: false, children, start: open.start, end };
330
330
  }
331
331
 
332
332
  #parse_list_item(): MdzNodeListItem {
@@ -376,7 +376,7 @@ export class MdzTokenParser {
376
376
  lang: t.lang,
377
377
  content: t.content,
378
378
  start: t.start,
379
- end: t.end,
379
+ end: t.end
380
380
  });
381
381
  this.#index++;
382
382
  continue;
@@ -400,9 +400,9 @@ export class MdzTokenParser {
400
400
 
401
401
  const end = children.length > 0 ? children[children.length - 1]!.end : open.end;
402
402
  if (open.number !== undefined) {
403
- return {type: 'ListItem', number: open.number, children, start: open.start, end};
403
+ return { type: 'ListItem', number: open.number, children, start: open.start, end };
404
404
  }
405
- return {type: 'ListItem', children, start: open.start, end};
405
+ return { type: 'ListItem', children, start: open.start, end };
406
406
  }
407
407
 
408
408
  #parse_inline(): MdzNode | null {
@@ -413,11 +413,11 @@ export class MdzTokenParser {
413
413
  switch (token.type) {
414
414
  case 'text':
415
415
  this.#index++;
416
- return {type: 'Text', content: token.content, start: token.start, end: token.end};
416
+ return { type: 'Text', content: token.content, start: token.start, end: token.end };
417
417
 
418
418
  case 'code':
419
419
  this.#index++;
420
- return {type: 'Code', content: token.content, start: token.start, end: token.end};
420
+ return { type: 'Code', content: token.content, start: token.start, end: token.end };
421
421
 
422
422
  case 'bold_open':
423
423
  return this.#parse_delimiter_pair('bold_close', 'Bold', '**');
@@ -443,19 +443,19 @@ export class MdzTokenParser {
443
443
  // Orphaned close tokens - treat as text
444
444
  case 'bold_close':
445
445
  this.#index++;
446
- return {type: 'Text', content: '**', start: token.start, end: token.end};
446
+ return { type: 'Text', content: '**', start: token.start, end: token.end };
447
447
 
448
448
  case 'italic_close':
449
449
  this.#index++;
450
- return {type: 'Text', content: '_', start: token.start, end: token.end};
450
+ return { type: 'Text', content: '_', start: token.start, end: token.end };
451
451
 
452
452
  case 'strikethrough_close':
453
453
  this.#index++;
454
- return {type: 'Text', content: '~~', start: token.start, end: token.end};
454
+ return { type: 'Text', content: '~~', start: token.start, end: token.end };
455
455
 
456
456
  case 'link_text_close':
457
457
  this.#index++;
458
- return {type: 'Text', content: ']', start: token.start, end: token.end};
458
+ return { type: 'Text', content: ']', start: token.start, end: token.end };
459
459
 
460
460
  case 'link_ref':
461
461
  this.#index++;
@@ -463,7 +463,7 @@ export class MdzTokenParser {
463
463
  type: 'Text',
464
464
  content: `(${token.reference})`,
465
465
  start: token.start,
466
- end: token.end,
466
+ end: token.end
467
467
  };
468
468
 
469
469
  case 'tag_close':
@@ -472,7 +472,7 @@ export class MdzTokenParser {
472
472
  type: 'Text',
473
473
  content: `</${token.name}>`,
474
474
  start: token.start,
475
- end: token.end,
475
+ end: token.end
476
476
  };
477
477
 
478
478
  default:
@@ -492,7 +492,7 @@ export class MdzTokenParser {
492
492
  #parse_delimiter_pair(
493
493
  close_type: 'bold_close' | 'italic_close' | 'strikethrough_close',
494
494
  node_type: 'Bold' | 'Italic' | 'Strikethrough',
495
- delimiter: '**' | '_' | '~~',
495
+ delimiter: '**' | '_' | '~~'
496
496
  ): MdzNodeBold | MdzNodeItalic | MdzNodeStrikethrough | MdzNodeText {
497
497
  const start = this.#tokens[this.#index]!.start;
498
498
  this.#index++;
@@ -503,7 +503,7 @@ export class MdzTokenParser {
503
503
  const t = this.#tokens[this.#index]!;
504
504
  if (t.type === close_type) {
505
505
  this.#index++;
506
- return {type: node_type, children, start, end: t.end};
506
+ return { type: node_type, children, start, end: t.end };
507
507
  }
508
508
  if (token_is_block_boundary(t.type)) {
509
509
  break;
@@ -513,7 +513,7 @@ export class MdzTokenParser {
513
513
  }
514
514
 
515
515
  // Unclosed - treat as text
516
- return {type: 'Text', content: delimiter, start, end: start + delimiter.length};
516
+ return { type: 'Text', content: delimiter, start, end: start + delimiter.length };
517
517
  }
518
518
 
519
519
  #parse_link(): MdzNodeLink | MdzNodeText {
@@ -538,12 +538,12 @@ export class MdzTokenParser {
538
538
  children,
539
539
  link_type: ref_token.link_type,
540
540
  start,
541
- end: ref_token.end,
541
+ end: ref_token.end
542
542
  };
543
543
  }
544
544
 
545
545
  // No link_ref - treat as text
546
- return {type: 'Text', content: '[', start, end: start + 1};
546
+ return { type: 'Text', content: '[', start, end: start + 1 };
547
547
  }
548
548
  if (token_is_block_boundary(t.type)) {
549
549
  break;
@@ -552,7 +552,7 @@ export class MdzTokenParser {
552
552
  if (node) mdz_push_merging_text(children, node);
553
553
  }
554
554
 
555
- return {type: 'Text', content: '[', start, end: start + 1};
555
+ return { type: 'Text', content: '[', start, end: start + 1 };
556
556
  }
557
557
 
558
558
  #parse_autolink(): MdzNodeLink {
@@ -561,10 +561,10 @@ export class MdzTokenParser {
561
561
  return {
562
562
  type: 'Link',
563
563
  reference: token.reference,
564
- children: [{type: 'Text', content: token.reference, start: token.start, end: token.end}],
564
+ children: [{ type: 'Text', content: token.reference, start: token.start, end: token.end }],
565
565
  link_type: token.link_type,
566
566
  start: token.start,
567
- end: token.end,
567
+ end: token.end
568
568
  };
569
569
  }
570
570
 
@@ -581,21 +581,21 @@ export class MdzTokenParser {
581
581
  const t = this.#tokens[this.#index]!;
582
582
  if (t.type === 'tag_close' && t.name === tag_name) {
583
583
  this.#index++;
584
- return {type: node_type, name: tag_name, children, start, end: t.end};
584
+ return { type: node_type, name: tag_name, children, start, end: t.end };
585
585
  }
586
586
  const node = this.#parse_inline();
587
587
  if (node) mdz_push_merging_text(children, node);
588
588
  }
589
589
 
590
590
  // Unclosed tag
591
- return {type: 'Text', content: '<', start, end: start + 1};
591
+ return { type: 'Text', content: '<', start, end: start + 1 };
592
592
  }
593
593
 
594
594
  #parse_self_close_tag(): MdzNodeElement | MdzNodeComponent {
595
595
  const token = this.#tokens[this.#index]! as MdzTokenTagSelfClose;
596
596
  const node_type: 'Component' | 'Element' = token.is_component ? 'Component' : 'Element';
597
597
  this.#index++;
598
- return {type: node_type, name: token.name, children: [], start: token.start, end: token.end};
598
+ return { type: node_type, name: token.name, children: [], start: token.start, end: token.end };
599
599
  }
600
600
 
601
601
  // -- Paragraph flushing --
@@ -627,7 +627,7 @@ export class MdzTokenParser {
627
627
  // `has_non_whitespace_content` (Unicode whitespace like NBSP is
628
628
  // content; `.trim()` here would silently drop it)
629
629
  const has_content = paragraph_children.some(
630
- (n) => n.type !== 'Text' || has_non_whitespace(n.content),
630
+ (n) => n.type !== 'Text' || has_non_whitespace(n.content)
631
631
  );
632
632
  if (!has_content) {
633
633
  paragraph_children.length = 0;
@@ -652,7 +652,7 @@ export class MdzTokenParser {
652
652
  type: 'Paragraph',
653
653
  children: merged,
654
654
  start: merged[0]!.start,
655
- end: merged[merged.length - 1]!.end,
655
+ end: merged[merged.length - 1]!.end
656
656
  };
657
657
  }
658
658
  }
@@ -14,11 +14,11 @@
14
14
  * @module
15
15
  */
16
16
 
17
- import type {ImportDeclaration, VariableDeclaration} from 'estree';
18
- import {parse, type PreprocessorGroup, type AST} from 'svelte/compiler';
17
+ import type { ImportDeclaration, VariableDeclaration } from 'estree';
18
+ import { parse, type PreprocessorGroup, type AST } from 'svelte/compiler';
19
19
  import MagicString from 'magic-string';
20
- import {walk} from 'zimmerframe';
21
- import {should_exclude_path} from '@fuzdev/fuz_util/path.ts';
20
+ import { walk } from 'zimmerframe';
21
+ import { should_exclude_path } from '@fuzdev/fuz_util/path.ts';
22
22
  import {
23
23
  find_attribute,
24
24
  extract_static_string,
@@ -33,11 +33,11 @@ import {
33
33
  remove_import_specifier,
34
34
  handle_preprocess_error,
35
35
  type PreprocessImportInfo,
36
- type ResolvedComponentImport,
36
+ type ResolvedComponentImport
37
37
  } from '@fuzdev/fuz_util/svelte_preprocess_helpers.ts';
38
38
 
39
- import {mdz_parse} from './mdz.ts';
40
- import {mdz_to_svelte, type MdzToSvelteResult} from './mdz_to_svelte.ts';
39
+ import { mdz_parse } from './mdz.ts';
40
+ import { mdz_to_svelte, type MdzToSvelteResult } from './mdz_to_svelte.ts';
41
41
 
42
42
  /**
43
43
  * An estree `ImportDeclaration` augmented with Svelte's position data.
@@ -56,7 +56,7 @@ export interface SveltePreprocessMdzOptions {
56
56
  /**
57
57
  * Component import mapping for mdz content.
58
58
  * Key: component name as used in mdz (e.g., 'Alert').
59
- * Value: import path (e.g., '$lib/Alert.svelte').
59
+ * Value: import path (e.g., '#lib/Alert.svelte').
60
60
  *
61
61
  * If mdz content references a component not in this map,
62
62
  * that `Mdz` usage is skipped (left as runtime).
@@ -116,10 +116,10 @@ const PRECOMPILED_NAME = 'MdzPrecompiled';
116
116
  * Creates a Svelte preprocessor that compiles static `Mdz` content at build time.
117
117
  *
118
118
  * @param options - configuration for component/element resolution and file filtering
119
- * @returns a Svelte `PreprocessorGroup` for use in `svelte.config.js`
119
+ * @returns a Svelte `PreprocessorGroup` for a `preprocess` option, like `sveltekit({preprocess})` in `vite.config.ts`
120
120
  */
121
121
  export const svelte_preprocess_mdz = (
122
- options: SveltePreprocessMdzOptions = {},
122
+ options: SveltePreprocessMdzOptions = {}
123
123
  ): PreprocessorGroup => {
124
124
  const {
125
125
  exclude = [],
@@ -129,52 +129,56 @@ export const svelte_preprocess_mdz = (
129
129
  compiled_component_import = '@fuzdev/mdz/MdzPrecompiled.svelte',
130
130
  code_component_import,
131
131
  codeblock_component_import,
132
- on_error = process.env.CI === 'true' ? 'throw' : 'log',
132
+ on_error = process.env.CI === 'true' ? 'throw' : 'log'
133
133
  } = options;
134
134
 
135
135
  return {
136
136
  name: 'fuz-mdz',
137
137
 
138
- markup: ({content, filename}) => {
138
+ markup: ({ content, filename }) => {
139
139
  if (should_exclude_path(filename, exclude)) {
140
- return {code: content};
140
+ return { code: content };
141
141
  }
142
142
 
143
143
  // Quick bail: does file mention any known Mdz import source?
144
144
  if (!mdz_component_imports.some((source) => content.includes(source))) {
145
- return {code: content};
145
+ return { code: content };
146
146
  }
147
147
 
148
- const ast = parse(content, {filename, modern: true});
148
+ const ast = parse(content, { filename, modern: true });
149
149
 
150
150
  // Resolve which local names map to the Mdz component
151
151
  const mdz_names = resolve_component_names(ast, mdz_component_imports);
152
152
  if (mdz_names.size === 0) {
153
- return {code: content};
153
+ return { code: content };
154
154
  }
155
155
 
156
156
  // Check for MdzPrecompiled name collision
157
157
  if (has_name_collision(ast, compiled_component_import)) {
158
- return {code: content};
158
+ return { code: content };
159
159
  }
160
160
 
161
161
  const s = new MagicString(content);
162
162
  const bindings = build_static_bindings(ast);
163
163
 
164
164
  // Find and transform Mdz usages with static content
165
- const {transformations, total_usages, transformed_usages} = find_mdz_usages(ast, mdz_names, {
166
- components,
167
- elements,
168
- filename,
169
- source: content,
170
- bindings,
171
- on_error,
172
- code_component_import,
173
- codeblock_component_import,
174
- });
165
+ const { transformations, total_usages, transformed_usages } = find_mdz_usages(
166
+ ast,
167
+ mdz_names,
168
+ {
169
+ components,
170
+ elements,
171
+ filename,
172
+ source: content,
173
+ bindings,
174
+ on_error,
175
+ code_component_import,
176
+ codeblock_component_import
177
+ }
178
+ );
175
179
 
176
180
  if (transformations.length === 0) {
177
- return {code: content};
181
+ return { code: content };
178
182
  }
179
183
 
180
184
  // Apply transformations
@@ -190,7 +194,7 @@ export const svelte_preprocess_mdz = (
190
194
  ast,
191
195
  mdz_names,
192
196
  total_usages,
193
- transformed_usages,
197
+ transformed_usages
194
198
  );
195
199
 
196
200
  // Add required imports and remove unused Mdz imports
@@ -200,14 +204,14 @@ export const svelte_preprocess_mdz = (
200
204
  transformations,
201
205
  removable_imports,
202
206
  compiled_component_import,
203
- content,
207
+ content
204
208
  );
205
209
 
206
210
  return {
207
211
  code: s.toString(),
208
- map: s.generateMap({hires: true}),
212
+ map: s.generateMap({ hires: true })
209
213
  };
210
- },
214
+ }
211
215
  };
212
216
  };
213
217
 
@@ -273,11 +277,11 @@ const has_name_collision = (ast: AST.Root, compiled_component_import: string): b
273
277
  */
274
278
  const collect_consumed_bindings = (
275
279
  value: AST.Attribute['value'],
276
- bindings: ReadonlyMap<string, string>,
280
+ bindings: ReadonlyMap<string, string>
277
281
  ): Set<string> => {
278
282
  const consumed: Set<string> = new Set();
279
283
  if (value === true || Array.isArray(value)) return consumed;
280
- const collect_from_expr = (expr: {type: string; [key: string]: any}): void => {
284
+ const collect_from_expr = (expr: { type: string; [key: string]: any }): void => {
281
285
  if (expr.type === 'Identifier' && bindings.has(expr.name)) {
282
286
  consumed.add(expr.name);
283
287
  } else if (expr.type === 'BinaryExpression' && expr.operator === '+') {
@@ -305,7 +309,7 @@ const collect_consumed_bindings = (
305
309
  const render_static_mdz = (
306
310
  content: string,
307
311
  base: string | undefined,
308
- context: FindMdzUsagesContext,
312
+ context: FindMdzUsagesContext
309
313
  ): MdzToSvelteResult | null => {
310
314
  let result: MdzToSvelteResult;
311
315
  try {
@@ -314,7 +318,7 @@ const render_static_mdz = (
314
318
  elements: context.elements,
315
319
  base,
316
320
  code_component_import: context.code_component_import,
317
- codeblock_component_import: context.codeblock_component_import,
321
+ codeblock_component_import: context.codeblock_component_import
318
322
  });
319
323
  } catch (error) {
320
324
  handle_preprocess_error(error, '[fuz-mdz]', context.filename, context.on_error);
@@ -330,7 +334,7 @@ const render_static_mdz = (
330
334
  const find_mdz_usages = (
331
335
  ast: AST.Root,
332
336
  mdz_names: Map<string, ResolvedComponentImport>,
333
- context: FindMdzUsagesContext,
337
+ context: FindMdzUsagesContext
334
338
  ): FindMdzUsagesResult => {
335
339
  const transformations: Array<MdzTransformation> = [];
336
340
  const total_usages: Map<string, number> = new Map();
@@ -339,7 +343,7 @@ const find_mdz_usages = (
339
343
  // zimmerframe types visitors against {type: string}, requiring explicit annotations
340
344
  // on the callback parameters for Svelte-specific AST types like AST.Component
341
345
  walk(ast.fragment as any, null, {
342
- Component(node: AST.Component, ctx: {next: () => void}) {
346
+ Component(node: AST.Component, ctx: { next: () => void }) {
343
347
  // Always recurse into children so nested Mdz components are found
344
348
  ctx.next();
345
349
 
@@ -385,7 +389,7 @@ const find_mdz_usages = (
385
389
  replacement,
386
390
  required_imports: result.imports,
387
391
  consumed_bindings: consumed,
388
- component_node: node,
392
+ component_node: node
389
393
  });
390
394
  return;
391
395
  }
@@ -394,17 +398,17 @@ const find_mdz_usages = (
394
398
  const chain = try_extract_conditional_chain(
395
399
  content_attr.value,
396
400
  context.source,
397
- context.bindings,
401
+ context.bindings
398
402
  );
399
403
  if (chain === null) return;
400
404
 
401
405
  // Parse and render each branch
402
- const branch_results: Array<{markup: string; imports: Map<string, PreprocessImportInfo>}> =
406
+ const branch_results: Array<{ markup: string; imports: Map<string, PreprocessImportInfo> }> =
403
407
  [];
404
408
  for (const branch of chain) {
405
409
  const result = render_static_mdz(branch.value, base, context);
406
410
  if (result === null) return; // parse error or unconfigured tags — leave for runtime
407
- branch_results.push({markup: result.markup, imports: result.imports});
411
+ branch_results.push({ markup: result.markup, imports: result.imports });
408
412
  }
409
413
 
410
414
  // Build {#if}/{:else if}/{:else} markup
@@ -440,12 +444,12 @@ const find_mdz_usages = (
440
444
  replacement,
441
445
  required_imports: merged_imports,
442
446
  consumed_bindings: consumed,
443
- component_node: node,
447
+ component_node: node
444
448
  });
445
- },
449
+ }
446
450
  });
447
451
 
448
- return {transformations, total_usages, transformed_usages};
452
+ return { transformations, total_usages, transformed_usages };
449
453
  };
450
454
 
451
455
  /**
@@ -459,7 +463,7 @@ const remove_dead_const_bindings = (
459
463
  s: MagicString,
460
464
  ast: AST.Root,
461
465
  transformations: Array<MdzTransformation>,
462
- source: string,
466
+ source: string
463
467
  ): void => {
464
468
  // Collect all consumed binding names across transformations
465
469
  const all_consumed: Set<string> = new Set();
@@ -483,12 +487,12 @@ const remove_dead_const_bindings = (
483
487
 
484
488
  for (const name of all_consumed) {
485
489
  // Find the VariableDeclaration containing this binding in instance script
486
- let declaration_node: (VariableDeclaration & {start: number; end: number}) | null = null;
490
+ let declaration_node: (VariableDeclaration & { start: number; end: number }) | null = null;
487
491
  for (const node of instance.content.body) {
488
492
  if (node.type !== 'VariableDeclaration' || node.kind !== 'const') continue;
489
493
  for (const decl of node.declarations) {
490
494
  if (decl.id.type === 'Identifier' && decl.id.name === name) {
491
- declaration_node = node as VariableDeclaration & {start: number; end: number};
495
+ declaration_node = node as VariableDeclaration & { start: number; end: number };
492
496
  break;
493
497
  }
494
498
  }
@@ -529,13 +533,13 @@ const build_replacement = (
529
533
  node: AST.Component,
530
534
  exclude_attrs: ReadonlySet<AST.Attribute>,
531
535
  children_markup: string,
532
- source: string,
536
+ source: string
533
537
  ): string => {
534
538
  // Collect source ranges of all attributes except excluded ones (content, base when resolved)
535
- const other_attr_ranges: Array<{start: number; end: number}> = [];
539
+ const other_attr_ranges: Array<{ start: number; end: number }> = [];
536
540
  for (const attr of node.attributes) {
537
541
  if (exclude_attrs.has(attr as AST.Attribute)) continue;
538
- other_attr_ranges.push({start: attr.start, end: attr.end});
542
+ other_attr_ranges.push({ start: attr.start, end: attr.end });
539
543
  }
540
544
 
541
545
  // Build opening tag with MdzPrecompiled name
@@ -572,11 +576,11 @@ const find_removable_mdz_imports = (
572
576
  ast: AST.Root,
573
577
  mdz_names: Map<string, ResolvedComponentImport>,
574
578
  total_usages: Map<string, number>,
575
- transformed_usages: Map<string, number>,
579
+ transformed_usages: Map<string, number>
576
580
  ): Map<string, ImportRemovalAction> => {
577
581
  const removable: Map<string, ImportRemovalAction> = new Map();
578
582
 
579
- for (const [name, {import_node, specifier}] of mdz_names) {
583
+ for (const [name, { import_node, specifier }] of mdz_names) {
580
584
  const total = total_usages.get(name) ?? 0;
581
585
  const transformed = transformed_usages.get(name) ?? 0;
582
586
 
@@ -603,12 +607,12 @@ const find_removable_mdz_imports = (
603
607
 
604
608
  const positioned_node = import_node as PositionedImportDeclaration;
605
609
  if (import_node.specifiers.length === 1) {
606
- removable.set(name, {node: positioned_node, kind: 'full'});
610
+ removable.set(name, { node: positioned_node, kind: 'full' });
607
611
  } else {
608
612
  removable.set(name, {
609
613
  node: positioned_node,
610
614
  kind: 'partial',
611
- specifier_to_remove: specifier,
615
+ specifier_to_remove: specifier
612
616
  });
613
617
  }
614
618
  }
@@ -636,7 +640,7 @@ const manage_imports = (
636
640
  transformations: Array<MdzTransformation>,
637
641
  removable_imports: Map<string, ImportRemovalAction>,
638
642
  compiled_component_import: string,
639
- source: string,
643
+ source: string
640
644
  ): void => {
641
645
  // Collect all required imports across transformations
642
646
  const required: Map<string, PreprocessImportInfo> = new Map();
@@ -647,7 +651,7 @@ const manage_imports = (
647
651
  }
648
652
 
649
653
  // Always need MdzPrecompiled when transformations occur
650
- required.set(PRECOMPILED_NAME, {path: compiled_component_import, kind: 'default'});
654
+ required.set(PRECOMPILED_NAME, { path: compiled_component_import, kind: 'default' });
651
655
 
652
656
  const script = ast.instance;
653
657
 
@@ -770,7 +774,7 @@ const manage_imports = (
770
774
  action.node,
771
775
  action.specifier_to_remove!,
772
776
  source,
773
- action === partial_carrier ? carrier_lines : '',
777
+ action === partial_carrier ? carrier_lines : ''
774
778
  );
775
779
  }
776
780
  };
@@ -8,7 +8,7 @@
8
8
  * @module
9
9
  */
10
10
 
11
- import {mdz_is_url} from './mdz_helpers.ts';
11
+ import { mdz_is_url } from './mdz_helpers.ts';
12
12
 
13
13
  /** Format a reference as mdz: URLs pass through, identifiers get backticks. */
14
14
  const format_reference = (ref: string): string => (mdz_is_url(ref) ? ref : `\`${ref}\``);