@fuzdev/fuz_ui 0.181.1 → 0.182.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.
@@ -2,7 +2,6 @@
2
2
  import Code from '@fuzdev/fuz_code/Code.svelte';
3
3
 
4
4
  import type {Declaration} from './declaration.svelte.js';
5
- import Details from './Details.svelte';
6
5
  import TypeLink from './TypeLink.svelte';
7
6
  import ModuleLink from './ModuleLink.svelte';
8
7
  import Mdz from './Mdz.svelte';
@@ -200,11 +199,8 @@
200
199
  {#if declaration.examples?.length}
201
200
  <section>
202
201
  <h4>examples</h4>
203
- {#each declaration.examples as example, i (example)}
204
- <Details>
205
- {#snippet summary()}Example {i + 1}{/snippet}
206
- <Code lang="ts" content={example} />
207
- </Details>
202
+ {#each declaration.examples as example (example)}
203
+ <Mdz content={example} />
208
204
  {/each}
209
205
  </section>
210
206
  {/if}
@@ -323,13 +319,13 @@
323
319
  <Mdz content={prop.doc_comment} />
324
320
  {/if}
325
321
  {#if prop.type_signature}
326
- <div class="row gap_md">
322
+ <div class="row gap_md mt_lg">
327
323
  <strong>type</strong>
328
324
  <TypeLink type={prop.type_signature} />
329
325
  </div>
330
326
  {/if}
331
327
  {#if prop.modifiers?.length}
332
- <div class="row gap_md">
328
+ <div class="row gap_md mt_lg">
333
329
  {#each prop.modifiers as modifier (modifier)}
334
330
  <span class="chip">{modifier}</span>
335
331
  {/each}
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarationDetail.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/DeclarationDetail.svelte"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAOxD,KAAK,gBAAgB,GAAI;IAAC,WAAW,EAAE,WAAW,CAAA;CAAC,CAAC;AAiVrD,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"DeclarationDetail.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/DeclarationDetail.svelte"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAMxD,KAAK,gBAAgB,GAAI;IAAC,WAAW,EAAE,WAAW,CAAA;CAAC,CAAC;AA6UrD,QAAA,MAAM,iBAAiB,sDAAwC,CAAC;AAChE,KAAK,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC9D,eAAe,iBAAiB,CAAC"}
@@ -15,9 +15,18 @@
15
15
  }: SvelteHTMLElements['a'] & {
16
16
  /**
17
17
  * GitHub path - can be a full URL or a relative path like `owner/repo` or `owner/repo/blob/main/file.ts`
18
- * @example fuzdev/fuz_ui
19
- * @example fuzdev/fuz_ui/blob/main/src/lib/Card.svelte
20
- * @example https://github.com/fuzdev/fuz_ui/issues/123
18
+ * @example
19
+ * ```ts
20
+ * 'fuzdev/fuz_ui'
21
+ * ```
22
+ * @example
23
+ * ```ts
24
+ * 'fuzdev/fuz_ui/blob/main/src/lib/Card.svelte'
25
+ * ```
26
+ * @example
27
+ * ```ts
28
+ * 'https://github.com/fuzdev/fuz_ui/issues/123'
29
+ * ```
21
30
  */
22
31
  path?: string;
23
32
  /** URL fragment to append, with or without the `#`. */
@@ -2,9 +2,18 @@ import type { SvelteHTMLElements } from 'svelte/elements';
2
2
  type $$ComponentProps = SvelteHTMLElements['a'] & {
3
3
  /**
4
4
  * GitHub path - can be a full URL or a relative path like `owner/repo` or `owner/repo/blob/main/file.ts`
5
- * @example fuzdev/fuz_ui
6
- * @example fuzdev/fuz_ui/blob/main/src/lib/Card.svelte
7
- * @example https://github.com/fuzdev/fuz_ui/issues/123
5
+ * @example
6
+ * ```ts
7
+ * 'fuzdev/fuz_ui'
8
+ * ```
9
+ * @example
10
+ * ```ts
11
+ * 'fuzdev/fuz_ui/blob/main/src/lib/Card.svelte'
12
+ * ```
13
+ * @example
14
+ * ```ts
15
+ * 'https://github.com/fuzdev/fuz_ui/issues/123'
16
+ * ```
8
17
  */
9
18
  path?: string;
10
19
  /** URL fragment to append, with or without the `#`. */
@@ -1 +1 @@
1
- {"version":3,"file":"GithubLink.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/GithubLink.svelte"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAMvD,KAAK,gBAAgB,GAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG;IAClD;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAoEH,QAAA,MAAM,UAAU,sDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"GithubLink.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/GithubLink.svelte"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAMvD,KAAK,gBAAgB,GAAI,kBAAkB,CAAC,GAAG,CAAC,GAAG;IAClD;;;;;;;;;;;;;;OAcG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAoEH,QAAA,MAAM,UAAU,sDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
package/dist/Mdz.svelte CHANGED
@@ -21,7 +21,7 @@
21
21
  <svelte:element
22
22
  this={inline ? 'span' : 'div'}
23
23
  {...rest}
24
- class="{rest.class} {nowrap ? 'white-space:pre' : 'white-space:pre-wrap'}"
24
+ style:white-space={nowrap ? 'pre' : 'pre-wrap'}
25
25
  >
26
26
  {#each nodes as node (node)}
27
27
  <MdzNodeView {node} />
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import type {Snippet} from 'svelte';
3
+ import type {SvelteHTMLElements} from 'svelte/elements';
4
+
5
+ /**
6
+ * Wrapper for precompiled mdz content. Used by `svelte_preprocess_mdz`.
7
+ * Not intended for direct use.
8
+ *
9
+ * @module
10
+ */
11
+
12
+ const {
13
+ inline = false,
14
+ nowrap = false,
15
+ children,
16
+ ...rest
17
+ }: (SvelteHTMLElements['div'] | SvelteHTMLElements['span']) & {
18
+ inline?: boolean;
19
+ nowrap?: boolean;
20
+ children: Snippet;
21
+ } = $props();
22
+ </script>
23
+
24
+ <svelte:element
25
+ this={inline ? 'span' : 'div'}
26
+ {...rest}
27
+ style:white-space={nowrap ? 'pre' : 'pre-wrap'}
28
+ >
29
+ {@render children()}
30
+ </svelte:element>
@@ -0,0 +1,11 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { SvelteHTMLElements } from 'svelte/elements';
3
+ type $$ComponentProps = (SvelteHTMLElements['div'] | SvelteHTMLElements['span']) & {
4
+ inline?: boolean;
5
+ nowrap?: boolean;
6
+ children: Snippet;
7
+ };
8
+ declare const MdzPrecompiled: import("svelte").Component<$$ComponentProps, {}, "">;
9
+ type MdzPrecompiled = ReturnType<typeof MdzPrecompiled>;
10
+ export default MdzPrecompiled;
11
+ //# sourceMappingURL=MdzPrecompiled.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdzPrecompiled.svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/MdzPrecompiled.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEvD,KAAK,gBAAgB,GAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,GAAG;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CAClB,CAAC;AA0BH,QAAA,MAAM,cAAc,sDAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
@@ -12,7 +12,7 @@ export declare class Declaration {
12
12
  */
13
13
  module_path: string;
14
14
  name: string;
15
- kind: "function" | "class" | "type" | "constructor" | "json" | "variable" | "component" | "css";
15
+ kind: "function" | "class" | "type" | "json" | "variable" | "constructor" | "component" | "css";
16
16
  /**
17
17
  * GitHub source URL with line number.
18
18
  */
@@ -86,7 +86,7 @@ export declare class Library {
86
86
  declarations?: {
87
87
  [x: string]: unknown;
88
88
  name: string;
89
- kind: "function" | "class" | "type" | "constructor" | "json" | "variable" | "component" | "css";
89
+ kind: "function" | "class" | "type" | "json" | "variable" | "constructor" | "component" | "css";
90
90
  doc_comment?: string | undefined;
91
91
  type_signature?: string | undefined;
92
92
  modifiers?: string[] | undefined;
@@ -0,0 +1,38 @@
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
+ */
37
+ export declare const mdz_to_svelte: (nodes: Array<MdzNode>, components: Record<string, string>, elements: ReadonlySet<string>) => MdzToSvelteResult;
38
+ //# sourceMappingURL=mdz_to_svelte.d.ts.map
@@ -0,0 +1 @@
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;AAEtC;;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;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACzB,OAAO,KAAK,CAAC,OAAO,CAAC,EACrB,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,UAAU,WAAW,CAAC,MAAM,CAAC,KAC3B,iBAgFF,CAAC"}
@@ -0,0 +1,89 @@
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
+ /**
14
+ * Converts an array of `MdzNode` to a Svelte markup string.
15
+ *
16
+ * Each node type produces output matching what `MdzNodeView.svelte` renders at runtime.
17
+ * Collects required imports and flags unconfigured component/element references.
18
+ *
19
+ * @param nodes Parsed mdz nodes to render.
20
+ * @param components Component name to import path mapping (e.g., `{Alert: '$lib/Alert.svelte'}`).
21
+ * If content references a component not in this map, `has_unconfigured_tags` is set.
22
+ * @param elements Allowed HTML element names (e.g., `new Set(['aside', 'details'])`).
23
+ * If content references an element not in this set, `has_unconfigured_tags` is set.
24
+ */
25
+ export const mdz_to_svelte = (nodes, components, elements) => {
26
+ const imports = new Map();
27
+ let has_unconfigured_tags = false;
28
+ const render_nodes = (children) => {
29
+ return children.map((child) => render_node(child)).join('');
30
+ };
31
+ const render_node = (node) => {
32
+ switch (node.type) {
33
+ case 'Text':
34
+ return escape_svelte_text(node.content);
35
+ case 'Code':
36
+ imports.set('DocsLink', { path: '@fuzdev/fuz_ui/DocsLink.svelte', kind: 'default' });
37
+ return `<DocsLink reference={'${escape_js_string(node.content)}'} />`;
38
+ case 'Codeblock': {
39
+ imports.set('Code', { path: '@fuzdev/fuz_code/Code.svelte', kind: 'default' });
40
+ const lang_attr = node.lang === null ? 'lang={null}' : `lang={'${escape_js_string(node.lang)}'}`;
41
+ return `<Code ${lang_attr} content={'${escape_js_string(node.content)}'} />`;
42
+ }
43
+ case 'Bold':
44
+ return `<strong>${render_nodes(node.children)}</strong>`;
45
+ case 'Italic':
46
+ return `<em>${render_nodes(node.children)}</em>`;
47
+ case 'Strikethrough':
48
+ return `<s>${render_nodes(node.children)}</s>`;
49
+ case 'Link': {
50
+ const children_markup = render_nodes(node.children);
51
+ if (node.link_type === 'internal') {
52
+ if (node.reference.startsWith('#') || node.reference.startsWith('?')) {
53
+ return `<a href={'${escape_js_string(node.reference)}'}>${children_markup}</a>`;
54
+ }
55
+ imports.set('resolve', { path: '$app/paths', kind: 'named' });
56
+ return `<a href={resolve('${escape_js_string(node.reference)}')}>${children_markup}</a>`;
57
+ }
58
+ // External link — matches MdzNodeView: target="_blank" rel="noopener"
59
+ return `<a href={'${escape_js_string(node.reference)}'} target="_blank" rel="noopener">${children_markup}</a>`;
60
+ }
61
+ case 'Paragraph':
62
+ return `<p>${render_nodes(node.children)}</p>`;
63
+ case 'Hr':
64
+ return '<hr />';
65
+ case 'Heading':
66
+ return `<h${node.level}>${render_nodes(node.children)}</h${node.level}>`;
67
+ case 'Element': {
68
+ if (!elements.has(node.name)) {
69
+ has_unconfigured_tags = true;
70
+ return '';
71
+ }
72
+ return `<${node.name}>${render_nodes(node.children)}</${node.name}>`;
73
+ }
74
+ case 'Component': {
75
+ const import_path = components[node.name];
76
+ if (!import_path) {
77
+ has_unconfigured_tags = true;
78
+ return '';
79
+ }
80
+ imports.set(node.name, { path: import_path, kind: 'default' });
81
+ return `<${node.name}>${render_nodes(node.children)}</${node.name}>`;
82
+ }
83
+ default:
84
+ throw new UnreachableError(node);
85
+ }
86
+ };
87
+ const markup = render_nodes(nodes);
88
+ return { markup, imports, has_unconfigured_tags };
89
+ };
@@ -49,10 +49,12 @@ export interface SourceFileInfo {
49
49
  * handles nested directories without special heuristics.
50
50
  *
51
51
  * @example
52
+ * ```ts
52
53
  * const options = module_create_source_options(process.cwd(), {
53
54
  * source_paths: ['src/lib', 'src/routes'],
54
55
  * source_root: 'src',
55
56
  * });
57
+ * ```
56
58
  */
57
59
  export interface ModuleSourceOptions {
58
60
  /**
@@ -61,7 +63,10 @@ export interface ModuleSourceOptions {
61
63
  * All `source_paths` are relative to this. Typically `process.cwd()` when
62
64
  * running from the project root via Gro, Vite, or other build tools.
63
65
  *
64
- * @example '/home/user/my-project'
66
+ * @example
67
+ * ```ts
68
+ * '/home/user/my-project'
69
+ * ```
65
70
  */
66
71
  project_root: string;
67
72
  /**
@@ -70,8 +75,14 @@ export interface ModuleSourceOptions {
70
75
  * Paths should not have leading or trailing slashes - they are added
71
76
  * internally for correct matching.
72
77
  *
73
- * @example ['src/lib'] - single source directory
74
- * @example ['src/lib', 'src/routes'] - multiple directories
78
+ * @example
79
+ * ```ts
80
+ * ['src/lib'] // single source directory
81
+ * ```
82
+ * @example
83
+ * ```ts
84
+ * ['src/lib', 'src/routes'] // multiple directories
85
+ * ```
75
86
  */
76
87
  source_paths: Array<string>;
77
88
  /**
@@ -81,8 +92,14 @@ export interface ModuleSourceOptions {
81
92
  * - Single `source_path`: defaults to that path
82
93
  * - Multiple `source_paths`: required (no auto-derivation)
83
94
  *
84
- * @example 'src/lib' - module paths like 'foo.ts', 'utils/bar.ts'
85
- * @example 'src' - module paths like 'lib/foo.ts', 'routes/page.svelte'
95
+ * @example
96
+ * ```ts
97
+ * 'src/lib' // module paths like 'foo.ts', 'utils/bar.ts'
98
+ * ```
99
+ * @example
100
+ * ```ts
101
+ * 'src' // module paths like 'lib/foo.ts', 'routes/page.svelte'
102
+ * ```
86
103
  */
87
104
  source_root?: string;
88
105
  /** Patterns to exclude (matched against full path). */
@@ -97,20 +114,24 @@ export interface ModuleSourceOptions {
97
114
  * @default Uses file extension: `.svelte` → svelte, `.ts`/`.js` → typescript
98
115
  *
99
116
  * @example
117
+ * ```ts
100
118
  * // Add MDsveX support
101
119
  * get_analyzer: (path) => {
102
120
  * if (path.endsWith('.svelte') || path.endsWith('.svx')) return 'svelte';
103
121
  * if (path.endsWith('.ts') || path.endsWith('.js')) return 'typescript';
104
122
  * return null;
105
123
  * }
124
+ * ```
106
125
  *
107
126
  * @example
127
+ * ```ts
108
128
  * // Include .d.ts files
109
129
  * get_analyzer: (path) => {
110
130
  * if (path.endsWith('.svelte')) return 'svelte';
111
131
  * if (path.endsWith('.ts') || path.endsWith('.d.ts') || path.endsWith('.js')) return 'typescript';
112
132
  * return null;
113
133
  * }
134
+ * ```
114
135
  */
115
136
  get_analyzer: (path: string) => AnalyzerType | null;
116
137
  }
@@ -142,21 +163,27 @@ export declare const MODULE_SOURCE_PARTIAL: ModuleSourcePartial;
142
163
  * @param overrides Optional overrides for default options
143
164
  *
144
165
  * @example
166
+ * ```ts
145
167
  * // Standard SvelteKit library
146
168
  * const options = module_create_source_options(process.cwd());
169
+ * ```
147
170
  *
148
171
  * @example
172
+ * ```ts
149
173
  * // Multiple source directories
150
174
  * const options = module_create_source_options(process.cwd(), {
151
175
  * source_paths: ['src/lib', 'src/routes'],
152
176
  * source_root: 'src',
153
177
  * });
178
+ * ```
154
179
  *
155
180
  * @example
181
+ * ```ts
156
182
  * // Custom exclusions
157
183
  * const options = module_create_source_options(process.cwd(), {
158
184
  * exclude_patterns: [/\.test\.ts$/, /\.internal\.ts$/],
159
185
  * });
186
+ * ```
160
187
  */
161
188
  export declare const module_create_source_options: (project_root: string, overrides?: Partial<ModuleSourcePartial>) => ModuleSourceOptions;
162
189
  /**
@@ -172,14 +199,17 @@ export declare const module_create_source_options: (project_root: string, overri
172
199
  * @throws Error if validation fails
173
200
  *
174
201
  * @example
202
+ * ```ts
175
203
  * // Valid - single source path (source_root auto-derived)
176
204
  * module_validate_source_options({
177
205
  * project_root: '/home/user/project',
178
206
  * source_paths: ['src/lib'],
179
207
  * ...
180
208
  * });
209
+ * ```
181
210
  *
182
211
  * @example
212
+ * ```ts
183
213
  * // Valid - multiple source paths with explicit source_root
184
214
  * module_validate_source_options({
185
215
  * project_root: '/home/user/project',
@@ -187,14 +217,17 @@ export declare const module_create_source_options: (project_root: string, overri
187
217
  * source_root: 'src',
188
218
  * ...
189
219
  * });
220
+ * ```
190
221
  *
191
222
  * @example
223
+ * ```ts
192
224
  * // Invalid - multiple source paths without source_root
193
225
  * module_validate_source_options({
194
226
  * project_root: '/home/user/project',
195
227
  * source_paths: ['src/lib', 'src/routes'], // throws
196
228
  * ...
197
229
  * });
230
+ * ```
198
231
  */
199
232
  export declare const module_validate_source_options: (options: ModuleSourceOptions) => void;
200
233
  /**
@@ -214,32 +247,40 @@ export declare const module_get_source_root: (options: ModuleSourceOptions) => s
214
247
  * @param options Module source options for path extraction
215
248
  *
216
249
  * @example
250
+ * ```ts
217
251
  * const options = module_create_source_options('/home/user/project');
218
252
  * module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'foo.ts'
219
253
  * module_extract_path('/home/user/project/src/lib/nested/bar.svelte', options) // => 'nested/bar.svelte'
254
+ * ```
220
255
  *
221
256
  * @example
257
+ * ```ts
222
258
  * const options = module_create_source_options('/home/user/project', {
223
259
  * source_paths: ['src/lib', 'src/routes'],
224
260
  * source_root: 'src',
225
261
  * });
226
262
  * module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'lib/foo.ts'
227
263
  * module_extract_path('/home/user/project/src/routes/page.svelte', options) // => 'routes/page.svelte'
264
+ * ```
228
265
  */
229
266
  export declare const module_extract_path: (source_id: string, options: ModuleSourceOptions) => string;
230
267
  /**
231
268
  * Extract component name from a Svelte module path.
232
269
  *
233
270
  * @example
271
+ * ```ts
234
272
  * module_get_component_name('Alert.svelte') // => 'Alert'
235
273
  * module_get_component_name('components/Button.svelte') // => 'Button'
274
+ * ```
236
275
  */
237
276
  export declare const module_get_component_name: (module_path: string) => string;
238
277
  /**
239
278
  * Convert module path to module key format (with ./ prefix).
240
279
  *
241
280
  * @example
281
+ * ```ts
242
282
  * module_get_key('foo.ts') // => './foo.ts'
283
+ * ```
243
284
  */
244
285
  export declare const module_get_key: (module_path: string) => string;
245
286
  /**
@@ -269,10 +310,12 @@ export declare const module_is_test: (path: string) => boolean;
269
310
  * @returns True if the path is an analyzable source file
270
311
  *
271
312
  * @example
313
+ * ```ts
272
314
  * const options = module_create_source_options('/home/user/project');
273
315
  * module_is_source('/home/user/project/src/lib/foo.ts', options) // => true
274
316
  * module_is_source('/home/user/project/src/lib/foo.test.ts', options) // => false (excluded)
275
317
  * module_is_source('/home/user/project/src/fixtures/mini/src/lib/bar.ts', options) // => false (wrong prefix)
318
+ * ```
276
319
  */
277
320
  export declare const module_is_source: (path: string, options: ModuleSourceOptions) => boolean;
278
321
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"module_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/module_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC9B,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;OAOG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;;;;;;OASG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,YAAY,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAI,MAAM,MAAM,KAAG,YAAY,GAAG,IAIzE,CAAC;AAEF;;;;GAIG;AACH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c,EAC3B,SAAS,mBAAmB,KAC1B;IAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CA2BzD,CAAC"}
@@ -40,21 +40,27 @@ export const MODULE_SOURCE_PARTIAL = {
40
40
  * @param overrides Optional overrides for default options
41
41
  *
42
42
  * @example
43
+ * ```ts
43
44
  * // Standard SvelteKit library
44
45
  * const options = module_create_source_options(process.cwd());
46
+ * ```
45
47
  *
46
48
  * @example
49
+ * ```ts
47
50
  * // Multiple source directories
48
51
  * const options = module_create_source_options(process.cwd(), {
49
52
  * source_paths: ['src/lib', 'src/routes'],
50
53
  * source_root: 'src',
51
54
  * });
55
+ * ```
52
56
  *
53
57
  * @example
58
+ * ```ts
54
59
  * // Custom exclusions
55
60
  * const options = module_create_source_options(process.cwd(), {
56
61
  * exclude_patterns: [/\.test\.ts$/, /\.internal\.ts$/],
57
62
  * });
63
+ * ```
58
64
  */
59
65
  export const module_create_source_options = (project_root, overrides) => ({
60
66
  project_root,
@@ -74,14 +80,17 @@ export const module_create_source_options = (project_root, overrides) => ({
74
80
  * @throws Error if validation fails
75
81
  *
76
82
  * @example
83
+ * ```ts
77
84
  * // Valid - single source path (source_root auto-derived)
78
85
  * module_validate_source_options({
79
86
  * project_root: '/home/user/project',
80
87
  * source_paths: ['src/lib'],
81
88
  * ...
82
89
  * });
90
+ * ```
83
91
  *
84
92
  * @example
93
+ * ```ts
85
94
  * // Valid - multiple source paths with explicit source_root
86
95
  * module_validate_source_options({
87
96
  * project_root: '/home/user/project',
@@ -89,14 +98,17 @@ export const module_create_source_options = (project_root, overrides) => ({
89
98
  * source_root: 'src',
90
99
  * ...
91
100
  * });
101
+ * ```
92
102
  *
93
103
  * @example
104
+ * ```ts
94
105
  * // Invalid - multiple source paths without source_root
95
106
  * module_validate_source_options({
96
107
  * project_root: '/home/user/project',
97
108
  * source_paths: ['src/lib', 'src/routes'], // throws
98
109
  * ...
99
110
  * });
111
+ * ```
100
112
  */
101
113
  export const module_validate_source_options = (options) => {
102
114
  const { project_root, source_paths, source_root } = options;
@@ -175,17 +187,21 @@ export const module_get_source_root = (options) => {
175
187
  * @param options Module source options for path extraction
176
188
  *
177
189
  * @example
190
+ * ```ts
178
191
  * const options = module_create_source_options('/home/user/project');
179
192
  * module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'foo.ts'
180
193
  * module_extract_path('/home/user/project/src/lib/nested/bar.svelte', options) // => 'nested/bar.svelte'
194
+ * ```
181
195
  *
182
196
  * @example
197
+ * ```ts
183
198
  * const options = module_create_source_options('/home/user/project', {
184
199
  * source_paths: ['src/lib', 'src/routes'],
185
200
  * source_root: 'src',
186
201
  * });
187
202
  * module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'lib/foo.ts'
188
203
  * module_extract_path('/home/user/project/src/routes/page.svelte', options) // => 'routes/page.svelte'
204
+ * ```
189
205
  */
190
206
  export const module_extract_path = (source_id, options) => {
191
207
  const effective_root = module_get_source_root(options);
@@ -201,15 +217,19 @@ export const module_extract_path = (source_id, options) => {
201
217
  * Extract component name from a Svelte module path.
202
218
  *
203
219
  * @example
220
+ * ```ts
204
221
  * module_get_component_name('Alert.svelte') // => 'Alert'
205
222
  * module_get_component_name('components/Button.svelte') // => 'Button'
223
+ * ```
206
224
  */
207
225
  export const module_get_component_name = (module_path) => module_path.replace(/^.*\//, '').replace(/\.svelte$/, '');
208
226
  /**
209
227
  * Convert module path to module key format (with ./ prefix).
210
228
  *
211
229
  * @example
230
+ * ```ts
212
231
  * module_get_key('foo.ts') // => './foo.ts'
232
+ * ```
213
233
  */
214
234
  export const module_get_key = (module_path) => `./${module_path}`;
215
235
  /**
@@ -239,10 +259,12 @@ export const module_is_test = (path) => path.endsWith('.test.ts');
239
259
  * @returns True if the path is an analyzable source file
240
260
  *
241
261
  * @example
262
+ * ```ts
242
263
  * const options = module_create_source_options('/home/user/project');
243
264
  * module_is_source('/home/user/project/src/lib/foo.ts', options) // => true
244
265
  * module_is_source('/home/user/project/src/lib/foo.test.ts', options) // => false (excluded)
245
266
  * module_is_source('/home/user/project/src/fixtures/mini/src/lib/bar.ts', options) // => false (wrong prefix)
267
+ * ```
246
268
  */
247
269
  export const module_is_source = (path, options) => {
248
270
  // Check exclusion patterns first (fast regex check)