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
@@ -4,11 +4,14 @@
4
4
  *
5
5
  * - `MAX_FILE_CONCURRENCY` — parallel `readFile` cap. Bounds FD pressure so
6
6
  * projects with thousands of source files don't trip `EMFILE` against the
7
- * typical 1024-FD ulimit. Used by `files.globFiles` and `exports.discoverFromExports`.
7
+ * typical 1024-FD ulimit. Used by `files.globFiles`, `exports.discoverFromExports`,
8
+ * and the session's context-closure reads.
8
9
  * - `MAX_RESOLVE_CONCURRENCY` — parallel resolver-call cap for session phase 2.
9
10
  * Async resolvers (Vite/Rollup `resolveId`, user-supplied) get backpressure
10
11
  * instead of a 20k+ task fan-out at once. Sync resolvers (TS default,
11
- * no-deps stub) settle in microtasks regardless of the bound.
12
+ * no-deps stub) settle in microtasks regardless of the bound. Also bounds
13
+ * `healUnresolvedEdges` retries.
14
+ * - `mapConcurrent` — order-preserving, fail-fast worker pool applying either cap.
12
15
  *
13
16
  * Same numerical value today, separately named so a future tuning pass can
14
17
  * move them independently (FD pressure and resolver backpressure are unrelated
@@ -34,5 +37,5 @@ export declare const MAX_RESOLVE_CONCURRENCY = 100;
34
37
  * @param fn - mapping function (receives item and index)
35
38
  * @returns array of results in input order
36
39
  */
37
- export declare const map_concurrent: <T, R>(items: ReadonlyArray<T>, concurrency: number, fn: (item: T, index: number) => Promise<R>) => Promise<Array<R>>;
40
+ export declare const mapConcurrent: <T, R>(items: ReadonlyArray<T>, concurrency: number, fn: (item: T, index: number) => Promise<R>) => Promise<Array<R>>;
38
41
  //# sourceMappingURL=concurrency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"concurrency.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,GAAU,CAAC,EAAE,CAAC,EACxC,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,aAAa,MAAM,EACnB,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KACxC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAkBlB,CAAC"}
1
+ {"version":3,"file":"concurrency.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/concurrency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa,GAAU,CAAC,EAAE,CAAC,EACvC,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,aAAa,MAAM,EACnB,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,KACxC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAkBlB,CAAC"}
@@ -4,11 +4,14 @@
4
4
  *
5
5
  * - `MAX_FILE_CONCURRENCY` — parallel `readFile` cap. Bounds FD pressure so
6
6
  * projects with thousands of source files don't trip `EMFILE` against the
7
- * typical 1024-FD ulimit. Used by `files.globFiles` and `exports.discoverFromExports`.
7
+ * typical 1024-FD ulimit. Used by `files.globFiles`, `exports.discoverFromExports`,
8
+ * and the session's context-closure reads.
8
9
  * - `MAX_RESOLVE_CONCURRENCY` — parallel resolver-call cap for session phase 2.
9
10
  * Async resolvers (Vite/Rollup `resolveId`, user-supplied) get backpressure
10
11
  * instead of a 20k+ task fan-out at once. Sync resolvers (TS default,
11
- * no-deps stub) settle in microtasks regardless of the bound.
12
+ * no-deps stub) settle in microtasks regardless of the bound. Also bounds
13
+ * `healUnresolvedEdges` retries.
14
+ * - `mapConcurrent` — order-preserving, fail-fast worker pool applying either cap.
12
15
  *
13
16
  * Same numerical value today, separately named so a future tuning pass can
