sveld 0.35.0 → 0.35.2
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 +46 -4
- package/cli.js +1 -1
- package/lib/ComponentParser.d.ts +164 -398
- package/lib/ast-guards.d.ts +2 -0
- package/lib/browser.d.ts +39 -0
- package/lib/browser.js +268 -0
- package/lib/bundle.d.ts +9 -4
- package/lib/chunk-1p4ka68s.js +2 -0
- package/lib/chunk-72hx9e9w.js +20 -0
- package/lib/chunk-7qz0hzgw.js +217 -0
- package/lib/chunk-8xw75w8t.js +10 -0
- package/lib/chunk-cxrw7gzr.js +2 -0
- package/lib/chunk-jdnsv86e.js +1 -0
- package/lib/chunk-pmj8c3yv.js +6 -0
- package/lib/chunk-s9mzxa4y.js +1 -0
- package/lib/chunk-v4q9vw0y.js +62 -0
- package/lib/chunk-xkrgedm4.js +4 -0
- package/lib/chunk-zva3xjwa.js +13 -0
- package/lib/cli-entry.d.ts +12 -0
- package/lib/cli-entry.js +1 -0
- package/lib/get-svelte-entry.d.ts +0 -1
- package/lib/index.js +1 -484
- package/lib/parse-cache.d.ts +1 -1
- package/lib/parse-entry-exports.d.ts +2 -2
- package/lib/parse-exports.d.ts +5 -1
- package/lib/parsed-component-metadata.d.ts +13 -0
- package/lib/parser/bindings.d.ts +0 -2
- package/lib/parser/context.d.ts +13 -51
- package/lib/parser/events.d.ts +0 -2
- package/lib/parser/jsdoc.d.ts +0 -4
- package/lib/parser/prop-shared.d.ts +84 -0
- package/lib/parser/props.d.ts +6 -2
- package/lib/parser/rest-props.d.ts +0 -2
- package/lib/parser/runes-detection.d.ts +13 -0
- package/lib/parser/scopes.d.ts +23 -7
- package/lib/parser/slots.d.ts +1 -6
- package/lib/parser/source-position.d.ts +0 -4
- package/lib/parser/type-resolution.d.ts +4 -14
- package/lib/parser/typescript-casts.d.ts +1 -0
- package/lib/parser/utils.d.ts +1 -0
- package/lib/parser/variable-jsdoc.d.ts +12 -0
- package/lib/parser-stack.d.ts +20 -0
- package/lib/path.d.ts +0 -1
- package/lib/resolve-types.d.ts +1 -1
- package/lib/svelte-parse.d.ts +4 -0
- package/lib/svelte-version.d.ts +1 -0
- package/lib/writer/Writer.d.ts +7 -29
- package/lib/writer/WriterMarkdown.d.ts +0 -2
- package/lib/writer/markdown-format-utils.d.ts +0 -84
- package/lib/writer/writer-json.d.ts +2 -12
- package/lib/writer/writer-markdown.d.ts +0 -2
- package/lib/writer/writer-ts-definitions-core.d.ts +1 -9
- package/lib/writer/writer-ts-definitions.d.ts +1 -28
- package/package.json +6 -1
|
@@ -6,99 +6,15 @@ export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reacti
|
|
|
6
6
|
export declare const SLOT_TABLE_HEADER = "| Slot name | Default | Props | Fallback | Description |\n| :- | :- | :- | :- | :- |\n";
|
|
7
7
|
export declare const EVENT_TABLE_HEADER = "| Event name | Type | Detail | Description |\n| :- | :- | :- | :- |\n";
|
|
8
8
|
export declare const EXPORT_TABLE_HEADER = "| Name | Kind | Type | Description |\n| :- | :- | :- | :- |\n";
|
|
9
|
-
/**
|
|
10
|
-
* Escape `|` and wrap a prop type for markdown table cells.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* formatPropType("string | number") // Returns: "<code>string | number</code>"
|
|
15
|
-
* formatPropType(undefined) // Returns: "--"
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
9
|
export declare function formatPropType(type?: string): string;
|
|
19
|
-
/**
|
|
20
|
-
* Escape `<` and `>` for markdown output.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* escapeHtml("<div>") // Returns: "<div>"
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
10
|
export declare function escapeHtml(text: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Format a default value for markdown table cells.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```ts
|
|
33
|
-
* formatPropValue("'hello'") // Returns: "<code>'hello'</code>"
|
|
34
|
-
* formatPropValue("`test`") // Returns: "<code>\\`test\\`</code>"
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
11
|
export declare function formatPropValue(value: string | undefined): string;
|
|
38
|
-
/**
|
|
39
|
-
* Strike through deprecated prop, slot, and event names in markdown tables.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* formatNameWithDeprecation("size", "use width")
|
|
44
|
-
* // Returns: "<s>size</s><br />**Deprecated**: use width"
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
12
|
export declare function formatNameWithDeprecation(name: string, deprecated: DeprecatedValue | undefined): string;
|
|
48
|
-
/**
|
|
49
|
-
* Format a prop description; newlines become `<br />`.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* formatPropDescription("Line 1\nLine 2")
|
|
54
|
-
* // Returns: "Line 1<br />Line 2"
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
13
|
export declare function formatPropDescription(description: string | undefined): string;
|
|
58
|
-
/**
|
|
59
|
-
* Format slot props for markdown table cells.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* formatSlotProps("{ title: string }") // Returns: "<code>{ title: string }</code>"
|
|
64
|
-
* formatSlotProps("{}") // Returns: "--"
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
14
|
export declare function formatSlotProps(props?: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* Format slot fallback content for markdown table cells.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* formatSlotFallback("<p>Default</p>")
|
|
74
|
-
* // Returns: "<code><p>Default</p></code>"
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
15
|
export declare function formatSlotFallback(fallback?: string): string;
|
|
78
|
-
/**
|
|
79
|
-
* Format a slot/snippet description plus pass-through JSDoc tags for markdown
|
|
80
|
-
* table cells. Newlines become `<br />` and `<`, `>`, `|` are escaped so the
|
|
81
|
-
* content stays inside a single table cell.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```ts
|
|
85
|
-
* formatSlotDescription("Header content.", [{ name: "since", body: "1.0.0" }])
|
|
86
|
-
* // Returns: "Header content.<br />@since 1.0.0"
|
|
87
|
-
* formatSlotDescription(undefined, [])
|
|
88
|
-
* // Returns: "--"
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
16
|
export declare function formatSlotDescription(description?: string, tags?: Array<{
|
|
92
17
|
name: string;
|
|
93
18
|
body: string;
|
|
94
19
|
}>): string;
|
|
95
|
-
/**
|
|
96
|
-
* Format event detail types for markdown table cells.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* formatEventDetail("{ value: string }")
|
|
101
|
-
* // Returns: "<code>{ value: string }</code>"
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
20
|
export declare function formatEventDetail(detail?: string): string;
|
|
@@ -9,25 +9,15 @@ export interface WriteJsonOptions {
|
|
|
9
9
|
entryExports?: EntryExports;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Writes component documentation to JSON format.
|
|
13
|
-
*
|
|
14
|
-
* Can write either:
|
|
15
|
-
* - Individual JSON files per component (when `outDir` is specified)
|
|
16
|
-
* - A single combined JSON file (when only `outFile` is specified)
|
|
17
|
-
*
|
|
18
|
-
* @param components - Map of component documentation to write
|
|
19
|
-
* @param options - Write options including output directory or file
|
|
20
|
-
* @returns A promise that resolves when all files have been written
|
|
21
|
-
*
|
|
22
12
|
* @example
|
|
23
13
|
* ```ts
|
|
24
|
-
* //
|
|
14
|
+
* // Per-component files:
|
|
25
15
|
* await writeJson(components, {
|
|
26
16
|
* inputDir: "./src",
|
|
27
17
|
* outDir: "./dist"
|
|
28
18
|
* });
|
|
29
19
|
*
|
|
30
|
-
* //
|
|
20
|
+
* // Single combined file:
|
|
31
21
|
* await writeJson(components, {
|
|
32
22
|
* inputDir: "./src",
|
|
33
23
|
* outFile: "components.api.json"
|
|
@@ -9,8 +9,6 @@ export interface WriteMarkdownOptions {
|
|
|
9
9
|
onAppend?: (type: AppendType, document: WriterMarkdown, components: ComponentDocs) => void;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Renders component docs to markdown and optionally writes `outFile`.
|
|
13
|
-
*
|
|
14
12
|
* @example
|
|
15
13
|
* ```ts
|
|
16
14
|
* const markdown = await writeMarkdown(components, {
|
|
@@ -2,23 +2,15 @@ import type { ComponentDocApi } from "../plugin";
|
|
|
2
2
|
export declare function formatTsProps(props?: string): string;
|
|
3
3
|
export declare function getTypeDefs(def: Pick<ComponentDocApi, "typedefs">): string;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Creates exported type definitions for each context, including generic
|
|
8
|
-
* type parameters when contexts reference component generics. Handles
|
|
9
|
-
* empty context objects by using `Record<string, never>`.
|
|
5
|
+
* Exported context type definitions for a component.
|
|
10
6
|
*
|
|
11
7
|
* @param def - Component documentation containing contexts and generics
|
|
12
8
|
* @returns TypeScript type definition string, or empty string if no contexts
|
|
13
9
|
*
|
|
14
10
|
* @example
|
|
15
11
|
* ```ts
|
|
16
|
-
* // Input: contexts with generic reference
|
|
17
|
-
* // Output:
|
|
18
12
|
* // export type ModalContext<T> = {
|
|
19
|
-
* // /** Open the modal *\/
|
|
20
13
|
* // open: () => void;
|
|
21
|
-
* // /** Close the modal *\/
|
|
22
14
|
* // close: () => void;
|
|
23
15
|
* // };
|
|
24
16
|
* ```
|
|
@@ -12,14 +12,6 @@ import { type WriteTsDefinitionOptions } from "./writer-ts-definitions-core";
|
|
|
12
12
|
*/
|
|
13
13
|
export { formatTsProps, getContextDefs, getTypeDefs, type WriteTsDefinitionOptions, writeTsDefinition, } from "./writer-ts-definitions-core";
|
|
14
14
|
/**
|
|
15
|
-
* Options for writing TypeScript definition files.
|
|
16
|
-
*
|
|
17
|
-
* @property outDir - The output directory where `.d.ts` files will be written
|
|
18
|
-
* @property inputDir - The input directory containing source components
|
|
19
|
-
* @property preamble - Text to prepend to the main `index.d.ts` file
|
|
20
|
-
* @property exports - Parsed export information for generating the index file
|
|
21
|
-
* @property format - `"class"` (default) or `"component"`; see {@link WriteTsDefinitionOptions}
|
|
22
|
-
*
|
|
23
15
|
* @example
|
|
24
16
|
* ```ts
|
|
25
17
|
* const options: WriteTsDefinitionsOptions = {
|
|
@@ -37,34 +29,15 @@ export interface WriteTsDefinitionsOptions extends WriteTsDefinitionOptions {
|
|
|
37
29
|
exports: ParsedExports;
|
|
38
30
|
}
|
|
39
31
|
/**
|
|
40
|
-
* Writes TypeScript definition files for all parsed Svelte components.
|
|
41
|
-
*
|
|
42
|
-
* Generates individual `.d.ts` files for each component and a main `index.d.ts`
|
|
43
|
-
* file that exports all components. Uses a TypeScript writer to handle file
|
|
44
|
-
* I/O operations efficiently.
|
|
45
|
-
*
|
|
46
|
-
* @param components - Map of component module names to their parsed documentation
|
|
47
|
-
* @param options - Configuration options for writing definitions
|
|
48
|
-
* @returns A promise that resolves when all files have been written
|
|
49
|
-
*
|
|
50
32
|
* @example
|
|
51
33
|
* ```ts
|
|
52
|
-
* const components = new Map([
|
|
53
|
-
* ["Button", { filePath: "Button.svelte", props: [...], ... }],
|
|
54
|
-
* ["Input", { filePath: "Input.svelte", props: [...], ... }]
|
|
55
|
-
* ]);
|
|
56
|
-
*
|
|
57
34
|
* await writeTsDefinitions(components, {
|
|
58
35
|
* outDir: "./dist",
|
|
59
36
|
* inputDir: "./src",
|
|
60
37
|
* preamble: "// Generated\n",
|
|
61
38
|
* exports: { ... }
|
|
62
39
|
* });
|
|
63
|
-
*
|
|
64
|
-
* // Creates:
|
|
65
|
-
* // - dist/Button.d.ts
|
|
66
|
-
* // - dist/Input.d.ts
|
|
67
|
-
* // - dist/index.d.ts
|
|
40
|
+
* // Creates dist/Button.d.ts, dist/Input.d.ts, dist/index.d.ts
|
|
68
41
|
* ```
|
|
69
42
|
*/
|
|
70
43
|
export default function writeTsDefinitions(components: ComponentDocs, options: WriteTsDefinitionsOptions): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sveld",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Generate TypeScript definitions and component documentation for your Svelte components.",
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
"types": "./lib/index.d.ts",
|
|
12
12
|
"import": "./lib/index.js",
|
|
13
13
|
"default": "./lib/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./browser": {
|
|
16
|
+
"types": "./lib/browser.d.ts",
|
|
17
|
+
"import": "./lib/browser.js",
|
|
18
|
+
"default": "./lib/browser.js"
|
|
14
19
|
}
|
|
15
20
|
},
|
|
16
21
|
"bin": {
|