svelte-docinfo 0.12.0 → 0.14.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 +10 -17
- package/README.md +49 -46
- package/dist/analyze-core.d.ts +17 -7
- package/dist/analyze-core.d.ts.map +1 -1
- package/dist/analyze-core.js +18 -9
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +21 -6
- package/dist/declaration-build.d.ts +6 -4
- package/dist/declaration-build.d.ts.map +1 -1
- package/dist/diagnostics.d.ts +17 -35
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +18 -27
- package/dist/postprocess.d.ts +8 -7
- package/dist/postprocess.d.ts.map +1 -1
- package/dist/postprocess.js +5 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +1 -0
- package/dist/svelte-legacy.d.ts +145 -0
- package/dist/svelte-legacy.d.ts.map +1 -0
- package/dist/svelte-legacy.js +210 -0
- package/dist/svelte-scripts.d.ts +144 -0
- package/dist/svelte-scripts.d.ts.map +1 -0
- package/dist/svelte-scripts.js +242 -0
- package/dist/svelte.d.ts +49 -18
- package/dist/svelte.d.ts.map +1 -1
- package/dist/svelte.js +344 -245
- package/dist/tsdoc.d.ts +55 -3
- package/dist/tsdoc.d.ts.map +1 -1
- package/dist/tsdoc.js +176 -10
- package/dist/types.d.ts +107 -41
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +61 -16
- package/dist/typescript-exports.d.ts +32 -19
- package/dist/typescript-exports.d.ts.map +1 -1
- package/dist/typescript-exports.js +381 -140
- package/dist/typescript-extract-class.d.ts +2 -0
- package/dist/typescript-extract-class.d.ts.map +1 -1
- package/dist/typescript-extract-class.js +2 -0
- package/dist/typescript-extract-function.d.ts +2 -0
- package/dist/typescript-extract-function.d.ts.map +1 -1
- package/dist/typescript-extract-function.js +2 -0
- package/dist/typescript-extract-shared.d.ts +31 -3
- package/dist/typescript-extract-shared.d.ts.map +1 -1
- package/dist/typescript-extract-shared.js +20 -5
- package/dist/typescript-extract-type-json.d.ts +3 -1
- package/dist/typescript-extract-type-json.d.ts.map +1 -1
- package/dist/typescript-extract-type-json.js +90 -19
- package/dist/typescript-extract-type-properties.d.ts +2 -0
- package/dist/typescript-extract-type-properties.d.ts.map +1 -1
- package/dist/typescript-extract-type-properties.js +2 -0
- package/dist/typescript-extract-type.d.ts +2 -0
- package/dist/typescript-extract-type.d.ts.map +1 -1
- package/dist/typescript-extract-type.js +2 -0
- package/dist/typescript-program.d.ts +1 -1
- package/dist/typescript-program.js +1 -1
- package/package.json +10 -9
package/LICENSE
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
BSD Zero Clause License
|
|
2
2
|
|
|
3
3
|
Copyright (c) fuz.dev
|
|
4
4
|
|
|
5
|
-
Permission
|
|
6
|
-
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for
|
|
6
|
+
any purpose with or without fee is hereby granted.
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
|
|
9
|
+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
|
10
|
+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
|
11
|
+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
|
|
12
|
+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
|
13
|
+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
14
|
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -18,8 +18,8 @@ in the [npm package](https://www.npmjs.com/package/svelte-docinfo).
|
|
|
18
18
|
npm i -D svelte-docinfo
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Peer dependencies: `svelte` 5+, `svelte2tsx`, and `typescript` 5.9+ or 6
|
|
22
|
-
|
|
21
|
+
Peer dependencies: `svelte` 5+, `svelte2tsx`, and `typescript` 5.9+ or 6,
|
|
22
|
+
plus an optional `vite` 6+ for the Vite plugin.
|
|
23
23
|
|
|
24
24
|
- [Quick start](#quick-start)
|
|
25
25
|
- [Vite plugin](#vite-plugin)
|
|
@@ -28,6 +28,7 @@ installs them automatically), plus an optional `vite` 6+ for the Vite plugin.
|
|
|
28
28
|
- [Features](#features)
|
|
29
29
|
- [Documentation](#documentation)
|
|
30
30
|
- [Credits](#credits)
|
|
31
|
+
- [Contributing](#contributing)
|
|
31
32
|
- [License](#license)
|
|
32
33
|
|
|
33
34
|
svelte-docinfo is largely inspired by [`sveld`](https://github.com/carbon-design-system/sveld),
|
|
@@ -53,11 +54,10 @@ which was more limited, lacking the fancy TS compiler usage, and grew slowly ove
|
|
|
53
54
|
|
|
54
55
|
## Quick start
|
|
55
56
|
|
|
56
|
-
Given a project with a `tsconfig.json` (at or above the project root) and
|
|
57
|
+
Given a project with a `tsconfig.json` (at or above the project root) and two files,
|
|
58
|
+
`src/lib/math.ts`:
|
|
57
59
|
|
|
58
60
|
```ts
|
|
59
|
-
// src/lib/math.ts
|
|
60
|
-
|
|
61
61
|
/**
|
|
62
62
|
* Add two numbers.
|
|
63
63
|
* @param a - first number
|
|
@@ -67,9 +67,9 @@ Given a project with a `tsconfig.json` (at or above the project root) and a coup
|
|
|
67
67
|
export const add = (a: number, b: number): number => a + b;
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
<!-- src/lib/Calculator.svelte -->
|
|
70
|
+
and `src/lib/Calculator.svelte`:
|
|
72
71
|
|
|
72
|
+
```svelte
|
|
73
73
|
<!--
|
|
74
74
|
@component
|
|
75
75
|
Calculator component for demonstrating Svelte analysis.
|
|
@@ -96,6 +96,8 @@ Three ways to integrate `svelte-docinfo`:
|
|
|
96
96
|
|
|
97
97
|
```ts
|
|
98
98
|
// vite.config.ts
|
|
99
|
+
import { defineConfig } from 'vite';
|
|
100
|
+
import { sveltekit } from '@sveltejs/kit/vite';
|
|
99
101
|
import svelteDocinfo from 'svelte-docinfo/vite.js';
|
|
100
102
|
|
|
101
103
|
export default defineConfig({ plugins: [sveltekit(), svelteDocinfo()] });
|
|
@@ -117,7 +119,8 @@ import { analyzeFromFiles } from 'svelte-docinfo';
|
|
|
117
119
|
const { modules } = await analyzeFromFiles({ projectRoot: process.cwd() });
|
|
118
120
|
```
|
|
119
121
|
|
|
120
|
-
All three produce the same
|
|
122
|
+
All three produce the same `AnalyzeResultJson` data. The CLI emits it compacted, as shown
|
|
123
|
+
here (the Vite module compacts `modules` only); the API returns it with defaults filled in:
|
|
121
124
|
|
|
122
125
|
```json
|
|
123
126
|
{
|
|
@@ -186,9 +189,9 @@ All three produce the same JSON shape:
|
|
|
186
189
|
}
|
|
187
190
|
```
|
|
188
191
|
|
|
189
|
-
|
|
190
|
-
and validate the shape, parse it with `parseAnalyzeResult`
|
|
191
|
-
`parseDiagnostics` for diagnostics alone):
|
|
192
|
+
The compact form leaves out defaulted fields: empty arrays (like `diagnostics` here) and
|
|
193
|
+
`false` flags. To restore them and validate the shape, parse it with `parseAnalyzeResult`
|
|
194
|
+
(`parseModuleJson` for one module, `parseDiagnostics` for diagnostics alone):
|
|
192
195
|
|
|
193
196
|
```ts
|
|
194
197
|
import { parseAnalyzeResult } from 'svelte-docinfo';
|
|
@@ -245,19 +248,19 @@ Plugin options:
|
|
|
245
248
|
| `resolveDependencies` | `true` | Resolve import dependencies. When `false`, `dependencies`/`dependents` stay empty. |
|
|
246
249
|
| `hmrDebounceMs` | `100` | Dev re-analysis debounce delay in milliseconds. |
|
|
247
250
|
| `onDuplicates` | — | Opt-in check that names are unique across modules, for packages with a flat export namespace: `'diagnostic'` \| `'warn'` \| `'throw'`. Off by default. |
|
|
248
|
-
| `tsconfig` | `'tsconfig.json'` | Path to the tsconfig, relative to `projectRoot
|
|
251
|
+
| `tsconfig` | `'tsconfig.json'` | Path to the tsconfig, relative to `projectRoot` and searched upward from it, or `false` to analyze without one (built-in strict options, with `compilerOptions` merged on top). |
|
|
249
252
|
| `compilerOptions` | — | Compiler options merged over the tsconfig's, per key. |
|
|
250
253
|
| `rootFileNames` | the tsconfig's roots | The program's root files in place of the tsconfig's: a list, or a function over the tsconfig's roots (`declarationFileRoots`, from `svelte-docinfo/typescript-program.js`, keeps the declaration files). Narrowing speeds up cold analysis; an ambient type declared in a dropped root resolves to `any`. |
|
|
251
254
|
|
|
252
255
|
Source-scope notes (shared with the [CLI](#cli) and `analyzeFromFiles`):
|
|
253
256
|
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
- Paths and patterns resolve against `projectRoot
|
|
257
|
+
- `include` **widens the source scope**: each pattern's static base joins `sourceOptions.sourcePaths`, so the files it finds emit modules (with paths relative to the widened set's common root) and the dev watcher tracks them. A pattern with no base (`'**/*.ts'`, a literal root file) makes the whole project root source and logs an info line.
|
|
258
|
+
- Beneath any `exclude`, `node_modules` and dot-directories below a source path are never source. The rule is relative to the source path, so an explicit dot-directory source path (`sourcePaths: ['.hidden/src']`) still works. `dist`, `build`, and `coverage` are ordinary names.
|
|
259
|
+
- **`src/lib/internal/`** holds modules that ship for public modules to import but aren't documented, excluded by the default `**/internal/**` pattern. Packages typically block consumer imports with an `"./internal/*": null` exports entry, which exports discovery honors with Node's best-match semantics. Internal modules stay live in dev: editing one re-analyzes the public modules that use it. A public re-export of an internal symbol documents as a full declaration at the re-export site. To document them anyway: `exclude: (defaults) => defaults.filter((p) => p !== '**/internal/**')`.
|
|
260
|
+
- Paths and patterns resolve against `projectRoot`. Absolute entries inside the root are accepted, and anything outside it **throws** at options creation instead of silently emitting nothing. `'/src/lib'` is filesystem-absolute, not shorthand for `'src/lib'`.
|
|
258
261
|
|
|
259
262
|
The options interface is `VitePluginSvelteDocinfoOptions` from `svelte-docinfo/vite.js` (not re-exported from the main barrel).
|
|
260
|
-
See the [docs
|
|
263
|
+
See the [Vite plugin docs](https://svelte-docinfo.fuz.dev/docs/vite-plugin) and [examples/vite/](examples/vite/README.md) for more.
|
|
261
264
|
|
|
262
265
|
> If TypeScript reports `Cannot find module 'virtual:svelte-docinfo'`, ensure the `/// <reference>` line is in your `app.d.ts`.
|
|
263
266
|
|
|
@@ -297,18 +300,20 @@ All CLI options:
|
|
|
297
300
|
| `--only <pattern>` | Glob filter applied to module paths in output (repeatable). Full project is still analyzed (re-exports/dependents stay correct); diagnostics aren't filtered |
|
|
298
301
|
| `--no-resolve-dependencies` | Disable dependency resolution |
|
|
299
302
|
| `--pretty` | Pretty-print JSON output (default: compact) |
|
|
300
|
-
| `--tsconfig <path>` | Path to the tsconfig, relative to project root (default: `tsconfig.json
|
|
303
|
+
| `--tsconfig <path>` | Path to the tsconfig, relative to project root and searched upward from it (default: `tsconfig.json`) |
|
|
301
304
|
| `--no-tsconfig` | Analyze without a tsconfig, using built-in strict compiler options |
|
|
302
305
|
| `-q, --quiet` | Suppress info messages on stderr (warnings and errors still print) |
|
|
303
306
|
| `--on-duplicates <mode>` | Opt-in check that names are unique across modules, for packages with a flat export namespace: `diagnostic` \| `warn` \| `throw` (default: off) |
|
|
304
307
|
| `-V, --version` | Show version number |
|
|
308
|
+
| `-h, --help` | Show help |
|
|
305
309
|
|
|
306
|
-
The [Vite plugin](#vite-plugin)'s source-scope notes apply here too
|
|
310
|
+
The [Vite plugin](#vite-plugin)'s source-scope notes apply here too, with `--include`, `--exclude`, and `--source-dir` in place of the options. `--exclude` always replaces the defaults (there's no callback form), so to document `internal/`, re-list the others: `-e '**/*.test.ts' -e '**/*.spec.ts'`.
|
|
307
311
|
|
|
308
|
-
Exit codes: 0 (success), 1 (analysis errors), 2 (
|
|
309
|
-
missing or unloadable
|
|
312
|
+
Exit codes: 0 (success), 1 (analysis errors), 2 (a usage error, like an unknown flag or a
|
|
313
|
+
missing or invalid option value, or a thrown analysis error, like a missing or unloadable
|
|
314
|
+
`tsconfig.json`).
|
|
310
315
|
|
|
311
|
-
See [examples/cli/](examples/cli/README.md) for more
|
|
316
|
+
See the [CLI docs](https://svelte-docinfo.fuz.dev/docs/cli) and [examples/cli/](examples/cli/README.md) for more.
|
|
312
317
|
|
|
313
318
|
## API
|
|
314
319
|
|
|
@@ -338,7 +343,8 @@ For just the discovery step (without running analysis), use
|
|
|
338
343
|
|
|
339
344
|
For long-lived consumers (a Vite plugin reacting to file edits, an LSP-style tool),
|
|
340
345
|
`createAnalysisSession` returns a persistent handle that reuses parsed ASTs across calls
|
|
341
|
-
— see [
|
|
346
|
+
— see the [session docs](https://svelte-docinfo.fuz.dev/docs/session) and
|
|
347
|
+
[examples/api/analyze-session.js](examples/api/analyze-session.js).
|
|
342
348
|
|
|
343
349
|
See [examples/api/](examples/api/README.md) for more patterns
|
|
344
350
|
including custom discovery, diagnostics, sessions, and error handling.
|
|
@@ -349,31 +355,28 @@ See the [API docs](https://svelte-docinfo.fuz.dev/docs/api) for the full referen
|
|
|
349
355
|
|
|
350
356
|
## Features
|
|
351
357
|
|
|
352
|
-
- **Full type resolution**:
|
|
353
|
-
- **Structured types**: an optional `typeInfo` tree (`TypeJson`) beside the flat type strings
|
|
354
|
-
- **
|
|
355
|
-
- **
|
|
356
|
-
- **Merged value+type symbols**: `
|
|
357
|
-
- **Svelte 5
|
|
358
|
-
- **External types**: props and members
|
|
359
|
-
- **Svelte 5 snippets**: `kind: 'snippet'` for
|
|
360
|
-
- **
|
|
361
|
-
- **
|
|
362
|
-
- **
|
|
363
|
-
- **
|
|
364
|
-
- **
|
|
365
|
-
- **
|
|
366
|
-
- **
|
|
367
|
-
- **Source locations**: file and line for every declaration
|
|
368
|
-
- **Build-tool agnostic**: works with any source: file system, build pipeline, or in-memory
|
|
369
|
-
- **Diagnostic collection**: accumulates warnings and errors without halting; `partial: true` flags incomplete declarations
|
|
358
|
+
- **Full type resolution**: generics, imported types, and inferred return types, without manual annotations
|
|
359
|
+
- **Structured types**: an optional `typeInfo` tree (`TypeJson`) beside the flat type strings, with union and intersection members (alias names kept), type arguments, and array/tuple elements. Absent where the flat string says everything; `typeJsonToTokens`/`typeJsonToText` render it
|
|
360
|
+
- **Alias-lost name recovery**: TypeScript drops the name of an alias over an indexed access or conditional (`z.infer<typeof S>`, valibot's `v.InferOutput<typeof S>`) and expands it at every use. `typeInfo` recovers it as `{kind: 'reference', name}`, from the written annotation or from a registry of the project's exported aliases. Losses nothing recovers surface as `alias_lost` warnings
|
|
361
|
+
- **TSDoc/JSDoc**: `@param`, `@returns`, `@throws`, `@example`, `@deprecated`, `@internal`, `@see`, `@since`, `@default`, `@module`, plus the custom `@nodocs` (exclude from docs) and `@mutates`; `@return` and `@defaultValue` parse as synonyms. `@internal` is a marker (`internalMessage`), not an exclusion. Inline `{@link}` survives in the text
|
|
362
|
+
- **Merged value+type symbols**: `const Foo = z.strictObject({...})` + `type Foo = z.infer<typeof Foo>` documents the type, with `mergedValue: true` marking the name as also a runtime value; JSDoc falls back to the const's
|
|
363
|
+
- **Svelte 5 components**: prop types, descriptions, defaults, bindability, and callback signatures via svelte2tsx, plus generics and `acceptsChildren`. JS components take props from the JSDoc `@type` on `$props()` or infer them from the destructuring
|
|
364
|
+
- **External types**: props and members from external packages (`HTMLButtonAttributes`) are filtered out and named in `externalTypes` (on components, type aliases, interfaces, and classes, including bags reached through local base types), unless the `$props()` destructuring names them
|
|
365
|
+
- **Svelte 5 snippets**: `kind: 'snippet'` for snippets exported from `<script module>`, with structured parameters
|
|
366
|
+
- **Runes**: `$state`, `$state.raw`, `$derived`, and `$derived.by` on variables and class fields (`reactivity`), detected syntactically in any file
|
|
367
|
+
- **Classes, enums, and overloads**: public and protected class members (`private` and `#` excluded), regular and const enums with member values, and every public overload signature with its own JSDoc
|
|
368
|
+
- **Re-exports**: `alsoExportedFrom` on canonical declarations and `ModuleJson.reExports` on barrels, `aliasOf` for renames, `starExports`, `kind: 'namespace'` for `export * as ns`, and external re-exports, with `resolveExportSurface()` combining them using ES star semantics
|
|
369
|
+
- **Dependency graphs**: imports between modules and the computed dependents
|
|
370
|
+
- **Source locations**: the source line of every declaration
|
|
371
|
+
- **Build-tool agnostic**: files can come from disk, a build pipeline, or memory
|
|
372
|
+
- **Diagnostics**: warnings and errors accumulate without halting; `partial: true` flags incomplete declarations
|
|
370
373
|
|
|
371
374
|
Known gaps:
|
|
372
375
|
|
|
373
|
-
- context
|
|
374
|
-
-
|
|
375
|
-
-
|
|
376
|
-
- legacy `export let` props
|
|
376
|
+
- Svelte context (`setContext`/`getContext`) isn't captured yet; investigation is planned, and
|
|
377
|
+
a [request](https://github.com/fuzdev/svelte-docinfo/discussions) would bump its priority
|
|
378
|
+
- standalone `namespace Foo {}` declarations document as a bare variable with no members, and decorators aren't modeled
|
|
379
|
+
- legacy `export let` components document their props (all `bindable`), and a legacy component's default `<slot />` sets `acceptsChildren` (a runes component's is ignored), but named slots, slot props, events, and `$$restProps` aren't modeled
|
|
377
380
|
- `@nodocs` applies to declarations and export statements only; on a member or component prop it's ignored without a warning
|
|
378
381
|
|
|
379
382
|
[Issues](https://github.com/fuzdev/svelte-docinfo/issues) for bugs and
|
|
@@ -409,4 +412,4 @@ see [package.json](package.json) for full dependencies.
|
|
|
409
412
|
|
|
410
413
|
## License
|
|
411
414
|
|
|
412
|
-
[
|
|
415
|
+
[0BSD](LICENSE)
|
package/dist/analyze-core.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ import { type SvelteVirtualFile } from './svelte.js';
|
|
|
43
43
|
import { type SourceFileInfo } from './source.js';
|
|
44
44
|
import { type ModuleSourceOptions } from './source-config.js';
|
|
45
45
|
import type { AliasRegistry } from './typescript-extract-type-json.js';
|
|
46
|
-
import { type IsEmittedFile } from './typescript-extract-shared.js';
|
|
46
|
+
import { type FileExists, type IsEmittedFile } from './typescript-extract-shared.js';
|
|
47
47
|
/**
|
|
48
48
|
* Opt-in check that declaration names are unique across modules.
|
|
49
49
|
*
|
|
@@ -65,14 +65,14 @@ import { type IsEmittedFile } from './typescript-extract-shared.js';
|
|
|
65
65
|
export type OnDuplicates = 'diagnostic' | 'warn' | 'throw';
|
|
66
66
|
declare const AnalyzeResultJsonEntries: v.StrictObjectSchema<{
|
|
67
67
|
readonly modules: v.OptionalSchema<v.ArraySchema<import("./types.js").ModuleJsonSchema, undefined>, () => never[]>;
|
|
68
|
-
readonly diagnostics: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"kind", [import("./diagnostics.js").TypeExtractionDiagnosticSchema, import("./diagnostics.js").SignatureAnalysisDiagnosticSchema, import("./diagnostics.js").ClassMemberDiagnosticSchema, import("./diagnostics.js").SveltePropDiagnosticSchema, import("./diagnostics.js").
|
|
68
|
+
readonly diagnostics: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"kind", [import("./diagnostics.js").TypeExtractionDiagnosticSchema, import("./diagnostics.js").SignatureAnalysisDiagnosticSchema, import("./diagnostics.js").ClassMemberDiagnosticSchema, import("./diagnostics.js").SveltePropDiagnosticSchema, import("./diagnostics.js").ModuleSkippedDiagnosticSchema, import("./diagnostics.js").ModuleUnreadableDiagnosticSchema, import("./diagnostics.js").ImportParseDiagnosticSchema, import("./diagnostics.js").DuplicateCommentDiagnosticSchema, import("./diagnostics.js").MisplacedTagDiagnosticSchema, import("./diagnostics.js").UnknownParamDiagnosticSchema, import("./diagnostics.js").SourceMapFailedDiagnosticSchema, import("./diagnostics.js").DuplicateDeclarationDiagnosticSchema, import("./diagnostics.js").TransformFailedDiagnosticSchema, import("./diagnostics.js").ResolverFailedDiagnosticSchema, import("./diagnostics.js").AliasLostDiagnosticSchema], undefined>, undefined>, () => never[]>;
|
|
69
69
|
}, undefined>;
|
|
70
70
|
/** @nodocs */
|
|
71
71
|
export interface AnalyzeResultJsonEntriesInput extends Named<v.InferInput<typeof AnalyzeResultJsonEntries>> {
|
|
72
72
|
}
|
|
73
73
|
declare const AnalyzeResultJsonImpl: v.SchemaWithPipe<readonly [v.CustomSchema<AnalyzeResultJsonEntriesInput, v.ErrorMessage<v.CustomIssue> | undefined>, v.StrictObjectSchema<{
|
|
74
74
|
readonly modules: v.OptionalSchema<v.ArraySchema<import("./types.js").ModuleJsonSchema, undefined>, () => never[]>;
|
|
75
|
-
readonly diagnostics: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"kind", [import("./diagnostics.js").TypeExtractionDiagnosticSchema, import("./diagnostics.js").SignatureAnalysisDiagnosticSchema, import("./diagnostics.js").ClassMemberDiagnosticSchema, import("./diagnostics.js").SveltePropDiagnosticSchema, import("./diagnostics.js").
|
|
75
|
+
readonly diagnostics: v.OptionalSchema<v.ArraySchema<v.VariantSchema<"kind", [import("./diagnostics.js").TypeExtractionDiagnosticSchema, import("./diagnostics.js").SignatureAnalysisDiagnosticSchema, import("./diagnostics.js").ClassMemberDiagnosticSchema, import("./diagnostics.js").SveltePropDiagnosticSchema, import("./diagnostics.js").ModuleSkippedDiagnosticSchema, import("./diagnostics.js").ModuleUnreadableDiagnosticSchema, import("./diagnostics.js").ImportParseDiagnosticSchema, import("./diagnostics.js").DuplicateCommentDiagnosticSchema, import("./diagnostics.js").MisplacedTagDiagnosticSchema, import("./diagnostics.js").UnknownParamDiagnosticSchema, import("./diagnostics.js").SourceMapFailedDiagnosticSchema, import("./diagnostics.js").DuplicateDeclarationDiagnosticSchema, import("./diagnostics.js").TransformFailedDiagnosticSchema, import("./diagnostics.js").ResolverFailedDiagnosticSchema, import("./diagnostics.js").AliasLostDiagnosticSchema], undefined>, undefined>, () => never[]>;
|
|
76
76
|
}, undefined>]>;
|
|
77
77
|
/** @nodocs */
|
|
78
78
|
export interface AnalyzeResultJsonSchema extends Named<typeof AnalyzeResultJsonImpl> {
|
|
@@ -175,14 +175,16 @@ export interface AnalyzeResultJsonWire {
|
|
|
175
175
|
* modules themselves get written-name recovery only, while `analyzeCore`
|
|
176
176
|
* passes the registry its pre-pass built (see `buildAliasRegistry`).
|
|
177
177
|
* `isEmittedFile` likewise: `analyzeCore` answers from its emitted set, and a
|
|
178
|
-
* direct caller falls back to `isSource` (see `IsEmittedFile`).
|
|
178
|
+
* direct caller falls back to `isSource` (see `IsEmittedFile`). `fileExists`
|
|
179
|
+
* too: `analyzeCore` sees its inputs' in-memory content, and a direct caller
|
|
180
|
+
* falls back to the disk (see `SvelteFileStatus`).
|
|
179
181
|
*
|
|
180
182
|
* @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
|
|
181
183
|
* power users; not stable API.
|
|
182
184
|
*/
|
|
183
185
|
export declare const analyzeModule: (sourceFile: SourceFileInfo & {
|
|
184
186
|
dependents?: ReadonlyArray<string>;
|
|
185
|
-
}, program: ts.Program, options: ModuleSourceOptions, diagnostics: Array<Diagnostic>, log?: AnalysisLog, aliasRegistry?: AliasRegistry, isEmittedFile?: IsEmittedFile) => ModuleJson | undefined;
|
|
187
|
+
}, program: ts.Program, options: ModuleSourceOptions, diagnostics: Array<Diagnostic>, log?: AnalysisLog, aliasRegistry?: AliasRegistry, isEmittedFile?: IsEmittedFile, fileExists?: FileExists) => ModuleJson | undefined;
|
|
186
188
|
/**
|
|
187
189
|
* Inputs to `analyzeCore`. The caller (one-shot wrapper or session.query)
|
|
188
190
|
* is responsible for normalizing `sourceOptions`, obtaining the program,
|
|
@@ -213,10 +215,18 @@ export interface AnalyzeCoreInputs {
|
|
|
213
215
|
*
|
|
214
216
|
* Resolution requires the component's virtual to exist — via the context
|
|
215
217
|
* closure (`analyzeFromFiles` included) or by passing the file as `analyze()`
|
|
216
|
-
* input. Without it a gated component re-export
|
|
217
|
-
*
|
|
218
|
+
* input. Without it a gated component re-export documents as a `partial`
|
|
219
|
+
* component with nothing filled.
|
|
218
220
|
*/
|
|
219
221
|
contextSvelteFiles?: ReadonlyArray<SourceFileInfo>;
|
|
222
|
+
/**
|
|
223
|
+
* Whether a path exists — owned in-memory content or disk. It tells a
|
|
224
|
+
* `.svelte` file with no svelte2tsx virtual from a mistyped specifier (see
|
|
225
|
+
* `SvelteFileStatus`). Defaults to the files handed in plus the disk; a
|
|
226
|
+
* session passes its whole owned set, which also holds files that emit
|
|
227
|
+
* nothing and aren't offered as context.
|
|
228
|
+
*/
|
|
229
|
+
fileExists?: FileExists;
|
|
220
230
|
onDuplicates?: OnDuplicates;
|
|
221
231
|
log?: AnalysisLog;
|
|
222
232
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAE7B,OAAO,EAAE,UAAU,EAAmB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"analyze-core.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/analyze-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,mBAAmB,GAC/B,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,SAAS;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAA;CAAE,KAC1E,IAKF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,wBAAwB,GACpC,aAAa,KAAK,CAAC,UAAU,CAAC,EAC9B,aAAa,MAAM,KACjB,IAuBF,CAAC;AAiPF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,2BAA2B,GACvC,SAAS,KAAK,CAAC,UAAU,CAAC,EAC1B,SAAS,mBAAmB,EAC5B,SAAS,EAAE,CAAC,OAAO,KACjB,IAKF,CAAC"}
|
package/dist/analyze-core.js
CHANGED
|
@@ -40,6 +40,7 @@ import { ModuleJson, parseModuleJson } from './types.js';
|
|
|
40
40
|
import { parseWithSummary } from './schema.js';
|
|
41
41
|
import { Diagnostic } from './diagnostics.js';
|
|
42
42
|
import { analyzeTypescriptModule } from './typescript-exports.js';
|
|
43
|
+
import { toModuleDocFields } from './tsdoc.js';
|
|
43
44
|
import { analyzeSvelteModule, reclassifySnippetDeclaration, remapVirtualDiagnosticPositions } from './svelte.js';
|
|
44
45
|
import { scrubVirtualSuffixes, stripVirtualSuffix, getComponentName } from './source.js';
|
|
45
46
|
import { extractPath, extractDependencies } from './source-config.js';
|
|
@@ -186,7 +187,7 @@ const toModuleJson = (raw) => {
|
|
|
186
187
|
reExports,
|
|
187
188
|
externalReExports,
|
|
188
189
|
externalStarExports: raw.externalStarExports,
|
|
189
|
-
...(raw.
|
|
190
|
+
...toModuleDocFields(raw.moduleDoc)
|
|
190
191
|
});
|
|
191
192
|
};
|
|
192
193
|
// Module dispatch
|
|
@@ -211,12 +212,14 @@ const toModuleJson = (raw) => {
|
|
|
211
212
|
* modules themselves get written-name recovery only, while `analyzeCore`
|
|
212
213
|
* passes the registry its pre-pass built (see `buildAliasRegistry`).
|
|
213
214
|
* `isEmittedFile` likewise: `analyzeCore` answers from its emitted set, and a
|
|
214
|
-
* direct caller falls back to `isSource` (see `IsEmittedFile`).
|
|
215
|
+
* direct caller falls back to `isSource` (see `IsEmittedFile`). `fileExists`
|
|
216
|
+
* too: `analyzeCore` sees its inputs' in-memory content, and a direct caller
|
|
217
|
+
* falls back to the disk (see `SvelteFileStatus`).
|
|
215
218
|
*
|
|
216
219
|
* @internal Importable from `svelte-docinfo/analyze-core.js` for tests and
|
|
217
220
|
* power users; not stable API.
|
|
218
221
|
*/
|
|
219
|
-
export const analyzeModule = (sourceFile, program, options, diagnostics, log, aliasRegistry, isEmittedFile) => {
|
|
222
|
+
export const analyzeModule = (sourceFile, program, options, diagnostics, log, aliasRegistry, isEmittedFile, fileExists) => {
|
|
220
223
|
const checker = program.getTypeChecker();
|
|
221
224
|
const modulePath = extractPath(sourceFile.id, options);
|
|
222
225
|
// diagnostics carry the absolute id (see the `Diagnostic.file` schema doc);
|
|
@@ -254,7 +257,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log, al
|
|
|
254
257
|
}
|
|
255
258
|
// the pass-scoped extraction context — constructed here because the
|
|
256
259
|
// dispatcher is where the program is in hand (see `analyzeExports`)
|
|
257
|
-
const ctx = createExtractContext(program, checker, options, diagnostics, aliasRegistry, isEmittedFile);
|
|
260
|
+
const ctx = createExtractContext(program, checker, options, diagnostics, aliasRegistry, isEmittedFile, fileExists);
|
|
258
261
|
raw = analyzeTypescriptModule(sourceFile, tsSourceFile, modulePath, ctx, options);
|
|
259
262
|
// a TS module can't declare a snippet, but it can re-export one from a
|
|
260
263
|
// component that emits nothing, and the synthesized alias is analyzed
|
|
@@ -297,7 +300,7 @@ export const analyzeModule = (sourceFile, program, options, diagnostics, log, al
|
|
|
297
300
|
* entirely; analysis diagnostics are dropped — the canonical's `partial`
|
|
298
301
|
* flag propagates through the fill, which is the emitted signal.
|
|
299
302
|
*/
|
|
300
|
-
const analyzeContextComponents = (contextSvelteFiles, emittedModules, inputs, aliasRegistry, isEmittedFile) => {
|
|
303
|
+
const analyzeContextComponents = (contextSvelteFiles, emittedModules, inputs, aliasRegistry, isEmittedFile, fileExists) => {
|
|
301
304
|
const { sourceOptions, program, svelteVirtualFiles } = inputs;
|
|
302
305
|
const referenced = new Set();
|
|
303
306
|
for (const mod of emittedModules) {
|
|
@@ -317,7 +320,7 @@ const analyzeContextComponents = (contextSvelteFiles, emittedModules, inputs, al
|
|
|
317
320
|
if (!virtualFile)
|
|
318
321
|
continue;
|
|
319
322
|
const droppedDiagnostics = [];
|
|
320
|
-
const raw = analyzeSvelteModule(sourceFile, modulePath, program.getTypeChecker(), sourceOptions, droppedDiagnostics, program, virtualFile, aliasRegistry, isEmittedFile);
|
|
323
|
+
const raw = analyzeSvelteModule(sourceFile, modulePath, program.getTypeChecker(), sourceOptions, droppedDiagnostics, program, virtualFile, aliasRegistry, isEmittedFile, fileExists);
|
|
321
324
|
if (raw)
|
|
322
325
|
contextModules.push(toModuleJson(raw));
|
|
323
326
|
}
|
|
@@ -352,6 +355,12 @@ export const analyzeCore = (inputs) => {
|
|
|
352
355
|
// link to from one they have to document in place.
|
|
353
356
|
const emittedIds = new Set(sourceFiles.map((f) => toPosixPath(f.id)));
|
|
354
357
|
const isEmittedFile = (file) => emittedIds.has(file);
|
|
358
|
+
// Existence for `SvelteFileStatus`: the caller's answer, else the files
|
|
359
|
+
// handed in (in-memory content counts) plus the disk.
|
|
360
|
+
const knownIds = new Set(emittedIds);
|
|
361
|
+
for (const f of contextSvelteFiles ?? [])
|
|
362
|
+
knownIds.add(toPosixPath(f.id));
|
|
363
|
+
const fileExists = inputs.fileExists ?? ((file) => knownIds.has(file) || ts.sys.fileExists(file));
|
|
355
364
|
// Registry pre-pass: register the emitted set's exported lost aliases
|
|
356
365
|
// before any extraction, so every `resolveTypeInfo` call this cycle can
|
|
357
366
|
// consult a complete registry. Svelte modules are reached through their
|
|
@@ -416,7 +425,7 @@ export const analyzeCore = (inputs) => {
|
|
|
416
425
|
const virtualFile = svelteVirtualFiles.get(sourceFile.id);
|
|
417
426
|
if (virtualFile) {
|
|
418
427
|
const modulePath = extractPath(sourceFile.id, sourceOptions);
|
|
419
|
-
const raw = analyzeSvelteModule(sourceFile, modulePath, checker, sourceOptions, diagnostics, program, virtualFile, aliasRegistry, isEmittedFile);
|
|
428
|
+
const raw = analyzeSvelteModule(sourceFile, modulePath, checker, sourceOptions, diagnostics, program, virtualFile, aliasRegistry, isEmittedFile, fileExists);
|
|
420
429
|
if (raw) {
|
|
421
430
|
mod = toModuleJson(raw);
|
|
422
431
|
}
|
|
@@ -425,7 +434,7 @@ export const analyzeCore = (inputs) => {
|
|
|
425
434
|
}
|
|
426
435
|
}
|
|
427
436
|
else {
|
|
428
|
-
mod = analyzeModule(sourceFile, program, sourceOptions, diagnostics, log, aliasRegistry, isEmittedFile);
|
|
437
|
+
mod = analyzeModule(sourceFile, program, sourceOptions, diagnostics, log, aliasRegistry, isEmittedFile, fileExists);
|
|
429
438
|
}
|
|
430
439
|
if (!mod)
|
|
431
440
|
continue;
|
|
@@ -435,7 +444,7 @@ export const analyzeCore = (inputs) => {
|
|
|
435
444
|
// `mergeReExports` (their edges would back-link modules absent from
|
|
436
445
|
// output) and out of the emitted set.
|
|
437
446
|
const contextModules = contextSvelteFiles?.length
|
|
438
|
-
? analyzeContextComponents(contextSvelteFiles, modules, inputs, aliasRegistry, isEmittedFile)
|
|
447
|
+
? analyzeContextComponents(contextSvelteFiles, modules, inputs, aliasRegistry, isEmittedFile, fileExists)
|
|
439
448
|
: [];
|
|
440
449
|
// Phase 2a: build alsoExportedFrom arrays from the modules' forward edges
|
|
441
450
|
const mergedModules = mergeReExports(modules);
|
package/dist/cli.d.ts
CHANGED
|
@@ -103,7 +103,8 @@ export interface CliOptions {
|
|
|
103
103
|
* Run the CLI with the given arguments.
|
|
104
104
|
*
|
|
105
105
|
* @param argv - command line arguments (defaults to `process.argv`)
|
|
106
|
-
* @returns exit code: 0 for success
|
|
106
|
+
* @returns exit code: 0 for success (including `--help` and `--version`), 1 if errors in
|
|
107
|
+
* diagnostics, 2 for CLI errors (an unknown flag, a missing or invalid option value) or any
|
|
107
108
|
* thrown analysis error (including an `--on-duplicates throw` collision)
|
|
108
109
|
*/
|
|
109
110
|
export declare const runCli: (argv?: Array<string>) => Promise<number>;
|
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;AAQH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAwBhD;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;OAKG;IACH,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;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC1B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC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AgB,KAAG,OAAO,CAAC,MAAM,CAmP/E,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module
|
|
19
19
|
*/
|
|
20
|
-
import { Command } from 'commander';
|
|
20
|
+
import { Command, CommanderError } from 'commander';
|
|
21
21
|
import { writeFile, readFile } from 'node:fs/promises';
|
|
22
22
|
import { resolve } from 'node:path';
|
|
23
23
|
import picomatch from 'picomatch';
|
|
@@ -42,7 +42,8 @@ const isDiscoveryFlag = (value) => DISCOVERY_VALUES.includes(value);
|
|
|
42
42
|
* Run the CLI with the given arguments.
|
|
43
43
|
*
|
|
44
44
|
* @param argv - command line arguments (defaults to `process.argv`)
|
|
45
|
-
* @returns exit code: 0 for success
|
|
45
|
+
* @returns exit code: 0 for success (including `--help` and `--version`), 1 if errors in
|
|
46
|
+
* diagnostics, 2 for CLI errors (an unknown flag, a missing or invalid option value) or any
|
|
46
47
|
* thrown analysis error (including an `--on-duplicates throw` collision)
|
|
47
48
|
*/
|
|
48
49
|
export const runCli = async (argv = process.argv) => {
|
|
@@ -68,6 +69,11 @@ export const runCli = async (argv = process.argv) => {
|
|
|
68
69
|
}
|
|
69
70
|
throw new Error(`svelte-docinfo: failed to load package.json for version. Attempted: ${attempted.join(', ')}`);
|
|
70
71
|
})();
|
|
72
|
+
// Commander exits 1 on its own parse errors; throw instead so they map to 2,
|
|
73
|
+
// keeping 1 for analysis errors. Its messages go through `console.error`
|
|
74
|
+
// like the CLI's own errors.
|
|
75
|
+
program.exitOverride();
|
|
76
|
+
program.configureOutput({ writeErr: (s) => console.error(s.trimEnd()) });
|
|
71
77
|
program
|
|
72
78
|
.name('svelte-docinfo')
|
|
73
79
|
.description('Static analysis for TypeScript and Svelte source code')
|
|
@@ -83,7 +89,8 @@ export const runCli = async (argv = process.argv) => {
|
|
|
83
89
|
.option('--no-resolve-dependencies', 'Disable dependency resolution')
|
|
84
90
|
.option('--discovery <mode>', `Source file discovery strategy: ${DISCOVERY_VALUES.join('|')} ` +
|
|
85
91
|
'(default: auto — exports first, glob fallback). ' +
|
|
86
|
-
'`exports` is strict and fails if package.json exports is missing
|
|
92
|
+
'`exports` is strict and fails if package.json exports is missing ' +
|
|
93
|
+
'or resolves to no files ' +
|
|
87
94
|
'(also incompatible with --include).')
|
|
88
95
|
.option('--dist-dir <dir>', 'Dist directory for exports discovery (default: dist)')
|
|
89
96
|
.option('--source-dir <dir>', 'Source directory, relative to project root or absolute inside it ' +
|
|
@@ -112,8 +119,8 @@ Examples:
|
|
|
112
119
|
$ svelte-docinfo --source-dir src Non-SvelteKit project (src/ root)
|
|
113
120
|
$ svelte-docinfo --source-dir src/lib --source-dir src/routes
|
|
114
121
|
Multiple source dirs (source-root auto-derived as 'src')
|
|
115
|
-
$ svelte-docinfo --source-dir src/lib --source-dir lib/utils
|
|
116
|
-
No common prefix — module paths
|
|
122
|
+
$ svelte-docinfo --source-dir src/lib --source-dir lib/utils
|
|
123
|
+
No common prefix — module paths are project-relative
|
|
117
124
|
$ svelte-docinfo --discovery glob Skip package.json exports
|
|
118
125
|
$ svelte-docinfo --discovery exports Strict — fail if exports missing
|
|
119
126
|
$ svelte-docinfo --tsconfig tsconfig.lib.json Use a specific tsconfig
|
|
@@ -217,6 +224,14 @@ Examples:
|
|
|
217
224
|
exitCode = 2;
|
|
218
225
|
}
|
|
219
226
|
});
|
|
220
|
-
|
|
227
|
+
try {
|
|
228
|
+
await program.parseAsync(argv);
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (!(error instanceof CommanderError))
|
|
232
|
+
throw error;
|
|
233
|
+
// `--help` and `--version` throw with exit code 0
|
|
234
|
+
return error.exitCode === 0 ? 0 : 2;
|
|
235
|
+
}
|
|
221
236
|
return exitCode;
|
|
222
237
|
};
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
15
|
import type { DeclarationKind, DeclarationModifier, GenericParamJson, MemberKind, ParameterJsonInput, OverloadJsonInput, ComponentPropJsonInput, Reactivity, ReExportJsonInput, ExternalReExportJsonInput, TypeJson } from './types.js';
|
|
16
|
+
import type { TsdocParsedComment } from './tsdoc.js';
|
|
16
17
|
/**
|
|
17
18
|
* Permissive type for constructing members incrementally before schema validation.
|
|
18
19
|
*
|
|
@@ -131,11 +132,12 @@ export interface DeclarationAnalysis {
|
|
|
131
132
|
*/
|
|
132
133
|
export interface ModuleExportsAnalysis {
|
|
133
134
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* from the original
|
|
135
|
+
* The parsed module-level comment, projected onto `ModuleJson` by
|
|
136
|
+
* `toModuleDocFields`. Always `undefined` for svelte2tsx virtual files —
|
|
137
|
+
* `analyzeSvelteModule` extracts Svelte module comments from the original
|
|
138
|
+
* source instead.
|
|
137
139
|
*/
|
|
138
|
-
|
|
140
|
+
moduleDoc?: TsdocParsedComment;
|
|
139
141
|
/** All exported declarations with `@nodocs` flags — consumer filters based on policy. */
|
|
140
142
|
declarations: Array<DeclarationAnalysis>;
|
|
141
143
|
/**
|
|
@@ -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,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,iBAAiB,EACjB,yBAAyB,EACzB,QAAQ,EACR,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"declaration-build.d.ts","sourceRoot":"../src/lib/","sources":["../src/lib/declaration-build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,sBAA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