declare const brand: unique symbol; type Brand = TBase & { readonly [brand]: TBrand; }; export type NormalizedPath = Brand; export declare function asNormalizedPath(path: string): NormalizedPath; interface ComponentParserDiagnostics { moduleName: string; filePath: string; } export class ComponentParser { private ctx; /** * Resets parser state for reuse between parses. * * @example * ```ts * parser.parseSvelteComponent(source1, diagnostics1); * parser.cleanup(); * parser.parseSvelteComponent(source2, diagnostics2); * ``` */ cleanup(): void; /** * @example * ```ts * const parser = new ComponentParser(); * const result = parser.parseSvelteComponent(source, { * moduleName: "Button", * filePath: "./Button.svelte" * }); * // { props, slots, events, typedefs, ... } * ``` */ parseSvelteComponent(source: string, diagnostics: ComponentParserDiagnostics): ParsedComponent; /** * Like {@link parseSvelteComponent}, but returns the candidates only a * pass with file access can resolve beside the component rather than * inside its metadata. */ parse(source: string, diagnostics: ComponentParserDiagnostics): ComponentParseResult; } interface JsDocPassthroughTag { name: string; body: string; } type DeprecatedValue = string | true; interface SourcePosition { /** 1-based. */ line: number; /** 0-based. */ column: number; } interface SourceRange { start: SourcePosition; end: SourcePosition; } interface PendingCallDefaultCandidate { propName: string; location: "props" | "moduleExports"; calleeName: string; importSource?: string; importedName?: string; } interface PendingConstDefaultCandidate { propName: string; location: "props" | "moduleExports"; importSource: string; importedName: string; /** Members read off the import, through namespace exports: `["DELAY"]` for `C.timing.DELAY`. */ members?: string[]; } interface PendingContextKeyCandidate { importSource: string; importedName: string; /** Members read off the import, through namespace exports: `["THEME"]` for `ns.keys.THEME`. */ members?: string[]; /** See {@link ComponentContext.type}. */ type?: string; properties: ComponentContextProp[]; description?: string; /** See {@link ComponentContext.hasUnresolvedSpread}. */ hasUnresolvedSpread?: boolean; /** See {@link ComponentContext.internal}. */ internal?: boolean; /** Source range of the `setContext(...)` call, when available. */ source?: SourceRange; } interface PendingDispatchEscapeCandidate { importSource: string; importedName: string; /** Members read off the import, through namespace exports: `["helper"]` for `ns.helper`. */ members?: string[]; /** Callee as written, for messages. */ calleeText: string; /** Local name of the `createEventDispatcher()` result. */ dispatcherName: string; /** Argument position the dispatcher is passed at. */ argumentIndex: number; /** Set when passed as an object literal property (`{ dispatch }`): that property's key. */ property?: string; /** Source range of the call, when available. */ source?: SourceRange; /** `@sveld-ignore sveld/dispatch-escapes` on the dispatcher's declaration. */ ignored?: boolean; } interface PendingCrossFileCandidates { pendingCallDefaultCandidates?: PendingCallDefaultCandidate[]; pendingConstDefaultCandidates?: PendingConstDefaultCandidate[]; pendingContextKeyCandidates?: PendingContextKeyCandidate[]; pendingDispatchEscapeCandidates?: PendingDispatchEscapeCandidate[]; /** * `event-no-source` diagnostics held back while the dispatcher escapes to * imported functions: the cross-file pass keeps those the functions don't dispatch. */ deferredEventNoSourceDiagnostics?: SveldDiagnostic[]; /** * `@event` tags with no `{type}` or `@property`, whose `null` detail no * same-file dispatch replaced; an escaped dispatcher's helper may still. */ untypedJsDocEventNames?: string[]; } interface ParsedComponentTypeScriptMetadata extends PendingCrossFileCandidates { canonicalPropsType?: string; canonicalPropNames: string[]; localTypeDeclarations: string[]; /** Types the module script exports (`export interface Item`), emitted with `export`. */ moduleTypeDeclarations?: string[]; typeImportStatements: string[]; } interface ComponentParseResult { component: ParsedComponent; /** Undefined when the component depends on no other file's contents. */ pending?: PendingCrossFileCandidates; } type SyntaxMode = "legacy" | "runes"; type ScriptLanguage = "js" | "ts"; type ComponentPropTypeSource = "typescript" | "jsdoc" | "default" | "inferred" | "unknown"; type ComponentPropDefaultValueKind = "literal" | "array" | "object" | "expression" | "function" | "unknown"; interface ComponentPropDefaultValue { raw: string; kind: ComponentPropDefaultValueKind; value?: unknown; } type ComponentPropBinding = "readonly" | "writable"; interface ComponentPropParam { name: string; type: string; description?: string; optional?: boolean; } interface ComponentPropReExport { /** Module specifier as written in the source (e.g. `"./utils.js"`). */ from: string; /** Name `from` exports: `"default"` for a default import, `"*"` for `export *` or a namespace import. */ imported: string; } interface ComponentClassMember { /** * `"property"` covers fields, constructor parameter properties, and getter/setter pairs; * `"index"` is an index signature (`[key: string]: unknown`). */ kind: "constructor" | "method" | "property" | "index"; /** Member name; `"constructor"` for the constructor, the bracketed key (`[key: string]`) for an index signature. */ name: string; /** Property type text; `"any"` when neither TypeScript nor JSDoc types it. */ type?: string; /** Method or constructor parameters, typed from TypeScript or JSDoc `@param`, else `"any"`. A rest parameter's name starts with `...`. */ params?: ComponentPropParam[]; /** Method return type from TypeScript or JSDoc `@returns`; unset when neither gives one. */ returnType?: string; /** A method's own type parameter list (`U extends object`), without the angle brackets. */ typeParameters?: string; static?: true; /** A `readonly` field, or a getter with no setter. */ readonly?: true; optional?: true; abstract?: true; description?: string; deprecated?: DeprecatedValue; tags?: JsDocPassthroughTag[]; } interface ComponentProp { /** Public prop name; `"*"` for a bare `export * from "..."`. */ name: string; /** * `"let"` (required), `"const"` (default), or `"function"`. `"re-export"` * is module-export only: `export { x } from "..."`, `export * from "..."`, * or `export { x }` of an imported binding, written to the `.d.ts` as-is. * `"class"` is module-export only too: a class the module script declares, * with its public surface in {@link ComponentProp.members}. */ kind: "let" | "const" | "function" | "re-export" | "class"; /** True when declared with `const`. */ constant: boolean; type?: string; /** Conservative provenance for the prop type. See the precedence rule on {@link ComponentProp}. */ typeSource?: ComponentPropTypeSource; /** Local binding when it differs from the public name. */ localName?: string; /** Default value as source text; unset when the prop has no initializer/default. */ value?: string; /** Structured default value metadata for docs UIs; set alongside `value` from the same initializer. */ defaultValue?: ComponentPropDefaultValue; /** From JSDoc, or a matching `@typedef`'s own description (legacy only; see {@link ComponentProp}). */ description?: string; /** From JSDoc `@param` on function props. */ params?: ComponentPropParam[]; /** From JSDoc `@returns` on function props. */ returnType?: string; /** * A function's own type parameter list from its `@template` tags (e.g. * `T extends { id: string }`), without the angle brackets. Also prefixed * onto `type` when that signature is built from `@param`/`@returns`. * For a `"class"`, the class's type parameters, from TypeScript or `@template`. */ typeParameters?: string; /** Set when `kind` is `"class"`: its public constructor, methods, and properties, in source order. */ members?: ComponentClassMember[]; /** Set when `kind` is `"class"` and the class is `abstract`. */ abstract?: true; /** Set when `kind` is `"class"` and it extends a base class: `Base`. */ extends?: string; /** Set when `kind` is `"class"` and it implements interfaces: `["Disposable"]`. */ implements?: string[]; /** * True for arrow/function-expression initializers and bare `function` * declarations in every mode; additionally true for a function-shaped * type/JSDoc signature in runes only (see {@link ComponentProp}). */ isFunction: boolean; isFunctionDeclaration: boolean; /** True when declared with `let` and no default. */ isRequired: boolean; /** * True when the prop is mutated locally (legacy, inferred from assignment/ * binding targets) or declared with `$bindable()` (runes). */ reactive: boolean; /** Binding direction from `@bindable` JSDoc. */ binding?: ComponentPropBinding; /** True when declared with Svelte 5 `$bindable()` (runes only). */ bindable?: true; /** From `@deprecated` JSDoc. */ deprecated?: DeprecatedValue; /** `@since` / `@example` tags in source order. */ tags?: JsDocPassthroughTag[]; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; /** Set when `kind` is `"re-export"`. */ reExport?: ComponentPropReExport; source?: SourceRange; } interface ComponentSlot { /** `null` for the default slot. */ name?: string | null; default: boolean; /** Fallback content when the slot is empty. */ fallback?: string; /** Slot props as TypeScript type text. */ slot_props?: string; /** From JSDoc `@slot` or `@snippet`. */ description?: string; /** From `@deprecated` JSDoc. */ deprecated?: DeprecatedValue; /** Tags between the description and `@slot`/`@snippet` (e.g. `@example`), in source order. */ tags?: JsDocPassthroughTag[]; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; source?: SourceRange; } interface DispatchedEvent { type: "dispatched"; name: string; detail?: string; /** From JSDoc `@event`. */ description?: string; /** From `@deprecated` JSDoc. */ deprecated?: DeprecatedValue; /** `@since` / `@example` tags in source order. */ tags?: JsDocPassthroughTag[]; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; source?: SourceRange; } interface SerializedForwardedEvent { type: "forwarded"; name: string; /** Element name as a string for JSON output. */ element: string; /** From JSDoc `@event`. */ description?: string; /** From `@deprecated` JSDoc. */ deprecated?: DeprecatedValue; /** Detail type from `@event`. */ detail?: string; /** `@since` / `@example` tags in source order. */ tags?: JsDocPassthroughTag[]; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; source?: SourceRange; } export type SerializedComponentEvent = SerializedForwardedEvent | DispatchedEvent; interface TypeDef { /** Type text (e.g. `"{ x: number; y: number }"`). */ type: string; name: string; description?: string; /** Full `type` alias declaration text. */ ts: string; /** Tags in the same block (e.g. `@since`, `@example`, `@see`), in source order. */ tags?: JsDocPassthroughTag[]; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; /** Source range of the `@typedef`/`@callback` tag, when available. */ source?: SourceRange; } type ComponentGenerics = [name: string, type: string] | null; interface ComponentInlineElement { type: "InlineComponent"; name: string; } interface ComponentElement { type: "Element"; name: string; /** * Static tag for `svelte:element this="div"`. Undefined when `this` is dynamic. * * @example * ```svelte * * * // thisValue: "div" * * * * // thisValue: undefined * ``` */ thisValue?: string; /** * The type parameter a dynamic tag is typed with, so rest props follow it: * `Tag` for `` with `tag` typed `Tag`. */ thisType?: string; /** From `@restProps` JSDoc. */ description?: string; } type RestProps = undefined | ComponentInlineElement | ComponentElement; interface Extends { /** Interface name (e.g. `"ButtonProps"`). */ interface: string; /** Import path (e.g. `"./types"`). */ import: string; } type CustomElementPropType = "String" | "Boolean" | "Number" | "Array" | "Object"; interface CustomElementPropConfig { /** Explicit attribute name. Svelte itself always observes every prop as an attribute; sveld's own output omits the attribute entirely when this is `false`. */ attribute?: string | false; reflect?: boolean; type?: CustomElementPropType; } interface CustomElementOptions { tag?: string; shadow?: "open" | "none"; props?: Record; extend?: true; } interface ComponentCssPart { name: string; description?: string; } interface ComponentCssProperty { /** Includes the leading `--`. */ name: string; type?: string; default?: string; description?: string; } interface ComponentContextProp { name: string; type: string; description?: string; optional: boolean; /** True from `@ignore`/`@internal` JSDoc; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; } interface ComponentContext { key: string; /** Generated type name (e.g. `"ModalContext"`). */ typeName: string; /** * The context's whole type, when the `setContext` value is a variable whose * type isn't an object type literal (`ModalAPI`, `Writable`, or `any` * when untyped). `properties` is empty then. */ type?: string; description?: string; /** Empty when {@link ComponentContext.type} is set. */ properties: ComponentContextProp[]; /** True when a `{...spread}` in the context's object literal couldn't be resolved; the generated type intersects with `Record`. */ hasUnresolvedSpread?: boolean; /** True from `@ignore`/`@internal` JSDoc on the `setContext` call; excluded from every output by `buildComponentApiDocument`. */ internal?: boolean; /** Source range of the `setContext(...)` call, when available. */ source?: SourceRange; } interface ParsedComponent { source?: SourceRange; syntaxMode: SyntaxMode; scriptLanguage?: ScriptLanguage; /** Instance-level props (`export let`/`export function`, or runes `$props()`). See {@link ComponentProp} for the shared IR these are built from. */ props: ComponentProp[]; /** Exports from `