svelte-docinfo 0.5.3 → 0.5.5
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 +19 -19
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +11 -11
- package/dist/analyze.d.ts.map +1 -1
- package/dist/analyze.js +8 -8
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -5
- package/dist/declaration-build.d.ts.map +1 -1
- package/dist/declaration-helpers.d.ts.map +1 -1
- package/dist/dep-resolver.js +2 -2
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +18 -18
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +2 -2
- package/dist/error.d.ts +15 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +14 -0
- package/dist/exports.d.ts.map +1 -1
- package/dist/exports.js +42 -6
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/logo.js +3 -3
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/postprocess.js +12 -12
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +16 -15
- package/dist/source-config.d.ts.map +1 -1
- package/dist/source-config.js +2 -2
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +181 -162
- package/dist/tsdoc.d.ts.map +1 -1
- package/dist/tsdoc.js +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +29 -29
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +18 -18
- package/dist/typescript-extract-class.d.ts.map +1 -1
- package/dist/typescript-extract-class.js +8 -7
- package/dist/typescript-extract-function.d.ts.map +1 -1
- package/dist/typescript-extract-function.js +6 -5
- package/dist/typescript-extract-shared.d.ts.map +1 -1
- package/dist/typescript-extract-shared.js +8 -7
- package/dist/typescript-extract-type-properties.d.ts.map +1 -1
- package/dist/typescript-extract-type-properties.js +8 -6
- package/dist/typescript-extract-type.d.ts.map +1 -1
- package/dist/typescript-extract-type.js +13 -12
- package/dist/typescript-program.d.ts.map +1 -1
- package/dist/typescript-program.js +4 -4
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +13 -13
- package/package.json +15 -13
- package/virtual-svelte-docinfo.d.ts +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,9 @@ and [fuz_ui](https://github.com/fuzdev/fuz_ui) components.
|
|
|
44
44
|
|
|
45
45
|
**AI disclosure:** the code and docs beyond the intro
|
|
46
46
|
were mostly written by Claude Code with uneven human guidance.
|
|
47
|
-
The first release took 5 months of intermittent work and ~500 manual commits
|
|
47
|
+
The first release took 5 months of intermittent work and ~500 manual commits
|
|
48
|
+
to [extract its initial implementation from fuz_ui](https://github.com/fuzdev/fuz_ui/pull/107),
|
|
49
|
+
which was more limited, lacking the fancy TS compiler usage, and grew slowly over years without AI assistance.
|
|
48
50
|
|
|
49
51
|
## Quick start
|
|
50
52
|
|
|
@@ -73,7 +75,7 @@ export const add = (a: number, b: number): number => a + b;
|
|
|
73
75
|
let {
|
|
74
76
|
result = $bindable(0),
|
|
75
77
|
mode = 'add',
|
|
76
|
-
disabled = false
|
|
78
|
+
disabled = false
|
|
77
79
|
}: {
|
|
78
80
|
/** Current result (bindable). */
|
|
79
81
|
result?: number;
|
|
@@ -93,7 +95,7 @@ Three ways to integrate `svelte-docinfo`:
|
|
|
93
95
|
// vite.config.ts
|
|
94
96
|
import svelteDocinfo from 'svelte-docinfo/vite.js';
|
|
95
97
|
|
|
96
|
-
export default defineConfig({plugins: [sveltekit(), svelteDocinfo()]});
|
|
98
|
+
export default defineConfig({ plugins: [sveltekit(), svelteDocinfo()] });
|
|
97
99
|
// then anywhere in your app:
|
|
98
100
|
// import {modules} from 'virtual:svelte-docinfo';
|
|
99
101
|
```
|
|
@@ -107,9 +109,9 @@ npx svelte-docinfo --pretty
|
|
|
107
109
|
3. [API](#api) - programmatic access for build tools, custom pipelines, and standalone scripts:
|
|
108
110
|
|
|
109
111
|
```ts
|
|
110
|
-
import {analyzeFromFiles} from 'svelte-docinfo';
|
|
112
|
+
import { analyzeFromFiles } from 'svelte-docinfo';
|
|
111
113
|
|
|
112
|
-
const {modules} = await analyzeFromFiles({projectRoot: process.cwd()});
|
|
114
|
+
const { modules } = await analyzeFromFiles({ projectRoot: process.cwd() });
|
|
113
115
|
```
|
|
114
116
|
|
|
115
117
|
All three produce the same JSON shape:
|
|
@@ -162,8 +164,8 @@ All three produce the same JSON shape:
|
|
|
162
164
|
"typeSignature": "(a: number, b: number): number",
|
|
163
165
|
"sourceLine": 7,
|
|
164
166
|
"parameters": [
|
|
165
|
-
{"name": "a", "type": "number", "description": "first number"},
|
|
166
|
-
{"name": "b", "type": "number", "description": "second number"}
|
|
167
|
+
{ "name": "a", "type": "number", "description": "first number" },
|
|
168
|
+
{ "name": "b", "type": "number", "description": "second number" }
|
|
167
169
|
],
|
|
168
170
|
"returnType": "number",
|
|
169
171
|
"returnDescription": "the sum"
|
|
@@ -174,23 +176,21 @@ All three produce the same JSON shape:
|
|
|
174
176
|
}
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
[svelte-docinfo.fuz.dev/demo/extraction](https://svelte-docinfo.fuz.dev/demo/extraction)
|
|
181
|
-
- browse the [test fixtures](https://github.com/fuzdev/svelte-docinfo/tree/main/src/test/fixtures)
|
|
179
|
+
The [extraction demo](https://svelte-docinfo.fuz.dev/demo/extraction) has more examples,
|
|
180
|
+
and see the docs for the complete [output format](https://svelte-docinfo.fuz.dev/docs/output-format).
|
|
181
|
+
You may also want to browse the [test fixtures](https://github.com/fuzdev/svelte-docinfo/tree/main/src/test/fixtures).
|
|
182
182
|
|
|
183
183
|
## Vite plugin
|
|
184
184
|
|
|
185
185
|
1. Add the plugin to `vite.config.ts`:
|
|
186
186
|
|
|
187
187
|
```ts
|
|
188
|
-
import {defineConfig} from 'vite';
|
|
189
|
-
import {sveltekit} from '@sveltejs/kit/vite';
|
|
188
|
+
import { defineConfig } from 'vite';
|
|
189
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
190
190
|
import svelteDocinfo from 'svelte-docinfo/vite.js';
|
|
191
191
|
|
|
192
192
|
export default defineConfig({
|
|
193
|
-
plugins: [sveltekit(), svelteDocinfo()]
|
|
193
|
+
plugins: [sveltekit(), svelteDocinfo()]
|
|
194
194
|
});
|
|
195
195
|
```
|
|
196
196
|
|
|
@@ -203,7 +203,7 @@ export default defineConfig({
|
|
|
203
203
|
3. Import the virtual module anywhere in your app:
|
|
204
204
|
|
|
205
205
|
```ts
|
|
206
|
-
import {modules, diagnostics} from 'virtual:svelte-docinfo';
|
|
206
|
+
import { modules, diagnostics } from 'virtual:svelte-docinfo';
|
|
207
207
|
// or: import data from 'virtual:svelte-docinfo';
|
|
208
208
|
```
|
|
209
209
|
|
|
@@ -284,9 +284,9 @@ For most projects, `analyzeFromFiles` is all you need. It reads your `package.js
|
|
|
284
284
|
to discover source files, falling back to glob patterns:
|
|
285
285
|
|
|
286
286
|
```ts
|
|
287
|
-
import {analyzeFromFiles} from 'svelte-docinfo';
|
|
287
|
+
import { analyzeFromFiles } from 'svelte-docinfo';
|
|
288
288
|
|
|
289
|
-
const {modules} = await analyzeFromFiles({projectRoot: process.cwd()});
|
|
289
|
+
const { modules } = await analyzeFromFiles({ projectRoot: process.cwd() });
|
|
290
290
|
```
|
|
291
291
|
|
|
292
292
|
Pass `include` for custom patterns or `discovery: 'glob'` to always use glob.
|
|
@@ -294,7 +294,7 @@ Use `discovery: 'exports'` for strict mode that throws if `package.json` has no
|
|
|
294
294
|
When you already have file contents in memory,
|
|
295
295
|
use `analyze` instead of `analyzeFromFiles` to skip file discovery.
|
|
296
296
|
For just the discovery step (without running analysis), use
|
|
297
|
-
`discoverSourceFiles`
|
|
297
|
+
`discoverSourceFiles` (also in the main `svelte-docinfo` import).
|
|
298
298
|
|
|
299
299
|
For long-lived consumers (a Vite plugin reacting to file edits, an LSP-style tool),
|
|
300
300
|
`createAnalysisSession` returns a persistent handle that reuses parsed ASTs across calls
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAsB,KAAK,cAAc,EAAoB,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,KAAK,mBAAmB,EAAoC,MAAM,oBAAoB,CAAC;AAEhG,OAAO,EAMN,KAAK,oBAAoB,EACzB,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAClC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC,EACpD,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,KAC3B,IAAI,CAAC;AAEV;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,G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AC,MAAM,CAAC,CAAC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,iBAAiB,KAAG,iBA4FvD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,aAAa,MAAM,KACjB,IAgBF,CAAC"}
|
package/dist/analyze-core.js
CHANGED
|
@@ -34,7 +34,7 @@ import { analyzeSvelteModule } from './svelte.js';
|
|
|
34
34
|
import { stripVirtualSuffix, getComponentName } from './source.js';
|
|
35
35
|
import { extractPath, extractDependencies } from './source-config.js';
|
|
36
36
|
import { toPosixPath } from './paths.js';
|
|
37
|
-
import { sortModules, findDuplicates, mergeReExports, resolveComponentAliases, compareStrings
|
|
37
|
+
import { sortModules, findDuplicates, mergeReExports, resolveComponentAliases, compareStrings } from './postprocess.js';
|
|
38
38
|
/**
|
|
39
39
|
* Convenience `OnDuplicatesCallback` that throws on any duplicate.
|
|
40
40
|
*
|
|
@@ -74,7 +74,7 @@ const emitDuplicateDiagnostics = (diagnostics, duplicates) => {
|
|
|
74
74
|
message: `Duplicate declaration "${name}" defined in: ${modules.join(', ')}`,
|
|
75
75
|
severity: 'warning',
|
|
76
76
|
declarationName: name,
|
|
77
|
-
modules
|
|
77
|
+
modules
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
};
|
|
@@ -119,7 +119,7 @@ const dispatchOnDuplicates = (mode, duplicates, log) => {
|
|
|
119
119
|
*/
|
|
120
120
|
export const AnalyzeResultJson = z.strictObject({
|
|
121
121
|
modules: z.array(ModuleJson).default([]),
|
|
122
|
-
diagnostics: z.array(Diagnostic).default([])
|
|
122
|
+
diagnostics: z.array(Diagnostic).default([])
|
|
123
123
|
});
|
|
124
124
|
const toModuleJson = (raw) => {
|
|
125
125
|
const filtered = raw.declarations.filter((d) => !d.nodocs).map((d) => d.declaration);
|
|
@@ -151,7 +151,7 @@ const toModuleJson = (raw) => {
|
|
|
151
151
|
reExports,
|
|
152
152
|
externalReExports,
|
|
153
153
|
externalStarExports: raw.externalStarExports,
|
|
154
|
-
...(raw.moduleComment ? { moduleComment: raw.moduleComment } : {})
|
|
154
|
+
...(raw.moduleComment ? { moduleComment: raw.moduleComment } : {})
|
|
155
155
|
});
|
|
156
156
|
};
|
|
157
157
|
// Module dispatch
|
|
@@ -187,7 +187,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log) =>
|
|
|
187
187
|
file: modulePath,
|
|
188
188
|
message: 'Svelte files require program integration. Use createAnalysisSession or analyze()/analyzeFromFiles() instead.',
|
|
189
189
|
severity: 'warning',
|
|
190
|
-
reason: 'requires_program'
|
|
190
|
+
reason: 'requires_program'
|
|
191
191
|
});
|
|
192
192
|
log?.warn(`Svelte file skipped in analyzeModule: ${sourceFile.id}`);
|
|
193
193
|
return undefined;
|
|
@@ -200,7 +200,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log) =>
|
|
|
200
200
|
file: modulePath,
|
|
201
201
|
message: `Could not get source file from program: ${sourceFile.id}`,
|
|
202
202
|
severity: 'warning',
|
|
203
|
-
reason: 'not_in_program'
|
|
203
|
+
reason: 'not_in_program'
|
|
204
204
|
});
|
|
205
205
|
log?.warn(`Could not get source file from program: ${sourceFile.id}`);
|
|
206
206
|
return undefined;
|
|
@@ -217,7 +217,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log) =>
|
|
|
217
217
|
starExports: [],
|
|
218
218
|
reExports: [],
|
|
219
219
|
externalReExports: [],
|
|
220
|
-
externalStarExports: []
|
|
220
|
+
externalStarExports: []
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
else {
|
|
@@ -226,7 +226,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log) =>
|
|
|
226
226
|
file: modulePath,
|
|
227
227
|
message: `No analyzer for file type: ${sourceFile.id}`,
|
|
228
228
|
severity: 'warning',
|
|
229
|
-
reason: 'no_analyzer'
|
|
229
|
+
reason: 'no_analyzer'
|
|
230
230
|
});
|
|
231
231
|
log?.warn(`No analyzer for file: ${sourceFile.id}`);
|
|
232
232
|
return undefined;
|
|
@@ -251,7 +251,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log) =>
|
|
|
251
251
|
* runs `computeDependents` on the owned set before invoking this.
|
|
252
252
|
*/
|
|
253
253
|
export const analyzeCore = (inputs) => {
|
|
254
|
-
const { sourceFiles, sourceOptions, program, svelteVirtualFiles, transformFailedIds, onDuplicates, log
|
|
254
|
+
const { sourceFiles, sourceOptions, program, svelteVirtualFiles, transformFailedIds, onDuplicates, log } = inputs;
|
|
255
255
|
const checker = program.getTypeChecker();
|
|
256
256
|
const diagnostics = [];
|
|
257
257
|
const modules = [];
|
|
@@ -271,7 +271,7 @@ export const analyzeCore = (inputs) => {
|
|
|
271
271
|
dependencies,
|
|
272
272
|
dependents,
|
|
273
273
|
starExports: [],
|
|
274
|
-
partial: true
|
|
274
|
+
partial: true
|
|
275
275
|
}));
|
|
276
276
|
log?.warn(`Svelte component ${componentName} marked partial (transform failed at ingest)`);
|
|
277
277
|
continue;
|
|
@@ -313,7 +313,7 @@ export const analyzeCore = (inputs) => {
|
|
|
313
313
|
normalizeDiagnosticPaths(diagnostics, sourceOptions.projectRoot);
|
|
314
314
|
return {
|
|
315
315
|
modules: sortedModules,
|
|
316
|
-
diagnostics
|
|
316
|
+
diagnostics
|
|
317
317
|
};
|
|
318
318
|
};
|
|
319
319
|
/**
|
package/dist/analyze.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"analyze.d.ts","sourceRoot":"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,oFAAoF;IACpF,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;;;;;;;OAYG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;;;;;;;OAUG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,2DAA2D;IAC3D,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAC5B,SAAS,uBAAuB,KAC9B,OAAO,CAAC,iBAAiB,CAqG3B,CAAC"}
|
package/dist/analyze.js
CHANGED
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { errorsOf, formatDiagnostic, warningsOf } from './diagnostics.js';
|
|
20
20
|
import { createAnalysisSession } from './session.js';
|
|
21
|
-
import { createSourceOptions
|
|
21
|
+
import { createSourceOptions } from './source-config.js';
|
|
22
22
|
import { discoverSourceFiles } from './discovery.js';
|
|
23
23
|
import { noDepsResolver } from './dep-resolver.js';
|
|
24
|
-
import { normalizeDiagnosticPaths
|
|
24
|
+
import { normalizeDiagnosticPaths } from './analyze-core.js';
|
|
25
25
|
/**
|
|
26
26
|
* Analyze library source files and extract metadata (one-shot).
|
|
27
27
|
*
|
|
@@ -38,7 +38,7 @@ export const analyze = async (options) => {
|
|
|
38
38
|
const session = createAnalysisSession({
|
|
39
39
|
sourceOptions: options.sourceOptions,
|
|
40
40
|
log: options.log,
|
|
41
|
-
resolveImport: options.resolveImport
|
|
41
|
+
resolveImport: options.resolveImport
|
|
42
42
|
});
|
|
43
43
|
try {
|
|
44
44
|
const ingest = await session.setFiles(options.sourceFiles);
|
|
@@ -47,7 +47,7 @@ export const analyze = async (options) => {
|
|
|
47
47
|
// session.setFiles; query diagnostics are normalized in analyze-core.
|
|
48
48
|
return {
|
|
49
49
|
modules: query.modules,
|
|
50
|
-
diagnostics: [...ingest.diagnostics, ...query.diagnostics]
|
|
50
|
+
diagnostics: [...ingest.diagnostics, ...query.diagnostics]
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
finally {
|
|
@@ -67,7 +67,7 @@ export const analyze = async (options) => {
|
|
|
67
67
|
* @throws Error if `sourceOptions` validation fails or `tsconfig.json` is missing
|
|
68
68
|
*/
|
|
69
69
|
export const analyzeFromFiles = async (options) => {
|
|
70
|
-
const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir
|
|
70
|
+
const { projectRoot, include, exclude, resolveDependencies: shouldResolveDependencies = true, resolveImport, sourceOptions, onDuplicates, log, discovery, distDir } = options;
|
|
71
71
|
// A custom resolver with resolution turned off is a contradiction — the
|
|
72
72
|
// resolver would never be consulted. Fail fast rather than silently dropping
|
|
73
73
|
// it (mirrors the `discovery: 'exports'` + `include` config-error throw).
|
|
@@ -89,7 +89,7 @@ export const analyzeFromFiles = async (options) => {
|
|
|
89
89
|
include,
|
|
90
90
|
discovery,
|
|
91
91
|
distDir,
|
|
92
|
-
log
|
|
92
|
+
log
|
|
93
93
|
});
|
|
94
94
|
// Step 2: build the session-default resolver. When dep-resolution is
|
|
95
95
|
// disabled, install the shared no-deps resolver so the session's lex+resolve
|
|
@@ -104,7 +104,7 @@ export const analyzeFromFiles = async (options) => {
|
|
|
104
104
|
const session = createAnalysisSession({
|
|
105
105
|
sourceOptions: resolvedSourceOptions,
|
|
106
106
|
log,
|
|
107
|
-
resolveImport: sessionResolver
|
|
107
|
+
resolveImport: sessionResolver
|
|
108
108
|
});
|
|
109
109
|
let result;
|
|
110
110
|
try {
|
|
@@ -112,7 +112,7 @@ export const analyzeFromFiles = async (options) => {
|
|
|
112
112
|
const query = session.query({ onDuplicates, log });
|
|
113
113
|
result = {
|
|
114
114
|
modules: query.modules,
|
|
115
|
-
diagnostics: [...ingest.diagnostics, ...query.diagnostics]
|
|
115
|
+
diagnostics: [...ingest.diagnostics, ...query.diagnostics]
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
finally {
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAUhD,4CAA4C;AAC5C,QAAA,MAAM,oBAAoB,4BAA6B,CAAC;AACxD,KAAK,gBAAgB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAS9D;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,gFAAgF;IAChF,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,sFAAsF;IACtF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,MAAM,GAAU,OAAM,KAAK,CAAC,MAAM,CAAgB,KAAG,OAAO,CAAC,MAAM,CA2N/E,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -23,6 +23,7 @@ import { resolve } from 'node:path';
|
|
|
23
23
|
import picomatch from 'picomatch';
|
|
24
24
|
import { analyzeFromFiles } from './analyze.js';
|
|
25
25
|
import { hasErrors } from './diagnostics.js';
|
|
26
|
+
import { to_error_message } from './error.js';
|
|
26
27
|
import { compactReplacer } from './declaration-helpers.js';
|
|
27
28
|
/** Collect repeatable option values into an array. */
|
|
28
29
|
const collect = (value, previous) => previous ? [...previous, value] : [value];
|
|
@@ -130,7 +131,7 @@ Examples:
|
|
|
130
131
|
onDuplicates: raw.onDuplicates,
|
|
131
132
|
only: raw.only,
|
|
132
133
|
quiet: raw.quiet,
|
|
133
|
-
pretty: raw.pretty
|
|
134
|
+
pretty: raw.pretty
|
|
134
135
|
};
|
|
135
136
|
const resolvedRoot = resolve(projectRoot);
|
|
136
137
|
// Stderr logger — `--quiet` only mutes info; warnings and errors always print
|
|
@@ -138,7 +139,7 @@ Examples:
|
|
|
138
139
|
const log = {
|
|
139
140
|
info: options.quiet ? () => { } : (msg) => console.error(msg),
|
|
140
141
|
warn: (msg) => console.error(`warning: ${msg}`),
|
|
141
|
-
error: (msg) => console.error(`error: ${msg}`)
|
|
142
|
+
error: (msg) => console.error(`error: ${msg}`)
|
|
142
143
|
};
|
|
143
144
|
// Build sourceOptions only when source-dir or source-root is specified,
|
|
144
145
|
// so the default (`['src/lib']`) flows through `createSourceOptions`.
|
|
@@ -148,7 +149,7 @@ Examples:
|
|
|
148
149
|
const sourceOptions = options.sourceDir !== undefined || options.sourceRoot !== undefined
|
|
149
150
|
? {
|
|
150
151
|
...(options.sourceDir !== undefined ? { sourcePaths: options.sourceDir } : {}),
|
|
151
|
-
...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {})
|
|
152
|
+
...(options.sourceRoot !== undefined ? { sourceRoot: options.sourceRoot } : {})
|
|
152
153
|
}
|
|
153
154
|
: undefined;
|
|
154
155
|
const onDuplicates = options.onDuplicates;
|
|
@@ -161,7 +162,7 @@ Examples:
|
|
|
161
162
|
distDir: options.distDir,
|
|
162
163
|
...(sourceOptions !== undefined ? { sourceOptions } : {}),
|
|
163
164
|
...(onDuplicates !== undefined ? { onDuplicates } : {}),
|
|
164
|
-
log
|
|
165
|
+
log
|
|
165
166
|
});
|
|
166
167
|
// `--only` is an output-only filter: analysis ran against the full
|
|
167
168
|
// owned set so re-exports/dependents/`alsoExportedFrom` are correct,
|
|
@@ -193,7 +194,7 @@ Examples:
|
|
|
193
194
|
catch (error) {
|
|
194
195
|
// Friendly one-line error for users; full stack only on DEBUG=1
|
|
195
196
|
// so CI logs and bug reports can still capture it on demand.
|
|
196
|
-
const message =
|
|
197
|
+
const message = to_error_message(error);
|
|
197
198
|
console.error(`error: ${message}`);
|
|
198
199
|
if (process.env.DEBUG) {
|
|
199
200
|
console.error(error);
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,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;;;;;;;;;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M,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IACnC,0DAA0D;IAC1D,WAAW,EAAE,oBAAoB,CAAC;IAClC,2FAA2F;IAC3F,MAAM,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yFAAyF;IACzF,YAAY,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,SAAS,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,2FAA2F;IAC3F,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACpD,6EAA6E;IAC7E,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC5D,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gFAAgF;IAChF,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration-helpers.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,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,7 +142,7 @@ export const createDefaultResolver = (compilerOptions, projectRoot) => {
|
|
|
142
142
|
*/
|
|
143
143
|
export const wrapResolveImport = (resolveImport, identity = Symbol('wrapped')) => ({
|
|
144
144
|
resolve: resolveImport,
|
|
145
|
-
identity
|
|
145
|
+
identity
|
|
146
146
|
});
|
|
147
147
|
/**
|
|
148
148
|
* Shared no-op `ImportResolver` for the "dependency resolution disabled" case.
|
|
@@ -161,5 +161,5 @@ export const wrapResolveImport = (resolveImport, identity = Symbol('wrapped')) =
|
|
|
161
161
|
*/
|
|
162
162
|
export const noDepsResolver = {
|
|
163
163
|
resolve: () => null,
|
|
164
|
-
identity: 'no-deps'
|
|
164
|
+
identity: 'no-deps'
|
|
165
165
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;EAA+B,CAAC;AAC/D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAIpE;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;EAezB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAiC5D;;GAEG;AACH,eAAO,MAAM,wBAAwB;IAGpC,2DAA2D;;IA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CAgBL,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAIpD;;GAEG;AACH,eAAO,MAAM,SAAS,GAAI,aAAa,KAAK,CAAC,UAAU,CAAC,KAAG,OACX,CAAC;AAEjD;;GAEG;AACH,eAAO,MAAM,WAAW,GAAI,aAAa,KAAK,CAAC,UAAU,CAAC,KAAG,OACX,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,aAAa,KAAK,CAAC,UAAU,CAAC,KAAG,KAAK,CAAC,UAAU,CACxB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,aAAa,KAAK,CAAC,UAAU,CAAC,KAAG,KAAK,CAAC,UAAU,CACxB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,cAAc,EAC9C,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,MAAM,CAAC,KACL,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,CAC6C,CAAC;AAEvF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAAI,YAAY,UAAU,KAAG,MAMzD,CAAC"}
|
package/dist/diagnostics.js
CHANGED
|
@@ -84,7 +84,7 @@ export const DiagnosticKind = z.enum([
|
|
|
84
84
|
'source_map_failed',
|
|
85
85
|
'duplicate_declaration',
|
|
86
86
|
'transform_failed',
|
|
87
|
-
'resolver_failed'
|
|
87
|
+
'resolver_failed'
|
|
88
88
|
]);
|
|
89
89
|
// Variants
|
|
90
90
|
/**
|
|
@@ -113,7 +113,7 @@ const baseDiagnosticFields = {
|
|
|
113
113
|
column: z.number().int().positive().optional(),
|
|
114
114
|
/** Human-readable description of the issue. */
|
|
115
115
|
message: z.string(),
|
|
116
|
-
severity: DiagnosticSeverity
|
|
116
|
+
severity: DiagnosticSeverity
|
|
117
117
|
};
|
|
118
118
|
/**
|
|
119
119
|
* Type extraction failed (e.g., complex or recursive types).
|
|
@@ -122,7 +122,7 @@ export const TypeExtractionDiagnostic = z.strictObject({
|
|
|
122
122
|
kind: z.literal('type_extraction_failed'),
|
|
123
123
|
...baseDiagnosticFields,
|
|
124
124
|
/** Name of the symbol whose type couldn't be extracted. */
|
|
125
|
-
symbolName: z.string()
|
|
125
|
+
symbolName: z.string()
|
|
126
126
|
});
|
|
127
127
|
/**
|
|
128
128
|
* Function/method signature analysis failed.
|
|
@@ -131,7 +131,7 @@ export const SignatureAnalysisDiagnostic = z.strictObject({
|
|
|
131
131
|
kind: z.literal('signature_analysis_failed'),
|
|
132
132
|
...baseDiagnosticFields,
|
|
133
133
|
/** Name of the function or method. */
|
|
134
|
-
functionName: z.string()
|
|
134
|
+
functionName: z.string()
|
|
135
135
|
});
|
|
136
136
|
/**
|
|
137
137
|
* Class member analysis failed.
|
|
@@ -142,7 +142,7 @@ export const ClassMemberDiagnostic = z.strictObject({
|
|
|
142
142
|
/** Name of the class. */
|
|
143
143
|
className: z.string(),
|
|
144
144
|
/** Name of the member that failed. */
|
|
145
|
-
memberName: z.string()
|
|
145
|
+
memberName: z.string()
|
|
146
146
|
});
|
|
147
147
|
/**
|
|
148
148
|
* Svelte prop type resolution failed.
|
|
@@ -153,7 +153,7 @@ export const SveltePropDiagnostic = z.strictObject({
|
|
|
153
153
|
/** Name of the component. */
|
|
154
154
|
componentName: z.string(),
|
|
155
155
|
/** Name of the prop. */
|
|
156
|
-
propName: z.string()
|
|
156
|
+
propName: z.string()
|
|
157
157
|
});
|
|
158
158
|
/**
|
|
159
159
|
* Module was skipped during the analysis pass.
|
|
@@ -173,7 +173,7 @@ export const ModuleSkippedDiagnostic = z.strictObject({
|
|
|
173
173
|
kind: z.literal('module_skipped'),
|
|
174
174
|
...baseDiagnosticFields,
|
|
175
175
|
/** Reason the module was skipped. */
|
|
176
|
-
reason: z.enum(['not_in_program', 'no_analyzer', 'requires_program'])
|
|
176
|
+
reason: z.enum(['not_in_program', 'no_analyzer', 'requires_program'])
|
|
177
177
|
});
|
|
178
178
|
/**
|
|
179
179
|
* File discovered via package.json `exports` exists but couldn't be read.
|
|
@@ -185,14 +185,14 @@ export const ModuleSkippedDiagnostic = z.strictObject({
|
|
|
185
185
|
*/
|
|
186
186
|
export const ModuleUnreadableDiagnostic = z.strictObject({
|
|
187
187
|
kind: z.literal('module_unreadable'),
|
|
188
|
-
...baseDiagnosticFields
|
|
188
|
+
...baseDiagnosticFields
|
|
189
189
|
});
|
|
190
190
|
/**
|
|
191
191
|
* Import parsing failed during dependency resolution.
|
|
192
192
|
*/
|
|
193
193
|
export const ImportParseDiagnostic = z.strictObject({
|
|
194
194
|
kind: z.literal('import_parse_failed'),
|
|
195
|
-
...baseDiagnosticFields
|
|
195
|
+
...baseDiagnosticFields
|
|
196
196
|
});
|
|
197
197
|
/**
|
|
198
198
|
* Duplicate comment sources detected (e.g., both HTML and JSDoc `@module`,
|
|
@@ -202,7 +202,7 @@ export const DuplicateCommentDiagnostic = z.strictObject({
|
|
|
202
202
|
kind: z.literal('duplicate_comment'),
|
|
203
203
|
...baseDiagnosticFields,
|
|
204
204
|
/** Which comment type is duplicated. */
|
|
205
|
-
commentType: z.enum(['module_comment', 'doc_comment'])
|
|
205
|
+
commentType: z.enum(['module_comment', 'doc_comment'])
|
|
206
206
|
});
|
|
207
207
|
/**
|
|
208
208
|
* A JSDoc tag found somewhere it has no effect.
|
|
@@ -235,13 +235,13 @@ export const MisplacedTagDiagnostic = z.strictObject({
|
|
|
235
235
|
'throws',
|
|
236
236
|
'mutates',
|
|
237
237
|
'default',
|
|
238
|
-
'nodocs'
|
|
238
|
+
'nodocs'
|
|
239
239
|
]),
|
|
240
240
|
/**
|
|
241
241
|
* Name of the function or method whose overload carries the misplaced tag.
|
|
242
242
|
* Absent for module-comment misplacements (no enclosing symbol).
|
|
243
243
|
*/
|
|
244
|
-
functionName: z.string().optional()
|
|
244
|
+
functionName: z.string().optional()
|
|
245
245
|
});
|
|
246
246
|
/**
|
|
247
247
|
* `@param` tag references a name that doesn't match any actual parameter.
|
|
@@ -255,7 +255,7 @@ export const UnknownParamDiagnostic = z.strictObject({
|
|
|
255
255
|
/** The `@param` key that didn't match a real parameter. */
|
|
256
256
|
paramName: z.string(),
|
|
257
257
|
/** Name of the function or method. */
|
|
258
|
-
functionName: z.string()
|
|
258
|
+
functionName: z.string()
|
|
259
259
|
});
|
|
260
260
|
/**
|
|
261
261
|
* A declaration `name` appears in more than one module.
|
|
@@ -272,7 +272,7 @@ export const DuplicateDeclarationDiagnostic = z.strictObject({
|
|
|
272
272
|
/** The duplicated declaration name. */
|
|
273
273
|
declarationName: z.string(),
|
|
274
274
|
/** Module paths where the name was defined (>= 2). */
|
|
275
|
-
modules: z.array(z.string()).min(2)
|
|
275
|
+
modules: z.array(z.string()).min(2)
|
|
276
276
|
});
|
|
277
277
|
/**
|
|
278
278
|
* Source map parsing failed for a Svelte virtual file.
|
|
@@ -288,7 +288,7 @@ export const DuplicateDeclarationDiagnostic = z.strictObject({
|
|
|
288
288
|
*/
|
|
289
289
|
export const SourceMapFailedDiagnostic = z.strictObject({
|
|
290
290
|
kind: z.literal('source_map_failed'),
|
|
291
|
-
...baseDiagnosticFields
|
|
291
|
+
...baseDiagnosticFields
|
|
292
292
|
});
|
|
293
293
|
/**
|
|
294
294
|
* svelte2tsx transform threw for a `.svelte` file.
|
|
@@ -301,7 +301,7 @@ export const SourceMapFailedDiagnostic = z.strictObject({
|
|
|
301
301
|
*/
|
|
302
302
|
export const TransformFailedDiagnostic = z.strictObject({
|
|
303
303
|
kind: z.literal('transform_failed'),
|
|
304
|
-
...baseDiagnosticFields
|
|
304
|
+
...baseDiagnosticFields
|
|
305
305
|
});
|
|
306
306
|
/**
|
|
307
307
|
* Import resolver threw while resolving a specifier.
|
|
@@ -318,7 +318,7 @@ export const ResolverFailedDiagnostic = z.strictObject({
|
|
|
318
318
|
kind: z.literal('resolver_failed'),
|
|
319
319
|
...baseDiagnosticFields,
|
|
320
320
|
/** The import specifier the resolver failed on. */
|
|
321
|
-
specifier: z.string()
|
|
321
|
+
specifier: z.string()
|
|
322
322
|
});
|
|
323
323
|
/**
|
|
324
324
|
* Discriminated union of all diagnostic variants.
|
|
@@ -337,7 +337,7 @@ export const Diagnostic = z.discriminatedUnion('kind', [
|
|
|
337
337
|
SourceMapFailedDiagnostic,
|
|
338
338
|
DuplicateDeclarationDiagnostic,
|
|
339
339
|
TransformFailedDiagnostic,
|
|
340
|
-
ResolverFailedDiagnostic
|
|
340
|
+
ResolverFailedDiagnostic
|
|
341
341
|
]);
|
|
342
342
|
// Helpers
|
|
343
343
|
/**
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,KAAK,mBAAmB,EAAiB,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,yCAAyC;AACzC,MAAM,WAAW,0BAA0B;IAC1C;;;;;;;;;OASG;IACH,aAAa,EAAE,mBAAmB,CAAC;IAEnC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAExB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,2CAA2C;IAC3C,GAAG,CAAC,EAAE,WAAW,CAAC;CAClB;AAED,uCAAuC;AACvC,MAAM,WAAW,yBAAyB;IACzC,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IAC7B,qFAAqF;IACrF,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,mBAAmB,GAC/B,SAAS,0BAA0B,KACjC,OAAO,CAAC,yBAAyB,CAgGnC,CAAC"}
|
package/dist/discovery.js
CHANGED
|
@@ -84,7 +84,7 @@ export const discoverSourceFiles = async (options) => {
|
|
|
84
84
|
projectRoot,
|
|
85
85
|
exclude,
|
|
86
86
|
sourceDir,
|
|
87
|
-
distDir
|
|
87
|
+
distDir
|
|
88
88
|
});
|
|
89
89
|
const { files: exportsFiles, diagnostics: exportsDiagnostics } = exportsResult;
|
|
90
90
|
diagnostics = exportsDiagnostics;
|
|
@@ -118,7 +118,7 @@ export const discoverSourceFiles = async (options) => {
|
|
|
118
118
|
files = await globFiles({
|
|
119
119
|
projectRoot,
|
|
120
120
|
include: include ?? deriveIncludePatterns(sourceOptions.sourcePaths),
|
|
121
|
-
exclude
|
|
121
|
+
exclude
|
|
122
122
|
});
|
|
123
123
|
log?.info(`Discovered ${files.length} source files via glob`);
|
|
124
124
|
}
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error-message normalization.
|
|
3
|
+
*
|
|
4
|
+
* `to_error_message` is the single primitive for coercing an unknown caught
|
|
5
|
+
* value to a human-readable string — `value.message` for an `Error`, otherwise
|
|
6
|
+
* a caller-supplied fallback or `String(value)`. Used wherever a `catch (err)`
|
|
7
|
+
* binding (typed `unknown`) feeds a diagnostic message, log line, or error
|
|
8
|
+
* field, replacing the inline `err instanceof Error ? err.message : String(err)`
|
|
9
|
+
* idiom.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/** Extract a human-readable message from an unknown thrown value. */
|
|
14
|
+
export declare const to_error_message: (value: unknown, fallback?: string) => string;
|
|
15
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,WAAW,MAAM,KAAG,MACA,CAAC"}
|
package/dist/error.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error-message normalization.
|
|
3
|
+
*
|
|
4
|
+
* `to_error_message` is the single primitive for coercing an unknown caught
|
|
5
|
+
* value to a human-readable string — `value.message` for an `Error`, otherwise
|
|
6
|
+
* a caller-supplied fallback or `String(value)`. Used wherever a `catch (err)`
|
|
7
|
+
* binding (typed `unknown`) feeds a diagnostic message, log line, or error
|
|
8
|
+
* field, replacing the inline `err instanceof Error ? err.message : String(err)`
|
|
9
|
+
* idiom.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/** Extract a human-readable message from an unknown thrown value. */
|
|
14
|
+
export const to_error_message = (value, fallback) => value instanceof Error ? value.message : (fallback ?? String(value));
|