svelte-docinfo 0.7.0 → 0.8.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 (76) hide show
  1. package/README.md +16 -9
  2. package/dist/analyze-core.d.ts +55 -27
  3. package/dist/analyze-core.d.ts.map +1 -1
  4. package/dist/analyze-core.js +51 -45
  5. package/dist/analyze.d.ts +12 -31
  6. package/dist/analyze.d.ts.map +1 -1
  7. package/dist/analyze.js +5 -3
  8. package/dist/cli.d.ts +4 -7
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +4 -3
  11. package/dist/concurrency.d.ts +6 -3
  12. package/dist/concurrency.d.ts.map +1 -1
  13. package/dist/concurrency.js +6 -3
  14. package/dist/dep-resolver.d.ts +6 -3
  15. package/dist/dep-resolver.d.ts.map +1 -1
  16. package/dist/dep-resolver.js +6 -3
  17. package/dist/diagnostics.d.ts +18 -9
  18. package/dist/diagnostics.d.ts.map +1 -1
  19. package/dist/diagnostics.js +20 -9
  20. package/dist/discovery.d.ts +16 -21
  21. package/dist/discovery.d.ts.map +1 -1
  22. package/dist/discovery.js +9 -17
  23. package/dist/error.d.ts +3 -4
  24. package/dist/error.d.ts.map +1 -1
  25. package/dist/error.js +3 -4
  26. package/dist/exports.d.ts +7 -7
  27. package/dist/exports.d.ts.map +1 -1
  28. package/dist/exports.js +8 -8
  29. package/dist/files.d.ts +0 -3
  30. package/dist/files.d.ts.map +1 -1
  31. package/dist/files.js +5 -5
  32. package/dist/index.js +1 -1
  33. package/dist/postprocess.d.ts +13 -6
  34. package/dist/postprocess.d.ts.map +1 -1
  35. package/dist/postprocess.js +13 -6
  36. package/dist/session.d.ts +36 -12
  37. package/dist/session.d.ts.map +1 -1
  38. package/dist/session.js +39 -24
  39. package/dist/source-config.d.ts +22 -19
  40. package/dist/source-config.d.ts.map +1 -1
  41. package/dist/source-config.js +14 -12
  42. package/dist/source.d.ts +17 -13
  43. package/dist/source.d.ts.map +1 -1
  44. package/dist/source.js +4 -7
  45. package/dist/svelte.d.ts +21 -4
  46. package/dist/svelte.d.ts.map +1 -1
  47. package/dist/svelte.js +48 -15
  48. package/dist/tsdoc.d.ts +4 -8
  49. package/dist/tsdoc.d.ts.map +1 -1
  50. package/dist/tsdoc.js +4 -8
  51. package/dist/types.d.ts +607 -171
  52. package/dist/types.d.ts.map +1 -1
  53. package/dist/types.js +71 -28
  54. package/dist/typescript-exports.d.ts +7 -7
  55. package/dist/typescript-exports.d.ts.map +1 -1
  56. package/dist/typescript-exports.js +15 -13
  57. package/dist/typescript-extract-class.d.ts +2 -1
  58. package/dist/typescript-extract-class.d.ts.map +1 -1
  59. package/dist/typescript-extract-class.js +7 -7
  60. package/dist/typescript-extract-function.js +3 -3
  61. package/dist/typescript-extract-shared.d.ts +32 -12
  62. package/dist/typescript-extract-shared.d.ts.map +1 -1
  63. package/dist/typescript-extract-shared.js +55 -34
  64. package/dist/typescript-extract-type-json.d.ts +11 -3
  65. package/dist/typescript-extract-type-json.d.ts.map +1 -1
  66. package/dist/typescript-extract-type-json.js +12 -9
  67. package/dist/typescript-extract-type-properties.js +3 -3
  68. package/dist/typescript-extract-type.js +7 -7
  69. package/dist/typescript-program.d.ts +23 -8
  70. package/dist/typescript-program.d.ts.map +1 -1
  71. package/dist/typescript-program.js +23 -14
  72. package/dist/vite.d.ts +12 -35
  73. package/dist/vite.d.ts.map +1 -1
  74. package/dist/vite.js +7 -6
  75. package/package.json +9 -29
  76. package/virtual-svelte-docinfo.d.ts +9 -7
package/README.md CHANGED
@@ -18,6 +18,9 @@ in the [npm package](https://www.npmjs.com/package/svelte-docinfo).
18
18
  npm i -D svelte-docinfo
19
19
  ```
20
20
 
21
+ Peer dependencies: `svelte` 5+, `svelte2tsx`, `typescript` 5.9+, and `zod` 4+
22
+ (npm 7+ installs them automatically).
23
+
21
24
  - [Quick start](#quick-start)
22
25
  - [Vite plugin](#vite-plugin)
23
26
  - [CLI](#cli)
@@ -50,7 +53,7 @@ which was more limited, lacking the fancy TS compiler usage, and grew slowly ove
50
53
 
51
54
  ## Quick start
52
55
 
53
- Given a project with a couple of files in `src/lib/`:
56
+ Given a project with a `tsconfig.json` (at or above the project root) and a couple of files in `src/lib/`:
54
57
 
55
58
  ```ts
56
59
  // src/lib/math.ts
@@ -221,7 +224,7 @@ Plugin options:
221
224
  | `projectRoot` | Vite's resolved `config.root` | Absolute path to project root. |
222
225
  | `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. |
223
226
  | `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. |
224
- | `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or empty. |
227
+ | `discovery` | `'auto'` | Discovery strategy: `'auto'` \| `'exports'` \| `'glob'`. `'exports'` is strict and fails if `package.json` exports is missing or resolves to no files. |
225
228
  | `distDir` | `'dist'` | Dist directory name for exports-based discovery. |
226
229
  | `sourceOptions` | `{sourcePaths: ['src/lib'], …}` | Partial overrides for default source options (SvelteKit `src/lib` layout). |
227
230
  | `resolveDependencies` | `true` | Resolve import dependencies. When `false`, `dependencies`/`dependents` stay empty. |
@@ -269,7 +272,7 @@ All CLI options:
269
272
  | `-i, --include <pattern>` | Include pattern (repeatable, replaces exports discovery, widens the source scope; incompatible with `--discovery exports`) |
270
273
  | `-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) |
