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.
Files changed (88) hide show
  1. package/README.md +33 -6
  2. package/lib/browser.d.ts +660 -39
  3. package/lib/browser.js +172 -172
  4. package/lib/chunk-0fqdg2xa.js +20 -0
  5. package/lib/chunk-2vwf7nck.js +1 -0
  6. package/lib/chunk-8myyzjb1.js +4 -0
  7. package/lib/{chunk-v4q9vw0y.js → chunk-as5hgj7e.js} +57 -57
  8. package/lib/{chunk-zva3xjwa.js → chunk-denfbw92.js} +1 -1
  9. package/lib/chunk-h1r040pg.js +6 -0
  10. package/lib/chunk-m538qnhp.js +230 -0
  11. package/lib/chunk-r4rrncmd.js +1 -0
  12. package/lib/{chunk-1p4ka68s.js → chunk-t9d5k3p7.js} +1 -1
  13. package/lib/{chunk-8xw75w8t.js → chunk-tmj7vnjr.js} +2 -2
  14. package/lib/chunk-xryt7ad2.js +3 -0
  15. package/lib/cli-entry.js +1 -1
  16. package/lib/index.d.ts +767 -10
  17. package/lib/index.js +1 -1
  18. package/package.json +1 -1
  19. package/lib/ComponentParser.d.ts +0 -560
  20. package/lib/ast-guards.d.ts +0 -16
  21. package/lib/brands.d.ts +0 -11
  22. package/lib/bundle.d.ts +0 -174
  23. package/lib/check.d.ts +0 -43
  24. package/lib/chunk-72hx9e9w.js +0 -20
  25. package/lib/chunk-7qz0hzgw.js +0 -217
  26. package/lib/chunk-cxrw7gzr.js +0 -2
  27. package/lib/chunk-jdnsv86e.js +0 -1
  28. package/lib/chunk-pmj8c3yv.js +0 -6
  29. package/lib/chunk-s9mzxa4y.js +0 -1
  30. package/lib/chunk-xkrgedm4.js +0 -4
  31. package/lib/cli-entry.d.ts +0 -12
  32. package/lib/cli.d.ts +0 -28
  33. package/lib/create-exports.d.ts +0 -32
  34. package/lib/dependency-graph.d.ts +0 -20
  35. package/lib/diagnostics.d.ts +0 -34
  36. package/lib/element-tag-map.d.ts +0 -146
  37. package/lib/example-check.d.ts +0 -24
  38. package/lib/get-svelte-entry.d.ts +0 -3
  39. package/lib/load-config.d.ts +0 -62
  40. package/lib/parse-cache.d.ts +0 -28
  41. package/lib/parse-entry-exports.d.ts +0 -30
  42. package/lib/parse-exports.d.ts +0 -25
  43. package/lib/parsed-component-metadata.d.ts +0 -13
  44. package/lib/parser/bindings.d.ts +0 -4
  45. package/lib/parser/context.d.ts +0 -72
  46. package/lib/parser/contexts.d.ts +0 -19
  47. package/lib/parser/diagnostics.d.ts +0 -8
  48. package/lib/parser/events.d.ts +0 -21
  49. package/lib/parser/generics.d.ts +0 -24
  50. package/lib/parser/jsdoc.d.ts +0 -55
  51. package/lib/parser/prop-shared.d.ts +0 -84
  52. package/lib/parser/props.d.ts +0 -71
  53. package/lib/parser/rest-props.d.ts +0 -4
  54. package/lib/parser/runes-detection.d.ts +0 -13
  55. package/lib/parser/runes-props.d.ts +0 -18
  56. package/lib/parser/scopes.d.ts +0 -56
  57. package/lib/parser/slots.d.ts +0 -24
  58. package/lib/parser/source-position.d.ts +0 -26
  59. package/lib/parser/type-resolution.d.ts +0 -17
  60. package/lib/parser/typescript-casts.d.ts +0 -1
  61. package/lib/parser/utils.d.ts +0 -1
  62. package/lib/parser/variable-jsdoc.d.ts +0 -12
  63. package/lib/parser-stack.d.ts +0 -20
  64. package/lib/path.d.ts +0 -2
  65. package/lib/plugin.d.ts +0 -85
  66. package/lib/resolve-alias.d.ts +0 -30
  67. package/lib/resolve-types.d.ts +0 -52
  68. package/lib/sveld.d.ts +0 -29
  69. package/lib/svelte-parse.d.ts +0 -4
  70. package/lib/svelte-version.d.ts +0 -1
  71. package/lib/validate.d.ts +0 -13
  72. package/lib/watch.d.ts +0 -34
  73. package/lib/writer/MarkdownWriterBase.d.ts +0 -26
  74. package/lib/writer/Writer.d.ts +0 -31
  75. package/lib/writer/WriterMarkdown.d.ts +0 -31
  76. package/lib/writer/built-in-writers.d.ts +0 -1
  77. package/lib/writer/document-model.d.ts +0 -34
  78. package/lib/writer/format-generated-ts.d.ts +0 -8
  79. package/lib/writer/markdown-format-utils.d.ts +0 -20
  80. package/lib/writer/markdown-render-utils.d.ts +0 -10
  81. package/lib/writer/registry.d.ts +0 -17
  82. package/lib/writer/writer-custom-elements-core.d.ts +0 -86
  83. package/lib/writer/writer-custom-elements.d.ts +0 -15
  84. package/lib/writer/writer-json.d.ts +0 -27
  85. package/lib/writer/writer-markdown-core.d.ts +0 -32
  86. package/lib/writer/writer-markdown.d.ts +0 -23
  87. package/lib/writer/writer-ts-definitions-core.d.ts +0 -30
  88. package/lib/writer/writer-ts-definitions.d.ts +0 -43
