@fuzdev/fuz_ui 0.194.0 → 0.195.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/DeclarationDetail.svelte +139 -64
  2. package/dist/DeclarationDetail.svelte.d.ts +9 -0
  3. package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
  4. package/dist/LibraryDetail.svelte +14 -10
  5. package/dist/LibraryDetail.svelte.d.ts +7 -0
  6. package/dist/LibraryDetail.svelte.d.ts.map +1 -1
  7. package/dist/declaration.svelte.d.ts +233 -25
  8. package/dist/declaration.svelte.d.ts.map +1 -1
  9. package/dist/declaration.svelte.js +71 -23
  10. package/dist/library.svelte.js +1 -1
  11. package/dist/library_gen.d.ts +24 -17
  12. package/dist/library_gen.d.ts.map +1 -1
  13. package/dist/library_gen.js +52 -32
  14. package/dist/library_output.d.ts +5 -4
  15. package/dist/library_output.d.ts.map +1 -1
  16. package/dist/library_output.js +11 -8
  17. package/dist/module.svelte.d.ts +21 -7
  18. package/dist/module.svelte.d.ts.map +1 -1
  19. package/dist/module.svelte.js +26 -11
  20. package/dist/tsdoc_mdz.d.ts +6 -1
  21. package/dist/tsdoc_mdz.d.ts.map +1 -1
  22. package/dist/tsdoc_mdz.js +23 -2
  23. package/package.json +10 -8
  24. package/src/lib/declaration.svelte.ts +90 -35
  25. package/src/lib/library.svelte.ts +1 -1
  26. package/src/lib/library_gen.ts +65 -42
  27. package/src/lib/library_output.ts +11 -8
  28. package/src/lib/module.svelte.ts +29 -16
  29. package/src/lib/tsdoc_mdz.ts +25 -2
  30. package/dist/analysis_context.d.ts +0 -199
  31. package/dist/analysis_context.d.ts.map +0 -1
  32. package/dist/analysis_context.js +0 -138
  33. package/dist/library_analysis.d.ts +0 -112
  34. package/dist/library_analysis.d.ts.map +0 -1
  35. package/dist/library_analysis.js +0 -106
  36. package/dist/library_generate.d.ts +0 -94
  37. package/dist/library_generate.d.ts.map +0 -1
  38. package/dist/library_generate.js +0 -147
  39. package/dist/library_pipeline.d.ts +0 -113
  40. package/dist/library_pipeline.d.ts.map +0 -1
  41. package/dist/library_pipeline.js +0 -160
  42. package/dist/module_helpers.d.ts +0 -334
  43. package/dist/module_helpers.d.ts.map +0 -1
  44. package/dist/module_helpers.js +0 -317
  45. package/dist/svelte_helpers.d.ts +0 -92
  46. package/dist/svelte_helpers.d.ts.map +0 -1
  47. package/dist/svelte_helpers.js +0 -367
  48. package/dist/ts_helpers.d.ts +0 -181
  49. package/dist/ts_helpers.d.ts.map +0 -1
  50. package/dist/ts_helpers.js +0 -674
  51. package/dist/tsdoc_helpers.d.ts +0 -119
  52. package/dist/tsdoc_helpers.d.ts.map +0 -1
  53. package/dist/tsdoc_helpers.js +0 -207
  54. package/src/lib/analysis_context.ts +0 -254
  55. package/src/lib/library_analysis.ts +0 -168
  56. package/src/lib/library_generate.ts +0 -215
  57. package/src/lib/library_pipeline.ts +0 -221
  58. package/src/lib/module_helpers.ts +0 -501
  59. package/src/lib/svelte_helpers.ts +0 -539
  60. package/src/lib/ts_helpers.ts +0 -862
  61. package/src/lib/tsdoc_helpers.ts +0 -246