271
274
  | `-o, --output <file>` | Output file (default: stdout; pass `-` for explicit stdout, so `-o "$OUT"` works when `$OUT=-`) |
272
- | `--discovery <mode>` | `auto` \| `exports` \| `glob` (default: `auto` — exports first, glob fallback). `exports` is strict and fails if package.json exports is missing |
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 |
273
276
  | `--dist-dir <dir>` | Dist directory for exports discovery (default: dist) |
274
277
  | `--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 |
275
278
  | `--source-root <dir>` | Source root for module-path stripping (default: single source-dir or longest common prefix; pass `.` for project-relative paths) |
@@ -282,7 +285,8 @@ All CLI options:
282
285
 
283
286
  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.
284
287
 
285
- Exit codes: 0 (success), 1 (analysis errors), 2 (CLI errors).
288
+ Exit codes: 0 (success), 1 (analysis errors), 2 (CLI errors or a thrown analysis error, like a
289
+ missing `tsconfig.json` or an `--on-duplicates throw` collision).
286
290
 
287
291
  See [examples/cli/](examples/cli/README.md) for more usage patterns.
288
292
 
@@ -326,11 +330,12 @@ See the [API docs](https://svelte-docinfo.fuz.dev/docs/api) for the full referen
326
330
  ## Features
327
331
 
328
332
  - **Full type resolution**: infers complex types without manual annotations, including generics, imported types, and inferred return types
329
- - **Structured types**: an optional `typeInfo` tree (`TypeJson`) beside the flat type strings on props, parameters, return types (`returnTypeInfo`, overloads included), type members, and variable/type declarations — union and intersection members (alias names kept, enum members as `{value, text}` pairs), reference type arguments (named generic instantiations like `Snippet<[a: string]>` classify as references), array and tuple elements (with `readonly` markers), so a union alias documents more than its own name — and absent wherever the flat string already says everything
330
- - **TSDoc/JSDoc parsing**: the common doc tags (`@param`, `@returns`, `@throws`, `@example`, `@deprecated`, `@internal`, `@see`, `@since`, `@default`) plus `@nodocs`, `@mutates`, and `@module` for file-level comments; divergent spellings parse as synonyms (`@return`, TSDoc's `@defaultValue`). `@internal` is a marker (`internalMessage`, prose kept), not an exclusion — that's `@nodocs`
331
- - **Alias-lost name recovery**: schema-inferred aliases (`type Foo = z.infer<typeof S>` — any indexed-access or conditional right-hand side) lose their name in the checker, which expands their structure at every use; `typeInfo` recovers the name as `{kind: 'reference', name}` from the written annotation where one exists, and — via an identity-keyed registry of the analyzed set's exported lost aliases — at unannotated inferred positions too, `null`-bearing optionals included; registry-recovered references also carry `module` (the declaring module's `ModuleJson.path`, always an emitted module) for collision-exact linking. Losses nothing recovers surface as `alias_lost` warnings (readable degradations like `z.enum` literal unions and `.brand()` intersections excluded)
332
- - **Merged value+type symbols**: `export const Foo = z.strictObject({...})` + `export type Foo = z.infer<typeof Foo>` (one symbol, both spaces) documents the type meaning — structure and members like the un-merged equivalent — with `mergedValue: true` marking the name as also importable as a runtime value; JSDoc falls back to the const's docs, and `generateImport` emits a value import
333
- - **Svelte 5 component props**: extracts prop types, descriptions, defaults, and bindability via svelte2tsx
333
+ - **Structured types**: an optional `typeInfo` tree (`TypeJson`) beside the flat type strings on props, parameters, return types (`returnTypeInfo`, overloads included), members, and variable/type declarations — union and intersection members (alias names kept), reference type arguments, and array/tuple elements, so a union alias documents more than its own name. Absent wherever the flat string already says everything; `typeJsonToTokens`/`typeJsonToText` render it
334
+ - **TSDoc/JSDoc parsing**: the common doc tags (`@param`, `@returns`, `@throws`, `@example`, `@deprecated`, `@internal`, `@see`, `@since`, `@default`) plus `@nodocs`, `@mutates`, and `@module` for file-level comments; divergent spellings parse as synonyms (`@return`, `@defaultValue`). `@internal` marks unstable API (`internalMessage`) but stays documented — `@nodocs` is the exclusion. Dotted `@param obj.prop` tags fill `propertyDescriptions`, and inline `{@link}` survives in extracted text
335
+ - **Alias-lost name recovery**: TypeScript drops the name of an alias over an indexed access or conditional (`type Foo = z.infer<typeof S>`) and expands its structure at every use. `typeInfo` recovers it as `{kind: 'reference', name}`, from the written annotation where there is one and otherwise from a registry of the project's exported aliases (those references also carry `module` for exact linking). Losses nothing recovers surface as `alias_lost` warnings
336
+ - **Merged value+type symbols**: `export const Foo = z.strictObject({...})` + `export type Foo = z.infer<typeof Foo>` documents the type meaning (structure and members), with `mergedValue: true` marking the name as also a runtime value; JSDoc falls back to the const's docs, and `generateImport` emits a value import
337
+ - **Svelte 5 component props**: extracts prop types, descriptions, defaults, and bindability via svelte2tsx, in source order; generic components carry `genericParams`, and JS components (no `lang="ts"`) are supported — props come from the JSDoc `@type` on `$props()` or are inferred from untyped destructuring
338
+ - **External types**: props and members contributed by external packages (e.g. `HTMLButtonAttributes`) are filtered out and named in `externalTypes` — on components, type aliases, interfaces, and classes, including bags reached through local base types
334
339
  - **Svelte 5 snippets**: `kind: 'snippet'` for template snippets (with structured parameters), `acceptsChildren` on components
335
340
  - **Svelte 5 reactivity runes**: detects `$state`, `$state.raw`, `$derived`, `$derived.by` on variables and class fields (`reactivity` field) — syntactic detection, surfaces wherever the rune pattern appears
336
341
  - **Class members**: public + protected fields, methods, constructors, getters/setters, generics; private (`private` and `#field`) excluded