@@ -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 {};
@@ -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[];
@@ -1,3 +0,0 @@
1
- import { type SvelteEntryPoint } from "./brands";
2
- export type { SvelteEntryPoint };
3
- export declare function getSvelteEntry(entryPoint?: string): SvelteEntryPoint | null;
@@ -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>;
@@ -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
- * await 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): Promise<EntryExports>;
@@ -1,25 +0,0 @@
1
- import { type RelativeSourcePath } from "./brands";
2
- export type ParsedExports = Record<string, {
3
- source: RelativeSourcePath;
4
- default: boolean;
5
- mixed?: boolean;
6
- }>;
7
- /**
8
- * Parses exports from an entry file and resolves aliases against `dir`.
9
- *
10
- * @example
11
- * ```ts
12
- * // Source: export { Button } from "./Button.svelte";
13
- * // export default App from "./App.svelte";
14
- * parseExports(source, "./src")
15
- * // Returns: {
16
- * // Button: { source: "./Button.svelte", default: false },
17
- * // App: { source: "./App.svelte", default: true }
18
- * // }
19
- * ```
20
- *
21
- * @param resolving - Absolute paths currently being resolved on this call
22
- * stack, used to break `export *` cycles between files that re-export
23
- * each other. Callers should not pass this; it is threaded internally.
24
- */
25
- export declare function parseExports(source: string, dir: string, resolving?: Set<string>): ParsedExports;
@@ -1,13 +0,0 @@
1
- /**
2
- * Runtime helpers for `ParsedComponent`'s symbol-keyed TypeScript metadata,
3
- * split out of `./ComponentParser` so callers that only need to read or
4
- * write this field (`parse-cache.ts`, `writer/writer-ts-definitions-core.ts`,
5
- * `bundle.ts`) don't have to import the parser stack to get it.
6
- */
7
- import type { ParsedComponent, ParsedComponentTypeScriptMetadata, ResolvedComponentProp } from "./ComponentParser";
8
- export declare const PARSED_COMPONENT_TYPE_SCRIPT_METADATA: unique symbol;
9
- export declare function getParsedComponentTypeScriptMetadata(component: {
10
- [PARSED_COMPONENT_TYPE_SCRIPT_METADATA]?: ParsedComponentTypeScriptMetadata;
11
- }): ParsedComponentTypeScriptMetadata | undefined;
12
- /** Append checker-resolved props. Names the AST walker already found are left alone. */
13
- export declare function applyResolvedProps(component: ParsedComponent, resolved: ResolvedComponentProp[]): void;
@@ -1,4 +0,0 @@
1
- import type ComponentParser from "../ComponentParser";
2
- import type { ParserContext } from "./context";
3
- export declare function extractPropertyType(typeStr: string, propName: string): string | undefined;
4
- export declare function resolveMemberExpressionType(ctx: ParserContext, parser: ComponentParser, expr: unknown): string | undefined;
@@ -1,72 +0,0 @@
1
- import type { FunctionDeclaration, VariableDeclaration } from "estree";
2
- import type { ComponentContext, ComponentElement, ComponentEvent, ComponentGenerics, ComponentInlineElement, ComponentProp, ComponentPropBindings, Extends, InternalComponentSlot, LegacyAstRoot, LexicalScope, LocalTypeDeclaration, RestProps, RunesPropsDeclarationMetadata, ScriptLanguage, SourceRange, SyntaxMode, TypeDef, TypeImportBinding } from "../ComponentParser";
3
- import type { SveldDiagnostic } from "../diagnostics";
4
- /** Per-parse mutable state for {@link ComponentParser}. Reset via {@link createParserContext} on each parse. */
5
- export interface ParserContext {
6
- syntaxMode: SyntaxMode;
7
- scriptLanguage?: ScriptLanguage;
8
- source?: string;
9
- parsed?: LegacyAstRoot;
10
- /**
11
- * Explicit `<svelte:options runes={...} />` value. When set, overrides rune-reference detection.
12
- */
13
- runesOptionOverride?: boolean;
14
- sourceLineStartOffsetsCache?: number[];
15
- rest_props?: RestProps;
16
- extends?: Extends;
17
- customElementTag?: string;
18
- componentComment?: string;
19
- componentCommentSource?: SourceRange;
20
- generics: ComponentGenerics;
21
- /**
22
- * Raw `generics` script attribute (with `lang="ts"` validated). Held until parse end so it can
23
- * override JSDoc-derived {@link ParserContext.generics}.
24
- */
25
- scriptGenericsAttribute?: {
26
- value: string;
27
- source?: SourceRange;
28
- };
29
- readonly diagnosticRecords: SveldDiagnostic[];
30
- componentFilePath: string;
31
- readonly props: Map<string, ComponentProp>;
32
- readonly moduleExports: Map<string, ComponentProp>;
33
- readonly propLocalToPublicName: Map<string, string>;
34
- readonly reactive_vars: Set<string>;
35
- readonly funcDecls: Map<string, FunctionDeclaration>;
36
- readonly vars: Set<VariableDeclaration>;
37
- readonly runesPropsDeclarationMetadataByDeclaratorStart: Map<number, RunesPropsDeclarationMetadata>;
38
- readonly typedRunesPropsDeclarations: RunesPropsDeclarationMetadata[];
39
- readonly explicitPropTypesByName: Map<string, string>;
40
- readonly explicitVariableTypesByName: Map<string, string>;
41
- readonly typeImportBindingsByLocalName: Map<string, TypeImportBinding>;
42
- readonly localTypeDeclarationsByName: Map<string, LocalTypeDeclaration>;
43
- readonly wholePropsLocals: Set<string>;
44
- readonly restPropLocals: Set<string>;
45
- readonly componentScope: LexicalScope;
46
- scopeDeclarations: WeakMap<object, LexicalScope>;
47
- readonly activeScopes: LexicalScope[];
48
- readonly slots: Map<string | null, InternalComponentSlot>;
49
- readonly snippetPropLocals: Set<string>;
50
- /** `@template` tags from a `@slot`/`@snippet` block (no `@extends`), held until finalization. */
51
- deferredSlotBlockGenerics: Array<{
52
- name: string;
53
- constraint: string;
54
- }>;
55
- readonly events: Map<string, ComponentEvent>;
56
- readonly eventDescriptions: Map<string, string | undefined>;
57
- readonly forwardedEvents: Map<string, ComponentInlineElement | ComponentElement>;
58
- readonly jsDocEventNames: Set<string>;
59
- /** Source range per `@event` JSDoc tag, for `event-no-source` diagnostics. */
60
- readonly jsDocEventSources: Map<string, SourceRange | undefined>;
61
- readonly bindings: Map<string, ComponentPropBindings>;
62
- readonly contexts: Map<string, ComponentContext>;
63
- readonly typedefs: Map<string, TypeDef>;
64
- variableInfoCache: Map<string, {
65
- type: string;
66
- description?: string;
67
- }>;
68
- /** True after the per-component variable/JSDoc symbol table has populated {@link variableInfoCache}. */
69
- variableInfoCacheBuilt: boolean;
70
- }
71
- /** Fresh {@link ParserContext}. Keep in sync with new fields on {@link ParserContext}. */
72
- export declare function createParserContext(): ParserContext;
@@ -1,19 +0,0 @@
1
- import type { CallExpression, NewExpression } from "estree";
2
- import type { Node } from "estree-walker";
3
- import type ComponentParser from "../ComponentParser";
4
- import type { ComponentContext } from "../ComponentParser";
5
- import type { ParserContext } from "./context";
6
- /** Turn `simple-modal` into `SimpleModalContext`. */
7
- export declare function generateContextTypeName(key: string): string;
8
- /** Build a {@link ComponentContext} from an object literal or variable reference. */
9
- export declare function parseContextValue(ctx: ParserContext, parser: ComponentParser, node: Node, key: string): ComponentContext | null;
10
- /** Static description from `Symbol()` / `Symbol.for()`, or `""` when unknown. Returns `null` for other calls. */
11
- export declare function resolveSymbolKeyDescription(node: CallExpression | NewExpression): string | null;
12
- /**
13
- * Resolve a `setContext` key to the string used in `{PascalCase}Context`.
14
- * Accepts literals, static templates, `const` chains (depth 5), and `Symbol()`.
15
- * Description-less symbols fall back to the binding name.
16
- */
17
- export declare function resolveContextKey(ctx: ParserContext, keyArg: unknown, depth?: number): string | null;
18
- /** Parse `setContext(key, value)` when the key resolves statically. */
19
- export declare function parseSetContextCall(ctx: ParserContext, parser: ComponentParser, node: Node, _parent?: Node): void;
@@ -1,8 +0,0 @@
1
- import type { SourceRange } from "../ComponentParser";
2
- import type { SveldDiagnosticKind } from "../diagnostics";
3
- import type { ParserContext } from "./context";
4
- /**
5
- * Appends a diagnostic (a place sveld had to guess a type) to `ctx.diagnosticRecords`,
6
- * tagged with the file path of the component currently being parsed.
7
- */
8
- export declare function recordDiagnostic(ctx: ParserContext, kind: SveldDiagnosticKind, name: string, message: string, source?: SourceRange): void;
@@ -1,21 +0,0 @@
1
- import type { CallExpression } from "estree";
2
- import type { DispatchedEvent } from "../ComponentParser";
3
- import type { ParserContext } from "./context";
4
- export declare function literalDetailToTypeText(value: unknown): string;
5
- /** Merge or add a dispatched event. Detail defaults to `null` when the dispatch has no argument and no `@event` detail. */
6
- export declare function addDispatchedEvent(ctx: ParserContext, { name, detail, has_argument, description, deprecated, tags, source, }: Pick<DispatchedEvent, "name" | "description" | "deprecated" | "tags" | "source"> & {
7
- detail: string;
8
- has_argument: boolean;
9
- }): void;
10
- /**
11
- * Detect `$host().dispatchEvent(new CustomEvent("name", { detail }))` (or `new Event(...)`) and
12
- * record it as a dispatched event, mirroring `createEventDispatcher()` detection.
13
- */
14
- export declare function parseHostDispatchEventCall(ctx: ParserContext, dispatchEventCall: CallExpression): string | undefined;
15
- export declare function buildEventDetailFromProperties(properties: Array<{
16
- name: string;
17
- type: string;
18
- description?: string;
19
- optional?: boolean;
20
- default?: string;
21
- }>, _eventName?: string, multiline?: boolean): string;
@@ -1,24 +0,0 @@
1
- import type { ComponentGenerics } from "../ComponentParser";
2
- import type { ParserContext } from "./context";
3
- /**
4
- * Splits a string on top-level commas, ignoring commas nested inside
5
- * `<>`, `()`, `[]`, or `{}`. Shared by the `generics` script attribute parser
6
- * and the TypeScript definition writer, both of which must separate generic
7
- * constraint declarations that may themselves contain commas (e.g. `Value extends Record<string, any>`).
8
- */
9
- export declare function splitTopLevelCommas(value: string): string[];
10
- /**
11
- * Parses the `generics` script attribute value (a TypeScript type-parameter
12
- * list, e.g. `"Row extends DataTableRow = DataTableRow, Header"`) into the
13
- * same `[names, constraints]` tuple the `@generics`/`@template` JSDoc tags produce.
14
- */
15
- export declare function parseGenericsAttribute(value: string): ComponentGenerics;
16
- /**
17
- * Extends `referencedImportedTypes`/`referencedLocalTypes` with any type names
18
- * mentioned in the `generics` script attribute (e.g. the `DataTableRow` in
19
- * `Row extends DataTableRow = DataTableRow`). These names only appear in the
20
- * raw attribute string, not in the `$props()` type annotation AST that
21
- * {@link collectReferencedTypeDependencies} normally walks, so without this
22
- * they would never get hoisted into the emitted `.d.ts`.
23
- */
24
- export declare function collectGenericsAttributeTypeDependencies(ctx: ParserContext, referencedImportedTypes: Set<string>, referencedLocalTypes: Set<string>): void;
@@ -1,55 +0,0 @@
1
- import { parse as parseComment } from "comment-parser";
2
- import type ComponentParser from "../ComponentParser";
3
- import type { ComponentPropBinding, ComponentPropParam, DeprecatedValue, JsDocPassthroughTag } from "../ComponentParser";
4
- import type { ParserContext } from "./context";
5
- export declare function formatComment(comment: string): string;
6
- export declare function getCommentTags(parsed: ReturnType<typeof parseComment>): {
7
- type: import("comment-parser").Spec | undefined;
8
- param: import("comment-parser").Spec[];
9
- returns: import("comment-parser").Spec | undefined;
10
- binding: ComponentPropBinding | undefined;
11
- deprecated: DeprecatedValue | undefined;
12
- additional: import("comment-parser").Spec[];
13
- passthrough: import("comment-parser").Spec[];
14
- description: string;
15
- };
16
- export declare function findJSDocComment(leadingComments: unknown[]): {
17
- value: string;
18
- } | undefined;
19
- export declare function findAdjacentJSDocComment(ctx: ParserContext, leadingComments: unknown[] | undefined, nodeStart: number | undefined): {
20
- value: string;
21
- } | undefined;
22
- export declare function processNodeJSDoc(ctx: ParserContext, parser: ComponentParser, node: {
23
- leadingComments?: unknown[];
24
- start?: number;
25
- } | null | undefined): {
26
- type?: string;
27
- params?: ComponentPropParam[];
28
- returnType?: string;
29
- description?: string;
30
- binding?: ComponentPropBinding;
31
- deprecated?: DeprecatedValue;
32
- tags?: JsDocPassthroughTag[];
33
- } | undefined;
34
- export declare function processLeadingCommentsJSDoc(ctx: ParserContext, parser: ComponentParser, node: {
35
- leadingComments?: unknown[];
36
- start?: number;
37
- } | null | undefined): {
38
- type?: string;
39
- params?: ComponentPropParam[];
40
- returnType?: string;
41
- description?: string;
42
- binding?: ComponentPropBinding;
43
- deprecated?: DeprecatedValue;
44
- tags?: JsDocPassthroughTag[];
45
- } | undefined;
46
- export declare function processJSDocComment(parser: ComponentParser, leadingComments: unknown[]): {
47
- type?: string;
48
- params?: ComponentPropParam[];
49
- returnType?: string;
50
- description?: string;
51
- binding?: ComponentPropBinding;
52
- deprecated?: DeprecatedValue;
53
- tags?: JsDocPassthroughTag[];
54
- } | undefined;
55
- export declare function parseCustomTypes(ctx: ParserContext, parser: ComponentParser): void;
@@ -1,84 +0,0 @@
1
- import type { ComponentPropParam, ComponentPropTypeSource } from "../ComponentParser";
2
- /**
3
- * Decides a prop's provenance for docs UIs. Order is fixed and mirrors the
4
- * precedence used to pick the prop's final `type` text in
5
- * {@link resolvePropTypeAndDocs}: an explicit TypeScript annotation always
6
- * wins, then JSDoc `@type`/`@param`/`@returns`, then a type resolved from an
7
- * identifier default's own JSDoc, and only then a bare inferred/initializer
8
- * type. `"unknown"` means none of the above produced any type text at all.
9
- */
10
- export declare function resolveTypeSource({ hasTypeScriptType, hasJSDocType, inferredType, finalType, }: {
11
- hasTypeScriptType?: boolean;
12
- hasJSDocType?: boolean;
13
- inferredType?: string;
14
- finalType?: string;
15
- }): ComponentPropTypeSource;
16
- export interface ResolvePropTypeAndDocsInput {
17
- /** Explicit TypeScript type text: a legacy `: T` annotation, or the matching `$props()` type-literal member in runes. */
18
- explicitType?: string;
19
- /**
20
- * Lowest-precedence type text, used only when nothing else applies: the
21
- * initializer's inferred type, or the literal `"() => any"` seed for a
22
- * bare `export function` declaration (which has no initializer).
23
- */
24
- typeSeed?: string;
25
- /**
26
- * Value fed to {@link resolveTypeSource}'s `inferredType` bucket. Distinct
27
- * from `typeSeed` for function declarations, which have an initializer-less
28
- * `typeSeed` placeholder but no actual inferred type.
29
- */
30
- inferredTypeForSource?: string;
31
- jsdocType?: string;
32
- jsdocDescription?: string;
33
- jsdocParams?: ComponentPropParam[];
34
- jsdocReturnType?: string;
35
- /**
36
- * Type/description/params/returnType resolved from an identifier default's
37
- * own JSDoc (e.g. `export let onClick = defaultHandler;` where
38
- * `defaultHandler` carries its own doc comment). Callers should gate this
39
- * to `undefined` whenever `explicitType`/`jsdocType` is already set, so it
40
- * only ever fills a genuine gap (see {@link resolvePropIsFunction}, which
41
- * relies on the same gating).
42
- */
43
- resolvedType?: string;
44
- resolvedDescription?: string;
45
- resolvedParams?: ComponentPropParam[];
46
- resolvedReturnType?: string;
47
- /** True when the initializer itself is an arrow/function expression. */
48
- initializerIsFunction: boolean;
49
- /** True for a bare `export function foo() {}` declaration. */
50
- isFunctionDeclaration: boolean;
51
- /**
52
- * Runes-only: also treat the prop as a function when its resolved type
53
- * text looks like a callback signature (`@param`/`@returns`/`=>` from
54
- * TypeScript, JSDoc, or an identifier default). Legacy `export let` never
55
- * applies this signature check; the mode difference predates this helper
56
- * and is preserved here rather than silently converged.
57
- */
58
- inferIsFunctionFromTypeSignature?: boolean;
59
- /**
60
- * Legacy-only: fall back to a `@typedef`'s own description when the prop
61
- * has none of its own. Runes omits this today (a preserved mode
62
- * difference); pass `undefined` there.
63
- */
64
- typedefs?: Map<string, {
65
- description?: string;
66
- }>;
67
- }
68
- export interface ResolvedPropTypeAndDocs {
69
- type?: string;
70
- typeSource: ComponentPropTypeSource;
71
- description?: string;
72
- params?: ComponentPropParam[];
73
- returnType?: string;
74
- isFunction: boolean;
75
- }
76
- /**
77
- * Resolves the type/description/params/returnType/isFunction decisions
78
- * shared by every prop front-end (legacy module exports, legacy instance
79
- * `export let`/`export function`, and runes `$props()` destructuring). The
80
- * front-ends differ only in how they extract the raw signals below from
81
- * their respective AST shapes; once extracted, the decisions are identical
82
- * except where explicitly parameterized above.
83
- */
84
- export declare function resolvePropTypeAndDocs(input: ResolvePropTypeAndDocsInput): ResolvedPropTypeAndDocs;