@@ -1,199 +0,0 @@
1
- /**
2
- * Diagnostic collection for source analysis.
3
- *
4
- * Provides structured error/warning collection during TypeScript and Svelte
5
- * analysis, replacing silent catch blocks with actionable diagnostics.
6
- *
7
- * ## Error Handling Contract
8
- *
9
- * Analysis functions follow a two-tier error model:
10
- *
11
- * **Accumulated (non-fatal)** - Collected in `AnalysisContext`, analysis continues:
12
- * - Type resolution failures (complex generics, circular refs)
13
- * - Missing or unparseable JSDoc
14
- * - Individual member/prop extraction failures
15
- * - The return value is still valid but may have partial data
16
- *
17
- * **Thrown (fatal)** - Analysis cannot continue for this file:
18
- * - File not found or unreadable
19
- * - Syntax errors preventing parsing
20
- * - svelte2tsx transformation failures
21
- * - Svelte version incompatibility
22
- *
23
- * ## Usage Pattern
24
- *
25
- * ```ts
26
- * const ctx = new AnalysisContext();
27
- * const results = files.map(f => {
28
- * try {
29
- * return library_analyze_module(f, program, options, ctx);
30
- * } catch (e) {
31
- * // Fatal error - log and skip this file
32
- * console.error(`Failed to analyze ${f.id}: ${e}`);
33
- * return null;
34
- * }
35
- * });
36
- *
37
- * // Results are valid even with accumulated errors
38
- * // Check ctx for diagnostics to display to user
39
- * if (ctx.has_errors()) {
40
- * for (const err of ctx.errors()) {
41
- * console.error(format_diagnostic(err));
42
- * }
43
- * }
44
- * ```
45
- *
46
- * @example
47
- * ```ts
48
- * const ctx = new AnalysisContext();
49
- * // ... analysis functions add diagnostics via ctx.add(...)
50
- * if (ctx.has_errors()) {
51
- * for (const err of ctx.errors()) {
52
- * console.error(`${err.file}:${err.line}: ${err.message}`);
53
- * }
54
- * }
55
- * ```
56
- *
57
- * @module
58
- */
59
- /**
60
- * Diagnostic severity levels.
61
- *
62
- * - `error`: Analysis failed, declaration may be incomplete or missing data
63
- * - `warning`: Partial success, something seems off but analysis continued
64
- */
65
- export type DiagnosticSeverity = 'error' | 'warning';
66
- /**
67
- * Discriminant for diagnostic types.
68
- */
69
- export type DiagnosticKind = 'type_extraction_failed' | 'signature_analysis_failed' | 'class_member_failed' | 'svelte_prop_failed' | 'module_skipped';
70
- /**
71
- * Base diagnostic fields shared by all diagnostic types.
72
- */
73
- export interface BaseDiagnostic {
74
- kind: DiagnosticKind;
75
- /** File path relative to project root (display with './' prefix). */
76
- file: string;
77
- /** Line number (1-based), or null if location unavailable. */
78
- line: number | null;
79
- /** Column number (1-based), or null if location unavailable. */
80
- column: number | null;
81
- /** Human-readable description of the issue. */
82
- message: string;
83
- severity: DiagnosticSeverity;
84
- }
85
- /**
86
- * Type extraction failed (e.g., complex or recursive types).
87
- */
88
- export interface TypeExtractionDiagnostic extends BaseDiagnostic {
89
- kind: 'type_extraction_failed';
90
- /** Name of the symbol whose type couldn't be extracted. */
91
- symbol_name: string;
92
- }
93
- /**
94
- * Function/method signature analysis failed.
95
- */
96
- export interface SignatureAnalysisDiagnostic extends BaseDiagnostic {
97
- kind: 'signature_analysis_failed';
98
- /** Name of the function or method. */
99
- function_name: string;
100
- }
101
- /**
102
- * Class member analysis failed.
103
- */
104
- export interface ClassMemberDiagnostic extends BaseDiagnostic {
105
- kind: 'class_member_failed';
106
- /** Name of the class. */
107
- class_name: string;
108
- /** Name of the member that failed. */
109
- member_name: string;
110
- }
111
- /**
112
- * Svelte prop type resolution failed.
113
- */
114
- export interface SveltePropDiagnostic extends BaseDiagnostic {
115
- kind: 'svelte_prop_failed';
116
- /** Name of the component. */
117
- component_name: string;
118
- /** Name of the prop. */
119
- prop_name: string;
120
- }
121
- /**
122
- * Module was skipped during analysis.
123
- * Could be due to missing source file in program or no analyzer available.
124
- */
125
- export interface ModuleSkippedDiagnostic extends BaseDiagnostic {
126
- kind: 'module_skipped';
127
- /** Reason the module was skipped. */
128
- reason: 'not_in_program' | 'no_analyzer';
129
- }
130
- /**
131
- * Union of all diagnostic types.
132
- */
133
- export type Diagnostic = TypeExtractionDiagnostic | SignatureAnalysisDiagnostic | ClassMemberDiagnostic | SveltePropDiagnostic | ModuleSkippedDiagnostic;
134
- /**
135
- * Context for collecting diagnostics during source analysis.
136
- *
137
- * Thread an instance through analysis functions to collect errors and warnings
138
- * without halting analysis. After analysis completes, check `has_errors()` and
139
- * report collected diagnostics.
140
- *
141
- * @example
142
- * ```ts
143
- * const ctx = new AnalysisContext();
144
- * ts_analyze_module_exports(source_file, checker, options, ctx);
145
- * if (ctx.has_errors()) {
146
- * console.error('Analysis completed with errors:');
147
- * for (const d of ctx.errors()) {
148
- * console.error(format_diagnostic(d));
149
- * }
150
- * }
151
- * ```
152
- */
153
- export declare class AnalysisContext {
154
- readonly diagnostics: Array<Diagnostic>;
155
- /**
156
- * Add a `Diagnostic` to the collection.
157
- */
158
- add(diagnostic: Diagnostic): void;
159
- /**
160
- * Check if any errors were collected.
161
- */
162
- has_errors(): boolean;
163
- /**
164
- * Check if any warnings were collected.
165
- */
166
- has_warnings(): boolean;
167
- /**
168
- * Get all error diagnostics.
169
- */
170
- errors(): Array<Diagnostic>;
171
- /**
172
- * Get all warning diagnostics.
173
- */
174
- warnings(): Array<Diagnostic>;
175
- /**
176
- * Get diagnostics of a specific `DiagnosticKind`.
177
- */
178
- by_kind<K extends DiagnosticKind>(kind: K): Array<Extract<Diagnostic, {
179
- kind: K;
180
- }>>;
181
- }
182
- /**
183
- * Options for formatting diagnostics.
184
- */
185
- export interface FormatDiagnosticOptions {
186
- /** Prefix for file path (default: './'). */
187
- prefix?: string;
188
- /** Base path to strip from absolute file paths (e.g., process.cwd()). */
189
- strip_base?: string;
190
- }
191
- /**
192
- * Format a diagnostic for display.
193
- *
194
- * @param diagnostic - the diagnostic to format
195
- * @param options - formatting options
196
- * @returns formatted string like './file.ts:10:5: error: message'
197
- */
198
- export declare const format_diagnostic: (diagnostic: Diagnostic, options?: FormatDiagnosticOptions) => string;
199
- //# sourceMappingURL=analysis_context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analysis_context.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analysis_context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,cAAc,GACvB,wBAAwB,GACxB,2BAA2B,GAC3B,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,CAAC;AAEpB;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,gEAAgE;IAChE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IACh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AU,CAAC;IAI3B;;OAEG;IACH,QAAQ,IAAI,KAAK,CAAC,UAAU,CAAC;IAI7B;;OAEG;IACH,OAAO,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE;QAAC,IAAI,EAAE,CAAC,CAAA;KAAC,CAAC,CAAC;CAGjF;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC7B,YAAY,UAAU,EACtB,UAAU,uBAAuB,KAC/B,MAeF,CAAC"}
@@ -1,138 +0,0 @@
1
- /**
2
- * Diagnostic collection for source analysis.
3
- *
4
- * Provides structured error/warning collection during TypeScript and Svelte
5
- * analysis, replacing silent catch blocks with actionable diagnostics.
6
- *
7
- * ## Error Handling Contract
8
- *
9
- * Analysis functions follow a two-tier error model:
10
- *
11
- * **Accumulated (non-fatal)** - Collected in `AnalysisContext`, analysis continues:
12
- * - Type resolution failures (complex generics, circular refs)
13
- * - Missing or unparseable JSDoc
14
- * - Individual member/prop extraction failures
15
- * - The return value is still valid but may have partial data
16
- *
17
- * **Thrown (fatal)** - Analysis cannot continue for this file:
18
- * - File not found or unreadable
19
- * - Syntax errors preventing parsing
20
- * - svelte2tsx transformation failures
21
- * - Svelte version incompatibility
22
- *
23
- * ## Usage Pattern
24
- *
25
- * ```ts
26
- * const ctx = new AnalysisContext();
27
- * const results = files.map(f => {
28
- * try {
29
- * return library_analyze_module(f, program, options, ctx);
30
- * } catch (e) {
31
- * // Fatal error - log and skip this file
32
- * console.error(`Failed to analyze ${f.id}: ${e}`);
33
- * return null;
34
- * }
35
- * });
36
- *
37
- * // Results are valid even with accumulated errors
38
- * // Check ctx for diagnostics to display to user
39
- * if (ctx.has_errors()) {
40
- * for (const err of ctx.errors()) {
41
- * console.error(format_diagnostic(err));
42
- * }
43
- * }
44
- * ```
45
- *
46
- * @example
47
- * ```ts
48
- * const ctx = new AnalysisContext();
49
- * // ... analysis functions add diagnostics via ctx.add(...)
50
- * if (ctx.has_errors()) {
51
- * for (const err of ctx.errors()) {
52
- * console.error(`${err.file}:${err.line}: ${err.message}`);
53
- * }
54
- * }
55
- * ```
56
- *
57
- * @module
58
- */
59
- /**
60
- * Context for collecting diagnostics during source analysis.
61
- *
62
- * Thread an instance through analysis functions to collect errors and warnings
63
- * without halting analysis. After analysis completes, check `has_errors()` and
64
- * report collected diagnostics.
65
- *
66
- * @example
67
- * ```ts
68
- * const ctx = new AnalysisContext();
69
- * ts_analyze_module_exports(source_file, checker, options, ctx);
70
- * if (ctx.has_errors()) {
71
- * console.error('Analysis completed with errors:');
72
- * for (const d of ctx.errors()) {
73
- * console.error(format_diagnostic(d));
74
- * }
75
- * }
76
- * ```
77
- */
78
- export class AnalysisContext {
79
- diagnostics = [];
80
- /**
81
- * Add a `Diagnostic` to the collection.
82
- */
83
- add(diagnostic) {
84
- this.diagnostics.push(diagnostic);
85
- }
86
- /**
87
- * Check if any errors were collected.
88
- */
89
- has_errors() {
90
- return this.diagnostics.some((d) => d.severity === 'error');
91
- }
92
- /**
93
- * Check if any warnings were collected.
94
- */
95
- has_warnings() {
96
- return this.diagnostics.some((d) => d.severity === 'warning');
97
- }
98
- /**
99
- * Get all error diagnostics.
100
- */
101
- errors() {
102
- return this.diagnostics.filter((d) => d.severity === 'error');
103
- }
104
- /**
105
- * Get all warning diagnostics.
106
- */
107
- warnings() {
108
- return this.diagnostics.filter((d) => d.severity === 'warning');
109
- }
110
- /**
111
- * Get diagnostics of a specific `DiagnosticKind`.
112
- */
113
- by_kind(kind) {
114
- return this.diagnostics.filter((d) => d.kind === kind);
115
- }
116
- }
117
- /**
118
- * Format a diagnostic for display.
119
- *
120
- * @param diagnostic - the diagnostic to format
121
- * @param options - formatting options
122
- * @returns formatted string like './file.ts:10:5: error: message'
123
- */
124
- export const format_diagnostic = (diagnostic, options) => {
125
- const prefix = options?.prefix ?? './';
126
- const strip_base = options?.strip_base;
127
- let file = diagnostic.file;
128
- if (strip_base && file.startsWith(strip_base)) {
129
- file = file.slice(strip_base.length);
130
- // Remove leading slash if present
131
- if (file.startsWith('/'))
132
- file = file.slice(1);
133
- }
134
- const { line, column, severity, message } = diagnostic;
135
- const location = line !== null ? (column !== null ? `${line}:${column}` : `${line}`) : '';
136
- const file_part = location ? `${prefix}${file}:${location}` : `${prefix}${file}`;
137
- return `${file_part}: ${severity}: ${message}`;
138
- };
@@ -1,112 +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 type { Logger } from '@fuzdev/fuz_util/log.js';
47
- import type { DeclarationJson } from '@fuzdev/fuz_util/source_json.js';
48
- import { type SourceFileInfo, type ModuleSourceOptions } from './module_helpers.js';
49
- import type { AnalysisContext } from './analysis_context.js';
50
- /**
51
- * Result of analyzing a single declaration.
52
- * Used by both TypeScript and Svelte analyzers for uniform handling.
53
- */
54
- export interface DeclarationAnalysis {
55
- /** The analyzed declaration metadata. */
56
- declaration: DeclarationJson;
57
- /** Whether the declaration is marked `@nodocs` (should be excluded from documentation). */
58
- nodocs: boolean;
59
- }
60
- /**
61
- * Information about a same-name re-export.
62
- * Used for post-processing to build `also_exported_from` arrays.
63
- */
64
- export interface ReExportInfo {
65
- /** Name of the re-exported declaration. */
66
- name: string;
67
- /** Module path (relative to src/lib) where the declaration is originally declared. */
68
- original_module: string;
69
- }
70
- /**
71
- * Result of analyzing a module (TypeScript or Svelte).
72
- * Both analyzers return this same structure for uniform handling.
73
- */
74
- export interface ModuleAnalysis {
75
- /** Module path relative to source root. */
76
- path: string;
77
- /** Module-level documentation comment. */
78
- module_comment?: string;
79
- /** All declarations with nodocs flags - consumer filters based on policy. */
80
- declarations: Array<DeclarationAnalysis>;
81
- /** Dependencies (other source modules this module imports). Empty if none. */
82
- dependencies: Array<string>;
83
- /** Dependents (other source modules that import this module). Empty if none. */
84
- dependents: Array<string>;
85
- /** Star exports (`export * from './module'`). Empty for Svelte components. */
86
- star_exports: Array<string>;
87
- /** Re-exports discovered during analysis. Empty for Svelte components. */
88
- re_exports: Array<ReExportInfo>;
89
- }
90
- /**
91
- * Analyze a source file and extract module metadata.
92
- *
93
- * Unified entry point that dispatches to the appropriate analyzer based on file type:
94
- * - TypeScript/JS files → `ts_analyze_module`
95
- * - Svelte components → `svelte_analyze_module`
96
- *
97
- * Returns raw analysis data including `nodocs` flags on declarations.
98
- * Consumer is responsible for filtering based on their policy.
99
- *
100
- * This function can be called incrementally - consumers may cache results and
101
- * only re-analyze changed files. The TypeScript program should include all files
102
- * for accurate type resolution, but only changed files need re-analysis.
103
- *
104
- * @param source_file - the source file info with content and optional dependency data
105
- * @param program - TypeScript program (used for type checking and source file lookup)
106
- * @param options - module source options for path extraction
107
- * @param ctx - analysis context for collecting diagnostics
108
- * @param log - optional logger for warnings
109
- * @returns module metadata and re-exports, or undefined if source file not found in program
110
- */
111
- export declare const library_analyze_module: (source_file: SourceFileInfo, program: ts.Program, options: ModuleSourceOptions, ctx: AnalysisContext, log?: Logger) => ModuleAnalysis | undefined;
112
- //# sourceMappingURL=library_analysis.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"library_analysis.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/library_analysis.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAIrE,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAExB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,yCAAyC;IACzC,WAAW,EAAE,eAAe,CAAC;IAC7B,2FAA2F;IAC3F,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC5B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,eAAe,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gFAAgF;IAChF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,0EAA0E;IAC1E,UAAU,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,sBAAsB,GAClC,aAAa,cAAc,EAC3B,SAAS,EAAE,CAAC,OAAO,EACnB,SAAS,mBAAmB,EAC5B,KAAK,eAAe,EACpB,MAAM,MAAM,KACV,cAAc,GAAG,SAuCnB,CAAC"}
@@ -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;A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