sveld 0.35.1 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -10
- package/cli.js +1 -1
- package/lib/browser.d.ts +660 -39
- package/lib/browser.js +205 -227
- package/lib/chunk-0fqdg2xa.js +20 -0
- package/lib/chunk-2vwf7nck.js +1 -0
- package/lib/chunk-8myyzjb1.js +4 -0
- package/lib/chunk-as5hgj7e.js +62 -0
- package/lib/chunk-denfbw92.js +13 -0
- package/lib/chunk-h1r040pg.js +6 -0
- package/lib/chunk-m538qnhp.js +230 -0
- package/lib/chunk-r4rrncmd.js +1 -0
- package/lib/chunk-t9d5k3p7.js +2 -0
- package/lib/chunk-tmj7vnjr.js +10 -0
- package/lib/chunk-xryt7ad2.js +3 -0
- package/lib/cli-entry.js +1 -0
- package/lib/index.d.ts +767 -10
- package/lib/index.js +1 -343
- package/package.json +1 -1
- package/lib/ComponentParser.d.ts +0 -822
- package/lib/ast-guards.d.ts +0 -18
- package/lib/brands.d.ts +0 -11
- package/lib/bundle.d.ts +0 -176
- package/lib/check.d.ts +0 -43
- package/lib/cli.d.ts +0 -28
- package/lib/create-exports.d.ts +0 -32
- package/lib/dependency-graph.d.ts +0 -20
- package/lib/diagnostics.d.ts +0 -34
- package/lib/element-tag-map.d.ts +0 -146
- package/lib/example-check.d.ts +0 -24
- package/lib/get-svelte-entry.d.ts +0 -4
- package/lib/load-config.d.ts +0 -62
- package/lib/parse-cache.d.ts +0 -28
- package/lib/parse-entry-exports.d.ts +0 -30
- package/lib/parse-exports.d.ts +0 -25
- package/lib/parser/bindings.d.ts +0 -6
- package/lib/parser/context.d.ts +0 -114
- package/lib/parser/contexts.d.ts +0 -19
- package/lib/parser/diagnostics.d.ts +0 -8
- package/lib/parser/events.d.ts +0 -23
- package/lib/parser/generics.d.ts +0 -24
- package/lib/parser/jsdoc.d.ts +0 -59
- package/lib/parser/props.d.ts +0 -73
- package/lib/parser/rest-props.d.ts +0 -6
- package/lib/parser/runes-detection.d.ts +0 -16
- package/lib/parser/runes-props.d.ts +0 -18
- package/lib/parser/scopes.d.ts +0 -58
- package/lib/parser/slots.d.ts +0 -29
- package/lib/parser/source-position.d.ts +0 -30
- package/lib/parser/type-resolution.d.ts +0 -32
- package/lib/parser/typescript-casts.d.ts +0 -2
- package/lib/path.d.ts +0 -3
- package/lib/plugin.d.ts +0 -85
- package/lib/resolve-alias.d.ts +0 -30
- package/lib/resolve-types.d.ts +0 -52
- package/lib/sveld.d.ts +0 -29
- package/lib/validate.d.ts +0 -13
- package/lib/watch.d.ts +0 -34
- package/lib/writer/MarkdownWriterBase.d.ts +0 -26
- package/lib/writer/Writer.d.ts +0 -53
- package/lib/writer/WriterMarkdown.d.ts +0 -33
- package/lib/writer/built-in-writers.d.ts +0 -1
- package/lib/writer/document-model.d.ts +0 -34
- package/lib/writer/format-generated-ts.d.ts +0 -8
- package/lib/writer/markdown-format-utils.d.ts +0 -104
- package/lib/writer/markdown-render-utils.d.ts +0 -10
- package/lib/writer/registry.d.ts +0 -17
- package/lib/writer/writer-custom-elements-core.d.ts +0 -86
- package/lib/writer/writer-custom-elements.d.ts +0 -15
- package/lib/writer/writer-json.d.ts +0 -37
- package/lib/writer/writer-markdown-core.d.ts +0 -32
- package/lib/writer/writer-markdown.d.ts +0 -25
- package/lib/writer/writer-ts-definitions-core.d.ts +0 -38
- package/lib/writer/writer-ts-definitions.d.ts +0 -70
package/lib/ast-guards.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ArrowFunctionExpression, CallExpression, FunctionDeclaration, FunctionExpression, Identifier, Literal, MemberExpression, NewExpression, ObjectExpression, VariableDeclaration } from "estree";
|
|
2
|
-
export declare function isObject(value: unknown): value is Record<string, unknown>;
|
|
3
|
-
export declare function isVariableDeclaration(node: unknown): node is VariableDeclaration;
|
|
4
|
-
export declare function isLiteral(node: unknown): node is Literal;
|
|
5
|
-
export declare function isIdentifier(node: unknown): node is Identifier;
|
|
6
|
-
export declare function isMemberExpression(node: unknown): node is MemberExpression;
|
|
7
|
-
export declare function isObjectExpression(node: unknown): node is ObjectExpression;
|
|
8
|
-
export declare function isCallExpression(node: unknown): node is CallExpression;
|
|
9
|
-
export declare function isCallExpressionNamed(node: unknown, calleeName: string): node is CallExpression;
|
|
10
|
-
/** Unwraps `expr as Type` / `expr satisfies Type`, returning the innermost expression. */
|
|
11
|
-
export declare function unwrapTypeCastExpression(node: unknown): unknown;
|
|
12
|
-
/** The type node from `expr as Type` / `expr satisfies Type`, if `node` is such a cast. */
|
|
13
|
-
export declare function getTypeCastAnnotation(node: unknown): unknown;
|
|
14
|
-
export declare function isNewExpression(node: unknown): node is NewExpression;
|
|
15
|
-
export declare function isNewExpressionNamed(node: unknown, calleeName: string): node is NewExpression;
|
|
16
|
-
export declare function isFunctionDeclaration(node: unknown): node is FunctionDeclaration;
|
|
17
|
-
export declare function isFunctionExpression(node: unknown): node is FunctionExpression;
|
|
18
|
-
export declare function isArrowFunctionExpression(node: unknown): node is ArrowFunctionExpression;
|
package/lib/brands.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const brand: unique symbol;
|
|
2
|
-
export type Brand<TBase extends string, TBrand extends string> = TBase & {
|
|
3
|
-
readonly [brand]: TBrand;
|
|
4
|
-
};
|
|
5
|
-
export type SvelteEntryPoint = Brand<string, "SvelteEntryPoint">;
|
|
6
|
-
export declare function asSvelteEntryPoint(path: string): SvelteEntryPoint;
|
|
7
|
-
export type NormalizedPath = Brand<string, "NormalizedPath">;
|
|
8
|
-
export declare function asNormalizedPath(path: string): NormalizedPath;
|
|
9
|
-
export type RelativeSourcePath = Brand<string, "RelativeSourcePath">;
|
|
10
|
-
export declare function asRelativeSourcePath(path: string): RelativeSourcePath;
|
|
11
|
-
export {};
|
package/lib/bundle.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { asRelativeSourcePath, type NormalizedPath } from "./brands";
|
|
2
|
-
import { type ParsedComponent } from "./ComponentParser";
|
|
3
|
-
import { type SveldDiagnostic } from "./diagnostics";
|
|
4
|
-
import { ParseCache } from "./parse-cache";
|
|
5
|
-
import { type EntryExports } from "./parse-entry-exports";
|
|
6
|
-
import { type ParsedExports } from "./parse-exports";
|
|
7
|
-
export interface ComponentDocApi extends ParsedComponent {
|
|
8
|
-
filePath: NormalizedPath;
|
|
9
|
-
moduleName: string;
|
|
10
|
-
}
|
|
11
|
-
export type ComponentDocs = Map<string, ComponentDocApi>;
|
|
12
|
-
/**
|
|
13
|
-
* A parse failure for a single component, captured so the rest of the run
|
|
14
|
-
* can continue. Surfaced via {@link GenerateBundleResult.errors}.
|
|
15
|
-
*/
|
|
16
|
-
export interface ComponentParseError {
|
|
17
|
-
filePath: string;
|
|
18
|
-
moduleName: string;
|
|
19
|
-
message: string;
|
|
20
|
-
stack?: string;
|
|
21
|
-
}
|
|
22
|
-
export interface GenerateBundleResult {
|
|
23
|
-
exports: ParsedExports;
|
|
24
|
-
/** Entry-barrel exports other than components. Empty when `documentExports` is off. */
|
|
25
|
-
entryExports: EntryExports;
|
|
26
|
-
components: ComponentDocs;
|
|
27
|
-
allComponentsForTypes: ComponentDocs;
|
|
28
|
-
/**
|
|
29
|
-
* Components that failed to parse. Empty unless `failFast` is disabled and
|
|
30
|
-
* one or more components threw during parsing.
|
|
31
|
-
*/
|
|
32
|
-
errors: ComponentParseError[];
|
|
33
|
-
/** Unknown props, `any` contexts, and orphan `@event` tags across the bundle. */
|
|
34
|
-
diagnostics: SveldDiagnostic[];
|
|
35
|
-
}
|
|
36
|
-
export interface GenerateBundleOptions {
|
|
37
|
-
/**
|
|
38
|
-
* Throw on the first component that fails to parse instead of collecting
|
|
39
|
-
* the failure and continuing with the remaining components.
|
|
40
|
-
*/
|
|
41
|
-
failFast?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Load the TypeScript program to expand opaque imported whole-object `$props()`
|
|
44
|
-
* types into JSON/Markdown props. Off by default; requires `typescript`.
|
|
45
|
-
*/
|
|
46
|
-
resolveTypes?: boolean;
|
|
47
|
-
/** Record consts, functions, and types from the entry barrel. Off by default. */
|
|
48
|
-
documentExports?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Cache parsed component output to disk. Unchanged files skip re-parsing on
|
|
51
|
-
* later runs. On by default, writing to
|
|
52
|
-
* `node_modules/.cache/sveld/parse-cache.json`; a string sets a custom path.
|
|
53
|
-
* Pass `false` to disable.
|
|
54
|
-
*/
|
|
55
|
-
cache?: boolean | string;
|
|
56
|
-
/**
|
|
57
|
-
* Run plain TS/JS `@example` blocks on props, module exports, slots, and
|
|
58
|
-
* events through the TypeScript program. Broken examples become
|
|
59
|
-
* `example-compile-error` diagnostics. Svelte/HTML markup is skipped.
|
|
60
|
-
* Off by default. Requires `typescript`.
|
|
61
|
-
*/
|
|
62
|
-
checkExamples?: boolean;
|
|
63
|
-
}
|
|
64
|
-
export declare function toGenerateBundleOptions(opts?: Pick<GenerateBundleOptions, "failFast" | "resolveTypes" | "documentExports" | "cache" | "checkExamples">): GenerateBundleOptions;
|
|
65
|
-
/** A function that resolves a (possibly relative) component path to an absolute path. */
|
|
66
|
-
export type ResolveComponentFilePath = (filePath: string) => string;
|
|
67
|
-
/** Options controlling how a single component parse failure is handled. */
|
|
68
|
-
export interface ProcessComponentOptions {
|
|
69
|
-
/** Rethrow on parse failure instead of reporting it via `onParseError`. */
|
|
70
|
-
failFast?: boolean;
|
|
71
|
-
/** Invoked with a diagnostic when a component fails to parse (and `failFast` is off). */
|
|
72
|
-
onParseError?: (error: ComponentParseError) => void;
|
|
73
|
-
/** When set, reuse a component's previous parse if its content hash is unchanged. */
|
|
74
|
-
cache?: ParseCache;
|
|
75
|
-
/** Resolved file path -> sha256, computed once up front so it isn't re-hashed per pass. */
|
|
76
|
-
hashes?: Map<string, string>;
|
|
77
|
-
/**
|
|
78
|
-
* In-run memo of freshly parsed components, keyed by resolved file path and
|
|
79
|
-
* shared across the exported and all-components passes so a component that
|
|
80
|
-
* appears in both is only parsed once. Only fresh parses are stored here
|
|
81
|
-
* (never disk-cache hits), and an entry is cleared wherever the disk cache
|
|
82
|
-
* is invalidated so the `@extends` dependency-invalidation flow still forces
|
|
83
|
-
* a re-parse.
|
|
84
|
-
*/
|
|
85
|
-
memo?: Map<string, ParsedComponent>;
|
|
86
|
-
}
|
|
87
|
-
export declare function stripTopLevelStyleBlock(source: string): string;
|
|
88
|
-
/**
|
|
89
|
-
* Discovered component sources for an entry point, before parsing.
|
|
90
|
-
*
|
|
91
|
-
* `exports` holds explicitly exported components (used for JSON/Markdown);
|
|
92
|
-
* `allComponents` additionally includes glob-discovered components (used for
|
|
93
|
-
* `.d.ts` generation). `resolveComponentFilePath` maps a component `source`
|
|
94
|
-
* to its absolute path on disk.
|
|
95
|
-
*/
|
|
96
|
-
export interface CollectedComponents {
|
|
97
|
-
exports: ParsedExports;
|
|
98
|
-
allComponents: ParsedExports;
|
|
99
|
-
rootDir: string;
|
|
100
|
-
resolveComponentFilePath: ResolveComponentFilePath;
|
|
101
|
-
}
|
|
102
|
-
/** A `.svelte` file discovered on disk, before it's merged into `exports`/`allComponents`. */
|
|
103
|
-
export interface GlobbedComponentSource {
|
|
104
|
-
moduleName: string;
|
|
105
|
-
source: ReturnType<typeof asRelativeSourcePath>;
|
|
106
|
-
}
|
|
107
|
-
/** Globs every `.svelte` file under `rootDir`, resolving each to its module name and source path. */
|
|
108
|
-
export declare function globComponentSources(rootDir: string): GlobbedComponentSource[];
|
|
109
|
-
/**
|
|
110
|
-
* Discovers component sources for an entry point without parsing them.
|
|
111
|
-
*
|
|
112
|
-
* Parses the entry's exports (when `input` is a file) and, when `glob` is set,
|
|
113
|
-
* augments the set with every `.svelte` file under the entry directory.
|
|
114
|
-
*
|
|
115
|
-
* @param documentExports - When `true`, log and continue if the entry file fails
|
|
116
|
-
* the acorn component-export parse (TypeScript-only syntax is common).
|
|
117
|
-
*/
|
|
118
|
-
export declare function collectComponents(input: string, glob: boolean, documentExports?: boolean): CollectedComponents;
|
|
119
|
-
/**
|
|
120
|
-
* Reads the given component file paths into a map of path -> contents.
|
|
121
|
-
*
|
|
122
|
-
* Failed reads are recorded as `null` (and logged) so callers can skip them
|
|
123
|
-
* gracefully rather than aborting the whole bundle.
|
|
124
|
-
*/
|
|
125
|
-
export declare function readFileMap(filePaths: Iterable<string>): Promise<Map<string, string | null>>;
|
|
126
|
-
/**
|
|
127
|
-
* Parses a single component entry into its documentation API.
|
|
128
|
-
*
|
|
129
|
-
* Reads the component contents from `fileMap`, removes top-level styles for
|
|
130
|
-
* metadata parsing, and parses it to extract component metadata. Returns `null`
|
|
131
|
-
* for non-Svelte entries or files that could not be read.
|
|
132
|
-
*
|
|
133
|
-
* A component that throws while parsing is captured via `options.onParseError`
|
|
134
|
-
* (and `null` is returned) so callers can continue with the rest, unless
|
|
135
|
-
* `options.failFast` is set, in which case the error is rethrown.
|
|
136
|
-
*
|
|
137
|
-
* @param entry - Export entry tuple `[exportName, exportInfo]`
|
|
138
|
-
* @param entries - All sibling entries, used to resolve the module name
|
|
139
|
-
* @param fileMap - Map of resolved file paths to their contents
|
|
140
|
-
* @param resolveComponentFilePath - Resolves a component `source` to its absolute path
|
|
141
|
-
* @param options - Parse-failure handling (`failFast` / `onParseError`)
|
|
142
|
-
*/
|
|
143
|
-
export declare function processComponent([exportName, entry]: [string, ParsedExports[string]], entries: Array<[string, ParsedExports[string]]>, fileMap: Map<string, string | null>, resolveComponentFilePath: ResolveComponentFilePath, options?: ProcessComponentOptions): ComponentDocApi | null;
|
|
144
|
-
/** Collects the resolved, absolute paths of all `.svelte` entries. */
|
|
145
|
-
export declare function collectSvelteFilePaths(entriesList: Array<Array<[string, ParsedExports[string]]>>, resolveComponentFilePath: ResolveComponentFilePath): Set<string>;
|
|
146
|
-
/** Reports collected component parse errors to stderr. No-op when empty. */
|
|
147
|
-
export declare function reportParseErrors(errors: ComponentParseError[]): void;
|
|
148
|
-
/**
|
|
149
|
-
* Generates component documentation bundle from Svelte source files.
|
|
150
|
-
*
|
|
151
|
-
* Parses exports, discovers components (optionally via glob), and processes
|
|
152
|
-
* all Svelte files to extract component metadata. Returns both exported
|
|
153
|
-
* components (for JSON/Markdown) and all components (for TypeScript definitions).
|
|
154
|
-
*
|
|
155
|
-
* A single component that fails to parse is captured as a diagnostic (see
|
|
156
|
-
* {@link GenerateBundleResult.errors}) so the remaining components still emit
|
|
157
|
-
* output. Pass `{ failFast: true }` to restore abort-on-first-error behavior.
|
|
158
|
-
*
|
|
159
|
-
* @param input - Entry point file or directory containing Svelte components
|
|
160
|
-
* @param glob - Whether to glob for all .svelte files in the directory
|
|
161
|
-
* @param options - Bundle options (e.g. `failFast`, `resolveTypes`, `documentExports`)
|
|
162
|
-
* @returns Bundle result containing exports, entryExports, components, allComponentsForTypes, and errors
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```ts
|
|
166
|
-
* // Generate from single file:
|
|
167
|
-
* const result = await generateBundle("./src/App.svelte", false);
|
|
168
|
-
*
|
|
169
|
-
* // Generate from directory with glob:
|
|
170
|
-
* const result = await generateBundle("./src", true);
|
|
171
|
-
*
|
|
172
|
-
* // Abort on the first parse failure:
|
|
173
|
-
* const result = await generateBundle("./src", true, { failFast: true });
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
export declare function generateBundle(input: string, glob: boolean, options?: GenerateBundleOptions): Promise<GenerateBundleResult>;
|
package/lib/check.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { ComponentDocs } from "./bundle";
|
|
2
|
-
import type { SveldRuntimeOptions } from "./load-config";
|
|
3
|
-
import type { EntryExports } from "./parse-entry-exports";
|
|
4
|
-
import { type ComponentApiDocument } from "./writer/document-model";
|
|
5
|
-
export type SemverBump = "major" | "minor" | "patch" | "none";
|
|
6
|
-
/** One API diff between the committed snapshot and the current parse. */
|
|
7
|
-
export interface ApiChange {
|
|
8
|
-
/** Component `moduleName` this change belongs to, or `"*"` for document-wide notices. */
|
|
9
|
-
component: string;
|
|
10
|
-
kind: "component" | "prop" | "moduleExport" | "event" | "slot" | "shape";
|
|
11
|
-
/** Prop, event, slot, or shape-field name, when applicable. */
|
|
12
|
-
name?: string;
|
|
13
|
-
bump: SemverBump;
|
|
14
|
-
message: string;
|
|
15
|
-
}
|
|
16
|
-
export interface CheckResult {
|
|
17
|
-
/** `false` when there was nothing on disk to diff against (e.g. first run). */
|
|
18
|
-
snapshotExists: boolean;
|
|
19
|
-
snapshotFile: string;
|
|
20
|
-
changes: ApiChange[];
|
|
21
|
-
/** Highest bump across all changes. */
|
|
22
|
-
bump: SemverBump;
|
|
23
|
-
}
|
|
24
|
-
/** Diffs two `COMPONENT_API.json` documents and assigns a semver bump to each change. */
|
|
25
|
-
export declare function diffApiDocuments(previous: ComponentApiDocument, next: ComponentApiDocument): ApiChange[];
|
|
26
|
-
export interface RunCheckOptions {
|
|
27
|
-
/** Entry-barrel exports when `documentExports` is on. */
|
|
28
|
-
entryExports?: EntryExports;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Resolves the snapshot path for `check`: an explicit string wins, otherwise
|
|
32
|
-
* it falls back to the `json` writer's `outFile`, or `COMPONENT_API.json`.
|
|
33
|
-
*/
|
|
34
|
-
export declare function resolveCheckSnapshotFile(options: Pick<SveldRuntimeOptions, "check" | "jsonOptions">): string;
|
|
35
|
-
/**
|
|
36
|
-
* Diffs the current component set against a committed `COMPONENT_API.json`
|
|
37
|
-
* snapshot and assigns a semver bump to each change. Returns
|
|
38
|
-
* `snapshotExists: false` when no snapshot file exists yet, so the first
|
|
39
|
-
* run does not fail CI.
|
|
40
|
-
*/
|
|
41
|
-
export declare function runCheck(components: ComponentDocs, snapshotFile: string, options?: RunCheckOptions): Promise<CheckResult>;
|
|
42
|
-
/** Groups changes by component for CLI output. */
|
|
43
|
-
export declare function formatCheckReport(result: CheckResult): string;
|
package/lib/cli.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type SveldRuntimeOptions } from "./load-config";
|
|
2
|
-
/** CLI options: identical surface to the shared runtime options. */
|
|
3
|
-
type CliOptions = SveldRuntimeOptions;
|
|
4
|
-
/** Discriminated result of parsing the full argument list. */
|
|
5
|
-
export type CliParseResult = {
|
|
6
|
-
kind: "options";
|
|
7
|
-
options: CliOptions;
|
|
8
|
-
} | {
|
|
9
|
-
kind: "help";
|
|
10
|
-
} | {
|
|
11
|
-
kind: "version";
|
|
12
|
-
} | {
|
|
13
|
-
kind: "unknown";
|
|
14
|
-
arg: string;
|
|
15
|
-
};
|
|
16
|
-
export declare function parseCliOptions(argv: string[]): CliParseResult;
|
|
17
|
-
/**
|
|
18
|
-
* CLI entry point: parse flags, load any config file, generate docs, write
|
|
19
|
-
* outputs.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* // Called from CLI: sveld --types --json --glob
|
|
24
|
-
* // Parses: { types: true, json: true, glob: true }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export declare function cli(process: NodeJS.Process): Promise<void>;
|
|
28
|
-
export {};
|
package/lib/create-exports.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ParsedExports } from "./parse-exports";
|
|
2
|
-
/**
|
|
3
|
-
* Builds export statements from parsed export metadata.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* // Input:
|
|
8
|
-
* { Button: { source: "./Button.svelte", default: true } }
|
|
9
|
-
*
|
|
10
|
-
* // Output:
|
|
11
|
-
* // export { default as Button } from "./Button.svelte";
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare function createExports(parsed_exports: ParsedExports): string;
|
|
15
|
-
/**
|
|
16
|
-
* Strips the `.svelte` extension from a path.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* removeSvelteExt("./Button.svelte") // Returns: "./Button"
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function removeSvelteExt(filePath: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* Maps a `.svelte` path to its `.svelte.d.ts` definition path.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* convertSvelteExt("./Button.svelte") // Returns: "./Button.svelte.d.ts"
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export declare function convertSvelteExt(filePath: string): string;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ComponentDocApi, ComponentDocs, ResolveComponentFilePath } from "./bundle";
|
|
2
|
-
/**
|
|
3
|
-
* Resolves a component's `@extendProps` / `@extends` target to an absolute path,
|
|
4
|
-
* or `null` when it doesn't point at a local `.svelte` file (e.g. it references
|
|
5
|
-
* an external package interface like `carbon-components-svelte`).
|
|
6
|
-
*/
|
|
7
|
-
export declare function resolveExtendsDependency(api: ComponentDocApi, componentPath: string): string | null;
|
|
8
|
-
/**
|
|
9
|
-
* Builds a reverse-dependency map: `dependencyPath -> set of dependent paths`.
|
|
10
|
-
*
|
|
11
|
-
* A component is a dependent of `X` when it extends `X` via `@extendProps` /
|
|
12
|
-
* `@extends`. When `X` changes, every dependent must be re-parsed.
|
|
13
|
-
*/
|
|
14
|
-
export declare function buildReverseDeps(components: ComponentDocs, resolveComponentFilePath: ResolveComponentFilePath): Map<string, Set<string>>;
|
|
15
|
-
/**
|
|
16
|
-
* Expands the set of changed paths to include every transitive dependent via
|
|
17
|
-
* the reverse-dependency map (e.g. editing `Button.svelte` also marks the
|
|
18
|
-
* `SecondaryButton.svelte` that `@extendProps`-es it).
|
|
19
|
-
*/
|
|
20
|
-
export declare function expandAffected(changed: Iterable<string>, reverseDeps: Map<string, Set<string>>): Set<string>;
|
package/lib/diagnostics.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { SourceRange } from "./ComponentParser";
|
|
2
|
-
/**
|
|
3
|
-
* Why sveld could not pin a type during parsing.
|
|
4
|
-
*
|
|
5
|
-
* - `prop-unknown-type`: prop `typeSource` is `"unknown"`.
|
|
6
|
-
* - `context-any-type`: `setContext` value inferred as `any`.
|
|
7
|
-
* - `event-no-source`: `@event` with no dispatch, forward, or callback prop.
|
|
8
|
-
* - `example-compile-error`: an `@example` block failed to type-check (opt-in, `checkExamples`).
|
|
9
|
-
* - `syntax-skipped`: `$props()`/`{@render}` syntax the parser can't model; omitted from output.
|
|
10
|
-
*/
|
|
11
|
-
export type SveldDiagnosticKind = "prop-unknown-type" | "context-any-type" | "event-no-source" | "example-compile-error" | "syntax-skipped";
|
|
12
|
-
/**
|
|
13
|
-
* One place sveld had to guess a type instead of inferring it.
|
|
14
|
-
*/
|
|
15
|
-
export interface SveldDiagnostic {
|
|
16
|
-
/** File this came from, e.g. `"./Button.svelte"`. */
|
|
17
|
-
component: string;
|
|
18
|
-
kind: SveldDiagnosticKind;
|
|
19
|
-
/** Prop, context field, or event name. */
|
|
20
|
-
name: string;
|
|
21
|
-
/** What went wrong and what type sveld used. */
|
|
22
|
-
message: string;
|
|
23
|
-
/** Where in the component source this diagnostic points, when the parser holds a stable position. */
|
|
24
|
-
source?: SourceRange;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Drop duplicates (same component, kind, and name). Each file is parsed twice
|
|
28
|
-
* when building exports and `.d.ts`, so without this the CLI summary doubles.
|
|
29
|
-
*/
|
|
30
|
-
export declare function dedupeDiagnostics(diagnostics: SveldDiagnostic[]): SveldDiagnostic[];
|
|
31
|
-
/**
|
|
32
|
-
* Group diagnostics by kind and component for CLI output.
|
|
33
|
-
*/
|
|
34
|
-
export declare function formatDiagnosticsSummary(diagnostics: SveldDiagnostic[]): string;
|
package/lib/element-tag-map.d.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tag-to-DOM-type map from TypeScript `lib.dom.d.ts`. Unknown tags fall back to `HTMLElement`.
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* tag_map["button"] // "HTMLButtonElement"
|
|
7
|
-
* tag_map["div"] // "HTMLDivElement"
|
|
8
|
-
* tag_map["input"] // "HTMLInputElement"
|
|
9
|
-
* ```
|
|
10
|
-
*/
|
|
11
|
-
declare const tag_map: {
|
|
12
|
-
a: string;
|
|
13
|
-
abbr: string;
|
|
14
|
-
address: string;
|
|
15
|
-
applet: string;
|
|
16
|
-
area: string;
|
|
17
|
-
article: string;
|
|
18
|
-
aside: string;
|
|
19
|
-
audio: string;
|
|
20
|
-
b: string;
|
|
21
|
-
base: string;
|
|
22
|
-
basefont: string;
|
|
23
|
-
bdi: string;
|
|
24
|
-
bdo: string;
|
|
25
|
-
blockquote: string;
|
|
26
|
-
body: string;
|
|
27
|
-
br: string;
|
|
28
|
-
button: string;
|
|
29
|
-
canvas: string;
|
|
30
|
-
caption: string;
|
|
31
|
-
cite: string;
|
|
32
|
-
code: string;
|
|
33
|
-
col: string;
|
|
34
|
-
colgroup: string;
|
|
35
|
-
data: string;
|
|
36
|
-
datalist: string;
|
|
37
|
-
dd: string;
|
|
38
|
-
del: string;
|
|
39
|
-
details: string;
|
|
40
|
-
dfn: string;
|
|
41
|
-
dialog: string;
|
|
42
|
-
dir: string;
|
|
43
|
-
div: string;
|
|
44
|
-
dl: string;
|
|
45
|
-
dt: string;
|
|
46
|
-
em: string;
|
|
47
|
-
embed: string;
|
|
48
|
-
fieldset: string;
|
|
49
|
-
figcaption: string;
|
|
50
|
-
figure: string;
|
|
51
|
-
font: string;
|
|
52
|
-
footer: string;
|
|
53
|
-
form: string;
|
|
54
|
-
frame: string;
|
|
55
|
-
frameset: string;
|
|
56
|
-
h1: string;
|
|
57
|
-
h2: string;
|
|
58
|
-
h3: string;
|
|
59
|
-
h4: string;
|
|
60
|
-
h5: string;
|
|
61
|
-
h6: string;
|
|
62
|
-
head: string;
|
|
63
|
-
header: string;
|
|
64
|
-
hgroup: string;
|
|
65
|
-
hr: string;
|
|
66
|
-
html: string;
|
|
67
|
-
i: string;
|
|
68
|
-
iframe: string;
|
|
69
|
-
img: string;
|
|
70
|
-
input: string;
|
|
71
|
-
ins: string;
|
|
72
|
-
kbd: string;
|
|
73
|
-
label: string;
|
|
74
|
-
legend: string;
|
|
75
|
-
li: string;
|
|
76
|
-
link: string;
|
|
77
|
-
main: string;
|
|
78
|
-
map: string;
|
|
79
|
-
mark: string;
|
|
80
|
-
marquee: string;
|
|
81
|
-
menu: string;
|
|
82
|
-
meta: string;
|
|
83
|
-
meter: string;
|
|
84
|
-
nav: string;
|
|
85
|
-
noscript: string;
|
|
86
|
-
object: string;
|
|
87
|
-
ol: string;
|
|
88
|
-
optgroup: string;
|
|
89
|
-
option: string;
|
|
90
|
-
output: string;
|
|
91
|
-
p: string;
|
|
92
|
-
param: string;
|
|
93
|
-
picture: string;
|
|
94
|
-
pre: string;
|
|
95
|
-
progress: string;
|
|
96
|
-
q: string;
|
|
97
|
-
rp: string;
|
|
98
|
-
rt: string;
|
|
99
|
-
ruby: string;
|
|
100
|
-
s: string;
|
|
101
|
-
samp: string;
|
|
102
|
-
script: string;
|
|
103
|
-
search: string;
|
|
104
|
-
section: string;
|
|
105
|
-
select: string;
|
|
106
|
-
slot: string;
|
|
107
|
-
small: string;
|
|
108
|
-
source: string;
|
|
109
|
-
span: string;
|
|
110
|
-
strong: string;
|
|
111
|
-
style: string;
|
|
112
|
-
sub: string;
|
|
113
|
-
summary: string;
|
|
114
|
-
sup: string;
|
|
115
|
-
table: string;
|
|
116
|
-
tbody: string;
|
|
117
|
-
td: string;
|
|
118
|
-
template: string;
|
|
119
|
-
textarea: string;
|
|
120
|
-
tfoot: string;
|
|
121
|
-
th: string;
|
|
122
|
-
thead: string;
|
|
123
|
-
time: string;
|
|
124
|
-
title: string;
|
|
125
|
-
tr: string;
|
|
126
|
-
track: string;
|
|
127
|
-
u: string;
|
|
128
|
-
ul: string;
|
|
129
|
-
var: string;
|
|
130
|
-
video: string;
|
|
131
|
-
wbr: string;
|
|
132
|
-
};
|
|
133
|
-
type ElementTag = keyof typeof tag_map;
|
|
134
|
-
export declare function isElementTag(element: string): element is ElementTag;
|
|
135
|
-
/**
|
|
136
|
-
* Returns the DOM interface for a tag, or `HTMLElement` when unknown.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* getElementByTag("button") // Returns: "HTMLButtonElement"
|
|
141
|
-
* getElementByTag("div") // Returns: "HTMLDivElement"
|
|
142
|
-
* getElementByTag("custom") // Returns: "HTMLElement" (fallback)
|
|
143
|
-
* ```
|
|
144
|
-
*/
|
|
145
|
-
export declare function getElementByTag(element: string): string;
|
|
146
|
-
export {};
|
package/lib/example-check.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { ParsedComponent, SourceRange } from "./ComponentParser";
|
|
2
|
-
/**
|
|
3
|
-
* One `@example` block worth type-checking, reduced to what `resolve-types.ts`
|
|
4
|
-
* needs: a declaration for the documented symbol and the example body itself.
|
|
5
|
-
*/
|
|
6
|
-
export interface ExampleCheckSource {
|
|
7
|
-
/** Stable id for diagnostics, e.g. `"prop:variant"` or `"prop:variant#1"` for a second example. */
|
|
8
|
-
id: string;
|
|
9
|
-
/** Human-readable name shown in diagnostics, e.g. `"variant"` or `"variant (example 2)"`. */
|
|
10
|
-
name: string;
|
|
11
|
-
/** TypeScript type to bind the documented symbol to before running `code`. */
|
|
12
|
-
type: string;
|
|
13
|
-
/** The `@example` body, stripped of any surrounding code fence. */
|
|
14
|
-
code: string;
|
|
15
|
-
/** Source range of the documented symbol (prop/export/slot/event), when available. */
|
|
16
|
-
source?: SourceRange;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Collects every `@example` block sveld can type-check for a parsed component:
|
|
20
|
-
* plain TS/JS bodies on props, module exports, slots, and events. Svelte/HTML
|
|
21
|
-
* markup examples (most slot/event examples, many prop examples) are skipped.
|
|
22
|
-
* Checking those needs `svelte2tsx` or similar; sveld stays AST-only.
|
|
23
|
-
*/
|
|
24
|
-
export declare function collectExampleSources(component: ParsedComponent): ExampleCheckSource[];
|
package/lib/load-config.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { PluginSveldOptions } from "./plugin";
|
|
2
|
-
/**
|
|
3
|
-
* Options shared by the config file, the CLI, and the programmatic `sveld()`
|
|
4
|
-
* API. Superset of `PluginSveldOptions` with the CLI-oriented flags that only
|
|
5
|
-
* make sense as part of a full `sveld` run (not the Vite/Rollup plugin).
|
|
6
|
-
*/
|
|
7
|
-
export interface SveldRuntimeOptions extends PluginSveldOptions {
|
|
8
|
-
/** Print unresolved-type diagnostics to stderr. */
|
|
9
|
-
reportDiagnostics?: boolean;
|
|
10
|
-
/** Exit code 1 when diagnostics exist. Implies `reportDiagnostics`. */
|
|
11
|
-
strict?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Diff the parsed component API against a committed snapshot (default:
|
|
14
|
-
* the `json` writer's `outFile`, or `COMPONENT_API.json`) and assign a
|
|
15
|
-
* semver bump to each change. Exits `1` on a breaking change. Pass a
|
|
16
|
-
* string for a custom snapshot path.
|
|
17
|
-
*/
|
|
18
|
-
check?: boolean | string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Public shape of a `sveld.config.{js,ts,mjs}` file. Identical to the options
|
|
22
|
-
* accepted by the CLI and the programmatic `sveld()` API.
|
|
23
|
-
*/
|
|
24
|
-
export type SveldConfig = SveldRuntimeOptions;
|
|
25
|
-
/** Config file names probed at the project root. First existing file wins. */
|
|
26
|
-
export declare const CONFIG_FILE_NAMES: readonly ["sveld.config.js", "sveld.config.mjs", "sveld.config.ts"];
|
|
27
|
-
/**
|
|
28
|
-
* Identity helper that fully types a `sveld` config object.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* // sveld.config.js
|
|
33
|
-
* import { defineConfig } from "sveld";
|
|
34
|
-
*
|
|
35
|
-
* export default defineConfig({
|
|
36
|
-
* glob: true,
|
|
37
|
-
* json: true,
|
|
38
|
-
* markdown: true,
|
|
39
|
-
* });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare function defineConfig(config: SveldConfig): SveldConfig;
|
|
43
|
-
/** Locate a `sveld.config.{js,mjs,ts}` file in `cwd`, or `null` if none exists. */
|
|
44
|
-
export declare function resolveConfigPath(cwd?: string): string | null;
|
|
45
|
-
/**
|
|
46
|
-
* Load and validate a `sveld` config file by absolute path.
|
|
47
|
-
*
|
|
48
|
-
* The package is ESM-only, so the file is loaded via dynamic `import()`. A
|
|
49
|
-
* cache-busting query is appended so repeated loads (e.g. across tests or
|
|
50
|
-
* watch runs) reflect the latest contents.
|
|
51
|
-
*
|
|
52
|
-
* @throws if the module cannot be imported (e.g. a syntax error or a config
|
|
53
|
-
* that throws at evaluation time) or if it does not default-export an object.
|
|
54
|
-
*/
|
|
55
|
-
export declare function loadConfigFrom(configPath: string): Promise<SveldConfig>;
|
|
56
|
-
/**
|
|
57
|
-
* Discover and load a `sveld.config.{js,mjs,ts}` file from `cwd`.
|
|
58
|
-
* Returns an empty object when no config file is present.
|
|
59
|
-
*/
|
|
60
|
-
export declare function loadConfig(cwd?: string): Promise<SveldConfig>;
|
|
61
|
-
/** Shallow-merge option sources. Later sources override earlier ones. */
|
|
62
|
-
export declare function mergeConfig<T extends PluginSveldOptions = PluginSveldOptions>(...sources: Array<Partial<T> | undefined>): Partial<T>;
|
package/lib/parse-cache.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type ParsedComponent } from "./ComponentParser";
|
|
2
|
-
/** Default on-disk location for the persistent parse cache, relative to the project root. */
|
|
3
|
-
export declare const DEFAULT_CACHE_FILE: string;
|
|
4
|
-
/** Resolves the effective cache file path for `cache: true | string`. */
|
|
5
|
-
export declare function resolveCacheFilePath(rootDir: string, cache: boolean | string): string;
|
|
6
|
-
export declare function hashSource(source: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* Cross-run parse cache. Entries match on file path and sha256 of source.
|
|
9
|
-
* Symbol-keyed TypeScript metadata is stored separately because JSON drops symbols.
|
|
10
|
-
*/
|
|
11
|
-
export declare class ParseCache {
|
|
12
|
-
private readonly cacheFilePath;
|
|
13
|
-
private readonly file;
|
|
14
|
-
private readonly next;
|
|
15
|
-
/** Paths forced to miss this run (e.g. dependents of a changed `@extends` target). */
|
|
16
|
-
private readonly blocked;
|
|
17
|
-
constructor(cacheFilePath: string);
|
|
18
|
-
/** True when `get()` would return a hit for `resolvedPath` and `hash`. */
|
|
19
|
-
has(resolvedPath: string, hash: string): boolean;
|
|
20
|
-
/** Returns the cached parse for `resolvedPath` when its content hash still matches. */
|
|
21
|
-
get(resolvedPath: string, hash: string): ParsedComponent | null;
|
|
22
|
-
/** Records a freshly parsed component so it can be reused on a future run. */
|
|
23
|
-
set(resolvedPath: string, hash: string, parsed: ParsedComponent): void;
|
|
24
|
-
/** Skip cache for `resolvedPath` this run (e.g. an @extends dependent). */
|
|
25
|
-
invalidate(resolvedPath: string): void;
|
|
26
|
-
/** Persists this run's cache entries back to disk. */
|
|
27
|
-
save(): void;
|
|
28
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** One named export from the entry barrel (not a `.svelte` component). */
|
|
2
|
-
export interface EntryExport {
|
|
3
|
-
name: string;
|
|
4
|
-
kind: "const" | "let" | "var" | "function" | "class" | "type" | "interface" | "enum";
|
|
5
|
-
/** Type text from the source, when present. */
|
|
6
|
-
type?: string;
|
|
7
|
-
/** Initializer text for simple constants. */
|
|
8
|
-
value?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
/** Declaring module, relative to the entry file. */
|
|
11
|
-
source?: string;
|
|
12
|
-
isTypeOnly: boolean;
|
|
13
|
-
}
|
|
14
|
-
export type EntryExports = EntryExport[];
|
|
15
|
-
/**
|
|
16
|
-
* List consts, functions, and types exported from an entry barrel.
|
|
17
|
-
*
|
|
18
|
-
* Follows re-exports with AST-only traversal. Skips `.svelte` files.
|
|
19
|
-
*
|
|
20
|
-
* @param entryFile - Absolute path to the entry module.
|
|
21
|
-
* @returns Exports deduplicated by name, sorted alphabetically.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* // entry: export { VERSION } from "./constants"; export type { Theme } from "./types";
|
|
26
|
-
* parseEntryExports("/abs/src/index.ts");
|
|
27
|
-
* // [{ name: "Theme", kind: "type", isTypeOnly: true, ... }, { name: "VERSION", kind: "const", ... }]
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare function parseEntryExports(entryFile: string): EntryExports;
|