svelte-docinfo 0.1.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/LICENSE +21 -0
- package/README.md +349 -0
- package/dist/analyze-core.d.ts +1386 -0
- package/dist/analyze-core.d.ts.map +1 -0
- package/dist/analyze-core.js +324 -0
- package/dist/analyze.d.ts +137 -0
- package/dist/analyze.d.ts.map +1 -0
- package/dist/analyze.js +148 -0
- package/dist/cli.d.ts +102 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +206 -0
- package/dist/concurrency.d.ts +38 -0
- package/dist/concurrency.d.ts.map +1 -0
- package/dist/concurrency.js +57 -0
- package/dist/declaration-build.d.ts +164 -0
- package/dist/declaration-build.d.ts.map +1 -0
- package/dist/declaration-build.js +15 -0
- package/dist/declaration-helpers.d.ts +169 -0
- package/dist/declaration-helpers.d.ts.map +1 -0
- package/dist/declaration-helpers.js +239 -0
- package/dist/dep-resolver.d.ts +166 -0
- package/dist/dep-resolver.d.ts.map +1 -0
- package/dist/dep-resolver.js +144 -0
- package/dist/diagnostics.d.ts +650 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +377 -0
- package/dist/discovery.d.ts +115 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +126 -0
- package/dist/exports.d.ts +105 -0
- package/dist/exports.d.ts.map +1 -0
- package/dist/exports.js +274 -0
- package/dist/files.d.ts +77 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +95 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/log.d.ts +32 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +11 -0
- package/dist/logo.d.ts +8 -0
- package/dist/logo.d.ts.map +1 -0
- package/dist/logo.js +9 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +18 -0
- package/dist/paths.d.ts +35 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +34 -0
- package/dist/postprocess.d.ts +145 -0
- package/dist/postprocess.d.ts.map +1 -0
- package/dist/postprocess.js +305 -0
- package/dist/session.d.ts +248 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +496 -0
- package/dist/source-config.d.ts +330 -0
- package/dist/source-config.d.ts.map +1 -0
- package/dist/source-config.js +356 -0
- package/dist/source.d.ts +126 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +68 -0
- package/dist/svelte.d.ts +179 -0
- package/dist/svelte.d.ts.map +1 -0
- package/dist/svelte.js +898 -0
- package/dist/tsdoc.d.ts +145 -0
- package/dist/tsdoc.d.ts.map +1 -0
- package/dist/tsdoc.js +262 -0
- package/dist/types.d.ts +3381 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +588 -0
- package/dist/typescript-exports.d.ts +91 -0
- package/dist/typescript-exports.d.ts.map +1 -0
- package/dist/typescript-exports.js +656 -0
- package/dist/typescript-extract-class.d.ts +29 -0
- package/dist/typescript-extract-class.d.ts.map +1 -0
- package/dist/typescript-extract-class.js +251 -0
- package/dist/typescript-extract-function.d.ts +47 -0
- package/dist/typescript-extract-function.d.ts.map +1 -0
- package/dist/typescript-extract-function.js +108 -0
- package/dist/typescript-extract-shared.d.ts +166 -0
- package/dist/typescript-extract-shared.d.ts.map +1 -0
- package/dist/typescript-extract-shared.js +528 -0
- package/dist/typescript-extract-type-properties.d.ts +34 -0
- package/dist/typescript-extract-type-properties.d.ts.map +1 -0
- package/dist/typescript-extract-type-properties.js +241 -0
- package/dist/typescript-extract-type.d.ts +48 -0
- package/dist/typescript-extract-type.d.ts.map +1 -0
- package/dist/typescript-extract-type.js +238 -0
- package/dist/typescript-program.d.ts +211 -0
- package/dist/typescript-program.d.ts.map +1 -0
- package/dist/typescript-program.js +290 -0
- package/dist/vite.d.ts +116 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +418 -0
- package/package.json +131 -0
- package/virtual-svelte-docinfo.d.ts +49 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package.json exports field discovery for source files.
|
|
3
|
+
*
|
|
4
|
+
* Maps dist paths in package.json `exports` to source file paths,
|
|
5
|
+
* enabling zero-config file discovery without glob patterns.
|
|
6
|
+
*
|
|
7
|
+
* @see `source.ts` for `SourceFileInfo`
|
|
8
|
+
* @see `analyze.ts` for `analyzeFromFiles` (primary consumer)
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { SourceFileInfo } from './source.js';
|
|
13
|
+
import type { Diagnostic } from './diagnostics.js';
|
|
14
|
+
/**
|
|
15
|
+
* A parsed entry from package.json exports field.
|
|
16
|
+
*/
|
|
17
|
+
export interface ExportEntry {
|
|
18
|
+
/** The export specifier (e.g., `"."`, `"./*.js"`). */
|
|
19
|
+
specifier: string;
|
|
20
|
+
/** Whether the specifier contains a wildcard (`*`). */
|
|
21
|
+
isPattern: boolean;
|
|
22
|
+
/** Resolved dist paths by condition (e.g., `{types: "./dist/index.d.ts", default: "./dist/index.js"}`). */
|
|
23
|
+
conditions: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Options for `discoverFromExports`.
|
|
27
|
+
*/
|
|
28
|
+
export interface ExportsDiscoveryOptions {
|
|
29
|
+
/** Absolute path to project root. */
|
|
30
|
+
projectRoot: string;
|
|
31
|
+
/** Dist directory name relative to projectRoot. Default: `'dist'`. */
|
|
32
|
+
distDir?: string;
|
|
33
|
+
/** Source directory name relative to projectRoot. Default: `'src/lib'`. */
|
|
34
|
+
sourceDir?: string;
|
|
35
|
+
/** Glob patterns to exclude from discovered files. */
|
|
36
|
+
exclude?: Array<string>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Result of discovering source files from package.json exports.
|
|
40
|
+
*
|
|
41
|
+
* Self-contained: includes both the discovered files and any error diagnostics
|
|
42
|
+
* (e.g., files that exist but could not be read).
|
|
43
|
+
*/
|
|
44
|
+
export interface ExportsDiscoveryResult {
|
|
45
|
+
/**
|
|
46
|
+
* Discovered source files, or `null` if no exports field found.
|
|
47
|
+
* Empty array means exports field exists but resolved no source files
|
|
48
|
+
* (likely a misconfigured dist-to-source mapping).
|
|
49
|
+
*/
|
|
50
|
+
files: Array<SourceFileInfo> | null;
|
|
51
|
+
/** Error diagnostics for files that exist but could not be read. */
|
|
52
|
+
diagnostics: Array<Diagnostic>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Result of reading and parsing package.json exports.
|
|
56
|
+
*/
|
|
57
|
+
export interface ParsedExports {
|
|
58
|
+
/** All parsed export entries. */
|
|
59
|
+
entries: Array<ExportEntry>;
|
|
60
|
+
/** Whether the package.json had an exports field. */
|
|
61
|
+
hasExports: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read and parse the exports field from package.json.
|
|
65
|
+
*
|
|
66
|
+
* Handles all Node.js export formats: strings, objects with conditions,
|
|
67
|
+
* nested conditions, null exclusions, and wildcard patterns.
|
|
68
|
+
*
|
|
69
|
+
* @param projectRoot - absolute path to project root
|
|
70
|
+
* @returns parsed `ParsedExports`, or `{entries: [], hasExports: false}` if no exports field
|
|
71
|
+
*/
|
|
72
|
+
export declare const parsePackageExports: (projectRoot: string) => Promise<ParsedExports>;
|
|
73
|
+
/**
|
|
74
|
+
* Map a dist file path to its source file path.
|
|
75
|
+
*
|
|
76
|
+
* Replaces the dist directory prefix with the source directory and maps
|
|
77
|
+
* file extensions based on the export condition.
|
|
78
|
+
*
|
|
79
|
+
* @param distPath - the dist path from exports (e.g., `"./dist/index.js"`)
|
|
80
|
+
* @param condition - the export condition (e.g., `"default"`, `"svelte"`, `"types"`)
|
|
81
|
+
* @param options - mapping configuration
|
|
82
|
+
* @returns source path relative to project root, or null if not mappable
|
|
83
|
+
*/
|
|
84
|
+
export declare const mapDistToSource: (distPath: string, condition: string, options: {
|
|
85
|
+
distDir: string;
|
|
86
|
+
sourceDir: string;
|
|
87
|
+
}) => string | null;
|
|
88
|
+
/**
|
|
89
|
+
* Discover source files using package.json exports field.
|
|
90
|
+
*
|
|
91
|
+
* Reads package.json, parses exports, maps dist paths to source paths,
|
|
92
|
+
* expands wildcard patterns, and loads file content.
|
|
93
|
+
*
|
|
94
|
+
* Returns `{files: null}` when no package.json or no exports field exists,
|
|
95
|
+
* signaling the caller to fall back to glob discovery. Returns `{files: []}`
|
|
96
|
+
* when exports exist but resolve no source files (likely misconfigured mapping).
|
|
97
|
+
*
|
|
98
|
+
* For concrete exports, maps directly to source paths and verifies existence.
|
|
99
|
+
* For wildcard exports, globs the source directory for matching files.
|
|
100
|
+
*
|
|
101
|
+
* @param options - discovery configuration
|
|
102
|
+
* @returns `ExportsDiscoveryResult` with discovered files and any error diagnostics
|
|
103
|
+
*/
|
|
104
|
+
export declare const discoverFromExports: (options: ExportsDiscoveryOptions) => Promise<ExportsDiscoveryResult>;
|
|
105
|
+
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/exports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAMjD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,2GAA2G;IAC3G,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;;OAIG;IACH,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACpC,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,iCAAiC;IACjC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC5B,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAC;CACpB;AASD;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAU,aAAa,MAAM,KAAG,OAAO,CAAC,aAAa,CA+BpF,CAAC;AAiCF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC3B,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,SAAS;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,KAC3C,MAAM,GAAG,IAwCX,CAAC;AAkBF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,sBAAsB,CA0DhC,CAAC"}
|
package/dist/exports.js
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package.json exports field discovery for source files.
|
|
3
|
+
*
|
|
4
|
+
* Maps dist paths in package.json `exports` to source file paths,
|
|
5
|
+
* enabling zero-config file discovery without glob patterns.
|
|
6
|
+
*
|
|
7
|
+
* @see `source.ts` for `SourceFileInfo`
|
|
8
|
+
* @see `analyze.ts` for `analyzeFromFiles` (primary consumer)
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { readFile, access } from 'node:fs/promises';
|
|
13
|
+
import { join, relative, resolve } from 'node:path';
|
|
14
|
+
import { glob } from 'tinyglobby';
|
|
15
|
+
import { toPosixPath } from './paths.js';
|
|
16
|
+
import { MAX_FILE_CONCURRENCY, map_concurrent } from './concurrency.js';
|
|
17
|
+
// ── Condition priority ───────────────────────────────────────────────────────
|
|
18
|
+
/** Priority order for selecting the condition to use for source mapping. */
|
|
19
|
+
const CONDITION_PRIORITY = ['svelte', 'default', 'import', 'require'];
|
|
20
|
+
// ── Parsing ──────────────────────────────────────────────────────────────────
|
|
21
|
+
/**
|
|
22
|
+
* Read and parse the exports field from package.json.
|
|
23
|
+
*
|
|
24
|
+
* Handles all Node.js export formats: strings, objects with conditions,
|
|
25
|
+
* nested conditions, null exclusions, and wildcard patterns.
|
|
26
|
+
*
|
|
27
|
+
* @param projectRoot - absolute path to project root
|
|
28
|
+
* @returns parsed `ParsedExports`, or `{entries: [], hasExports: false}` if no exports field
|
|
29
|
+
*/
|
|
30
|
+
export const parsePackageExports = async (projectRoot) => {
|
|
31
|
+
let pkg;
|
|
32
|
+
try {
|
|
33
|
+
const content = await readFile(join(projectRoot, 'package.json'), 'utf-8');
|
|
34
|
+
pkg = JSON.parse(content);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return { entries: [], hasExports: false };
|
|
38
|
+
}
|
|
39
|
+
const exportsField = pkg.exports;
|
|
40
|
+
if (!exportsField || typeof exportsField !== 'object') {
|
|
41
|
+
return { entries: [], hasExports: false };
|
|
42
|
+
}
|
|
43
|
+
const entries = [];
|
|
44
|
+
for (const [specifier, value] of Object.entries(exportsField)) {
|
|
45
|
+
// Skip package.json self-reference
|
|
46
|
+
if (specifier === './package.json')
|
|
47
|
+
continue;
|
|
48
|
+
const conditions = flattenConditions(value);
|
|
49
|
+
if (!conditions)
|
|
50
|
+
continue; // null exclusion or unparseable
|
|
51
|
+
entries.push({
|
|
52
|
+
specifier,
|
|
53
|
+
isPattern: specifier.includes('*'),
|
|
54
|
+
conditions,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return { entries, hasExports: true };
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Flatten a possibly-nested export value into a flat conditions record.
|
|
61
|
+
*
|
|
62
|
+
* @returns flat conditions record, or null for explicit exclusions
|
|
63
|
+
*/
|
|
64
|
+
const flattenConditions = (value, prefix) => {
|
|
65
|
+
// Null = explicit exclusion
|
|
66
|
+
if (value === null || value === undefined)
|
|
67
|
+
return null;
|
|
68
|
+
// String = direct path (condition is the parent key, or 'default')
|
|
69
|
+
if (typeof value === 'string') {
|
|
70
|
+
return { [prefix ?? 'default']: value };
|
|
71
|
+
}
|
|
72
|
+
// Object = conditions map (possibly nested)
|
|
73
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
74
|
+
const result = {};
|
|
75
|
+
for (const [key, nested] of Object.entries(value)) {
|
|
76
|
+
const flattened = flattenConditions(nested, key);
|
|
77
|
+
if (flattened) {
|
|
78
|
+
Object.assign(result, flattened);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
};
|
|
85
|
+
// ── Source mapping ───────────────────────────────────────────────────────────
|
|
86
|
+
/**
|
|
87
|
+
* Map a dist file path to its source file path.
|
|
88
|
+
*
|
|
89
|
+
* Replaces the dist directory prefix with the source directory and maps
|
|
90
|
+
* file extensions based on the export condition.
|
|
91
|
+
*
|
|
92
|
+
* @param distPath - the dist path from exports (e.g., `"./dist/index.js"`)
|
|
93
|
+
* @param condition - the export condition (e.g., `"default"`, `"svelte"`, `"types"`)
|
|
94
|
+
* @param options - mapping configuration
|
|
95
|
+
* @returns source path relative to project root, or null if not mappable
|
|
96
|
+
*/
|
|
97
|
+
export const mapDistToSource = (distPath, condition, options) => {
|
|
98
|
+
const { distDir, sourceDir } = options;
|
|
99
|
+
// Skip types-only conditions (not source files)
|
|
100
|
+
if (condition === 'types')
|
|
101
|
+
return null;
|
|
102
|
+
// Normalize: strip leading ./
|
|
103
|
+
const normalized = distPath.replace(/^\.\//, '');
|
|
104
|
+
// Must start with dist dir
|
|
105
|
+
if (!normalized.startsWith(distDir + '/'))
|
|
106
|
+
return null;
|
|
107
|
+
// Replace dist prefix with source prefix. Empty `sourceDir` (the
|
|
108
|
+
// no-common-prefix sourcePaths case where `getSourceRoot` returns `''`)
|
|
109
|
+
// means "source files live at project root" — emit `relPath` directly
|
|
110
|
+
// rather than `'/relPath'`, which would resolve as an absolute path and
|
|
111
|
+
// fail every `fileExists` check.
|
|
112
|
+
const relPath = normalized.slice(distDir.length + 1);
|
|
113
|
+
const sourceBase = sourceDir ? `${sourceDir}/${relPath}` : relPath;
|
|
114
|
+
// Extension mapping based on condition
|
|
115
|
+
if (condition === 'svelte') {
|
|
116
|
+
// Svelte condition → keep .svelte extension
|
|
117
|
+
return sourceBase;
|
|
118
|
+
}
|
|
119
|
+
if (sourceBase.endsWith('.css')) {
|
|
120
|
+
return sourceBase;
|
|
121
|
+
}
|
|
122
|
+
if (sourceBase.endsWith('.json')) {
|
|
123
|
+
return sourceBase;
|
|
124
|
+
}
|
|
125
|
+
// .js → .ts (primary), .js (fallback — handled by caller checking existence)
|
|
126
|
+
if (sourceBase.endsWith('.js')) {
|
|
127
|
+
return sourceBase.replace(/\.js$/, '.ts');
|
|
128
|
+
}
|
|
129
|
+
return sourceBase;
|
|
130
|
+
};
|
|
131
|
+
// ── Discovery ────────────────────────────────────────────────────────────────
|
|
132
|
+
/**
|
|
133
|
+
* Select the best condition for source mapping from an export entry.
|
|
134
|
+
*/
|
|
135
|
+
const selectCondition = (conditions) => {
|
|
136
|
+
for (const key of CONDITION_PRIORITY) {
|
|
137
|
+
if (key in conditions)
|
|
138
|
+
return [key, conditions[key]];
|
|
139
|
+
}
|
|
140
|
+
// Fall back to first non-types condition
|
|
141
|
+
for (const [key, value] of Object.entries(conditions)) {
|
|
142
|
+
if (key !== 'types')
|
|
143
|
+
return [key, value];
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Discover source files using package.json exports field.
|
|
149
|
+
*
|
|
150
|
+
* Reads package.json, parses exports, maps dist paths to source paths,
|
|
151
|
+
* expands wildcard patterns, and loads file content.
|
|
152
|
+
*
|
|
153
|
+
* Returns `{files: null}` when no package.json or no exports field exists,
|
|
154
|
+
* signaling the caller to fall back to glob discovery. Returns `{files: []}`
|
|
155
|
+
* when exports exist but resolve no source files (likely misconfigured mapping).
|
|
156
|
+
*
|
|
157
|
+
* For concrete exports, maps directly to source paths and verifies existence.
|
|
158
|
+
* For wildcard exports, globs the source directory for matching files.
|
|
159
|
+
*
|
|
160
|
+
* @param options - discovery configuration
|
|
161
|
+
* @returns `ExportsDiscoveryResult` with discovered files and any error diagnostics
|
|
162
|
+
*/
|
|
163
|
+
export const discoverFromExports = async (options) => {
|
|
164
|
+
const { projectRoot, distDir = 'dist', sourceDir = 'src/lib', exclude } = options;
|
|
165
|
+
const parsed = await parsePackageExports(projectRoot);
|
|
166
|
+
if (!parsed.hasExports)
|
|
167
|
+
return { files: null, diagnostics: [] };
|
|
168
|
+
const mappingOptions = { distDir, sourceDir };
|
|
169
|
+
const discovered = new Map(); // absolute path → relative source path
|
|
170
|
+
for (const entry of parsed.entries) {
|
|
171
|
+
const selected = selectCondition(entry.conditions);
|
|
172
|
+
if (!selected)
|
|
173
|
+
continue;
|
|
174
|
+
const [condition, distPath] = selected;
|
|
175
|
+
if (entry.isPattern) {
|
|
176
|
+
// Wildcard: expand via glob
|
|
177
|
+
await expandWildcardExport(distPath, condition, mappingOptions, projectRoot, exclude, discovered);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// Concrete: map directly
|
|
181
|
+
await resolveConcreteExport(distPath, condition, mappingOptions, projectRoot, discovered);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (discovered.size === 0)
|
|
185
|
+
return { files: [], diagnostics: [] };
|
|
186
|
+
// Load file contents with bounded concurrency to keep FD pressure under
|
|
187
|
+
// the typical ulimit on large projects. See `concurrency.ts`.
|
|
188
|
+
const diagnostics = [];
|
|
189
|
+
const absPaths = Array.from(discovered.keys());
|
|
190
|
+
const results = await map_concurrent(absPaths, MAX_FILE_CONCURRENCY, async (absPath) => {
|
|
191
|
+
try {
|
|
192
|
+
const content = await readFile(absPath, 'utf-8');
|
|
193
|
+
return { id: absPath, content };
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
diagnostics.push({
|
|
197
|
+
kind: 'module_unreadable',
|
|
198
|
+
severity: 'error',
|
|
199
|
+
file: toPosixPath(relative(projectRoot, absPath)),
|
|
200
|
+
message: `Could not read file discovered via package.json exports: ${err instanceof Error ? err.message : String(err)}`,
|
|
201
|
+
});
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
const files = results.filter((r) => r !== null);
|
|
206
|
+
return { files, diagnostics };
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Resolve a concrete (non-wildcard) export entry to a source file.
|
|
210
|
+
*/
|
|
211
|
+
const resolveConcreteExport = async (distPath, condition, mappingOptions, projectRoot, discovered) => {
|
|
212
|
+
const sourcePath = mapDistToSource(distPath, condition, mappingOptions);
|
|
213
|
+
if (!sourcePath)
|
|
214
|
+
return;
|
|
215
|
+
const absPath = toPosixPath(resolve(projectRoot, sourcePath));
|
|
216
|
+
if (discovered.has(absPath))
|
|
217
|
+
return;
|
|
218
|
+
// Check existence — try .ts first, fall back to .js
|
|
219
|
+
if (await fileExists(absPath)) {
|
|
220
|
+
discovered.set(absPath, sourcePath);
|
|
221
|
+
}
|
|
222
|
+
else if (sourcePath.endsWith('.ts')) {
|
|
223
|
+
const jsPath = sourcePath.replace(/\.ts$/, '.js');
|
|
224
|
+
const absJs = toPosixPath(resolve(projectRoot, jsPath));
|
|
225
|
+
if (await fileExists(absJs)) {
|
|
226
|
+
discovered.set(absJs, jsPath);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Expand a wildcard export pattern to matching source files.
|
|
232
|
+
*/
|
|
233
|
+
const expandWildcardExport = async (distPath, condition, mappingOptions, projectRoot, exclude, discovered) => {
|
|
234
|
+
const sourcePattern = mapDistToSource(distPath, condition, mappingOptions);
|
|
235
|
+
if (!sourcePattern)
|
|
236
|
+
return;
|
|
237
|
+
// Convert mapped pattern to glob: "src/lib/*.ts" is already a valid glob
|
|
238
|
+
const patterns = [sourcePattern];
|
|
239
|
+
// For .ts patterns, also try .svelte and .js
|
|
240
|
+
if (sourcePattern.endsWith('.ts')) {
|
|
241
|
+
patterns.push(sourcePattern.replace(/\.ts$/, '.svelte'));
|
|
242
|
+
patterns.push(sourcePattern.replace(/\.ts$/, '.js'));
|
|
243
|
+
// Also try CSS
|
|
244
|
+
patterns.push(sourcePattern.replace(/\.ts$/, '.css'));
|
|
245
|
+
}
|
|
246
|
+
const filePaths = await glob(patterns, {
|
|
247
|
+
cwd: projectRoot,
|
|
248
|
+
ignore: exclude,
|
|
249
|
+
absolute: true,
|
|
250
|
+
});
|
|
251
|
+
for (const rawAbsPath of filePaths) {
|
|
252
|
+
// Posixify before keying — tinyglobby returns native separators on
|
|
253
|
+
// Windows; the rest of the pipeline expects POSIX absolute paths.
|
|
254
|
+
const absPath = toPosixPath(rawAbsPath);
|
|
255
|
+
if (!discovered.has(absPath)) {
|
|
256
|
+
// Compute relative source path from absolute. Both sides are POSIX
|
|
257
|
+
// at this point, so the slice produces a forward-slash relative path.
|
|
258
|
+
const relPath = absPath.slice(projectRoot.length + 1);
|
|
259
|
+
discovered.set(absPath, relPath);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Check if a file exists.
|
|
265
|
+
*/
|
|
266
|
+
const fileExists = async (path) => {
|
|
267
|
+
try {
|
|
268
|
+
await access(path);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
};
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File system helpers — file loading and glob discovery.
|
|
3
|
+
*
|
|
4
|
+
* Composable primitives for `analyzeFromFiles` / `discoverSourceFiles`. For
|
|
5
|
+
* most use cases prefer those higher-level entry points.
|
|
6
|
+
*
|
|
7
|
+
* Build tools that want to drive resolve outside the session can construct an
|
|
8
|
+
* `ImportResolver` directly and pass it to `createAnalysisSession`.
|
|
9
|
+
*
|
|
10
|
+
* @see `analyzeFromFiles` for the high-level disk-discovery wrapper
|
|
11
|
+
* @see `discoverSourceFiles` for exports-first discovery with glob fallback
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import type { SourceFileInfo } from './source.js';
|
|
16
|
+
/**
|
|
17
|
+
* Load a single source file from disk.
|
|
18
|
+
*
|
|
19
|
+
* Accepts either relative or absolute paths. Relative paths are resolved against `projectRoot`.
|
|
20
|
+
*
|
|
21
|
+
* @param path - file path (relative to `projectRoot` or absolute)
|
|
22
|
+
* @param projectRoot - absolute path to project root
|
|
23
|
+
* @returns source file info with content loaded
|
|
24
|
+
* @throws Error if the file cannot be read (e.g., missing or permission denied)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const file = await loadFile('src/lib/math.ts', process.cwd());
|
|
29
|
+
* // {id: '/abs/path/to/src/lib/math.ts', content: '...'}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const loadFile: (path: string, projectRoot: string) => Promise<SourceFileInfo>;
|
|
33
|
+
/**
|
|
34
|
+
* Build an include pattern array from source paths.
|
|
35
|
+
*
|
|
36
|
+
* Each path becomes a `<path>/**\/*.{ts,js,svelte,css,json}` glob. Used by
|
|
37
|
+
* `discoverSourceFiles` to derive a default `include` from
|
|
38
|
+
* `sourceOptions.sourcePaths` when no explicit pattern is supplied — keeps
|
|
39
|
+
* the glob fallback consistent with custom `sourcePaths` instead of silently
|
|
40
|
+
* defaulting to `src/lib`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* deriveIncludePatterns(['packages/foo', 'packages/bar'])
|
|
45
|
+
* // => ['packages/foo/**\/*.{ts,js,svelte,css,json}', 'packages/bar/**\/*.{ts,js,svelte,css,json}']
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const deriveIncludePatterns: (sourcePaths: ReadonlyArray<string>) => Array<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Options for `globFiles`.
|
|
51
|
+
*/
|
|
52
|
+
export interface GlobFilesOptions {
|
|
53
|
+
/** Absolute path to project root. */
|
|
54
|
+
projectRoot: string;
|
|
55
|
+
/** Glob patterns to include (relative to `projectRoot`). */
|
|
56
|
+
include: Array<string>;
|
|
57
|
+
/** Optional glob patterns to exclude. */
|
|
58
|
+
exclude?: Array<string>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Discover source files via glob patterns.
|
|
62
|
+
*
|
|
63
|
+
* @param options - glob configuration
|
|
64
|
+
* @returns array of source files with content loaded
|
|
65
|
+
* @throws Error if any matched file cannot be read — `Promise.all` rejects on the first read failure
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* const files = await globFiles({
|
|
70
|
+
* projectRoot: process.cwd(),
|
|
71
|
+
* include: deriveIncludePatterns(['src/lib']),
|
|
72
|
+
* exclude: DEFAULT_SOURCE_OPTIONS.exclude,
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare const globFiles: (options: GlobFilesOptions) => Promise<Array<SourceFileInfo>>;
|
|
77
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAMH,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAIhD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,EAAE,aAAa,MAAM,KAAG,OAAO,CAAC,cAAc,CAQxF,CAAC;AASF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAAI,aAAa,aAAa,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,MAAM,CACvB,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,yCAAyC;IACzC,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS,GAAU,SAAS,gBAAgB,KAAG,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAexF,CAAC"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File system helpers — file loading and glob discovery.
|
|
3
|
+
*
|
|
4
|
+
* Composable primitives for `analyzeFromFiles` / `discoverSourceFiles`. For
|
|
5
|
+
* most use cases prefer those higher-level entry points.
|
|
6
|
+
*
|
|
7
|
+
* Build tools that want to drive resolve outside the session can construct an
|
|
8
|
+
* `ImportResolver` directly and pass it to `createAnalysisSession`.
|
|
9
|
+
*
|
|
10
|
+
* @see `analyzeFromFiles` for the high-level disk-discovery wrapper
|
|
11
|
+
* @see `discoverSourceFiles` for exports-first discovery with glob fallback
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
import { readFile } from 'node:fs/promises';
|
|
16
|
+
import { resolve, isAbsolute } from 'node:path';
|
|
17
|
+
import { glob } from 'tinyglobby';
|
|
18
|
+
import { toPosixPath } from './paths.js';
|
|
19
|
+
import { MAX_FILE_CONCURRENCY, map_concurrent } from './concurrency.js';
|
|
20
|
+
/**
|
|
21
|
+
* Load a single source file from disk.
|
|
22
|
+
*
|
|
23
|
+
* Accepts either relative or absolute paths. Relative paths are resolved against `projectRoot`.
|
|
24
|
+
*
|
|
25
|
+
* @param path - file path (relative to `projectRoot` or absolute)
|
|
26
|
+
* @param projectRoot - absolute path to project root
|
|
27
|
+
* @returns source file info with content loaded
|
|
28
|
+
* @throws Error if the file cannot be read (e.g., missing or permission denied)
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const file = await loadFile('src/lib/math.ts', process.cwd());
|
|
33
|
+
* // {id: '/abs/path/to/src/lib/math.ts', content: '...'}
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const loadFile = async (path, projectRoot) => {
|
|
37
|
+
const absolutePath = isAbsolute(path) ? path : resolve(projectRoot, path);
|
|
38
|
+
const content = await readFile(absolutePath, 'utf-8');
|
|
39
|
+
return {
|
|
40
|
+
id: toPosixPath(absolutePath),
|
|
41
|
+
content,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Glob extension list for source files. Matches the extension set covered by
|
|
46
|
+
* `getDefaultAnalyzer` in `source.ts` — keep in sync if a new analyzable
|
|
47
|
+
* extension is added there.
|
|
48
|
+
*/
|
|
49
|
+
const SOURCE_FILE_EXTENSIONS = 'ts,js,svelte,css,json';
|
|
50
|
+
/**
|
|
51
|
+
* Build an include pattern array from source paths.
|
|
52
|
+
*
|
|
53
|
+
* Each path becomes a `<path>/**\/*.{ts,js,svelte,css,json}` glob. Used by
|
|
54
|
+
* `discoverSourceFiles` to derive a default `include` from
|
|
55
|
+
* `sourceOptions.sourcePaths` when no explicit pattern is supplied — keeps
|
|
56
|
+
* the glob fallback consistent with custom `sourcePaths` instead of silently
|
|
57
|
+
* defaulting to `src/lib`.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* deriveIncludePatterns(['packages/foo', 'packages/bar'])
|
|
62
|
+
* // => ['packages/foo/**\/*.{ts,js,svelte,css,json}', 'packages/bar/**\/*.{ts,js,svelte,css,json}']
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export const deriveIncludePatterns = (sourcePaths) => sourcePaths.map((p) => `${p}/**/*.{${SOURCE_FILE_EXTENSIONS}}`);
|
|
66
|
+
/**
|
|
67
|
+
* Discover source files via glob patterns.
|
|
68
|
+
*
|
|
69
|
+
* @param options - glob configuration
|
|
70
|
+
* @returns array of source files with content loaded
|
|
71
|
+
* @throws Error if any matched file cannot be read — `Promise.all` rejects on the first read failure
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const files = await globFiles({
|
|
76
|
+
* projectRoot: process.cwd(),
|
|
77
|
+
* include: deriveIncludePatterns(['src/lib']),
|
|
78
|
+
* exclude: DEFAULT_SOURCE_OPTIONS.exclude,
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export const globFiles = async (options) => {
|
|
83
|
+
const { projectRoot, include, exclude } = options;
|
|
84
|
+
const filePaths = await glob(include, {
|
|
85
|
+
cwd: projectRoot,
|
|
86
|
+
ignore: exclude,
|
|
87
|
+
absolute: true,
|
|
88
|
+
});
|
|
89
|
+
// Bounded concurrency to keep FD pressure under the typical ulimit on
|
|
90
|
+
// large projects. See `concurrency.ts`.
|
|
91
|
+
return map_concurrent(filePaths, MAX_FILE_CONCURRENCY, async (id) => {
|
|
92
|
+
const content = await readFile(id, 'utf-8');
|
|
93
|
+
return { id: toPosixPath(id), content };
|
|
94
|
+
});
|
|
95
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* svelte-docinfo: static analysis for TypeScript and Svelte.
|
|
3
|
+
*
|
|
4
|
+
* This barrel export provides the common API surface. Every module also exports
|
|
5
|
+
* its full public API via direct imports (e.g., `svelte-docinfo/typescript-exports.js`)
|
|
6
|
+
* for power users who need lower-level access to TypeScript compiler wrappers,
|
|
7
|
+
* Svelte analysis internals, or TSDoc parsing utilities.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
* @nodocs
|
|
11
|
+
*/
|
|
12
|
+
export { analyze, analyzeFromFiles } from './analyze.js';
|
|
13
|
+
export type { AnalyzeOptions, AnalyzeFromFilesOptions } from './analyze.js';
|
|
14
|
+
export { throwOnDuplicates, AnalyzeResultJson } from './analyze-core.js';
|
|
15
|
+
export type { OnDuplicates, OnDuplicatesCallback } from './analyze-core.js';
|
|
16
|
+
export { createAnalysisSession } from './session.js';
|
|
17
|
+
export type { AnalysisSession, AnalysisSessionOptions, SetFileOptions, SetFileResult, SetFilesResult, QueryOptions, } from './session.js';
|
|
18
|
+
export { normalizeResolveImport } from './dep-resolver.js';
|
|
19
|
+
export type { ImportResolver, ResolveImport, ResolveImportFn } from './dep-resolver.js';
|
|
20
|
+
export { DeclarationKind, DeclarationModifier, MemberKind, Reactivity, GenericParamJson, ParameterJson, ComponentPropJson, OverloadJson, FunctionMemberJson, VariableMemberJson, ConstructorMemberJson, MemberJson, FunctionDeclarationJson, ClassDeclarationJson, InterfaceDeclarationJson, TypeDeclarationJson, VariableDeclarationJson, EnumDeclarationJson, ComponentDeclarationJson, SnippetDeclarationJson, NamespaceDeclarationJson, DeclarationJson, ModuleJson, } from './types.js';
|
|
21
|
+
export { getDisplayName, generateImport, compactReplacer, isKind, findTypeReferences, buildTypeReferencePatterns, } from './declaration-helpers.js';
|
|
22
|
+
export type { SourceFileInfo, AnalyzerType } from './source.js';
|
|
23
|
+
export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
|
|
24
|
+
export type { ModuleSourceOptions, SourceOptionsDefaults } from './source-config.js';
|
|
25
|
+
export { findDuplicates, mergeReExports, resolveComponentAliases } from './postprocess.js';
|
|
26
|
+
export type { DuplicateDeclaration, ReExportEntry } from './postprocess.js';
|
|
27
|
+
export { deriveIncludePatterns } from './files.js';
|
|
28
|
+
export { discoverSourceFiles } from './discovery.js';
|
|
29
|
+
export type { Discovery, DiscoverSourceFilesOptions, DiscoverSourceFilesResult, } from './discovery.js';
|
|
30
|
+
export { hasErrors, hasWarnings, errorsOf, warningsOf, byKind, formatDiagnostic, DiagnosticSeverity, DiagnosticKind, Diagnostic, } from './diagnostics.js';
|
|
31
|
+
export type { AnalysisLog } from './log.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACvD,YAAY,EAAC,cAAc,EAAE,uBAAuB,EAAC,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACvE,YAAY,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AACnD,YAAY,EACX,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,cAAc,EACd,YAAY,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAC,cAAc,EAAE,aAAa,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAItF,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,EACf,UAAU,GACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EACN,cAAc,EACd,cAAc,EACd,eAAe,EACf,MAAM,EACN,kBAAkB,EAClB,0BAA0B,GAC1B,MAAM,0BAA0B,CAAC;AAIlC,YAAY,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAI9D,OAAO,EAAC,mBAAmB,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAC,mBAAmB,EAAE,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AAInF,OAAO,EAAC,cAAc,EAAE,cAAc,EAAE,uBAAuB,EAAC,MAAM,kBAAkB,CAAC;AACzF,YAAY,EAAC,oBAAoB,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAI1E,OAAO,EAAC,qBAAqB,EAAC,MAAM,YAAY,CAAC;AAIjD,OAAO,EAAC,mBAAmB,EAAC,MAAM,gBAAgB,CAAC;AACnD,YAAY,EACX,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,GACzB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EACN,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,EACV,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,UAAU,GACV,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* svelte-docinfo: static analysis for TypeScript and Svelte.
|
|
3
|
+
*
|
|
4
|
+
* This barrel export provides the common API surface. Every module also exports
|
|
5
|
+
* its full public API via direct imports (e.g., `svelte-docinfo/typescript-exports.js`)
|
|
6
|
+
* for power users who need lower-level access to TypeScript compiler wrappers,
|
|
7
|
+
* Svelte analysis internals, or TSDoc parsing utilities.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
* @nodocs
|
|
11
|
+
*/
|
|
12
|
+
// ── Core entry points ───────────────────────────────────────────────────────
|
|
13
|
+
export { analyze, analyzeFromFiles } from './analyze.js';
|
|
14
|
+
export { throwOnDuplicates, AnalyzeResultJson } from './analyze-core.js';
|
|
15
|
+
export { createAnalysisSession } from './session.js';
|
|
16
|
+
export { normalizeResolveImport } from './dep-resolver.js';
|
|
17
|
+
// ── Types (Zod schemas + TypeScript interfaces) ─────────────────────────────
|
|
18
|
+
export { DeclarationKind, DeclarationModifier, MemberKind, Reactivity, GenericParamJson, ParameterJson, ComponentPropJson, OverloadJson, FunctionMemberJson, VariableMemberJson, ConstructorMemberJson, MemberJson, FunctionDeclarationJson, ClassDeclarationJson, InterfaceDeclarationJson, TypeDeclarationJson, VariableDeclarationJson, EnumDeclarationJson, ComponentDeclarationJson, SnippetDeclarationJson, NamespaceDeclarationJson, DeclarationJson, ModuleJson, } from './types.js';
|
|
19
|
+
// ── Declaration helpers ────────────────────────────────────────────────────
|
|
20
|
+
export { getDisplayName, generateImport, compactReplacer, isKind, findTypeReferences, buildTypeReferencePatterns, } from './declaration-helpers.js';
|
|
21
|
+
// ── Source options ──────────────────────────────────────────────────────────
|
|
22
|
+
export { createSourceOptions, DEFAULT_SOURCE_OPTIONS } from './source-config.js';
|
|
23
|
+
// ── Post-processing ────────────────────────────────────────────────────────
|
|
24
|
+
export { findDuplicates, mergeReExports, resolveComponentAliases } from './postprocess.js';
|
|
25
|
+
// ── File system constants ──────────────────────────────────────────────────
|
|
26
|
+
export { deriveIncludePatterns } from './files.js';
|
|
27
|
+
// ── File discovery ──────────────────────────────────────────────────────────
|
|
28
|
+
export { discoverSourceFiles } from './discovery.js';
|
|
29
|
+
// ── Diagnostics ─────────────────────────────────────────────────────────────
|
|
30
|
+
export { hasErrors, hasWarnings, errorsOf, warningsOf, byKind, formatDiagnostic, DiagnosticSeverity, DiagnosticKind, Diagnostic, } from './diagnostics.js';
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal logger interface threaded through analysis functions.
|
|
3
|
+
*
|
|
4
|
+
* Separate from `diagnostics.ts` because logging and diagnostics are not the
|
|
5
|
+
* same concern: diagnostics are structured, schema-validated records of
|
|
6
|
+
* analysis-time failures; logs are unstructured progress/info messages the
|
|
7
|
+
* caller chooses how to display.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Minimal logger interface for analysis functions.
|
|
13
|
+
*
|
|
14
|
+
* Intentionally narrow so that both `@fuzdev/fuz_util`'s `Logger` class and
|
|
15
|
+
* Vite's built-in logger satisfy it without adapters or casts.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Stderr logger for CLI usage
|
|
20
|
+
* const log: AnalysisLog = {
|
|
21
|
+
* info: (msg) => console.error(msg),
|
|
22
|
+
* warn: (msg) => console.error(`warning: ${msg}`),
|
|
23
|
+
* error: (msg) => console.error(`error: ${msg}`),
|
|
24
|
+
* };
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export interface AnalysisLog {
|
|
28
|
+
info: (msg: string) => void;
|
|
29
|
+
warn: (msg: string) => void;
|
|
30
|
+
error: (msg: string) => void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B"}
|