sveld 0.30.3 → 0.32.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 +197 -18
- package/lib/index.js +498 -496
- package/lib/{ComponentParser.d.ts → src/ComponentParser.d.ts} +64 -0
- package/lib/{writer → src/writer}/markdown-format-utils.d.ts +1 -1
- package/package.json +1 -1
- /package/lib/{cli.d.ts → src/cli.d.ts} +0 -0
- /package/lib/{create-exports.d.ts → src/create-exports.d.ts} +0 -0
- /package/lib/{element-tag-map.d.ts → src/element-tag-map.d.ts} +0 -0
- /package/lib/{get-svelte-entry.d.ts → src/get-svelte-entry.d.ts} +0 -0
- /package/lib/{index.d.ts → src/index.d.ts} +0 -0
- /package/lib/{parse-exports.d.ts → src/parse-exports.d.ts} +0 -0
- /package/lib/{path.d.ts → src/path.d.ts} +0 -0
- /package/lib/{plugin.d.ts → src/plugin.d.ts} +0 -0
- /package/lib/{resolve-alias.d.ts → src/resolve-alias.d.ts} +0 -0
- /package/lib/{sveld.d.ts → src/sveld.d.ts} +0 -0
- /package/lib/{writer → src/writer}/MarkdownWriterBase.d.ts +0 -0
- /package/lib/{writer → src/writer}/Writer.d.ts +0 -0
- /package/lib/{writer → src/writer}/WriterMarkdown.d.ts +0 -0
- /package/lib/{writer → src/writer}/markdown-render-utils.d.ts +0 -0
- /package/lib/{writer → src/writer}/writer-json.d.ts +0 -0
- /package/lib/{writer → src/writer}/writer-markdown-core.d.ts +0 -0
- /package/lib/{writer → src/writer}/writer-markdown.d.ts +0 -0
- /package/lib/{writer → src/writer}/writer-ts-definitions-core.d.ts +0 -0
- /package/lib/{writer → src/writer}/writer-ts-definitions.d.ts +0 -0
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
export interface SourcePosition {
|
|
2
|
+
/** 1-based source line number */
|
|
3
|
+
line: number;
|
|
4
|
+
/** 0-based source column number */
|
|
5
|
+
column: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SourceRange {
|
|
8
|
+
start: SourcePosition;
|
|
9
|
+
end: SourcePosition;
|
|
10
|
+
}
|
|
1
11
|
export interface ParsedComponentTypeScriptMetadata {
|
|
2
12
|
canonicalPropsType?: string;
|
|
3
13
|
canonicalPropNames: string[];
|
|
@@ -8,6 +18,15 @@ export declare const PARSED_COMPONENT_TYPE_SCRIPT_METADATA: unique symbol;
|
|
|
8
18
|
export declare function getParsedComponentTypeScriptMetadata(component: {
|
|
9
19
|
[PARSED_COMPONENT_TYPE_SCRIPT_METADATA]?: ParsedComponentTypeScriptMetadata;
|
|
10
20
|
}): ParsedComponentTypeScriptMetadata | undefined;
|
|
21
|
+
type SyntaxMode = "legacy" | "runes";
|
|
22
|
+
type ScriptLanguage = "js" | "ts";
|
|
23
|
+
type ComponentPropTypeSource = "typescript" | "jsdoc" | "default" | "inferred" | "unknown";
|
|
24
|
+
type ComponentPropDefaultValueKind = "literal" | "array" | "object" | "expression" | "function" | "unknown";
|
|
25
|
+
interface ComponentPropDefaultValue {
|
|
26
|
+
raw: string;
|
|
27
|
+
kind: ComponentPropDefaultValueKind;
|
|
28
|
+
value?: unknown;
|
|
29
|
+
}
|
|
11
30
|
/**
|
|
12
31
|
* Diagnostic information for component parsing.
|
|
13
32
|
*
|
|
@@ -27,6 +46,7 @@ interface ComponentParserOptions {
|
|
|
27
46
|
/** Enable verbose logging for debugging parsing issues */
|
|
28
47
|
verbose?: boolean;
|
|
29
48
|
}
|
|
49
|
+
type ComponentPropBinding = "readonly" | "writable";
|
|
30
50
|
/**
|
|
31
51
|
* Parameter information for function props.
|
|
32
52
|
*
|
|
@@ -58,8 +78,14 @@ interface ComponentProp {
|
|
|
58
78
|
constant: boolean;
|
|
59
79
|
/** The TypeScript type of the prop (e.g., "string", "number | string") */
|
|
60
80
|
type?: string;
|
|
81
|
+
/** Conservative provenance for the prop type */
|
|
82
|
+
typeSource?: ComponentPropTypeSource;
|
|
83
|
+
/** Local variable name, emitted when it differs from the public prop name */
|
|
84
|
+
localName?: string;
|
|
61
85
|
/** The default value as a string representation of the source code */
|
|
62
86
|
value?: string;
|
|
87
|
+
/** Structured default value metadata for docs UIs */
|
|
88
|
+
defaultValue?: ComponentPropDefaultValue;
|
|
63
89
|
/** Description extracted from JSDoc comments */
|
|
64
90
|
description?: string;
|
|
65
91
|
/** Function parameters (for function props) extracted from `@param` tags */
|
|
@@ -74,6 +100,12 @@ interface ComponentProp {
|
|
|
74
100
|
isRequired: boolean;
|
|
75
101
|
/** Whether this prop is reactive (can change and trigger reactivity) */
|
|
76
102
|
reactive: boolean;
|
|
103
|
+
/** Explicit author-documented binding direction from `@bindable` JSDoc */
|
|
104
|
+
binding?: ComponentPropBinding;
|
|
105
|
+
/** True when the prop is explicitly declared with Svelte 5 `$bindable()` */
|
|
106
|
+
bindable?: true;
|
|
107
|
+
/** Source range for the prop declaration, when available */
|
|
108
|
+
source?: SourceRange;
|
|
77
109
|
}
|
|
78
110
|
/**
|
|
79
111
|
* Component slot definition.
|
|
@@ -100,6 +132,8 @@ interface ComponentSlot {
|
|
|
100
132
|
name: string;
|
|
101
133
|
body: string;
|
|
102
134
|
}>;
|
|
135
|
+
/** Source range for the slot/snippet declaration or documentation tag, when available */
|
|
136
|
+
source?: SourceRange;
|
|
103
137
|
}
|
|
104
138
|
/**
|
|
105
139
|
* Event that is forwarded from a child component or element.
|
|
@@ -118,6 +152,8 @@ interface ForwardedEvent {
|
|
|
118
152
|
description?: string;
|
|
119
153
|
/** The detail type if explicitly specified in `@event` tag */
|
|
120
154
|
detail?: string;
|
|
155
|
+
/** Source range for the forwarded event declaration or documentation tag, when available */
|
|
156
|
+
source?: SourceRange;
|
|
121
157
|
}
|
|
122
158
|
/**
|
|
123
159
|
* Event that is dispatched by the component.
|
|
@@ -134,6 +170,8 @@ interface DispatchedEvent {
|
|
|
134
170
|
detail?: string;
|
|
135
171
|
/** Description extracted from JSDoc `@event` tags */
|
|
136
172
|
description?: string;
|
|
173
|
+
/** Source range for the dispatched event call or documentation tag, when available */
|
|
174
|
+
source?: SourceRange;
|
|
137
175
|
}
|
|
138
176
|
type ComponentEvent = ForwardedEvent | DispatchedEvent;
|
|
139
177
|
/**
|
|
@@ -256,6 +294,12 @@ interface ComponentContext {
|
|
|
256
294
|
* ```
|
|
257
295
|
*/
|
|
258
296
|
export interface ParsedComponent {
|
|
297
|
+
/** Source range for the component source that was parsed */
|
|
298
|
+
source?: SourceRange;
|
|
299
|
+
/** Whether the component uses legacy or runes syntax according to compiler metadata */
|
|
300
|
+
syntaxMode: SyntaxMode;
|
|
301
|
+
/** Language used by the instance or module script when it can be determined */
|
|
302
|
+
scriptLanguage?: ScriptLanguage;
|
|
259
303
|
/** Component props that can be passed to the component */
|
|
260
304
|
props: ComponentProp[];
|
|
261
305
|
/** Exports from `<script context="module">` block */
|
|
@@ -274,6 +318,8 @@ export interface ParsedComponent {
|
|
|
274
318
|
extends?: Extends;
|
|
275
319
|
/** Component-level description from `@component` HTML comment */
|
|
276
320
|
componentComment?: string;
|
|
321
|
+
/** Source range for the `@component` HTML comment, when available */
|
|
322
|
+
componentCommentSource?: SourceRange;
|
|
277
323
|
/** Contexts created with `setContext` in the component */
|
|
278
324
|
contexts?: ComponentContext[];
|
|
279
325
|
/** Internal writer-only TypeScript metadata. Not serialized to JSON. */
|
|
@@ -284,6 +330,8 @@ export default class ComponentParser {
|
|
|
284
330
|
private options?;
|
|
285
331
|
/** Whether the component uses legacy or runes syntax according to compiler metadata */
|
|
286
332
|
private syntaxMode;
|
|
333
|
+
/** Language used by the component's instance or module script, when supported */
|
|
334
|
+
private scriptLanguage?;
|
|
287
335
|
/** Raw source code of the Svelte component being parsed */
|
|
288
336
|
private source?;
|
|
289
337
|
/** Compiled Svelte code containing extracted variables and AST */
|
|
@@ -296,6 +344,8 @@ export default class ComponentParser {
|
|
|
296
344
|
private extends?;
|
|
297
345
|
/** Component-level description extracted from `@component` HTML comment */
|
|
298
346
|
private componentComment?;
|
|
347
|
+
/** Source range for the `@component` HTML comment, when available */
|
|
348
|
+
private componentCommentSource?;
|
|
299
349
|
/** Set of reactive variable names found in the component */
|
|
300
350
|
private readonly reactive_vars;
|
|
301
351
|
/** Set of all variable declarations found in the component script */
|
|
@@ -348,8 +398,12 @@ export default class ComponentParser {
|
|
|
348
398
|
private readonly activeScopes;
|
|
349
399
|
/** Cached array of source code lines split by newline for efficient line-based operations */
|
|
350
400
|
private sourceLinesCache?;
|
|
401
|
+
/** Cached 0-based source offsets for the start of each line */
|
|
402
|
+
private sourceLineStartOffsetsCache?;
|
|
351
403
|
constructor(options?: ComponentParserOptions);
|
|
352
404
|
private static mapToArray;
|
|
405
|
+
private static getStaticAttributeValue;
|
|
406
|
+
private static resolveScriptLanguage;
|
|
353
407
|
private static assignValue;
|
|
354
408
|
private resolvePublicPropName;
|
|
355
409
|
private trackPropLocalName;
|
|
@@ -361,6 +415,11 @@ export default class ComponentParser {
|
|
|
361
415
|
private getTypeReferenceName;
|
|
362
416
|
private getTypeDependencyName;
|
|
363
417
|
private getTypeAnnotationText;
|
|
418
|
+
private getSourceLineStartOffsets;
|
|
419
|
+
private sourcePositionFromOffset;
|
|
420
|
+
private sourceRangeFromOffsets;
|
|
421
|
+
private sourceRangeFromNode;
|
|
422
|
+
private sourceRangeFromCommentTag;
|
|
364
423
|
private collectReferencedTypeDependencies;
|
|
365
424
|
private buildTypeImportStatements;
|
|
366
425
|
private buildTypeScriptMetadata;
|
|
@@ -384,6 +443,7 @@ export default class ComponentParser {
|
|
|
384
443
|
private isCallExpressionNamed;
|
|
385
444
|
private getPropertyName;
|
|
386
445
|
private logUnsupportedRunesPattern;
|
|
446
|
+
private logParserWarning;
|
|
387
447
|
private static formatComment;
|
|
388
448
|
/**
|
|
389
449
|
* Extracts and categorizes JSDoc tags from a parsed comment.
|
|
@@ -498,6 +558,10 @@ export default class ComponentParser {
|
|
|
498
558
|
* @returns The source code substring, or undefined if source is not available
|
|
499
559
|
*/
|
|
500
560
|
private sourceAtPos;
|
|
561
|
+
private sourceForExpression;
|
|
562
|
+
private jsonSafeValueFromExpression;
|
|
563
|
+
private classifyDefaultValue;
|
|
564
|
+
private resolveTypeSource;
|
|
501
565
|
/**
|
|
502
566
|
* Processes an initializer expression to extract its value, type, and function status.
|
|
503
567
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const BACKTICK_REGEX: RegExp;
|
|
2
2
|
export declare const WHITESPACE_REGEX: RegExp;
|
|
3
3
|
export declare const MD_TYPE_UNDEFINED = "--";
|
|
4
|
-
export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reactive | Type | Default value | Description |\n| :- | :- | :- | :- |\n";
|
|
4
|
+
export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |\n| :- | :- | :- | :- | :- | :- | :- | :- |\n";
|
|
5
5
|
export declare const SLOT_TABLE_HEADER = "| Slot name | Default | Props | Fallback |\n| :- | :- | :- | :- |\n";
|
|
6
6
|
export declare const EVENT_TABLE_HEADER = "| Event name | Type | Detail | Description |\n| :- | :- | :- | :- |\n";
|
|
7
7
|
/**
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|