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.
- package/README.md +16 -9
- package/dist/analyze-core.d.ts +55 -27
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +51 -45
- package/dist/analyze.d.ts +12 -31
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +5 -3
- package/dist/cli.d.ts +4 -7
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -3
- package/dist/concurrency.d.ts +6 -3
- package/dist/concurrency.d.ts.map +1 -1
- package/dist/concurrency.js +6 -3
- package/dist/dep-resolver.d.ts +6 -3
- package/dist/dep-resolver.d.ts.map +1 -1
- package/dist/dep-resolver.js +6 -3
- package/dist/diagnostics.d.ts +18 -9
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +20 -9
- package/dist/discovery.d.ts +16 -21
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +9 -17
- package/dist/error.d.ts +3 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +3 -4
- package/dist/exports.d.ts +7 -7
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +8 -8
- package/dist/files.d.ts +0 -3
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +5 -5
- package/dist/index.js +1 -1
- package/dist/postprocess.d.ts +13 -6
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/postprocess.js +13 -6
- package/dist/session.d.ts +36 -12
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +39 -24
- package/dist/source-config.d.ts +22 -19
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +14 -12
- package/dist/source.d.ts +17 -13
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +4 -7
- package/dist/svelte.d.ts +21 -4
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +48 -15
- package/dist/tsdoc.d.ts +4 -8
- package/dist/tsdoc.d.ts.map +1 -1
- package/dist/tsdoc.js +4 -8
- package/dist/types.d.ts +607 -171
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +71 -28
- package/dist/typescript-exports.d.ts +7 -7
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +15 -13
- package/dist/typescript-extract-class.d.ts +2 -1
- package/dist/typescript-extract-class.d.ts.map +1 -1
- package/dist/typescript-extract-class.js +7 -7
- package/dist/typescript-extract-function.js +3 -3
- package/dist/typescript-extract-shared.d.ts +32 -12
- package/dist/typescript-extract-shared.d.ts.map +1 -1
- package/dist/typescript-extract-shared.js +55 -34
- package/dist/typescript-extract-type-json.d.ts +11 -3
- package/dist/typescript-extract-type-json.d.ts.map +1 -1
- package/dist/typescript-extract-type-json.js +12 -9
- package/dist/typescript-extract-type-properties.js +3 -3
- package/dist/typescript-extract-type.js +7 -7
- package/dist/typescript-program.d.ts +23 -8
- package/dist/typescript-program.d.ts.map +1 -1
- package/dist/typescript-program.js +23 -14
- package/dist/vite.d.ts +12 -35
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +7 -6
- package/package.json +9 -29
- package/virtual-svelte-docinfo.d.ts +9 -7
package/dist/postprocess.d.ts
CHANGED
|
@@ -5,14 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 1. **Validation** — `findDuplicates` checks flat namespace constraints
|
|
7
7
|
* 2. **Transformation** — `mergeReExports` resolves re-export relationships,
|
|
8
|
+
* `resolveComponentAliases` fills component aliases from their canonicals,
|
|
8
9
|
* `computeDependents` builds bidirectional dependency graphs
|
|
9
|
-
* 3. **Output** — `sortModules` prepares deterministic output
|
|
10
|
+
* 3. **Output** — `sortModules` prepares deterministic output (`compareStrings`
|
|
11
|
+
* is the one comparator for all output ordering)
|
|
12
|
+
* 4. **Queries** — `resolveExportSurface` combines a module's declarations and
|
|
13
|
+
* re-export facts into its full export surface
|
|
10
14
|
*
|
|
11
15
|
* Every function here is pure — transformation passes return new arrays with
|
|
12
16
|
* structural sharing (unchanged objects flow through `===`-equal) and never
|
|
13
17
|
* mutate their input.
|
|
14
18
|
*
|
|
15
|
-
* @see `analyze.ts` for the
|
|
19
|
+
* @see `analyze-core.ts` for the phase-2 pipeline that runs these
|
|
16
20
|
*
|
|
17
21
|
* @module
|
|
18
22
|
*/
|
|
@@ -137,6 +141,9 @@ export declare const mergeReExports: (modules: Array<ModuleJson>) => Array<Modul
|
|
|
137
141
|
* are shared by reference, not cloned); everything else flows through
|
|
138
142
|
* `===`-equal.
|
|
139
143
|
*
|
|
144
|
+
* Doc-comment fields fill gaps only: local doc fields applied to the alias
|
|
145
|
+
* before phase 2 (from JSDoc on the re-export statement) stick.
|
|
146
|
+
*
|
|
140
147
|
* @param modules - the analyzed modules (parsed `ModuleJson`s)
|
|
141
148
|
* @param contextModules - canonical-lookup-only modules that never appear in
|
|
142
149
|
* output — gated component canonicals (the `internal/` convention) analyzed
|
|
@@ -150,10 +157,10 @@ export declare const resolveComponentAliases: (modules: Array<ModuleJson>, conte
|
|
|
150
157
|
/**
|
|
151
158
|
* Compute bidirectional dependencies from source files.
|
|
152
159
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
160
|
+
* If file A has file B in its `dependencies`, file B gets file A in its
|
|
161
|
+
* `dependents`. Dependents are derived solely from the forward `dependencies`
|
|
162
|
+
* edges within `files` (`SourceFileInfo` carries no `dependents` field);
|
|
163
|
+
* edges to files outside the set are ignored.
|
|
157
164
|
*
|
|
158
165
|
* Returns new `SourceFileInfo` objects when computed dependents exist or when
|
|
159
166
|
* paths needed posixification; otherwise the original input objects flow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postprocess.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/postprocess.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"postprocess.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/postprocess.ts"],"names":[],"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AwD/D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,GAAG,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IACtD,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qFAAqF;IACrF,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,oFAAoF;IACpF,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACnC;;;OAGG;IACH,qBAAqB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC;;;OAGG;IACH,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,oBAAoB,GAChC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,MAAM,MAAM,KACV,aAAa,GAAG,IA+IlB,CAAC"}
|
package/dist/postprocess.js
CHANGED
|
@@ -5,14 +5,18 @@
|
|
|
5
5
|
*
|
|
6
6
|
* 1. **Validation** — `findDuplicates` checks flat namespace constraints
|
|
7
7
|
* 2. **Transformation** — `mergeReExports` resolves re-export relationships,
|
|
8
|
+
* `resolveComponentAliases` fills component aliases from their canonicals,
|
|
8
9
|
* `computeDependents` builds bidirectional dependency graphs
|
|
9
|
-
* 3. **Output** — `sortModules` prepares deterministic output
|
|
10
|
+
* 3. **Output** — `sortModules` prepares deterministic output (`compareStrings`
|
|
11
|
+
* is the one comparator for all output ordering)
|
|
12
|
+
* 4. **Queries** — `resolveExportSurface` combines a module's declarations and
|
|
13
|
+
* re-export facts into its full export surface
|
|
10
14
|
*
|
|
11
15
|
* Every function here is pure — transformation passes return new arrays with
|
|
12
16
|
* structural sharing (unchanged objects flow through `===`-equal) and never
|
|
13
17
|
* mutate their input.
|
|
14
18
|
*
|
|
15
|
-
* @see `analyze.ts` for the
|
|
19
|
+
* @see `analyze-core.ts` for the phase-2 pipeline that runs these
|
|
16
20
|
*
|
|
17
21
|
* @module
|
|
18
22
|
*/
|
|
@@ -281,6 +285,9 @@ export const mergeReExports = (modules) => {
|
|
|
281
285
|
* are shared by reference, not cloned); everything else flows through
|
|
282
286
|
* `===`-equal.
|
|
283
287
|
*
|
|
288
|
+
* Doc-comment fields fill gaps only: local doc fields applied to the alias
|
|
289
|
+
* before phase 2 (from JSDoc on the re-export statement) stick.
|
|
290
|
+
*
|
|
284
291
|
* @param modules - the analyzed modules (parsed `ModuleJson`s)
|
|
285
292
|
* @param contextModules - canonical-lookup-only modules that never appear in
|
|
286
293
|
* output — gated component canonicals (the `internal/` convention) analyzed
|
|
@@ -356,10 +363,10 @@ export const resolveComponentAliases = (modules, contextModules = []) => {
|
|
|
356
363
|
/**
|
|
357
364
|
* Compute bidirectional dependencies from source files.
|
|
358
365
|
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
366
|
+
* If file A has file B in its `dependencies`, file B gets file A in its
|
|
367
|
+
* `dependents`. Dependents are derived solely from the forward `dependencies`
|
|
368
|
+
* edges within `files` (`SourceFileInfo` carries no `dependents` field);
|
|
369
|
+
* edges to files outside the set are ignored.
|
|
363
370
|
*
|
|
364
371
|
* Returns new `SourceFileInfo` objects when computed dependents exist or when
|
|
365
372
|
* paths needed posixification; otherwise the original input objects flow
|
package/dist/session.d.ts
CHANGED
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
* when content matches AND the mode-specific cache key matches (resolver
|
|
10
10
|
* identity for lex+resolve, dependency-snapshot equality for pre-resolved).
|
|
11
11
|
* - `deleteFile` — drop owned entry, evict from LS.
|
|
12
|
-
* - `has` / `list` — owned-set introspection
|
|
13
|
-
*
|
|
14
|
-
* - `query` — sync analysis pass against the
|
|
15
|
-
* analysis-pass diagnostics only (ingest diagnostics
|
|
16
|
-
* `setFile`/`setFiles` returns
|
|
12
|
+
* - `has` / `list` — owned-set introspection, so consumers need no mirror
|
|
13
|
+
* cache of their own.
|
|
14
|
+
* - `query` — sync analysis pass against the source-gated owned set; returns
|
|
15
|
+
* analysis-pass diagnostics only (ingest diagnostics come from the
|
|
16
|
+
* `setFile`/`setFiles` returns, and cumulatively, context-closure ingest
|
|
17
|
+
* included, from `allIngestDiagnostics`).
|
|
18
|
+
* - `getProgram` — the LS-backed `ts.Program`, for consumers doing their own
|
|
19
|
+
* checker work.
|
|
17
20
|
* - `dispose` — release LS resources.
|
|
18
21
|
*
|
|
19
22
|
* The session owns a single `Map<id, OwnedEntry>` covering content, svelte
|
|
@@ -21,7 +24,8 @@
|
|
|
21
24
|
* or pre-resolved snapshot), and ingest-time diagnostics. svelte2tsx runs
|
|
22
25
|
* at most once per content change. Resolver work parallelizes across the
|
|
23
26
|
* batch in phase 2 of the three-phase setFiles pipeline; fully pre-resolved
|
|
24
|
-
* batches skip phase 2
|
|
27
|
+
* batches skip phase 2 and the default-resolver construction (see
|
|
28
|
+
* `AnalysisSessionOptions.contextClosure` for the exception).
|
|
25
29
|
* A batch that adds paths then retries the import specifiers earlier batches
|
|
26
30
|
* couldn't resolve, since the file that settles one is the dep rather than
|
|
27
31
|
* the importer (see `AnalysisSession` → Deferred resolutions).
|
|
@@ -41,10 +45,6 @@ import { type ModuleSourceOptions } from './source-config.js';
|
|
|
41
45
|
import { AnalyzeResultJson, type OnDuplicates } from './analyze-core.js';
|
|
42
46
|
/**
|
|
43
47
|
* Options for a per-file or per-batch resolver override.
|
|
44
|
-
*
|
|
45
|
-
* Identity is required (not optional) — silently coalescing missing identities
|
|
46
|
-
* to a function reference would destroy cache reuse when the same logical
|
|
47
|
-
* resolver is wrapped in fresh closures across calls.
|
|
48
48
|
*/
|
|
49
49
|
export interface SetFileOptions {
|
|
50
50
|
/**
|
|
@@ -166,6 +166,20 @@ export interface QueryOptions {
|
|
|
166
166
|
* in-root non-source dependency closure (e.g. `internal/` modules public
|
|
167
167
|
* files import) so those files are version-tracked rather than pinned at
|
|
168
168
|
* their first disk read.
|
|
169
|
+
*
|
|
170
|
+
* **Input order**: `query()` analyzes the owned set in `compareStrings` order
|
|
171
|
+
* of file ID, and the language-service host returns owned program roots in
|
|
172
|
+
* that order too, so the same files ingested in any order, in one batch or
|
|
173
|
+
* across many `setFile` calls, give identical output from a fresh session.
|
|
174
|
+
* Analysis order matters because TypeScript prints a union with no alias
|
|
175
|
+
* origin (`z.enum` members, literal unions) in type-creation order, which
|
|
176
|
+
* follows the order the checker first visits files; root order matters
|
|
177
|
+
* because it sets the merge order of `declare global`, module augmentations,
|
|
178
|
+
* and interface merging. Two limits remain, both from type-creation order:
|
|
179
|
+
* an edit to an unrelated file can still reorder such a union's members,
|
|
180
|
+
* since it can change which file first creates a member type, and checker
|
|
181
|
+
* work done through `getProgram()` before the first `query()` on a fresh
|
|
182
|
+
* program can reorder them in that query's output.
|
|
169
183
|
*/
|
|
170
184
|
export interface AnalysisSession {
|
|
171
185
|
/**
|
|
@@ -219,6 +233,10 @@ export interface AnalysisSession {
|
|
|
219
233
|
* retained reference goes stale after any `setFile` / `setFiles` /
|
|
220
234
|
* `deleteFile`; re-call after mutating. Subject to the session's
|
|
221
235
|
* concurrency contract above; invalid after `dispose()`.
|
|
236
|
+
*
|
|
237
|
+
* Checker work done before `query()` on a fresh program can reorder
|
|
238
|
+
* origin-less unions in that query's output (see "Input order" above);
|
|
239
|
+
* call `query()` first.
|
|
222
240
|
*/
|
|
223
241
|
getProgram(): ts.Program;
|
|
224
242
|
/**
|
|
@@ -295,6 +313,11 @@ export interface AnalysisSessionOptions extends Omit<AnalysisLanguageServiceOpti
|
|
|
295
313
|
* the Vite plugin, watched) for the session's lifetime, even when no
|
|
296
314
|
* importer remains.
|
|
297
315
|
*
|
|
316
|
+
* A context file created after its importer's last ingest becomes owned on
|
|
317
|
+
* the importer's next change only if its specifier re-resolves — with the
|
|
318
|
+
* default resolver a cached miss sticks until owned-set membership changes
|
|
319
|
+
* (the Vite dev resolver doesn't cache).
|
|
320
|
+
*
|
|
298
321
|
* Set `false` only when the caller supplies every file the checker needs
|
|
299
322
|
* (the internal `analyze()` wrapper does): TS/JS context is covered by the
|
|
300
323
|
* LS disk fallback either way, but a gated `.svelte` dependency resolves
|
|
@@ -324,8 +347,9 @@ export interface AnalysisSessionOptions extends Omit<AnalysisLanguageServiceOpti
|
|
|
324
347
|
*
|
|
325
348
|
* @example One-shot via the public wrapper
|
|
326
349
|
* ```ts
|
|
327
|
-
* // Equivalent to `analyze(...)` — the wrapper goes through a session internally
|
|
328
|
-
*
|
|
350
|
+
* // Equivalent to `analyze(...)` — the wrapper goes through a session internally
|
|
351
|
+
* // (and opts out of the context closure, since its callers supply the inputs).
|
|
352
|
+
* const session = createAnalysisSession({sourceOptions, contextClosure: false});
|
|
329
353
|
* try {
|
|
330
354
|
* await session.setFiles(sourceFiles);
|
|
331
355
|
* return session.query({onDuplicates: 'throw'});
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/session.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAIN,KAAK,8BAA8B,EACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,UAAU,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;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC/F,0DAA0D;IAC1D,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,mEAAmE;IACnE,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,4EAA4E;IAC5E,IAAI,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAAC;IAC9C;;;;;;;;OAQG;IACH,oBAAoB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1C;;;;;;;;;;;;;;;OAeG;IACH,UAAU,IAAI,EAAE,CAAC,OAAO,CAAC;IACzB;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CACnD,8BAA8B,EAC9B,aAAa,GAAG,cAAc,CAC9B;IACA;;;;;;;;;;OAUG;IACH,aAAa,EAAE,mBAAmB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kDAAkD;IAClD,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AA0HD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,sBAAsB,KAAG,eAqzBvE,CAAC"}
|
package/dist/session.js
CHANGED
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
* when content matches AND the mode-specific cache key matches (resolver
|
|
10
10
|
* identity for lex+resolve, dependency-snapshot equality for pre-resolved).
|
|
11
11
|
* - `deleteFile` — drop owned entry, evict from LS.
|
|
12
|
-
* - `has` / `list` — owned-set introspection
|
|
13
|
-
*
|
|
14
|
-
* - `query` — sync analysis pass against the
|
|
15
|
-
* analysis-pass diagnostics only (ingest diagnostics
|
|
16
|
-
* `setFile`/`setFiles` returns
|
|
12
|
+
* - `has` / `list` — owned-set introspection, so consumers need no mirror
|
|
13
|
+
* cache of their own.
|
|
14
|
+
* - `query` — sync analysis pass against the source-gated owned set; returns
|
|
15
|
+
* analysis-pass diagnostics only (ingest diagnostics come from the
|
|
16
|
+
* `setFile`/`setFiles` returns, and cumulatively, context-closure ingest
|
|
17
|
+
* included, from `allIngestDiagnostics`).
|
|
18
|
+
* - `getProgram` — the LS-backed `ts.Program`, for consumers doing their own
|
|
19
|
+
* checker work.
|
|
17
20
|
* - `dispose` — release LS resources.
|
|
18
21
|
*
|
|
19
22
|
* The session owns a single `Map<id, OwnedEntry>` covering content, svelte
|
|
@@ -21,7 +24,8 @@
|
|
|
21
24
|
* or pre-resolved snapshot), and ingest-time diagnostics. svelte2tsx runs
|
|
22
25
|
* at most once per content change. Resolver work parallelizes across the
|
|
23
26
|
* batch in phase 2 of the three-phase setFiles pipeline; fully pre-resolved
|
|
24
|
-
* batches skip phase 2
|
|
27
|
+
* batches skip phase 2 and the default-resolver construction (see
|
|
28
|
+
* `AnalysisSessionOptions.contextClosure` for the exception).
|
|
25
29
|
* A batch that adds paths then retries the import specifiers earlier batches
|
|
26
30
|
* couldn't resolve, since the file that settles one is the dep rather than
|
|
27
31
|
* the importer (see `AnalysisSession` → Deferred resolutions).
|
|
@@ -34,14 +38,14 @@
|
|
|
34
38
|
import { readFile } from 'node:fs/promises';
|
|
35
39
|
import ts from 'typescript';
|
|
36
40
|
import { createAnalysisLanguageService, createOwnedDirIndex } from './typescript-program.js';
|
|
37
|
-
import {
|
|
41
|
+
import { toErrorMessage } from './error.js';
|
|
38
42
|
import { transformSvelteSource } from './svelte.js';
|
|
39
43
|
import { createDefaultResolver, ensureLexerReady, isNodeBuiltin, lexImports, normalizeResolveImport } from './dep-resolver.js';
|
|
40
44
|
import { hasBaselineExcludedSegment, isSource, normalizeSourceOptions } from './source-config.js';
|
|
41
45
|
import { toPosixPath } from './paths.js';
|
|
42
|
-
import { MAX_FILE_CONCURRENCY, MAX_RESOLVE_CONCURRENCY,
|
|
46
|
+
import { MAX_FILE_CONCURRENCY, MAX_RESOLVE_CONCURRENCY, mapConcurrent } from './concurrency.js';
|
|
43
47
|
import { analyzeCore, normalizeDiagnosticPaths, AnalyzeResultJson } from './analyze-core.js';
|
|
44
|
-
import { computeDependents } from './postprocess.js';
|
|
48
|
+
import { compareStrings, computeDependents } from './postprocess.js';
|
|
45
49
|
/**
|
|
46
50
|
* Element-wise equality on two readonly string arrays. Used for the
|
|
47
51
|
* pre-resolved-deps cache key: a fresh array with identical contents
|
|
@@ -80,8 +84,9 @@ const arraysShallowEqual = (a, b) => {
|
|
|
80
84
|
*
|
|
81
85
|
* @example One-shot via the public wrapper
|
|
82
86
|
* ```ts
|
|
83
|
-
* // Equivalent to `analyze(...)` — the wrapper goes through a session internally
|
|
84
|
-
*
|
|
87
|
+
* // Equivalent to `analyze(...)` — the wrapper goes through a session internally
|
|
88
|
+
* // (and opts out of the context closure, since its callers supply the inputs).
|
|
89
|
+
* const session = createAnalysisSession({sourceOptions, contextClosure: false});
|
|
85
90
|
* try {
|
|
86
91
|
* await session.setFiles(sourceFiles);
|
|
87
92
|
* return session.query({onDuplicates: 'throw'});
|
|
@@ -153,8 +158,9 @@ export const createAnalysisSession = (options) => {
|
|
|
153
158
|
// Lazy default resolver — only constructed when needed: a `setFiles` batch
|
|
154
159
|
// has at least one file lacking `dependencies`, the call doesn't supply a
|
|
155
160
|
// per-call override, and no session-default resolver was configured. Fully
|
|
156
|
-
// pre-resolved batches skip the construction
|
|
157
|
-
//
|
|
161
|
+
// pre-resolved batches skip the construction (see `needsResolver` gating
|
|
162
|
+
// below), though a context-closure batch can still trigger it, since
|
|
163
|
+
// context files always lex+resolve. Compiler options come from the LS handle — the session's
|
|
158
164
|
// one tsconfig parse, at LS construction — so the resolver and the checker
|
|
159
165
|
// see the same merged config. The TS module-resolution cache is kept on
|
|
160
166
|
// the resolver so consecutive resolves share state.
|
|
@@ -255,7 +261,7 @@ export const createAnalysisSession = (options) => {
|
|
|
255
261
|
ingestDiagnostics.push({
|
|
256
262
|
kind: 'import_parse_failed',
|
|
257
263
|
file: file.id,
|
|
258
|
-
message: `Failed to parse imports: ${
|
|
264
|
+
message: `Failed to parse imports: ${toErrorMessage(err)}`,
|
|
259
265
|
severity: 'warning'
|
|
260
266
|
});
|
|
261
267
|
}
|
|
@@ -459,7 +465,7 @@ export const createAnalysisSession = (options) => {
|
|
|
459
465
|
if (tasks.length > 0 && resolver === null) {
|
|
460
466
|
throw new Error('svelte-docinfo: phase-2 invariant violated — tasks pending without a resolver');
|
|
461
467
|
}
|
|
462
|
-
const taskResults = await
|
|
468
|
+
const taskResults = await mapConcurrent(tasks, MAX_RESOLVE_CONCURRENCY, async (t) => {
|
|
463
469
|
const pending = pendings[t.pendingIdx];
|
|
464
470
|
try {
|
|
465
471
|
const resolved = await resolver.resolve(t.specifier, pending.file.id);
|
|
@@ -478,7 +484,7 @@ export const createAnalysisSession = (options) => {
|
|
|
478
484
|
return {
|
|
479
485
|
...t,
|
|
480
486
|
resolved: null,
|
|
481
|
-
error:
|
|
487
|
+
error: toErrorMessage(err)
|
|
482
488
|
};
|
|
483
489
|
}
|
|
484
490
|
});
|
|
@@ -585,7 +591,7 @@ export const createAnalysisSession = (options) => {
|
|
|
585
591
|
while (candidates.length > 0) {
|
|
586
592
|
for (const c of candidates)
|
|
587
593
|
attempted.add(c);
|
|
588
|
-
const loaded = await
|
|
594
|
+
const loaded = await mapConcurrent(candidates, MAX_FILE_CONCURRENCY, async (id) => {
|
|
589
595
|
try {
|
|
590
596
|
return { id, content: await readFile(id, 'utf-8') };
|
|
591
597
|
}
|
|
@@ -627,11 +633,13 @@ export const createAnalysisSession = (options) => {
|
|
|
627
633
|
// `runBatch` cleared those at the top.
|
|
628
634
|
//
|
|
629
635
|
// A settled slot also retires the `resolver_failed` its ingest emitted, if
|
|
630
|
-
// any — the claim was true then and isn't now.
|
|
631
|
-
//
|
|
632
|
-
//
|
|
633
|
-
//
|
|
634
|
-
//
|
|
636
|
+
// any — the claim was true then and isn't now. Gaps, each corrected only on
|
|
637
|
+
// the importer's next content change: a resolver that throws *here* leaves
|
|
638
|
+
// the slot deferred with its original diagnostic standing; a newly resolved
|
|
639
|
+
// edge to an in-root non-source file doesn't seed a context-closure round;
|
|
640
|
+
// and an owned file *shadowing* a target that already resolved from disk
|
|
641
|
+
// (`dep.ts` displacing `dep.js`) is outside this pass entirely, since the
|
|
642
|
+
// entry has no deferred slot to retry.
|
|
635
643
|
const healUnresolvedEdges = async (opts) => {
|
|
636
644
|
// A scan of the owned set rather than a side index of deferred entries:
|
|
637
645
|
// it can't desync, and it only runs on a batch that added paths.
|
|
@@ -657,7 +665,7 @@ export const createAnalysisSession = (options) => {
|
|
|
657
665
|
}
|
|
658
666
|
if (retries.length === 0)
|
|
659
667
|
return;
|
|
660
|
-
const results = await
|
|
668
|
+
const results = await mapConcurrent(retries, MAX_RESOLVE_CONCURRENCY, async (r) => {
|
|
661
669
|
try {
|
|
662
670
|
const resolved = await resolver.resolve(r.entry.unresolved.specifiers[r.slot], r.id);
|
|
663
671
|
return { ...r, resolved: resolved === null ? null : toPosixPath(resolved) };
|
|
@@ -781,7 +789,14 @@ export const createAnalysisSession = (options) => {
|
|
|
781
789
|
const contextSvelteFiles = [];
|
|
782
790
|
const svelteVirtualFiles = new Map();
|
|
783
791
|
const transformFailedIds = new Set();
|
|
784
|
-
|
|
792
|
+
// Analysis order is sorted, not ingest order, so output is a function of
|
|
793
|
+
// the owned file set. TypeScript prints a union with no alias origin
|
|
794
|
+
// (`z.enum` members, literal unions) in type-creation order, so the
|
|
795
|
+
// order the checker first visits files in reorders those members;
|
|
796
|
+
// ingest order varies with the filesystem crawl and with which files
|
|
797
|
+
// an incremental session received first.
|
|
798
|
+
const ownedSorted = [...owned].sort((a, b) => compareStrings(a[0], b[0]));
|
|
799
|
+
for (const [id, entry] of ownedSorted) {
|
|
785
800
|
if (!emittedIds.has(id)) {
|
|
786
801
|
// Gated Svelte file with a good virtual (context closure, or a
|
|
787
802
|
// caller-pushed input): offered to `analyzeCore` as canonical-fill
|
package/dist/source-config.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides `ModuleSourceOptions` configuration management and functions
|
|
5
5
|
* that operate on source files using those options: path extraction,
|
|
6
|
-
* source detection, dependency filtering,
|
|
6
|
+
* source detection, dependency filtering, include-pattern widening, and
|
|
7
|
+
* glob-pattern normalization.
|
|
7
8
|
*
|
|
8
9
|
* @see `source.ts` for pure file type predicates (`isTypescript`, `isSvelte`, etc.)
|
|
9
|
-
* @see `analyze.ts` for consumers (`analyze`, `analyzeFromFiles`)
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
@@ -100,8 +100,7 @@ export interface ModuleSourceOptions {
|
|
|
100
100
|
* Applied at both stages of the pipeline:
|
|
101
101
|
* - **Discovery time** by `globFiles`/`discoverFromExports`, preventing matched files from being loaded.
|
|
102
102
|
* - **Analysis time** by `isSource()` against `relative(projectRoot, absolutePath)`,
|
|
103
|
-
*
|
|
104
|
-
* (e.g., a source file imports a test helper).
|
|
103
|
+
* which gates both the emitted module set (`query()`) and dependency edges.
|
|
105
104
|
*
|
|
106
105
|
* Beneath it, the always-on baseline (`node_modules` + dot-directories
|
|
107
106
|
* below a matched source path — see `hasBaselineExcludedSegment`) applies
|
|
@@ -116,7 +115,8 @@ export interface ModuleSourceOptions {
|
|
|
116
115
|
* defaults doesn't require restating them; this normalized field is always
|
|
117
116
|
* a plain array.
|
|
118
117
|
*
|
|
119
|
-
* `analyzeFromFiles`
|
|
118
|
+
* `analyzeFromFiles` and the Vite plugin accept a top-level `exclude` that
|
|
119
|
+
* replaces this field (no merge).
|
|
120
120
|
*
|
|
121
121
|
* Compiled to a matcher once per options object via picomatch and cached by reference;
|
|
122
122
|
* mutating this array post-`isSource`-call has no effect — pass through
|
|
@@ -129,14 +129,9 @@ export interface ModuleSourceOptions {
|
|
|
129
129
|
/**
|
|
130
130
|
* Determine which analyzer to use for a file path.
|
|
131
131
|
*
|
|
132
|
-
* Called
|
|
133
|
-
* -
|
|
134
|
-
*
|
|
135
|
-
* - `'css'` — CSS files included as modules with no declarations
|
|
136
|
-
* - `'json'` — JSON files included as modules with no declarations
|
|
137
|
-
* - `null` — skip the file
|
|
138
|
-
*
|
|
139
|
-
* @default Uses file extension: `.svelte` → svelte, `.ts`/`.js` → typescript, `.css` → css, `.json` → json
|
|
132
|
+
* Called wherever the pipeline classifies a path (ingest, every `isSource`
|
|
133
|
+
* check, context-closure candidates), so keep it cheap and pure. Return an
|
|
134
|
+
* `AnalyzerType` (see there for what each analyzes) or `null` to skip.
|
|
140
135
|
*
|
|
141
136
|
* Extend the default table by delegating to `getDefaultAnalyzer` (exported
|
|
142
137
|
* from the main barrel) for everything but the added case — restating the
|
|
@@ -153,6 +148,8 @@ export interface ModuleSourceOptions {
|
|
|
153
148
|
* // Include .d.ts files (the default excludes them)
|
|
154
149
|
* getAnalyzerType: (path) => (path.endsWith('.d.ts') ? 'typescript' : getDefaultAnalyzer(path))
|
|
155
150
|
* ```
|
|
151
|
+
*
|
|
152
|
+
* @default `getDefaultAnalyzer` (by file extension)
|
|
156
153
|
*/
|
|
157
154
|
getAnalyzerType: (path: string) => AnalyzerType | null;
|
|
158
155
|
}
|
|
@@ -169,9 +166,10 @@ export type SourceOptionsDefaults = Omit<ModuleSourceOptions, 'projectRoot'>;
|
|
|
169
166
|
* `analyzeFromFiles`, the Vite plugin — not the CLI, whose `--exclude` is
|
|
170
167
|
* array-only).
|
|
171
168
|
*
|
|
172
|
-
* An array **replaces** `DEFAULT_SOURCE_OPTIONS.exclude` wholesale
|
|
173
|
-
*
|
|
174
|
-
*
|
|
169
|
+
* An array **replaces** `DEFAULT_SOURCE_OPTIONS.exclude` wholesale (the test,
|
|
170
|
+
* spec, and `internal/` filters are dropped unless restated); the callback
|
|
171
|
+
* form receives a fresh copy of those defaults and returns the list to use,
|
|
172
|
+
* so extending them doesn't require restating them:
|
|
175
173
|
*
|
|
176
174
|
* ```ts
|
|
177
175
|
* exclude: (defaults) => [...defaults, '**\/*.gen.ts'] // add a pattern
|
|
@@ -181,7 +179,9 @@ export type SourceOptionsDefaults = Omit<ModuleSourceOptions, 'projectRoot'>;
|
|
|
181
179
|
* The callback runs at most once per built options object (include-pattern
|
|
182
180
|
* widening rebuilds options from the already-resolved array). Resolved to a
|
|
183
181
|
* plain array before normalization; `ModuleSourceOptions.exclude` never
|
|
184
|
-
* carries the function form.
|
|
182
|
+
* carries the function form. The always-on baseline (`node_modules` +
|
|
183
|
+
* dot-directories below a matched source path, `hasBaselineExcludedSegment`)
|
|
184
|
+
* applies beneath either form and is unaffected by overrides.
|
|
185
185
|
*/
|
|
186
186
|
export type ExcludeOption = Array<string> | ((defaults: Array<string>) => Array<string>);
|
|
187
187
|
/**
|
|
@@ -218,7 +218,9 @@ export declare const DEFAULT_SOURCE_OPTIONS: SourceOptionsDefaults;
|
|
|
218
218
|
*
|
|
219
219
|
* @param projectRoot - path to project root (typically `process.cwd()`); resolved to absolute
|
|
220
220
|
* @param overrides - optional overrides for default options
|
|
221
|
-
* @throws Error if validation fails (empty `sourcePaths
|
|
221
|
+
* @throws Error if validation fails (empty `sourcePaths`; a `sourcePaths` entry, `sourceRoot`,
|
|
222
|
+
* or absolute `exclude` glob escaping `projectRoot`; or `sourceRoot` not a prefix of all
|
|
223
|
+
* `sourcePaths`)
|
|
222
224
|
*
|
|
223
225
|
* @example
|
|
224
226
|
* ```ts
|
|
@@ -430,7 +432,8 @@ export declare const extractPath: (sourceId: string, options: ModuleSourceOption
|
|
|
430
432
|
*
|
|
431
433
|
* Deliberately NOT part of `DEFAULT_SOURCE_OPTIONS.exclude`: user `exclude`
|
|
432
434
|
* replaces the defaults wholesale and would silently strip the baseline.
|
|
433
|
-
* `baselineExcludesForBase` is the discovery-time glob form
|
|
435
|
+
* `baselineExcludesForBase` is the discovery-time glob form; at analysis it
|
|
436
|
+
* applies wherever `isSource` does.
|
|
434
437
|
*
|
|
435
438
|
* @param relPath - POSIX path relative to a matched source path / discovery base
|
|
436
439
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-config.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAsB,MAAM,aAAa,CAAC;AAGzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB
|
|
1
|
+
{"version":3,"file":"source-config.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAsB,MAAM,aAAa,CAAC;AAGzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,mBAAmB;IACn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AAY,cAAc,GAAG;IAAE,UAAU,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,EACnE,SAAS,mBAAmB,KAC1B;IAAE,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CA2B1D,CAAC"}
|
package/dist/source-config.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides `ModuleSourceOptions` configuration management and functions
|
|
5
5
|
* that operate on source files using those options: path extraction,
|
|
6
|
-
* source detection, dependency filtering,
|
|
6
|
+
* source detection, dependency filtering, include-pattern widening, and
|
|
7
|
+
* glob-pattern normalization.
|
|
7
8
|
*
|
|
8
9
|
* @see `source.ts` for pure file type predicates (`isTypescript`, `isSvelte`, etc.)
|
|
9
|
-
* @see `analyze.ts` for consumers (`analyze`, `analyzeFromFiles`)
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
@@ -42,7 +42,9 @@ export const DEFAULT_SOURCE_OPTIONS = {
|
|
|
42
42
|
*
|
|
43
43
|
* @param projectRoot - path to project root (typically `process.cwd()`); resolved to absolute
|
|
44
44
|
* @param overrides - optional overrides for default options
|
|
45
|
-
* @throws Error if validation fails (empty `sourcePaths
|
|
45
|
+
* @throws Error if validation fails (empty `sourcePaths`; a `sourcePaths` entry, `sourceRoot`,
|
|
46
|
+
* or absolute `exclude` glob escaping `projectRoot`; or `sourceRoot` not a prefix of all
|
|
47
|
+
* `sourcePaths`)
|
|
46
48
|
*
|
|
47
49
|
* @example
|
|
48
50
|
* ```ts
|
|
@@ -151,11 +153,10 @@ export const normalizeSourceOptions = (options) => {
|
|
|
151
153
|
// resolve inside the project root by storing them root-relative (matching
|
|
152
154
|
// `loadFile`'s treatment of path inputs). An entry that resolves outside
|
|
153
155
|
// the project root throws: out-of-root modules are unrepresentable
|
|
154
|
-
// (`ModuleJson.path` is relative to `sourceRoot` and
|
|
155
|
-
// the
|
|
156
|
-
//
|
|
157
|
-
//
|
|
158
|
-
// with no trace beyond its info log. Include-pattern widening re-runs
|
|
156
|
+
// (`ModuleJson.path` is relative to `sourceRoot` and cannot name a file
|
|
157
|
+
// outside the root), so the config would be silently dead — discovery finds
|
|
158
|
+
// the files, ingest accepts them, and the query-time source gate drops every
|
|
159
|
+
// one with no trace beyond its info log. Include-pattern widening re-runs
|
|
159
160
|
// `createSourceOptions`, so an out-of-root include base fails here too.
|
|
160
161
|
const sourcePaths = options.sourcePaths.map((p) => toRootRelativePath(p, projectRoot, 'sourcePaths entry', 'Out-of-root files cannot be analyzed — module paths and diagnostics are ' +
|
|
161
162
|
'project-root-relative. Point projectRoot at a common ancestor of all source ' +
|
|
@@ -193,9 +194,9 @@ export const normalizeSourceOptions = (options) => {
|
|
|
193
194
|
// Normalize exclude globs the same way include patterns normalize at the
|
|
194
195
|
// discovery seams: an in-root absolute pattern relativizes (textual prefix
|
|
195
196
|
// strip — glob metacharacters aren't path segments), an out-of-root one
|
|
196
|
-
// throws.
|
|
197
|
-
// absolute excludes at discovery while `isSource` and the concrete-export
|
|
198
|
-
// check match
|
|
197
|
+
// throws. Keeps the stages agreeing: tinyglobby's glob `ignore` honors
|
|
198
|
+
// absolute excludes at discovery, while `isSource` and the concrete-export
|
|
199
|
+
// check match root-relative paths and would silently never exclude.
|
|
199
200
|
const exclude = options.exclude.map((p) => normalizeGlobPattern(p, projectRoot, 'exclude glob'));
|
|
200
201
|
return { ...options, projectRoot, sourcePaths, sourceRoot, exclude };
|
|
201
202
|
};
|
|
@@ -487,7 +488,8 @@ export const extractPath = (sourceId, options) => {
|
|
|
487
488
|
*
|
|
488
489
|
* Deliberately NOT part of `DEFAULT_SOURCE_OPTIONS.exclude`: user `exclude`
|
|
489
490
|
* replaces the defaults wholesale and would silently strip the baseline.
|
|
490
|
-
* `baselineExcludesForBase` is the discovery-time glob form
|
|
491
|
+
* `baselineExcludesForBase` is the discovery-time glob form; at analysis it
|
|
492
|
+
* applies wherever `isSource` does.
|
|
491
493
|
*
|
|
492
494
|
* @param relPath - POSIX path relative to a matched source path / discovery base
|
|
493
495
|
*/
|
package/dist/source.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Source file
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* component names from paths. No configuration dependency — these are
|
|
6
|
-
* the building blocks used by `source-config.ts`.
|
|
2
|
+
* Source file shapes (`SourceFileInfo`, `AnalyzerType`), extension predicates,
|
|
3
|
+
* and svelte2tsx virtual-path and generated-name helpers. No configuration
|
|
4
|
+
* dependency; the building blocks under `source-config.ts`.
|
|
7
5
|
*
|
|
8
6
|
* @see `source-config.ts` for configuration-aware functions (`isSource`, `extractPath`, etc.)
|
|
9
|
-
* @see `analyze.ts` for consumers (`analyze`, `analyzeFromFiles`)
|
|
10
7
|
*
|
|
11
8
|
* @module
|
|
12
9
|
*/
|
|
@@ -25,13 +22,17 @@ export type AnalyzerType = 'typescript' | 'svelte' | 'css' | 'json';
|
|
|
25
22
|
* Provides file content to analysis functions from any source:
|
|
26
23
|
* file system, build pipeline, or in-memory.
|
|
27
24
|
*
|
|
28
|
-
* Note: `content` is required
|
|
29
|
-
*
|
|
25
|
+
* Note: `content` is required so callers control what the checker sees for
|
|
26
|
+
* the files they supply. Files they don't (context-closure files,
|
|
27
|
+
* `node_modules`, other unowned imports) are read from disk.
|
|
30
28
|
*/
|
|
31
29
|
export interface SourceFileInfo {
|
|
32
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Absolute path to the file. Native paths are fine at the boundary — ids
|
|
32
|
+
* are posixified at ingest (see `paths.ts`).
|
|
33
|
+
*/
|
|
33
34
|
id: string;
|
|
34
|
-
/** File content (required
|
|
35
|
+
/** File content (required — the checker sees this, not the disk, for ingested files). */
|
|
35
36
|
content: string;
|
|
36
37
|
/**
|
|
37
38
|
* Pre-resolved absolute file paths of modules this file imports.
|
|
@@ -59,8 +60,11 @@ export interface SourceFileInfo {
|
|
|
59
60
|
*
|
|
60
61
|
* Type-only imports (`import type {...}`) are the most common asymmetry
|
|
61
62
|
* versus the lex+resolve path: the default lex (`es-module-lexer`) keeps
|
|
62
|
-
*
|
|
63
|
-
* them. Both are intentional within
|
|
63
|
+
* `import type` and inline `type` specifiers; pre-resolved callers backed
|
|
64
|
+
* by a Gro-style filer typically drop them. Both are intentional within
|
|
65
|
+
* their respective contracts. The default lex does drop type-only
|
|
66
|
+
* re-exports (see `lexImports`), so such a re-export has a `reExports`
|
|
67
|
+
* edge with no `dependencies` entry and seeds no context closure.
|
|
64
68
|
*
|
|
65
69
|
* Cache semantics: the session compares this array element-wise (shallow
|
|
66
70
|
* equality) against the snapshot stored from the prior call — a fresh
|
|
@@ -81,7 +85,7 @@ export interface SourceFileInfo {
|
|
|
81
85
|
* Default analyzer resolver based on file extension.
|
|
82
86
|
*
|
|
83
87
|
* - `.svelte` → `'svelte'`
|
|
84
|
-
* - `.ts
|
|
88
|
+
* - `.ts` (not `.d.ts`), `.js` → `'typescript'`
|
|
85
89
|
* - `.css` → `'css'`
|
|
86
90
|
* - `.json` → `'json'`
|
|
87
91
|
* - Other extensions → `null` (skip)
|
package/dist/source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"source.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEpE;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;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