14
17
  * move them independently (FD pressure and resolver backpressure are unrelated
@@ -34,7 +37,7 @@ export const MAX_RESOLVE_CONCURRENCY = 100;
34
37
  * @param fn - mapping function (receives item and index)
35
38
  * @returns array of results in input order
36
39
  */
37
- export const map_concurrent = async (items, concurrency, fn) => {
40
+ export const mapConcurrent = async (items, concurrency, fn) => {
38
41
  const results = new Array(items.length);
39
42
  let next = 0;
40
43
  let failed = false;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Import resolver primitives for the analysis session.
3
3
  *
4
- * Exposes the `ImportResolver` token contract (`{resolve, identity}`) plus
4
+ * Exposes the `ImportResolver` token contract (`{resolve, identity, invalidate?}`) plus
5
5
  * building blocks the session uses inside its three-phase setFiles pipeline:
6
6
  *
7
7
  * - `ensureLexerReady` — one-time wasm init for `es-module-lexer`. Phase 1 is
@@ -18,8 +18,9 @@
18
18
  * wraps a bare function in an `ImportResolver`, synthesizing a throwaway
19
19
  * identity unless a stable one is passed.
20
20
  *
21
- * @internal — subpath-importable for power users who want to drive resolution
22
- * outside the session, but not part of the stable barrel surface.
21
+ * `ImportResolver`, `ResolveImport`, `ResolveImportFn`, and
22
+ * `normalizeResolveImport` are on the main barrel; the lexing and
23
+ * default-resolver building blocks are subpath-only and not stable API.
23
24
  *
24
25
  * @see `session.ts` for the three-phase ingestion pipeline that consumes these
25
26
  * @see `loadTsconfig` in `typescript-program.ts` for producing the merged
@@ -122,6 +123,8 @@ export declare const ensureLexerReady: () => Promise<void>;
122
123
  * content, not the raw `.svelte` source (which isn't lex-able as JS/TS).
123
124
  *
124
125
  * Dynamic imports (`import(specifier)` with non-literal arg) are omitted.
126
+ * `import type` and inline `type` specifiers are kept, but the lexer drops
127
+ * type-only re-exports (`export type {...} from`, `export type * from`).
125
128
  *
126
129
  * @throws Error if lexing fails (malformed source). Callers should catch and
127
130
  * emit `import_parse_failed`.
@@ -1 +1 @@
1
- {"version":3,"file":"dep-resolver.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dep-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,CAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,KACZ,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,C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O,MAAM,cAAc,EAAE,cAG5B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Import resolver primitives for the analysis session.
3
3
  *
4
- * Exposes the `ImportResolver` token contract (`{resolve, identity}`) plus
4
+ * Exposes the `ImportResolver` token contract (`{resolve, identity, invalidate?}`) plus
5
5
  * building blocks the session uses inside its three-phase setFiles pipeline:
6
6
  *
7
7
  * - `ensureLexerReady` — one-time wasm init for `es-module-lexer`. Phase 1 is
@@ -18,8 +18,9 @@
18
18
  * wraps a bare function in an `ImportResolver`, synthesizing a throwaway
19
19
  * identity unless a stable one is passed.
20
20
  *
21
- * @internal — subpath-importable for power users who want to drive resolution
22
- * outside the session, but not part of the stable barrel surface.
21
+ * `ImportResolver`, `ResolveImport`, `ResolveImportFn`, and
22
+ * `normalizeResolveImport` are on the main barrel; the lexing and
23
+ * default-resolver building blocks are subpath-only and not stable API.
23
24
  *
24
25
  * @see `session.ts` for the three-phase ingestion pipeline that consumes these
25
26
  * @see `loadTsconfig` in `typescript-program.ts` for producing the merged
@@ -60,6 +61,8 @@ export const ensureLexerReady = async () => {
60
61
  * content, not the raw `.svelte` source (which isn't lex-able as JS/TS).
61
62
  *
62
63
  * Dynamic imports (`import(specifier)` with non-literal arg) are omitted.
64
+ * `import type` and inline `type` specifiers are kept, but the lexer drops
65
+ * type-only re-exports (`export type {...} from`, `export type * from`).
63
66
  *
64
67
  * @throws Error if lexing fails (malformed source). Callers should catch and
65
68
  * emit `import_parse_failed`.
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Diagnostic collection for source analysis.
3
3
  *
4
- * Provides structured error/warning collection during TypeScript and Svelte
5
- * analysis, replacing silent catch blocks with actionable diagnostics.
4
+ * Structured error/warning collection during TypeScript and Svelte analysis.
6
5
  *
7
6
  * ## Error Handling Contract
8
7
  *
@@ -14,11 +13,12 @@
14
13
  * construction failures, import lex / resolver failures, and duplicate
15
14
  * declarations.
16
15
  *
17
- * A small set of conditions still throws from public entry points — these are
18
- * setup-level, not per-file: missing `tsconfig.json` (`loadTsconfig`), Svelte
19
- * <5 detected (`transformSvelteSource`), or strict `discovery: 'exports'`
20
- * mode with no resolvable exports (`discoverSourceFiles`). Wrap the top-level
21
- * `analyze` / `analyzeFromFiles` call if you want to handle these.
16
+ * A few conditions still throw from the public entry points. These are
17
+ * configuration and environment errors, not per-file failures: invalid or
18
+ * contradictory options (see the `@throws` on `createSourceOptions` and
19
+ * `discoverSourceFiles`), a missing `tsconfig.json`, Svelte <5, and failed
20
+ * strict `'exports'` discovery. `onDuplicates: 'throw'` also throws, by
21
+ * request. Wrap the top-level call to handle these.
22
22
  *
23
23
  * ## Usage Pattern
24
24
  *
@@ -55,7 +55,8 @@
55
55
  * (`setFile`/`setFiles` at ingest, `query` at analysis) normalize paths from
56
56
  * all sources (extraction, discovery, dependency resolution) before
57
57
  * returning. Consumers that need an absolute path can rejoin with
58
- * `projectRoot`.
58
+ * `projectRoot` — a file outside the root takes the `../` form, so the rejoin
59
+ * holds for it too.
59
60
  *
60
61
  * It names a *file*, not a module: `ModuleJson.path` is relative to
61
62
  * `sourceRoot`, so `file` is not a lookup key into `modules`.
@@ -76,6 +77,9 @@ export declare const DiagnosticSeverity: z.ZodEnum<{
76
77
  export type DiagnosticSeverity = z.infer<typeof DiagnosticSeverity>;
77
78
  /**
78
79
  * Discriminant for `Diagnostic` variant types.
80
+ *
81
+ * Severity is a stable per-kind property: `transform_failed` and
82
+ * `module_unreadable` are always `error`, every other kind always `warning`.
79
83
  */
80
84
  export declare const DiagnosticKind: z.ZodEnum<{
81
85
  type_extraction_failed: "type_extraction_failed";
@@ -840,6 +844,8 @@ export type TransformFailedDiagnostic = z.infer<typeof TransformFailedDiagnostic
840
844
  * "external package" case); resolvers that *throw* surface here so consumers
841
845
  * can fix the resolver. Recoverable — the session treats the throw as `null`
842
846
  * and continues, so analysis still runs but with a missing dependency edge.
847
+ * Durable on the entry until a later `setFiles` that adds paths resolves the
848
+ * specifier, which retires the diagnostic and adds the edge.
843
849
  *
844
850
  * Emitted at ingest time by the session's resolve phase.
845
851
  */
@@ -945,7 +951,10 @@ export declare const AliasLostDiagnostic: z.ZodObject<{
945
951
  }, z.core.$strict>;
946
952
  export type AliasLostDiagnostic = z.infer<typeof AliasLostDiagnostic>;
947
953
  /**
948
- * Discriminated union of all diagnostic variants.
954
+ * Discriminated union of all diagnostic variants. Ingest-time kinds:
955
+ * `transform_failed`, `source_map_failed`, `import_parse_failed`, and
956
+ * `resolver_failed`; discovery-time: `module_unreadable`; every other kind is
957
+ * query-time.
949
958
  */
950
959
  export declare const Diagnostic: z.ZodDiscriminatedUnion<[
951
960
  typeof TypeExtractionDiagnostic,
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;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;;GAEG;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,2BAA2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M,gBAAgB,GAAI,YAAY,UAAU,KAAG,MAMzD,CAAC"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Diagnostic collection for source analysis.
3
3
  *
4
- * Provides structured error/warning collection during TypeScript and Svelte
5
- * analysis, replacing silent catch blocks with actionable diagnostics.
4
+ * Structured error/warning collection during TypeScript and Svelte analysis.
6
5
  *
7
6
  * ## Error Handling Contract
8
7
  *
@@ -14,11 +13,12 @@
14
13
  * construction failures, import lex / resolver failures, and duplicate
15
14
  * declarations.
16
15
  *
17
- * A small set of conditions still throws from public entry points — these are
18
- * setup-level, not per-file: missing `tsconfig.json` (`loadTsconfig`), Svelte
19
- * <5 detected (`transformSvelteSource`), or strict `discovery: 'exports'`
20
- * mode with no resolvable exports (`discoverSourceFiles`). Wrap the top-level
21
- * `analyze` / `analyzeFromFiles` call if you want to handle these.
16
+ * A few conditions still throw from the public entry points. These are
17
+ * configuration and environment errors, not per-file failures: invalid or
18
+ * contradictory options (see the `@throws` on `createSourceOptions` and
19
+ * `discoverSourceFiles`), a missing `tsconfig.json`, Svelte <5, and failed
20
+ * strict `'exports'` discovery. `onDuplicates: 'throw'` also throws, by
21
+ * request. Wrap the top-level call to handle these.
22
22
  *
23
23
  * ## Usage Pattern
24
24
  *
@@ -55,7 +55,8 @@
55
55
  * (`setFile`/`setFiles` at ingest, `query` at analysis) normalize paths from
56
56
  * all sources (extraction, discovery, dependency resolution) before
57
57
  * returning. Consumers that need an absolute path can rejoin with
58
- * `projectRoot`.
58
+ * `projectRoot` — a file outside the root takes the `../` form, so the rejoin
59
+ * holds for it too.
59
60
  *
60
61
  * It names a *file*, not a module: `ModuleJson.path` is relative to
61
62
  * `sourceRoot`, so `file` is not a lookup key into `modules`.
@@ -74,6 +75,9 @@ export const DiagnosticSeverity = z.enum(['error', 'warning']);
74
75
  // Kind
75
76
  /**
76
77
  * Discriminant for `Diagnostic` variant types.
78
+ *
79
+ * Severity is a stable per-kind property: `transform_failed` and
80
+ * `module_unreadable` are always `error`, every other kind always `warning`.
77
81
  */
78
82
  export const DiagnosticKind = z.enum([
79
83
  'type_extraction_failed',
@@ -370,6 +374,8 @@ export const TransformFailedDiagnostic = z.strictObject({
370
374
  * "external package" case); resolvers that *throw* surface here so consumers
371
375
  * can fix the resolver. Recoverable — the session treats the throw as `null`
372
376
  * and continues, so analysis still runs but with a missing dependency edge.
377
+ * Durable on the entry until a later `setFiles` that adds paths resolves the
378
+ * specifier, which retires the diagnostic and adds the edge.
373
379
  *
374
380
  * Emitted at ingest time by the session's resolve phase.
375
381
  */
@@ -403,8 +409,13 @@ export const AliasLostDiagnostic = z.strictObject({
403
409
  aliasName: z.string()
404
410
  });
405
411
  /**
406
- * Discriminated union of all diagnostic variants.
412
+ * Discriminated union of all diagnostic variants. Ingest-time kinds:
413
+ * `transform_failed`, `source_map_failed`, `import_parse_failed`, and
414
+ * `resolver_failed`; discovery-time: `module_unreadable`; every other kind is
415
+ * query-time.
407
416
  */
417
+ // the explicit `ZodDiscriminatedUnion` annotation means a new variant must
418
+ // land in both the type-parameter tuple and the runtime array
408
419
  export const Diagnostic = z.discriminatedUnion('kind', [
409
420
  TypeExtractionDiagnostic,
410
421
  SignatureAnalysisDiagnostic,
@@ -24,11 +24,8 @@ import type { AnalysisLog } from './log.js';
24
24
  * always declare their public surface via `exports`)
25
25
  * - `'glob'` — skip `exports` entirely, use glob patterns
26
26
  *
27
- * Providing `include` patterns implies `'glob'` semantics regardless of mode
28
- * — when `discovery: 'auto'` and `include` is set, the auto fallback chain
29
- * collapses to glob immediately. Combining `discovery: 'exports'` with
30
- * `include` is a configuration error (the modes are contradictory) and
31
- * throws at discovery time.
27
+ * Under `'auto'`, `include` skips `exports` and goes straight to glob.
28
+ * Combining `'exports'` with `include` is a configuration error and throws.
32
29
  */
33
30
  export type Discovery = 'auto' | 'exports' | 'glob';
34
31
  /** Options for `discoverSourceFiles`. */
@@ -57,13 +54,18 @@ export interface DiscoverSourceFilesOptions {
57
54
  * `sourceOptions.sourcePaths` via `deriveIncludePatterns`, so custom
58
55
  * `sourcePaths` (e.g., `['packages/foo']`) discover files instead of
59
56
  * silently defaulting to `src/lib`.
57
+ *
58
+ * Discovery alone doesn't widen the source scope: files outside
59
+ * `sourcePaths` are dropped at query time unless the options came from
60
+ * `createSourceOptionsWithInclude` (as `analyzeFromFiles` and the Vite
61
+ * plugin do).
60
62
  */
61
63
  include?: Array<string>;
62
64
  /**
63
65
  * Discovery strategy.
64
66
  *
65
67
  * @default 'auto'
66
- * @see {@link Discovery} for semantics of each variant
68
+ * @see `Discovery` for semantics of each variant
67
69
  */
68
70
  discovery?: Discovery;
69
71
  /**
@@ -91,24 +93,17 @@ export interface DiscoverSourceFilesResult {
91
93
  * consumers can call it directly when they want the discovered file list
92
94
  * without running full analysis.
93
95
  *
94
- * Strategy is selected by `discovery`:
95
- * - `'auto'` (default) — try `exports` first, fall back to glob.
96
- * - `'exports'` — `exports` only; **throws** if `exports` is missing or
97
- * resolves to no source files. Combining with `include` is a configuration
98
- * error and also throws.
99
- * - `'glob'` — glob only; `include` parameterizes the search.
100
- *
101
- * Exclusion globs come from `sourceOptions.exclude` (the single source of
102
- * truth, also applied at analysis time by `isSource()`). Beneath it, the
103
- * always-on baseline (`node_modules` + dot-directories, see
104
- * `hasBaselineExcludedSegment` in `source-config.ts`) applies at both stages
105
- * and is not affected by `exclude` overrides.
96
+ * Strategy is selected by `discovery` (see `Discovery`). Exclusion globs come
97
+ * from `sourceOptions.exclude`, also applied at analysis time by `isSource()`;
98
+ * the always-on baseline (`hasBaselineExcludedSegment`) applies beneath it at
99
+ * both stages.
106
100
  *
107
101
  * @param options - discovery configuration
108
102
  * @returns discovered files (content loaded) and any diagnostics from the exports step
109
- * @throws Error in strict `'exports'` mode when `exports` is missing or
110
- * resolves to no source files, or when `include` is combined with
111
- * `discovery: 'exports'`.
103
+ * @throws Error when `include` is combined with `discovery: 'exports'`, when an
104
+ * absolute `include` pattern falls outside `projectRoot`, or in strict
105
+ * `'exports'` mode when `exports` is missing, resolves to no source files, or
106
+ * can't map a multi-`sourcePaths` layout with no common prefix
112
107
  *
113
108
  * @example
114
109
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;;OASG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,yBAAyB;IACzC,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC7B,qFAAqF;IACrF,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,0BAA0B,KACjC,OAAO,CAAC,yBAAyB,CAmGnC,CAAC"}
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;;OASG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,yBAAyB;IACzC,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC7B,qFAAqF;IACrF,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,0BAA0B,KACjC,OAAO,CAAC,yBAAyB,CAkGnC,CAAC"}
package/dist/discovery.js CHANGED
@@ -20,24 +20,17 @@ import { discoverFromExports } from './exports.js';
20
20
  * consumers can call it directly when they want the discovered file list
21
21
  * without running full analysis.
22
22
  *
23
- * Strategy is selected by `discovery`:
24
- * - `'auto'` (default) — try `exports` first, fall back to glob.
25
- * - `'exports'` — `exports` only; **throws** if `exports` is missing or
26
- * resolves to no source files. Combining with `include` is a configuration
27
- * error and also throws.
28
- * - `'glob'` — glob only; `include` parameterizes the search.
29
- *
30
- * Exclusion globs come from `sourceOptions.exclude` (the single source of
31
- * truth, also applied at analysis time by `isSource()`). Beneath it, the
32
- * always-on baseline (`node_modules` + dot-directories, see
33
- * `hasBaselineExcludedSegment` in `source-config.ts`) applies at both stages
34
- * and is not affected by `exclude` overrides.
23
+ * Strategy is selected by `discovery` (see `Discovery`). Exclusion globs come
24
+ * from `sourceOptions.exclude`, also applied at analysis time by `isSource()`;
25
+ * the always-on baseline (`hasBaselineExcludedSegment`) applies beneath it at
26
+ * both stages.
35
27
  *
36
28
  * @param options - discovery configuration
37
29
  * @returns discovered files (content loaded) and any diagnostics from the exports step
38
- * @throws Error in strict `'exports'` mode when `exports` is missing or
39
- * resolves to no source files, or when `include` is combined with
40
- * `discovery: 'exports'`.
30
+ * @throws Error when `include` is combined with `discovery: 'exports'`, when an
31
+ * absolute `include` pattern falls outside `projectRoot`, or in strict
32
+ * `'exports'` mode when `exports` is missing, resolves to no source files, or
33
+ * can't map a multi-`sourcePaths` layout with no common prefix
41
34
  *
42
35
  * @example
43
36
  * ```ts
@@ -118,8 +111,7 @@ export const discoverSourceFiles = async (options) => {
118
111
  // Fall back to glob-based discovery (auto fallback or explicit glob mode).
119
112
  // Derive include from `sourceOptions.sourcePaths` when none is supplied so
120
113
  // custom `sourcePaths` (e.g. `['packages/foo']`) discover files instead of
121
- // silently defaulting to `src/lib`. Mirrors the CLI's prior local
122
- // derivation — single source of truth lives here now.
114
+ // silently defaulting to `src/lib`.
123
115
  if (!files) {
124
116
  files = await globFiles({
125
117
  projectRoot,
package/dist/error.d.ts CHANGED
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * Error-message normalization.
3
3
  *
4
- * `to_error_message` is the single primitive for coercing an unknown caught
4
+ * `toErrorMessage` is the single primitive for coercing an unknown caught
5
5
  * value to a human-readable string — `value.message` for an `Error`, otherwise
6
6
  * a caller-supplied fallback or `String(value)`. Used wherever a `catch (err)`
7
7
  * binding (typed `unknown`) feeds a diagnostic message, log line, or error
8
- * field, replacing the inline `err instanceof Error ? err.message : String(err)`
9
- * idiom.
8
+ * field.
10
9
  *
11
10
  * @module
12
11
  */
13
12
  /** Extract a human-readable message from an unknown thrown value. */
14
- export declare const to_error_message: (value: unknown, fallback?: string) => string;
13
+ export declare const toErrorMessage: (value: unknown, fallback?: string) => string;
15
14
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,WAAW,MAAM,KAAG,MACA,CAAC"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qEAAqE;AACrE,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,WAAW,MAAM,KAAG,MACE,CAAC"}
package/dist/error.js CHANGED
@@ -1,14 +1,13 @@
1
1
  /**
2
2
  * Error-message normalization.
3
3
  *
4
- * `to_error_message` is the single primitive for coercing an unknown caught
4
+ * `toErrorMessage` is the single primitive for coercing an unknown caught
5
5
  * value to a human-readable string — `value.message` for an `Error`, otherwise
6
6
  * a caller-supplied fallback or `String(value)`. Used wherever a `catch (err)`
7
7
  * binding (typed `unknown`) feeds a diagnostic message, log line, or error
8
- * field, replacing the inline `err instanceof Error ? err.message : String(err)`
9
- * idiom.
8
+ * field.
10
9
  *
11
10
  * @module
12
11
  */
13
12
  /** Extract a human-readable message from an unknown thrown value. */
14
- export const to_error_message = (value, fallback) => value instanceof Error ? value.message : (fallback ?? String(value));
13
+ export const toErrorMessage = (value, fallback) => value instanceof Error ? value.message : (fallback ?? String(value));
package/dist/exports.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * enabling zero-config file discovery without glob patterns.
6
6
  *
7
7
  * @see `source.ts` for `SourceFileInfo`
8
- * @see `analyze.ts` for `analyzeFromFiles` (primary consumer)
8
+ * @see `discovery.ts` for `discoverSourceFiles` (the consumer)
9
9
  *
10
10
  * @module
11
11
  */
@@ -59,12 +59,12 @@ export interface ParsedExports {
59
59
  entries: Array<ExportEntry>;
60
60
  /**
61
61
  * Specifiers (exact or wildcard patterns) whose export target resolves
62
- * nothing — a literal `null`, or a conditions object with no usable
63
- * target. Node's explicit-exclusion form: `"./internal/*": null` blocks
64
- * the subpaths a broader wildcard would otherwise expose. Discovery
65
- * honors these with Node's best-match semantics: a subpath whose
66
- * most-specific matching key is blocked is not exported, so its source
67
- * file is not discovered.
62
+ * nothing — a literal `null`, a conditions object with no usable target
63
+ * (all-null or empty), or a fallback array with no usable element. Node's
64
+ * explicit-exclusion form: `"./internal/*": null` blocks the subpaths a
65
+ * broader wildcard would otherwise expose. Discovery honors these with
66
+ * Node's best-match semantics: a subpath whose most-specific matching key
67
+ * is blocked is not exported, so its source file is not discovered.
68
68
  *
69
69
  * Interpret via `createBlockedSpecifierChecker` — a naive membership
70
70
  * check (`blocked.includes(specifier)`) is wrong for wildcard keys and
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQnD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,2GAA2G;IAC3G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW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Q,aAAa,KACnB,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,IA+BrC,CAAC;AAIF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC3B,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAC7C,MAAM,GAAG,IAwCX,CAAC;AAqCF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,sBAAsB,CAgEhC,CAAC"}
package/dist/exports.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * enabling zero-config file discovery without glob patterns.
6
6
  *
7
7
  * @see `source.ts` for `SourceFileInfo`
8
- * @see `analyze.ts` for `analyzeFromFiles` (primary consumer)
8
+ * @see `discovery.ts` for `discoverSourceFiles` (the consumer)
9
9
  *
10
10
  * @module
11
11
  */
@@ -13,9 +13,10 @@ import { readFile, access } from 'node:fs/promises';
13
13
  import { join, relative, resolve } from 'node:path';
14
14
  import picomatch from 'picomatch';
15
15
  import { glob } from 'tinyglobby';
16
- import { to_error_message } from './error.js';
16
+ import { toErrorMessage } from './error.js';
17
17
  import { toPosixPath } from './paths.js';
18
- import { MAX_FILE_CONCURRENCY, map_concurrent } from './concurrency.js';
18
+ import { compareStrings } from './postprocess.js';
19
+ import { MAX_FILE_CONCURRENCY, mapConcurrent } from './concurrency.js';
19
20
  import { baselineExcludesForBase, hasBaselineExcludedSegment } from './source-config.js';
20
21
  // Condition priority
21
22
  /** Priority order for selecting the condition to use for source mapping. */
@@ -315,8 +316,8 @@ export const discoverFromExports = async (options) => {
315
316
  // Load file contents with bounded concurrency to keep FD pressure under
316
317
  // the typical ulimit on large projects. See `concurrency.ts`.
317
318
  const diagnostics = [];
318
- const absPaths = Array.from(discovered.keys());
319
- const results = await map_concurrent(absPaths, MAX_FILE_CONCURRENCY, async (absPath) => {
319
+ const absPaths = Array.from(discovered.keys()).sort(compareStrings);
320
+ const results = await mapConcurrent(absPaths, MAX_FILE_CONCURRENCY, async (absPath) => {
320
321
  try {
321
322
  const content = await readFile(absPath, 'utf-8');
322
323
  return { id: absPath, content };
@@ -326,7 +327,7 @@ export const discoverFromExports = async (options) => {
326
327
  kind: 'module_unreadable',
327
328
  severity: 'error',
328
329
  file: toPosixPath(relative(projectRoot, absPath)),
329
- message: `Could not read file discovered via package.json exports: ${to_error_message(err)}`
330
+ message: `Could not read file discovered via package.json exports: ${toErrorMessage(err)}`
330
331
  });
331
332
  return null;
332
333
  }
@@ -394,8 +395,7 @@ const resolveConcreteExport = async (distPath, condition, ctx) => {
394
395
  * project-root `**` that rakes in `node_modules`/`dist`. Empty `sourceDir`
395
396
  * only arises from the multi-`sourcePaths` no-common-prefix layout (which
396
397
  * `discoverSourceFiles` short-circuits before reaching here) or an explicit
397
- * `sourceRoot: ''`; leaving it non-recursive matches the prior behavior
398
- * without the explosion risk.
398
+ * `sourceRoot: ''`; it stays non-recursive, avoiding the explosion risk.
399
399
  *
400
400
  * Both fall through to matching same-directory files only.
401
401
  */
package/dist/files.d.ts CHANGED
@@ -4,9 +4,6 @@
4
4
  * Composable primitives for `analyzeFromFiles` / `discoverSourceFiles`. For
5
5
  * most use cases prefer those higher-level entry points.
6
6
  *
7
- * Build tools that want to drive resolve outside the session can construct an
8
- * `ImportResolver` directly and pass it to `createAnalysisSession`.
9
- *
10
7
  * @see `analyzeFromFiles` for the high-level disk-discovery wrapper
11
8
  * @see `discoverSourceFiles` for exports-first discovery with glob fallback
12
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAA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;;;;GAsBG;AACH,eAAO,MAAM,SAAS,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CA+CxF,CAAC"}
package/dist/files.js CHANGED
@@ -4,9 +4,6 @@
4
4
  * Composable primitives for `analyzeFromFiles` / `discoverSourceFiles`. For
5
5
  * most use cases prefer those higher-level entry points.
6
6
  *
7
- * Build tools that want to drive resolve outside the session can construct an
8
- * `ImportResolver` directly and pass it to `createAnalysisSession`.
9
- *
10
7
  * @see `analyzeFromFiles` for the high-level disk-discovery wrapper
11
8
  * @see `discoverSourceFiles` for exports-first discovery with glob fallback
12
9
  *
@@ -16,7 +13,8 @@ import { readFile } from 'node:fs/promises';
16
13
  import { resolve, isAbsolute } from 'node:path';
17
14
  import { glob } from 'tinyglobby';
18
15
  import { toPosixPath } from './paths.js';
19
- import { MAX_FILE_CONCURRENCY, map_concurrent } from './concurrency.js';
16
+ import { compareStrings } from './postprocess.js';
17
+ import { MAX_FILE_CONCURRENCY, mapConcurrent } from './concurrency.js';
20
18
  import { baselineExcludesForBase, includePatternBase } from './source-config.js';
21
19
  /**
22
20
  * Load a single source file from disk.
@@ -127,9 +125,11 @@ export const globFiles = async (options) => {
127
125
  }
128
126
  }
129
127
  }
128
+ // the crawl's order varies run to run; sort so logs and diagnostics are stable
129
+ filePaths.sort(compareStrings);
130
130
  // Bounded concurrency to keep FD pressure under the typical ulimit on
131
131
  // large projects. See `concurrency.ts`.
132
- return map_concurrent(filePaths, MAX_FILE_CONCURRENCY, async (id) => {
132
+ return mapConcurrent(filePaths, MAX_FILE_CONCURRENCY, async (id) => {
133
133
  const content = await readFile(id, 'utf-8');
134
134
  return { id: toPosixPath(id), content };
135
135
  });
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ export { getDefaultAnalyzer } from './source.js';
23
23
  export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
24
24
  // Post-processing
25
25
  export { findDuplicates, mergeReExports, resolveComponentAliases, resolveExportSurface } from './postprocess.js';
26
- // File system constants
26
+ // File system helpers
27
27
  export { deriveIncludePatterns } from './files.js';
28
28
  // File discovery
29
29
  export { discoverSourceFiles } from './discovery.js';