svelte-docinfo 0.5.4 → 0.6.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.
Files changed (90) hide show
  1. package/README.md +69 -50
  2. package/dist/analyze-core.d.ts +179 -24
  3. package/dist/analyze-core.d.ts.map +1 -1
  4. package/dist/analyze-core.js +462 -42
  5. package/dist/analyze.d.ts +31 -6
  6. package/dist/analyze.d.ts.map +1 -1
  7. package/dist/analyze.js +29 -9
  8. package/dist/cli.d.ts +17 -7
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +12 -9
  11. package/dist/declaration-build.d.ts +14 -4
  12. package/dist/declaration-build.d.ts.map +1 -1
  13. package/dist/declaration-helpers.d.ts +65 -42
  14. package/dist/declaration-helpers.d.ts.map +1 -1
  15. package/dist/declaration-helpers.js +167 -72
  16. package/dist/dep-resolver.d.ts +38 -13
  17. package/dist/dep-resolver.d.ts.map +1 -1
  18. package/dist/dep-resolver.js +40 -22
  19. package/dist/diagnostics.d.ts +365 -14
  20. package/dist/diagnostics.d.ts.map +1 -1
  21. package/dist/diagnostics.js +112 -28
  22. package/dist/discovery.d.ts +7 -2
  23. package/dist/discovery.d.ts.map +1 -1
  24. package/dist/discovery.js +11 -5
  25. package/dist/exports.d.ts +39 -2
  26. package/dist/exports.d.ts.map +1 -1
  27. package/dist/exports.js +251 -46
  28. package/dist/files.d.ts +14 -2
  29. package/dist/files.d.ts.map +1 -1
  30. package/dist/files.js +49 -8
  31. package/dist/index.d.ts +9 -7
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +6 -4
  34. package/dist/logo.js +3 -3
  35. package/dist/paths.d.ts +22 -1
  36. package/dist/paths.d.ts.map +1 -1
  37. package/dist/paths.js +22 -1
  38. package/dist/postprocess.d.ts +31 -10
  39. package/dist/postprocess.d.ts.map +1 -1
  40. package/dist/postprocess.js +124 -76
  41. package/dist/session.d.ts +101 -11
  42. package/dist/session.d.ts.map +1 -1
  43. package/dist/session.js +457 -127
  44. package/dist/source-config.d.ts +210 -33
  45. package/dist/source-config.d.ts.map +1 -1
  46. package/dist/source-config.js +313 -26
  47. package/dist/source.d.ts +35 -0
  48. package/dist/source.d.ts.map +1 -1
  49. package/dist/source.js +37 -0
  50. package/dist/svelte.d.ts +81 -23
  51. package/dist/svelte.d.ts.map +1 -1
  52. package/dist/svelte.js +686 -359
  53. package/dist/tsdoc.d.ts +47 -12
  54. package/dist/tsdoc.d.ts.map +1 -1
  55. package/dist/tsdoc.js +70 -17
  56. package/dist/types.d.ts +967 -45
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/types.js +259 -48
  59. package/dist/typescript-alias-registry.d.ts +76 -0
  60. package/dist/typescript-alias-registry.d.ts.map +1 -0
  61. package/dist/typescript-alias-registry.js +206 -0
  62. package/dist/typescript-exports.d.ts +20 -15
  63. package/dist/typescript-exports.d.ts.map +1 -1
  64. package/dist/typescript-exports.js +264 -137
  65. package/dist/typescript-extract-class.d.ts +3 -4
  66. package/dist/typescript-extract-class.d.ts.map +1 -1
  67. package/dist/typescript-extract-class.js +71 -52
  68. package/dist/typescript-extract-function.d.ts +6 -8
  69. package/dist/typescript-extract-function.d.ts.map +1 -1
  70. package/dist/typescript-extract-function.js +20 -15
  71. package/dist/typescript-extract-shared.d.ts +309 -29
  72. package/dist/typescript-extract-shared.d.ts.map +1 -1
  73. package/dist/typescript-extract-shared.js +957 -127
  74. package/dist/typescript-extract-type-json.d.ts +286 -0
  75. package/dist/typescript-extract-type-json.d.ts.map +1 -0
  76. package/dist/typescript-extract-type-json.js +854 -0
  77. package/dist/typescript-extract-type-properties.d.ts +2 -3
  78. package/dist/typescript-extract-type-properties.d.ts.map +1 -1
  79. package/dist/typescript-extract-type-properties.js +91 -84
  80. package/dist/typescript-extract-type.d.ts +6 -8
  81. package/dist/typescript-extract-type.d.ts.map +1 -1
  82. package/dist/typescript-extract-type.js +138 -40
  83. package/dist/typescript-program.d.ts +106 -23
  84. package/dist/typescript-program.d.ts.map +1 -1
  85. package/dist/typescript-program.js +182 -54
  86. package/dist/vite.d.ts +23 -8
  87. package/dist/vite.d.ts.map +1 -1
  88. package/dist/vite.js +34 -14
  89. package/package.json +17 -15
  90. package/virtual-svelte-docinfo.d.ts +1 -1
