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.
Files changed (74) hide show
  1. package/README.md +33 -10
  2. package/cli.js +1 -1
  3. package/lib/browser.d.ts +660 -39
  4. package/lib/browser.js +205 -227
  5. package/lib/chunk-0fqdg2xa.js +20 -0
  6. package/lib/chunk-2vwf7nck.js +1 -0
  7. package/lib/chunk-8myyzjb1.js +4 -0
  8. package/lib/chunk-as5hgj7e.js +62 -0
  9. package/lib/chunk-denfbw92.js +13 -0
  10. package/lib/chunk-h1r040pg.js +6 -0
  11. package/lib/chunk-m538qnhp.js +230 -0
  12. package/lib/chunk-r4rrncmd.js +1 -0
  13. package/lib/chunk-t9d5k3p7.js +2 -0
  14. package/lib/chunk-tmj7vnjr.js +10 -0
  15. package/lib/chunk-xryt7ad2.js +3 -0
  16. package/lib/cli-entry.js +1 -0
  17. package/lib/index.d.ts +767 -10
  18. package/lib/index.js +1 -343
  19. package/package.json +1 -1
  20. package/lib/ComponentParser.d.ts +0 -822
  21. package/lib/ast-guards.d.ts +0 -18
  22. package/lib/brands.d.ts +0 -11
  23. package/lib/bundle.d.ts +0 -176
  24. package/lib/check.d.ts +0 -43
  25. package/lib/cli.d.ts +0 -28
  26. package/lib/create-exports.d.ts +0 -32
  27. package/lib/dependency-graph.d.ts +0 -20
  28. package/lib/diagnostics.d.ts +0 -34
  29. package/lib/element-tag-map.d.ts +0 -146
  30. package/lib/example-check.d.ts +0 -24
  31. package/lib/get-svelte-entry.d.ts +0 -4
  32. package/lib/load-config.d.ts +0 -62
  33. package/lib/parse-cache.d.ts +0 -28
  34. package/lib/parse-entry-exports.d.ts +0 -30
  35. package/lib/parse-exports.d.ts +0 -25
  36. package/lib/parser/bindings.d.ts +0 -6
  37. package/lib/parser/context.d.ts +0 -114
  38. package/lib/parser/contexts.d.ts +0 -19
  39. package/lib/parser/diagnostics.d.ts +0 -8
  40. package/lib/parser/events.d.ts +0 -23
  41. package/lib/parser/generics.d.ts +0 -24
  42. package/lib/parser/jsdoc.d.ts +0 -59
  43. package/lib/parser/props.d.ts +0 -73
  44. package/lib/parser/rest-props.d.ts +0 -6
  45. package/lib/parser/runes-detection.d.ts +0 -16
  46. package/lib/parser/runes-props.d.ts +0 -18
  47. package/lib/parser/scopes.d.ts +0 -58
  48. package/lib/parser/slots.d.ts +0 -29
  49. package/lib/parser/source-position.d.ts +0 -30
  50. package/lib/parser/type-resolution.d.ts +0 -32
  51. package/lib/parser/typescript-casts.d.ts +0 -2
  52. package/lib/path.d.ts +0 -3
  53. package/lib/plugin.d.ts +0 -85
  54. package/lib/resolve-alias.d.ts +0 -30
  55. package/lib/resolve-types.d.ts +0 -52
  56. package/lib/sveld.d.ts +0 -29
  57. package/lib/validate.d.ts +0 -13
  58. package/lib/watch.d.ts +0 -34
  59. package/lib/writer/MarkdownWriterBase.d.ts +0 -26
  60. package/lib/writer/Writer.d.ts +0 -53
  61. package/lib/writer/WriterMarkdown.d.ts +0 -33
  62. package/lib/writer/built-in-writers.d.ts +0 -1
  63. package/lib/writer/document-model.d.ts +0 -34
  64. package/lib/writer/format-generated-ts.d.ts +0 -8
  65. package/lib/writer/markdown-format-utils.d.ts +0 -104
  66. package/lib/writer/markdown-render-utils.d.ts +0 -10
  67. package/lib/writer/registry.d.ts +0 -17
  68. package/lib/writer/writer-custom-elements-core.d.ts +0 -86
  69. package/lib/writer/writer-custom-elements.d.ts +0 -15
  70. package/lib/writer/writer-json.d.ts +0 -37
  71. package/lib/writer/writer-markdown-core.d.ts +0 -32
  72. package/lib/writer/writer-markdown.d.ts +0 -25
  73. package/lib/writer/writer-ts-definitions-core.d.ts +0 -38
  74. package/lib/writer/writer-ts-definitions.d.ts +0 -70