@@ -348,6 +353,8 @@ Known gaps:
348
353
  - context tracking (transitive detection of common patterns seems tractable)
349
354
  - standalone `namespace Foo {}` declarations and decorators are not yet supported
350
355
  - Svelte 4 legacy features (slots, events, `$restProps`) are out of scope — Svelte 5 snippets and callback props replace most of them
356
+ - legacy `export let` props aren't extracted (the component gets zero props), but a `legacy_props` warning names them
357
+ - `@nodocs` applies to declarations and export statements only; on a member or component prop it's ignored without a warning
351
358
 
352
359
  [Issues](https://github.com/fuzdev/svelte-docinfo/issues) for bugs and
353
360
  [discussions](https://github.com/fuzdev/svelte-docinfo/discussions) are welcome!
@@ -1,21 +1,21 @@
1
1
  /**
2
2
  * Pure two-phase analysis orchestrator.
3
3
  *
4
- * Extracted from `analyze.ts` to break what would otherwise be a circular
5
- * import: `session.ts` → `analyze.ts` (for the orchestrator) → `session.ts`
6
- * (for the wrappers). With the orchestrator here, both `session.ts` and
7
- * `analyze.ts` import downward into this module without depending on each
8
- * other.
4
+ * Separate from `analyze.ts` so `session.ts` (which needs the orchestrator)
5
+ * and `analyze.ts` (which needs the session) both import downward into this
6
+ * module without a cycle.
9
7
  *
10
8
  * Public surface:
11
9
  *
12
10
  * - `analyzeCore` — runs phase 1 module dispatch + phase 2 re-export merge,
13
11
  * returns `AnalyzeResultJson`. Caller supplies pre-prepared inputs (program,
14
12
  * svelte virtuals, transform-failed IDs).
15
- * - `analyzeModule` — the per-module dispatcher (TS / Svelte / CSS / JSON).
16
- * `@internal`; exposed for tests and power users via the subpath.
17
- * - `AnalyzeResultJson` / `OnDuplicates` / `OnDuplicatesCallback` — shared types
18
- * surfaced through the main barrel directly from this module.
13
+ * - `analyzeModule` — the per-module dispatcher for non-Svelte files (TS / CSS /
14
+ * JSON; Svelte needs `analyzeSvelteModule`). `@internal`; exposed for tests
15
+ * and power users via the subpath.
16
+ * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` /
17
+ * `OnDuplicatesCallback` — shared types surfaced through the main barrel
18
+ * directly from this module.
19
19
  * - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
20
20
  * - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
21
21
  * remap, then path normalization) in their required order; the one call for
@@ -28,8 +28,9 @@
28
28
  * assembling modules itself through `analyzeModule` can meet the same
29
29
  * output contract.
30
30
  *
31
- * @internal — module split is implementation detail; consumers go through
32
- * `analyze.ts` / `session.ts` for the stable surface.
31
+ * The barrel-surfaced schemas, types, and `throwOnDuplicates` are stable API.
32
+ * Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
33
+ * `@internal`.
33
34
  *
34
35
  * @module
35
36
  */
@@ -1464,12 +1465,8 @@ export interface AnalyzeResultJsonWire {
1464
1465
  diagnostics: Array<Diagnostic>;
1465
1466
  }
1466
1467
  /**
1467
- * Analyze a single non-Svelte source file and extract module metadata.
1468
- *
1469
- * @internal Single-module dispatcher used internally by the two-phase
1470
- * orchestrator. Importable from `svelte-docinfo/analyze-core.js` for tests
1471
- * and power users — not part of the stable barrel API and not guaranteed
1472
- * across minor versions.
1468
+ * Analyze a single non-Svelte source file and extract module metadata — the
1469
+ * per-module dispatcher behind `analyzeCore`.
1473
1470
  *
1474
1471
  * Dispatches on file type:
1475
1472
  * - TypeScript/JS → `analyzeTypescriptModule`
@@ -1487,6 +1484,9 @@ export interface AnalyzeResultJsonWire {
1487
1484
  * `aliasRegistry` is optional at this boundary: direct callers assembling
1488
1485
  * modules themselves get written-name recovery only, while `analyzeCore`
1489
1486
  * passes the registry its pre-pass built (see `buildAliasRegistry`).
1487
+ *
1488
+ * @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
1489
+ * power users; not stable API.
1490
1490
  */
1491
1491
  export declare const analyzeModule: (sourceFile: SourceFileInfo & {
1492
1492
  dependents?: ReadonlyArray<string>;
@@ -1517,11 +1517,35 @@ export interface AnalyzeCoreInputs {
1517
1517
  * context for `resolveComponentAliases` — their modules never emit and
1518
1518
  * their analysis diagnostics are dropped (`partial` on the canonical
1519
1519
  * propagates to the filled alias instead).
1520
+ *
1521
+ * Resolution requires the component's virtual to exist — via the context
1522
+ * closure (`analyzeFromFiles` included) or by passing the file as `analyze()`
1523
+ * input. Without it a gated component re-export degrades silently to an
1524
+ * empty `kind: 'variable'` husk.
1520
1525
  */
1521
1526
  contextSvelteFiles?: ReadonlyArray<SourceFileInfo>;
1522
1527
  onDuplicates?: OnDuplicates;
1523
1528
  log?: AnalysisLog;
1524
1529
  }
1530
+ /**
1531
+ * Run the two-phase analysis loop on pre-prepared inputs. The orchestrator
1532
+ * behind `session.query`, and so behind the one-shot wrappers, which query a
1533
+ * single-use session.
1534
+ *
1535
+ * Runs the alias-registry pre-pass (`buildAliasRegistry`) over the emitted
1536
+ * set, then phase 1: per-file dispatch (TS / Svelte / CSS / JSON /
1537
+ * placeholder for transform-failed Svelte), plus gated Svelte canonicals
1538
+ * analyzed as fill context. Phase 2: re-export merge, component-alias fill,
1539
+ * sort, duplicate detection, and module-path normalization in printed types
1540
+ * (`normalizeModulePathsInTypes`), then `finalizeDiagnostics`.
1541
+ *
1542
+ * Dependents are read from `sourceFile.dependents` via `extractDependencies`;
1543
+ * `analyzeCore` does not compute them. `session.query` runs
1544
+ * `computeDependents` on the emitted set before invoking this.
1545
+ *
1546
+ * @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
1547
+ * power users; not stable API.
1548
+ */
1525
1549
  export declare const analyzeCore: (inputs: AnalyzeCoreInputs) => AnalyzeResultJson;
1526
1550
  /**
1527
1551
  * Run the diagnostic boundary passes in their required order: virtual
@@ -1533,7 +1557,7 @@ export declare const analyzeCore: (inputs: AnalyzeCoreInputs) => AnalyzeResultJs
1533
1557
  * ordering unrepresentable instead of a contract to remember. Omit
1534
1558
  * `virtualFiles` when no Svelte virtuals are in play.
1535
1559
  *
1536
- * @mutates diagnostics — rewrites positions, `file`, and `message`
1560
+ * @mutates diagnostics - rewrites positions, `file`, and `message`
1537
1561
  */
1538
1562
  export declare const finalizeDiagnostics: (diagnostics: Array<Diagnostic>, options: {
1539
1563
  projectRoot: string;
@@ -1547,9 +1571,8 @@ export declare const finalizeDiagnostics: (diagnostics: Array<Diagnostic>, optio
1547
1571
  * paths (svelte2tsx output like `Foo.svelte.__svelte2tsx__.ts`). This pass
1548
1572
  * collapses both to the public contract: a path relative to `projectRoot`
1549
1573
  * with no leading slash and no `./` prefix. A file outside the root gets the
1550
- * `../` form, matching module paths in printed type text — and making the
1551
- * documented "rejoin with `projectRoot` to get an absolute path" actually
1552
- * hold for it, which dropping the leading slash did not.
1574
+ * `../` form, matching module paths in printed type text — so the documented
1575
+ * "rejoin with `projectRoot` to get an absolute path" holds for it too.
1553
1576
  *
1554
1577
  * `message` gets the same treatment as `file`, by textual substitution. A
1555
1578
  * message is free-form, and not every path in one comes from a field this
@@ -1565,7 +1588,7 @@ export declare const finalizeDiagnostics: (diagnostics: Array<Diagnostic>, optio
1565
1588
  * pass can only correct the absolute form — a relative path on a base other
1566
1589
  * than the project root passes through and ships as-is.
1567
1590
  *
1568
- * @mutates diagnostics — rewrites each diagnostic's `file` and `message`
1591
+ * @mutates diagnostics - rewrites each diagnostic's `file` and `message`
1569
1592
  * @see `finalizeDiagnostics` — when Svelte virtuals are in play, the position
1570
1593
  * remap must run before this pass (it strips the suffix the remap matches on)
1571
1594
  */
@@ -1576,22 +1599,27 @@ export declare const normalizeDiagnosticPaths: (diagnostics: Array<Diagnostic>,
1576
1599
  *
1577
1600
  * The checker prints a module object as `typeof import("<absolute path>")`,
1578
1601
  * which reaches output through every checker-printed field — `typeSignature`
1579
- * on declarations and members, `returnType`, and the `text`/`name` of a
1580
- * `TypeJson` node. Left alone it makes output machine-dependent (two checkouts
1602
+ * on declarations and members, `returnType`, and the `text` of a
1603
+ * `TypeJson` node (a module object is a terminal `other` node, never a
1604
+ * `reference`). Left alone it makes output machine-dependent (two checkouts
1581
1605
  * of the same source produce different bytes), publishes local filesystem
1582
1606
  * paths on any site that renders `typeSignature`, and exposes the svelte2tsx
1583
- * virtual suffix that `stripVirtualSuffix` exists to hide.
1607
+ * virtual suffix that `stripVirtualSuffix` exists to hide. A written
1608
+ * `import('./x').T` annotation resolves to the type's own name and never
1609
+ * carries a path.
1584
1610
  *
1585
1611
  * A path that resolves to a module in this output is rewritten to that
1586
1612
  * module's `ModuleJson.path`, so the string doubles as a lookup key: a
1587
1613
  * consumer linkifies with `modules.find((m) => m.path === s)` and reads a miss
1588
1614
  * as "not a module here." See `createModulePathNormalizer` for the remaining
1589
- * tiers.
1615
+ * tiers. The string's shape doesn't distinguish them (`sub/nested.ts` and
1616
+ * `pkg/index.d.ts` look alike) — the lookup does, which keeps `sourceRoot` out
1617
+ * of the output envelope.
1590
1618
  *
1591
1619
  * Runs as a whole-output pass rather than at the ~20 `typeToString` /
1592
1620
  * `signatureToString` call sites, so a new printing site can't miss it.
1593
1621
  *
1594
- * @mutates modules — rewrites printed type text on declarations and members
1622
+ * @mutates modules - rewrites printed type text on declarations and members
1595
1623
  */
1596
1624
  export declare const normalizeModulePathsInTypes: (modules: Array<ModuleJson>, options: ModuleSourceOptions, program: ts.Program) => void;
1597
1625
  //# sourceMappingURL=analyze-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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;AAEvE,OAAO,EAMN,KAAK,oBAAoB,EACzB,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC,EACpD,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,oBAAoB,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,oBAG/B,CAAC;AA2EF;;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;;;;;;;;;;;;;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"}
@@ -1,21 +1,21 @@
1
1
  /**
2
2
  * Pure two-phase analysis orchestrator.
3
3
  *
4
- * Extracted from `analyze.ts` to break what would otherwise be a circular
5
- * import: `session.ts` → `analyze.ts` (for the orchestrator) → `session.ts`
6
- * (for the wrappers). With the orchestrator here, both `session.ts` and
7
- * `analyze.ts` import downward into this module without depending on each
8
- * other.
4
+ * Separate from `analyze.ts` so `session.ts` (which needs the orchestrator)
5
+ * and `analyze.ts` (which needs the session) both import downward into this
6
+ * module without a cycle.
9
7
  *
10
8
  * Public surface:
11
9
  *
12
10
  * - `analyzeCore` — runs phase 1 module dispatch + phase 2 re-export merge,
13
11
  * returns `AnalyzeResultJson`. Caller supplies pre-prepared inputs (program,
14
12
  * svelte virtuals, transform-failed IDs).
15
- * - `analyzeModule` — the per-module dispatcher (TS / Svelte / CSS / JSON).
16
- * `@internal`; exposed for tests and power users via the subpath.
17
- * - `AnalyzeResultJson` / `OnDuplicates` / `OnDuplicatesCallback` — shared types
18
- * surfaced through the main barrel directly from this module.
13
+ * - `analyzeModule` — the per-module dispatcher for non-Svelte files (TS / CSS /
14
+ * JSON; Svelte needs `analyzeSvelteModule`). `@internal`; exposed for tests
15
+ * and power users via the subpath.
16
+ * - `AnalyzeResultJson` / `AnalyzeResultJsonWire` / `OnDuplicates` /
17
+ * `OnDuplicatesCallback` — shared types surfaced through the main barrel
18
+ * directly from this module.
19
19
  * - `throwOnDuplicates` — convenience callback paired with `OnDuplicates`.
20
20
  * - `finalizeDiagnostics` — the diagnostic boundary passes (virtual position
21
21
  * remap, then path normalization) in their required order; the one call for
@@ -28,8 +28,9 @@
28
28
  * assembling modules itself through `analyzeModule` can meet the same
29
29
  * output contract.
30
30
  *
31
- * @internal — module split is implementation detail; consumers go through
32
- * `analyze.ts` / `session.ts` for the stable surface.
31
+ * The barrel-surfaced schemas, types, and `throwOnDuplicates` are stable API.
32
+ * Everything else is subpath-only; `analyzeCore` and `analyzeModule` are
33
+ * `@internal`.
33
34
  *
34
35
  * @module
35
36
  */
@@ -179,12 +180,8 @@ const toModuleJson = (raw) => {
179
180
  };
180
181
  // Module dispatch
181
182
  /**
182
- * Analyze a single non-Svelte source file and extract module metadata.
183
- *
184
- * @internal Single-module dispatcher used internally by the two-phase
185
- * orchestrator. Importable from `svelte-docinfo/analyze-core.js` for tests
186
- * and power users — not part of the stable barrel API and not guaranteed
187
- * across minor versions.
183
+ * Analyze a single non-Svelte source file and extract module metadata — the
184
+ * per-module dispatcher behind `analyzeCore`.
188
185
  *
189
186
  * Dispatches on file type:
190
187
  * - TypeScript/JS → `analyzeTypescriptModule`
@@ -202,6 +199,9 @@ const toModuleJson = (raw) => {
202
199
  * `aliasRegistry` is optional at this boundary: direct callers assembling
203
200
  * modules themselves get written-name recovery only, while `analyzeCore`
204
201
  * passes the registry its pre-pass built (see `buildAliasRegistry`).
202
+ *
203
+ * @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
204
+ * power users; not stable API.
205
205
  */
206
206
  export const analyzeModule = (sourceFile, program, options, diagnostics, log, aliasRegistry) => {
207
207
  const checker = program.getTypeChecker();
@@ -270,23 +270,6 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log, al
270
270
  }
271
271
  return toModuleJson(raw);
272
272
  };
273
- /**
274
- * Run the two-phase analysis loop on pre-prepared inputs.
275
- *
276
- * @internal Shared two-phase orchestrator used internally by `session.query`
277
- * and the one-shot wrappers. Importable from `svelte-docinfo/analyze-core.js`
278
- * for tests and power users — not part of the stable barrel API and not
279
- * guaranteed across minor versions.
280
- *
281
- * Phase 1: per-file dispatch (TS / Svelte / CSS / JSON / placeholder for
282
- * transform-failed Svelte). Phase 2: re-export merge, component-alias fill,
283
- * sort, duplicate detection. Diagnostic paths are normalized to
284
- * project-root-relative form before return.
285
- *
286
- * Dependents are read from `sourceFile.dependents` (caller-supplied via
287
- * `extractDependencies`); `analyzeCore` does not compute them. `session.query`
288
- * runs `computeDependents` on the owned set before invoking this.
289
- */
290
273
  /**
291
274
  * Analyze the gated Svelte canonicals referenced by an emitted component
292
275
  * alias, as `resolveComponentAliases` fill context only (see
@@ -320,6 +303,25 @@ const analyzeContextComponents = (contextSvelteFiles, emittedModules, inputs, al
320
303
  }
321
304
  return contextModules;
322
305
  };
306
+ /**
307
+ * Run the two-phase analysis loop on pre-prepared inputs. The orchestrator
308
+ * behind `session.query`, and so behind the one-shot wrappers, which query a
309
+ * single-use session.
310
+ *
311
+ * Runs the alias-registry pre-pass (`buildAliasRegistry`) over the emitted
312
+ * set, then phase 1: per-file dispatch (TS / Svelte / CSS / JSON /
313
+ * placeholder for transform-failed Svelte), plus gated Svelte canonicals
314
+ * analyzed as fill context. Phase 2: re-export merge, component-alias fill,
315
+ * sort, duplicate detection, and module-path normalization in printed types
316
+ * (`normalizeModulePathsInTypes`), then `finalizeDiagnostics`.
317
+ *
318
+ * Dependents are read from `sourceFile.dependents` via `extractDependencies`;
319
+ * `analyzeCore` does not compute them. `session.query` runs
320
+ * `computeDependents` on the emitted set before invoking this.
321
+ *
322
+ * @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
323
+ * power users; not stable API.
324
+ */
323
325
  export const analyzeCore = (inputs) => {
324
326
  const { sourceFiles, sourceOptions, program, svelteVirtualFiles, transformFailedIds, contextSvelteFiles, onDuplicates, log } = inputs;
325
327
  const checker = program.getTypeChecker();
@@ -445,7 +447,7 @@ export const analyzeCore = (inputs) => {
445
447
  * ordering unrepresentable instead of a contract to remember. Omit
446
448
  * `virtualFiles` when no Svelte virtuals are in play.
447
449
  *
448
- * @mutates diagnostics — rewrites positions, `file`, and `message`
450
+ * @mutates diagnostics - rewrites positions, `file`, and `message`
449
451
  */
450
452
  export const finalizeDiagnostics = (diagnostics, options) => {
451
453
  if (options.virtualFiles) {
@@ -461,9 +463,8 @@ export const finalizeDiagnostics = (diagnostics, options) => {
461
463
  * paths (svelte2tsx output like `Foo.svelte.__svelte2tsx__.ts`). This pass
462
464
  * collapses both to the public contract: a path relative to `projectRoot`
463
465
  * with no leading slash and no `./` prefix. A file outside the root gets the
464
- * `../` form, matching module paths in printed type text — and making the
465
- * documented "rejoin with `projectRoot` to get an absolute path" actually
466
- * hold for it, which dropping the leading slash did not.
466
+ * `../` form, matching module paths in printed type text — so the documented
467
+ * "rejoin with `projectRoot` to get an absolute path" holds for it too.
467
468
  *
468
469
  * `message` gets the same treatment as `file`, by textual substitution. A
469
470
  * message is free-form, and not every path in one comes from a field this
@@ -479,7 +480,7 @@ export const finalizeDiagnostics = (diagnostics, options) => {
479
480
  * pass can only correct the absolute form — a relative path on a base other
480
481
  * than the project root passes through and ships as-is.
481
482
  *
482
- * @mutates diagnostics — rewrites each diagnostic's `file` and `message`
483
+ * @mutates diagnostics - rewrites each diagnostic's `file` and `message`
483
484
  * @see `finalizeDiagnostics` — when Svelte virtuals are in play, the position
484
485
  * remap must run before this pass (it strips the suffix the remap matches on)
485
486
  */
@@ -500,7 +501,7 @@ export const normalizeDiagnosticPaths = (diagnostics, projectRoot) => {
500
501
  }
501
502
  else if (isAbsolutePosixPath(file)) {
502
503
  // Outside the root. Relativize rather than dropping the leading slash,
503
- // which produced a string that reads as root-relative but resolves
504
+ // which would produce a string that reads as root-relative but resolves
504
505
  // somewhere else entirely. A path already relative is left alone —
505
506
  // `relative` would resolve it against `cwd`.
506
507
  file = toPosixPath(relative(root, file));
@@ -745,22 +746,27 @@ const rewriteTypeText = (value, rewrite) => {
745
746
  *
746
747
  * The checker prints a module object as `typeof import("<absolute path>")`,
747
748
  * which reaches output through every checker-printed field — `typeSignature`
748
- * on declarations and members, `returnType`, and the `text`/`name` of a
749
- * `TypeJson` node. Left alone it makes output machine-dependent (two checkouts
749
+ * on declarations and members, `returnType`, and the `text` of a
750
+ * `TypeJson` node (a module object is a terminal `other` node, never a
751
+ * `reference`). Left alone it makes output machine-dependent (two checkouts
750
752
  * of the same source produce different bytes), publishes local filesystem
751
753
  * paths on any site that renders `typeSignature`, and exposes the svelte2tsx
752
- * virtual suffix that `stripVirtualSuffix` exists to hide.
754
+ * virtual suffix that `stripVirtualSuffix` exists to hide. A written
755
+ * `import('./x').T` annotation resolves to the type's own name and never
756
+ * carries a path.
753
757
  *
754
758
  * A path that resolves to a module in this output is rewritten to that
755
759
  * module's `ModuleJson.path`, so the string doubles as a lookup key: a
756
760
  * consumer linkifies with `modules.find((m) => m.path === s)` and reads a miss
757
761
  * as "not a module here." See `createModulePathNormalizer` for the remaining
758
- * tiers.
762
+ * tiers. The string's shape doesn't distinguish them (`sub/nested.ts` and
763
+ * `pkg/index.d.ts` look alike) — the lookup does, which keeps `sourceRoot` out
764
+ * of the output envelope.
759
765
  *
760
766
  * Runs as a whole-output pass rather than at the ~20 `typeToString` /
761
767
  * `signatureToString` call sites, so a new printing site can't miss it.
762
768
  *
763
- * @mutates modules — rewrites printed type text on declarations and members
769
+ * @mutates modules - rewrites printed type text on declarations and members
764
770
  */
765
771
  export const normalizeModulePathsInTypes = (modules, options, program) => {
766
772
  const rewrite = createModulePathNormalizer(modules, options, program);
package/dist/analyze.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * One-shot analysis wrappers — `analyze` and `analyzeFromFiles`.
3
3
  *
4
- * Both wrap a single-use `AnalysisSession`: `createSession → setFiles → query
5
- * → dispose`. Incremental consumers (Vite plugin, LSP) should use
4
+ * Both wrap a single-use `AnalysisSession`: `createAnalysisSession → setFiles →
5
+ * query → dispose`. Incremental consumers (Vite plugin, LSP) should use
6
6
  * `createAnalysisSession` directly so parsed ASTs and svelte2tsx output
7
7
  * survive between calls.
8
8
  *
@@ -82,37 +82,16 @@ export interface AnalyzeFromFilesOptions {
82
82
  /** Optional logger for status and diagnostic messages. */
83
83
  log?: AnalysisLog;
84
84
  /**
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`).
88
- *
89
- * Filters glob-based discovery. Providing `include` under the default
90
- * `discovery: 'auto'` collapses the chain to glob immediately; combining
91
- * with `discovery: 'exports'` throws.
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
- *
101
- * When omitted, the glob fallback derives an include from
102
- * `sourceOptions.sourcePaths` via `deriveIncludePatterns`, so custom
103
- * `sourcePaths` (e.g., `['packages/foo']`) survive the fallback instead of
104
- * silently defaulting to `src/lib`.
85
+ * Glob patterns to include, relative to `projectRoot`. Collapses
86
+ * `discovery: 'auto'` to glob (combining with `'exports'` throws), and each
87
+ * pattern's static base widens `sourceOptions.sourcePaths` so the matched
88
+ * files emit modules (see `createSourceOptionsWithInclude`).
105
89
  */
106
90
  include?: Array<string>;
107
91
  /**
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.
92
+ * Glob patterns to exclude — supersedes `sourceOptions.exclude` whole (no
93
+ * merge; the callback form still receives the built-in defaults). An array
94
+ * replaces the defaults, a callback extends them — see `ExcludeOption`.
116
95
  */
117
96
  exclude?: ExcludeOption;
118
97
  /**
@@ -156,7 +135,9 @@ export interface AnalyzeFromFilesOptions {
156
135
  * 3. **Analysis** — `session.query()`
157
136
  *
158
137
  * @returns analyzed modules + concatenated ingest, discovery, and query diagnostics
159
- * @throws Error if `sourceOptions` validation fails or `tsconfig.json` is missing
138
+ * @throws Error on invalid or contradictory options, a missing `tsconfig.json`,
139
+ * failed strict `'exports'` discovery, or a collision under
140
+ * `onDuplicates: 'throw'`
160
141
  */
161
142
  export declare const analyzeFromFiles: (options: AnalyzeFromFilesOptions) => Promise<AnalyzeResultJson>;
162
143
  //# sourceMappingURL=analyze.d.ts.map
@@ -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,0EAA0E;IAC1E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB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,eAAO,MAAM,gBAAgB,GAC5B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,iBAAiB,CAwH3B,CAAC"}
package/dist/analyze.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * One-shot analysis wrappers — `analyze` and `analyzeFromFiles`.
3
3
  *
4
- * Both wrap a single-use `AnalysisSession`: `createSession → setFiles → query
5
- * → dispose`. Incremental consumers (Vite plugin, LSP) should use
4
+ * Both wrap a single-use `AnalysisSession`: `createAnalysisSession → setFiles →
5
+ * query → dispose`. Incremental consumers (Vite plugin, LSP) should use
6
6
  * `createAnalysisSession` directly so parsed ASTs and svelte2tsx output
7
7
  * survive between calls.
8
8
  *
@@ -70,7 +70,9 @@ export const analyze = async (options) => {
70
70
  * 3. **Analysis** — `session.query()`
71
71
  *
72
72
  * @returns analyzed modules + concatenated ingest, discovery, and query diagnostics
73
- * @throws Error if `sourceOptions` validation fails or `tsconfig.json` is missing
73
+ * @throws Error on invalid or contradictory options, a missing `tsconfig.json`,
74
+ * failed strict `'exports'` discovery, or a collision under
75
+ * `onDuplicates: 'throw'`
74
76
  */
75
77
  export const analyzeFromFiles = async (options) => {
76
78
  const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir } = options;
package/dist/cli.d.ts CHANGED
@@ -36,12 +36,8 @@ export interface CliOptions {
36
36
  * File patterns to exclude (undefined = use defaults — test/spec files and
37
37
  * `internal/` directories).
38
38
  *
39
- * When provided, **fully replaces** the defaults — no array merge. Passing
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.
39
+ * When provided, **fully replaces** the defaults (the API's callback form
40
+ * has no CLI equivalent) — see `ExcludeOption`.
45
41
  */
46
42
  exclude?: Array<string>;
47
43
  /** Output file path (undefined = stdout). */
@@ -105,7 +101,8 @@ export interface CliOptions {
105
101
  * Run the CLI with the given arguments.
106
102
  *
107
103
  * @param argv - command line arguments (defaults to `process.argv`)
108
- * @returns exit code: 0 for success, 1 if errors in diagnostics, 2 for CLI errors
104
+ * @returns exit code: 0 for success, 1 if errors in diagnostics, 2 for CLI errors or any
105
+ * thrown analysis error (including an `--on-duplicates throw` collision)
109
106
  */
110
107
  export declare const runCli: (argv?: Array<string>) => Promise<number>;
111
108
  export {};
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;AAUH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUhD,4CAA4C;AAC5C,QAAA,MAAM,oBAAoB,4BAA6B,CAAC;AACxD,KAAK,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,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;;;;;;;OAO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,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,CA6N/E,CAAC"}
package/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ import picomatch from 'picomatch';
24
24
  import { analyzeFromFiles } from './analyze.js';
25
25
  import { DEFAULT_SOURCE_OPTIONS } from './source-config.js';
26
26
  import { hasErrors } from './diagnostics.js';
27
- import { to_error_message } from './error.js';
27
+ import { toErrorMessage } from './error.js';
28
28
  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];
@@ -38,7 +38,8 @@ const isDiscoveryFlag = (value) => DISCOVERY_VALUES.includes(value);
38
38
  * Run the CLI with the given arguments.
39
39
  *
40
40
  * @param argv - command line arguments (defaults to `process.argv`)
41
- * @returns exit code: 0 for success, 1 if errors in diagnostics, 2 for CLI errors
41
+ * @returns exit code: 0 for success, 1 if errors in diagnostics, 2 for CLI errors or any
42
+ * thrown analysis error (including an `--on-duplicates throw` collision)
42
43
  */
43
44
  export const runCli = async (argv = process.argv) => {
44
45
  // Track exit code from action (commander actions don't return values)
@@ -197,7 +198,7 @@ Examples:
197
198
  catch (error) {
198
199
  // Friendly one-line error for users; full stack only on DEBUG=1
199
200
  // so CI logs and bug reports can still capture it on demand.
200
- const message = to_error_message(error);
201
+ const message = toErrorMessage(error);
201
202
  console.error(`error: ${message}`);
202
203
  if (process.env.DEBUG) {
203
204
  console.error(error);