@fuzdev/fuz_ui 0.182.0 → 0.183.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.
- package/README.md +1 -1
- package/dist/DeclarationDetail.svelte +2 -6
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/GithubLink.svelte +12 -3
- package/dist/GithubLink.svelte.d.ts +12 -3
- package/dist/GithubLink.svelte.d.ts.map +1 -1
- package/dist/library_gen.d.ts +2 -2
- package/dist/library_gen.d.ts.map +1 -1
- package/dist/library_gen.js +1 -1
- package/dist/module_helpers.d.ts +48 -5
- package/dist/module_helpers.d.ts.map +1 -1
- package/dist/module_helpers.js +22 -0
- package/dist/package_helpers.d.ts +24 -0
- package/dist/package_helpers.d.ts.map +1 -1
- package/dist/package_helpers.js +24 -0
- package/package.json +12 -7
- package/src/lib/library_gen.ts +3 -3
- package/src/lib/module_helpers.ts +48 -5
- package/src/lib/package_helpers.ts +24 -0
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ npm run build
|
|
|
84
84
|
npm start
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
Fuz uses [Gro](https://github.com/
|
|
87
|
+
Fuz uses [Gro](https://github.com/fuzdev/gro),
|
|
88
88
|
my CLI and toolkit that I use to run tasks in all of my projects.
|
|
89
89
|
If you're not allergic it's handy to install globally.
|
|
90
90
|
|
|
@@ -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
|
|
204
|
-
<
|
|
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}
|
|
@@ -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;
|
|
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"}
|
package/dist/GithubLink.svelte
CHANGED
|
@@ -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
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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/library_gen.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
|
-
import type { Gen } from '@
|
|
17
|
-
import type { Disknode } from '@
|
|
16
|
+
import type { Gen } from '@fuzdev/gro';
|
|
17
|
+
import type { Disknode } from '@fuzdev/gro/disknode.js';
|
|
18
18
|
import { type SourceFileInfo, type ModuleSourceOptions, type ModuleSourcePartial } from './module_helpers.js';
|
|
19
19
|
import { type OnDuplicatesCallback } from './library_generate.js';
|
|
20
20
|
/** Options for Gro library generation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library_gen.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"library_gen.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAErC,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAKxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAmB,KAAK,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAElF,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IACjC;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC5D;;;;;;;;;;;;;;;;;;OAkBG;IACH,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,QAAQ,KAAG,cAY9D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2CAA2C,GACvD,WAAW,QAAQ,CAAC,QAAQ,CAAC,EAC7B,SAAS,mBAAmB,EAC5B,MAAM;IAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;CAAC,KACtF,KAAK,CAAC,cAAc,CA6BtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,iBAAiB,KAAG,GA2CzD,CAAC"}
|
package/dist/library_gen.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
|
-
import { package_json_load } from '@
|
|
16
|
+
import { package_json_load } from '@fuzdev/gro/package_json.js';
|
|
17
17
|
import { module_create_source_options, module_validate_source_options, module_is_source, module_get_source_root, } from './module_helpers.js';
|
|
18
18
|
import { library_generate } from './library_generate.js';
|
|
19
19
|
/**
|
package/dist/module_helpers.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
74
|
-
*
|
|
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
|
|
85
|
-
*
|
|
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
|
|
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;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;;;;OAUG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;;;;;;;;;;;OAcG;IACH,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;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,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,mBAInC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,4BAA4B,GACxC,cAAc,MAAM,EACpB,YAAY,OAAO,CAAC,mBAAmB,CAAC,KACtC,mBAID,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,mBAAmB,KAAG,IAqE7E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,mBAAmB,KAAG,MAWrE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,EAAE,SAAS,mBAAmB,KAAG,MAUrF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAAI,aAAa,MAAM,KAAG,MACN,CAAC;AAE3D;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,MAAM,KAAG,MAA4B,CAAC;AAElF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM,MAAM,KAAG,OACsB,CAAC;AAE3E,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAAmC,CAAC;AAEpF,eAAO,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,OAAgC,CAAC;AAE9E,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,OAAiC,CAAC;AAEhF,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,OAAoC,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,EAAE,SAAS,mBAAmB,KAAG,OAe7E,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACvC,aAAa,cAAc,EAC3B,SAAS,mBAAmB,KAC1B;IAAC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CA2BzD,CAAC"}
|
package/dist/module_helpers.js
CHANGED
|
@@ -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)
|
|
@@ -30,12 +30,16 @@ import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
|
30
30
|
* @returns Full GitHub URL to the file on the main branch
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
+
* ```ts
|
|
33
34
|
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
35
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
36
|
+
* ```
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
39
|
+
* ```ts
|
|
37
40
|
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
41
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
42
|
+
* ```
|
|
39
43
|
*/
|
|
40
44
|
export declare const url_github_file: (repo_url: string, file_path: string, line?: number) => string;
|
|
41
45
|
/**
|
|
@@ -46,8 +50,10 @@ export declare const url_github_file: (repo_url: string, file_path: string, line
|
|
|
46
50
|
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
47
51
|
*
|
|
48
52
|
* @example
|
|
53
|
+
* ```ts
|
|
49
54
|
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
50
55
|
* // => 'https://github.com/fuzdev'
|
|
56
|
+
* ```
|
|
51
57
|
*/
|
|
52
58
|
export declare const url_github_org: (repo_url: string, repo_name: string) => string | null;
|
|
53
59
|
/**
|
|
@@ -57,12 +63,16 @@ export declare const url_github_org: (repo_url: string, repo_name: string) => st
|
|
|
57
63
|
* @returns Owner name, or null if not a valid GitHub URL
|
|
58
64
|
*
|
|
59
65
|
* @example
|
|
66
|
+
* ```ts
|
|
60
67
|
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
61
68
|
* // => 'fuzdev'
|
|
69
|
+
* ```
|
|
62
70
|
*
|
|
63
71
|
* @example
|
|
72
|
+
* ```ts
|
|
64
73
|
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
65
74
|
* // => null (not a GitHub URL)
|
|
75
|
+
* ```
|
|
66
76
|
*/
|
|
67
77
|
export declare const repo_url_github_owner: (repo_url: string) => string | null;
|
|
68
78
|
/**
|
|
@@ -72,8 +82,10 @@ export declare const repo_url_github_owner: (repo_url: string) => string | null;
|
|
|
72
82
|
* @returns Full npm package page URL
|
|
73
83
|
*
|
|
74
84
|
* @example
|
|
85
|
+
* ```ts
|
|
75
86
|
* url_npm_package('@fuzdev/fuz_ui')
|
|
76
87
|
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
88
|
+
* ```
|
|
77
89
|
*/
|
|
78
90
|
export declare const url_npm_package: (package_name: string) => string;
|
|
79
91
|
/**
|
|
@@ -96,12 +108,16 @@ export declare const package_is_published: (package_json: PackageJson) => boolea
|
|
|
96
108
|
* @throws Error if scoped package name is malformed
|
|
97
109
|
*
|
|
98
110
|
* @example
|
|
111
|
+
* ```ts
|
|
99
112
|
* repo_name_parse('@fuzdev/fuz_ui')
|
|
100
113
|
* // => 'fuz_ui'
|
|
114
|
+
* ```
|
|
101
115
|
*
|
|
102
116
|
* @example
|
|
117
|
+
* ```ts
|
|
103
118
|
* repo_name_parse('lodash')
|
|
104
119
|
* // => 'lodash'
|
|
120
|
+
* ```
|
|
105
121
|
*/
|
|
106
122
|
export declare const repo_name_parse: (name: string) => string;
|
|
107
123
|
/**
|
|
@@ -114,16 +130,22 @@ export declare const repo_name_parse: (name: string) => string;
|
|
|
114
130
|
* @returns Clean repository URL, or null if not provided
|
|
115
131
|
*
|
|
116
132
|
* @example
|
|
133
|
+
* ```ts
|
|
117
134
|
* repo_url_parse('https://github.com/foo/bar')
|
|
118
135
|
* // => 'https://github.com/foo/bar'
|
|
136
|
+
* ```
|
|
119
137
|
*
|
|
120
138
|
* @example
|
|
139
|
+
* ```ts
|
|
121
140
|
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
122
141
|
* // => 'https://github.com/foo/bar'
|
|
142
|
+
* ```
|
|
123
143
|
*
|
|
124
144
|
* @example
|
|
145
|
+
* ```ts
|
|
125
146
|
* repo_url_parse(undefined)
|
|
126
147
|
* // => null
|
|
148
|
+
* ```
|
|
127
149
|
*/
|
|
128
150
|
export declare const repo_url_parse: (repository: PackageJson["repository"]) => string | null;
|
|
129
151
|
/**
|
|
@@ -134,8 +156,10 @@ export declare const repo_url_parse: (repository: PackageJson["repository"]) =>
|
|
|
134
156
|
* @returns Full URL to the .well-known file
|
|
135
157
|
*
|
|
136
158
|
* @example
|
|
159
|
+
* ```ts
|
|
137
160
|
* url_well_known('https://fuz.dev', 'package.json')
|
|
138
161
|
* // => 'https://fuz.dev/.well-known/package.json'
|
|
162
|
+
* ```
|
|
139
163
|
*/
|
|
140
164
|
export declare const url_well_known: (homepage_url: string, filename: string) => string;
|
|
141
165
|
//# sourceMappingURL=package_helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/package_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAElE
|
|
1
|
+
{"version":3,"file":"package_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/package_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,KAAG,MAIpF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,MAAM,GAAG,IAE7E,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,IAKjE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,cAAc,MAAM,KAAG,MACP,CAAC;AAEjD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,cAAc,WAAW,KAAG,OAEhE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAS9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,WAAW,CAAC,YAAY,CAAC,KAAG,MAAM,GAAG,IAK/E,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,cAAc,MAAM,EAAE,UAAU,MAAM,KAAG,MAEvE,CAAC"}
|
package/dist/package_helpers.js
CHANGED
|
@@ -30,12 +30,16 @@ import { ensure_end, strip_end, strip_start } from '@fuzdev/fuz_util/string.js';
|
|
|
30
30
|
* @returns Full GitHub URL to the file on the main branch
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
|
+
* ```ts
|
|
33
34
|
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
34
35
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
36
|
+
* ```
|
|
35
37
|
*
|
|
36
38
|
* @example
|
|
39
|
+
* ```ts
|
|
37
40
|
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
38
41
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
42
|
+
* ```
|
|
39
43
|
*/
|
|
40
44
|
export const url_github_file = (repo_url, file_path, line) => {
|
|
41
45
|
const clean_path = file_path.replace(/^\.\//, '');
|
|
@@ -50,8 +54,10 @@ export const url_github_file = (repo_url, file_path, line) => {
|
|
|
50
54
|
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
51
55
|
*
|
|
52
56
|
* @example
|
|
57
|
+
* ```ts
|
|
53
58
|
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
54
59
|
* // => 'https://github.com/fuzdev'
|
|
60
|
+
* ```
|
|
55
61
|
*/
|
|
56
62
|
export const url_github_org = (repo_url, repo_name) => {
|
|
57
63
|
return repo_url.endsWith('/' + repo_name) ? strip_end(repo_url, '/' + repo_name) : null;
|
|
@@ -63,12 +69,16 @@ export const url_github_org = (repo_url, repo_name) => {
|
|
|
63
69
|
* @returns Owner name, or null if not a valid GitHub URL
|
|
64
70
|
*
|
|
65
71
|
* @example
|
|
72
|
+
* ```ts
|
|
66
73
|
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
67
74
|
* // => 'fuzdev'
|
|
75
|
+
* ```
|
|
68
76
|
*
|
|
69
77
|
* @example
|
|
78
|
+
* ```ts
|
|
70
79
|
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
71
80
|
* // => null (not a GitHub URL)
|
|
81
|
+
* ```
|
|
72
82
|
*/
|
|
73
83
|
export const repo_url_github_owner = (repo_url) => {
|
|
74
84
|
const stripped = strip_start(repo_url, 'https://github.com/');
|
|
@@ -84,8 +94,10 @@ export const repo_url_github_owner = (repo_url) => {
|
|
|
84
94
|
* @returns Full npm package page URL
|
|
85
95
|
*
|
|
86
96
|
* @example
|
|
97
|
+
* ```ts
|
|
87
98
|
* url_npm_package('@fuzdev/fuz_ui')
|
|
88
99
|
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
100
|
+
* ```
|
|
89
101
|
*/
|
|
90
102
|
export const url_npm_package = (package_name) => 'https://www.npmjs.com/package/' + package_name;
|
|
91
103
|
/**
|
|
@@ -110,12 +122,16 @@ export const package_is_published = (package_json) => {
|
|
|
110
122
|
* @throws Error if scoped package name is malformed
|
|
111
123
|
*
|
|
112
124
|
* @example
|
|
125
|
+
* ```ts
|
|
113
126
|
* repo_name_parse('@fuzdev/fuz_ui')
|
|
114
127
|
* // => 'fuz_ui'
|
|
128
|
+
* ```
|
|
115
129
|
*
|
|
116
130
|
* @example
|
|
131
|
+
* ```ts
|
|
117
132
|
* repo_name_parse('lodash')
|
|
118
133
|
* // => 'lodash'
|
|
134
|
+
* ```
|
|
119
135
|
*/
|
|
120
136
|
export const repo_name_parse = (name) => {
|
|
121
137
|
if (name[0] === '@') {
|
|
@@ -137,16 +153,22 @@ export const repo_name_parse = (name) => {
|
|
|
137
153
|
* @returns Clean repository URL, or null if not provided
|
|
138
154
|
*
|
|
139
155
|
* @example
|
|
156
|
+
* ```ts
|
|
140
157
|
* repo_url_parse('https://github.com/foo/bar')
|
|
141
158
|
* // => 'https://github.com/foo/bar'
|
|
159
|
+
* ```
|
|
142
160
|
*
|
|
143
161
|
* @example
|
|
162
|
+
* ```ts
|
|
144
163
|
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
145
164
|
* // => 'https://github.com/foo/bar'
|
|
165
|
+
* ```
|
|
146
166
|
*
|
|
147
167
|
* @example
|
|
168
|
+
* ```ts
|
|
148
169
|
* repo_url_parse(undefined)
|
|
149
170
|
* // => null
|
|
171
|
+
* ```
|
|
150
172
|
*/
|
|
151
173
|
export const repo_url_parse = (repository) => {
|
|
152
174
|
if (!repository)
|
|
@@ -164,8 +186,10 @@ export const repo_url_parse = (repository) => {
|
|
|
164
186
|
* @returns Full URL to the .well-known file
|
|
165
187
|
*
|
|
166
188
|
* @example
|
|
189
|
+
* ```ts
|
|
167
190
|
* url_well_known('https://fuz.dev', 'package.json')
|
|
168
191
|
* // => 'https://fuz.dev/.well-known/package.json'
|
|
192
|
+
* ```
|
|
169
193
|
*/
|
|
170
194
|
export const url_well_known = (homepage_url, filename) => {
|
|
171
195
|
return `${ensure_end(homepage_url, '/')}.well-known/${filename}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fuzdev/fuz_ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.183.0",
|
|
4
4
|
"description": "Svelte UI library",
|
|
5
5
|
"motto": "friendly user zystem",
|
|
6
6
|
"glyph": "🧶",
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
"node": ">=22.15"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@fuzdev/fuz_code": ">=0.
|
|
38
|
+
"@fuzdev/fuz_code": ">=0.45.0",
|
|
39
39
|
"@fuzdev/fuz_css": ">=0.47.0",
|
|
40
|
-
"@fuzdev/fuz_util": ">=0.
|
|
40
|
+
"@fuzdev/fuz_util": ">=0.50.1",
|
|
41
|
+
"@fuzdev/gro": ">=0.192.0",
|
|
41
42
|
"@jridgewell/trace-mapping": "^0.3",
|
|
42
43
|
"@ryanatkn/gro": ">=0.191.0",
|
|
43
44
|
"@sveltejs/kit": "^2.47.3",
|
|
@@ -54,6 +55,9 @@
|
|
|
54
55
|
"@fuzdev/fuz_util": {
|
|
55
56
|
"optional": true
|
|
56
57
|
},
|
|
58
|
+
"@fuzdev/gro": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
57
61
|
"@jridgewell/trace-mapping": {
|
|
58
62
|
"optional": true
|
|
59
63
|
},
|
|
@@ -75,9 +79,10 @@
|
|
|
75
79
|
},
|
|
76
80
|
"devDependencies": {
|
|
77
81
|
"@changesets/changelog-git": "^0.2.1",
|
|
78
|
-
"@fuzdev/fuz_code": "^0.
|
|
79
|
-
"@fuzdev/fuz_css": "^0.
|
|
82
|
+
"@fuzdev/fuz_code": "^0.45.0",
|
|
83
|
+
"@fuzdev/fuz_css": "^0.49.0",
|
|
80
84
|
"@fuzdev/fuz_util": "^0.50.1",
|
|
85
|
+
"@fuzdev/gro": "^0.192.1",
|
|
81
86
|
"@jridgewell/trace-mapping": "^0.3.31",
|
|
82
87
|
"@ryanatkn/eslint-config": "^0.9.0",
|
|
83
88
|
"@ryanatkn/gro": "^0.191.0",
|
|
@@ -97,13 +102,13 @@
|
|
|
97
102
|
"prettier-plugin-svelte": "^3.4.1",
|
|
98
103
|
"svelte": "^5.49.1",
|
|
99
104
|
"svelte-check": "^4.3.6",
|
|
100
|
-
"svelte2tsx": "^0.7.
|
|
105
|
+
"svelte2tsx": "^0.7.47",
|
|
101
106
|
"tslib": "^2.8.1",
|
|
102
107
|
"typescript": "^5.9.3",
|
|
103
108
|
"typescript-eslint": "^8.48.1",
|
|
104
109
|
"vitest": "^4.0.15",
|
|
105
110
|
"zimmerframe": "^1.1.4",
|
|
106
|
-
"zod": "^4.
|
|
111
|
+
"zod": "^4.3.6"
|
|
107
112
|
},
|
|
108
113
|
"prettier": {
|
|
109
114
|
"plugins": [
|
package/src/lib/library_gen.ts
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type {Gen} from '@
|
|
18
|
-
import {package_json_load} from '@
|
|
19
|
-
import type {Disknode} from '@
|
|
17
|
+
import type {Gen} from '@fuzdev/gro';
|
|
18
|
+
import {package_json_load} from '@fuzdev/gro/package_json.js';
|
|
19
|
+
import type {Disknode} from '@fuzdev/gro/disknode.js';
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
type SourceFileInfo,
|
|
@@ -52,10 +52,12 @@ export interface SourceFileInfo {
|
|
|
52
52
|
* handles nested directories without special heuristics.
|
|
53
53
|
*
|
|
54
54
|
* @example
|
|
55
|
+
* ```ts
|
|
55
56
|
* const options = module_create_source_options(process.cwd(), {
|
|
56
57
|
* source_paths: ['src/lib', 'src/routes'],
|
|
57
58
|
* source_root: 'src',
|
|
58
59
|
* });
|
|
60
|
+
* ```
|
|
59
61
|
*/
|
|
60
62
|
export interface ModuleSourceOptions {
|
|
61
63
|
/**
|
|
@@ -64,7 +66,10 @@ export interface ModuleSourceOptions {
|
|
|
64
66
|
* All `source_paths` are relative to this. Typically `process.cwd()` when
|
|
65
67
|
* running from the project root via Gro, Vite, or other build tools.
|
|
66
68
|
*
|
|
67
|
-
* @example
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* '/home/user/my-project'
|
|
72
|
+
* ```
|
|
68
73
|
*/
|
|
69
74
|
project_root: string;
|
|
70
75
|
/**
|
|
@@ -73,8 +78,14 @@ export interface ModuleSourceOptions {
|
|
|
73
78
|
* Paths should not have leading or trailing slashes - they are added
|
|
74
79
|
* internally for correct matching.
|
|
75
80
|
*
|
|
76
|
-
* @example
|
|
77
|
-
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* ['src/lib'] // single source directory
|
|
84
|
+
* ```
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* ['src/lib', 'src/routes'] // multiple directories
|
|
88
|
+
* ```
|
|
78
89
|
*/
|
|
79
90
|
source_paths: Array<string>;
|
|
80
91
|
/**
|
|
@@ -84,8 +95,14 @@ export interface ModuleSourceOptions {
|
|
|
84
95
|
* - Single `source_path`: defaults to that path
|
|
85
96
|
* - Multiple `source_paths`: required (no auto-derivation)
|
|
86
97
|
*
|
|
87
|
-
* @example
|
|
88
|
-
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* 'src/lib' // module paths like 'foo.ts', 'utils/bar.ts'
|
|
101
|
+
* ```
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* 'src' // module paths like 'lib/foo.ts', 'routes/page.svelte'
|
|
105
|
+
* ```
|
|
89
106
|
*/
|
|
90
107
|
source_root?: string;
|
|
91
108
|
/** Patterns to exclude (matched against full path). */
|
|
@@ -100,20 +117,24 @@ export interface ModuleSourceOptions {
|
|
|
100
117
|
* @default Uses file extension: `.svelte` → svelte, `.ts`/`.js` → typescript
|
|
101
118
|
*
|
|
102
119
|
* @example
|
|
120
|
+
* ```ts
|
|
103
121
|
* // Add MDsveX support
|
|
104
122
|
* get_analyzer: (path) => {
|
|
105
123
|
* if (path.endsWith('.svelte') || path.endsWith('.svx')) return 'svelte';
|
|
106
124
|
* if (path.endsWith('.ts') || path.endsWith('.js')) return 'typescript';
|
|
107
125
|
* return null;
|
|
108
126
|
* }
|
|
127
|
+
* ```
|
|
109
128
|
*
|
|
110
129
|
* @example
|
|
130
|
+
* ```ts
|
|
111
131
|
* // Include .d.ts files
|
|
112
132
|
* get_analyzer: (path) => {
|
|
113
133
|
* if (path.endsWith('.svelte')) return 'svelte';
|
|
114
134
|
* if (path.endsWith('.ts') || path.endsWith('.d.ts') || path.endsWith('.js')) return 'typescript';
|
|
115
135
|
* return null;
|
|
116
136
|
* }
|
|
137
|
+
* ```
|
|
117
138
|
*/
|
|
118
139
|
get_analyzer: (path: string) => AnalyzerType | null;
|
|
119
140
|
}
|
|
@@ -157,21 +178,27 @@ export const MODULE_SOURCE_PARTIAL: ModuleSourcePartial = {
|
|
|
157
178
|
* @param overrides Optional overrides for default options
|
|
158
179
|
*
|
|
159
180
|
* @example
|
|
181
|
+
* ```ts
|
|
160
182
|
* // Standard SvelteKit library
|
|
161
183
|
* const options = module_create_source_options(process.cwd());
|
|
184
|
+
* ```
|
|
162
185
|
*
|
|
163
186
|
* @example
|
|
187
|
+
* ```ts
|
|
164
188
|
* // Multiple source directories
|
|
165
189
|
* const options = module_create_source_options(process.cwd(), {
|
|
166
190
|
* source_paths: ['src/lib', 'src/routes'],
|
|
167
191
|
* source_root: 'src',
|
|
168
192
|
* });
|
|
193
|
+
* ```
|
|
169
194
|
*
|
|
170
195
|
* @example
|
|
196
|
+
* ```ts
|
|
171
197
|
* // Custom exclusions
|
|
172
198
|
* const options = module_create_source_options(process.cwd(), {
|
|
173
199
|
* exclude_patterns: [/\.test\.ts$/, /\.internal\.ts$/],
|
|
174
200
|
* });
|
|
201
|
+
* ```
|
|
175
202
|
*/
|
|
176
203
|
export const module_create_source_options = (
|
|
177
204
|
project_root: string,
|
|
@@ -195,14 +222,17 @@ export const module_create_source_options = (
|
|
|
195
222
|
* @throws Error if validation fails
|
|
196
223
|
*
|
|
197
224
|
* @example
|
|
225
|
+
* ```ts
|
|
198
226
|
* // Valid - single source path (source_root auto-derived)
|
|
199
227
|
* module_validate_source_options({
|
|
200
228
|
* project_root: '/home/user/project',
|
|
201
229
|
* source_paths: ['src/lib'],
|
|
202
230
|
* ...
|
|
203
231
|
* });
|
|
232
|
+
* ```
|
|
204
233
|
*
|
|
205
234
|
* @example
|
|
235
|
+
* ```ts
|
|
206
236
|
* // Valid - multiple source paths with explicit source_root
|
|
207
237
|
* module_validate_source_options({
|
|
208
238
|
* project_root: '/home/user/project',
|
|
@@ -210,14 +240,17 @@ export const module_create_source_options = (
|
|
|
210
240
|
* source_root: 'src',
|
|
211
241
|
* ...
|
|
212
242
|
* });
|
|
243
|
+
* ```
|
|
213
244
|
*
|
|
214
245
|
* @example
|
|
246
|
+
* ```ts
|
|
215
247
|
* // Invalid - multiple source paths without source_root
|
|
216
248
|
* module_validate_source_options({
|
|
217
249
|
* project_root: '/home/user/project',
|
|
218
250
|
* source_paths: ['src/lib', 'src/routes'], // throws
|
|
219
251
|
* ...
|
|
220
252
|
* });
|
|
253
|
+
* ```
|
|
221
254
|
*/
|
|
222
255
|
export const module_validate_source_options = (options: ModuleSourceOptions): void => {
|
|
223
256
|
const {project_root, source_paths, source_root} = options;
|
|
@@ -319,17 +352,21 @@ export const module_get_source_root = (options: ModuleSourceOptions): string =>
|
|
|
319
352
|
* @param options Module source options for path extraction
|
|
320
353
|
*
|
|
321
354
|
* @example
|
|
355
|
+
* ```ts
|
|
322
356
|
* const options = module_create_source_options('/home/user/project');
|
|
323
357
|
* module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'foo.ts'
|
|
324
358
|
* module_extract_path('/home/user/project/src/lib/nested/bar.svelte', options) // => 'nested/bar.svelte'
|
|
359
|
+
* ```
|
|
325
360
|
*
|
|
326
361
|
* @example
|
|
362
|
+
* ```ts
|
|
327
363
|
* const options = module_create_source_options('/home/user/project', {
|
|
328
364
|
* source_paths: ['src/lib', 'src/routes'],
|
|
329
365
|
* source_root: 'src',
|
|
330
366
|
* });
|
|
331
367
|
* module_extract_path('/home/user/project/src/lib/foo.ts', options) // => 'lib/foo.ts'
|
|
332
368
|
* module_extract_path('/home/user/project/src/routes/page.svelte', options) // => 'routes/page.svelte'
|
|
369
|
+
* ```
|
|
333
370
|
*/
|
|
334
371
|
export const module_extract_path = (source_id: string, options: ModuleSourceOptions): string => {
|
|
335
372
|
const effective_root = module_get_source_root(options);
|
|
@@ -347,8 +384,10 @@ export const module_extract_path = (source_id: string, options: ModuleSourceOpti
|
|
|
347
384
|
* Extract component name from a Svelte module path.
|
|
348
385
|
*
|
|
349
386
|
* @example
|
|
387
|
+
* ```ts
|
|
350
388
|
* module_get_component_name('Alert.svelte') // => 'Alert'
|
|
351
389
|
* module_get_component_name('components/Button.svelte') // => 'Button'
|
|
390
|
+
* ```
|
|
352
391
|
*/
|
|
353
392
|
export const module_get_component_name = (module_path: string): string =>
|
|
354
393
|
module_path.replace(/^.*\//, '').replace(/\.svelte$/, '');
|
|
@@ -357,7 +396,9 @@ export const module_get_component_name = (module_path: string): string =>
|
|
|
357
396
|
* Convert module path to module key format (with ./ prefix).
|
|
358
397
|
*
|
|
359
398
|
* @example
|
|
399
|
+
* ```ts
|
|
360
400
|
* module_get_key('foo.ts') // => './foo.ts'
|
|
401
|
+
* ```
|
|
361
402
|
*/
|
|
362
403
|
export const module_get_key = (module_path: string): string => `./${module_path}`;
|
|
363
404
|
|
|
@@ -394,10 +435,12 @@ export const module_is_test = (path: string): boolean => path.endsWith('.test.ts
|
|
|
394
435
|
* @returns True if the path is an analyzable source file
|
|
395
436
|
*
|
|
396
437
|
* @example
|
|
438
|
+
* ```ts
|
|
397
439
|
* const options = module_create_source_options('/home/user/project');
|
|
398
440
|
* module_is_source('/home/user/project/src/lib/foo.ts', options) // => true
|
|
399
441
|
* module_is_source('/home/user/project/src/lib/foo.test.ts', options) // => false (excluded)
|
|
400
442
|
* module_is_source('/home/user/project/src/fixtures/mini/src/lib/bar.ts', options) // => false (wrong prefix)
|
|
443
|
+
* ```
|
|
401
444
|
*/
|
|
402
445
|
export const module_is_source = (path: string, options: ModuleSourceOptions): boolean => {
|
|
403
446
|
// Check exclusion patterns first (fast regex check)
|
|
@@ -33,12 +33,16 @@ import type {PackageJson} from '@fuzdev/fuz_util/package_json.js';
|
|
|
33
33
|
* @returns Full GitHub URL to the file on the main branch
|
|
34
34
|
*
|
|
35
35
|
* @example
|
|
36
|
+
* ```ts
|
|
36
37
|
* url_github_file('https://github.com/foo/bar', 'src/index.ts')
|
|
37
38
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts'
|
|
39
|
+
* ```
|
|
38
40
|
*
|
|
39
41
|
* @example
|
|
42
|
+
* ```ts
|
|
40
43
|
* url_github_file('https://github.com/foo/bar', './src/index.ts', 42)
|
|
41
44
|
* // => 'https://github.com/foo/bar/blob/main/src/index.ts#L42'
|
|
45
|
+
* ```
|
|
42
46
|
*/
|
|
43
47
|
export const url_github_file = (repo_url: string, file_path: string, line?: number): string => {
|
|
44
48
|
const clean_path = file_path.replace(/^\.\//, '');
|
|
@@ -54,8 +58,10 @@ export const url_github_file = (repo_url: string, file_path: string, line?: numb
|
|
|
54
58
|
* @returns Organization URL, or null if repo_url doesn't end with repo_name
|
|
55
59
|
*
|
|
56
60
|
* @example
|
|
61
|
+
* ```ts
|
|
57
62
|
* url_github_org('https://github.com/fuzdev/fuz_ui', 'fuz_ui')
|
|
58
63
|
* // => 'https://github.com/fuzdev'
|
|
64
|
+
* ```
|
|
59
65
|
*/
|
|
60
66
|
export const url_github_org = (repo_url: string, repo_name: string): string | null => {
|
|
61
67
|
return repo_url.endsWith('/' + repo_name) ? strip_end(repo_url, '/' + repo_name) : null;
|
|
@@ -68,12 +74,16 @@ export const url_github_org = (repo_url: string, repo_name: string): string | nu
|
|
|
68
74
|
* @returns Owner name, or null if not a valid GitHub URL
|
|
69
75
|
*
|
|
70
76
|
* @example
|
|
77
|
+
* ```ts
|
|
71
78
|
* repo_url_github_owner('https://github.com/fuzdev/fuz_ui')
|
|
72
79
|
* // => 'fuzdev'
|
|
80
|
+
* ```
|
|
73
81
|
*
|
|
74
82
|
* @example
|
|
83
|
+
* ```ts
|
|
75
84
|
* repo_url_github_owner('https://gitlab.com/foo/bar')
|
|
76
85
|
* // => null (not a GitHub URL)
|
|
86
|
+
* ```
|
|
77
87
|
*/
|
|
78
88
|
export const repo_url_github_owner = (repo_url: string): string | null => {
|
|
79
89
|
const stripped = strip_start(repo_url, 'https://github.com/');
|
|
@@ -89,8 +99,10 @@ export const repo_url_github_owner = (repo_url: string): string | null => {
|
|
|
89
99
|
* @returns Full npm package page URL
|
|
90
100
|
*
|
|
91
101
|
* @example
|
|
102
|
+
* ```ts
|
|
92
103
|
* url_npm_package('@fuzdev/fuz_ui')
|
|
93
104
|
* // => 'https://www.npmjs.com/package/@fuzdev/fuz_ui'
|
|
105
|
+
* ```
|
|
94
106
|
*/
|
|
95
107
|
export const url_npm_package = (package_name: string): string =>
|
|
96
108
|
'https://www.npmjs.com/package/' + package_name;
|
|
@@ -118,12 +130,16 @@ export const package_is_published = (package_json: PackageJson): boolean => {
|
|
|
118
130
|
* @throws Error if scoped package name is malformed
|
|
119
131
|
*
|
|
120
132
|
* @example
|
|
133
|
+
* ```ts
|
|
121
134
|
* repo_name_parse('@fuzdev/fuz_ui')
|
|
122
135
|
* // => 'fuz_ui'
|
|
136
|
+
* ```
|
|
123
137
|
*
|
|
124
138
|
* @example
|
|
139
|
+
* ```ts
|
|
125
140
|
* repo_name_parse('lodash')
|
|
126
141
|
* // => 'lodash'
|
|
142
|
+
* ```
|
|
127
143
|
*/
|
|
128
144
|
export const repo_name_parse = (name: string): string => {
|
|
129
145
|
if (name[0] === '@') {
|
|
@@ -146,16 +162,22 @@ export const repo_name_parse = (name: string): string => {
|
|
|
146
162
|
* @returns Clean repository URL, or null if not provided
|
|
147
163
|
*
|
|
148
164
|
* @example
|
|
165
|
+
* ```ts
|
|
149
166
|
* repo_url_parse('https://github.com/foo/bar')
|
|
150
167
|
* // => 'https://github.com/foo/bar'
|
|
168
|
+
* ```
|
|
151
169
|
*
|
|
152
170
|
* @example
|
|
171
|
+
* ```ts
|
|
153
172
|
* repo_url_parse({url: 'git+https://github.com/foo/bar.git'})
|
|
154
173
|
* // => 'https://github.com/foo/bar'
|
|
174
|
+
* ```
|
|
155
175
|
*
|
|
156
176
|
* @example
|
|
177
|
+
* ```ts
|
|
157
178
|
* repo_url_parse(undefined)
|
|
158
179
|
* // => null
|
|
180
|
+
* ```
|
|
159
181
|
*/
|
|
160
182
|
export const repo_url_parse = (repository: PackageJson['repository']): string | null => {
|
|
161
183
|
if (!repository) return null;
|
|
@@ -172,8 +194,10 @@ export const repo_url_parse = (repository: PackageJson['repository']): string |
|
|
|
172
194
|
* @returns Full URL to the .well-known file
|
|
173
195
|
*
|
|
174
196
|
* @example
|
|
197
|
+
* ```ts
|
|
175
198
|
* url_well_known('https://fuz.dev', 'package.json')
|
|
176
199
|
* // => 'https://fuz.dev/.well-known/package.json'
|
|
200
|
+
* ```
|
|
177
201
|
*/
|
|
178
202
|
export const url_well_known = (homepage_url: string, filename: string): string => {
|
|
179
203
|
return `${ensure_end(homepage_url, '/')}.well-known/${filename}`;
|