svelte-docinfo 0.8.1 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -9
- package/dist/analyze-core.d.ts +16 -40
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +13 -34
- package/dist/analyze.d.ts +7 -6
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +5 -4
- package/dist/cli.d.ts +4 -10
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -6
- package/dist/diagnostics.d.ts +7 -6
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +7 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/postprocess.d.ts +3 -11
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/postprocess.js +3 -11
- package/dist/session.d.ts +2 -2
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +1 -1
- package/dist/typescript-program.d.ts +24 -4
- package/dist/typescript-program.d.ts.map +1 -1
- package/dist/typescript-program.js +67 -5
- package/dist/vite.d.ts +9 -6
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +130 -49
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ npm i -D svelte-docinfo
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Peer dependencies: `svelte` 5+, `svelte2tsx`, `typescript` 5.9+ or 6, and `zod` 4+
|
|
22
|
-
(npm 7+ installs them automatically).
|
|
22
|
+
(npm 7+ installs them automatically), plus an optional `vite` 6+ for the Vite plugin.
|
|
23
23
|
|
|
24
24
|
- [Quick start](#quick-start)
|
|
25
25
|
- [Vite plugin](#vite-plugin)
|
|
@@ -92,7 +92,7 @@ export const add = (a: number, b: number): number => a + b;
|
|
|
92
92
|
|
|
93
93
|
Three ways to integrate `svelte-docinfo`:
|
|
94
94
|
|
|
95
|
-
1. [Vite plugin](#vite-plugin) - recommended for SvelteKit and Vite projects. Serves a virtual module
|
|
95
|
+
1. [Vite plugin](#vite-plugin) - recommended for SvelteKit and Vite projects. Serves a virtual module that stays current in dev mode:
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
98
|
// vite.config.ts
|
|
@@ -192,6 +192,8 @@ You may also want to browse the [test fixtures](https://github.com/fuzdev/svelte
|
|
|
192
192
|
|
|
193
193
|
## Vite plugin
|
|
194
194
|
|
|
195
|
+
Requires Vite 6 or later.
|
|
196
|
+
|
|
195
197
|
1. Add the plugin to `vite.config.ts`:
|
|
196
198
|
|
|
197
199
|
```ts
|
|
@@ -224,12 +226,12 @@ Plugin options:
|
|
|
224
226
|
| `projectRoot` | Vite's resolved `config.root` | Absolute path to project root. |
|
|
225
227
|
| `include` | — | Glob patterns to include (relative to `projectRoot`; absolute inside it accepted). Collapses `discovery: 'auto'` to glob; combining with `discovery: 'exports'` throws. Widens the source scope — see the notes below. |
|
|
226
228
|
| `exclude` | `['**/*.test.ts', '**/*.spec.ts', '**/internal/**']` | Glob patterns to exclude. An array fully replaces the defaults; the callback form extends them (`(defaults) => [...defaults, '**/*.gen.ts']`). The always-on baseline below still applies. |
|
|
227
|
-
| `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or resolves to no files.
|
|
229
|
+
| `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or resolves to no files. |
|
|
228
230
|
| `distDir` | `'dist'` | Dist directory name for exports-based discovery. |
|
|
229
231
|
| `sourceOptions` | `{sourcePaths: ['src/lib'], …}` | Partial overrides for default source options (SvelteKit `src/lib` layout). |
|
|
230
232
|
| `resolveDependencies` | `true` | Resolve import dependencies. When `false`, `dependencies`/`dependents` stay empty. |
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
233
|
+
| `hmrDebounceMs` | `100` | Dev re-analysis debounce delay in milliseconds. |
|
|
234
|
+
| `onDuplicates` | — | Opt-in check that names are unique across modules, for packages with a flat export namespace: `'diagnostic'` \| `'warn'` \| `'throw'`. Off by default. |
|
|
233
235
|
|
|
234
236
|
Source-scope notes (shared with the [CLI](#cli) and `analyzeFromFiles`):
|
|
235
237
|
|
|
@@ -272,21 +274,21 @@ All CLI options:
|
|
|
272
274
|
| `-i, --include <pattern>` | Include pattern (repeatable, replaces exports discovery, widens the source scope; incompatible with `--discovery exports`) |
|
|
273
275
|
| `-e, --exclude <pattern>` | Exclude glob, applied at discovery and analysis (repeatable; fully replaces the defaults `**/*.test.ts`, `**/*.spec.ts`, `**/internal/**` — no merge; the always-on baseline applies beneath) |
|
|
274
276
|
| `-o, --output <file>` | Output file (default: stdout; pass `-` for explicit stdout, so `-o "$OUT"` works when `$OUT=-`) |
|
|
275
|
-
| `--discovery <mode>` | `auto` \| `exports` \| `glob` (default: `auto` — exports first, glob fallback). `exports` is strict and fails if package.json exports is missing or resolves to no files
|
|
277
|
+
| `--discovery <mode>` | `auto` \| `exports` \| `glob` (default: `auto` — exports first, glob fallback). `exports` is strict and fails if package.json exports is missing or resolves to no files |
|
|
276
278
|
| `--dist-dir <dir>` | Dist directory for exports discovery (default: dist) |
|
|
277
279
|
| `--source-dir <dir>` | Source directory, relative to project root or absolute inside it (default: src/lib). Repeatable for monorepos; drives the implicit include glob when no `--include` is provided |
|
|
278
280
|
| `--source-root <dir>` | Source root for module-path stripping (default: single source-dir or longest common prefix; pass `.` for project-relative paths) |
|
|
279
|
-
| `--on-duplicates <mode>` | Dispatch on duplicate declaration names: `throw` \| `warn` (default: emit `duplicate_declaration` diagnostic, no dispatch) |
|
|
280
281
|
| `--only <pattern>` | Glob filter applied to module paths in output (repeatable). Full project is still analyzed (re-exports/dependents stay correct); diagnostics aren't filtered |
|
|
281
282
|
| `--no-resolve-dependencies` | Disable dependency resolution |
|
|
282
283
|
| `--pretty` | Pretty-print JSON output (default: compact) |
|
|
283
284
|
| `-q, --quiet` | Suppress info messages on stderr (warnings and errors still print) |
|
|
285
|
+
| `--on-duplicates <mode>` | Opt-in check that names are unique across modules, for packages with a flat export namespace: `diagnostic` \| `warn` \| `throw` (default: off) |
|
|
284
286
|
| `-V, --version` | Show version number |
|
|
285
287
|
|
|
286
288
|
The [Vite plugin](#vite-plugin)'s source-scope notes apply here too: explicit `--include` patterns widen the source scope (module paths become relative to the widened root, and a pattern with no base scopes the whole project root and logs an info line); `node_modules` and dot-directories below a source dir are always excluded regardless of `--exclude`; absolute paths and patterns inside the project root are accepted, and out-of-root ones fail loudly.
|
|
287
289
|
|
|
288
290
|
Exit codes: 0 (success), 1 (analysis errors), 2 (CLI errors or a thrown analysis error, like a
|
|
289
|
-
missing `tsconfig.json`
|
|
291
|
+
missing or unloadable `tsconfig.json`).
|
|
290
292
|
|
|
291
293
|
See [examples/cli/](examples/cli/README.md) for more usage patterns.
|
|
292
294
|
|
|
@@ -362,7 +364,7 @@ Known gaps:
|
|
|
362
364
|
## Documentation
|
|
363
365
|
|
|
364
366
|
- [svelte-docinfo.fuz.dev](https://svelte-docinfo.fuz.dev/) - docs site with guides, options reference, and API docs
|
|
365
|
-
- [examples/vite/](examples/vite/README.md) - Vite plugin with
|
|
367
|
+
- [examples/vite/](examples/vite/README.md) - Vite plugin with live reload in dev
|
|
366
368
|
- [examples/cli/](examples/cli/README.md) - CLI usage and piping
|
|
367
369
|
- [examples/api/](examples/api/README.md) - API usage patterns
|
|
368
370
|
|
package/dist/analyze-core.d.ts
CHANGED
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
* - `analyzeModule` — the per-module dispatcher for non-Svelte files (TS / CSS /
|
|
14
14
|
* JSON; Svelte needs `analyzeSvelteModule`). `@internal`; exposed for tests
|
|
15
15
|
* and power users via the subpath.
|
|
16
|
-
* - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates`
|
|
17
|
-
*
|
|
18
|
-
* directly from this module.
|
|
19
|
-
* - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
|
|
16
|
+
* - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` — shared
|
|
17
|
+
* types surfaced through the main barrel directly from this module.
|
|
20
18
|
* - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
|
|
21
19
|
* remap, then path normalization) in their required order; the one call for
|
|
22
20
|
* callers assembling modules themselves.
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
* assembling modules itself through `analyzeModule` can meet the same
|
|
29
27
|
* output contract.
|
|
30
28
|
*
|
|
31
|
-
* The barrel-surfaced schemas
|
|
29
|
+
* The barrel-surfaced schemas and types are stable API.
|
|
32
30
|
* Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
|
|
33
31
|
* `@internal`.
|
|
34
32
|
*
|
|
@@ -43,47 +41,25 @@ import { type SvelteVirtualFile } from './svelte.js';
|
|
|
43
41
|
import { type SourceFileInfo } from './source.js';
|
|
44
42
|
import { type ModuleSourceOptions } from './source-config.js';
|
|
45
43
|
import type { AliasRegistry } from './typescript-extract-type-json.js';
|
|
46
|
-
import { type DuplicateDeclaration } from './postprocess.js';
|
|
47
44
|
/**
|
|
48
|
-
*
|
|
45
|
+
* Opt-in check that declaration names are unique across modules.
|
|
49
46
|
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
47
|
+
* For packages that keep a flat export namespace, where every exported name
|
|
48
|
+
* is unique across the whole package. Most packages don't, and two modules
|
|
49
|
+
* exporting the same name is ordinary, so the check is off by default:
|
|
50
|
+
* omitted, duplicate detection doesn't run and nothing is reported.
|
|
52
51
|
*
|
|
53
|
-
*
|
|
54
|
-
* @param log - logger for reporting (only `error` method required)
|
|
55
|
-
*/
|
|
56
|
-
export type OnDuplicatesCallback = (duplicates: Map<string, Array<DuplicateDeclaration>>, log: Pick<AnalysisLog, 'error'>) => void;
|
|
57
|
-
/**
|
|
58
|
-
* Behavior selector for duplicate declaration names across modules.
|
|
59
|
-
*
|
|
60
|
-
* - `'throw'` — throw an `Error` listing every duplicate (strict flat-namespace enforcement)
|
|
61
|
-
* - `'warn'` — log to `log.error` and continue
|
|
62
|
-
* - `OnDuplicatesCallback` — custom handler
|
|
63
|
-
*
|
|
64
|
-
* Omitted entirely: no dispatch runs, but a `duplicate_declaration` diagnostic
|
|
65
|
-
* is still emitted into the diagnostics array for every collision (the diagnostic
|
|
66
|
-
* is the data; this option is the action).
|
|
52
|
+
* Every mode emits a `duplicate_declaration` diagnostic per colliding name:
|
|
67
53
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* should omit `onDuplicates` and inspect themselves:
|
|
72
|
-
*
|
|
73
|
-
* ```ts
|
|
74
|
-
* const result = await analyze({...});
|
|
75
|
-
* if (hasErrors(result.diagnostics)) throw new Error('analysis errors');
|
|
76
|
-
* ```
|
|
77
|
-
*
|
|
78
|
-
* Or use an `OnDuplicatesCallback` and stash the data before throwing.
|
|
79
|
-
*/
|
|
80
|
-
export type OnDuplicates = 'throw' | 'warn' | OnDuplicatesCallback;
|
|
81
|
-
/**
|
|
82
|
-
* Convenience `OnDuplicatesCallback` that throws on any duplicate.
|
|
54
|
+
* - `'diagnostic'` — the diagnostics only
|
|
55
|
+
* - `'warn'` — also log the collisions to `log.warn` and continue
|
|
56
|
+
* - `'throw'` — also throw an `Error` listing every duplicate
|
|
83
57
|
*
|
|
84
|
-
*
|
|
58
|
+
* The throw fires before the result is returned, so `'throw'` callers never
|
|
59
|
+
* reach the diagnostics array. For custom handling, use `'diagnostic'` and
|
|
60
|
+
* read the records with `byKind(diagnostics, 'duplicate_declaration')`.
|
|
85
61
|
*/
|
|
86
|
-
export
|
|
62
|
+
export type OnDuplicates = 'diagnostic' | 'warn' | 'throw';
|
|
87
63
|
/**
|
|
88
64
|
* Result of `analyze`, `analyzeFromFiles`, and `AnalysisSession.query`.
|
|
89
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAGN,KAAK,cAAc,EAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAoC,MAAM,oBAAoB,CAAC;AAGhG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAavE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAoE3D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAC1E,IAKF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,aAAa,MAAM,KACjB,IAuBF,CAAC;AAiPF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,GACvC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,SAAS,mBAAmB,EAC5B,SAAS,EAAE,CAAC,OAAO,KACjB,IAKF,CAAC"}
|
package/dist/analyze-core.js
CHANGED
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
* - `analyzeModule` — the per-module dispatcher for non-Svelte files (TS / CSS /
|
|
14
14
|
* JSON; Svelte needs `analyzeSvelteModule`). `@internal`; exposed for tests
|
|
15
15
|
* and power users via the subpath.
|
|
16
|
-
* - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates`
|
|
17
|
-
*
|
|
18
|
-
* directly from this module.
|
|
19
|
-
* - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
|
|
16
|
+
* - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` — shared
|
|
17
|
+
* types surfaced through the main barrel directly from this module.
|
|
20
18
|
* - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
|
|
21
19
|
* remap, then path normalization) in their required order; the one call for
|
|
22
20
|
* callers assembling modules themselves.
|
|
@@ -28,7 +26,7 @@
|
|
|
28
26
|
* assembling modules itself through `analyzeModule` can meet the same
|
|
29
27
|
* output contract.
|
|
30
28
|
*
|
|
31
|
-
* The barrel-surfaced schemas
|
|
29
|
+
* The barrel-surfaced schemas and types are stable API.
|
|
32
30
|
* Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
|
|
33
31
|
* `@internal`.
|
|
34
32
|
*
|
|
@@ -47,16 +45,6 @@ import { toPosixPath, isAbsolutePosixPath } from './paths.js';
|
|
|
47
45
|
import { buildAliasRegistry } from './typescript-alias-registry.js';
|
|
48
46
|
import { createExtractContext } from './typescript-extract-shared.js';
|
|
49
47
|
import { sortModules, findDuplicates, mergeReExports, resolveComponentAliases, compareStrings } from './postprocess.js';
|
|
50
|
-
/**
|
|
51
|
-
* Convenience `OnDuplicatesCallback` that throws on any duplicate.
|
|
52
|
-
*
|
|
53
|
-
* @throws Error listing every duplicate name and module location
|
|
54
|
-
*/
|
|
55
|
-
export const throwOnDuplicates = (duplicates) => {
|
|
56
|
-
if (duplicates.size === 0)
|
|
57
|
-
return;
|
|
58
|
-
throw new Error(formatDuplicates(duplicates));
|
|
59
|
-
};
|
|
60
48
|
const formatDuplicates = (duplicates) => {
|
|
61
49
|
const details = Array.from(duplicates)
|
|
62
50
|
.map(([name, occurrences]) => {
|
|
@@ -70,9 +58,8 @@ const formatDuplicates = (duplicates) => {
|
|
|
70
58
|
})
|
|
71
59
|
.join('\n');
|
|
72
60
|
return (`Found ${duplicates.size} duplicate declaration name${duplicates.size === 1 ? '' : 's'} across modules. ` +
|
|
73
|
-
'
|
|
74
|
-
'
|
|
75
|
-
'(2) add /** @nodocs */ to exclude from documentation.\n' +
|
|
61
|
+
'To resolve, rename one of the conflicting declarations, ' +
|
|
62
|
+
'or mark one /** @nodocs */ if it is not public API.\n' +
|
|
76
63
|
details);
|
|
77
64
|
};
|
|
78
65
|
/**
|
|
@@ -103,17 +90,12 @@ const emitDuplicateDiagnostics = (diagnostics, duplicates, sourceIdsByModulePath
|
|
|
103
90
|
}
|
|
104
91
|
};
|
|
105
92
|
const dispatchOnDuplicates = (mode, duplicates, log) => {
|
|
106
|
-
if (duplicates.size === 0)
|
|
107
|
-
return;
|
|
108
|
-
if (mode === 'throw') {
|
|
109
|
-
throw new Error(formatDuplicates(duplicates));
|
|
110
|
-
}
|
|
111
|
-
const errorLog = log ?? { error: (msg) => console.error(msg) };
|
|
112
|
-
if (mode === 'warn') {
|
|
113
|
-
errorLog.error(formatDuplicates(duplicates));
|
|
93
|
+
if (duplicates.size === 0 || mode === 'diagnostic')
|
|
114
94
|
return;
|
|
115
|
-
|
|
116
|
-
mode
|
|
95
|
+
const message = formatDuplicates(duplicates);
|
|
96
|
+
if (mode === 'throw')
|
|
97
|
+
throw new Error(message);
|
|
98
|
+
(log?.warn ?? console.warn)(message);
|
|
117
99
|
};
|
|
118
100
|
// Result types
|
|
119
101
|
/**
|
|
@@ -418,13 +400,10 @@ export const analyzeCore = (inputs) => {
|
|
|
418
400
|
// Gated canonicals extend the lookup without joining the output.
|
|
419
401
|
const resolvedModules = resolveComponentAliases(mergedModules, contextModules);
|
|
420
402
|
const sortedModules = sortModules(resolvedModules);
|
|
421
|
-
//
|
|
422
|
-
// reaches consumers regardless of `onDuplicates`. The `onDuplicates`
|
|
423
|
-
// callback/shortcut still fires for callers that want fail-fast or custom
|
|
424
|
-
// handling — diagnostics is the data, `onDuplicates` is the action.
|
|
425
|
-
const duplicates = findDuplicates(sortedModules);
|
|
426
|
-
emitDuplicateDiagnostics(diagnostics, duplicates, sourceIdsByModulePath);
|
|
403
|
+
// opt-in flat-namespace check, see `OnDuplicates`
|
|
427
404
|
if (onDuplicates) {
|
|
405
|
+
const duplicates = findDuplicates(sortedModules);
|
|
406
|
+
emitDuplicateDiagnostics(diagnostics, duplicates, sourceIdsByModulePath);
|
|
428
407
|
dispatchOnDuplicates(onDuplicates, duplicates, log);
|
|
429
408
|
}
|
|
430
409
|
normalizeModulePathsInTypes(sortedModules, sourceOptions, program);
|
package/dist/analyze.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface AnalyzeOptions {
|
|
|
40
40
|
sourceFiles: ReadonlyArray<SourceFileInfo>;
|
|
41
41
|
/** Module source options for path extraction and source filtering. */
|
|
42
42
|
sourceOptions: ModuleSourceOptions;
|
|
43
|
-
/**
|
|
43
|
+
/** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
|
|
44
44
|
onDuplicates?: OnDuplicates;
|
|
45
45
|
/** Optional logger for status and diagnostic messages. */
|
|
46
46
|
log?: AnalysisLog;
|
|
@@ -63,7 +63,8 @@ export interface AnalyzeOptions {
|
|
|
63
63
|
* @returns analyzed modules (sorted alphabetically) + concatenated ingest +
|
|
64
64
|
* query diagnostics
|
|
65
65
|
* @throws Error if `sourceOptions` validation fails or `tsconfig.json` is
|
|
66
|
-
* missing at `projectRoot
|
|
66
|
+
* missing at `projectRoot` or can't be loaded (see `loadTsconfig`). Also
|
|
67
|
+
* propagates `onDuplicates: 'throw'` errors.
|
|
67
68
|
*/
|
|
68
69
|
export declare const analyze: (options: AnalyzeOptions) => Promise<AnalyzeResultJson>;
|
|
69
70
|
/**
|
|
@@ -77,7 +78,7 @@ export interface AnalyzeFromFilesOptions {
|
|
|
77
78
|
projectRoot: string;
|
|
78
79
|
/** Partial overrides for default source options (SvelteKit `src/lib` layout). */
|
|
79
80
|
sourceOptions?: SourceOptionsOverrides;
|
|
80
|
-
/**
|
|
81
|
+
/** Opt-in check that declaration names are unique across modules (see `OnDuplicates`). */
|
|
81
82
|
onDuplicates?: OnDuplicates;
|
|
82
83
|
/** Optional logger for status and diagnostic messages. */
|
|
83
84
|
log?: AnalysisLog;
|
|
@@ -135,9 +136,9 @@ export interface AnalyzeFromFilesOptions {
|
|
|
135
136
|
* 3. **Analysis** — `session.query()`
|
|
136
137
|
*
|
|
137
138
|
* @returns analyzed modules + concatenated ingest, discovery, and query diagnostics
|
|
138
|
-
* @throws Error on invalid or contradictory options, a missing
|
|
139
|
-
* failed strict `'exports'` discovery,
|
|
140
|
-
* `onDuplicates: 'throw'`
|
|
139
|
+
* @throws Error on invalid or contradictory options, a missing or unloadable
|
|
140
|
+
* `tsconfig.json` (see `loadTsconfig`), failed strict `'exports'` discovery,
|
|
141
|
+
* or a collision under `onDuplicates: 'throw'`
|
|
141
142
|
*/
|
|
142
143
|
export declare const analyzeFromFiles: (options: AnalyzeFromFilesOptions) => Promise<AnalyzeResultJson>;
|
|
143
144
|
//# sourceMappingURL=analyze.d.ts.map
|
package/dist/analyze.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAEN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;OAMG;IACH,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3C,sEAAsE;IACtE,aAAa,EAAE,mBAAmB,CAAC;IACnC,
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAEN,KAAK,iBAAiB,EACtB,KA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|
package/dist/analyze.js
CHANGED
|
@@ -32,7 +32,8 @@ import { normalizeDiagnosticPaths } from './analyze-core.js';
|
|
|
32
32
|
* @returns analyzed modules (sorted alphabetically) + concatenated ingest +
|
|
33
33
|
* query diagnostics
|
|
34
34
|
* @throws Error if `sourceOptions` validation fails or `tsconfig.json` is
|
|
35
|
-
* missing at `projectRoot
|
|
35
|
+
* missing at `projectRoot` or can't be loaded (see `loadTsconfig`). Also
|
|
36
|
+
* propagates `onDuplicates: 'throw'` errors.
|
|
36
37
|
*/
|
|
37
38
|
export const analyze = async (options) => {
|
|
38
39
|
const session = createAnalysisSession({
|
|
@@ -70,9 +71,9 @@ export const analyze = async (options) => {
|
|
|
70
71
|
* 3. **Analysis** — `session.query()`
|
|
71
72
|
*
|
|
72
73
|
* @returns analyzed modules + concatenated ingest, discovery, and query diagnostics
|
|
73
|
-
* @throws Error on invalid or contradictory options, a missing
|
|
74
|
-
* failed strict `'exports'` discovery,
|
|
75
|
-
* `onDuplicates: 'throw'`
|
|
74
|
+
* @throws Error on invalid or contradictory options, a missing or unloadable
|
|
75
|
+
* `tsconfig.json` (see `loadTsconfig`), failed strict `'exports'` discovery,
|
|
76
|
+
* or a collision under `onDuplicates: 'throw'`
|
|
76
77
|
*/
|
|
77
78
|
export const analyzeFromFiles = async (options) => {
|
|
78
79
|
const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir } = options;
|
package/dist/cli.d.ts
CHANGED
|
@@ -17,10 +17,8 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
|
+
import type { OnDuplicates } from './analyze-core.js';
|
|
20
21
|
import type { Discovery } from './discovery.js';
|
|
21
|
-
/** Allowed values for `--on-duplicates`. */
|
|
22
|
-
declare const ON_DUPLICATES_VALUES: readonly ["throw", "warn"];
|
|
23
|
-
type OnDuplicatesFlag = (typeof ON_DUPLICATES_VALUES)[number];
|
|
24
22
|
/**
|
|
25
23
|
* CLI options parsed from command line arguments.
|
|
26
24
|
*/
|
|
@@ -76,13 +74,10 @@ export interface CliOptions {
|
|
|
76
74
|
*/
|
|
77
75
|
sourceRoot?: string;
|
|
78
76
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* Duplicate detection always runs regardless of this option — the diagnostic
|
|
83
|
-
* is the data, this option is the dispatch action.
|
|
77
|
+
* Opt-in check that declaration names are unique across modules (see
|
|
78
|
+
* `OnDuplicates`). Undefined skips the check.
|
|
84
79
|
*/
|
|
85
|
-
onDuplicates?:
|
|
80
|
+
onDuplicates?: OnDuplicates;
|
|
86
81
|
/**
|
|
87
82
|
* Glob patterns to filter the emitted `modules` array against `ModuleJson.path`
|
|
88
83
|
* (undefined = emit all analyzed modules).
|
|
@@ -105,5 +100,4 @@ export interface CliOptions {
|
|
|
105
100
|
* thrown analysis error (including an `--on-duplicates throw` collision)
|
|
106
101
|
*/
|
|
107
102
|
export declare const runCli: (argv?: Array<string>) => Promise<number>;
|
|
108
|
-
export {};
|
|
109
103
|
//# sourceMappingURL=cli.d.ts.map
|
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;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAwBhD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;OAMG;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;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;;;;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;;;;;;GAMG;AACH,eAAO,MAAM,MAAM,GAAU,OAAM,KAAK,CAAC,MAAM,CAAgB,KAAG,OAAO,CAAC,MAAM,CA4N/E,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -29,7 +29,11 @@ import { compactReplacer } from './declaration-helpers.js';
|
|
|
29
29
|
/** Collect repeatable option values into an array. */
|
|
30
30
|
const collect = (value, previous) => previous ? [...previous, value] : [value];
|
|
31
31
|
/** Allowed values for `--on-duplicates`. */
|
|
32
|
-
const ON_DUPLICATES_VALUES = [
|
|
32
|
+
const ON_DUPLICATES_VALUES = [
|
|
33
|
+
'diagnostic',
|
|
34
|
+
'warn',
|
|
35
|
+
'throw'
|
|
36
|
+
];
|
|
33
37
|
const isOnDuplicatesFlag = (value) => ON_DUPLICATES_VALUES.includes(value);
|
|
34
38
|
/** Allowed values for `--discovery`. */
|
|
35
39
|
const DISCOVERY_VALUES = ['auto', 'exports', 'glob'];
|
|
@@ -87,14 +91,16 @@ export const runCli = async (argv = process.argv) => {
|
|
|
87
91
|
'glob for the glob-discovery fallback when no --include is provided.', collect)
|
|
88
92
|
.option('--source-root <dir>', 'Prefix stripped from module paths in output (default: the source-dir, ' +
|
|
89
93
|
'or longest common prefix when multiple). Pass `.` to keep paths project-relative.')
|
|
90
|
-
.option('--on-duplicates <mode>', `Dispatch on duplicate declaration names across modules: ${ON_DUPLICATES_VALUES.join('|')} ` +
|
|
91
|
-
'(default: emit duplicate_declaration diagnostic, no dispatch)')
|
|
92
94
|
.option('--only <pattern>', 'Glob filter applied to module paths in output (repeatable). ' +
|
|
93
95
|
'Full project is still analyzed — re-exports/dependents stay correct — ' +
|
|
94
96
|
'but only matching modules are emitted. Diagnostics are not filtered ' +
|
|
95
97
|
'and may reference modules dropped from output.', collect)
|
|
96
98
|
.option('--pretty', 'Pretty-print JSON output', false)
|
|
97
99
|
.option('-q, --quiet', 'Suppress info messages on stderr (warnings and errors still print)', false)
|
|
100
|
+
.option('--on-duplicates <mode>', 'Opt-in check that declaration names are unique across modules, ' +
|
|
101
|
+
`for packages with a flat export namespace: ${ON_DUPLICATES_VALUES.join('|')} ` +
|
|
102
|
+
'(default: off). Every mode emits duplicate_declaration diagnostics; ' +
|
|
103
|
+
'warn also logs them and throw fails the run.')
|
|
98
104
|
.addHelpText('after', `
|
|
99
105
|
Examples:
|
|
100
106
|
$ svelte-docinfo Analyze current project
|
|
@@ -107,7 +113,6 @@ Examples:
|
|
|
107
113
|
No common prefix — module paths stay project-relative
|
|
108
114
|
$ svelte-docinfo --discovery glob Skip package.json exports
|
|
109
115
|
$ svelte-docinfo --discovery exports Strict — fail if exports missing
|
|
110
|
-
$ svelte-docinfo --on-duplicates throw Enforce flat namespace
|
|
111
116
|
$ svelte-docinfo --only 'components/**' Emit only modules under components/
|
|
112
117
|
$ svelte-docinfo --only '*.svelte' Emit only Svelte modules (top-level)
|
|
113
118
|
$ svelte-docinfo | jq . Pipe to jq for readable output`)
|
|
@@ -156,7 +161,6 @@ Examples:
|
|
|
156
161
|
...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {})
|
|
157
162
|
}
|
|
158
163
|
: undefined;
|
|
159
|
-
const onDuplicates = options.onDuplicates;
|
|
160
164
|
const { modules, diagnostics } = await analyzeFromFiles({
|
|
161
165
|
projectRoot: resolvedRoot,
|
|
162
166
|
include: options.include,
|
|
@@ -165,7 +169,7 @@ Examples:
|
|
|
165
169
|
discovery: options.discovery,
|
|
166
170
|
distDir: options.distDir,
|
|
167
171
|
...(sourceOptions !== undefined ? { sourceOptions } : {}),
|
|
168
|
-
...(onDuplicates !== undefined ? { onDuplicates } : {}),
|
|
172
|
+
...(options.onDuplicates !== undefined ? { onDuplicates: options.onDuplicates } : {}),
|
|
169
173
|
log
|
|
170
174
|
});
|
|
171
175
|
// `--only` is an output-only filter: analysis ran against the full
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* A few conditions still throw from the public entry points. These are
|
|
17
17
|
* configuration and environment errors, not per-file failures: invalid or
|
|
18
18
|
* contradictory options (see the `@throws` on `createSourceOptions` and
|
|
19
|
-
* `discoverSourceFiles`), a missing `tsconfig.json
|
|
19
|
+
* `discoverSourceFiles`), a missing or unloadable `tsconfig.json` (including
|
|
20
|
+
* an unresolved `extends`, see `loadTsconfig`), Svelte <5, and failed
|
|
20
21
|
* strict `'exports'` discovery. `onDuplicates: 'throw'` also throws, by
|
|
21
22
|
* request. Wrap the top-level call to handle these.
|
|
22
23
|
*
|
|
@@ -676,11 +677,11 @@ export type UnknownParamDiagnostic = z.infer<typeof UnknownParamDiagnostic>;
|
|
|
676
677
|
/**
|
|
677
678
|
* A declaration `name` appears in more than one module.
|
|
678
679
|
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
* the analysis result remains usable;
|
|
682
|
-
*
|
|
683
|
-
*
|
|
680
|
+
* Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
|
|
681
|
+
* flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
|
|
682
|
+
* so the analysis result remains usable; `onDuplicates: 'throw'` makes it
|
|
683
|
+
* fatal. The default slot (`name === 'default'`) is excluded — every module
|
|
684
|
+
* owns its own.
|
|
684
685
|
*/
|
|
685
686
|
export declare const DuplicateDeclarationDiagnostic: z.ZodObject<{
|
|
686
687
|
/** The duplicated declaration name. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;EAiBzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAgD5D;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAGpC,2DAA2D;;IAzC3D;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;IAEH,6DAA6D;;IAE7D,+DAA+D;;IAE/D,+CAA+C;;;;;;;kBAa9C,CAAC;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,2BAA2B;IAGvC,sCAAsC;;IApDtC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;;I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C,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAC6C,CAAC;AAEvF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,MAMzD,CAAC"}
|
package/dist/diagnostics.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* A few conditions still throw from the public entry points. These are
|
|
17
17
|
* configuration and environment errors, not per-file failures: invalid or
|
|
18
18
|
* contradictory options (see the `@throws` on `createSourceOptions` and
|
|
19
|
-
* `discoverSourceFiles`), a missing `tsconfig.json
|
|
19
|
+
* `discoverSourceFiles`), a missing or unloadable `tsconfig.json` (including
|
|
20
|
+
* an unresolved `extends`, see `loadTsconfig`), Svelte <5, and failed
|
|
20
21
|
* strict `'exports'` discovery. `onDuplicates: 'throw'` also throws, by
|
|
21
22
|
* request. Wrap the top-level call to handle these.
|
|
22
23
|
*
|
|
@@ -314,11 +315,11 @@ export const UnknownParamDiagnostic = z.strictObject({
|
|
|
314
315
|
/**
|
|
315
316
|
* A declaration `name` appears in more than one module.
|
|
316
317
|
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* the analysis result remains usable;
|
|
320
|
-
*
|
|
321
|
-
*
|
|
318
|
+
* Opt-in: emitted only when `onDuplicates` is set, for packages that keep a
|
|
319
|
+
* flat export namespace (see `OnDuplicates`). Emitted at `warning` severity
|
|
320
|
+
* so the analysis result remains usable; `onDuplicates: 'throw'` makes it
|
|
321
|
+
* fatal. The default slot (`name === 'default'`) is excluded — every module
|
|
322
|
+
* owns its own.
|
|
322
323
|
*/
|
|
323
324
|
export const DuplicateDeclarationDiagnostic = z.strictObject({
|
|
324
325
|
kind: z.literal('duplicate_declaration'),
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { analyze, analyzeFromFiles } from './analyze.js';
|
|
12
12
|
export type { AnalyzeOptions, AnalyzeFromFilesOptions } from './analyze.js';
|
|
13
|
-
export {
|
|
14
|
-
export type { AnalyzeResultJsonWire, OnDuplicates
|
|
13
|
+
export { AnalyzeResultJson } from './analyze-core.js';
|
|
14
|
+
export type { AnalyzeResultJsonWire, OnDuplicates } from './analyze-core.js';
|
|
15
15
|
export { createAnalysisSession } from './session.js';
|
|
16
16
|
export type { AnalysisSession, AnalysisSessionOptions, SetFileOptions, SetFileResult, SetFilesResult, QueryOptions } from './session.js';
|
|
17
17
|
export { normalizeResolveImport } from './dep-resolver.js';
|
|
@@ -23,8 +23,8 @@ export { getDefaultAnalyzer } from './source.js';
|
|
|
23
23
|
export type { SourceFileInfo, AnalyzerType } from './source.js';
|
|
24
24
|
export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
|
|
25
25
|
export type { ExcludeOption, ModuleSourceOptions, SourceOptionsDefaults, SourceOptionsOverrides } from './source-config.js';
|
|
26
|
-
export {
|
|
27
|
-
export type {
|
|
26
|
+
export { mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
|
|
27
|
+
export type { ExportSurface, ExportSurfaceEntry } from './postprocess.js';
|
|
28
28
|
export { deriveIncludePatterns } from './files.js';
|
|
29
29
|
export { discoverSourceFiles } from './discovery.js';
|
|
30
30
|
export type { Discovery, DiscoverSourceFilesOptions, DiscoverSourceFilesResult } from './discovery.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzD,YAAY,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/index.ts"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E,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjF,YAAY,EACX,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACjG,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAInD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EACX,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,EACzB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,UAAU,EACV,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
// Core entry points
|
|
12
12
|
export { analyze, analyzeFromFiles } from './analyze.js';
|
|
13
|
-
export {
|
|
13
|
+
export { AnalyzeResultJson } from './analyze-core.js';
|
|
14
14
|
export { createAnalysisSession } from './session.js';
|
|
15
15
|
export { normalizeResolveImport } from './dep-resolver.js';
|
|
16
16
|
// Types (Zod schemas + TypeScript interfaces)
|
|
@@ -22,7 +22,7 @@ export { getDefaultAnalyzer } from './source.js';
|
|
|
22
22
|
// Source options
|
|
23
23
|
export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
|
|
24
24
|
// Post-processing
|
|
25
|
-
export {
|
|
25
|
+
export { mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
|
|
26
26
|
// File system helpers
|
|
27
27
|
export { deriveIncludePatterns } from './files.js';
|
|
28
28
|
// File discovery
|