sveld 0.35.2 → 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 -6
- package/lib/browser.d.ts +660 -39
- package/lib/browser.js +172 -172
- package/lib/chunk-0fqdg2xa.js +20 -0
- package/lib/chunk-2vwf7nck.js +1 -0
- package/lib/chunk-8myyzjb1.js +4 -0
- package/lib/{chunk-v4q9vw0y.js → chunk-as5hgj7e.js} +57 -57
- package/lib/{chunk-zva3xjwa.js → chunk-denfbw92.js} +1 -1
- package/lib/chunk-h1r040pg.js +6 -0
- package/lib/chunk-m538qnhp.js +230 -0
- package/lib/chunk-r4rrncmd.js +1 -0
- package/lib/{chunk-1p4ka68s.js → chunk-t9d5k3p7.js} +1 -1
- package/lib/{chunk-8xw75w8t.js → chunk-tmj7vnjr.js} +2 -2
- package/lib/chunk-xryt7ad2.js +3 -0
- package/lib/cli-entry.js +1 -1
- package/lib/index.d.ts +767 -10
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/lib/ComponentParser.d.ts +0 -560
- package/lib/ast-guards.d.ts +0 -16
- package/lib/brands.d.ts +0 -11
- package/lib/bundle.d.ts +0 -174
- package/lib/check.d.ts +0 -43
- package/lib/chunk-72hx9e9w.js +0 -20
- package/lib/chunk-7qz0hzgw.js +0 -217
- package/lib/chunk-cxrw7gzr.js +0 -2
- package/lib/chunk-jdnsv86e.js +0 -1
- package/lib/chunk-pmj8c3yv.js +0 -6
- package/lib/chunk-s9mzxa4y.js +0 -1
- package/lib/chunk-xkrgedm4.js +0 -4
- package/lib/cli-entry.d.ts +0 -12
- 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 -3
- 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/parsed-component-metadata.d.ts +0 -13
- package/lib/parser/bindings.d.ts +0 -4
- package/lib/parser/context.d.ts +0 -72
- package/lib/parser/contexts.d.ts +0 -19
- package/lib/parser/diagnostics.d.ts +0 -8
- package/lib/parser/events.d.ts +0 -21
- package/lib/parser/generics.d.ts +0 -24
- package/lib/parser/jsdoc.d.ts +0 -55
- package/lib/parser/prop-shared.d.ts +0 -84
- package/lib/parser/props.d.ts +0 -71
- package/lib/parser/rest-props.d.ts +0 -4
- package/lib/parser/runes-detection.d.ts +0 -13
- package/lib/parser/runes-props.d.ts +0 -18
- package/lib/parser/scopes.d.ts +0 -56
- package/lib/parser/slots.d.ts +0 -24
- package/lib/parser/source-position.d.ts +0 -26
- package/lib/parser/type-resolution.d.ts +0 -17
- package/lib/parser/typescript-casts.d.ts +0 -1
- package/lib/parser/utils.d.ts +0 -1
- package/lib/parser/variable-jsdoc.d.ts +0 -12
- package/lib/parser-stack.d.ts +0 -20
- package/lib/path.d.ts +0 -2
- 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/svelte-parse.d.ts +0 -4
- package/lib/svelte-version.d.ts +0 -1
- 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 -31
- package/lib/writer/WriterMarkdown.d.ts +0 -31
- 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 -20
- 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 -27
- package/lib/writer/writer-markdown-core.d.ts +0 -32
- package/lib/writer/writer-markdown.d.ts +0 -23
- package/lib/writer/writer-ts-definitions-core.d.ts +0 -30
- package/lib/writer/writer-ts-definitions.d.ts +0 -43
package/lib/parser/props.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ArrowFunctionExpression, FunctionDeclaration, FunctionExpression } from "estree";
|
|
2
|
-
import type ComponentParser from "../ComponentParser";
|
|
3
|
-
import type { ComponentProp, ComponentPropParam, ProcessedInitializer } from "../ComponentParser";
|
|
4
|
-
import type { ParserContext } from "./context";
|
|
5
|
-
export declare function addProp(parser: ComponentParser, ctx: ParserContext, prop_name: string, data: ComponentProp): void;
|
|
6
|
-
export declare function processInitializer(parser: ComponentParser, ctx: ParserContext, init: unknown, depth?: number): ProcessedInitializer;
|
|
7
|
-
/**
|
|
8
|
-
* Look up a local variable's initializer AST node by name.
|
|
9
|
-
* Returns the init node if found, or undefined.
|
|
10
|
-
*/
|
|
11
|
-
export declare function resolveLocalVarInitializer(ctx: ParserContext, name: string): unknown | undefined;
|
|
12
|
-
/**
|
|
13
|
-
* Look up the initializer for a local `const` by name.
|
|
14
|
-
*
|
|
15
|
-
* {@link resolveLocalVarInitializer} also walks `let`/`var`. This method does not.
|
|
16
|
-
* Props and mutable bindings can change at runtime, so they cannot be context keys.
|
|
17
|
-
*
|
|
18
|
-
* @param name - The variable name to look up
|
|
19
|
-
* @returns The initializer node for a matching `const` binding, or undefined
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveConstInitializer(ctx: ParserContext, name: string): unknown | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Build a function type from `@param`/`@returns` when `@type` is missing.
|
|
24
|
-
* If JSDoc has no params or return either, try the function `node`, then
|
|
25
|
-
* `(...args: any[]) => any`.
|
|
26
|
-
*/
|
|
27
|
-
export declare function buildFunctionTypeFromParts(jsdoc?: {
|
|
28
|
-
params?: ComponentPropParam[];
|
|
29
|
-
returnType?: string;
|
|
30
|
-
}, node?: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression): string;
|
|
31
|
-
/**
|
|
32
|
-
* Guess arity and return type for a function default with no JSDoc `@type`.
|
|
33
|
-
* Explicit `@type`/`@param`/`@returns` on the prop beat this every time.
|
|
34
|
-
* A default's body is a weak signal for the prop contract. We only read
|
|
35
|
-
* named params and literal returns. Everything else becomes `any`.
|
|
36
|
-
*/
|
|
37
|
-
export declare function inferFunctionTypeFromNode(node: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression): string;
|
|
38
|
-
/**
|
|
39
|
-
* Turn params into `name: any`, or use `...args: any[]` when arity is unclear:
|
|
40
|
-
* no params, destructuring, rest, or defaults.
|
|
41
|
-
*/
|
|
42
|
-
export declare function inferParamsFromNode(node: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression): string;
|
|
43
|
-
/**
|
|
44
|
-
* Infer return type from literal returns only. Every `return` must agree on
|
|
45
|
-
* the same primitive. Bare `return;`, no returns, identifiers, calls,
|
|
46
|
-
* objects, ternaries, async, or generators all become `any`.
|
|
47
|
-
*/
|
|
48
|
-
export declare function inferReturnTypeFromNode(node: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression): string;
|
|
49
|
-
/**
|
|
50
|
-
* Walk a block body and collect each `return`'s argument, skipping nested
|
|
51
|
-
* functions. Bare `return;` becomes `null`.
|
|
52
|
-
*
|
|
53
|
-
* Not fused with the componentRoot walk: this runs from `processInitializer`, called
|
|
54
|
-
* synchronously while the outer walk is still on the ancestor `ExportNamedDeclaration`/
|
|
55
|
-
* `VariableDeclaration` node, so it needs the inferred type before the outer walk would
|
|
56
|
-
* otherwise reach these descendant statements. Deferring it to ride along with the outer
|
|
57
|
-
* traversal would mean computing prop types in a second pass instead of inline.
|
|
58
|
-
*/
|
|
59
|
-
export declare function collectReturnArguments(body: unknown): unknown[];
|
|
60
|
-
/**
|
|
61
|
-
* Map one return expression to `string`, `number`, or `boolean`, or `null`
|
|
62
|
-
* if it isn't a literal, template literal, or `String`/`Number`/`Boolean` call.
|
|
63
|
-
*/
|
|
64
|
-
export declare function inferReturnPrimitive(expr: unknown): "string" | "number" | "boolean" | null;
|
|
65
|
-
/**
|
|
66
|
-
* Unwraps `$bindable(...)` calls so defaults are documented as their underlying values.
|
|
67
|
-
*/
|
|
68
|
-
export declare function unwrapBindableInitializer(init: unknown): {
|
|
69
|
-
init?: unknown;
|
|
70
|
-
bindable: boolean;
|
|
71
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { SyntaxMode } from "../ComponentParser";
|
|
2
|
-
import type { ParserContext } from "./context";
|
|
3
|
-
/**
|
|
4
|
-
* Determines a component's syntax mode without running the svelte compiler's analyze phase.
|
|
5
|
-
*
|
|
6
|
-
* Mirrors `analyze_component`'s own logic (`node_modules/svelte/src/compiler/phases/2-analyze/index.js`):
|
|
7
|
-
* an explicit `<svelte:options runes={...} />` always wins; otherwise the component is in runes
|
|
8
|
-
* mode if any rune name is referenced - and not shadowed by a local declaration of the same name -
|
|
9
|
-
* anywhere in the module script, instance script, or template.
|
|
10
|
-
*
|
|
11
|
-
* Mirrors svelte analyze runes detection. Omitted: top-level `await` forces runes (no fixture).
|
|
12
|
-
*/
|
|
13
|
-
export declare function detectSyntaxMode(ctx: ParserContext): SyntaxMode;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { VariableDeclaration } from "estree";
|
|
2
|
-
import type ComponentParser from "../ComponentParser";
|
|
3
|
-
import type { ModernRunesTypeNode, RunesPropTypeMetadata } from "../ComponentParser";
|
|
4
|
-
import type { ParserContext } from "./context";
|
|
5
|
-
/** Flatten a runes `$props()` type node into prop name -> metadata, following local aliases and intersections. */
|
|
6
|
-
export declare function buildRunesPropTypeMetadataMap(parser: ComponentParser, ctx: ParserContext, typeNode: ModernRunesTypeNode | undefined, localTypeDeclarations: Map<string, ModernRunesTypeNode>, visitedTypeNames?: Set<string>): Map<string, RunesPropTypeMetadata>;
|
|
7
|
-
/**
|
|
8
|
-
* Re-parse `ctx.source` in modern AST mode before the legacy walk: type imports,
|
|
9
|
-
* local types, explicit `export let` annotations, and `$props()` metadata.
|
|
10
|
-
*/
|
|
11
|
-
export declare function buildRunesPropTypeMetadata(parser: ComponentParser, ctx: ParserContext): void;
|
|
12
|
-
/** Top-level `$props()` declarations in runes components. */
|
|
13
|
-
export declare function parseRunesPropsDeclaration(parser: ComponentParser, ctx: ParserContext, node: VariableDeclaration): void;
|
|
14
|
-
/**
|
|
15
|
-
* Runes-only: fold phantom `@event` entries into matching `on<Event>` callback props
|
|
16
|
-
* when nothing in the component actually dispatches that event.
|
|
17
|
-
*/
|
|
18
|
-
export declare function normalizeRunesCallbackProps(ctx: ParserContext, actuallyDispatchedEvents: Set<string>): void;
|
package/lib/parser/scopes.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { ArrowFunctionExpression, Expression, FunctionDeclaration, FunctionExpression, Pattern, VariableDeclaration, VariableDeclarator } from "estree";
|
|
2
|
-
import type ComponentParser from "../ComponentParser";
|
|
3
|
-
import type { LexicalScope, ScopeBinding, ScopeBindingKind } from "../ComponentParser";
|
|
4
|
-
import type { ParserContext } from "./context";
|
|
5
|
-
export declare function declareScopeBinding(scope: LexicalScope, name: string, binding: ScopeBinding): void;
|
|
6
|
-
export declare function resolveIdentifierToReactiveProp(ctx: ParserContext, name: string): string | undefined;
|
|
7
|
-
/** Collects all identifier names bound by a destructuring/assignment pattern (or plain expression). */
|
|
8
|
-
export declare function collectPatternIdentifiers(target: Pattern | Expression | null | undefined, names?: Set<string>): Set<string>;
|
|
9
|
-
/** Marks any reactive props referenced by a mutation target (assignment LHS / update argument) as reactive. */
|
|
10
|
-
export declare function markReactivePropsFromMutationTarget(ctx: ParserContext, target: Pattern | Expression | null | undefined): void;
|
|
11
|
-
/** True for AST/Svelte node types that introduce a new lexical scope. */
|
|
12
|
-
export declare function isScopeOwner(node: unknown): boolean;
|
|
13
|
-
/** True for node types that introduce a new `var`-hoisting (function) scope. */
|
|
14
|
-
export declare function isFunctionScopeOwner(node: unknown): boolean;
|
|
15
|
-
/** Returns the scope map for `node`, creating and caching an empty one on first access. */
|
|
16
|
-
export declare function getOrCreateScope(ctx: ParserContext, node: object): LexicalScope;
|
|
17
|
-
/** Scope bindings from `const { a, b: c } = $props()`. Destructured props are `prop`; rest is `local`. */
|
|
18
|
-
export declare function extractRunesScopeBindings(parser: ComponentParser, _node: VariableDeclaration, declarator: VariableDeclarator): {
|
|
19
|
-
kind: ScopeBindingKind;
|
|
20
|
-
name: string;
|
|
21
|
-
publicPropName?: string;
|
|
22
|
-
}[];
|
|
23
|
-
/** Declares bindings for every declarator in a `var`/`let`/`const` declaration into the appropriate scope. */
|
|
24
|
-
export declare function declareVariableDeclaration(parser: ComponentParser, declaration: unknown, lexicalScope: LexicalScope, varScope: LexicalScope, options?: {
|
|
25
|
-
allowRunesProps?: boolean;
|
|
26
|
-
forceProp?: boolean;
|
|
27
|
-
}): void;
|
|
28
|
-
/** Declares a function-like node's own name (if any) and its parameter bindings into `scope`. */
|
|
29
|
-
export declare function declareFunctionLikeScopeBindings(node: FunctionExpression | ArrowFunctionExpression | FunctionDeclaration, scope: LexicalScope): void;
|
|
30
|
-
/** Declares top-level `var`/`function`/`class` bindings directly within a block's statement list. */
|
|
31
|
-
export declare function collectDirectBlockDeclarations(parser: ComponentParser, body: unknown, lexicalScope: LexicalScope, varScope: LexicalScope): void;
|
|
32
|
-
/** Declares all component-instance-level (`<script>`) bindings into `ctx.componentScope`. */
|
|
33
|
-
export declare function collectComponentScopeDeclarations(parser: ComponentParser, ctx: ParserContext, instance: unknown): void;
|
|
34
|
-
/**
|
|
35
|
-
* Resets `ctx.componentScope` / `ctx.scopeDeclarations` / `ctx.activeScopes` and declares the
|
|
36
|
-
* top-level `<script>` bindings. Does not walk the component tree; nested scope declarations are
|
|
37
|
-
* built incrementally by {@link enterNestedScopeDeclarationNode} inside the caller's own traversal
|
|
38
|
-
* of `componentRoot` (fused with prop/slot/event extraction there rather than walked separately).
|
|
39
|
-
*/
|
|
40
|
-
export declare function initComponentScope(parser: ComponentParser, ctx: ParserContext): void;
|
|
41
|
-
/** Mutable stack tracking the enclosing `var`-hoisting scope while walking `componentRoot`. */
|
|
42
|
-
export type ScopeWalkState = {
|
|
43
|
-
varScopeStack: LexicalScope[];
|
|
44
|
-
};
|
|
45
|
-
/** Creates the scope-walk state for a fresh traversal of `componentRoot`, seeded with `ctx.componentScope`. */
|
|
46
|
-
export declare function createScopeWalkState(ctx: ParserContext): ScopeWalkState;
|
|
47
|
-
/**
|
|
48
|
-
* Per-node `enter` step of the (formerly standalone) nested-scope-declaration walk. Declares
|
|
49
|
-
* bindings for `node` if it's a scope owner and pushes it as the active `var` scope for its
|
|
50
|
-
* descendants. Must be called during the same top-down traversal of `componentRoot` that
|
|
51
|
-
* {@link leaveNestedScopeDeclarationNode} tears down, and before any logic that reads
|
|
52
|
-
* `ctx.scopeDeclarations` for `node` itself (its own scope is only created here, on entry).
|
|
53
|
-
*/
|
|
54
|
-
export declare function enterNestedScopeDeclarationNode(parser: ComponentParser, ctx: ParserContext, state: ScopeWalkState, node: unknown): void;
|
|
55
|
-
/** Per-node `leave` step counterpart to {@link enterNestedScopeDeclarationNode}. */
|
|
56
|
-
export declare function leaveNestedScopeDeclarationNode(state: ScopeWalkState, node: unknown): void;
|
package/lib/parser/slots.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Expression, ObjectExpression } from "estree";
|
|
2
|
-
import type ComponentParser from "../ComponentParser";
|
|
3
|
-
import type { DeprecatedValue, JsDocPassthroughTag, SlotProps, SlotPropValue, SourceRange } from "../ComponentParser";
|
|
4
|
-
import type { ParserContext } from "./context";
|
|
5
|
-
export declare function inferSlotPropValueFromExpression(ctx: ParserContext, parser: ComponentParser, expression: unknown): SlotPropValue;
|
|
6
|
-
export declare function buildSlotPropsFromObjectExpression(ctx: ParserContext, parser: ComponentParser, expression: ObjectExpression): SlotProps;
|
|
7
|
-
export declare function resolveRenderTagPropReference(ctx: ParserContext, callee: unknown): {
|
|
8
|
-
publicName: string;
|
|
9
|
-
trackingName: string;
|
|
10
|
-
} | null;
|
|
11
|
-
export declare function extractRenderTagInfo(ctx: ParserContext, expression: unknown): {
|
|
12
|
-
publicName: string;
|
|
13
|
-
trackingName: string;
|
|
14
|
-
arguments: Array<Expression | unknown>;
|
|
15
|
-
} | null;
|
|
16
|
-
export declare function addSlot(ctx: ParserContext, { slot_name, slot_props, slot_fallback, slot_description, slot_deprecated, slot_tags, source, }: {
|
|
17
|
-
slot_name?: string;
|
|
18
|
-
slot_props?: string | SlotProps;
|
|
19
|
-
slot_fallback?: string;
|
|
20
|
-
slot_description?: string;
|
|
21
|
-
slot_deprecated?: DeprecatedValue;
|
|
22
|
-
slot_tags?: JsDocPassthroughTag[];
|
|
23
|
-
source?: SourceRange;
|
|
24
|
-
}): void;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { SourcePosition, SourceRange } from "../ComponentParser";
|
|
2
|
-
import type { ParserContext } from "./context";
|
|
3
|
-
/**
|
|
4
|
-
* Returns (and lazily computes/caches on `ctx`) the 0-based source offset for
|
|
5
|
-
* the start of each line in `ctx.source`.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getSourceLineStartOffsets(ctx: ParserContext): number[];
|
|
8
|
-
export declare function sourcePositionFromOffset(ctx: ParserContext, offset: number): SourcePosition | undefined;
|
|
9
|
-
export declare function sourceRangeFromOffsets(ctx: ParserContext, start: number | undefined, end: number | undefined): SourceRange | undefined;
|
|
10
|
-
export declare function sourceRangeFromNode(ctx: ParserContext, node: unknown): SourceRange | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Computes the {@link SourceRange} for a JSDoc tag within a parsed comment
|
|
13
|
-
* block, given the block's own source lines and starting offset.
|
|
14
|
-
*/
|
|
15
|
-
export declare function sourceRangeFromCommentTag(ctx: ParserContext, blockSource: Array<{
|
|
16
|
-
number: number;
|
|
17
|
-
source: string;
|
|
18
|
-
}>, tagSource: Array<{
|
|
19
|
-
number: number;
|
|
20
|
-
source: string;
|
|
21
|
-
tokens: {
|
|
22
|
-
tag?: string;
|
|
23
|
-
};
|
|
24
|
-
}> | undefined, blockStartOffset: number | undefined): SourceRange | undefined;
|
|
25
|
-
export declare function sourceAtPos(ctx: ParserContext, start: number, end: number): string | undefined;
|
|
26
|
-
export declare function sourceForExpression(ctx: ParserContext, node: unknown): string | undefined;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { ModernRunesTypeNode, ParsedComponentTypeScriptMetadata } from "../ComponentParser";
|
|
2
|
-
import type { ParserContext } from "./context";
|
|
3
|
-
export declare function getRunesPropsDeclarationMetadata(ctx: ParserContext, declaratorStart: number | undefined): import("../ComponentParser").RunesPropsDeclarationMetadata | undefined;
|
|
4
|
-
export declare function getRunesPropTypeMetadata(ctx: ParserContext, declaratorStart: number | undefined, propName: string): import("../ComponentParser").RunesPropTypeMetadata | undefined;
|
|
5
|
-
export declare function getTypeReferenceName(typeName: unknown): string | undefined;
|
|
6
|
-
export declare function getTypeDependencyName(typeName: unknown): string | undefined;
|
|
7
|
-
export declare function getTypeAnnotationText(ctx: ParserContext, typeAnnotation: {
|
|
8
|
-
start?: number;
|
|
9
|
-
end?: number;
|
|
10
|
-
} | undefined): string | undefined;
|
|
11
|
-
export declare function getTypeNodeText(ctx: ParserContext, typeNode: {
|
|
12
|
-
start?: number;
|
|
13
|
-
end?: number;
|
|
14
|
-
} | undefined): string | undefined;
|
|
15
|
-
export declare function collectReferencedTypeDependencies(ctx: ParserContext, typeNode: ModernRunesTypeNode | undefined, referencedImportedTypes: Set<string>, referencedLocalTypes: Set<string>, visitedLocalTypes?: Set<string>): void;
|
|
16
|
-
export declare function buildTypeImportStatements(ctx: ParserContext, referencedImportedTypes: Set<string>): string[];
|
|
17
|
-
export declare function buildTypeScriptMetadata(ctx: ParserContext): ParsedComponentTypeScriptMetadata | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function stripTypeCastWrappers(root: unknown): void;
|
package/lib/parser/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function assignValueOrUndefined(value?: "" | string): string | undefined;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type ComponentParser from "../ComponentParser";
|
|
2
|
-
import type { ParserContext } from "./context";
|
|
3
|
-
/**
|
|
4
|
-
* Maps every top-level variable/function name declared in a component's module and instance
|
|
5
|
-
* scripts to the `@type`/description from its attached JSDoc block. Used by
|
|
6
|
-
* {@link ComponentParser.findVariableTypeAndDescription} to resolve plain identifiers (e.g. a
|
|
7
|
-
* value passed to `setContext`) that aren't otherwise typed by a prop or a TS annotation.
|
|
8
|
-
*/
|
|
9
|
-
export declare function buildVariableJsDocTable(ctx: ParserContext, parser: ComponentParser): Map<string, {
|
|
10
|
-
type: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
}>;
|
package/lib/parser-stack.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lazily loads the parser stack (`ComponentParser` and the pruned svelte
|
|
3
|
-
* parser in `./svelte-parse`, which together pull in acorn,
|
|
4
|
-
* `@sveltejs/acorn-typescript`, comment-parser, and estree-walker) behind a
|
|
5
|
-
* dynamic import.
|
|
6
|
-
*
|
|
7
|
-
* A fully cached run never needs to parse a single component, so it never
|
|
8
|
-
* has to pay for evaluating any of that. Callers that are about to parse
|
|
9
|
-
* (`bundle.ts`, `parse-entry-exports.ts`, `watch.ts`) await
|
|
10
|
-
* `loadParserStack()` once up front, then read the resolved stack back
|
|
11
|
-
* synchronously via `getParserStack()` for the rest of the (otherwise
|
|
12
|
-
* synchronous) parse path. The load happens at most once per process.
|
|
13
|
-
*/
|
|
14
|
-
export interface ParserStack {
|
|
15
|
-
ComponentParser: typeof import("./ComponentParser").default;
|
|
16
|
-
parseSvelte: typeof import("./svelte-parse").parse;
|
|
17
|
-
}
|
|
18
|
-
export declare function loadParserStack(): Promise<ParserStack>;
|
|
19
|
-
/** Reads back the stack resolved by a prior, already-awaited `loadParserStack()` call. */
|
|
20
|
-
export declare function getParserStack(): ParserStack;
|
package/lib/path.d.ts
DELETED
package/lib/plugin.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { type GenerateBundleOptions, type GenerateBundleResult } from "./bundle";
|
|
2
|
-
import "./writer/built-in-writers";
|
|
3
|
-
import type { WriteCustomElementsOptions } from "./writer/writer-custom-elements";
|
|
4
|
-
import type { WriteJsonOptions } from "./writer/writer-json";
|
|
5
|
-
import type { WriteMarkdownOptions } from "./writer/writer-markdown";
|
|
6
|
-
import type { WriteTsDefinitionsOptions } from "./writer/writer-ts-definitions";
|
|
7
|
-
export type { CollectedComponents, ComponentDocApi, ComponentDocs, ComponentParseError, GenerateBundleOptions, GenerateBundleResult, ResolveComponentFilePath, } from "./bundle";
|
|
8
|
-
export { collectComponents, collectSvelteFilePaths, generateBundle, processComponent, readFileMap, reportParseErrors, toGenerateBundleOptions, } from "./bundle";
|
|
9
|
-
export interface PluginSveldOptions extends Pick<GenerateBundleOptions, "resolveTypes" | "cache" | "checkExamples"> {
|
|
10
|
-
/**
|
|
11
|
-
* Specify the entry point to uncompiled Svelte source.
|
|
12
|
-
* If not provided, sveld will use the "svelte" field from package.json.
|
|
13
|
-
*/
|
|
14
|
-
entry?: string;
|
|
15
|
-
glob?: boolean;
|
|
16
|
-
/** Record consts, functions, and types from the entry barrel. Off by default. */
|
|
17
|
-
documentExports?: boolean;
|
|
18
|
-
types?: boolean;
|
|
19
|
-
typesOptions?: Partial<Omit<WriteTsDefinitionsOptions, "inputDir">>;
|
|
20
|
-
json?: boolean;
|
|
21
|
-
jsonOptions?: Partial<Omit<WriteJsonOptions, "inputDir">>;
|
|
22
|
-
markdown?: boolean;
|
|
23
|
-
markdownOptions?: Partial<WriteMarkdownOptions>;
|
|
24
|
-
/** Generate a Custom Elements Manifest (`custom-elements.json`, schemaVersion "1.0.0"). */
|
|
25
|
-
customElements?: boolean;
|
|
26
|
-
customElementsOptions?: Partial<Omit<WriteCustomElementsOptions, "inputDir">>;
|
|
27
|
-
/**
|
|
28
|
-
* Run additional, userland-registered writers (via `registerWriter` from
|
|
29
|
-
* "sveld") beyond the built-in `json`/`markdown`/`types` outputs. Keyed by
|
|
30
|
-
* the writer's registered `name`, valued by that writer's options.
|
|
31
|
-
*/
|
|
32
|
-
additionalWriters?: Record<string, unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* Abort the entire run when a single component fails to parse.
|
|
35
|
-
* When `false` (the default), parse failures are collected as diagnostics
|
|
36
|
-
* and the remaining components still emit their output.
|
|
37
|
-
*/
|
|
38
|
-
failFast?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Regenerate output incrementally when `.svelte` source changes during
|
|
41
|
-
* `vite dev` / `vite build --watch`. Only the changed component and the
|
|
42
|
-
* components that depend on it via `@extendProps` / `@extends` are re-parsed.
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
watch?: boolean;
|
|
46
|
-
}
|
|
47
|
-
/** Subset of Vite/Rollup's HMR context that the watch hook relies on. */
|
|
48
|
-
interface HotUpdateContext {
|
|
49
|
-
file: string;
|
|
50
|
-
}
|
|
51
|
-
interface SveldPlugin {
|
|
52
|
-
name: string;
|
|
53
|
-
apply?: "build" | "serve";
|
|
54
|
-
enforce?: "pre" | "post";
|
|
55
|
-
buildStart(): void | Promise<void>;
|
|
56
|
-
generateBundle(): Promise<void>;
|
|
57
|
-
writeBundle(): Promise<void>;
|
|
58
|
-
/** Vite dev-server HMR hook (serve mode). */
|
|
59
|
-
handleHotUpdate?(ctx: HotUpdateContext): void;
|
|
60
|
-
/** Rollup/Vite watch hook (build `--watch`). */
|
|
61
|
-
watchChange?(id: string): void;
|
|
62
|
-
}
|
|
63
|
-
export default function pluginSveld(opts?: PluginSveldOptions): SveldPlugin;
|
|
64
|
-
/**
|
|
65
|
-
* Writes output files based on plugin options.
|
|
66
|
-
*
|
|
67
|
-
* Generates TypeScript definitions, JSON metadata, and/or Markdown documentation
|
|
68
|
-
* based on the options provided. Uses different component sets for different
|
|
69
|
-
* output types to match expected behavior.
|
|
70
|
-
*
|
|
71
|
-
* @param result - Bundle result containing exports and component documentation
|
|
72
|
-
* @param opts - Plugin options determining what outputs to generate
|
|
73
|
-
* @param input - Input file path for determining input directory
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* await writeOutput(result, {
|
|
78
|
-
* types: true,
|
|
79
|
-
* json: true,
|
|
80
|
-
* markdown: true
|
|
81
|
-
* }, "./src/App.svelte");
|
|
82
|
-
* // Generates: types/*.d.ts, COMPONENT_API.json, COMPONENT_INDEX.md
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare function writeOutput(result: GenerateBundleResult, opts: PluginSveldOptions, input: string): Promise<void>;
|
package/lib/resolve-alias.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Clears cached tsconfig/jsconfig reads (tests and hot reload). */
|
|
2
|
-
export declare function clearConfigCache(): void;
|
|
3
|
-
/**
|
|
4
|
-
* Resolve a tsconfig/jsconfig path alias to an absolute filesystem path.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* // With tsconfig.json: { "paths": { "$lib/*": ["./src/lib/*"] } }
|
|
9
|
-
* resolvePathAliasAbsolute("$lib/utils", "./src")
|
|
10
|
-
* // Returns: "/absolute/path/to/src/lib/utils"
|
|
11
|
-
*
|
|
12
|
-
* resolvePathAliasAbsolute("./relative", "./src")
|
|
13
|
-
* // Returns: "./relative" (unchanged, not an alias)
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function resolvePathAliasAbsolute(importPath: string, fromDir: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Resolve a path alias to a path relative to `fromDir` for generated exports.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* // With alias "$lib/utils" -> "./src/lib/utils"
|
|
23
|
-
* resolvePathAlias("$lib/utils", "./src")
|
|
24
|
-
* // Returns: "./lib/utils"
|
|
25
|
-
*
|
|
26
|
-
* resolvePathAlias("./Button.svelte", "./src")
|
|
27
|
-
* // Returns: "./Button.svelte" (unchanged, not an alias)
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare function resolvePathAlias(importPath: string, fromDir: string): string;
|
package/lib/resolve-types.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { ParsedComponentTypeScriptMetadata, ResolvedComponentProp } from "./ComponentParser";
|
|
2
|
-
import type { ExampleCheckSource } from "./example-check";
|
|
3
|
-
export interface ResolveTarget {
|
|
4
|
-
moduleName: string;
|
|
5
|
-
filePath: string;
|
|
6
|
-
metadata: ParsedComponentTypeScriptMetadata;
|
|
7
|
-
}
|
|
8
|
-
export interface ExampleCheckTarget {
|
|
9
|
-
moduleName: string;
|
|
10
|
-
filePath: string;
|
|
11
|
-
sources: ExampleCheckSource[];
|
|
12
|
-
}
|
|
13
|
-
/** One `@example` block that failed to type-check. */
|
|
14
|
-
export interface ExampleCheckDiagnostic {
|
|
15
|
-
id: string;
|
|
16
|
-
name: string;
|
|
17
|
-
message: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Expands opaque imported `$props()` types using the project's TypeScript program.
|
|
21
|
-
* Loaded only when `resolveTypes` is enabled.
|
|
22
|
-
*/
|
|
23
|
-
export declare class TypeResolver {
|
|
24
|
-
private readonly api;
|
|
25
|
-
private readonly symbolFlags;
|
|
26
|
-
private readonly typeFlags;
|
|
27
|
-
private readonly tsconfigPath;
|
|
28
|
-
private readonly overlay;
|
|
29
|
-
private constructor();
|
|
30
|
-
/**
|
|
31
|
-
* Loads `typescript` and the nearest `tsconfig.json`.
|
|
32
|
-
* Returns `null` when either is missing.
|
|
33
|
-
*/
|
|
34
|
-
static create(cwd?: string): Promise<TypeResolver | null>;
|
|
35
|
-
/** Resolves every target in one program snapshot. */
|
|
36
|
-
expandAll(targets: ResolveTarget[]): Promise<Map<string, ResolvedComponentProp[]>>;
|
|
37
|
-
/**
|
|
38
|
-
* Type-checks every `@example` block in one program snapshot.
|
|
39
|
-
*
|
|
40
|
-
* Each example gets its own virtual file: a `declare`-style binding for the
|
|
41
|
-
* documented symbol (typed as `any` end-to-end, so types sveld can't see
|
|
42
|
-
* never cause a false positive), then the example body. Catches renamed
|
|
43
|
-
* or removed symbols and wrong arity. Not full type checking; it does not
|
|
44
|
-
* depend on the rest of the component's types.
|
|
45
|
-
*/
|
|
46
|
-
checkExamples(targets: ExampleCheckTarget[]): Promise<Map<string, ExampleCheckDiagnostic[]>>;
|
|
47
|
-
/** Closes the TypeScript server process. */
|
|
48
|
-
dispose(): Promise<void>;
|
|
49
|
-
private createFileSystem;
|
|
50
|
-
private virtualFileName;
|
|
51
|
-
private exampleFileName;
|
|
52
|
-
}
|
package/lib/sveld.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { type CheckResult } from "./check";
|
|
2
|
-
import { type SveldDiagnostic } from "./diagnostics";
|
|
3
|
-
import { type SveldRuntimeOptions } from "./load-config";
|
|
4
|
-
type SveldOptions = SveldRuntimeOptions;
|
|
5
|
-
/**
|
|
6
|
-
* Result of a programmatic `sveld` run.
|
|
7
|
-
*/
|
|
8
|
-
interface SveldResult {
|
|
9
|
-
/** Diagnostics from this run. */
|
|
10
|
-
diagnostics: SveldDiagnostic[];
|
|
11
|
-
/** Populated when `check` is enabled: the API diff against the committed snapshot. */
|
|
12
|
-
check?: CheckResult;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Programmatic entry point for sveld.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* await sveld({
|
|
20
|
-
* entry: "./src",
|
|
21
|
-
* types: true,
|
|
22
|
-
* json: true,
|
|
23
|
-
* markdown: true,
|
|
24
|
-
* glob: true
|
|
25
|
-
* });
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function sveld(opts?: SveldOptions): Promise<SveldResult>;
|
|
29
|
-
export {};
|
package/lib/svelte-parse.d.ts
DELETED
package/lib/svelte-version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const VERSION: string;
|
package/lib/validate.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
-
export interface ParsedPackageJson {
|
|
3
|
-
svelte?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function parsePackageJson(value: unknown): ParsedPackageJson;
|
|
6
|
-
export interface ParsedTsConfig {
|
|
7
|
-
compilerOptions?: {
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
paths?: Record<string, string[]>;
|
|
10
|
-
};
|
|
11
|
-
extends?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function parseTsConfig(value: unknown): ParsedTsConfig;
|
package/lib/watch.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type GenerateBundleResult } from "./bundle";
|
|
2
|
-
/** Result of an incremental update. */
|
|
3
|
-
export interface SveldBundleUpdate {
|
|
4
|
-
/** The full, updated bundle result (all components, with the affected ones re-parsed). */
|
|
5
|
-
result: GenerateBundleResult;
|
|
6
|
-
/**
|
|
7
|
-
* Absolute paths of the components that were re-parsed: the changed files
|
|
8
|
-
* plus their transitive `@extendProps` / `@extends` dependents. Other
|
|
9
|
-
* components are reused from the previous parse.
|
|
10
|
-
*/
|
|
11
|
-
reparsed: string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A long-lived bundle that supports scoped, incremental re-parsing.
|
|
15
|
-
*
|
|
16
|
-
* `createSveldBundle` performs the initial full parse. `update` then re-parses
|
|
17
|
-
* only the components affected by a set of changed files, leaving every other
|
|
18
|
-
* component's previously-parsed output untouched. This is the core of the
|
|
19
|
-
* plugin's watch mode.
|
|
20
|
-
*/
|
|
21
|
-
export interface SveldBundle {
|
|
22
|
-
readonly result: GenerateBundleResult;
|
|
23
|
-
/** Re-parse the changed files plus their dependents and return the updated bundle. */
|
|
24
|
-
update(changedFilePaths: string[]): Promise<SveldBundleUpdate>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Creates a watch-mode bundle for the given entry point, performing the initial
|
|
28
|
-
* full parse up front.
|
|
29
|
-
*
|
|
30
|
-
* @param input - Entry point file or directory containing Svelte components
|
|
31
|
-
* @param glob - Whether to glob for all `.svelte` files in the directory
|
|
32
|
-
* @param documentExports - Record consts, functions, and types from the entry barrel
|
|
33
|
-
*/
|
|
34
|
-
export declare function createSveldBundle(input: string, glob: boolean, documentExports?: boolean): Promise<SveldBundle>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type AppendType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "quote" | "p" | "divider" | "raw";
|
|
2
|
-
export interface TocLine {
|
|
3
|
-
/** Leading space count; 0 for the top-level (`h2`) entries the TOC currently lists. */
|
|
4
|
-
indent: number;
|
|
5
|
-
raw: string;
|
|
6
|
-
}
|
|
7
|
-
export interface MarkdownWriterBase {
|
|
8
|
-
sourceParts: string[];
|
|
9
|
-
hasToC: boolean;
|
|
10
|
-
toc: TocLine[];
|
|
11
|
-
appendLineBreaks(): this;
|
|
12
|
-
append(type: AppendType, raw?: string): this;
|
|
13
|
-
tableOfContents(): this;
|
|
14
|
-
end(): string;
|
|
15
|
-
get source(): string;
|
|
16
|
-
}
|
|
17
|
-
export declare class MarkdownWriterBaseImpl implements MarkdownWriterBase {
|
|
18
|
-
sourceParts: string[];
|
|
19
|
-
hasToC: boolean;
|
|
20
|
-
toc: TocLine[];
|
|
21
|
-
get source(): string;
|
|
22
|
-
appendLineBreaks(): this;
|
|
23
|
-
append(type: AppendType, raw?: string): this;
|
|
24
|
-
tableOfContents(): this;
|
|
25
|
-
end(): string;
|
|
26
|
-
}
|
package/lib/writer/Writer.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export default class Writer {
|
|
2
|
-
/**
|
|
3
|
-
* Skips the write when `filePath` already contains `raw`, so repeated runs
|
|
4
|
-
* over unchanged sources don't touch the file (or its mtime).
|
|
5
|
-
*
|
|
6
|
-
* @returns `true` if the file was written, `false` if it was already up to date.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const writer = new Writer();
|
|
11
|
-
* await writer.write("./dist/index.d.ts", "export type Props = {};");
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
write(filePath: string, raw: string): Promise<boolean>;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @example
|
|
18
|
-
* ```ts
|
|
19
|
-
* const writer = createJsonWriter();
|
|
20
|
-
* await writer.write("data.json", JSON.stringify({ key: "value" }));
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function createJsonWriter(): Writer;
|
|
24
|
-
/**
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* const writer = createTypeScriptWriter();
|
|
28
|
-
* await writer.write("index.d.ts", "export type Props = {};");
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare function createTypeScriptWriter(): Writer;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type AppendType } from "./MarkdownWriterBase";
|
|
2
|
-
import Writer from "./Writer";
|
|
3
|
-
type OnAppend = (type: AppendType, document: WriterMarkdown) => void;
|
|
4
|
-
interface MarkdownOptions {
|
|
5
|
-
onAppend?: OnAppend;
|
|
6
|
-
}
|
|
7
|
-
export type { AppendType };
|
|
8
|
-
/**
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* const writer = new WriterMarkdown({
|
|
12
|
-
* onAppend: (type, doc) => {
|
|
13
|
-
* console.log(`Appended ${type} to markdown`);
|
|
14
|
-
* }
|
|
15
|
-
* });
|
|
16
|
-
* writer.append("h1", "Title");
|
|
17
|
-
* await writer.write("./docs.md", writer.end());
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export default class WriterMarkdown extends Writer {
|
|
21
|
-
onAppend?: OnAppend;
|
|
22
|
-
private markdownBase;
|
|
23
|
-
constructor(options: MarkdownOptions);
|
|
24
|
-
get source(): string;
|
|
25
|
-
get hasToC(): boolean;
|
|
26
|
-
get toc(): import("./MarkdownWriterBase").TocLine[];
|
|
27
|
-
appendLineBreaks(): this;
|
|
28
|
-
append(type: AppendType, raw?: string): this;
|
|
29
|
-
tableOfContents(): this;
|
|
30
|
-
end(): string;
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|