package/dist/analyze.d.ts CHANGED
@@ -17,7 +17,7 @@
17
17
  * @module
18
18
  */
19
19
  import type { AnalysisLog } from './log.js';
20
- import { type ModuleSourceOptions, type SourceOptionsDefaults } from './source-config.js';
20
+ import { type ExcludeOption, type ModuleSourceOptions, type SourceOptionsOverrides } from './source-config.js';
21
21
  import { type Discovery } from './discovery.js';
22
22
  import { type ResolveImport } from './dep-resolver.js';
23
23
  import { type AnalyzeResultJson, type OnDuplicates } from './analyze-core.js';
@@ -30,7 +30,13 @@ import type { SourceFileInfo } from './source.js';
30
30
  * for incremental use.
31
31
  */
32
32
  export interface AnalyzeOptions {
33
- /** Source files to analyze (must have content loaded). */
33
+ /**
34
+ * Source files to analyze (must have content loaded). Files outside
35
+ * `sourceOptions.sourcePaths` or matching `exclude` emit no module — they
36
+ * still feed the checker as in-memory content, so passing extra files
37
+ * (unsaved buffers, virtual-only helpers) shapes type resolution without
38
+ * polluting the output.
39
+ */
34
40
  sourceFiles: ReadonlyArray<SourceFileInfo>;
35
41
  /** Module source options for path extraction and source filtering. */
36
42
  sourceOptions: ModuleSourceOptions;
@@ -70,26 +76,45 @@ export interface AnalyzeFromFilesOptions {
70
76
  /** Absolute path to project root directory. */
71
77
  projectRoot: string;
72
78
  /** Partial overrides for default source options (SvelteKit `src/lib` layout). */
73
- sourceOptions?: Partial<SourceOptionsDefaults>;
79
+ sourceOptions?: SourceOptionsOverrides;
74
80
  /** Behavior when duplicate declaration names are found across modules. */
75
81
  onDuplicates?: OnDuplicates;
76
82
  /** Optional logger for status and diagnostic messages. */
77
83
  log?: AnalysisLog;
78
84
  /**
79
- * Glob patterns to include (relative to `projectRoot`).
85
+ * Glob patterns to include (relative to `projectRoot`; an absolute pattern
86
+ * inside the root relativizes, an out-of-root one throws — see
87
+ * `normalizeIncludePatterns`).
80
88
  *
81
89
  * Filters glob-based discovery. Providing `include` under the default
82
90
  * `discovery: 'auto'` collapses the chain to glob immediately; combining
83
91
  * with `discovery: 'exports'` throws.
84
92
  *
93
+ * Explicit patterns also widen the source scope: their static bases join
94
+ * `sourceOptions.sourcePaths` (see `widenSourcePathsForInclude`), so
95
+ * include-discovered files outside the configured source paths still emit
96
+ * modules, with paths relative to the widened set's common root. A pattern
97
+ * with no static base (`'**\/*.ts'`, a literal root file) scopes the whole
98
+ * project root as source and logs an info line; an out-of-root base
99
+ * (`'../other/**'`) throws.
100
+ *
85
101
  * When omitted, the glob fallback derives an include from
86
102
  * `sourceOptions.sourcePaths` via `deriveIncludePatterns`, so custom
87
103
  * `sourcePaths` (e.g., `['packages/foo']`) survive the fallback instead of
88
104
  * silently defaulting to `src/lib`.
89
105
  */
90
106
  include?: Array<string>;
91
- /** Glob patterns to exclude — fully replaces `sourceOptions.exclude` (no merge). */
92
- exclude?: Array<string>;
107
+ /**
108
+ * Glob patterns to exclude — takes precedence over `sourceOptions.exclude`
109
+ * (no merge between the two). An array replaces the default patterns
110
+ * wholesale; the callback form extends them without restating them
111
+ * (`(defaults) => [...defaults, '**\/*.gen.ts']` — see `ExcludeOption`).
112
+ * The callback always receives the built-in defaults, even when
113
+ * `sourceOptions.exclude` is also set (that value is superseded whole).
114
+ * The always-on baseline (`node_modules` + dot-directories below a matched
115
+ * source path) applies beneath it and is unaffected by overrides.
116
+ */
117
+ exclude?: ExcludeOption;
93
118
  /**
94
119
  * Whether to resolve import dependencies (default `true`).
95
120
  *
@@ -1 +1 @@
1
- {"version":3,"file":"analyze.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAE1C,OAAO,EAEN,KAAK,mBAAmB,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vC,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;;;;OASG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,iBAAiB,CAwH3B,CAAC"}
package/dist/analyze.js CHANGED
@@ -18,10 +18,10 @@
18
18
  */
19
19
  import { errorsOf, formatDiagnostic, warningsOf } from './diagnostics.js';
20
20
  import { createAnalysisSession } from './session.js';
21
- import { createSourceOptions, } from './source-config.js';
21
+ import { createSourceOptionsWithInclude } from './source-config.js';
22
22
  import { discoverSourceFiles } from './discovery.js';
23
23
  import { noDepsResolver } from './dep-resolver.js';
24
- import { normalizeDiagnosticPaths, } from './analyze-core.js';
24
+ import { normalizeDiagnosticPaths } from './analyze-core.js';
25
25
  /**
26
26
  * Analyze library source files and extract metadata (one-shot).
27
27
  *
@@ -39,6 +39,12 @@ export const analyze = async (options) => {
39
39
  sourceOptions: options.sourceOptions,
40
40
  log: options.log,
41
41
  resolveImport: options.resolveImport,
42
+ // One-shot with caller-provided inputs: no watch loop, so TS/JS context
43
+ // is read exactly once via the LS disk fallback either way — closure
44
+ // ownership is pure overhead. Gated *Svelte* dependencies are the
45
+ // exception (the LS can't serve raw `.svelte` from disk); callers pass
46
+ // them in `sourceFiles` — the query gate keeps them out of output.
47
+ contextClosure: false
42
48
  });
43
49
  try {
44
50
  const ingest = await session.setFiles(options.sourceFiles);
@@ -47,7 +53,7 @@ export const analyze = async (options) => {
47
53
  // session.setFiles; query diagnostics are normalized in analyze-core.
48
54
  return {
49
55
  modules: query.modules,
50
- diagnostics: [...ingest.diagnostics, ...query.diagnostics],
56
+ diagnostics: [...ingest.diagnostics, ...query.diagnostics]
51
57
  };
52
58
  }
53
59
  finally {
@@ -67,7 +73,7 @@ export const analyze = async (options) => {
67
73
  * @throws Error if `sourceOptions` validation fails or `tsconfig.json` is missing
68
74
  */
69
75
  export const analyzeFromFiles = async (options) => {
70
- const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir, } = options;
76
+ const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir } = options;
71
77
  // A custom resolver with resolution turned off is a contradiction — the
72
78
  // resolver would never be consulted. Fail fast rather than silently dropping
73
79
  // it (mirrors the `discovery: 'exports'` + `include` config-error throw).
@@ -81,7 +87,11 @@ export const analyzeFromFiles = async (options) => {
81
87
  // `createSourceOptions` so the normalized options carry a single source
82
88
  // of truth.
83
89
  const mergedSourceOptions = exclude !== undefined ? { ...sourceOptions, exclude } : sourceOptions;
84
- const resolvedSourceOptions = createSourceOptions(projectRoot, mergedSourceOptions);
90
+ // Explicit include patterns widen the source scope — their static bases
91
+ // join `sourcePaths` so include-discovered files pass the query-time source
92
+ // gate and get proper relative module paths; a pattern with no base scopes
93
+ // the whole project root and logs.
94
+ const resolvedSourceOptions = createSourceOptionsWithInclude(projectRoot, mergedSourceOptions, include, log);
85
95
  const normalizedProjectRoot = resolvedSourceOptions.projectRoot;
86
96
  // Step 1: discover files.
87
97
  const { files: discoveredFiles, diagnostics: discoveryDiagnostics } = await discoverSourceFiles({
@@ -89,7 +99,7 @@ export const analyzeFromFiles = async (options) => {
89
99
  include,
90
100
  discovery,
91
101
  distDir,
92
- log,
102
+ log
93
103
  });
94
104
  // Step 2: build the session-default resolver. When dep-resolution is
95
105
  // disabled, install the shared no-deps resolver so the session's lex+resolve
@@ -104,15 +114,25 @@ export const analyzeFromFiles = async (options) => {
104
114
  const session = createAnalysisSession({
105
115
  sourceOptions: resolvedSourceOptions,
106
116
  log,
107
- resolveImport: sessionResolver,
117
+ resolveImport: sessionResolver
118
+ // Closure stays on (the session default) despite being one-shot:
119
+ // discovery excludes gated files, so a gated `.svelte` dependency
120
+ // (`export {default as X} from './internal/X.svelte'`) exists nowhere
121
+ // else — the LS can't serve raw `.svelte` from disk, only the closure's
122
+ // ingest runs svelte2tsx. TS/JS context would be covered by the disk
123
+ // fallback either way; the closure's extra reads are the price of the
124
+ // Svelte case resolving.
108
125
  });
109
126
  let result;
110
127
  try {
111
- const ingest = await session.setFiles(discoveredFiles);
128
+ await session.setFiles(discoveredFiles);
112
129
  const query = session.query({ onDuplicates, log });
113
130
  result = {
114
131
  modules: query.modules,
115
- diagnostics: [...ingest.diagnostics, ...query.diagnostics],
132
+ // Cumulative rather than the batch return: context-closure ingest
133
+ // diagnostics (e.g. a gated Svelte file whose transform failed)
134
+ // live only on entries.
135
+ diagnostics: [...session.allIngestDiagnostics(), ...query.diagnostics]
116
136
  };
117
137
  }
118
138
  finally {
package/dist/cli.d.ts CHANGED
@@ -25,14 +25,23 @@ type OnDuplicatesFlag = (typeof ON_DUPLICATES_VALUES)[number];
25
25
  * CLI options parsed from command line arguments.
26
26
  */
27
27
  export interface CliOptions {
28
- /** File patterns to include (undefined = use exports discovery or defaults). */
28
+ /**
29
+ * File patterns to include (undefined = use exports discovery or defaults).
30
+ *
31
+ * Relative to the project root; an absolute pattern inside it relativizes,
32
+ * an out-of-root one throws.
33
+ */
29
34
  include?: Array<string>;
30
35
  /**
31
- * File patterns to exclude (undefined = use defaults — test and spec files).
36
+ * File patterns to exclude (undefined = use defaults — test/spec files and
37
+ * `internal/` directories).
32
38
  *
33
39
  * When provided, **fully replaces** the defaults — no array merge. Passing
34
- * a custom `--exclude` pattern drops the default test/spec filters unless
35
- * the caller re-includes them explicitly.
40
+ * a custom `--exclude` pattern drops the default test/spec/`internal/`
41
+ * filters unless the caller re-includes them explicitly (the API's
42
+ * exclude-callback form has no CLI equivalent). The always-on baseline
43
+ * (`node_modules` + dot-directories below a source path) applies beneath
44
+ * it and is unaffected by overrides.
36
45
  */
37
46
  exclude?: Array<string>;
38
47
  /** Output file path (undefined = stdout). */
@@ -52,7 +61,8 @@ export interface CliOptions {
52
61
  /** Dist directory name for exports-based discovery (undefined = 'dist'). */
53
62
  distDir?: string;
54
63
  /**
55
- * Source directories relative to project root (undefined = ['src/lib']).
64
+ * Source directories, relative to project root or absolute inside it
65
+ * (undefined = ['src/lib']); an out-of-root entry throws.
56
66
  *
57
67
  * Repeatable. Drives the implicit include glob in the glob-discovery
58
68
  * fallback (via `deriveIncludePatterns` inside `discoverSourceFiles`) so
@@ -60,8 +70,8 @@ export interface CliOptions {
60
70
  */
61
71
  sourceDir?: Array<string>;
62
72
  /**
63
- * Source root for module path extraction, relative to project root
64
- * (undefined = single sourceDir or longest common prefix).
73
+ * Source root for module path extraction, relative to project root or
74
+ * absolute inside it (undefined = single sourceDir or longest common prefix).
65
75
  *
66
76
  * Module paths in output are stripped of `<projectRoot>/<sourceRoot>/`.
67
77
  * Pass `.` (or `""`) to keep module paths project-relative — useful when
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAU9C,4CAA4C;AAC5C,QAAA,MAAM,oBAAoB,4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AC,CAAC,MAAM,CAAC,CAAC;AAS9D;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAU,OAAM,KAAK,CAAC,MAAM,CAAgB,KAAG,OAAO,CAAC,MAAM,CA6N/E,CAAC"}
package/dist/cli.js CHANGED
@@ -22,6 +22,7 @@ import { writeFile, readFile } from 'node:fs/promises';
22
22
  import { resolve } from 'node:path';
23
23
  import picomatch from 'picomatch';
24
24
  import { analyzeFromFiles } from './analyze.js';
25
+ import { DEFAULT_SOURCE_OPTIONS } from './source-config.js';
25
26
  import { hasErrors } from './diagnostics.js';
26
27
  import { to_error_message } from './error.js';
27
28
  import { compactReplacer } from './declaration-helpers.js';
@@ -67,10 +68,12 @@ export const runCli = async (argv = process.argv) => {
67
68
  .description('Static analysis for TypeScript and Svelte source code')
68
69
  .version(pkg.version)
69
70
  .argument('[project-root]', 'Project root directory', process.cwd())
70
- .option('-i, --include <pattern>', 'Include pattern (repeatable, replaces exports discovery; ' +
71
+ .option('-i, --include <pattern>', 'Include pattern, relative to project root — absolute inside it accepted ' +
72
+ '(repeatable, replaces exports discovery, widens the source scope; ' +
71
73
  'incompatible with --discovery exports)', collect)
72
74
  .option('-e, --exclude <pattern>', 'Exclude glob (applied at discovery and analysis, repeatable; ' +
73
- 'fully replaces defaults — does not merge with **/*.test.ts, **/*.spec.ts)', collect)
75
+ `fully replaces the defaults ${DEFAULT_SOURCE_OPTIONS.exclude.join(', ')} — no merge; ` +
76
+ 'node_modules and dot-directories below a source dir are always excluded regardless)', collect)
74
77
  .option('-o, --output <file>', 'Output file (default: stdout; pass `-` for explicit stdout)')
75
78
  .option('--no-resolve-dependencies', 'Disable dependency resolution')
76
79
  .option('--discovery <mode>', `Source file discovery strategy: ${DISCOVERY_VALUES.join('|')} ` +
@@ -78,9 +81,9 @@ export const runCli = async (argv = process.argv) => {
78
81
  '`exports` is strict and fails if package.json exports is missing or empty ' +
79
82
  '(also incompatible with --include).')
80
83
  .option('--dist-dir <dir>', 'Dist directory for exports discovery (default: dist)')
81
- .option('--source-dir <dir>', 'Source directory relative to project root (default: src/lib). ' +
82
- 'Repeatable for monorepos. Drives the implicit include glob for the ' +
83
- 'glob-discovery fallback when no --include is provided.', collect)
84
+ .option('--source-dir <dir>', 'Source directory, relative to project root or absolute inside it ' +
85
+ '(default: src/lib). Repeatable for monorepos. Drives the implicit include ' +
86
+ 'glob for the glob-discovery fallback when no --include is provided.', collect)
84
87
  .option('--source-root <dir>', 'Prefix stripped from module paths in output (default: the source-dir, ' +
85
88
  'or longest common prefix when multiple). Pass `.` to keep paths project-relative.')
86
89
  .option('--on-duplicates <mode>', `Dispatch on duplicate declaration names across modules: ${ON_DUPLICATES_VALUES.join('|')} ` +
@@ -131,7 +134,7 @@ Examples:
131
134
  onDuplicates: raw.onDuplicates,
132
135
  only: raw.only,
133
136
  quiet: raw.quiet,
134
- pretty: raw.pretty,
137
+ pretty: raw.pretty
135
138
  };
136
139
  const resolvedRoot = resolve(projectRoot);
137
140
  // Stderr logger — `--quiet` only mutes info; warnings and errors always print
@@ -139,7 +142,7 @@ Examples:
139
142
  const log = {
140
143
  info: options.quiet ? () => { } : (msg) => console.error(msg),
141
144
  warn: (msg) => console.error(`warning: ${msg}`),
142
- error: (msg) => console.error(`error: ${msg}`),
145
+ error: (msg) => console.error(`error: ${msg}`)
143
146
  };
144
147
  // Build sourceOptions only when source-dir or source-root is specified,
145
148
  // so the default (`['src/lib']`) flows through `createSourceOptions`.
@@ -149,7 +152,7 @@ Examples:
149
152
  const sourceOptions = options.sourceDir !== undefined || options.sourceRoot !== undefined
150
153
  ? {
151
154
  ...(options.sourceDir !== undefined ? { sourcePaths: options.sourceDir } : {}),
152
- ...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {}),
155
+ ...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {})
153
156
  }
154
157
  : undefined;
155
158
  const onDuplicates = options.onDuplicates;
@@ -162,7 +165,7 @@ Examples:
162
165
  distDir: options.distDir,
163
166
  ...(sourceOptions !== undefined ? { sourceOptions } : {}),
164
167
  ...(onDuplicates !== undefined ? { onDuplicates } : {}),
165
- log,
168
+ log
166
169
  });
167
170
  // `--only` is an output-only filter: analysis ran against the full
168
171
  // owned set so re-exports/dependents/`alsoExportedFrom` are correct,
@@ -13,7 +13,7 @@
13
13
  * @module
14
14
  */
15
15
  import { z } from 'zod';
16
- import type { DeclarationKind, DeclarationModifier, GenericParamJson, MemberKind, ParameterJson, OverloadJsonInput, ComponentPropJsonInput, Reactivity, ReExportJsonInput, ExternalReExportJsonInput } from './types.js';
16
+ import type { DeclarationKind, DeclarationModifier, GenericParamJson, MemberKind, ParameterJson, OverloadJsonInput, ComponentPropJsonInput, Reactivity, ReExportJsonInput, ExternalReExportJsonInput, TypeJson } from './types.js';
17
17
  /**
18
18
  * Permissive type for constructing members incrementally before Zod validation.
19
19
  *
@@ -35,10 +35,12 @@ export interface MemberJsonBuild {
35
35
  genericParams?: Array<GenericParamJson>;
36
36
  parameters?: Array<z.input<typeof ParameterJson>>;
37
37
  returnType?: string;
38
+ returnTypeInfo?: TypeJson;
38
39
  returnDescription?: string;
39
40
  overloads?: Array<OverloadJsonInput>;
40
41
  examples?: Array<string>;
41
42
  deprecatedMessage?: string;
43
+ internalMessage?: string;
42
44
  seeAlso?: Array<string>;
43
45
  throws?: Array<{
44
46
  type?: string;
@@ -50,8 +52,10 @@ export interface MemberJsonBuild {
50
52
  partial?: boolean;
51
53
  /** Whether the member has a `?` token in its declaration. Function and variable members only. */
52
54
  optional?: boolean;
53
- /** Default value documented via `@default`. Variable members only. */
55
+ /** Default value documented via `@default`. Variable and function members only. */
54
56
  defaultValue?: string;
57
+ /** Structured type. Variable members only; see `TypeJson`. */
58
+ typeInfo?: TypeJson;
55
59
  }
56
60
  /**
57
61
  * Permissive type for constructing declarations incrementally before Zod validation.
@@ -69,11 +73,13 @@ export interface DeclarationJsonBuild {
69
73
  sourceLine?: number;
70
74
  parameters?: Array<z.input<typeof ParameterJson>>;
71
75
  returnType?: string;
76
+ returnTypeInfo?: TypeJson;
72
77
  returnDescription?: string;
73
78
  genericParams?: Array<GenericParamJson>;
74
79
  overloads?: Array<OverloadJsonInput>;
75
80
  examples?: Array<string>;
76
81
  deprecatedMessage?: string;
82
+ internalMessage?: string;
77
83
  seeAlso?: Array<string>;
78
84
  throws?: Array<{
79
85
  type?: string;
@@ -81,8 +87,8 @@ export interface DeclarationJsonBuild {
81
87
  }>;
82
88
  since?: string;
83
89
  mutates?: Record<string, string>;
84
- extends?: string | Array<string>;
85
- intersects?: Array<string>;
90
+ extends?: Array<string>;
91
+ externalTypes?: Array<string>;
86
92
  implements?: Array<string>;
87
93
  members?: Array<MemberJsonBuild>;
88
94
  props?: Array<ComponentPropJsonInput>;
@@ -99,6 +105,10 @@ export interface DeclarationJsonBuild {
99
105
  module?: string;
100
106
  /** Default value documented via `@default`. Variable declarations only. */
101
107
  defaultValue?: string;
108
+ /** The exported name also carries a value meaning. Type/interface declarations only. */
109
+ mergedValue?: boolean;
110
+ /** Structured type. Variable and type-alias declarations only; see `TypeJson`. */
111
+ typeInfo?: TypeJson;
102
112
  }
103
113
  /**
104
114
  * Result of analyzing a single declaration.
@@ -1 +1 @@
1
- {"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,iBAAiB,CAA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tB,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IACnC,0DAA0D;IAC1D,WAAW,EAAE,oBAAoB,CAAC;IAClC,2FAA2F;IAC3F,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,2FAA2F;IAC3F,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACpD,6EAA6E;IAC7E,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC5D,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gFAAgF;IAChF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B"}
@@ -2,13 +2,13 @@
2
2
  * Utility functions for working with declaration and member types.
3
3
  *
4
4
  * Display formatting, code generation, serialization, type narrowing,
5
- * and type reference discovery for `DeclarationJson` and `MemberJson`.
5
+ * and `TypeJson` tokenization for `DeclarationJson` and `MemberJson`.
6
6
  *
7
- * @see `types.ts` for `DeclarationJson`, `MemberJson` Zod schemas
7
+ * @see `types.ts` for `DeclarationJson`, `MemberJson`, `TypeJson` Zod schemas
8
8
  *
9
9
  * @module
10
10
  */
11
- import type { DeclarationJson, MemberJson, DeclarationKind, MemberKind } from './types.js';
11
+ import type { DeclarationJson, MemberJson, DeclarationKind, MemberKind, TypeJson } from './types.js';
12
12
  /**
13
13
  * JSON replacer that strips Zod default values for compact serialization.
14
14
  *
@@ -17,6 +17,12 @@ import type { DeclarationJson, MemberJson, DeclarationKind, MemberKind } from '.
17
17
  * Assumes all boolean fields in the schema default to `false` — a `true`-defaulted
18
18
  * boolean would need its `false` values preserved, breaking the round-trip.
19
19
  *
20
+ * One keyed exemption: `value` is never stripped. `TypeJson`'s literal nodes
21
+ * carry data there (`{kind: 'literal', value: false}` is the literal type
22
+ * `false`, required by the schema), not a defaulted flag — no other output
23
+ * field is named `value`, and any future one must not be a `false`-defaulted
24
+ * boolean.
25
+ *
20
26
  * **Root-value caveat**: `JSON.stringify([], compactReplacer)` returns the JS
21
27
  * `undefined` (not the string `'[]'`), and `JSON.stringify(false, compactReplacer)`
22
28
  * returns the JS `undefined` too. Object-rooted callers (`AnalyzeResultJson`
@@ -43,7 +49,7 @@ import type { DeclarationJson, MemberJson, DeclarationKind, MemberKind } from '.
43
49
  * const restored = AnalyzeResultJson.parse(JSON.parse(json));
44
50
  * ```
45
51
  */
46
- export declare const compactReplacer: (_key: string, value: unknown) => unknown;
52
+ export declare const compactReplacer: (key: string, value: unknown) => unknown;
47
53
  /**
48
54
  * Format declaration or member name with generic parameters for display.
49
55
  *
@@ -69,7 +75,10 @@ export declare const getDisplayName: (declaration: DeclarationJson | MemberJson)
69
75
  /**
70
76
  * Generate TypeScript import statement for a declaration.
71
77
  *
72
- * Produces `import type` for type/interface declarations, `import` for values.
78
+ * Produces `import type` for type/interface declarations, `import` for values —
79
+ * including type/interface declarations marked `mergedValue` (a merged
80
+ * value+type symbol like a schema/type pair is importable as a runtime value,
81
+ * so a type-only import would break value use).
73
82
  *
74
83
  * **Default export handling**: when `declaration.name === 'default'`, emits
75
84
  * `import X from '...'` with the binding derived by PascalCasing the module
@@ -96,56 +105,70 @@ export declare const getDisplayName: (declaration: DeclarationJson | MemberJson)
96
105
  */
97
106
  export declare const generateImport: (declaration: DeclarationJson, modulePath: string, libraryName: string) => string;
98
107
  /**
99
- * Pre-compile identifier-boundary patterns for a set of declaration names.
108
+ * One rendered piece of a `TypeJson` tree, produced by `typeJsonToTokens`:
109
+ * `name` tokens are candidate references for a renderer to link (or print
110
+ * plainly) — reference names, alias names of alias-carrying
111
+ * unions/intersections — `code` tokens are terminal type text (intrinsics,
112
+ * literals, anonymous objects/functions, depth-capped nodes) for a renderer
113
+ * to syntax-highlight, and `text` tokens are structural punctuation
114
+ * (`<`, ` | `, `[]`, tuple labels). A `name` token carries `module` when its
115
+ * reference node does (registry-recovered references — the declaring
116
+ * `ModuleJson.path`), so a renderer can scope the link; alias-name tokens
117
+ * never carry it.
118
+ */
119
+ export type TypeJsonToken = {
120
+ kind: 'text';
121
+ text: string;
122
+ } | {
123
+ kind: 'name';
124
+ name: string;
125
+ module?: string;
126
+ } | {
127
+ kind: 'code';
128
+ text: string;
129
+ };
130
+ /**
131
+ * Flatten a `TypeJson` tree into a render-ready token list.
100
132
  *
101
- * When scanning many type strings against the same declaration set,
102
- * call this once and pass the result to `findTypeReferences`
103
- * to avoid recompiling regexes on every call.
133
+ * The semantic linearization for renderers: spacing, separators,
134
+ * parenthesization (`((x) => void) | null`, `(A | B)[]`), and tuple labels
135
+ * (`[a: string, b?: number, ...rest: boolean[]]`) are decided here — in
136
+ * lockstep with the `TypeJson` schema's projection rules — so a renderer
137
+ * maps tokens to output without re-deriving type syntax. What a token
138
+ * *looks like* stays the consumer's decision: fuz_ui links `name` tokens to
139
+ * API docs and syntax-highlights `code` tokens; a CLI might print them all
140
+ * plainly. Adjacent punctuation merges into single `text` tokens.
104
141
  *
105
- * @param declarationNames - set of known in-project declaration names
106
- * @returns array of `[name, pattern]` pairs for use with `findTypeReferences`
142
+ * @param node - the `TypeJson` tree to flatten (a `typeInfo`/`returnTypeInfo` field)
143
+ * @returns tokens in source order; concatenating their text yields the printed type
107
144
  *
108
145
  * @example
109
146
  * ```ts
110
- * const names = new Set(modules.flatMap(m => m.declarations.map(d => d.name)));
111
- * const patterns = buildTypeReferencePatterns(names);
112
- * for (const decl of declarations) {
113
- * const refs = findTypeReferences(decl.typeSignature, patterns);
114
- * }
147
+ * typeJsonToTokens({kind: 'reference', name: 'Map', typeArgs: [
148
+ * {kind: 'intrinsic', text: 'string'},
149
+ * {kind: 'reference', name: 'Tome'}
150
+ * ]})
151
+ * // => [{kind: 'name', name: 'Map'}, {kind: 'text', text: '<'},
152
+ * // {kind: 'code', text: 'string'}, {kind: 'text', text: ', '},
153
+ * // {kind: 'name', name: 'Tome'}, {kind: 'text', text: '>'}]
115
154
  * ```
116
155
  */
117
- export declare const buildTypeReferencePatterns: (declarationNames: ReadonlySet<string>) => Array<[string, RegExp]>;
156
+ export declare const typeJsonToTokens: (node: TypeJson) => Array<TypeJsonToken>;
118
157
  /**
119
- * Find in-project declaration names referenced in a type string.
120
- *
121
- * Uses identifier-boundary matching to find which known declaration names appear
122
- * in an opaque type string (e.g., `typeSignature`, `returnType`, parameter `type`).
123
- * Enables consumers to render clickable type links without needing access to
124
- * the TypeScript type checker.
125
- *
126
- * Handles identifiers starting with `$` (e.g., `$state`) which `\b` does not
127
- * recognize as word boundaries.
128
- *
129
- * Accepts either a `ReadonlySet<string>` (convenience) or pre-compiled patterns
130
- * from `buildTypeReferencePatterns` (performance). Use pre-compiled patterns
131
- * when scanning many type strings against the same declaration set.
132
- *
133
- * **Known limitations**: Identifier-boundary matching can produce false positives
134
- * when a declaration name appears as a property key in an object literal type
135
- * (e.g., `{ Foo: string }` when `Foo` is a declaration). This is rare in practice.
136
- *
137
- * @param typeString - opaque type string from analysis output
138
- * @param declarationNames - set of names or pre-compiled patterns from `buildTypeReferencePatterns`
139
- * @returns array of declaration names found in the type string
158
+ * The plain-text printed form of a `TypeJson` tree — `typeJsonToTokens`
159
+ * concatenated. For consumers with no linkification or highlighting surface
160
+ * (CLI output, markdown code spans, log lines) and for test assertions.
140
161
  *
141
162
  * @example
142
163
  * ```ts
143
- * const names = new Set(modules.flatMap(m => m.declarations.map(d => d.name)));
144
- * findTypeReferences('Map<string, ModuleJson[]>', names)
145
- * // => ['ModuleJson']
164
+ * typeJsonToText({kind: 'union', members: [
165
+ * {kind: 'reference', name: 'Tome'},
166
+ * {kind: 'intrinsic', text: 'null'}
167
+ * ]})
168
+ * // => 'Tome | null'
146
169
  * ```
147
170
  */
148
- export declare const findTypeReferences: (typeString: string, declarationNames: ReadonlySet<string> | Array<[string, RegExp]>) => Array<string>;
171
+ export declare const typeJsonToText: (node: TypeJson) => string;
149
172
  /**
150
173
  * Narrow a declaration by kind for type-safe field access.
151
174
  *
@@ -1 +1 @@
1
- {"version":3,"file":"declaration-helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAC,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAC,MAAM,YAAY,CAAC;AAIzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,OACqB,CAAC;AAIrF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,cAAc,GAAI,aAAa,eAAe,GAAG,UAAU,KAAG,MAS1E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,cAAc,GAC1B,aAAa,eAAe,EAC5B,YAAY,MAAM,EAClB,aAAa,MAAM,KACjB,MAuBF,CAAC;AA6BF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,GACtC,kBAAkB,WAAW,CAAC,MAAM,CAAC,KACnC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;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