@fuzdev/fuz_ui 0.175.0 → 0.176.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/Alert.svelte +2 -0
- package/dist/Alert.svelte.d.ts.map +1 -1
- package/dist/ApiModule.svelte +5 -6
- package/dist/ApiModule.svelte.d.ts.map +1 -1
- package/dist/DeclarationDetail.svelte +2 -1
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/Details.svelte +2 -0
- package/dist/Details.svelte.d.ts.map +1 -1
- package/dist/Themed.svelte +2 -0
- package/dist/Themed.svelte.d.ts.map +1 -1
- package/dist/analysis_context.d.ts +195 -0
- package/dist/analysis_context.d.ts.map +1 -0
- package/dist/analysis_context.js +134 -0
- package/dist/library_analysis.d.ts +112 -0
- package/dist/library_analysis.d.ts.map +1 -0
- package/dist/library_analysis.js +106 -0
- package/dist/library_gen.d.ts +73 -5
- package/dist/library_gen.d.ts.map +1 -1
- package/dist/library_gen.js +130 -68
- package/dist/library_gen_helpers.d.ts +81 -72
- package/dist/library_gen_helpers.d.ts.map +1 -1
- package/dist/library_gen_helpers.js +115 -156
- package/dist/library_gen_output.d.ts +34 -0
- package/dist/library_gen_output.d.ts.map +1 -0
- package/dist/library_gen_output.js +40 -0
- package/dist/mdz.d.ts +3 -0
- package/dist/mdz.d.ts.map +1 -1
- package/dist/mdz.js +12 -3
- package/dist/module_helpers.d.ts +246 -24
- package/dist/module_helpers.d.ts.map +1 -1
- package/dist/module_helpers.js +250 -42
- package/dist/svelte_helpers.d.ts +65 -10
- package/dist/svelte_helpers.d.ts.map +1 -1
- package/dist/svelte_helpers.js +171 -49
- package/dist/ts_helpers.d.ts +132 -61
- package/dist/ts_helpers.d.ts.map +1 -1
- package/dist/ts_helpers.js +423 -282
- package/dist/tsdoc_helpers.d.ts +11 -0
- package/dist/tsdoc_helpers.d.ts.map +1 -1
- package/dist/tsdoc_helpers.js +22 -47
- package/dist/tsdoc_mdz.d.ts +36 -0
- package/dist/tsdoc_mdz.d.ts.map +1 -0
- package/dist/tsdoc_mdz.js +56 -0
- package/dist/vite_plugin_library_well_known.js +5 -5
- package/package.json +11 -6
- package/src/lib/analysis_context.ts +250 -0
- package/src/lib/library_analysis.ts +168 -0
- package/src/lib/library_gen.ts +199 -83
- package/src/lib/library_gen_helpers.ts +148 -215
- package/src/lib/library_gen_output.ts +63 -0
- package/src/lib/mdz.ts +13 -4
- package/src/lib/module_helpers.ts +392 -47
- package/src/lib/svelte_helpers.ts +291 -55
- package/src/lib/ts_helpers.ts +538 -338
- package/src/lib/tsdoc_helpers.ts +24 -49
- package/src/lib/tsdoc_mdz.ts +62 -0
- package/src/lib/vite_plugin_library_well_known.ts +5 -5
package/dist/library_gen.d.ts
CHANGED
|
@@ -11,13 +11,79 @@
|
|
|
11
11
|
* - Dependency graphs
|
|
12
12
|
* - Svelte component props
|
|
13
13
|
*
|
|
14
|
+
* This file contains Gro-specific integration. The actual analysis logic is in
|
|
15
|
+
* build-tool agnostic helpers that work with `SourceFileInfo`.
|
|
16
|
+
*
|
|
14
17
|
* @see @fuzdev/fuz_util/source_json.js for type definitions
|
|
15
|
-
* @see
|
|
16
|
-
* @see
|
|
17
|
-
* @see
|
|
18
|
-
* @see
|
|
18
|
+
* @see `library_analysis.ts` for the unified analysis entry point
|
|
19
|
+
* @see `library_gen_helpers.ts` for pipeline orchestration helpers
|
|
20
|
+
* @see `tsdoc_helpers.ts` for JSDoc/TSDoc parsing
|
|
21
|
+
* @see `ts_helpers.ts` for TypeScript analysis
|
|
22
|
+
* @see `svelte_helpers.ts` for Svelte component analysis
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
19
25
|
*/
|
|
20
26
|
import type { Gen } from '@ryanatkn/gro';
|
|
27
|
+
import type { Disknode } from '@ryanatkn/gro/disknode.js';
|
|
28
|
+
import { type SourceFileInfo, type ModuleSourceOptions, type ModuleSourcePartial } from './module_helpers.js';
|
|
29
|
+
import { type DuplicateInfo } from './library_gen_helpers.js';
|
|
30
|
+
/** Options for library generation. */
|
|
31
|
+
export interface LibraryGenOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Module source options for filtering and path extraction.
|
|
34
|
+
*
|
|
35
|
+
* Can provide full `ModuleSourceOptions` or partial options that will be
|
|
36
|
+
* merged with defaults. The `project_root` is automatically set to
|
|
37
|
+
* `process.cwd()` if not provided.
|
|
38
|
+
*/
|
|
39
|
+
source?: ModuleSourceOptions | Partial<ModuleSourcePartial>;
|
|
40
|
+
/**
|
|
41
|
+
* Callback invoked when duplicate declaration names are found.
|
|
42
|
+
*
|
|
43
|
+
* Consumers decide how to handle duplicates: throw, warn, or ignore.
|
|
44
|
+
* Use `library_gen_throw_on_duplicates` for strict flat namespace enforcement.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Throw on duplicates (strict flat namespace)
|
|
48
|
+
* library_gen({ on_duplicates: library_gen_throw_on_duplicates });
|
|
49
|
+
*
|
|
50
|
+
* // Warn but continue
|
|
51
|
+
* library_gen({
|
|
52
|
+
* on_duplicates: (dupes, log) => {
|
|
53
|
+
* for (const [name, locs] of dupes) {
|
|
54
|
+
* log.warn(`Duplicate: ${name} in ${locs.map(l => l.module).join(', ')}`);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
on_duplicates?: OnDuplicatesCallback;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Callback for handling duplicate declaration names.
|
|
63
|
+
*
|
|
64
|
+
* @param duplicates Map of declaration names to their occurrences across modules
|
|
65
|
+
* @param log Logger for reporting
|
|
66
|
+
*/
|
|
67
|
+
export type OnDuplicatesCallback = (duplicates: Map<string, Array<DuplicateInfo>>, log: {
|
|
68
|
+
error: (...args: Array<unknown>) => void;
|
|
69
|
+
}) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Strict duplicate handler that throws on any duplicate declaration names.
|
|
72
|
+
*
|
|
73
|
+
* Use this callback with `library_gen({ on_duplicates: library_gen_throw_on_duplicates })`
|
|
74
|
+
* to enforce a flat namespace where all declaration names must be unique.
|
|
75
|
+
*
|
|
76
|
+
* @throws Error if any duplicate declaration names are found
|
|
77
|
+
*/
|
|
78
|
+
export declare const library_gen_throw_on_duplicates: OnDuplicatesCallback;
|
|
79
|
+
/**
|
|
80
|
+
* Convert Gro's Disknode to the build-tool agnostic SourceFileInfo interface.
|
|
81
|
+
*
|
|
82
|
+
* Use this when you want to analyze files using Gro's filer directly.
|
|
83
|
+
*
|
|
84
|
+
* @throws Error if disknode has no content (should be loaded by Gro filer)
|
|
85
|
+
*/
|
|
86
|
+
export declare const source_file_from_disknode: (disknode: Disknode) => SourceFileInfo;
|
|
21
87
|
/**
|
|
22
88
|
* Creates a Gen object for generating library metadata with full TypeScript analysis.
|
|
23
89
|
*
|
|
@@ -28,6 +94,8 @@ import type { Gen } from '@ryanatkn/gro';
|
|
|
28
94
|
*
|
|
29
95
|
* export const gen = library_gen();
|
|
30
96
|
* ```
|
|
97
|
+
*
|
|
98
|
+
* @param options Optional generation options
|
|
31
99
|
*/
|
|
32
|
-
export declare const library_gen: () => Gen;
|
|
100
|
+
export declare const library_gen: (options?: LibraryGenOptions) => Gen;
|
|
33
101
|
//# sourceMappingURL=library_gen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library_gen.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"library_gen.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAC,GAAG,EAAC,MAAM,eAAe,CAAC;AAEvC,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAC;AAIxD,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAGxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAMN,KAAK,aAAa,EAClB,MAAM,0BAA0B,CAAC;AAIlC,sCAAsC;AACtC,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;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,EAC7C,GAAG,EAAE;IAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;CAAC,KAC3C,IAAI,CAAC;AAEV;;;;;;;GAOG;AACH,eAAO,MAAM,+BAA+B,EAAE,oBAkB7C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,QAAQ,KAAG,cAY9D,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,iBAAiB,KAAG,GAuHzD,CAAC"}
|
package/dist/library_gen.js
CHANGED
|
@@ -11,16 +11,68 @@
|
|
|
11
11
|
* - Dependency graphs
|
|
12
12
|
* - Svelte component props
|
|
13
13
|
*
|
|
14
|
+
* This file contains Gro-specific integration. The actual analysis logic is in
|
|
15
|
+
* build-tool agnostic helpers that work with `SourceFileInfo`.
|
|
16
|
+
*
|
|
14
17
|
* @see @fuzdev/fuz_util/source_json.js for type definitions
|
|
15
|
-
* @see
|
|
16
|
-
* @see
|
|
17
|
-
* @see
|
|
18
|
-
* @see
|
|
18
|
+
* @see `library_analysis.ts` for the unified analysis entry point
|
|
19
|
+
* @see `library_gen_helpers.ts` for pipeline orchestration helpers
|
|
20
|
+
* @see `tsdoc_helpers.ts` for JSDoc/TSDoc parsing
|
|
21
|
+
* @see `ts_helpers.ts` for TypeScript analysis
|
|
22
|
+
* @see `svelte_helpers.ts` for Svelte component analysis
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
19
25
|
*/
|
|
20
26
|
import { package_json_load } from '@ryanatkn/gro/package_json.js';
|
|
21
|
-
import { ts_create_program } from
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
27
|
+
import { ts_create_program } from './ts_helpers.js';
|
|
28
|
+
import { module_create_source_options, module_validate_source_options, } from './module_helpers.js';
|
|
29
|
+
import { library_analyze_module } from './library_analysis.js';
|
|
30
|
+
import { library_collect_source_files, library_sort_modules, library_find_duplicates, library_merge_re_exports, } from './library_gen_helpers.js';
|
|
31
|
+
import { library_generate_json } from './library_gen_output.js';
|
|
32
|
+
import { AnalysisContext, format_diagnostic } from './analysis_context.js';
|
|
33
|
+
/**
|
|
34
|
+
* Strict duplicate handler that throws on any duplicate declaration names.
|
|
35
|
+
*
|
|
36
|
+
* Use this callback with `library_gen({ on_duplicates: library_gen_throw_on_duplicates })`
|
|
37
|
+
* to enforce a flat namespace where all declaration names must be unique.
|
|
38
|
+
*
|
|
39
|
+
* @throws Error if any duplicate declaration names are found
|
|
40
|
+
*/
|
|
41
|
+
export const library_gen_throw_on_duplicates = (duplicates, log) => {
|
|
42
|
+
if (duplicates.size === 0)
|
|
43
|
+
return;
|
|
44
|
+
log.error('Duplicate declaration names detected in flat namespace:');
|
|
45
|
+
for (const [name, occurrences] of duplicates) {
|
|
46
|
+
log.error(` "${name}" found in:`);
|
|
47
|
+
for (const { declaration, module } of occurrences) {
|
|
48
|
+
const line_info = declaration.source_line !== undefined ? `:${declaration.source_line}` : '';
|
|
49
|
+
log.error(` - ${module}${line_info} (${declaration.kind})`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`Found ${duplicates.size} duplicate declaration name${duplicates.size === 1 ? '' : 's'} across modules. ` +
|
|
53
|
+
'The flat namespace requires unique names. To resolve: ' +
|
|
54
|
+
'(1) rename one of the conflicting declarations, or ' +
|
|
55
|
+
'(2) add /** @nodocs */ to exclude from documentation. ' +
|
|
56
|
+
'See CLAUDE.md "Declaration namespacing" section for details.');
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Convert Gro's Disknode to the build-tool agnostic SourceFileInfo interface.
|
|
60
|
+
*
|
|
61
|
+
* Use this when you want to analyze files using Gro's filer directly.
|
|
62
|
+
*
|
|
63
|
+
* @throws Error if disknode has no content (should be loaded by Gro filer)
|
|
64
|
+
*/
|
|
65
|
+
export const source_file_from_disknode = (disknode) => {
|
|
66
|
+
if (disknode.contents == null) {
|
|
67
|
+
throw new Error(`Source file has no content: ${disknode.id} (ensure Gro filer loads file contents)`);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
id: disknode.id,
|
|
71
|
+
content: disknode.contents,
|
|
72
|
+
dependencies: [...disknode.dependencies.keys()],
|
|
73
|
+
dependents: [...disknode.dependents.keys()],
|
|
74
|
+
};
|
|
75
|
+
};
|
|
24
76
|
/**
|
|
25
77
|
* Creates a Gen object for generating library metadata with full TypeScript analysis.
|
|
26
78
|
*
|
|
@@ -31,92 +83,102 @@ import { library_gen_collect_source_files, library_gen_sort_modules, library_gen
|
|
|
31
83
|
*
|
|
32
84
|
* export const gen = library_gen();
|
|
33
85
|
* ```
|
|
86
|
+
*
|
|
87
|
+
* @param options Optional generation options
|
|
34
88
|
*/
|
|
35
|
-
export const library_gen = () => {
|
|
89
|
+
export const library_gen = (options) => {
|
|
36
90
|
return {
|
|
37
91
|
generate: async ({ log, filer }) => {
|
|
38
92
|
log.info('generating library metadata with full TypeScript analysis...');
|
|
93
|
+
// Build source options with project_root from cwd
|
|
94
|
+
const source_options = options?.source && 'project_root' in options.source
|
|
95
|
+
? options.source
|
|
96
|
+
: module_create_source_options(process.cwd(), options?.source);
|
|
97
|
+
// Validate options early to fail fast on misconfiguration
|
|
98
|
+
// (before expensive operations like program creation)
|
|
99
|
+
module_validate_source_options(source_options);
|
|
39
100
|
// Ensure filer is initialized
|
|
40
101
|
await filer.init();
|
|
41
102
|
// Read package.json
|
|
42
103
|
const package_json = await package_json_load();
|
|
43
104
|
// Create TypeScript program
|
|
44
|
-
const program = ts_create_program(log);
|
|
45
|
-
|
|
46
|
-
|
|
105
|
+
const { program } = ts_create_program(undefined, log);
|
|
106
|
+
// Create analysis context for collecting diagnostics
|
|
107
|
+
const ctx = new AnalysisContext();
|
|
108
|
+
// Convert Gro's filer files to build-tool agnostic SourceFileInfo
|
|
109
|
+
const all_source_files = [];
|
|
110
|
+
for (const disknode of filer.files.values()) {
|
|
111
|
+
all_source_files.push(source_file_from_disknode(disknode));
|
|
47
112
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
113
|
+
// Collect and filter source files
|
|
114
|
+
const source_files = library_collect_source_files(all_source_files, source_options, log);
|
|
115
|
+
// Collect modules (declared before source_json to include directly)
|
|
116
|
+
const modules = [];
|
|
51
117
|
// Build source_json with array-based modules
|
|
52
118
|
// Phase 1: Analyze all modules and collect re-exports
|
|
53
119
|
const source_json = {
|
|
54
120
|
name: package_json.name,
|
|
55
121
|
version: package_json.version,
|
|
56
|
-
modules
|
|
122
|
+
modules,
|
|
57
123
|
};
|
|
58
|
-
// Collect
|
|
59
|
-
//
|
|
60
|
-
const
|
|
61
|
-
for (const
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
124
|
+
// Collect re-exports for phase 2 merging
|
|
125
|
+
// See library_merge_re_exports for the two-phase resolution strategy
|
|
126
|
+
const collected_re_exports = [];
|
|
127
|
+
for (const source_file of source_files) {
|
|
128
|
+
// Use unified analyzer that dispatches based on file type
|
|
129
|
+
const result = library_analyze_module(source_file, program, source_options, ctx, log);
|
|
130
|
+
if (!result)
|
|
131
|
+
continue;
|
|
132
|
+
// Build ModuleJson, filtering out @nodocs declarations
|
|
133
|
+
const module = {
|
|
134
|
+
path: result.path,
|
|
135
|
+
declarations: result.declarations.filter((d) => !d.nodocs).map((d) => d.declaration),
|
|
136
|
+
};
|
|
137
|
+
if (result.module_comment)
|
|
138
|
+
module.module_comment = result.module_comment;
|
|
139
|
+
if (result.dependencies.length > 0)
|
|
140
|
+
module.dependencies = result.dependencies;
|
|
141
|
+
if (result.dependents.length > 0)
|
|
142
|
+
module.dependents = result.dependents;
|
|
143
|
+
if (result.star_exports.length > 0)
|
|
144
|
+
module.star_exports = result.star_exports;
|
|
145
|
+
modules.push(module);
|
|
146
|
+
// Collect re-exports for phase 2 merging
|
|
147
|
+
for (const re_export of result.re_exports) {
|
|
148
|
+
collected_re_exports.push({ re_exporting_module: result.path, re_export });
|
|
84
149
|
}
|
|
85
150
|
}
|
|
86
151
|
// Phase 2: Build also_exported_from arrays from re-export data
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if (!module_map.has(name)) {
|
|
96
|
-
module_map.set(name, []);
|
|
152
|
+
library_merge_re_exports(source_json, collected_re_exports);
|
|
153
|
+
// Sort modules alphabetically for deterministic output and cleaner diffs
|
|
154
|
+
source_json.modules = library_sort_modules(modules);
|
|
155
|
+
// Check for duplicate declaration names and invoke callback if provided
|
|
156
|
+
if (options?.on_duplicates) {
|
|
157
|
+
const duplicates = library_find_duplicates(source_json);
|
|
158
|
+
if (duplicates.size > 0) {
|
|
159
|
+
options.on_duplicates(duplicates, log);
|
|
97
160
|
}
|
|
98
|
-
module_map.get(name).push(re_exporting_module);
|
|
99
161
|
}
|
|
100
|
-
//
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
162
|
+
// Report any analysis diagnostics
|
|
163
|
+
if (ctx.diagnostics.length > 0) {
|
|
164
|
+
const errors = ctx.errors();
|
|
165
|
+
const warnings = ctx.warnings();
|
|
166
|
+
const format_options = { strip_base: process.cwd() };
|
|
167
|
+
if (errors.length > 0) {
|
|
168
|
+
log.error(`Analysis completed with ${errors.length} error(s):`);
|
|
169
|
+
for (const diagnostic of errors) {
|
|
170
|
+
log.error(` ${format_diagnostic(diagnostic, format_options)}`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (warnings.length > 0) {
|
|
174
|
+
log.warn(`Analysis completed with ${warnings.length} warning(s):`);
|
|
175
|
+
for (const diagnostic of warnings) {
|
|
176
|
+
log.warn(` ${format_diagnostic(diagnostic, format_options)}`);
|
|
109
177
|
}
|
|
110
178
|
}
|
|
111
179
|
}
|
|
112
|
-
// Sort modules alphabetically for deterministic output and cleaner diffs
|
|
113
|
-
source_json.modules = source_json.modules
|
|
114
|
-
? library_gen_sort_modules(source_json.modules)
|
|
115
|
-
: undefined;
|
|
116
|
-
// Validate no duplicate declaration names across modules
|
|
117
|
-
library_gen_validate_no_duplicates(source_json, log);
|
|
118
180
|
log.info('library metadata generation complete');
|
|
119
|
-
const { json_content, ts_content } =
|
|
181
|
+
const { json_content, ts_content } = library_generate_json(package_json, source_json);
|
|
120
182
|
// Return array of files:
|
|
121
183
|
// - library.json (default from .gen.json.ts naming)
|
|
122
184
|
// - library.ts (typed wrapper that validates with zod)
|
|
@@ -1,101 +1,110 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Library metadata generation helpers - pipeline orchestration.
|
|
3
3
|
*
|
|
4
|
-
* These functions handle
|
|
5
|
-
*
|
|
4
|
+
* These functions handle collection, validation, and transformation of library metadata
|
|
5
|
+
* during the generation pipeline. They are internal to the generation process.
|
|
6
6
|
*
|
|
7
|
-
* - `
|
|
8
|
-
* - `svelte_helpers.ts` - `svelte_analyze_file`
|
|
9
|
-
* - `module_helpers.ts` - path utilities and source detection
|
|
7
|
+
* For source analysis (the consumer-facing API), see `library_analysis.ts`.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* Pipeline stages:
|
|
10
|
+
* 1. **Collection** - `library_collect_source_files` gathers and filters source files
|
|
11
|
+
* 2. **Analysis** - `library_analyze_module` (in library_analysis.ts) extracts metadata
|
|
12
|
+
* 3. **Validation** - `library_find_duplicates` checks flat namespace constraints
|
|
13
|
+
* 4. **Transformation** - `library_merge_re_exports` resolves re-export relationships
|
|
14
|
+
* 5. **Output** - `library_sort_modules` prepares deterministic output
|
|
13
15
|
*
|
|
14
|
-
* @see
|
|
15
|
-
* @see
|
|
16
|
-
* @see
|
|
17
|
-
*
|
|
16
|
+
* @see library_analysis.ts for the analysis entry point
|
|
17
|
+
* @see library_gen_output.ts for output file generation (JSON/TS wrapper)
|
|
18
|
+
* @see library_gen.ts for the main generation task (Gro-specific)
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
18
21
|
*/
|
|
19
|
-
import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
20
22
|
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
21
|
-
import type { ModuleJson, SourceJson } from '@fuzdev/fuz_util/source_json.js';
|
|
22
|
-
import type {
|
|
23
|
-
import type
|
|
24
|
-
import type { PathId } from '@fuzdev/fuz_util/path.js';
|
|
25
|
-
import { type ReExportInfo } from './ts_helpers.js';
|
|
23
|
+
import type { DeclarationJson, ModuleJson, SourceJson } from '@fuzdev/fuz_util/source_json.js';
|
|
24
|
+
import type { ReExportInfo } from './library_analysis.js';
|
|
25
|
+
import { type SourceFileInfo, type ModuleSourceOptions } from './module_helpers.js';
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* Includes both the module metadata and re-export information for post-processing.
|
|
27
|
+
* A duplicate declaration with its full metadata and module path.
|
|
29
28
|
*/
|
|
30
|
-
export interface
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
29
|
+
export interface DuplicateInfo {
|
|
30
|
+
/** The full declaration metadata. */
|
|
31
|
+
declaration: DeclarationJson;
|
|
32
|
+
/** Module path where this declaration is defined. */
|
|
33
|
+
module: string;
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* Find duplicate declaration names across modules.
|
|
37
|
+
*
|
|
38
|
+
* Returns a Map of declaration names to their full metadata (only includes duplicates).
|
|
39
|
+
* Callers can decide how to handle duplicates (throw, warn, ignore).
|
|
39
40
|
*
|
|
40
|
-
* @
|
|
41
|
+
* @example
|
|
42
|
+
* const duplicates = library_find_duplicates(source_json);
|
|
43
|
+
* if (duplicates.size > 0) {
|
|
44
|
+
* for (const [name, occurrences] of duplicates) {
|
|
45
|
+
* console.error(`"${name}" found in:`);
|
|
46
|
+
* for (const {declaration, module} of occurrences) {
|
|
47
|
+
* console.error(` - ${module}:${declaration.source_line} (${declaration.kind})`);
|
|
48
|
+
* }
|
|
49
|
+
* }
|
|
50
|
+
* throw new Error(`Found ${duplicates.size} duplicate declaration names`);
|
|
51
|
+
* }
|
|
41
52
|
*/
|
|
42
|
-
export declare const
|
|
53
|
+
export declare const library_find_duplicates: (source_json: SourceJson) => Map<string, Array<DuplicateInfo>>;
|
|
43
54
|
/**
|
|
44
55
|
* Sort modules alphabetically by path for deterministic output and cleaner diffs.
|
|
45
56
|
*/
|
|
46
|
-
export declare const
|
|
57
|
+
export declare const library_sort_modules: (modules: Array<ModuleJson>) => Array<ModuleJson>;
|
|
47
58
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
59
|
+
* A collected re-export with its source module context.
|
|
60
|
+
*
|
|
61
|
+
* Used during the two-phase re-export resolution:
|
|
62
|
+
* 1. Phase 1: Collect re-exports from each module during analysis
|
|
63
|
+
* 2. Phase 2: Group by original module and merge into `also_exported_from`
|
|
50
64
|
*/
|
|
51
|
-
export interface
|
|
52
|
-
/**
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
65
|
+
export interface CollectedReExport {
|
|
66
|
+
/** The module that re-exports the declaration. */
|
|
67
|
+
re_exporting_module: string;
|
|
68
|
+
/** The re-export info (name and original module). */
|
|
69
|
+
re_export: ReExportInfo;
|
|
56
70
|
}
|
|
57
71
|
/**
|
|
58
|
-
*
|
|
59
|
-
* Parses at generation time so runtime only needs the pre-computed result.
|
|
60
|
-
*
|
|
61
|
-
* Returns JSON + .ts wrapper because:
|
|
62
|
-
* - JSON is natively importable by Node.js and Vite without TypeScript loaders
|
|
63
|
-
* - Works in CI environments that don't have TS compilation
|
|
64
|
-
* - The .ts wrapper validates with zod and exports with proper types
|
|
65
|
-
* (JSON imports get widened types like `string` instead of literal unions)
|
|
66
|
-
*/
|
|
67
|
-
export declare const library_gen_generate_json: (package_json: PackageJson, source_json: SourceJson) => LibraryGenOutput;
|
|
68
|
-
/**
|
|
69
|
-
* Collect and filter source files from filer.
|
|
72
|
+
* Build `also_exported_from` arrays from collected re-export data.
|
|
70
73
|
*
|
|
71
|
-
*
|
|
72
|
-
* Returns an empty array with a warning if no source files are found.
|
|
73
|
-
*/
|
|
74
|
-
export declare const library_gen_collect_source_files: (files: Map<PathId, Disknode>, log: Logger) => Array<Disknode>;
|
|
75
|
-
/**
|
|
76
|
-
* Analyze a Svelte component file and extract metadata.
|
|
74
|
+
* This function resolves the two-phase re-export problem:
|
|
77
75
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
*
|
|
76
|
+
* **Problem**: When module A re-exports from module B, we discover this while
|
|
77
|
+
* analyzing A, but need to update B's declarations. However, B may already be
|
|
78
|
+
* processed or may be processed later.
|
|
79
|
+
*
|
|
80
|
+
* **Solution**: Collect all re-exports in phase 1, then merge them in phase 2
|
|
81
|
+
* after all modules are analyzed.
|
|
84
82
|
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
83
|
+
* @example
|
|
84
|
+
* // helpers.ts exports: foo, bar
|
|
85
|
+
* // index.ts does: export {foo, bar} from './helpers.js'
|
|
86
|
+
* //
|
|
87
|
+
* // After processing:
|
|
88
|
+
* // - helpers.ts foo declaration gets: also_exported_from: ['index.ts']
|
|
89
|
+
* // - helpers.ts bar declaration gets: also_exported_from: ['index.ts']
|
|
87
90
|
*
|
|
88
|
-
*
|
|
91
|
+
* @param source_json The source JSON with all modules (will be mutated)
|
|
92
|
+
* @param collected_re_exports Array of re-exports collected during phase 1
|
|
93
|
+
* @mutates source_json - adds `also_exported_from` to declarations
|
|
89
94
|
*/
|
|
90
|
-
export declare const
|
|
95
|
+
export declare const library_merge_re_exports: (source_json: SourceJson, collected_re_exports: Array<CollectedReExport>) => void;
|
|
91
96
|
/**
|
|
92
|
-
*
|
|
97
|
+
* Collect and filter source files.
|
|
98
|
+
*
|
|
99
|
+
* Returns source files for TypeScript/JS files and Svelte components, excluding test files.
|
|
100
|
+
* Returns an empty array with a warning if no source files are found.
|
|
101
|
+
*
|
|
102
|
+
* File types are determined by `options.get_analyzer`. By default, `.ts`, `.js`, and `.svelte`
|
|
103
|
+
* files are supported. Customize `get_analyzer` to support additional file types like `.svx`.
|
|
93
104
|
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
105
|
+
* @param files Iterable of source file info (from Gro filer, file system, or other source)
|
|
106
|
+
* @param options Module source options for filtering
|
|
107
|
+
* @param log Optional logger for status messages
|
|
96
108
|
*/
|
|
97
|
-
export declare const
|
|
98
|
-
dependencies: Array<string>;
|
|
99
|
-
dependents: Array<string>;
|
|
100
|
-
};
|
|
109
|
+
export declare const library_collect_source_files: (files: Iterable<SourceFileInfo>, options: ModuleSourceOptions, log?: Logger) => Array<SourceFileInfo>;
|
|
101
110
|
//# sourceMappingURL=library_gen_helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library_gen_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen_helpers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"library_gen_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_gen_helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,iCAAiC,CAAC;AAE7F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAIxB,MAAM,qBAAqB,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,qCAAqC;IACrC,WAAW,EAAE,eAAe,CAAC;IAC7B,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GACnC,aAAa,UAAU,KACrB,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,CA0BlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,KAAK,CAAC,UAAU,CAAC,KAAG,KAAK,CAAC,UAAU,CAEjF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,SAAS,EAAE,YAAY,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,UAAU,EACvB,sBAAsB,KAAK,CAAC,iBAAiB,CAAC,KAC5C,IAgCF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,4BAA4B,GACxC,OAAO,QAAQ,CAAC,cAAc,CAAC,EAC/B,SAAS,mBAAmB,EAC5B,MAAM,MAAM,KACV,KAAK,CAAC,cAAc,CA0BtB,CAAC"}
|