sveld 0.35.1 → 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 -10
- package/cli.js +1 -1
- package/lib/browser.d.ts +660 -39
- package/lib/browser.js +205 -227
- package/lib/chunk-0fqdg2xa.js +20 -0
- package/lib/chunk-2vwf7nck.js +1 -0
- package/lib/chunk-8myyzjb1.js +4 -0
- package/lib/chunk-as5hgj7e.js +62 -0
- package/lib/chunk-denfbw92.js +13 -0
- package/lib/chunk-h1r040pg.js +6 -0
- package/lib/chunk-m538qnhp.js +230 -0
- package/lib/chunk-r4rrncmd.js +1 -0
- package/lib/chunk-t9d5k3p7.js +2 -0
- package/lib/chunk-tmj7vnjr.js +10 -0
- package/lib/chunk-xryt7ad2.js +3 -0
- package/lib/cli-entry.js +1 -0
- package/lib/index.d.ts +767 -10
- package/lib/index.js +1 -343
- package/package.json +1 -1
- package/lib/ComponentParser.d.ts +0 -822
- package/lib/ast-guards.d.ts +0 -18
- package/lib/brands.d.ts +0 -11
- package/lib/bundle.d.ts +0 -176
- package/lib/check.d.ts +0 -43
- 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 -4
- 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/parser/bindings.d.ts +0 -6
- package/lib/parser/context.d.ts +0 -114
- package/lib/parser/contexts.d.ts +0 -19
- package/lib/parser/diagnostics.d.ts +0 -8
- package/lib/parser/events.d.ts +0 -23
- package/lib/parser/generics.d.ts +0 -24
- package/lib/parser/jsdoc.d.ts +0 -59
- package/lib/parser/props.d.ts +0 -73
- package/lib/parser/rest-props.d.ts +0 -6
- package/lib/parser/runes-detection.d.ts +0 -16
- package/lib/parser/runes-props.d.ts +0 -18
- package/lib/parser/scopes.d.ts +0 -58
- package/lib/parser/slots.d.ts +0 -29
- package/lib/parser/source-position.d.ts +0 -30
- package/lib/parser/type-resolution.d.ts +0 -32
- package/lib/parser/typescript-casts.d.ts +0 -2
- package/lib/path.d.ts +0 -3
- 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/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 -53
- package/lib/writer/WriterMarkdown.d.ts +0 -33
- 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 -104
- 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 -37
- package/lib/writer/writer-markdown-core.d.ts +0 -32
- package/lib/writer/writer-markdown.d.ts +0 -25
- package/lib/writer/writer-ts-definitions-core.d.ts +0 -38
- package/lib/writer/writer-ts-definitions.d.ts +0 -70
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { EntryExports } from "../parse-entry-exports";
|
|
2
|
-
import type { ComponentDocs } from "../plugin";
|
|
3
|
-
export interface WriteJsonOptions {
|
|
4
|
-
input: string;
|
|
5
|
-
inputDir: string;
|
|
6
|
-
outFile: string;
|
|
7
|
-
outDir?: string;
|
|
8
|
-
/** Entry-barrel exports when `documentExports` is on. */
|
|
9
|
-
entryExports?: EntryExports;
|
|
10
|
-
}
|
|
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
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* // Write individual files:
|
|
25
|
-
* await writeJson(components, {
|
|
26
|
-
* inputDir: "./src",
|
|
27
|
-
* outDir: "./dist"
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Write single file:
|
|
31
|
-
* await writeJson(components, {
|
|
32
|
-
* inputDir: "./src",
|
|
33
|
-
* outFile: "components.api.json"
|
|
34
|
-
* });
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export default function writeJson(components: ComponentDocs, options: WriteJsonOptions): Promise<void>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ComponentDocs } from "../plugin";
|
|
2
|
-
import { type AppendType, MarkdownWriterBaseImpl } from "./MarkdownWriterBase";
|
|
3
|
-
export type { AppendType };
|
|
4
|
-
type OnAppend = (type: AppendType, document: BrowserWriterMarkdown) => void;
|
|
5
|
-
interface MarkdownOptions {
|
|
6
|
-
onAppend?: OnAppend;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Browser-compatible WriterMarkdown that doesn't extend Writer.
|
|
10
|
-
*
|
|
11
|
-
* This class is designed for browser environments where file system operations
|
|
12
|
-
* are not available. It extends MarkdownWriterBaseImpl directly instead of
|
|
13
|
-
* Writer to avoid Node.js dependencies.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* const writer = new BrowserWriterMarkdown({
|
|
18
|
-
* onAppend: (type, doc) => {
|
|
19
|
-
* console.log(`Appended ${type} to document`);
|
|
20
|
-
* }
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare class BrowserWriterMarkdown extends MarkdownWriterBaseImpl {
|
|
25
|
-
onAppend?: OnAppend;
|
|
26
|
-
constructor(options: MarkdownOptions);
|
|
27
|
-
append(type: AppendType, raw?: string): this;
|
|
28
|
-
}
|
|
29
|
-
export interface WriteMarkdownCoreOptions {
|
|
30
|
-
onAppend?: (type: AppendType, document: BrowserWriterMarkdown, components: ComponentDocs) => void;
|
|
31
|
-
}
|
|
32
|
-
export declare function writeMarkdownCore(components: ComponentDocs, options?: WriteMarkdownCoreOptions): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { EntryExports } from "../parse-entry-exports";
|
|
2
|
-
import type { ComponentDocs } from "../plugin";
|
|
3
|
-
import WriterMarkdown, { type AppendType } from "./WriterMarkdown";
|
|
4
|
-
export interface WriteMarkdownOptions {
|
|
5
|
-
write?: boolean;
|
|
6
|
-
outFile: string;
|
|
7
|
-
/** Entry-barrel exports when `documentExports` is on. */
|
|
8
|
-
entryExports?: EntryExports;
|
|
9
|
-
onAppend?: (type: AppendType, document: WriterMarkdown, components: ComponentDocs) => void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Renders component docs to markdown and optionally writes `outFile`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* const markdown = await writeMarkdown(components, {
|
|
17
|
-
* outFile: "COMPONENTS.md",
|
|
18
|
-
* write: true,
|
|
19
|
-
* onAppend: (type, doc) => {
|
|
20
|
-
* console.log(`Appended ${type}`);
|
|
21
|
-
* }
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export default function writeMarkdown(components: ComponentDocs, options: WriteMarkdownOptions): Promise<string>;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ComponentDocApi } from "../plugin";
|
|
2
|
-
export declare function formatTsProps(props?: string): string;
|
|
3
|
-
export declare function getTypeDefs(def: Pick<ComponentDocApi, "typedefs">): string;
|
|
4
|
-
/**
|
|
5
|
-
* Generates TypeScript type definitions for component contexts.
|
|
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>`.
|
|
10
|
-
*
|
|
11
|
-
* @param def - Component documentation containing contexts and generics
|
|
12
|
-
* @returns TypeScript type definition string, or empty string if no contexts
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // Input: contexts with generic reference
|
|
17
|
-
* // Output:
|
|
18
|
-
* // export type ModalContext<T> = {
|
|
19
|
-
* // /** Open the modal *\/
|
|
20
|
-
* // open: () => void;
|
|
21
|
-
* // /** Close the modal *\/
|
|
22
|
-
* // close: () => void;
|
|
23
|
-
* // };
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare function getContextDefs(def: Pick<ComponentDocApi, "contexts" | "generics">): string;
|
|
27
|
-
export interface WriteTsDefinitionOptions {
|
|
28
|
-
/**
|
|
29
|
-
* `"class"` (default) extends the deprecated `SvelteComponentTyped`.
|
|
30
|
-
* `"component"` emits `declare const X: Component<Props, Exports, Bindings>`
|
|
31
|
-
* instead, for Svelte 5+ consumers. Generic components get a per-component
|
|
32
|
-
* interface with a generic call signature instead of `Component<...>`
|
|
33
|
-
* directly, since a `declare const` can't itself carry a generic type
|
|
34
|
-
* parameter (see `genGenericComponentDeclaration`).
|
|
35
|
-
*/
|
|
36
|
-
format?: "class" | "component";
|
|
37
|
-
}
|
|
38
|
-
export declare function writeTsDefinition(component: ComponentDocApi, options?: WriteTsDefinitionOptions): string;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { ParsedExports } from "../parse-exports";
|
|
2
|
-
import type { ComponentDocs } from "../plugin";
|
|
3
|
-
import { type WriteTsDefinitionOptions } from "./writer-ts-definitions-core";
|
|
4
|
-
/**
|
|
5
|
-
* Re-export browser-compatible functions from core module.
|
|
6
|
-
*
|
|
7
|
-
* These functions are exported from the core TypeScript definitions writer
|
|
8
|
-
* to provide a browser-compatible API surface. The core module contains the
|
|
9
|
-
* actual implementation logic.
|
|
10
|
-
*
|
|
11
|
-
* @see {@link ./writer-ts-definitions-core} for the core implementation
|
|
12
|
-
*/
|
|
13
|
-
export { formatTsProps, getContextDefs, getTypeDefs, type WriteTsDefinitionOptions, writeTsDefinition, } from "./writer-ts-definitions-core";
|
|
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
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const options: WriteTsDefinitionsOptions = {
|
|
26
|
-
* outDir: "./dist",
|
|
27
|
-
* inputDir: "./src",
|
|
28
|
-
* preamble: "// Generated by sveld\n",
|
|
29
|
-
* exports: { ... }
|
|
30
|
-
* };
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export interface WriteTsDefinitionsOptions extends WriteTsDefinitionOptions {
|
|
34
|
-
outDir: string;
|
|
35
|
-
inputDir: string;
|
|
36
|
-
preamble: string;
|
|
37
|
-
exports: ParsedExports;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
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
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* const components = new Map([
|
|
53
|
-
* ["Button", { filePath: "Button.svelte", props: [...], ... }],
|
|
54
|
-
* ["Input", { filePath: "Input.svelte", props: [...], ... }]
|
|
55
|
-
* ]);
|
|
56
|
-
*
|
|
57
|
-
* await writeTsDefinitions(components, {
|
|
58
|
-
* outDir: "./dist",
|
|
59
|
-
* inputDir: "./src",
|
|
60
|
-
* preamble: "// Generated\n",
|
|
61
|
-
* exports: { ... }
|
|
62
|
-
* });
|
|
63
|
-
*
|
|
64
|
-
* // Creates:
|
|
65
|
-
* // - dist/Button.d.ts
|
|
66
|
-
* // - dist/Input.d.ts
|
|
67
|
-
* // - dist/index.d.ts
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export default function writeTsDefinitions(components: ComponentDocs, options: WriteTsDefinitionsOptions): Promise<void>;
|