sveld 0.32.3 → 0.32.5
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 +352 -73
- package/lib/ComponentParser.d.ts +84 -45
- package/lib/ast-guards.d.ts +12 -0
- package/lib/brands.d.ts +11 -0
- package/lib/cli.d.ts +1 -6
- package/lib/create-exports.d.ts +3 -16
- package/lib/element-tag-map.d.ts +4 -13
- package/lib/get-svelte-entry.d.ts +4 -6
- package/lib/index.d.ts +2 -1
- package/lib/index.js +583 -583
- package/lib/parse-exports.d.ts +3 -10
- package/lib/path.d.ts +3 -6
- package/lib/plugin.d.ts +3 -3
- package/lib/resolve-alias.d.ts +3 -24
- package/lib/sveld.d.ts +2 -9
- package/lib/validate.d.ts +13 -0
- package/lib/writer/MarkdownWriterBase.d.ts +0 -4
- package/lib/writer/WriterMarkdown.d.ts +1 -10
- package/lib/writer/markdown-format-utils.d.ts +7 -49
- package/lib/writer/markdown-render-utils.d.ts +1 -8
- package/lib/writer/writer-markdown.d.ts +1 -9
- package/package.json +1 -1
package/lib/parse-exports.d.ts
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
+
import { type RelativeSourcePath } from "./brands";
|
|
1
2
|
export type ParsedExports = Record<string, {
|
|
2
|
-
source:
|
|
3
|
+
source: RelativeSourcePath;
|
|
3
4
|
default: boolean;
|
|
4
5
|
mixed?: boolean;
|
|
5
6
|
}>;
|
|
6
7
|
/**
|
|
7
|
-
* Parses
|
|
8
|
-
*
|
|
9
|
-
* Extracts all exports (default, named, and re-exports) and resolves
|
|
10
|
-
* their source paths, handling path aliases and directory imports.
|
|
11
|
-
* Caches parsed ASTs for performance.
|
|
12
|
-
*
|
|
13
|
-
* @param source - The source code to parse
|
|
14
|
-
* @param dir - The directory context for resolving relative paths and aliases
|
|
15
|
-
* @returns A map of export names to their source paths and metadata
|
|
8
|
+
* Parses exports from an entry file and resolves aliases against `dir`.
|
|
16
9
|
*
|
|
17
10
|
* @example
|
|
18
11
|
* ```ts
|
package/lib/path.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* @returns Path with normalized separators.
|
|
5
|
-
*/
|
|
6
|
-
export declare function normalizeSeparators(filePath: string): string;
|
|
1
|
+
import type { NormalizedPath } from "./brands";
|
|
2
|
+
/** Normalize path separators to `/`. */
|
|
3
|
+
export declare function normalizeSeparators(filePath: string): NormalizedPath;
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NormalizedPath } from "./brands";
|
|
1
2
|
import { type ParsedComponent } from "./ComponentParser";
|
|
2
3
|
import { type ParsedExports } from "./parse-exports";
|
|
3
4
|
import { type WriteJsonOptions } from "./writer/writer-json";
|
|
@@ -17,12 +18,11 @@ export interface PluginSveldOptions {
|
|
|
17
18
|
markdown?: boolean;
|
|
18
19
|
markdownOptions?: Partial<WriteMarkdownOptions>;
|
|
19
20
|
}
|
|
20
|
-
type ComponentModuleName = string;
|
|
21
21
|
export interface ComponentDocApi extends ParsedComponent {
|
|
22
|
-
filePath:
|
|
22
|
+
filePath: NormalizedPath;
|
|
23
23
|
moduleName: string;
|
|
24
24
|
}
|
|
25
|
-
export type ComponentDocs = Map<
|
|
25
|
+
export type ComponentDocs = Map<string, ComponentDocApi>;
|
|
26
26
|
interface SveldPlugin {
|
|
27
27
|
name: string;
|
|
28
28
|
apply?: "build" | "serve";
|
package/lib/resolve-alias.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Clears the TypeScript/JavaScript config cache.
|
|
3
|
-
*
|
|
4
|
-
* Useful for testing or when config files are modified during runtime.
|
|
5
|
-
* Forces re-reading of config files on next resolution.
|
|
6
|
-
*/
|
|
1
|
+
/** Clears cached tsconfig/jsconfig reads (tests and hot reload). */
|
|
7
2
|
export declare function clearConfigCache(): void;
|
|
8
3
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Uses TypeScript/JavaScript config path mappings to resolve aliases like
|
|
12
|
-
* `$lib/components` to actual file system paths. Handles wildcard patterns
|
|
13
|
-
* and baseUrl resolution.
|
|
14
|
-
*
|
|
15
|
-
* @param importPath - The import path that may contain an alias
|
|
16
|
-
* @param fromDir - The directory to resolve relative to (for finding config)
|
|
17
|
-
* @returns The absolute resolved path, or original path if resolution fails
|
|
4
|
+
* Resolve a tsconfig/jsconfig path alias to an absolute filesystem path.
|
|
18
5
|
*
|
|
19
6
|
* @example
|
|
20
7
|
* ```ts
|
|
@@ -28,15 +15,7 @@ export declare function clearConfigCache(): void;
|
|
|
28
15
|
*/
|
|
29
16
|
export declare function resolvePathAliasAbsolute(importPath: string, fromDir: string): string;
|
|
30
17
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* This is used for storing paths in the exports object for output generation.
|
|
34
|
-
* Unlike `resolvePathAliasAbsolute`, this returns a relative path suitable
|
|
35
|
-
* for use in generated export statements.
|
|
36
|
-
*
|
|
37
|
-
* @param importPath - The import path that may contain an alias
|
|
38
|
-
* @param fromDir - The directory to resolve relative to
|
|
39
|
-
* @returns A relative path (prefixed with ./ if needed), or original path if resolution fails
|
|
18
|
+
* Resolve a path alias to a path relative to `fromDir` for generated exports.
|
|
40
19
|
*
|
|
41
20
|
* @example
|
|
42
21
|
* ```ts
|
package/lib/sveld.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginSveldOptions } from "./plugin";
|
|
2
|
-
interface SveldOptions extends PluginSveldOptions {
|
|
2
|
+
interface SveldOptions extends Omit<PluginSveldOptions, "entry"> {
|
|
3
3
|
/**
|
|
4
4
|
* Specify the input to the uncompiled Svelte source.
|
|
5
5
|
* If no value is provided, `sveld` will attempt to infer
|
|
@@ -8,14 +8,7 @@ interface SveldOptions extends PluginSveldOptions {
|
|
|
8
8
|
input?: string;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Generates component documentation from Svelte source files and writes
|
|
14
|
-
* output files based on the provided options. Can be used as a library
|
|
15
|
-
* in addition to the CLI interface.
|
|
16
|
-
*
|
|
17
|
-
* @param opts - Options for generating documentation
|
|
18
|
-
* @returns A promise that resolves when documentation generation is complete
|
|
11
|
+
* Programmatic entry point for sveld.
|
|
19
12
|
*
|
|
20
13
|
* @example
|
|
21
14
|
* ```ts
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
export interface ParsedPackageJson {
|
|
3
|
+
svelte?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function parsePackageJson(value: unknown): ParsedPackageJson;
|
|
6
|
+
export interface ParsedTsConfig {
|
|
7
|
+
compilerOptions?: {
|
|
8
|
+
baseUrl?: string;
|
|
9
|
+
paths?: Record<string, string[]>;
|
|
10
|
+
};
|
|
11
|
+
extends?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseTsConfig(value: unknown): ParsedTsConfig;
|
|
@@ -13,10 +13,6 @@ export interface MarkdownWriterBase {
|
|
|
13
13
|
end(): string;
|
|
14
14
|
get source(): string;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Base class containing shared markdown writing logic.
|
|
18
|
-
* This can be extended or used via composition.
|
|
19
|
-
*/
|
|
20
16
|
export declare class MarkdownWriterBaseImpl implements MarkdownWriterBase {
|
|
21
17
|
sourceParts: string[];
|
|
22
18
|
hasToC: boolean;
|
|
@@ -6,11 +6,7 @@ interface MarkdownOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export type { AppendType };
|
|
8
8
|
/**
|
|
9
|
-
* Markdown writer
|
|
10
|
-
*
|
|
11
|
-
* Combines file writing capabilities from Writer with markdown
|
|
12
|
-
* generation capabilities from MarkdownWriterBaseImpl. Supports
|
|
13
|
-
* callbacks for monitoring document construction.
|
|
9
|
+
* Markdown writer with Prettier formatting and optional append callbacks.
|
|
14
10
|
*
|
|
15
11
|
* @example
|
|
16
12
|
* ```ts
|
|
@@ -26,11 +22,6 @@ export type { AppendType };
|
|
|
26
22
|
export default class WriterMarkdown extends Writer {
|
|
27
23
|
onAppend?: OnAppend;
|
|
28
24
|
private markdownBase;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a new WriterMarkdown instance.
|
|
31
|
-
*
|
|
32
|
-
* @param options - Markdown writer options including append callback
|
|
33
|
-
*/
|
|
34
25
|
constructor(options: MarkdownOptions);
|
|
35
26
|
get source(): string;
|
|
36
27
|
get hasToC(): boolean;
|
|
@@ -5,13 +5,7 @@ export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reacti
|
|
|
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
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Escapes pipe characters to prevent breaking markdown table syntax
|
|
11
|
-
* and wraps the type in a code block.
|
|
12
|
-
*
|
|
13
|
-
* @param type - The type string to format
|
|
14
|
-
* @returns Formatted type string or MD_TYPE_UNDEFINED if type is undefined
|
|
8
|
+
* Escape `|` and wrap a prop type for markdown table cells.
|
|
15
9
|
*
|
|
16
10
|
* @example
|
|
17
11
|
* ```ts
|
|
@@ -21,13 +15,7 @@ export declare const EVENT_TABLE_HEADER = "| Event name | Type | Detail | Descri
|
|
|
21
15
|
*/
|
|
22
16
|
export declare function formatPropType(type?: string): string;
|
|
23
17
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Converts `<` to `<` and `>` to `>` to prevent HTML injection
|
|
27
|
-
* and ensure proper rendering in markdown.
|
|
28
|
-
*
|
|
29
|
-
* @param text - The text to escape
|
|
30
|
-
* @returns The escaped text
|
|
18
|
+
* Escape `<` and `>` for markdown output.
|
|
31
19
|
*
|
|
32
20
|
* @example
|
|
33
21
|
* ```ts
|
|
@@ -36,12 +24,7 @@ export declare function formatPropType(type?: string): string;
|
|
|
36
24
|
*/
|
|
37
25
|
export declare function escapeHtml(text: string): string;
|
|
38
26
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* Escapes backticks and pipe characters, and wraps the value in a code block.
|
|
42
|
-
*
|
|
43
|
-
* @param value - The default value string to format
|
|
44
|
-
* @returns Formatted value string or MD_TYPE_UNDEFINED if value is undefined
|
|
27
|
+
* Format a default value for markdown table cells.
|
|
45
28
|
*
|
|
46
29
|
* @example
|
|
47
30
|
* ```ts
|
|
@@ -51,13 +34,7 @@ export declare function escapeHtml(text: string): string;
|
|
|
51
34
|
*/
|
|
52
35
|
export declare function formatPropValue(value: string | undefined): string;
|
|
53
36
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* Escapes HTML characters and converts newlines to `<br />` tags
|
|
57
|
-
* for proper rendering in markdown tables.
|
|
58
|
-
*
|
|
59
|
-
* @param description - The description string to format
|
|
60
|
-
* @returns Formatted description or MD_TYPE_UNDEFINED if description is empty
|
|
37
|
+
* Format a prop description; newlines become `<br />`.
|
|
61
38
|
*
|
|
62
39
|
* @example
|
|
63
40
|
* ```ts
|
|
@@ -67,14 +44,7 @@ export declare function formatPropValue(value: string | undefined): string;
|
|
|
67
44
|
*/
|
|
68
45
|
export declare function formatPropDescription(description: string | undefined): string;
|
|
69
46
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* Converts TypeScript type definitions to a single-line format
|
|
73
|
-
* and wraps them in a code block. Returns MD_TYPE_UNDEFINED for
|
|
74
|
-
* empty or undefined props.
|
|
75
|
-
*
|
|
76
|
-
* @param props - The slot props type string
|
|
77
|
-
* @returns Formatted props string or MD_TYPE_UNDEFINED
|
|
47
|
+
* Format slot props for markdown table cells.
|
|
78
48
|
*
|
|
79
49
|
* @example
|
|
80
50
|
* ```ts
|
|
@@ -84,13 +54,7 @@ export declare function formatPropDescription(description: string | undefined):
|
|
|
84
54
|
*/
|
|
85
55
|
export declare function formatSlotProps(props?: string): string;
|
|
86
56
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* Escapes HTML and converts newlines to `<br />` tags, then wraps
|
|
90
|
-
* in a code block.
|
|
91
|
-
*
|
|
92
|
-
* @param fallback - The fallback content string
|
|
93
|
-
* @returns Formatted fallback string or MD_TYPE_UNDEFINED if undefined
|
|
57
|
+
* Format slot fallback content for markdown table cells.
|
|
94
58
|
*
|
|
95
59
|
* @example
|
|
96
60
|
* ```ts
|
|
@@ -100,13 +64,7 @@ export declare function formatSlotProps(props?: string): string;
|
|
|
100
64
|
*/
|
|
101
65
|
export declare function formatSlotFallback(fallback?: string): string;
|
|
102
66
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* Converts the detail type to a single-line format and wraps it
|
|
106
|
-
* in a code block.
|
|
107
|
-
*
|
|
108
|
-
* @param detail - The event detail type string
|
|
109
|
-
* @returns Formatted detail string or MD_TYPE_UNDEFINED if undefined
|
|
67
|
+
* Format event detail types for markdown table cells.
|
|
110
68
|
*
|
|
111
69
|
* @example
|
|
112
70
|
* ```ts
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import type { ComponentDocs } from "../plugin";
|
|
2
2
|
import type { AppendType } from "./MarkdownWriterBase";
|
|
3
|
-
/**
|
|
4
|
-
* Interface for markdown documents that can be used for rendering.
|
|
5
|
-
* Only requires the methods we actually use, not the full implementation.
|
|
6
|
-
*/
|
|
3
|
+
/** Minimal markdown writer surface used by JSON and browser renderers. */
|
|
7
4
|
interface MarkdownDocument {
|
|
8
5
|
append(type: AppendType, raw?: string): MarkdownDocument;
|
|
9
6
|
tableOfContents(): MarkdownDocument;
|
|
10
7
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Renders component documentation to a markdown document.
|
|
13
|
-
* This shared function is used by both writeMarkdown and writeMarkdownCore.
|
|
14
|
-
*/
|
|
15
8
|
export declare function renderComponentsToMarkdown(document: MarkdownDocument, components: ComponentDocs): void;
|
|
16
9
|
export {};
|
|
@@ -6,15 +6,7 @@ export interface WriteMarkdownOptions {
|
|
|
6
6
|
onAppend?: (type: AppendType, document: WriterMarkdown, components: ComponentDocs) => void;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Renders all components to markdown format and optionally writes
|
|
12
|
-
* the result to a file. Returns the markdown string regardless of
|
|
13
|
-
* whether it was written to disk.
|
|
14
|
-
*
|
|
15
|
-
* @param components - Map of component documentation to render
|
|
16
|
-
* @param options - Write options including output file and callbacks
|
|
17
|
-
* @returns A promise that resolves to the generated markdown string
|
|
9
|
+
* Renders component docs to markdown and optionally writes `outFile`.
|
|
18
10
|
*
|
|
19
11
|
* @example
|
|
20
12
|
* ```ts
|