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/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as R,b,c as t,d as y,e as j,f as k,g as A,h as D,i as q,j as W,k as v,l as S,m as e,n as H,o as I,p as L,q as M,r as J,s as N}from"./chunk-m538qnhp.js";import{t as K}from"./chunk-0fqdg2xa.js";import"./chunk-8myyzjb1.js";import"./chunk-as5hgj7e.js";import"./chunk-tmj7vnjr.js";import"./chunk-xryt7ad2.js";import"./chunk-t9d5k3p7.js";async function E(x){if(x&&"input"in x)throw Error("sveld: the `input` option was renamed to `entry`.");let{entry:P,...z}=x??{},m=await W(),p=D(P??m.entry);if(p===null)throw Error('sveld: could not resolve a Svelte entry point. Set package.json#svelte, or pass the "entry" option.');let o=v(m,z,{entry:p}),r=await e(p,o.glob===!0,S(o)),C;if(o.check)C=await y(r.components,t(o),{entryExports:r.entryExports});await J(r,o,p);let{diagnostics:f}=r;if((o.reportDiagnostics||o.strict)&&f.length>0)console.error(A(f));if(o.strict&&f.length>0)process.exitCode=1;return{diagnostics:f,check:C}}export{E as sveld,y as runCheck,H as registerWriter,L as listWriters,I as getWriter,k as formatCheckReportJson,j as formatCheckReport,b as diffApiDocuments,q as defineConfig,M as default,N as cli,R as buildComponentApiDocument,K as ComponentParser};
|
package/package.json
CHANGED
package/lib/ComponentParser.d.ts
DELETED
|
@@ -1,560 +0,0 @@
|
|
|
1
|
-
import type { Property } from "estree";
|
|
2
|
-
import type { Node } from "estree-walker";
|
|
3
|
-
import type { SveldDiagnostic } from "./diagnostics";
|
|
4
|
-
import { PARSED_COMPONENT_TYPE_SCRIPT_METADATA } from "./parsed-component-metadata";
|
|
5
|
-
import { assignValueOrUndefined } from "./parser/utils";
|
|
6
|
-
export { assignValueOrUndefined as assignValue };
|
|
7
|
-
/** Structured JSDoc tag (e.g. `{ name: "since", body: "1.2.0" }`). */
|
|
8
|
-
export interface JsDocPassthroughTag {
|
|
9
|
-
name: string;
|
|
10
|
-
body: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* From `@deprecated` JSDoc: a message string, or `true` when the tag has no message.
|
|
14
|
-
*/
|
|
15
|
-
export type DeprecatedValue = string | true;
|
|
16
|
-
export interface LegacyAstRoot {
|
|
17
|
-
module?: Node;
|
|
18
|
-
html?: Node;
|
|
19
|
-
instance?: Node;
|
|
20
|
-
}
|
|
21
|
-
export interface SourcePosition {
|
|
22
|
-
/** 1-based source line number */
|
|
23
|
-
line: number;
|
|
24
|
-
/** 0-based source column number */
|
|
25
|
-
column: number;
|
|
26
|
-
}
|
|
27
|
-
export interface SourceRange {
|
|
28
|
-
start: SourcePosition;
|
|
29
|
-
end: SourcePosition;
|
|
30
|
-
}
|
|
31
|
-
export interface RunesPropTypeMetadata {
|
|
32
|
-
optional: boolean;
|
|
33
|
-
source?: SourceRange;
|
|
34
|
-
type: string;
|
|
35
|
-
}
|
|
36
|
-
export interface RunesPropsDeclarationMetadata {
|
|
37
|
-
canonicalType?: string;
|
|
38
|
-
props: Map<string, RunesPropTypeMetadata>;
|
|
39
|
-
referencedImportedTypes: Set<string>;
|
|
40
|
-
referencedLocalTypes: Set<string>;
|
|
41
|
-
}
|
|
42
|
-
export type ModernRunesTypeNode = {
|
|
43
|
-
type?: string;
|
|
44
|
-
id?: {
|
|
45
|
-
name?: string;
|
|
46
|
-
};
|
|
47
|
-
start?: number;
|
|
48
|
-
end?: number;
|
|
49
|
-
body?: {
|
|
50
|
-
body?: ModernRunesTypeMember[];
|
|
51
|
-
};
|
|
52
|
-
typeAnnotation?: ModernRunesTypeNode;
|
|
53
|
-
typeName?: unknown;
|
|
54
|
-
types?: ModernRunesTypeNode[];
|
|
55
|
-
members?: ModernRunesTypeMember[];
|
|
56
|
-
/** Declaration-side `<T, U = Default>` (interfaces/type aliases). */
|
|
57
|
-
typeParameters?: {
|
|
58
|
-
params?: Array<{
|
|
59
|
-
name?: string;
|
|
60
|
-
}>;
|
|
61
|
-
};
|
|
62
|
-
/** Reference-side `<string, number>` concrete arguments (`TSTypeReference`). */
|
|
63
|
-
typeArguments?: {
|
|
64
|
-
params?: ModernRunesTypeNode[];
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
export type ModernRunesTypeMember = {
|
|
68
|
-
type?: string;
|
|
69
|
-
computed?: boolean;
|
|
70
|
-
optional?: boolean;
|
|
71
|
-
start?: number;
|
|
72
|
-
end?: number;
|
|
73
|
-
key?: Property["key"];
|
|
74
|
-
typeAnnotation?: {
|
|
75
|
-
start?: number;
|
|
76
|
-
end?: number;
|
|
77
|
-
typeAnnotation?: ModernRunesTypeNode;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
export interface TypeImportBinding {
|
|
81
|
-
importedName?: string;
|
|
82
|
-
localName: string;
|
|
83
|
-
source: string;
|
|
84
|
-
specifierType: "default" | "named" | "namespace";
|
|
85
|
-
}
|
|
86
|
-
export interface LocalTypeDeclaration {
|
|
87
|
-
code: string;
|
|
88
|
-
node: ModernRunesTypeNode;
|
|
89
|
-
start: number;
|
|
90
|
-
}
|
|
91
|
-
export interface ParsedComponentTypeScriptMetadata {
|
|
92
|
-
canonicalPropsType?: string;
|
|
93
|
-
canonicalPropNames: string[];
|
|
94
|
-
localTypeDeclarations: string[];
|
|
95
|
-
typeImportStatements: string[];
|
|
96
|
-
/**
|
|
97
|
-
* Whether `canonicalPropsType` mentions one of the component's own
|
|
98
|
-
* `<script generics="...">` parameters (e.g. `Props<T>`). The semantic
|
|
99
|
-
* resolver has no binding for `T`, so `resolveTypes` must leave this
|
|
100
|
-
* component's props as their AST-derived text rather than expand them.
|
|
101
|
-
*/
|
|
102
|
-
referencesComponentGenerics?: boolean;
|
|
103
|
-
}
|
|
104
|
-
export { applyResolvedProps, getParsedComponentTypeScriptMetadata, PARSED_COMPONENT_TYPE_SCRIPT_METADATA, } from "./parsed-component-metadata";
|
|
105
|
-
/** One prop returned by the TypeScript checker during `resolveTypes`. */
|
|
106
|
-
export interface ResolvedComponentProp {
|
|
107
|
-
name: string;
|
|
108
|
-
type: string;
|
|
109
|
-
isRequired: boolean;
|
|
110
|
-
description?: string;
|
|
111
|
-
}
|
|
112
|
-
export type SyntaxMode = "legacy" | "runes";
|
|
113
|
-
export type ScriptLanguage = "js" | "ts";
|
|
114
|
-
export type ScopeBindingKind = "prop" | "local";
|
|
115
|
-
export type ScopeBinding = {
|
|
116
|
-
kind: ScopeBindingKind;
|
|
117
|
-
publicPropName?: string;
|
|
118
|
-
};
|
|
119
|
-
export type LexicalScope = Map<string, ScopeBinding>;
|
|
120
|
-
export type ComponentPropTypeSource = "typescript" | "jsdoc" | "default" | "inferred" | "unknown";
|
|
121
|
-
export type ComponentPropDefaultValueKind = "literal" | "array" | "object" | "expression" | "function" | "unknown";
|
|
122
|
-
export interface ComponentPropDefaultValue {
|
|
123
|
-
raw: string;
|
|
124
|
-
kind: ComponentPropDefaultValueKind;
|
|
125
|
-
value?: unknown;
|
|
126
|
-
}
|
|
127
|
-
export interface ProcessedInitializer {
|
|
128
|
-
value?: string;
|
|
129
|
-
type?: string;
|
|
130
|
-
isFunction: boolean;
|
|
131
|
-
defaultValue?: ComponentPropDefaultValue;
|
|
132
|
-
/** JSDoc from identifier default when the prop has none. */
|
|
133
|
-
resolvedType?: string;
|
|
134
|
-
resolvedDescription?: string;
|
|
135
|
-
resolvedParams?: ComponentPropParam[];
|
|
136
|
-
resolvedReturnType?: string;
|
|
137
|
-
}
|
|
138
|
-
type ModernScriptAttribute = {
|
|
139
|
-
name?: string;
|
|
140
|
-
value?: Array<{
|
|
141
|
-
data?: string;
|
|
142
|
-
raw?: string;
|
|
143
|
-
}> | boolean;
|
|
144
|
-
start?: number;
|
|
145
|
-
end?: number;
|
|
146
|
-
};
|
|
147
|
-
export type ModernScriptNode = {
|
|
148
|
-
attributes?: ModernScriptAttribute[];
|
|
149
|
-
};
|
|
150
|
-
interface ComponentParserDiagnostics {
|
|
151
|
-
moduleName: string;
|
|
152
|
-
filePath: string;
|
|
153
|
-
}
|
|
154
|
-
export type ComponentPropBinding = "readonly" | "writable";
|
|
155
|
-
/** Function prop parameter from JSDoc `@param` tags. */
|
|
156
|
-
export interface ComponentPropParam {
|
|
157
|
-
/** Parameter name. */
|
|
158
|
-
name: string;
|
|
159
|
-
/** Parameter type (e.g. `"string"`, `"CustomType"`). */
|
|
160
|
-
type: string;
|
|
161
|
-
/** From JSDoc `@param`. */
|
|
162
|
-
description?: string;
|
|
163
|
-
/** True when optional. */
|
|
164
|
-
optional?: boolean;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* A parsed component prop: the shared internal IR that every prop front-end
|
|
168
|
-
* (legacy `<script context="module">` exports, legacy instance
|
|
169
|
-
* `export let`/`export function`, and runes `$props()` destructuring)
|
|
170
|
-
* produces via {@link resolvePropTypeAndDocs}, then hands to `addProp`. The
|
|
171
|
-
* three front-ends differ only in how they extract the raw signals (type
|
|
172
|
-
* text, JSDoc, initializer shape) from their respective AST shapes; the
|
|
173
|
-
* decisions below are shared and, outside the two documented mode
|
|
174
|
-
* differences, identical across modes.
|
|
175
|
-
*
|
|
176
|
-
* - `typeSource` precedence: an explicit TypeScript annotation always wins,
|
|
177
|
-
* then JSDoc (`@type`/`@param`/`@returns`), then a type resolved from an
|
|
178
|
-
* identifier default's own JSDoc, and only then a bare inferred/initializer
|
|
179
|
-
* type. See {@link resolveTypeSource}.
|
|
180
|
-
* - JSDoc-vs-TS merge: `type`/`params`/`returnType`/`description` each
|
|
181
|
-
* independently prefer their JSDoc-sourced value over the identifier
|
|
182
|
-
* default's resolved value; an explicit TypeScript type additionally beats
|
|
183
|
-
* JSDoc for `type` only.
|
|
184
|
-
* - Mode difference (preserved, not converged): legacy `export let`/
|
|
185
|
-
* `export function` never infers `isFunction` from a function-shaped type
|
|
186
|
-
* text; runes `$props()` does (`inferIsFunctionFromTypeSignature`).
|
|
187
|
-
* - Mode difference (preserved, not converged): legacy falls back to a
|
|
188
|
-
* matching `@typedef`'s own description when the prop has none; runes does
|
|
189
|
-
* not pass `typedefs` to {@link resolvePropTypeAndDocs} today.
|
|
190
|
-
*/
|
|
191
|
-
export interface ComponentProp {
|
|
192
|
-
/** Public prop name. */
|
|
193
|
-
name: string;
|
|
194
|
-
/** `"let"` (required), `"const"` (default), or `"function"`. */
|
|
195
|
-
kind: "let" | "const" | "function";
|
|
196
|
-
/** True when declared with `const`. */
|
|
197
|
-
constant: boolean;
|
|
198
|
-
/** TypeScript type text. */
|
|
199
|
-
type?: string;
|
|
200
|
-
/** Conservative provenance for the prop type. See the precedence rule on {@link ComponentProp}. */
|
|
201
|
-
typeSource?: ComponentPropTypeSource;
|
|
202
|
-
/** Local binding when it differs from the public name. */
|
|
203
|
-
localName?: string;
|
|
204
|
-
/** Default value as source text; unset when the prop has no initializer/default. */
|
|
205
|
-
value?: string;
|
|
206
|
-
/** Structured default value metadata for docs UIs; set alongside `value` from the same initializer. */
|
|
207
|
-
defaultValue?: ComponentPropDefaultValue;
|
|
208
|
-
/** From JSDoc, or a matching `@typedef`'s own description (legacy only; see {@link ComponentProp}). */
|
|
209
|
-
description?: string;
|
|
210
|
-
/** From JSDoc `@param` on function props. */
|
|
211
|
-
params?: ComponentPropParam[];
|
|
212
|
-
/** From JSDoc `@returns` on function props. */
|
|
213
|
-
returnType?: string;
|
|
214
|
-
/**
|
|
215
|
-
* True for arrow/function-expression initializers and bare `function`
|
|
216
|
-
* declarations in every mode; additionally true for a function-shaped
|
|
217
|
-
* type/JSDoc signature in runes only (see {@link ComponentProp}).
|
|
218
|
-
*/
|
|
219
|
-
isFunction: boolean;
|
|
220
|
-
/** True for `function` declarations. */
|
|
221
|
-
isFunctionDeclaration: boolean;
|
|
222
|
-
/** True when declared with `let` and no default. */
|
|
223
|
-
isRequired: boolean;
|
|
224
|
-
/**
|
|
225
|
-
* True when the prop is mutated locally (legacy, inferred from assignment/
|
|
226
|
-
* binding targets) or declared with `$bindable()` (runes).
|
|
227
|
-
*/
|
|
228
|
-
reactive: boolean;
|
|
229
|
-
/** Binding direction from `@bindable` JSDoc. */
|
|
230
|
-
binding?: ComponentPropBinding;
|
|
231
|
-
/** True when declared with Svelte 5 `$bindable()` (runes only). */
|
|
232
|
-
bindable?: true;
|
|
233
|
-
/** From `@deprecated` JSDoc. */
|
|
234
|
-
deprecated?: DeprecatedValue;
|
|
235
|
-
/** `@since` / `@example` tags in source order. */
|
|
236
|
-
tags?: JsDocPassthroughTag[];
|
|
237
|
-
/** Source range when available. */
|
|
238
|
-
source?: SourceRange;
|
|
239
|
-
}
|
|
240
|
-
export interface ComponentSlot {
|
|
241
|
-
/** Slot name (`null` for the default slot). */
|
|
242
|
-
name?: string | null;
|
|
243
|
-
/** True for the default slot. */
|
|
244
|
-
default: boolean;
|
|
245
|
-
/** Fallback content when the slot is empty. */
|
|
246
|
-
fallback?: string;
|
|
247
|
-
/** Slot props as TypeScript type text. */
|
|
248
|
-
slot_props?: string;
|
|
249
|
-
/** From JSDoc `@slot` or `@snippet`. */
|
|
250
|
-
description?: string;
|
|
251
|
-
/** From `@deprecated` JSDoc. */
|
|
252
|
-
deprecated?: DeprecatedValue;
|
|
253
|
-
/** Tags between the description and `@slot`/`@snippet` (e.g. `@example`), in source order. */
|
|
254
|
-
tags?: JsDocPassthroughTag[];
|
|
255
|
-
/** Source range when available. */
|
|
256
|
-
source?: SourceRange;
|
|
257
|
-
}
|
|
258
|
-
/** Slot prop type text or a reference to resolve at finalize time. */
|
|
259
|
-
export interface SlotPropValue {
|
|
260
|
-
/** Type text or reference. */
|
|
261
|
-
value?: string;
|
|
262
|
-
/** True to replace with a prop type reference. */
|
|
263
|
-
replace: boolean;
|
|
264
|
-
}
|
|
265
|
-
export type SlotProps = Record<string, SlotPropValue>;
|
|
266
|
-
/**
|
|
267
|
-
* Internal representation of {@link ComponentSlot} used while parsing.
|
|
268
|
-
*
|
|
269
|
-
* `slot_props` is either raw TS type text (from a JSDoc `@slot`/`@snippet` tag,
|
|
270
|
-
* used as-is) or a structured {@link SlotProps} map (from template parsing,
|
|
271
|
-
* formatted into TS type text once at the end of the parse). Keeping it
|
|
272
|
-
* structured until then avoids a JSON.stringify/JSON.parse round-trip per slot.
|
|
273
|
-
*/
|
|
274
|
-
export type InternalComponentSlot = Omit<ComponentSlot, "slot_props"> & {
|
|
275
|
-
slot_props?: string | SlotProps;
|
|
276
|
-
};
|
|
277
|
-
/** Event forwarded with `on:eventname` and no handler. */
|
|
278
|
-
export interface ForwardedEvent {
|
|
279
|
-
/** Discriminator: `"forwarded"`. */
|
|
280
|
-
type: "forwarded";
|
|
281
|
-
/** Event name. */
|
|
282
|
-
name: string;
|
|
283
|
-
/** Element or component that forwards the event. */
|
|
284
|
-
element: ComponentInlineElement | ComponentElement;
|
|
285
|
-
/** From JSDoc `@event`. */
|
|
286
|
-
description?: string;
|
|
287
|
-
/** From `@deprecated` JSDoc. */
|
|
288
|
-
deprecated?: DeprecatedValue;
|
|
289
|
-
/** Detail type from `@event`. */
|
|
290
|
-
detail?: string;
|
|
291
|
-
/** `@since` / `@example` tags in source order. */
|
|
292
|
-
tags?: JsDocPassthroughTag[];
|
|
293
|
-
/** Source range when available. */
|
|
294
|
-
source?: SourceRange;
|
|
295
|
-
}
|
|
296
|
-
/** Event from `createEventDispatcher()`, `dispatch()`, or `$host().dispatchEvent()`. */
|
|
297
|
-
export interface DispatchedEvent {
|
|
298
|
-
/** Discriminator: `"dispatched"`. */
|
|
299
|
-
type: "dispatched";
|
|
300
|
-
/** Event name. */
|
|
301
|
-
name: string;
|
|
302
|
-
/** Detail type text. */
|
|
303
|
-
detail?: string;
|
|
304
|
-
/** From JSDoc `@event`. */
|
|
305
|
-
description?: string;
|
|
306
|
-
/** From `@deprecated` JSDoc. */
|
|
307
|
-
deprecated?: DeprecatedValue;
|
|
308
|
-
/** `@since` / `@example` tags in source order. */
|
|
309
|
-
tags?: JsDocPassthroughTag[];
|
|
310
|
-
/** Source range when available. */
|
|
311
|
-
source?: SourceRange;
|
|
312
|
-
}
|
|
313
|
-
export type ComponentEvent = ForwardedEvent | DispatchedEvent;
|
|
314
|
-
/**
|
|
315
|
-
* Serialized {@link ForwardedEvent} for JSON output. `element` is a string, not an object.
|
|
316
|
-
*
|
|
317
|
-
* @example
|
|
318
|
-
* ```ts
|
|
319
|
-
* // ForwardedEvent with element object:
|
|
320
|
-
* { type: "forwarded", name: "click", element: { type: "Element", name: "button" } }
|
|
321
|
-
*
|
|
322
|
-
* // SerializedForwardedEvent for JSON:
|
|
323
|
-
* { type: "forwarded", name: "click", element: "button" }
|
|
324
|
-
* ```
|
|
325
|
-
*/
|
|
326
|
-
export interface SerializedForwardedEvent {
|
|
327
|
-
/** Discriminator: `"forwarded"`. */
|
|
328
|
-
type: "forwarded";
|
|
329
|
-
/** Event name. */
|
|
330
|
-
name: string;
|
|
331
|
-
/** Element name as a string for JSON output. */
|
|
332
|
-
element: string;
|
|
333
|
-
/** From JSDoc `@event`. */
|
|
334
|
-
description?: string;
|
|
335
|
-
/** From `@deprecated` JSDoc. */
|
|
336
|
-
deprecated?: DeprecatedValue;
|
|
337
|
-
/** Detail type from `@event`. */
|
|
338
|
-
detail?: string;
|
|
339
|
-
/** `@since` / `@example` tags in source order. */
|
|
340
|
-
tags?: JsDocPassthroughTag[];
|
|
341
|
-
/** Source range when available. */
|
|
342
|
-
source?: SourceRange;
|
|
343
|
-
}
|
|
344
|
-
export type SerializedComponentEvent = SerializedForwardedEvent | DispatchedEvent;
|
|
345
|
-
/** JSDoc `@typedef` extracted as a named type. */
|
|
346
|
-
export interface TypeDef {
|
|
347
|
-
/** Type text (e.g. `"{ x: number; y: number }"`). */
|
|
348
|
-
type: string;
|
|
349
|
-
/** Type name. */
|
|
350
|
-
name: string;
|
|
351
|
-
/** From JSDoc. */
|
|
352
|
-
description?: string;
|
|
353
|
-
/** Full `type` alias declaration text. */
|
|
354
|
-
ts: string;
|
|
355
|
-
}
|
|
356
|
-
export type ComponentGenerics = [name: string, type: string] | null;
|
|
357
|
-
export interface ComponentInlineElement {
|
|
358
|
-
/** Discriminator: `"InlineComponent"`. */
|
|
359
|
-
type: "InlineComponent";
|
|
360
|
-
/** Component name. */
|
|
361
|
-
name: string;
|
|
362
|
-
}
|
|
363
|
-
export interface ComponentElement {
|
|
364
|
-
type: "Element";
|
|
365
|
-
name: string;
|
|
366
|
-
/**
|
|
367
|
-
* Static tag for `svelte:element this="div"`. Undefined when `this` is dynamic.
|
|
368
|
-
*
|
|
369
|
-
* @example
|
|
370
|
-
* ```svelte
|
|
371
|
-
* <!-- Static tag -->
|
|
372
|
-
* <svelte:element this="div" bind:this={elementRef} />
|
|
373
|
-
* // thisValue: "div"
|
|
374
|
-
*
|
|
375
|
-
* <!-- Dynamic tag -->
|
|
376
|
-
* <svelte:element this={tagName} bind:this={elementRef} />
|
|
377
|
-
* // thisValue: undefined
|
|
378
|
-
* ```
|
|
379
|
-
*/
|
|
380
|
-
thisValue?: string;
|
|
381
|
-
/** From `@restProps` JSDoc. */
|
|
382
|
-
description?: string;
|
|
383
|
-
}
|
|
384
|
-
export type RestProps = undefined | ComponentInlineElement | ComponentElement;
|
|
385
|
-
/** JSDoc `@extends` target. */
|
|
386
|
-
export interface Extends {
|
|
387
|
-
/** Interface name (e.g. `"ButtonProps"`). */
|
|
388
|
-
interface: string;
|
|
389
|
-
/** Import path (e.g. `"./types"`). */
|
|
390
|
-
import: string;
|
|
391
|
-
}
|
|
392
|
-
export interface ComponentPropBindings {
|
|
393
|
-
elements: string[];
|
|
394
|
-
}
|
|
395
|
-
export interface ComponentContextProp {
|
|
396
|
-
/** Property name. */
|
|
397
|
-
name: string;
|
|
398
|
-
/** Property type text. */
|
|
399
|
-
type: string;
|
|
400
|
-
/** From JSDoc. */
|
|
401
|
-
description?: string;
|
|
402
|
-
/** True when optional. */
|
|
403
|
-
optional: boolean;
|
|
404
|
-
}
|
|
405
|
-
/** Context from `setContext(key, value)`. */
|
|
406
|
-
export interface ComponentContext {
|
|
407
|
-
/** Context key from `setContext`. */
|
|
408
|
-
key: string;
|
|
409
|
-
/** Generated type name (e.g. `"ModalContext"`). */
|
|
410
|
-
typeName: string;
|
|
411
|
-
/** From JSDoc. */
|
|
412
|
-
description?: string;
|
|
413
|
-
/** Context object properties. */
|
|
414
|
-
properties: ComponentContextProp[];
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Complete parsed component metadata from {@link ComponentParser.parseSvelteComponent}.
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* ```ts
|
|
421
|
-
* const parser = new ComponentParser();
|
|
422
|
-
* const parsed = parser.parseSvelteComponent(source, {
|
|
423
|
-
* moduleName: "Button",
|
|
424
|
-
* filePath: "./Button.svelte"
|
|
425
|
-
* });
|
|
426
|
-
*
|
|
427
|
-
* parsed.props;
|
|
428
|
-
* parsed.slots;
|
|
429
|
-
* parsed.events;
|
|
430
|
-
* parsed.typedefs;
|
|
431
|
-
* parsed.contexts;
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
export interface ParsedComponent {
|
|
435
|
-
/** Source range of the parsed file. */
|
|
436
|
-
source?: SourceRange;
|
|
437
|
-
syntaxMode: SyntaxMode;
|
|
438
|
-
scriptLanguage?: ScriptLanguage;
|
|
439
|
-
/** Instance-level props (`export let`/`export function`, or runes `$props()`). See {@link ComponentProp} for the shared IR these are built from. */
|
|
440
|
-
props: ComponentProp[];
|
|
441
|
-
/** Exports from `<script context="module">`. Same {@link ComponentProp} shape as `props`, resolved through the same shared decisions. */
|
|
442
|
-
moduleExports: ComponentProp[];
|
|
443
|
-
slots: ComponentSlot[];
|
|
444
|
-
/** Serialized events for JSON/API output. */
|
|
445
|
-
events: SerializedComponentEvent[];
|
|
446
|
-
typedefs: TypeDef[];
|
|
447
|
-
generics: null | ComponentGenerics;
|
|
448
|
-
rest_props: RestProps;
|
|
449
|
-
extends?: Extends;
|
|
450
|
-
/** From `@component` HTML comment. */
|
|
451
|
-
componentComment?: string;
|
|
452
|
-
componentCommentSource?: SourceRange;
|
|
453
|
-
contexts?: ComponentContext[];
|
|
454
|
-
customElementTag?: string;
|
|
455
|
-
/**
|
|
456
|
-
* Type guesses from this parse (unknown props, `any` contexts, orphan `@event` tags).
|
|
457
|
-
*/
|
|
458
|
-
diagnostics?: SveldDiagnostic[];
|
|
459
|
-
/** Writer-only TypeScript metadata. Not serialized to JSON. */
|
|
460
|
-
[PARSED_COMPONENT_TYPE_SCRIPT_METADATA]?: ParsedComponentTypeScriptMetadata;
|
|
461
|
-
}
|
|
462
|
-
export default class ComponentParser {
|
|
463
|
-
/**
|
|
464
|
-
* All per-parse mutable state (props, slots, events, scopes, source, etc.).
|
|
465
|
-
* See {@link ParserContext} for field-by-field documentation. Replaced
|
|
466
|
-
* wholesale by `cleanup()` between parses.
|
|
467
|
-
*/
|
|
468
|
-
private ctx;
|
|
469
|
-
private static mapToArray;
|
|
470
|
-
private static getStaticAttributeValue;
|
|
471
|
-
resolveScriptLanguage(parsed: {
|
|
472
|
-
instance?: ModernScriptNode;
|
|
473
|
-
module?: ModernScriptNode;
|
|
474
|
-
}): ScriptLanguage | undefined;
|
|
475
|
-
/**
|
|
476
|
-
* Reads the `generics` attribute off the instance script (Svelte only allows
|
|
477
|
-
* it there, and only alongside `lang="ts"`). Returns the raw value for later
|
|
478
|
-
* precedence resolution against `@generics`/`@template` JSDoc tags, or
|
|
479
|
-
* `undefined` if absent. Records a `syntax-skipped` diagnostic and returns
|
|
480
|
-
* `undefined` if the attribute is present without `lang="ts"`, since sveld
|
|
481
|
-
* can't safely guess how to parse it as plain JavaScript.
|
|
482
|
-
*/
|
|
483
|
-
resolveScriptGenericsAttribute(parsed: {
|
|
484
|
-
instance?: ModernScriptNode;
|
|
485
|
-
}): {
|
|
486
|
-
value: string;
|
|
487
|
-
source?: SourceRange;
|
|
488
|
-
} | undefined;
|
|
489
|
-
private static assignValue;
|
|
490
|
-
private resolvePublicPropName;
|
|
491
|
-
trackPropLocalName(propName: string, localName?: string): void;
|
|
492
|
-
private getPropByLocalOrPublic;
|
|
493
|
-
getPropTypeByLocalOrPublic(name: string): string | undefined;
|
|
494
|
-
getExplicitPropType(name: string): string | undefined;
|
|
495
|
-
getPropertyName(node: Property["key"]): string | undefined;
|
|
496
|
-
isNumericConstant(memberExpr: unknown): boolean;
|
|
497
|
-
resolveLocalVarJSDoc(name: string): {
|
|
498
|
-
type?: string;
|
|
499
|
-
params?: ComponentPropParam[];
|
|
500
|
-
returnType?: string;
|
|
501
|
-
description?: string;
|
|
502
|
-
binding?: ComponentPropBinding;
|
|
503
|
-
deprecated?: DeprecatedValue;
|
|
504
|
-
tags?: JsDocPassthroughTag[];
|
|
505
|
-
} | undefined;
|
|
506
|
-
private addModuleExport;
|
|
507
|
-
/**
|
|
508
|
-
* @example
|
|
509
|
-
* ```ts
|
|
510
|
-
* aliasType("*"); // "any"
|
|
511
|
-
* aliasType(" string "); // "string"
|
|
512
|
-
* ```
|
|
513
|
-
*/
|
|
514
|
-
aliasType(type: string): string;
|
|
515
|
-
/**
|
|
516
|
-
* @example
|
|
517
|
-
* ```ts
|
|
518
|
-
* // Given:
|
|
519
|
-
* // /**
|
|
520
|
-
* // * @type {number}
|
|
521
|
-
* // * The count value
|
|
522
|
-
* // *\/
|
|
523
|
-
* // const count = 0;
|
|
524
|
-
*
|
|
525
|
-
* findVariableTypeAndDescription("count");
|
|
526
|
-
* // { type: "number", description: "The count value" }
|
|
527
|
-
* ```
|
|
528
|
-
*/
|
|
529
|
-
findVariableTypeAndDescription(varName: string): {
|
|
530
|
-
type: string;
|
|
531
|
-
description?: string;
|
|
532
|
-
} | null;
|
|
533
|
-
accumulateGeneric(name: string, constraint: string): void;
|
|
534
|
-
/**
|
|
535
|
-
* Resets parser state for reuse between parses.
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```ts
|
|
539
|
-
* parser.parseSvelteComponent(source1, diagnostics1);
|
|
540
|
-
* parser.cleanup();
|
|
541
|
-
* parser.parseSvelteComponent(source2, diagnostics2);
|
|
542
|
-
* ```
|
|
543
|
-
*/
|
|
544
|
-
cleanup(): void;
|
|
545
|
-
private static readonly SCRIPT_BLOCK_REGEX;
|
|
546
|
-
private static readonly TS_DIRECTIVE_REGEX;
|
|
547
|
-
private static stripTypeScriptDirectivesFromScripts;
|
|
548
|
-
/**
|
|
549
|
-
* @example
|
|
550
|
-
* ```ts
|
|
551
|
-
* const parser = new ComponentParser();
|
|
552
|
-
* const result = parser.parseSvelteComponent(source, {
|
|
553
|
-
* moduleName: "Button",
|
|
554
|
-
* filePath: "./Button.svelte"
|
|
555
|
-
* });
|
|
556
|
-
* // { props, slots, events, typedefs, ... }
|
|
557
|
-
* ```
|
|
558
|
-
*/
|
|
559
|
-
parseSvelteComponent(source: string, diagnostics: ComponentParserDiagnostics): ParsedComponent;
|
|
560
|
-
}
|
package/lib/ast-guards.d.ts
DELETED
|
@@ -1,16 +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
|
-
export declare function unwrapTypeCastExpression(node: unknown): unknown;
|
|
11
|
-
export declare function getTypeCastAnnotation(node: unknown): unknown;
|
|
12
|
-
export declare function isNewExpression(node: unknown): node is NewExpression;
|
|
13
|
-
export declare function isNewExpressionNamed(node: unknown, calleeName: string): node is NewExpression;
|
|
14
|
-
export declare function isFunctionDeclaration(node: unknown): node is FunctionDeclaration;
|
|
15
|
-
export declare function isFunctionExpression(node: unknown): node is FunctionExpression;
|
|
16
|
-
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 {};
|