@fuzdev/fuz_ui 0.193.1 → 0.195.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/dist/DeclarationDetail.svelte +139 -64
- package/dist/DeclarationDetail.svelte.d.ts +9 -0
- package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
- package/dist/LibraryDetail.svelte +14 -10
- package/dist/LibraryDetail.svelte.d.ts +7 -0
- package/dist/LibraryDetail.svelte.d.ts.map +1 -1
- package/dist/Spiders.svelte +4 -2
- package/dist/Spiders.svelte.d.ts +2 -1
- package/dist/Spiders.svelte.d.ts.map +1 -1
- package/dist/StyleVariableButton.svelte +1 -1
- package/dist/contextmenu_state.svelte.d.ts +14 -14
- package/dist/contextmenu_state.svelte.d.ts.map +1 -1
- package/dist/contextmenu_state.svelte.js +3 -3
- package/dist/declaration.svelte.d.ts +233 -25
- package/dist/declaration.svelte.d.ts.map +1 -1
- package/dist/declaration.svelte.js +71 -23
- package/dist/docs_helpers.svelte.d.ts +5 -5
- package/dist/docs_helpers.svelte.d.ts.map +1 -1
- package/dist/docs_helpers.svelte.js +1 -1
- package/dist/library.svelte.d.ts +5 -5
- package/dist/library.svelte.d.ts.map +1 -1
- package/dist/library.svelte.js +2 -2
- package/dist/library_gen.d.ts +24 -17
- package/dist/library_gen.d.ts.map +1 -1
- package/dist/library_gen.js +52 -32
- package/dist/library_output.d.ts +5 -4
- package/dist/library_output.d.ts.map +1 -1
- package/dist/library_output.js +11 -8
- package/dist/mdz_components.d.ts +16 -16
- package/dist/mdz_components.d.ts.map +1 -1
- package/dist/module.svelte.d.ts +21 -7
- package/dist/module.svelte.d.ts.map +1 -1
- package/dist/module.svelte.js +26 -11
- package/dist/style_variable_helpers.svelte.d.ts +4 -4
- package/dist/style_variable_helpers.svelte.d.ts.map +1 -1
- package/dist/style_variable_helpers.svelte.js +1 -1
- package/dist/tome.d.ts +10 -10
- package/dist/tome.d.ts.map +1 -1
- package/dist/tome.js +2 -2
- package/dist/tsdoc_mdz.d.ts +6 -1
- package/dist/tsdoc_mdz.d.ts.map +1 -1
- package/dist/tsdoc_mdz.js +23 -2
- package/package.json +11 -9
- package/src/lib/contextmenu_state.svelte.ts +6 -6
- package/src/lib/declaration.svelte.ts +90 -35
- package/src/lib/docs_helpers.svelte.ts +2 -2
- package/src/lib/library.svelte.ts +3 -3
- package/src/lib/library_gen.ts +65 -42
- package/src/lib/library_output.ts +11 -8
- package/src/lib/mdz_components.ts +18 -18
- package/src/lib/module.svelte.ts +29 -16
- package/src/lib/style_variable_helpers.svelte.ts +2 -2
- package/src/lib/tome.ts +4 -4
- package/src/lib/tsdoc_mdz.ts +25 -2
- package/dist/analysis_context.d.ts +0 -199
- package/dist/analysis_context.d.ts.map +0 -1
- package/dist/analysis_context.js +0 -138
- package/dist/library_analysis.d.ts +0 -112
- package/dist/library_analysis.d.ts.map +0 -1
- package/dist/library_analysis.js +0 -106
- package/dist/library_generate.d.ts +0 -94
- package/dist/library_generate.d.ts.map +0 -1
- package/dist/library_generate.js +0 -147
- package/dist/library_pipeline.d.ts +0 -113
- package/dist/library_pipeline.d.ts.map +0 -1
- package/dist/library_pipeline.js +0 -160
- package/dist/module_helpers.d.ts +0 -334
- package/dist/module_helpers.d.ts.map +0 -1
- package/dist/module_helpers.js +0 -317
- package/dist/svelte_helpers.d.ts +0 -92
- package/dist/svelte_helpers.d.ts.map +0 -1
- package/dist/svelte_helpers.js +0 -367
- package/dist/ts_helpers.d.ts +0 -181
- package/dist/ts_helpers.d.ts.map +0 -1
- package/dist/ts_helpers.js +0 -674
- package/dist/tsdoc_helpers.d.ts +0 -119
- package/dist/tsdoc_helpers.d.ts.map +0 -1
- package/dist/tsdoc_helpers.js +0 -207
- package/src/lib/analysis_context.ts +0 -254
- package/src/lib/library_analysis.ts +0 -168
- package/src/lib/library_generate.ts +0 -215
- package/src/lib/library_pipeline.ts +0 -221
- package/src/lib/module_helpers.ts +0 -501
- package/src/lib/svelte_helpers.ts +0 -539
- package/src/lib/ts_helpers.ts +0 -862
- package/src/lib/tsdoc_helpers.ts +0 -246
package/dist/library_analysis.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library source analysis - unified entry point and shared types.
|
|
3
|
-
*
|
|
4
|
-
* Provides a single function for analyzing TypeScript and Svelte source files,
|
|
5
|
-
* dispatching to the appropriate domain-specific analyzer.
|
|
6
|
-
*
|
|
7
|
-
* This module also exports shared types used by both analyzers:
|
|
8
|
-
* - `DeclarationAnalysis` - A declaration with its nodocs flag
|
|
9
|
-
* - `ReExportInfo` - Information about a same-name re-export
|
|
10
|
-
* - `ModuleAnalysis` - Result of analyzing a module (unified structure)
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* import {library_analyze_module} from './library_analysis.js';
|
|
15
|
-
* import {ts_create_program} from './ts_helpers.js';
|
|
16
|
-
* import {module_create_source_options} from './module_helpers.js';
|
|
17
|
-
* import {AnalysisContext} from './analysis_context.js';
|
|
18
|
-
*
|
|
19
|
-
* const {program} = ts_create_program({root: './my-project'});
|
|
20
|
-
* const ctx = new AnalysisContext();
|
|
21
|
-
* const options = module_create_source_options('/my-project');
|
|
22
|
-
*
|
|
23
|
-
* const result = library_analyze_module(
|
|
24
|
-
* {id: '/my-project/src/lib/file.ts', content: '...'},
|
|
25
|
-
* program,
|
|
26
|
-
* options,
|
|
27
|
-
* ctx,
|
|
28
|
-
* );
|
|
29
|
-
*
|
|
30
|
-
* if (result) {
|
|
31
|
-
* // Filter out @nodocs declarations
|
|
32
|
-
* const declarations = result.declarations
|
|
33
|
-
* .filter(d => !d.nodocs)
|
|
34
|
-
* .map(d => d.declaration);
|
|
35
|
-
* console.log('Declarations:', declarations);
|
|
36
|
-
* }
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @see `ts_helpers.ts` for TypeScript-specific analysis
|
|
40
|
-
* @see `svelte_helpers.ts` for Svelte component analysis
|
|
41
|
-
* @see `module_helpers.ts` for path utilities and `SourceFileInfo`
|
|
42
|
-
*
|
|
43
|
-
* @module
|
|
44
|
-
*/
|
|
45
|
-
import ts from 'typescript';
|
|
46
|
-
import { ts_analyze_module } from './ts_helpers.js';
|
|
47
|
-
import { svelte_analyze_module } from './svelte_helpers.js';
|
|
48
|
-
import { module_extract_path, } from './module_helpers.js';
|
|
49
|
-
/**
|
|
50
|
-
* Analyze a source file and extract module metadata.
|
|
51
|
-
*
|
|
52
|
-
* Unified entry point that dispatches to the appropriate analyzer based on file type:
|
|
53
|
-
* - TypeScript/JS files → `ts_analyze_module`
|
|
54
|
-
* - Svelte components → `svelte_analyze_module`
|
|
55
|
-
*
|
|
56
|
-
* Returns raw analysis data including `nodocs` flags on declarations.
|
|
57
|
-
* Consumer is responsible for filtering based on their policy.
|
|
58
|
-
*
|
|
59
|
-
* This function can be called incrementally - consumers may cache results and
|
|
60
|
-
* only re-analyze changed files. The TypeScript program should include all files
|
|
61
|
-
* for accurate type resolution, but only changed files need re-analysis.
|
|
62
|
-
*
|
|
63
|
-
* @param source_file - the source file info with content and optional dependency data
|
|
64
|
-
* @param program - TypeScript program (used for type checking and source file lookup)
|
|
65
|
-
* @param options - module source options for path extraction
|
|
66
|
-
* @param ctx - analysis context for collecting diagnostics
|
|
67
|
-
* @param log - optional logger for warnings
|
|
68
|
-
* @returns module metadata and re-exports, or undefined if source file not found in program
|
|
69
|
-
*/
|
|
70
|
-
export const library_analyze_module = (source_file, program, options, ctx, log) => {
|
|
71
|
-
const checker = program.getTypeChecker();
|
|
72
|
-
const module_path = module_extract_path(source_file.id, options);
|
|
73
|
-
const analyzer_type = options.get_analyzer(source_file.id);
|
|
74
|
-
if (analyzer_type === 'svelte') {
|
|
75
|
-
return svelte_analyze_module(source_file, module_path, checker, options, ctx);
|
|
76
|
-
}
|
|
77
|
-
if (analyzer_type === 'typescript') {
|
|
78
|
-
const ts_source_file = program.getSourceFile(source_file.id);
|
|
79
|
-
if (!ts_source_file) {
|
|
80
|
-
ctx.add({
|
|
81
|
-
kind: 'module_skipped',
|
|
82
|
-
file: module_path,
|
|
83
|
-
line: null,
|
|
84
|
-
column: null,
|
|
85
|
-
message: `Could not get source file from program: ${source_file.id}`,
|
|
86
|
-
severity: 'warning',
|
|
87
|
-
reason: 'not_in_program',
|
|
88
|
-
});
|
|
89
|
-
log?.warn(`Could not get source file from program: ${source_file.id}`);
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
return ts_analyze_module(source_file, ts_source_file, module_path, checker, options, ctx);
|
|
93
|
-
}
|
|
94
|
-
// analyzer_type is null - skip this file
|
|
95
|
-
ctx.add({
|
|
96
|
-
kind: 'module_skipped',
|
|
97
|
-
file: module_path,
|
|
98
|
-
line: null,
|
|
99
|
-
column: null,
|
|
100
|
-
message: `No analyzer for file type: ${source_file.id}`,
|
|
101
|
-
severity: 'warning',
|
|
102
|
-
reason: 'no_analyzer',
|
|
103
|
-
});
|
|
104
|
-
log?.warn(`No analyzer for file: ${source_file.id}`);
|
|
105
|
-
return undefined;
|
|
106
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic library metadata generation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides build-tool agnostic library generation. It takes source files
|
|
5
|
-
* and package metadata, analyzes them, and produces structured metadata with:
|
|
6
|
-
* - JSDoc/TSDoc comments with full tag support
|
|
7
|
-
* - Full type signatures
|
|
8
|
-
* - Source code locations
|
|
9
|
-
* - Parameter information with descriptions and defaults
|
|
10
|
-
* - Return value documentation
|
|
11
|
-
* - Usage examples
|
|
12
|
-
* - Dependency graphs
|
|
13
|
-
* - Svelte component props
|
|
14
|
-
*
|
|
15
|
-
* For Gro integration, see `library_gen.ts` which wraps this with Gro's `Gen` interface.
|
|
16
|
-
*
|
|
17
|
-
* @see `@fuzdev/fuz_util/source_json.js` for type definitions
|
|
18
|
-
* @see `library_analysis.ts` for the unified analysis entry point
|
|
19
|
-
* @see `library_pipeline.ts` for pipeline helpers
|
|
20
|
-
* @see `library_output.ts` for JSON/TS file generation
|
|
21
|
-
*
|
|
22
|
-
* @module
|
|
23
|
-
*/
|
|
24
|
-
import type ts from 'typescript';
|
|
25
|
-
import type { SourceJson } from '@fuzdev/fuz_util/source_json.js';
|
|
26
|
-
import type { PackageJson } from '@fuzdev/fuz_util/package_json.js';
|
|
27
|
-
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
28
|
-
import { type SourceFileInfo, type ModuleSourceOptions } from './module_helpers.js';
|
|
29
|
-
import { type DuplicateInfo } from './library_pipeline.js';
|
|
30
|
-
/**
|
|
31
|
-
* Callback for handling duplicate declaration names.
|
|
32
|
-
*
|
|
33
|
-
* @param duplicates - map of declaration names to their occurrences across modules
|
|
34
|
-
* @param log - logger for reporting
|
|
35
|
-
*/
|
|
36
|
-
export type OnDuplicatesCallback = (duplicates: Map<string, Array<DuplicateInfo>>, log: {
|
|
37
|
-
error: (...args: Array<unknown>) => void;
|
|
38
|
-
}) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Strict duplicate handler that throws on any duplicate declaration names.
|
|
41
|
-
*
|
|
42
|
-
* Use this callback with `library_generate({ on_duplicates: library_throw_on_duplicates })`
|
|
43
|
-
* to enforce a flat namespace where all declaration names must be unique.
|
|
44
|
-
*
|
|
45
|
-
* @throws Error if any duplicate declaration names are found
|
|
46
|
-
*/
|
|
47
|
-
export declare const library_throw_on_duplicates: OnDuplicatesCallback;
|
|
48
|
-
/** Input for library metadata generation. */
|
|
49
|
-
export interface LibraryGenerateInput {
|
|
50
|
-
/** Source files to analyze (must have content loaded). */
|
|
51
|
-
source_files: Array<SourceFileInfo>;
|
|
52
|
-
/** Package metadata (name, version). */
|
|
53
|
-
package_json: PackageJson;
|
|
54
|
-
/** Module source options for path extraction. */
|
|
55
|
-
source_options: ModuleSourceOptions;
|
|
56
|
-
/**
|
|
57
|
-
* Optional TypeScript program. If not provided, one will be created.
|
|
58
|
-
* Pass an existing program to reuse across multiple calls.
|
|
59
|
-
*/
|
|
60
|
-
program?: ts.Program;
|
|
61
|
-
/** Optional callback for handling duplicate declaration names. */
|
|
62
|
-
on_duplicates?: OnDuplicatesCallback;
|
|
63
|
-
/** Optional logger for status and diagnostic messages. */
|
|
64
|
-
log?: Logger;
|
|
65
|
-
}
|
|
66
|
-
/** Result of library metadata generation. */
|
|
67
|
-
export interface LibraryGenerateResult {
|
|
68
|
-
/** The generated source metadata. */
|
|
69
|
-
source_json: SourceJson;
|
|
70
|
-
/** JSON file content string. */
|
|
71
|
-
json_content: string;
|
|
72
|
-
/** TypeScript wrapper file content string. */
|
|
73
|
-
ts_content: string;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Generate library metadata from source files.
|
|
77
|
-
*
|
|
78
|
-
* This is the main entry point for library generation. It analyzes source files,
|
|
79
|
-
* extracts metadata, and produces both structured data and file contents.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* const result = library_generate({
|
|
84
|
-
* source_files,
|
|
85
|
-
* package_json: {name: '@my/lib', version: '1.0.0'},
|
|
86
|
-
* source_options: module_create_source_options(process.cwd()),
|
|
87
|
-
* });
|
|
88
|
-
*
|
|
89
|
-
* await writeFile('library.json', result.json_content);
|
|
90
|
-
* await writeFile('library.ts', result.ts_content);
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
export declare const library_generate: (input: LibraryGenerateInput) => LibraryGenerateResult;
|
|
94
|
-
//# sourceMappingURL=library_generate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"library_generate.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAC,UAAU,EAAa,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAClE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAC,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAC,MAAM,qBAAqB,CAAC;AAElF,OAAO,EAKN,KAAK,aAAa,EAClB,MAAM,uBAAuB,CAAC;AAI/B;;;;;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,2BAA2B,EAAE,oBAiBzC,CAAC;AAEF,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACpC,0DAA0D;IAC1D,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACpC,wCAAwC;IACxC,YAAY,EAAE,WAAW,CAAC;IAC1B,iDAAiD;IACjD,cAAc,EAAE,mBAAmB,CAAC;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC;IACrB,kEAAkE;IAClE,aAAa,CAAC,EAAE,oBAAoB,CAAC;IACrC,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAED,6CAA6C;AAC7C,MAAM,WAAW,qBAAqB;IACrC,qCAAqC;IACrC,WAAW,EAAE,UAAU,CAAC;IACxB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,oBAAoB,KAAG,qBAuF9D,CAAC"}
|
package/dist/library_generate.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic library metadata generation.
|
|
3
|
-
*
|
|
4
|
-
* This module provides build-tool agnostic library generation. It takes source files
|
|
5
|
-
* and package metadata, analyzes them, and produces structured metadata with:
|
|
6
|
-
* - JSDoc/TSDoc comments with full tag support
|
|
7
|
-
* - Full type signatures
|
|
8
|
-
* - Source code locations
|
|
9
|
-
* - Parameter information with descriptions and defaults
|
|
10
|
-
* - Return value documentation
|
|
11
|
-
* - Usage examples
|
|
12
|
-
* - Dependency graphs
|
|
13
|
-
* - Svelte component props
|
|
14
|
-
*
|
|
15
|
-
* For Gro integration, see `library_gen.ts` which wraps this with Gro's `Gen` interface.
|
|
16
|
-
*
|
|
17
|
-
* @see `@fuzdev/fuz_util/source_json.js` for type definitions
|
|
18
|
-
* @see `library_analysis.ts` for the unified analysis entry point
|
|
19
|
-
* @see `library_pipeline.ts` for pipeline helpers
|
|
20
|
-
* @see `library_output.ts` for JSON/TS file generation
|
|
21
|
-
*
|
|
22
|
-
* @module
|
|
23
|
-
*/
|
|
24
|
-
import { ts_create_program } from './ts_helpers.js';
|
|
25
|
-
import {} from './module_helpers.js';
|
|
26
|
-
import { library_analyze_module } from './library_analysis.js';
|
|
27
|
-
import { library_sort_modules, library_find_duplicates, library_merge_re_exports, } from './library_pipeline.js';
|
|
28
|
-
import { library_generate_output } from './library_output.js';
|
|
29
|
-
import { AnalysisContext, format_diagnostic } from './analysis_context.js';
|
|
30
|
-
/**
|
|
31
|
-
* Strict duplicate handler that throws on any duplicate declaration names.
|
|
32
|
-
*
|
|
33
|
-
* Use this callback with `library_generate({ on_duplicates: library_throw_on_duplicates })`
|
|
34
|
-
* to enforce a flat namespace where all declaration names must be unique.
|
|
35
|
-
*
|
|
36
|
-
* @throws Error if any duplicate declaration names are found
|
|
37
|
-
*/
|
|
38
|
-
export const library_throw_on_duplicates = (duplicates, log) => {
|
|
39
|
-
if (duplicates.size === 0)
|
|
40
|
-
return;
|
|
41
|
-
log.error('Duplicate declaration names detected in flat namespace:');
|
|
42
|
-
for (const [name, occurrences] of duplicates) {
|
|
43
|
-
log.error(` "${name}" found in:`);
|
|
44
|
-
for (const { declaration, module } of occurrences) {
|
|
45
|
-
const line_info = declaration.source_line !== undefined ? `:${declaration.source_line}` : '';
|
|
46
|
-
log.error(` - ${module}${line_info} (${declaration.kind})`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
throw new Error(`Found ${duplicates.size} duplicate declaration name${duplicates.size === 1 ? '' : 's'} across modules. ` +
|
|
50
|
-
'The flat namespace requires unique names. To resolve: ' +
|
|
51
|
-
'(1) rename one of the conflicting declarations, or ' +
|
|
52
|
-
'(2) add /** @nodocs */ to exclude from documentation.');
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Generate library metadata from source files.
|
|
56
|
-
*
|
|
57
|
-
* This is the main entry point for library generation. It analyzes source files,
|
|
58
|
-
* extracts metadata, and produces both structured data and file contents.
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```ts
|
|
62
|
-
* const result = library_generate({
|
|
63
|
-
* source_files,
|
|
64
|
-
* package_json: {name: '@my/lib', version: '1.0.0'},
|
|
65
|
-
* source_options: module_create_source_options(process.cwd()),
|
|
66
|
-
* });
|
|
67
|
-
*
|
|
68
|
-
* await writeFile('library.json', result.json_content);
|
|
69
|
-
* await writeFile('library.ts', result.ts_content);
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export const library_generate = (input) => {
|
|
73
|
-
const { source_files, package_json, source_options, on_duplicates, log } = input;
|
|
74
|
-
// Create or use provided TypeScript program
|
|
75
|
-
const program = input.program ?? ts_create_program(undefined, log).program;
|
|
76
|
-
// Create analysis context for collecting diagnostics
|
|
77
|
-
const ctx = new AnalysisContext();
|
|
78
|
-
// Collect modules
|
|
79
|
-
const modules = [];
|
|
80
|
-
// Build source_json with array-based modules
|
|
81
|
-
// Phase 1: Analyze all modules and collect re-exports
|
|
82
|
-
const source_json = {
|
|
83
|
-
name: package_json.name,
|
|
84
|
-
version: package_json.version || '',
|
|
85
|
-
modules,
|
|
86
|
-
};
|
|
87
|
-
// Collect re-exports for phase 2 merging
|
|
88
|
-
// See library_merge_re_exports for the two-phase resolution strategy
|
|
89
|
-
const collected_re_exports = [];
|
|
90
|
-
for (const source_file of source_files) {
|
|
91
|
-
// Use unified analyzer that dispatches based on file type
|
|
92
|
-
const result = library_analyze_module(source_file, program, source_options, ctx, log);
|
|
93
|
-
if (!result)
|
|
94
|
-
continue;
|
|
95
|
-
// Build ModuleJson, filtering out @nodocs declarations
|
|
96
|
-
const module = {
|
|
97
|
-
path: result.path,
|
|
98
|
-
declarations: result.declarations.filter((d) => !d.nodocs).map((d) => d.declaration),
|
|
99
|
-
};
|
|
100
|
-
if (result.module_comment)
|
|
101
|
-
module.module_comment = result.module_comment;
|
|
102
|
-
if (result.dependencies.length > 0)
|
|
103
|
-
module.dependencies = result.dependencies;
|
|
104
|
-
if (result.dependents.length > 0)
|
|
105
|
-
module.dependents = result.dependents;
|
|
106
|
-
if (result.star_exports.length > 0)
|
|
107
|
-
module.star_exports = result.star_exports;
|
|
108
|
-
modules.push(module);
|
|
109
|
-
// Collect re-exports for phase 2 merging
|
|
110
|
-
for (const re_export of result.re_exports) {
|
|
111
|
-
collected_re_exports.push({ re_exporting_module: result.path, re_export });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// Phase 2: Build also_exported_from arrays from re-export data
|
|
115
|
-
library_merge_re_exports(source_json, collected_re_exports);
|
|
116
|
-
// Sort modules alphabetically for deterministic output and cleaner diffs
|
|
117
|
-
source_json.modules = library_sort_modules(modules);
|
|
118
|
-
// Check for duplicate declaration names and invoke callback if provided
|
|
119
|
-
if (on_duplicates) {
|
|
120
|
-
const duplicates = library_find_duplicates(source_json);
|
|
121
|
-
if (duplicates.size > 0) {
|
|
122
|
-
// Use provided logger or a minimal fallback
|
|
123
|
-
const error_log = log ?? { error: (...args) => console.error(...args) }; // eslint-disable-line no-console
|
|
124
|
-
on_duplicates(duplicates, error_log);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Report any analysis diagnostics
|
|
128
|
-
if (ctx.diagnostics.length > 0 && log) {
|
|
129
|
-
const errors = ctx.errors();
|
|
130
|
-
const warnings = ctx.warnings();
|
|
131
|
-
const format_options = { strip_base: source_options.project_root };
|
|
132
|
-
if (errors.length > 0) {
|
|
133
|
-
log.error(`Analysis completed with ${errors.length} error(s):`);
|
|
134
|
-
for (const diagnostic of errors) {
|
|
135
|
-
log.error(` ${format_diagnostic(diagnostic, format_options)}`);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (warnings.length > 0) {
|
|
139
|
-
log.warn(`Analysis completed with ${warnings.length} warning(s):`);
|
|
140
|
-
for (const diagnostic of warnings) {
|
|
141
|
-
log.warn(` ${format_diagnostic(diagnostic, format_options)}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const { json_content, ts_content } = library_generate_output(package_json, source_json);
|
|
146
|
-
return { source_json, json_content, ts_content };
|
|
147
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library metadata generation pipeline.
|
|
3
|
-
*
|
|
4
|
-
* These functions handle collection, validation, and transformation of library metadata
|
|
5
|
-
* during the generation pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Pipeline stages:
|
|
8
|
-
* 1. **Collection** - `library_collect_source_files` gathers and filters source files
|
|
9
|
-
* 2. **Analysis** - `library_analyze_module` (in `library_analysis.ts`) extracts metadata
|
|
10
|
-
* 3. **Validation** - `library_find_duplicates` checks flat namespace constraints
|
|
11
|
-
* 4. **Transformation** - `library_merge_re_exports` resolves re-export relationships
|
|
12
|
-
* 5. **Output** - `library_sort_modules` prepares deterministic output
|
|
13
|
-
*
|
|
14
|
-
* @see `library_generate.ts` for the main generation entry point
|
|
15
|
-
* @see `library_analysis.ts` for module-level analysis
|
|
16
|
-
* @see `library_output.ts` for output file generation (JSON/TS wrapper)
|
|
17
|
-
* @see `library_gen.ts` for Gro-specific integration
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
import type { Logger } from '@fuzdev/fuz_util/log.js';
|
|
22
|
-
import type { DeclarationJson, ModuleJson, SourceJson } from '@fuzdev/fuz_util/source_json.js';
|
|
23
|
-
import type { ReExportInfo } from './library_analysis.js';
|
|
24
|
-
import { type SourceFileInfo, type ModuleSourceOptions } from './module_helpers.js';
|
|
25
|
-
/**
|
|
26
|
-
* A duplicate declaration with its full metadata and module path.
|
|
27
|
-
*/
|
|
28
|
-
export interface DuplicateInfo {
|
|
29
|
-
/** The full declaration metadata. */
|
|
30
|
-
declaration: DeclarationJson;
|
|
31
|
-
/** Module path where this declaration is defined. */
|
|
32
|
-
module: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Find duplicate declaration names across modules.
|
|
36
|
-
*
|
|
37
|
-
* Returns a Map of declaration names to their full metadata (only includes duplicates).
|
|
38
|
-
* Callers can decide how to handle duplicates (throw, warn, ignore).
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```ts
|
|
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
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
export declare const library_find_duplicates: (source_json: SourceJson) => Map<string, Array<DuplicateInfo>>;
|
|
55
|
-
/**
|
|
56
|
-
* Sort modules alphabetically by path for deterministic output and cleaner diffs.
|
|
57
|
-
*/
|
|
58
|
-
export declare const library_sort_modules: (modules: Array<ModuleJson>) => Array<ModuleJson>;
|
|
59
|
-
/**
|
|
60
|
-
* A collected re-export with its source module context.
|
|
61
|
-
*
|
|
62
|
-
* Used during the two-phase re-export resolution:
|
|
63
|
-
* 1. Phase 1: Collect re-exports from each module during analysis
|
|
64
|
-
* 2. Phase 2: Group by original module and merge into `also_exported_from`
|
|
65
|
-
*/
|
|
66
|
-
export interface CollectedReExport {
|
|
67
|
-
/** The module that re-exports the declaration. */
|
|
68
|
-
re_exporting_module: string;
|
|
69
|
-
/** The re-export info (name and original module). */
|
|
70
|
-
re_export: ReExportInfo;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Build `also_exported_from` arrays from collected re-export data.
|
|
74
|
-
*
|
|
75
|
-
* This function resolves the two-phase re-export problem:
|
|
76
|
-
*
|
|
77
|
-
* **Problem**: When module A re-exports from module B, we discover this while
|
|
78
|
-
* analyzing A, but need to update B's declarations. However, B may already be
|
|
79
|
-
* processed or may be processed later.
|
|
80
|
-
*
|
|
81
|
-
* **Solution**: Collect all re-exports in phase 1, then merge them in phase 2
|
|
82
|
-
* after all modules are analyzed.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* // helpers.ts exports: foo, bar
|
|
87
|
-
* // index.ts does: export {foo, bar} from './helpers.js'
|
|
88
|
-
* //
|
|
89
|
-
* // After processing:
|
|
90
|
-
* // - helpers.ts foo declaration gets: also_exported_from: ['index.ts']
|
|
91
|
-
* // - helpers.ts bar declaration gets: also_exported_from: ['index.ts']
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @param source_json - the source JSON with all modules (will be mutated)
|
|
95
|
-
* @param collected_re_exports - array of re-exports collected during phase 1
|
|
96
|
-
* @mutates source_json - adds `also_exported_from` to declarations
|
|
97
|
-
*/
|
|
98
|
-
export declare const library_merge_re_exports: (source_json: SourceJson, collected_re_exports: Array<CollectedReExport>) => void;
|
|
99
|
-
/**
|
|
100
|
-
* Collect and filter source files.
|
|
101
|
-
*
|
|
102
|
-
* Returns source files for TypeScript/JS files and Svelte components, excluding test files.
|
|
103
|
-
* Returns an empty array with a warning if no source files are found.
|
|
104
|
-
*
|
|
105
|
-
* File types are determined by `options.get_analyzer`. By default, `.ts`, `.js`, and `.svelte`
|
|
106
|
-
* files are supported. Customize `get_analyzer` to support additional file types like `.svx`.
|
|
107
|
-
*
|
|
108
|
-
* @param files - iterable of source file info (from Gro filer, file system, or other source)
|
|
109
|
-
* @param options - module source options for filtering
|
|
110
|
-
* @param log - optional logger for status messages
|
|
111
|
-
*/
|
|
112
|
-
export declare const library_collect_source_files: (files: Iterable<SourceFileInfo>, options: ModuleSourceOptions, log?: Logger) => Array<SourceFileInfo>;
|
|
113
|
-
//# sourceMappingURL=library_pipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"library_pipeline.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;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;;;;;;;;;;;;;;;;;;;GAmBG;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;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;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"}
|
package/dist/library_pipeline.js
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library metadata generation pipeline.
|
|
3
|
-
*
|
|
4
|
-
* These functions handle collection, validation, and transformation of library metadata
|
|
5
|
-
* during the generation pipeline.
|
|
6
|
-
*
|
|
7
|
-
* Pipeline stages:
|
|
8
|
-
* 1. **Collection** - `library_collect_source_files` gathers and filters source files
|
|
9
|
-
* 2. **Analysis** - `library_analyze_module` (in `library_analysis.ts`) extracts metadata
|
|
10
|
-
* 3. **Validation** - `library_find_duplicates` checks flat namespace constraints
|
|
11
|
-
* 4. **Transformation** - `library_merge_re_exports` resolves re-export relationships
|
|
12
|
-
* 5. **Output** - `library_sort_modules` prepares deterministic output
|
|
13
|
-
*
|
|
14
|
-
* @see `library_generate.ts` for the main generation entry point
|
|
15
|
-
* @see `library_analysis.ts` for module-level analysis
|
|
16
|
-
* @see `library_output.ts` for output file generation (JSON/TS wrapper)
|
|
17
|
-
* @see `library_gen.ts` for Gro-specific integration
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
import { module_is_source, module_validate_source_options, module_get_source_root, } from './module_helpers.js';
|
|
22
|
-
/**
|
|
23
|
-
* Find duplicate declaration names across modules.
|
|
24
|
-
*
|
|
25
|
-
* Returns a Map of declaration names to their full metadata (only includes duplicates).
|
|
26
|
-
* Callers can decide how to handle duplicates (throw, warn, ignore).
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const duplicates = library_find_duplicates(source_json);
|
|
31
|
-
* if (duplicates.size > 0) {
|
|
32
|
-
* for (const [name, occurrences] of duplicates) {
|
|
33
|
-
* console.error(`"${name}" found in:`);
|
|
34
|
-
* for (const {declaration, module} of occurrences) {
|
|
35
|
-
* console.error(` - ${module}:${declaration.source_line} (${declaration.kind})`);
|
|
36
|
-
* }
|
|
37
|
-
* }
|
|
38
|
-
* throw new Error(`Found ${duplicates.size} duplicate declaration names`);
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export const library_find_duplicates = (source_json) => {
|
|
43
|
-
const all_occurrences = new Map();
|
|
44
|
-
// Collect all declaration names and their full metadata
|
|
45
|
-
for (const mod of source_json.modules ?? []) {
|
|
46
|
-
for (const declaration of mod.declarations ?? []) {
|
|
47
|
-
const name = declaration.name;
|
|
48
|
-
if (!all_occurrences.has(name)) {
|
|
49
|
-
all_occurrences.set(name, []);
|
|
50
|
-
}
|
|
51
|
-
all_occurrences.get(name).push({
|
|
52
|
-
declaration,
|
|
53
|
-
module: mod.path,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
// Filter to only duplicates
|
|
58
|
-
const duplicates = new Map();
|
|
59
|
-
for (const [name, occurrences] of all_occurrences) {
|
|
60
|
-
if (occurrences.length > 1) {
|
|
61
|
-
duplicates.set(name, occurrences);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return duplicates;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Sort modules alphabetically by path for deterministic output and cleaner diffs.
|
|
68
|
-
*/
|
|
69
|
-
export const library_sort_modules = (modules) => {
|
|
70
|
-
return modules.slice().sort((a, b) => a.path.localeCompare(b.path));
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Build `also_exported_from` arrays from collected re-export data.
|
|
74
|
-
*
|
|
75
|
-
* This function resolves the two-phase re-export problem:
|
|
76
|
-
*
|
|
77
|
-
* **Problem**: When module A re-exports from module B, we discover this while
|
|
78
|
-
* analyzing A, but need to update B's declarations. However, B may already be
|
|
79
|
-
* processed or may be processed later.
|
|
80
|
-
*
|
|
81
|
-
* **Solution**: Collect all re-exports in phase 1, then merge them in phase 2
|
|
82
|
-
* after all modules are analyzed.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```ts
|
|
86
|
-
* // helpers.ts exports: foo, bar
|
|
87
|
-
* // index.ts does: export {foo, bar} from './helpers.js'
|
|
88
|
-
* //
|
|
89
|
-
* // After processing:
|
|
90
|
-
* // - helpers.ts foo declaration gets: also_exported_from: ['index.ts']
|
|
91
|
-
* // - helpers.ts bar declaration gets: also_exported_from: ['index.ts']
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* @param source_json - the source JSON with all modules (will be mutated)
|
|
95
|
-
* @param collected_re_exports - array of re-exports collected during phase 1
|
|
96
|
-
* @mutates source_json - adds `also_exported_from` to declarations
|
|
97
|
-
*/
|
|
98
|
-
export const library_merge_re_exports = (source_json, collected_re_exports) => {
|
|
99
|
-
// Group re-exports by original module and declaration name
|
|
100
|
-
// Structure: Map<original_module_path, Map<declaration_name, Array<re_exporting_module_path>>>
|
|
101
|
-
const re_export_map = new Map();
|
|
102
|
-
for (const { re_exporting_module, re_export } of collected_re_exports) {
|
|
103
|
-
const { name, original_module } = re_export;
|
|
104
|
-
if (!re_export_map.has(original_module)) {
|
|
105
|
-
re_export_map.set(original_module, new Map());
|
|
106
|
-
}
|
|
107
|
-
const module_map = re_export_map.get(original_module);
|
|
108
|
-
if (!module_map.has(name)) {
|
|
109
|
-
module_map.set(name, []);
|
|
110
|
-
}
|
|
111
|
-
module_map.get(name).push(re_exporting_module);
|
|
112
|
-
}
|
|
113
|
-
// Merge into original declarations
|
|
114
|
-
for (const mod of source_json.modules ?? []) {
|
|
115
|
-
const module_re_exports = re_export_map.get(mod.path);
|
|
116
|
-
if (!module_re_exports)
|
|
117
|
-
continue;
|
|
118
|
-
for (const declaration of mod.declarations ?? []) {
|
|
119
|
-
const re_exporters = module_re_exports.get(declaration.name);
|
|
120
|
-
if (re_exporters?.length) {
|
|
121
|
-
// Sort for deterministic output
|
|
122
|
-
declaration.also_exported_from = re_exporters.sort();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
/**
|
|
128
|
-
* Collect and filter source files.
|
|
129
|
-
*
|
|
130
|
-
* Returns source files for TypeScript/JS files and Svelte components, excluding test files.
|
|
131
|
-
* Returns an empty array with a warning if no source files are found.
|
|
132
|
-
*
|
|
133
|
-
* File types are determined by `options.get_analyzer`. By default, `.ts`, `.js`, and `.svelte`
|
|
134
|
-
* files are supported. Customize `get_analyzer` to support additional file types like `.svx`.
|
|
135
|
-
*
|
|
136
|
-
* @param files - iterable of source file info (from Gro filer, file system, or other source)
|
|
137
|
-
* @param options - module source options for filtering
|
|
138
|
-
* @param log - optional logger for status messages
|
|
139
|
-
*/
|
|
140
|
-
export const library_collect_source_files = (files, options, log) => {
|
|
141
|
-
// Validate options early to fail fast on misconfiguration
|
|
142
|
-
module_validate_source_options(options);
|
|
143
|
-
const all_files = Array.from(files);
|
|
144
|
-
log?.info(`received ${all_files.length} files total`);
|
|
145
|
-
const source_files = [];
|
|
146
|
-
for (const file of all_files) {
|
|
147
|
-
if (module_is_source(file.id, options)) {
|
|
148
|
-
source_files.push(file);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
log?.info(`found ${source_files.length} source files to analyze`);
|
|
152
|
-
if (source_files.length === 0) {
|
|
153
|
-
const effective_root = module_get_source_root(options);
|
|
154
|
-
log?.warn(`No source files found in ${effective_root} - generating empty library metadata`);
|
|
155
|
-
return [];
|
|
156
|
-
}
|
|
157
|
-
// Sort for deterministic output (stable alphabetical module ordering)
|
|
158
|
-
source_files.sort((a, b) => a.id.localeCompare(b.id));
|
|
159
|
-
return source_files;
|
|
160
|
-
};
|