package/lib/plugin.d.ts DELETED
@@ -1,85 +0,0 @@
1
- import { type GenerateBundleOptions, type GenerateBundleResult } from "./bundle";
2
- import "./writer/built-in-writers";
3
- import type { WriteCustomElementsOptions } from "./writer/writer-custom-elements";
4
- import type { WriteJsonOptions } from "./writer/writer-json";
5
- import type { WriteMarkdownOptions } from "./writer/writer-markdown";
6
- import type { WriteTsDefinitionsOptions } from "./writer/writer-ts-definitions";
7
- export type { CollectedComponents, ComponentDocApi, ComponentDocs, ComponentParseError, GenerateBundleOptions, GenerateBundleResult, ResolveComponentFilePath, } from "./bundle";
8
- export { collectComponents, collectSvelteFilePaths, generateBundle, processComponent, readFileMap, reportParseErrors, toGenerateBundleOptions, } from "./bundle";
9
- export interface PluginSveldOptions extends Pick<GenerateBundleOptions, "resolveTypes" | "cache" | "checkExamples"> {
10
- /**
11
- * Specify the entry point to uncompiled Svelte source.
12
- * If not provided, sveld will use the "svelte" field from package.json.
13
- */
14
- entry?: string;
15
- glob?: boolean;
16
- /** Record consts, functions, and types from the entry barrel. Off by default. */
17
- documentExports?: boolean;
18
- types?: boolean;
19
- typesOptions?: Partial<Omit<WriteTsDefinitionsOptions, "inputDir">>;
20
- json?: boolean;
21
- jsonOptions?: Partial<Omit<WriteJsonOptions, "inputDir">>;
22
- markdown?: boolean;
23
- markdownOptions?: Partial<WriteMarkdownOptions>;
24
- /** Generate a Custom Elements Manifest (`custom-elements.json`, schemaVersion "1.0.0"). */
25
- customElements?: boolean;
26
- customElementsOptions?: Partial<Omit<WriteCustomElementsOptions, "inputDir">>;
27
- /**
28
- * Run additional, userland-registered writers (via `registerWriter` from
29
- * "sveld") beyond the built-in `json`/`markdown`/`types` outputs. Keyed by
30
- * the writer's registered `name`, valued by that writer's options.
31
- */
32
- additionalWriters?: Record<string, unknown>;
33
- /**
34
- * Abort the entire run when a single component fails to parse.
35
- * When `false` (the default), parse failures are collected as diagnostics
36
- * and the remaining components still emit their output.
37
- */
38
- failFast?: boolean;
39
- /**
40
- * Regenerate output incrementally when `.svelte` source changes during
41
- * `vite dev` / `vite build --watch`. Only the changed component and the
42
- * components that depend on it via `@extendProps` / `@extends` are re-parsed.
43
- * @default false
44
- */
45
- watch?: boolean;
46
- }
47
- /** Subset of Vite/Rollup's HMR context that the watch hook relies on. */
48
- interface HotUpdateContext {
49
- file: string;
50
- }
51
- interface SveldPlugin {
52
- name: string;
53
- apply?: "build" | "serve";
54
- enforce?: "pre" | "post";
55
- buildStart(): void | Promise<void>;
56
- generateBundle(): Promise<void>;
57
- writeBundle(): Promise<void>;
58
- /** Vite dev-server HMR hook (serve mode). */
59
- handleHotUpdate?(ctx: HotUpdateContext): void;
60
- /** Rollup/Vite watch hook (build `--watch`). */
61
- watchChange?(id: string): void;
62
- }
63
- export default function pluginSveld(opts?: PluginSveldOptions): SveldPlugin;
64
- /**
65
- * Writes output files based on plugin options.
66
- *
67
- * Generates TypeScript definitions, JSON metadata, and/or Markdown documentation
68
- * based on the options provided. Uses different component sets for different
69
- * output types to match expected behavior.
70
- *
71
- * @param result - Bundle result containing exports and component documentation
72
- * @param opts - Plugin options determining what outputs to generate
73
- * @param input - Input file path for determining input directory
74
- *
75
- * @example
76
- * ```ts
77
- * await writeOutput(result, {
78
- * types: true,
79
- * json: true,
80
- * markdown: true
81
- * }, "./src/App.svelte");
82
- * // Generates: types/*.d.ts, COMPONENT_API.json, COMPONENT_INDEX.md
83
- * ```
84
- */
85
- export declare function writeOutput(result: GenerateBundleResult, opts: PluginSveldOptions, input: string): Promise<void>;
@@ -1,30 +0,0 @@
1
- /** Clears cached tsconfig/jsconfig reads (tests and hot reload). */
2
- export declare function clearConfigCache(): void;
3
- /**
4
- * Resolve a tsconfig/jsconfig path alias to an absolute filesystem path.
5
- *
6
- * @example
7
- * ```ts
8
- * // With tsconfig.json: { "paths": { "$lib/*": ["./src/lib/*"] } }
9
- * resolvePathAliasAbsolute("$lib/utils", "./src")
10
- * // Returns: "/absolute/path/to/src/lib/utils"
11
- *
12
- * resolvePathAliasAbsolute("./relative", "./src")
13
- * // Returns: "./relative" (unchanged, not an alias)
14
- * ```
15
- */
16
- export declare function resolvePathAliasAbsolute(importPath: string, fromDir: string): string;
17
- /**
18
- * Resolve a path alias to a path relative to `fromDir` for generated exports.
19
- *
20
- * @example
21
- * ```ts
22
- * // With alias "$lib/utils" -> "./src/lib/utils"
23
- * resolvePathAlias("$lib/utils", "./src")
24
- * // Returns: "./lib/utils"
25
- *
26
- * resolvePathAlias("./Button.svelte", "./src")
27
- * // Returns: "./Button.svelte" (unchanged, not an alias)
28
- * ```
29
- */
30
- export declare function resolvePathAlias(importPath: string, fromDir: string): string;
@@ -1,52 +0,0 @@
1
- import type { ParsedComponentTypeScriptMetadata, ResolvedComponentProp } from "./ComponentParser";
2
- import type { ExampleCheckSource } from "./example-check";
3
- export interface ResolveTarget {
4
- moduleName: string;
5
- filePath: string;
6
- metadata: ParsedComponentTypeScriptMetadata;
7
- }
8
- export interface ExampleCheckTarget {
9
- moduleName: string;
10
- filePath: string;
11
- sources: ExampleCheckSource[];
12
- }
13
- /** One `@example` block that failed to type-check. */
14
- export interface ExampleCheckDiagnostic {
15
- id: string;
16
- name: string;
17
- message: string;
18
- }
19
- /**
20
- * Expands opaque imported `$props()` types using the project's TypeScript program.
21
- * Loaded only when `resolveTypes` is enabled.
22
- */
23
- export declare class TypeResolver {
24
- private readonly api;
25
- private readonly symbolFlags;
26
- private readonly typeFlags;
27
- private readonly tsconfigPath;
28
- private readonly overlay;
29
- private constructor();
30
- /**
31
- * Loads `typescript` and the nearest `tsconfig.json`.
32
- * Returns `null` when either is missing.
33
- */
34
- static create(cwd?: string): Promise<TypeResolver | null>;
35
- /** Resolves every target in one program snapshot. */
36
- expandAll(targets: ResolveTarget[]): Promise<Map<string, ResolvedComponentProp[]>>;
37
- /**
38
- * Type-checks every `@example` block in one program snapshot.
39
- *
40
- * Each example gets its own virtual file: a `declare`-style binding for the
41
- * documented symbol (typed as `any` end-to-end, so types sveld can't see
42
- * never cause a false positive), then the example body. Catches renamed
43
- * or removed symbols and wrong arity. Not full type checking; it does not
44
- * depend on the rest of the component's types.
45
- */
46
- checkExamples(targets: ExampleCheckTarget[]): Promise<Map<string, ExampleCheckDiagnostic[]>>;
47
- /** Closes the TypeScript server process. */
48
- dispose(): Promise<void>;
49
- private createFileSystem;
50
- private virtualFileName;
51
- private exampleFileName;
52
- }
package/lib/sveld.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import { type CheckResult } from "./check";
2
- import { type SveldDiagnostic } from "./diagnostics";
3
- import { type SveldRuntimeOptions } from "./load-config";
4
- type SveldOptions = SveldRuntimeOptions;
5
- /**
6
- * Result of a programmatic `sveld` run.
7
- */
8
- interface SveldResult {
9
- /** Diagnostics from this run. */
10
- diagnostics: SveldDiagnostic[];
11
- /** Populated when `check` is enabled: the API diff against the committed snapshot. */
12
- check?: CheckResult;
13
- }
14
- /**
15
- * Programmatic entry point for sveld.
16
- *
17
- * @example
18
- * ```ts
19
- * await sveld({
20
- * entry: "./src",
21
- * types: true,
22
- * json: true,
23
- * markdown: true,
24
- * glob: true
25
- * });
26
- * ```
27
- */
28
- export declare function sveld(opts?: SveldOptions): Promise<SveldResult>;
29
- export {};
package/lib/validate.d.ts DELETED
@@ -1,13 +0,0 @@
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;
package/lib/watch.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import { type GenerateBundleResult } from "./bundle";
2
- /** Result of an incremental update. */
3
- export interface SveldBundleUpdate {
4
- /** The full, updated bundle result (all components, with the affected ones re-parsed). */
5
- result: GenerateBundleResult;
6
- /**
7
- * Absolute paths of the components that were re-parsed: the changed files
8
- * plus their transitive `@extendProps` / `@extends` dependents. Other
9
- * components are reused from the previous parse.
10
- */
11
- reparsed: string[];
12
- }
13
- /**
14
- * A long-lived bundle that supports scoped, incremental re-parsing.
15
- *
16
- * `createSveldBundle` performs the initial full parse. `update` then re-parses
17
- * only the components affected by a set of changed files, leaving every other
18
- * component's previously-parsed output untouched. This is the core of the
19
- * plugin's watch mode.
20
- */
21
- export interface SveldBundle {
22
- readonly result: GenerateBundleResult;
23
- /** Re-parse the changed files plus their dependents and return the updated bundle. */
24
- update(changedFilePaths: string[]): Promise<SveldBundleUpdate>;
25
- }
26
- /**
27
- * Creates a watch-mode bundle for the given entry point, performing the initial
28
- * full parse up front.
29
- *
30
- * @param input - Entry point file or directory containing Svelte components
31
- * @param glob - Whether to glob for all `.svelte` files in the directory
32
- * @param documentExports - Record consts, functions, and types from the entry barrel
33
- */
34
- export declare function createSveldBundle(input: string, glob: boolean, documentExports?: boolean): Promise<SveldBundle>;
@@ -1,26 +0,0 @@
1
- export type AppendType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "quote" | "p" | "divider" | "raw";
2
- export interface TocLine {
3
- /** Leading space count; 0 for the top-level (`h2`) entries the TOC currently lists. */
4
- indent: number;
5
- raw: string;
6
- }
7
- export interface MarkdownWriterBase {
8
- sourceParts: string[];
9
- hasToC: boolean;
10
- toc: TocLine[];
11
- appendLineBreaks(): this;
12
- append(type: AppendType, raw?: string): this;
13
- tableOfContents(): this;
14
- end(): string;
15
- get source(): string;
16
- }
17
- export declare class MarkdownWriterBaseImpl implements MarkdownWriterBase {
18
- sourceParts: string[];
19
- hasToC: boolean;
20
- toc: TocLine[];
21
- get source(): string;
22
- appendLineBreaks(): this;
23
- append(type: AppendType, raw?: string): this;
24
- tableOfContents(): this;
25
- end(): string;
26
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * Base writer class for file system operations.
3
- *
4
- * Automatically creates directories as needed before writing.
5
- *
6
- * @example
7
- * ```ts
8
- * const writer = new Writer();
9
- * await writer.write("./dist/index.d.ts", "export type Props = {};");
10
- * ```
11
- */
12
- export default class Writer {
13
- /**
14
- * Writes content to a file.
15
- *
16
- * Creates the directory structure if needed, then writes the content
17
- * to the specified file path.
18
- *
19
- * @param filePath - The path where the file should be written
20
- * @param raw - The content to write
21
- *
22
- * @example
23
- * ```ts
24
- * await writer.write("./dist/index.d.ts", "export type Props={}");
25
- * // Creates ./dist/index.d.ts with the given content
26
- * ```
27
- */
28
- write(filePath: string, raw: string): Promise<void>;
29
- }
30
- /**
31
- * Creates a Writer instance for JSON files.
32
- *
33
- * @returns A Writer instance
34
- *
35
- * @example
36
- * ```ts
37
- * const writer = createJsonWriter();
38
- * await writer.write("data.json", JSON.stringify({ key: "value" }));
39
- * ```
40
- */
41
- export declare function createJsonWriter(): Writer;
42
- /**
43
- * Creates a Writer instance for TypeScript files.
44
- *
45
- * @returns A Writer instance
46
- *
47
- * @example
48
- * ```ts
49
- * const writer = createTypeScriptWriter();
50
- * await writer.write("index.d.ts", "export type Props={};");
51
- * ```
52
- */
53
- export declare function createTypeScriptWriter(): Writer;
@@ -1,33 +0,0 @@
1
- import { type AppendType } from "./MarkdownWriterBase";
2
- import Writer from "./Writer";
3
- type OnAppend = (type: AppendType, document: WriterMarkdown) => void;
4
- interface MarkdownOptions {
5
- onAppend?: OnAppend;
6
- }
7
- export type { AppendType };
8
- /**
9
- * Markdown writer with optional append callbacks.
10
- *
11
- * @example
12
- * ```ts
13
- * const writer = new WriterMarkdown({
14
- * onAppend: (type, doc) => {
15
- * console.log(`Appended ${type} to markdown`);
16
- * }
17
- * });
18
- * writer.append("h1", "Title");
19
- * await writer.write("./docs.md", writer.end());
20
- * ```
21
- */
22
- export default class WriterMarkdown extends Writer {
23
- onAppend?: OnAppend;
24
- private markdownBase;
25
- constructor(options: MarkdownOptions);
26
- get source(): string;
27
- get hasToC(): boolean;
28
- get toc(): import("./MarkdownWriterBase").TocLine[];
29
- appendLineBreaks(): this;
30
- append(type: AppendType, raw?: string): this;
31
- tableOfContents(): this;
32
- end(): string;
33
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,34 +0,0 @@
1
- import type { EntryExports } from "../parse-entry-exports";
2
- import type { ComponentDocApi, ComponentDocs } from "../plugin";
3
- export declare const COMPONENT_API_SCHEMA_VERSION = 1;
4
- /**
5
- * Canonical, renderer-agnostic representation of a component collection.
6
- *
7
- * Every writer (JSON, Markdown, TypeScript definitions) builds this document
8
- * via `buildComponentApiDocument` instead of independently sorting/filtering
9
- * the raw `ComponentDocs` map, so sort order and field stripping can't drift
10
- * between output formats.
11
- */
12
- export interface ComponentApiDocument {
13
- schemaVersion: 1;
14
- generator: {
15
- name: string;
16
- version: string;
17
- svelteVersion: string;
18
- };
19
- total: number;
20
- components: ComponentDocApi[];
21
- /** Only when `documentExports` is on. */
22
- totalExports?: number;
23
- exports?: EntryExports;
24
- }
25
- export interface BuildComponentApiDocumentOptions {
26
- /** Entry-barrel exports when `documentExports` is on. */
27
- entryExports?: EntryExports;
28
- }
29
- /**
30
- * Builds the canonical document for a component collection: components
31
- * sorted alphabetically by `moduleName`, with the Node-only `diagnostics`
32
- * field stripped.
33
- */
34
- export declare function buildComponentApiDocument(components: ComponentDocs, options?: BuildComponentApiDocumentOptions): ComponentApiDocument;
@@ -1,8 +0,0 @@
1
- /**
2
- * Reformats generator-emitted `.d.ts` source for consistent indentation and
3
- * spacing, without depending on an external formatter. This is a structural
4
- * cleanup pass (bracket-depth reindentation, blank-line normalization) rather
5
- * than a full TypeScript printer — it does not wrap long lines or rewrite
6
- * operator spacing.
7
- */
8
- export declare function formatGeneratedTypeScript(raw: string): string;
@@ -1,104 +0,0 @@
1
- import type { DeprecatedValue } from "../ComponentParser";
2
- export declare const BACKTICK_REGEX: RegExp;
3
- export declare const WHITESPACE_REGEX: RegExp;
4
- export declare const MD_TYPE_UNDEFINED = "--";
5
- export declare const PROP_TABLE_HEADER = "| Prop name | Required | Kind | Reactive | Binding | Type | Default value | Description |\n| :- | :- | :- | :- | :- | :- | :- | :- |\n";
6
- export declare const SLOT_TABLE_HEADER = "| Slot name | Default | Props | Fallback | Description |\n| :- | :- | :- | :- | :- |\n";
7
- export declare const EVENT_TABLE_HEADER = "| Event name | Type | Detail | Description |\n| :- | :- | :- | :- |\n";
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 &#124; number</code>"
15
- * formatPropType(undefined) // Returns: "--"
16
- * ```
17
- */
18
- export declare function formatPropType(type?: string): string;
19
- /**
20
- * Escape `<` and `>` for markdown output.
21
- *
22
- * @example
23
- * ```ts
24
- * escapeHtml("<div>") // Returns: "&lt;div&gt;"
25
- * ```
26
- */
27
- 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
- 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
- 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
- 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
- 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>&lt;p&gt;Default&lt;/p&gt;</code>"
75
- * ```
76
- */
77
- 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
- export declare function formatSlotDescription(description?: string, tags?: Array<{
92
- name: string;
93
- body: string;
94
- }>): 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
- export declare function formatEventDetail(detail?: string): string;
@@ -1,10 +0,0 @@
1
- import type { EntryExports } from "../parse-entry-exports";
2
- import type { ComponentDocs } from "../plugin";
3
- import type { AppendType } from "./MarkdownWriterBase";
4
- /** Minimal markdown writer surface used by JSON and browser renderers. */
5
- interface MarkdownDocument {
6
- append(type: AppendType, raw?: string): MarkdownDocument;
7
- tableOfContents(): MarkdownDocument;
8
- }
9
- export declare function renderComponentsToMarkdown(document: MarkdownDocument, components: ComponentDocs, entryExports?: EntryExports): void;
10
- export {};
@@ -1,17 +0,0 @@
1
- import type { ComponentDocs } from "../plugin";
2
- /** Which component set a writer expects: exported-only, or every discovered component. */
3
- export type WriterComponentSet = "exported" | "all";
4
- /**
5
- * A pluggable output format. Built-in writers (`json`, `markdown`, `types`)
6
- * register themselves under these names; third parties can `registerWriter`
7
- * their own to add new output formats without a core PR.
8
- */
9
- export interface OutputWriter<TOptions = unknown> {
10
- name: string;
11
- /** Which component set this writer expects. @default "exported" */
12
- componentSet?: WriterComponentSet;
13
- write(components: ComponentDocs, options: TOptions): Promise<unknown> | unknown;
14
- }
15
- export declare function registerWriter<TOptions = unknown>(writer: OutputWriter<TOptions>): void;
16
- export declare function getWriter(name: string): OutputWriter<unknown> | undefined;
17
- export declare function listWriters(): OutputWriter<unknown>[];
@@ -1,86 +0,0 @@
1
- import type { DeprecatedValue } from "../ComponentParser";
2
- import type { ComponentDocApi, ComponentDocs } from "../plugin";
3
- /**
4
- * Minimal local subset of the published Custom Elements Manifest schema
5
- * (schemaVersion "1.0.0") for the fields sveld can populate. See
6
- * https://github.com/webcomponents/custom-elements-manifest for the full spec.
7
- */
8
- export interface CemType {
9
- text: string;
10
- }
11
- export interface CemClassField {
12
- kind: "field";
13
- name: string;
14
- type?: CemType;
15
- default?: string;
16
- description?: string;
17
- deprecated?: DeprecatedValue;
18
- }
19
- export interface CemAttribute {
20
- name: string;
21
- fieldName: string;
22
- type?: CemType;
23
- default?: string;
24
- description?: string;
25
- }
26
- export interface CemEvent {
27
- name: string;
28
- type: CemType;
29
- description?: string;
30
- deprecated?: DeprecatedValue;
31
- }
32
- export interface CemSlot {
33
- name: string;
34
- description?: string;
35
- deprecated?: DeprecatedValue;
36
- }
37
- export interface CemClassDeclaration {
38
- kind: "class";
39
- name: string;
40
- description?: string;
41
- members: CemClassField[];
42
- attributes: CemAttribute[];
43
- events: CemEvent[];
44
- slots: CemSlot[];
45
- /** Only present when the source component sets `<svelte:options customElement="..." />`. */
46
- tagName?: string;
47
- /** Only present when the source component sets `<svelte:options customElement="..." />`. */
48
- customElement?: true;
49
- }
50
- export interface CemJavaScriptExport {
51
- kind: "js";
52
- name: string;
53
- declaration: {
54
- name: string;
55
- module: string;
56
- };
57
- }
58
- export interface CemCustomElementExport {
59
- kind: "custom-element-definition";
60
- name: string;
61
- declaration: {
62
- name: string;
63
- module: string;
64
- };
65
- }
66
- export type CemExport = CemJavaScriptExport | CemCustomElementExport;
67
- export interface CemModule {
68
- kind: "javascript-module";
69
- path: string;
70
- declarations: CemClassDeclaration[];
71
- exports: CemExport[];
72
- }
73
- export interface CustomElementsManifest {
74
- schemaVersion: "1.0.0";
75
- modules: CemModule[];
76
- }
77
- export interface BuildCustomElementsManifestOptions {
78
- /** Resolves each component's manifest `path`. Defaults to the component's `filePath` as-is. */
79
- resolveModulePath?: (component: ComponentDocApi) => string;
80
- }
81
- /**
82
- * Builds a Custom Elements Manifest (schemaVersion "1.0.0") in memory, with
83
- * no file-system or `node:*` dependency so it can run in the browser (e.g.
84
- * the playground).
85
- */
86
- export declare function buildCustomElementsManifest(components: ComponentDocs, options?: BuildCustomElementsManifestOptions): CustomElementsManifest;
@@ -1,15 +0,0 @@
1
- import type { ComponentDocs } from "../plugin";
2
- export type { CemAttribute, CemClassDeclaration, CemClassField, CemCustomElementExport, CemEvent, CemExport, CemJavaScriptExport, CemModule, CemSlot, CemType, CustomElementsManifest, } from "./writer-custom-elements-core";
3
- export interface WriteCustomElementsOptions {
4
- inputDir: string;
5
- outFile: string;
6
- }
7
- /**
8
- * Writes component documentation as a Custom Elements Manifest
9
- * (schemaVersion "1.0.0"). Components without a `customElementTag` (i.e. not
10
- * compiled with `<svelte:options customElement="..." />`) still emit a plain
11
- * class declaration; the manifest is most useful for `customElement`-compiled
12
- * builds, where editors, Storybook, and other CEM-aware tooling can resolve
13
- * `tagName`, `attributes`, and `events`.
14
- */
15
- export default function writeCustomElements(components: ComponentDocs, options: WriteCustomElementsOptions): Promise<void>;