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
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* plumbing, `.svelte` module resolution):
|
|
6
6
|
*
|
|
7
7
|
* - `createAnalysisProgram` — one-shot `ts.Program` from a `ts.CompilerHost`.
|
|
8
|
-
* Lower-level escape hatch for power users
|
|
9
|
-
*
|
|
8
|
+
* Lower-level escape hatch for power users. Does not support incremental
|
|
9
|
+
* updates.
|
|
10
10
|
* - `createAnalysisLanguageService` — persistent `ts.LanguageService` with
|
|
11
11
|
* versioned `IScriptSnapshot`s. Incremental: subsequent `getProgram()` calls
|
|
12
12
|
* reuse parsed ASTs and checker state for unchanged files. Used by
|
|
@@ -23,6 +23,7 @@ import ts from 'typescript';
|
|
|
23
23
|
import { SVELTE_VIRTUAL_SUFFIX } from './source.js';
|
|
24
24
|
import { getSourceRoot } from './source-config.js';
|
|
25
25
|
import { toPosixPath } from './paths.js';
|
|
26
|
+
import { compareStrings } from './postprocess.js';
|
|
26
27
|
/** Create an empty `OwnedDirIndex`. @internal */
|
|
27
28
|
export const createOwnedDirIndex = () => {
|
|
28
29
|
const paths = new Set();
|
|
@@ -129,7 +130,10 @@ export const applyVirtualFiles = (host, virtualFiles) => {
|
|
|
129
130
|
* resolution via `ts.resolveModuleName`) without the cost of building a full
|
|
130
131
|
* `ts.Program`.
|
|
131
132
|
*
|
|
132
|
-
*
|
|
133
|
+
* Each call globs the tsconfig `include` to build `rootFileNames`; reuse the
|
|
134
|
+
* result rather than calling per resolve.
|
|
135
|
+
*
|
|
136
|
+
* @throws Error if tsconfig.json (or the file named by `options.tsconfig`) is not found.
|
|
133
137
|
*/
|
|
134
138
|
export const loadTsconfig = (options, log) => {
|
|
135
139
|
const projectRoot = options?.projectRoot ?? process.cwd();
|
|
@@ -302,11 +306,16 @@ export const createAnalysisLanguageService = (options, log) => {
|
|
|
302
306
|
getCompilationSettings: () => compilerOptions,
|
|
303
307
|
getScriptFileNames: () => {
|
|
304
308
|
// Combine tsconfig roots with owned virtual roots. Set semantics
|
|
305
|
-
// dedupe when an owned file was also a tsconfig root.
|
|
309
|
+
// dedupe when an owned file was also a tsconfig root. Owned roots
|
|
310
|
+
// are sorted rather than kept in ingest order: root order sets the
|
|
311
|
+
// program's file order, and with it the merge order of
|
|
312
|
+
// `declare global`, module augmentations, and interface merging.
|
|
313
|
+
// The LS compares root lists by content, so a stable sort keeps
|
|
314
|
+
// program reuse intact.
|
|
306
315
|
if (ownedRoots.size === 0)
|
|
307
316
|
return [...tsconfigRoots];
|
|
308
317
|
const combined = new Set(tsconfigRoots);
|
|
309
|
-
for (const path of ownedRoots)
|
|
318
|
+
for (const path of [...ownedRoots].sort(compareStrings))
|
|
310
319
|
combined.add(path);
|
|
311
320
|
return [...combined];
|
|
312
321
|
},
|
|
@@ -371,6 +380,15 @@ export const createAnalysisLanguageService = (options, log) => {
|
|
|
371
380
|
};
|
|
372
381
|
return { getProgram, getCompilerOptions, setFile, deleteFile, hasFile, dispose };
|
|
373
382
|
};
|
|
383
|
+
/** The project/source prefixes both externality predicates compare against. */
|
|
384
|
+
const externalityPrefixes = (options) => {
|
|
385
|
+
const projectPrefix = options.projectRoot + '/';
|
|
386
|
+
const effectiveRoot = getSourceRoot(options);
|
|
387
|
+
return {
|
|
388
|
+
projectPrefix,
|
|
389
|
+
sourcePrefix: effectiveRoot ? projectPrefix + effectiveRoot + '/' : projectPrefix
|
|
390
|
+
};
|
|
391
|
+
};
|
|
374
392
|
/**
|
|
375
393
|
* Create an `IsExternalFile` predicate from `ModuleSourceOptions`.
|
|
376
394
|
*
|
|
@@ -381,15 +399,6 @@ export const createAnalysisLanguageService = (options, log) => {
|
|
|
381
399
|
* declarations like `.svelte-kit/non-ambient.d.ts` while keeping user `.d.ts` files
|
|
382
400
|
* in the source tree)
|
|
383
401
|
*/
|
|
384
|
-
/** The project/source prefixes both externality predicates compare against. */
|
|
385
|
-
const externalityPrefixes = (options) => {
|
|
386
|
-
const projectPrefix = options.projectRoot + '/';
|
|
387
|
-
const effectiveRoot = getSourceRoot(options);
|
|
388
|
-
return {
|
|
389
|
-
projectPrefix,
|
|
390
|
-
sourcePrefix: effectiveRoot ? projectPrefix + effectiveRoot + '/' : projectPrefix
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
402
|
export const createIsExternalFile = (options) => {
|
|
394
403
|
const { projectPrefix, sourcePrefix } = externalityPrefixes(options);
|
|
395
404
|
return (sf) => !sf.fileName.startsWith(projectPrefix) ||
|
package/dist/vite.d.ts
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* `setFiles` + one `query` per debounce window — multi-file editor saves
|
|
7
7
|
* collapse to a single re-analysis instead of N serialized round-trips.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* directly. `session.list()` / `session.has()` cover owned-set introspection.
|
|
9
|
+
* HMR invalidation keys on `setFiles`'s `changedIds`; the watcher gates on
|
|
10
|
+
* `isSource(file) || session.has(file)`.
|
|
12
11
|
*
|
|
13
12
|
* Consumers import the analysis result:
|
|
14
13
|
*
|
|
@@ -49,40 +48,18 @@ export interface VitePluginSvelteDocinfoOptions {
|
|
|
49
48
|
*/
|
|
50
49
|
projectRoot?: string;
|
|
51
50
|
/**
|
|
52
|
-
* Glob patterns to include
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* to glob (exports discovery is skipped). Combining `include` with
|
|
58
|
-
* `discovery: 'exports'` throws at config-resolve time — `exports` mode
|
|
59
|
-
* has no concept of include patterns.
|
|
60
|
-
*
|
|
61
|
-
* Explicit patterns also widen the source scope: their static bases join
|
|
62
|
-
* `sourceOptions.sourcePaths` (see `widenSourcePathsForInclude`), so
|
|
63
|
-
* include-discovered files outside the configured source paths still emit
|
|
64
|
-
* modules — and the watcher tracks their changes. A pattern with no static
|
|
65
|
-
* base (`'**\/*.ts'`, a literal root file) scopes the whole project root
|
|
66
|
-
* as source and logs an info line; an out-of-root base throws.
|
|
67
|
-
*
|
|
68
|
-
* When omitted, the glob fallback derives an include from
|
|
69
|
-
* `sourceOptions.sourcePaths` via `deriveIncludePatterns`, so custom
|
|
70
|
-
* `sourcePaths` survive the fallback instead of silently defaulting to
|
|
71
|
-
* `src/lib`.
|
|
51
|
+
* Glob patterns to include, relative to `projectRoot`. Collapses
|
|
52
|
+
* `discovery: 'auto'` to glob (combining with `'exports'` throws at
|
|
53
|
+
* config-resolve time), and each pattern's static base widens
|
|
54
|
+
* `sourceOptions.sourcePaths` so the matched files emit modules and the
|
|
55
|
+
* watcher tracks them (see `createSourceOptionsWithInclude`).
|
|
72
56
|
*/
|
|
73
57
|
include?: Array<string>;
|
|
74
58
|
/**
|
|
75
|
-
* Glob patterns to exclude, applied at both discovery and analysis time
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* spec, and `internal/` filters are dropped unless re-included — while the
|
|
80
|
-
* callback form extends them without restating them
|
|
81
|
-
* (`(defaults) => [...defaults, '**\/*.gen.ts']` — see `ExcludeOption`).
|
|
82
|
-
* The callback always receives the built-in defaults, even when
|
|
83
|
-
* `sourceOptions.exclude` is also set (that value is superseded whole).
|
|
84
|
-
* The always-on baseline (`node_modules` + dot-directories below a matched
|
|
85
|
-
* source path) applies beneath it and is unaffected by overrides.
|
|
59
|
+
* Glob patterns to exclude, applied at both discovery and analysis time —
|
|
60
|
+
* supersedes `sourceOptions.exclude` whole (no merge; the callback form
|
|
61
|
+
* still receives the built-in defaults). An array replaces the defaults, a
|
|
62
|
+
* callback extends them — see `ExcludeOption`.
|
|
86
63
|
*/
|
|
87
64
|
exclude?: ExcludeOption;
|
|
88
65
|
/**
|
|
@@ -98,7 +75,7 @@ export interface VitePluginSvelteDocinfoOptions {
|
|
|
98
75
|
* Discovery strategy for source files.
|
|
99
76
|
*
|
|
100
77
|
* @default 'auto'
|
|
101
|
-
* @see
|
|
78
|
+
* @see `Discovery`
|
|
102
79
|
*/
|
|
103
80
|
discovery?: Discovery;
|
|
104
81
|
/**
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/vite.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/vite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,KAAK,EAAwB,MAAM,EAAiB,MAAM,MAAM,CAAC;AAGxE,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAKrE,OAAO,EAGN,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC3B,MAAM,oBAAoB,CAAC;AAU5B,mDAAmD;AACnD,MAAM,WAAW,8BAA8B;IAC9C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,0EAA0E;IAC1E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,aAAa,GAAI,UAAS,8BAAmC,KAAG,MA0YrE,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/dist/vite.js
CHANGED
|
@@ -6,9 +6,8 @@
|
|
|
6
6
|
* `setFiles` + one `query` per debounce window — multi-file editor saves
|
|
7
7
|
* collapse to a single re-analysis instead of N serialized round-trips.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* directly. `session.list()` / `session.has()` cover owned-set introspection.
|
|
9
|
+
* HMR invalidation keys on `setFiles`'s `changedIds`; the watcher gates on
|
|
10
|
+
* `isSource(file) || session.has(file)`.
|
|
12
11
|
*
|
|
13
12
|
* Consumers import the analysis result:
|
|
14
13
|
*
|
|
@@ -186,8 +185,10 @@ const svelteDocinfo = (options = {}) => {
|
|
|
186
185
|
// session's context closure — e.g. `internal/` modules public files
|
|
187
186
|
// import), whose edits change public output through the checker even
|
|
188
187
|
// though they emit no module themselves. A context file created *after*
|
|
189
|
-
// its importer's last ingest becomes owned on that importer's next
|
|
190
|
-
//
|
|
188
|
+
// its importer's last ingest becomes owned on that importer's next change
|
|
189
|
+
// (the dev resolver doesn't cache misses; see
|
|
190
|
+
// `AnalysisSessionOptions.contextClosure`); until then its events are
|
|
191
|
+
// dropped.
|
|
191
192
|
const isWatchedFile = (file) => isSource(file, resolvedSourceOptions) || (session?.has(file) ?? false);
|
|
192
193
|
// Initial analysis (cold start in buildStart)
|
|
193
194
|
const runInitialAnalysis = async () => {
|
|
@@ -292,7 +293,7 @@ const svelteDocinfo = (options = {}) => {
|
|
|
292
293
|
// as `analyzeFromFiles`).
|
|
293
294
|
const mergedSourceOptions = exclude !== undefined ? { ...sourceOptions, exclude } : sourceOptions;
|
|
294
295
|
// Explicit include patterns widen the source scope (same as
|
|
295
|
-
// `analyzeFromFiles`)
|
|
296
|
+
// `analyzeFromFiles`), which the watcher needs too: its `isWatchedFile`
|
|
296
297
|
// gate reads `sourcePaths` and would otherwise ignore changes to
|
|
297
298
|
// include-discovered files outside them.
|
|
298
299
|
resolvedSourceOptions = createSourceOptionsWithInclude(projectRoot, mergedSourceOptions, include, logger);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-docinfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "static analysis for TypeScript and Svelte",
|
|
5
5
|
"glyph": "📜",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"zod": "^4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@fuzdev/
|
|
54
|
-
"@fuzdev/fuz_code": "^0.
|
|
55
|
-
"@fuzdev/fuz_css": "^0.
|
|
56
|
-
"@fuzdev/fuz_ui": "^0.
|
|
57
|
-
"@fuzdev/fuz_util": "^0.
|
|
58
|
-
"@fuzdev/gro": "^0.
|
|
53
|
+
"@fuzdev/blake3-wasm": "^0.2.0",
|
|
54
|
+
"@fuzdev/fuz_code": "^0.50.0",
|
|
55
|
+
"@fuzdev/fuz_css": "^0.65.1",
|
|
56
|
+
"@fuzdev/fuz_ui": "^0.210.1",
|
|
57
|
+
"@fuzdev/fuz_util": "^0.69.0",
|
|
58
|
+
"@fuzdev/gro": "^0.213.0",
|
|
59
59
|
"@fuzdev/mdz": "^0.3.0",
|
|
60
|
-
"@ryanatkn/eslint-config": "^0.12.
|
|
60
|
+
"@ryanatkn/eslint-config": "^0.12.2",
|
|
61
61
|
"@sveltejs/acorn-typescript": "^1.0.9",
|
|
62
62
|
"@sveltejs/adapter-static": "^3.0.10",
|
|
63
63
|
"@sveltejs/kit": "^2.69.2",
|
|
@@ -71,8 +71,6 @@
|
|
|
71
71
|
"eslint-plugin-svelte": "^3.19.0",
|
|
72
72
|
"esm-env": "^1.2.2",
|
|
73
73
|
"magic-string": "^0.30.21",
|
|
74
|
-
"prettier": "^3.9.6",
|
|
75
|
-
"prettier-plugin-svelte": "^4.1.1",
|
|
76
74
|
"svelte": "^5.56.4",
|
|
77
75
|
"svelte-check": "^4.7.2",
|
|
78
76
|
"svelte2tsx": "^0.7.55",
|
|
@@ -80,28 +78,10 @@
|
|
|
80
78
|
"typescript": "^5.9.3",
|
|
81
79
|
"typescript-eslint": "^8.48.1",
|
|
82
80
|
"vite": "^7.3.6",
|
|
83
|
-
"vitest": "^
|
|
81
|
+
"vitest": "^5.0.0",
|
|
84
82
|
"zimmerframe": "^1.1.4",
|
|
85
83
|
"zod": "^4.3.6"
|
|
86
84
|
},
|
|
87
|
-
"prettier": {
|
|
88
|
-
"plugins": [
|
|
89
|
-
"prettier-plugin-svelte"
|
|
90
|
-
],
|
|
91
|
-
"useTabs": true,
|
|
92
|
-
"printWidth": 100,
|
|
93
|
-
"singleQuote": true,
|
|
94
|
-
"bracketSpacing": true,
|
|
95
|
-
"trailingComma": "none",
|
|
96
|
-
"overrides": [
|
|
97
|
-
{
|
|
98
|
-
"files": "package.json",
|
|
99
|
-
"options": {
|
|
100
|
-
"useTabs": false
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
85
|
"sideEffects": [],
|
|
106
86
|
"files": [
|
|
107
87
|
"dist",
|
|
@@ -28,13 +28,15 @@
|
|
|
28
28
|
*
|
|
29
29
|
* ## Why this file lives at the package root, not `src/lib/`
|
|
30
30
|
*
|
|
31
|
-
* `svelte.config.js` aliases `'svelte-docinfo' → 'src/lib'`
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* to
|
|
31
|
+
* `svelte.config.js` aliases `'svelte-docinfo' → 'src/lib'` — load-bearing for
|
|
32
|
+
* the site build, where dependencies (fuz_ui, gro) import `svelte-docinfo` at
|
|
33
|
+
* runtime and the package isn't installed in its own `node_modules`, so only
|
|
34
|
+
* the alias resolves those imports (package self-reference doesn't apply to
|
|
35
|
+
* imports from inside another package). `@sveltejs/package` applies that
|
|
36
|
+
* alias to every file under `src/lib/`, including hand-written `.d.ts`,
|
|
37
|
+
* rewriting the `'svelte-docinfo'` import below to a relative path.
|
|
38
|
+
* TypeScript doesn't resolve relative imports inside ambient `declare module`
|
|
39
|
+
* blocks in consumer projects — types silently collapse to `any`.
|
|
38
40
|
*
|
|
39
41
|
* Living at the root keeps the file out of `svelte-package`'s reach;
|
|
40
42
|
* `gro.config.ts` and `package.json` `files` re-register it for npm.
|