svelte-docinfo 0.5.1 → 0.5.3
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/dist/analyze-core.js +2 -2
- package/dist/declaration-build.d.ts +5 -1
- package/dist/declaration-build.d.ts.map +1 -1
- package/dist/declaration-helpers.js +4 -4
- package/dist/dep-resolver.d.ts +6 -2
- package/dist/dep-resolver.d.ts.map +1 -1
- package/dist/dep-resolver.js +18 -8
- package/dist/diagnostics.js +4 -4
- package/dist/exports.js +4 -4
- package/dist/index.js +8 -8
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +10 -6
- package/dist/svelte.d.ts +14 -2
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +40 -17
- package/dist/types.js +2 -2
- package/dist/typescript-exports.d.ts +2 -1
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +8 -3
- package/dist/vite.js +4 -4
- package/package.json +2 -2
package/dist/analyze-core.js
CHANGED
|
@@ -91,7 +91,7 @@ const dispatchOnDuplicates = (mode, duplicates, log) => {
|
|
|
91
91
|
}
|
|
92
92
|
mode(duplicates, errorLog);
|
|
93
93
|
};
|
|
94
|
-
//
|
|
94
|
+
// Result types
|
|
95
95
|
/**
|
|
96
96
|
* Result of `analyze`, `analyzeFromFiles`, and `AnalysisSession.query`.
|
|
97
97
|
*
|
|
@@ -154,7 +154,7 @@ const toModuleJson = (raw) => {
|
|
|
154
154
|
...(raw.moduleComment ? { moduleComment: raw.moduleComment } : {}),
|
|
155
155
|
});
|
|
156
156
|
};
|
|
157
|
-
//
|
|
157
|
+
// Module dispatch
|
|
158
158
|
/**
|
|
159
159
|
* Analyze a single non-Svelte source file and extract module metadata.
|
|
160
160
|
*
|
|
@@ -121,7 +121,11 @@ export interface DeclarationAnalysis {
|
|
|
121
121
|
* Produced by `analyzeExports` in `typescript-exports.ts`.
|
|
122
122
|
*/
|
|
123
123
|
export interface ModuleExportsAnalysis {
|
|
124
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Module-level documentation comment. Always `undefined` for svelte2tsx
|
|
126
|
+
* virtual files — `analyzeSvelteModule` extracts Svelte module comments
|
|
127
|
+
* from the original source instead.
|
|
128
|
+
*/
|
|
125
129
|
moduleComment?: string;
|
|
126
130
|
/** All exported declarations with `@nodocs` flags — consumer filters based on policy. */
|
|
127
131
|
declarations: Array<DeclarationAnalysis>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB,OAAO,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACxC,UAAU,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC,CAAC;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC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,CAAC,CAAC;CAC1B"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
//
|
|
11
|
+
// Serialization
|
|
12
12
|
/**
|
|
13
13
|
* JSON replacer that strips Zod default values for compact serialization.
|
|
14
14
|
*
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
export const compactReplacer = (_key, value) => (Array.isArray(value) && value.length === 0) || value === false ? undefined : value;
|
|
47
|
-
//
|
|
47
|
+
// Display Helpers
|
|
48
48
|
/**
|
|
49
49
|
* Format declaration or member name with generic parameters for display.
|
|
50
50
|
*
|
|
@@ -133,7 +133,7 @@ const pascalCaseFromModulePath = (modulePath) => {
|
|
|
133
133
|
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
134
134
|
.join('');
|
|
135
135
|
};
|
|
136
|
-
//
|
|
136
|
+
// Type Reference Helpers
|
|
137
137
|
/**
|
|
138
138
|
* Escape special regex characters in a string.
|
|
139
139
|
*/
|
|
@@ -218,7 +218,7 @@ export const findTypeReferences = (typeString, declarationNames) => {
|
|
|
218
218
|
}
|
|
219
219
|
return refs;
|
|
220
220
|
};
|
|
221
|
-
//
|
|
221
|
+
// Narrowed Declaration Types
|
|
222
222
|
/**
|
|
223
223
|
* Narrow a declaration by kind for type-safe field access.
|
|
224
224
|
*
|
package/dist/dep-resolver.d.ts
CHANGED
|
@@ -134,8 +134,12 @@ export declare const isNodeBuiltin: (specifier: string) => boolean;
|
|
|
134
134
|
* resolver instance share the cache scope (correct, since resolver state is
|
|
135
135
|
* shared too).
|
|
136
136
|
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
137
|
+
* `ts.resolveModuleName` cannot resolve real `.svelte` files (no compiler
|
|
138
|
+
* option teaches it the extension), so relative and absolute `.svelte`
|
|
139
|
+
* specifiers — with or without the extension written — fall back to manual
|
|
140
|
+
* filesystem resolution against `fromFile`. Non-relative `.svelte` specifiers
|
|
141
|
+
* (tsconfig `paths` aliases, package subpaths) stay unresolved; supply a
|
|
142
|
+
* custom `resolveImport` for those setups.
|
|
139
143
|
*
|
|
140
144
|
* @param compilerOptions - parsed tsconfig (from `loadTsconfig`)
|
|
141
145
|
* @param projectRoot - absolute project root for the module-resolution cache
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dep-resolver.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dep-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;
|
|
1
|
+
{"version":3,"file":"dep-resolver.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/dep-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;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,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC9B,uEAAuE;IACvE,OAAO,EAAE,eAAe,CAAC;IACzB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GAClC,OAAO,aAAa,GAAG,SAAS,KAC9B,cAAc,GAAG,SAC6E,CAAC;AAElG;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,IAAI,CAErD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,MAAM,EAAE,QAAQ,MAAM,KAAG,KAAK,CAAC,MAAM,CAOxE,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,WAAW,MAAM,KAAG,OAA+B,CAAC;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,qBAAqB,GACjC,iBAAiB,EAAE,CAAC,eAAe,EACnC,aAAa,MAAM,KACjB,cAsBF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,GAC7B,eAAe,eAAe,EAC9B,WAAU,MAAM,GAAG,MAA0B,KAC3C,cAGD,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,cAG5B,CAAC"}
|
package/dist/dep-resolver.js
CHANGED
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
29
|
import { isBuiltin } from 'node:module';
|
|
30
|
+
import { dirname, isAbsolute, resolve as resolvePath } from 'node:path';
|
|
30
31
|
import ts from 'typescript';
|
|
31
32
|
import { init as esModuleLexerInit, parse as esModuleLexerParse } from 'es-module-lexer';
|
|
33
|
+
import { toPosixPath } from './paths.js';
|
|
32
34
|
/**
|
|
33
35
|
* Normalize the public `ResolveImport` union to an `ImportResolver`.
|
|
34
36
|
*
|
|
@@ -92,8 +94,12 @@ export const isNodeBuiltin = (specifier) => isBuiltin(specifier);
|
|
|
92
94
|
* resolver instance share the cache scope (correct, since resolver state is
|
|
93
95
|
* shared too).
|
|
94
96
|
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
+
* `ts.resolveModuleName` cannot resolve real `.svelte` files (no compiler
|
|
98
|
+
* option teaches it the extension), so relative and absolute `.svelte`
|
|
99
|
+
* specifiers — with or without the extension written — fall back to manual
|
|
100
|
+
* filesystem resolution against `fromFile`. Non-relative `.svelte` specifiers
|
|
101
|
+
* (tsconfig `paths` aliases, package subpaths) stay unresolved; supply a
|
|
102
|
+
* custom `resolveImport` for those setups.
|
|
97
103
|
*
|
|
98
104
|
* @param compilerOptions - parsed tsconfig (from `loadTsconfig`)
|
|
99
105
|
* @param projectRoot - absolute project root for the module-resolution cache
|
|
@@ -104,12 +110,16 @@ export const createDefaultResolver = (compilerOptions, projectRoot) => {
|
|
|
104
110
|
const result = ts.resolveModuleName(specifier, fromFile, compilerOptions, ts.sys, cache);
|
|
105
111
|
if (result.resolvedModule)
|
|
106
112
|
return result.resolvedModule.resolvedFileName;
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
// ts.resolveModuleName never resolves real .svelte files — no compiler
|
|
114
|
+
// option teaches it the extension — so resolve relative/absolute
|
|
115
|
+
// specifiers manually, appending .svelte when it isn't written.
|
|
116
|
+
if (specifier.startsWith('./') || specifier.startsWith('../') || isAbsolute(specifier)) {
|
|
117
|
+
const withExt = specifier.endsWith('.svelte') ? specifier : specifier + '.svelte';
|
|
118
|
+
const candidate = isAbsolute(withExt) ? withExt : resolvePath(dirname(fromFile), withExt);
|
|
119
|
+
// posixified for parity with ts.resolveModuleName, which always
|
|
120
|
+
// returns forward-slash paths
|
|
121
|
+
if (ts.sys.fileExists(candidate))
|
|
122
|
+
return toPosixPath(candidate);
|
|
113
123
|
}
|
|
114
124
|
return null;
|
|
115
125
|
};
|
package/dist/diagnostics.js
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
* @module
|
|
59
59
|
*/
|
|
60
60
|
import { z } from 'zod';
|
|
61
|
-
//
|
|
61
|
+
// Severity
|
|
62
62
|
/**
|
|
63
63
|
* Diagnostic severity levels.
|
|
64
64
|
*
|
|
@@ -66,7 +66,7 @@ import { z } from 'zod';
|
|
|
66
66
|
* - `'warning'` — partial success, something seems off but analysis continued
|
|
67
67
|
*/
|
|
68
68
|
export const DiagnosticSeverity = z.enum(['error', 'warning']);
|
|
69
|
-
//
|
|
69
|
+
// Kind
|
|
70
70
|
/**
|
|
71
71
|
* Discriminant for `Diagnostic` variant types.
|
|
72
72
|
*/
|
|
@@ -86,7 +86,7 @@ export const DiagnosticKind = z.enum([
|
|
|
86
86
|
'transform_failed',
|
|
87
87
|
'resolver_failed',
|
|
88
88
|
]);
|
|
89
|
-
//
|
|
89
|
+
// Variants
|
|
90
90
|
/**
|
|
91
91
|
* Base diagnostic fields shared by every variant.
|
|
92
92
|
*
|
|
@@ -339,7 +339,7 @@ export const Diagnostic = z.discriminatedUnion('kind', [
|
|
|
339
339
|
TransformFailedDiagnostic,
|
|
340
340
|
ResolverFailedDiagnostic,
|
|
341
341
|
]);
|
|
342
|
-
//
|
|
342
|
+
// Helpers
|
|
343
343
|
/**
|
|
344
344
|
* Check if any error-severity diagnostics were collected.
|
|
345
345
|
*/
|
package/dist/exports.js
CHANGED
|
@@ -14,10 +14,10 @@ import { join, relative, resolve } from 'node:path';
|
|
|
14
14
|
import { glob } from 'tinyglobby';
|
|
15
15
|
import { toPosixPath } from './paths.js';
|
|
16
16
|
import { MAX_FILE_CONCURRENCY, map_concurrent } from './concurrency.js';
|
|
17
|
-
//
|
|
17
|
+
// Condition priority
|
|
18
18
|
/** Priority order for selecting the condition to use for source mapping. */
|
|
19
19
|
const CONDITION_PRIORITY = ['svelte', 'default', 'import', 'require'];
|
|
20
|
-
//
|
|
20
|
+
// Parsing
|
|
21
21
|
/**
|
|
22
22
|
* Read and parse the exports field from package.json.
|
|
23
23
|
*
|
|
@@ -85,7 +85,7 @@ const flattenConditions = (value, prefix) => {
|
|
|
85
85
|
}
|
|
86
86
|
return null;
|
|
87
87
|
};
|
|
88
|
-
//
|
|
88
|
+
// Source mapping
|
|
89
89
|
/**
|
|
90
90
|
* Map a dist file path to its source file path.
|
|
91
91
|
*
|
|
@@ -131,7 +131,7 @@ export const mapDistToSource = (distPath, condition, options) => {
|
|
|
131
131
|
}
|
|
132
132
|
return sourceBase;
|
|
133
133
|
};
|
|
134
|
-
//
|
|
134
|
+
// Discovery
|
|
135
135
|
/**
|
|
136
136
|
* Select the best condition for source mapping from an export entry.
|
|
137
137
|
*/
|
package/dist/index.js
CHANGED
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @module
|
|
10
10
|
*/
|
|
11
|
-
//
|
|
11
|
+
// Core entry points
|
|
12
12
|
export { analyze, analyzeFromFiles } from './analyze.js';
|
|
13
13
|
export { throwOnDuplicates, AnalyzeResultJson } from './analyze-core.js';
|
|
14
14
|
export { createAnalysisSession } from './session.js';
|
|
15
15
|
export { normalizeResolveImport } from './dep-resolver.js';
|
|
16
|
-
//
|
|
16
|
+
// Types (Zod schemas + TypeScript interfaces)
|
|
17
17
|
export { DeclarationKind, DeclarationModifier, MemberKind, Reactivity, GenericParamJson, ParameterJson, ComponentPropJson, OverloadJson, FunctionMemberJson, VariableMemberJson, ConstructorMemberJson, MemberJson, FunctionDeclarationJson, ClassDeclarationJson, InterfaceDeclarationJson, TypeDeclarationJson, VariableDeclarationJson, EnumDeclarationJson, ComponentDeclarationJson, SnippetDeclarationJson, NamespaceDeclarationJson, DeclarationJson, ReExportJson, ExternalReExportJson, ModuleJson, } from './types.js';
|
|
18
|
-
//
|
|
18
|
+
// Declaration helpers
|
|
19
19
|
export { getDisplayName, generateImport, compactReplacer, isKind, findTypeReferences, buildTypeReferencePatterns, } from './declaration-helpers.js';
|
|
20
|
-
//
|
|
20
|
+
// Source options
|
|
21
21
|
export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
|
|
22
|
-
//
|
|
22
|
+
// Post-processing
|
|
23
23
|
export { findDuplicates, mergeReExports, resolveComponentAliases, resolveExportSurface, } from './postprocess.js';
|
|
24
|
-
//
|
|
24
|
+
// File system constants
|
|
25
25
|
export { deriveIncludePatterns } from './files.js';
|
|
26
|
-
//
|
|
26
|
+
// File discovery
|
|
27
27
|
export { discoverSourceFiles } from './discovery.js';
|
|
28
|
-
//
|
|
28
|
+
// Diagnostics
|
|
29
29
|
export { hasErrors, hasWarnings, errorsOf, warningsOf, byKind, formatDiagnostic, DiagnosticSeverity, DiagnosticKind, Diagnostic, } from './diagnostics.js';
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAIN,KAAK,8BAA8B,EACnC,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAE1C,OAAO,EAEN,KAAK,aAAa,EAMlB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,EAAC,KAAK,mBAAmB,EAAmC,MAAM,oBAAoB,CAAC;AAG9F,OAAO,EAGN,iBAAiB,EACjB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAG3B;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC9B;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC7B,qFAAqF;IACrF,OAAO,EAAE,OAAO,CAAC;IACjB,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC9B;;;;OAIG;IACH,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,0EAA0E;IAC1E,YA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eAAe;IAC/B;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7E;;;OAGG;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;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,iBAAiB,CAAC;IAC9C;;;;;;;;OAQG;IACH,oBAAoB,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAC1C;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CACnD,8BAA8B,EAC9B,aAAa,GAAG,cAAc,CAC9B;IACA;;;;;;;;;OASG;IACH,aAAa,EAAE,mBAAmB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,kDAAkD;IAClD,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AA+FD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,sBAAsB,KAAG,eAsdvE,CAAC"}
|
package/dist/session.js
CHANGED
|
@@ -133,7 +133,7 @@ export const createAnalysisSession = (options) => {
|
|
|
133
133
|
return sessionDefaultResolver;
|
|
134
134
|
return getDefaultResolver();
|
|
135
135
|
};
|
|
136
|
-
//
|
|
136
|
+
// Phase 1: sync per-file transform/lex
|
|
137
137
|
// `resolver` is `null` when the entire batch is pre-resolved — phase 1
|
|
138
138
|
// needs no resolver identity in that case, and skipping `pickResolver`
|
|
139
139
|
// avoids constructing the lazy default for fully pre-resolved consumers.
|
|
@@ -231,7 +231,7 @@ export const createAnalysisSession = (options) => {
|
|
|
231
231
|
preResolvedDeps: usePreResolved ? preResolvedDeps : undefined,
|
|
232
232
|
};
|
|
233
233
|
};
|
|
234
|
-
//
|
|
234
|
+
// Phase 3: serial per-file LS push + entry write
|
|
235
235
|
const phase3 = (pending, resolved) => {
|
|
236
236
|
if (pending.cacheHit) {
|
|
237
237
|
// Cached SetFileResult: same diagnostics array reference, changed: false.
|
|
@@ -247,13 +247,16 @@ export const createAnalysisSession = (options) => {
|
|
|
247
247
|
// Build `unfilteredDeps` from one of two sources:
|
|
248
248
|
// pre-resolved → caller's `file.dependencies`, posixified + filtered
|
|
249
249
|
// lex+resolve → resolver task outputs, already posixified, filtered
|
|
250
|
-
|
|
250
|
+
// The Set dedupes in first-occurrence order — multiple statements
|
|
251
|
+
// importing the same module (or a duplicate caller-declared edge) are
|
|
252
|
+
// one edge.
|
|
253
|
+
const depSet = new Set();
|
|
251
254
|
if (pending.preResolvedDeps !== undefined) {
|
|
252
255
|
for (const raw of pending.preResolvedDeps) {
|
|
253
256
|
const posix = toPosixPath(raw);
|
|
254
257
|
if (!isSource(posix, sourceOptions))
|
|
255
258
|
continue;
|
|
256
|
-
|
|
259
|
+
depSet.add(posix);
|
|
257
260
|
}
|
|
258
261
|
}
|
|
259
262
|
else {
|
|
@@ -262,9 +265,10 @@ export const createAnalysisSession = (options) => {
|
|
|
262
265
|
continue;
|
|
263
266
|
if (!isSource(r, sourceOptions))
|
|
264
267
|
continue;
|
|
265
|
-
|
|
268
|
+
depSet.add(r);
|
|
266
269
|
}
|
|
267
270
|
}
|
|
271
|
+
const unfilteredDeps = [...depSet];
|
|
268
272
|
// Build a mode-specific entry. The discriminator (`mode`) tags which
|
|
269
273
|
// cache-key field to read on the next ingest: `resolverIdentity` for
|
|
270
274
|
// lex+resolve, `preResolvedDepsSnapshot` for pre-resolved. Snapshot
|
|
@@ -310,7 +314,7 @@ export const createAnalysisSession = (options) => {
|
|
|
310
314
|
}
|
|
311
315
|
return { changed: true, diagnostics: [...pending.ingestDiagnostics] };
|
|
312
316
|
};
|
|
313
|
-
//
|
|
317
|
+
// setFiles: orchestrate three phases
|
|
314
318
|
const setFiles = async (files, opts) => {
|
|
315
319
|
await ensureLexerReady();
|
|
316
320
|
// Resolver gating: pick one only if any file in the batch lacks
|
package/dist/svelte.d.ts
CHANGED
|
@@ -90,6 +90,16 @@ export declare const transformSvelteSource: (sourceFile: SourceFileInfo) => Tran
|
|
|
90
90
|
* @returns the script tag content, or undefined if no matching script tag is found
|
|
91
91
|
*/
|
|
92
92
|
export declare const extractScriptContent: (svelteSource: string) => string | undefined;
|
|
93
|
+
/**
|
|
94
|
+
* Extract the content of the module `<script>` tag from Svelte source.
|
|
95
|
+
*
|
|
96
|
+
* Counterpart of `extractScriptContent` with the same attribute test inverted:
|
|
97
|
+
* matches only module scripts (`<script module>`, `<script context="module">`),
|
|
98
|
+
* so the two partition a source's script tags consistently.
|
|
99
|
+
*
|
|
100
|
+
* @returns the module script tag content, or undefined if no module script is found
|
|
101
|
+
*/
|
|
102
|
+
export declare const extractModuleScriptContent: (svelteSource: string) => string | undefined;
|
|
93
103
|
/**
|
|
94
104
|
* Extract `@module` comment from HTML comments in Svelte source.
|
|
95
105
|
*
|
|
@@ -105,9 +115,11 @@ export declare const extractHtmlModuleComment: (svelteSource: string) => string
|
|
|
105
115
|
* Extract module-level comment from Svelte script content.
|
|
106
116
|
*
|
|
107
117
|
* Parses the script content as TypeScript and delegates to `extractModuleComment`
|
|
108
|
-
* for the shared `@module` tag detection logic.
|
|
118
|
+
* for the shared `@module` tag detection logic. Works on either script's
|
|
119
|
+
* content — instance `<script>` and `<script module>` (see
|
|
120
|
+
* `extractScriptContent`/`extractModuleScriptContent`).
|
|
109
121
|
*
|
|
110
|
-
* @param scriptContent - the content of
|
|
122
|
+
* @param scriptContent - the content of a `<script>` or `<script module>` tag
|
|
111
123
|
* @returns the cleaned module comment text, or undefined if none found
|
|
112
124
|
*/
|
|
113
125
|
export declare const extractSvelteModuleComment: (scriptContent: string) => string | undefined;
|
package/dist/svelte.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAC,QAAQ,EAAsB,MAAM,2BAA2B,CAAC;AAGxE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAA2C,kBAAkB,EAAC,MAAM,YAAY,CAAC;AAC7F,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAAC,KAAK,cAAc,EAA0C,MAAM,aAAa,CAAC;AACzF,OAAO,EAAC,KAAK,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAC,KAAK,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAGjD,0FAA0F;AAC1F,KAAK,SAAS,GAAG,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IACjC,gEAAgE;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,sGAAsG;IACtG,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,eAAe;IAC/B,OAAO,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACvC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC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tualSource, sourceMap) => {
|
|
|
204
204
|
*
|
|
205
205
|
* @returns the script tag content, or undefined if no matching script tag is found
|
|
206
206
|
*/
|
|
207
|
-
export const extractScriptContent = (svelteSource) =>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
207
|
+
export const extractScriptContent = (svelteSource) => findScriptContent(svelteSource, false);
|
|
208
|
+
/**
|
|
209
|
+
* Extract the content of the module `<script>` tag from Svelte source.
|
|
210
|
+
*
|
|
211
|
+
* Counterpart of `extractScriptContent` with the same attribute test inverted:
|
|
212
|
+
* matches only module scripts (`<script module>`, `<script context="module">`),
|
|
213
|
+
* so the two partition a source's script tags consistently.
|
|
214
|
+
*
|
|
215
|
+
* @returns the module script tag content, or undefined if no module script is found
|
|
216
|
+
*/
|
|
217
|
+
export const extractModuleScriptContent = (svelteSource) => findScriptContent(svelteSource, true);
|
|
218
|
+
/**
|
|
219
|
+
* Shared scan behind `extractScriptContent`/`extractModuleScriptContent`.
|
|
220
|
+
*
|
|
221
|
+
* A script tag is a module script when its attributes contain the word
|
|
222
|
+
* `module` — covers Svelte 5 `<script module>` (with any `lang`) and
|
|
223
|
+
* Svelte 4 `<script context="module">`.
|
|
224
|
+
*/
|
|
225
|
+
const findScriptContent = (svelteSource, wantModule) => {
|
|
212
226
|
const scriptRegex = /<script(\s+[^>]*)?>([^]*?)<\/script>/gi;
|
|
213
227
|
let match;
|
|
214
228
|
while ((match = scriptRegex.exec(svelteSource)) !== null) {
|
|
215
229
|
const attrs = match[1] ?? '';
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
continue;
|
|
219
|
-
return match[2];
|
|
230
|
+
if (/\bmodule\b/.test(attrs) === wantModule)
|
|
231
|
+
return match[2];
|
|
220
232
|
}
|
|
221
233
|
return undefined;
|
|
222
234
|
};
|
|
@@ -259,9 +271,11 @@ export const extractHtmlModuleComment = (svelteSource) => {
|
|
|
259
271
|
* Extract module-level comment from Svelte script content.
|
|
260
272
|
*
|
|
261
273
|
* Parses the script content as TypeScript and delegates to `extractModuleComment`
|
|
262
|
-
* for the shared `@module` tag detection logic.
|
|
274
|
+
* for the shared `@module` tag detection logic. Works on either script's
|
|
275
|
+
* content — instance `<script>` and `<script module>` (see
|
|
276
|
+
* `extractScriptContent`/`extractModuleScriptContent`).
|
|
263
277
|
*
|
|
264
|
-
* @param scriptContent - the content of
|
|
278
|
+
* @param scriptContent - the content of a `<script>` or `<script module>` tag
|
|
265
279
|
* @returns the cleaned module comment text, or undefined if none found
|
|
266
280
|
*/
|
|
267
281
|
export const extractSvelteModuleComment = (scriptContent) => {
|
|
@@ -464,7 +478,7 @@ const extractPropsMetadata = (virtualSource) => {
|
|
|
464
478
|
visit(virtualSource);
|
|
465
479
|
return { bindableProps, propsDefaults, propsTypeName };
|
|
466
480
|
};
|
|
467
|
-
//
|
|
481
|
+
// Snippet Detection
|
|
468
482
|
/**
|
|
469
483
|
* Check if a type string represents a `Snippet` type.
|
|
470
484
|
*
|
|
@@ -535,7 +549,7 @@ export const synthesizeSnippetTypeSignature = (parameters) => {
|
|
|
535
549
|
const inner = parameters.map((p) => `${p.name}: ${p.type}`).join(', ');
|
|
536
550
|
return `Snippet<[${inner}]>`;
|
|
537
551
|
};
|
|
538
|
-
//
|
|
552
|
+
// Checker-Backed Analysis
|
|
539
553
|
/**
|
|
540
554
|
* Check if a symbol name is an internal svelte2tsx identifier.
|
|
541
555
|
*
|
|
@@ -726,8 +740,13 @@ export const analyzeSvelteModule = (sourceFile, modulePath, checker, options, di
|
|
|
726
740
|
});
|
|
727
741
|
return undefined;
|
|
728
742
|
}
|
|
729
|
-
// 1. Use analyzeExports for full checker-backed analysis (same as .ts files)
|
|
730
|
-
|
|
743
|
+
// 1. Use analyzeExports for full checker-backed analysis (same as .ts files).
|
|
744
|
+
// Its `moduleComment` is undefined for virtuals — the `<script module>`
|
|
745
|
+
// comment is extracted from the original source in step 4, because svelte2tsx
|
|
746
|
+
// hoists instance-script imports (with their leading JSDoc) to the virtual's
|
|
747
|
+
// top level, where an instance `@module` comment would masquerade as a
|
|
748
|
+
// `<script module>` one.
|
|
749
|
+
const { declarations: rawDeclarations, reExports, starExports, externalReExports, externalStarExports, } = analyzeExports(virtualTsSource, checker, options, diagnostics);
|
|
731
750
|
// 2. Filter internal svelte2tsx symbols and the default export (generated component class),
|
|
732
751
|
// and reclassify exported snippets from 'function' to 'snippet'
|
|
733
752
|
const moduleDeclarations = [];
|
|
@@ -903,11 +922,15 @@ export const analyzeSvelteModule = (sourceFile, modulePath, checker, options, di
|
|
|
903
922
|
const instanceModuleComment = scriptContent
|
|
904
923
|
? extractSvelteModuleComment(scriptContent)
|
|
905
924
|
: undefined;
|
|
925
|
+
const moduleScriptContent = extractModuleScriptContent(sourceFile.content);
|
|
926
|
+
const scriptModuleComment = moduleScriptContent
|
|
927
|
+
? extractSvelteModuleComment(moduleScriptContent)
|
|
928
|
+
: undefined;
|
|
906
929
|
const htmlModuleComment = extractHtmlModuleComment(sourceFile.content);
|
|
907
930
|
const moduleComment = instanceModuleComment ?? scriptModuleComment ?? htmlModuleComment;
|
|
908
|
-
// @nodocs has no module-level meaning — warn per misplaced comment
|
|
909
|
-
// <script module> source is covered by analyzeExports on the virtual above.
|
|
931
|
+
// @nodocs has no module-level meaning — warn per misplaced comment
|
|
910
932
|
warnModuleCommentNodocs(instanceModuleComment, modulePath, diagnostics);
|
|
933
|
+
warnModuleCommentNodocs(scriptModuleComment, modulePath, diagnostics);
|
|
911
934
|
warnModuleCommentNodocs(htmlModuleComment, modulePath, diagnostics);
|
|
912
935
|
// Warn if multiple @module sources exist
|
|
913
936
|
const moduleCommentSources = [
|
package/dist/types.js
CHANGED
|
@@ -304,7 +304,7 @@ const functionLikeFields = {
|
|
|
304
304
|
...callableFields,
|
|
305
305
|
...returnFields,
|
|
306
306
|
};
|
|
307
|
-
//
|
|
307
|
+
// MemberJson Variants
|
|
308
308
|
/**
|
|
309
309
|
* A function member (method, call signature, method signature).
|
|
310
310
|
* Has `parameters`, `returnType`, `returnDescription`, `overloads`.
|
|
@@ -380,7 +380,7 @@ export const ConstructorMemberJson = z.strictObject({
|
|
|
380
380
|
* Nesting is exactly one level deep — members never contain their own members.
|
|
381
381
|
*/
|
|
382
382
|
export const MemberJson = z.discriminatedUnion('kind', [FunctionMemberJson, VariableMemberJson, ConstructorMemberJson]);
|
|
383
|
-
//
|
|
383
|
+
// DeclarationJson Variants
|
|
384
384
|
/** Top-level-only fields shared by all `DeclarationJson` variants. */
|
|
385
385
|
const declarationTopLevelFields = {
|
|
386
386
|
/**
|
|
@@ -40,7 +40,8 @@ export declare const analyzeTypescriptModule: (sourceFileInfo: SourceFileInfo &
|
|
|
40
40
|
/**
|
|
41
41
|
* Analyze all exports from a TypeScript source file.
|
|
42
42
|
*
|
|
43
|
-
* Extracts the module-level comment via `extractModuleComment
|
|
43
|
+
* Extracts the module-level comment via `extractModuleComment` (skipped for
|
|
44
|
+
* svelte2tsx virtual files — see the inline note), star exports via
|
|
44
45
|
* `extractStarExports`, and all exported declarations with complete metadata.
|
|
45
46
|
* Handles re-exports by:
|
|
46
47
|
* - Same-name re-exports: tracked in `reExports` for `alsoExportedFrom` building
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript-exports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/typescript-exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EACX,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACN,KAAK,cAAc,EAInB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,KAAK,mBAAmB,EAIxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,KAAK,cAAc,EAAuB,MAAM,yBAAyB,CAAC;AAMlF;;;;;;;;;;;;;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AU,CAAC,KAC5B,qBAgVF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,kBAAkB,GAC9B,QAAQ,EAAE,CAAC,MAAM,EACjB,YAAY,EAAE,CAAC,UAAU,EACzB,SAAS,EAAE,CAAC,WAAW,EACvB,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,gBAAgB,cAAc,KAC5B,mBA+CF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,YAAY,EAAE,CAAC,UAAU,KAAG,MAAM,GAAG,SAqCzE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,eAAe,MAAM,GAAG,SAAS,EACjC,MAAM,MAAM,EACZ,aAAa,KAAK,CAAC,UAAU,CAAC,KAC5B,IAUF,CAAC"}
|
|
@@ -266,7 +266,8 @@ const synthesizeCrossFileAlias = (publicName, aliasedSymbol, originalSource, ori
|
|
|
266
266
|
/**
|
|
267
267
|
* Analyze all exports from a TypeScript source file.
|
|
268
268
|
*
|
|
269
|
-
* Extracts the module-level comment via `extractModuleComment
|
|
269
|
+
* Extracts the module-level comment via `extractModuleComment` (skipped for
|
|
270
|
+
* svelte2tsx virtual files — see the inline note), star exports via
|
|
270
271
|
* `extractStarExports`, and all exported declarations with complete metadata.
|
|
271
272
|
* Handles re-exports by:
|
|
272
273
|
* - Same-name re-exports: tracked in `reExports` for `alsoExportedFrom` building
|
|
@@ -290,13 +291,17 @@ export const analyzeExports = (sourceFile, checker, options, diagnostics) => {
|
|
|
290
291
|
const reExports = [];
|
|
291
292
|
const externalReExports = [];
|
|
292
293
|
const isExternalFile = createIsExternalFile(options);
|
|
293
|
-
// Extract module-level comment
|
|
294
|
-
const moduleComment = extractModuleComment(sourceFile);
|
|
295
294
|
// Extract star exports (export * from './module' / 'pkg')
|
|
296
295
|
const { starExports, externalStarExports } = extractStarExports(sourceFile, checker, options);
|
|
297
296
|
// Normalize virtual paths once (e.g., Foo.svelte.__svelte2tsx__.ts → Foo.svelte)
|
|
298
297
|
// so re-export tracking matches real module paths
|
|
299
298
|
const currentFileName = stripVirtualSuffix(sourceFile.fileName);
|
|
299
|
+
// Extract module-level comment — skipped for svelte2tsx virtuals, where
|
|
300
|
+
// hoisted instance-script comments would read as module comments;
|
|
301
|
+
// `analyzeSvelteModule` extracts the `<script module>` comment from the
|
|
302
|
+
// original source instead (and owns its `@nodocs` warning)
|
|
303
|
+
const isVirtual = currentFileName !== sourceFile.fileName;
|
|
304
|
+
const moduleComment = isVirtual ? undefined : extractModuleComment(sourceFile);
|
|
300
305
|
warnModuleCommentNodocs(moduleComment, currentFileName, diagnostics);
|
|
301
306
|
// 1-based line of a node in this file. Virtual coordinates for Svelte
|
|
302
307
|
// `<script module>` sources — remapped in `analyzeSvelteModule`.
|
package/dist/vite.js
CHANGED
|
@@ -71,7 +71,7 @@ const svelteDocinfo = (options = {}) => {
|
|
|
71
71
|
// runs at cold start). Tracked here because the session has no concept of
|
|
72
72
|
// "discovery" — it ingests files the plugin hands to it.
|
|
73
73
|
let discoveryDiagnostics = [];
|
|
74
|
-
//
|
|
74
|
+
// Resolver wiring
|
|
75
75
|
// Dev resolver: server.pluginContainer.resolveId. Stable identity across
|
|
76
76
|
// the dev session — cache hits work across HMR cycles.
|
|
77
77
|
const viteDevResolver = {
|
|
@@ -86,7 +86,7 @@ const svelteDocinfo = (options = {}) => {
|
|
|
86
86
|
},
|
|
87
87
|
identity: VITE_DEV_IDENTITY,
|
|
88
88
|
};
|
|
89
|
-
//
|
|
89
|
+
// In-flight analysis tracking
|
|
90
90
|
// Initial analysis runs once in buildStart; HMR flushes run on debounce.
|
|
91
91
|
// `load()` awaits both so we never serve stale JSON to a freshly-importing
|
|
92
92
|
// module.
|
|
@@ -182,7 +182,7 @@ const svelteDocinfo = (options = {}) => {
|
|
|
182
182
|
log.error(`[svelte-docinfo] ${message}`);
|
|
183
183
|
};
|
|
184
184
|
const isWatchedFile = (file) => isSource(file, resolvedSourceOptions);
|
|
185
|
-
//
|
|
185
|
+
// Initial analysis (cold start in buildStart)
|
|
186
186
|
const runInitialAnalysis = async () => {
|
|
187
187
|
if (!session)
|
|
188
188
|
return;
|
|
@@ -198,7 +198,7 @@ const svelteDocinfo = (options = {}) => {
|
|
|
198
198
|
const result = session.query({ onDuplicates, log: logger ?? undefined });
|
|
199
199
|
updateOutputFromQuery(result.modules, result.diagnostics);
|
|
200
200
|
};
|
|
201
|
-
//
|
|
201
|
+
// HMR flush: drain pendingChanges via setFiles + query
|
|
202
202
|
const flushBatch = async () => {
|
|
203
203
|
if (initialPromise)
|
|
204
204
|
await initialPromise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-docinfo",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "static analysis for TypeScript and Svelte",
|
|
5
5
|
"glyph": "📜",
|
|
6
6
|
"logo": "logo.svg",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@fuzdev/blake3_wasm": "^0.1.1",
|
|
54
54
|
"@fuzdev/fuz_code": "^0.46.0",
|
|
55
55
|
"@fuzdev/fuz_css": "^0.62.0",
|
|
56
|
-
"@fuzdev/fuz_ui": "^0.
|
|
56
|
+
"@fuzdev/fuz_ui": "^0.203.1",
|
|
57
57
|
"@fuzdev/fuz_util": "^0.65.1",
|
|
58
58
|
"@fuzdev/gro": "^0.204.0",
|
|
59
59
|
"@ryanatkn/eslint-config": "^0.12.1",
|