sveld 0.26.1 → 0.27.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 +14 -8
- package/cli.js +1 -7
- package/lib/index.js +184 -14
- package/package.json +10 -9
- package/lib/ComponentParser.js +0 -2657
- package/lib/cli.js +0 -48
- package/lib/create-exports.js +0 -170
- package/lib/element-tag-map.js +0 -158
- package/lib/get-svelte-entry.js +0 -39
- package/lib/parse-exports.js +0 -112
- package/lib/path.js +0 -12
- package/lib/plugin.js +0 -269
- package/lib/resolve-alias.js +0 -198
- package/lib/sveld.js +0 -33
- package/lib/writer/MarkdownWriterBase.js +0 -70
- package/lib/writer/Writer.js +0 -104
- package/lib/writer/WriterMarkdown.js +0 -65
- package/lib/writer/markdown-format-utils.js +0 -158
- package/lib/writer/markdown-render-utils.js +0 -89
- package/lib/writer/writer-json.js +0 -119
- package/lib/writer/writer-markdown-core.js +0 -44
- package/lib/writer/writer-markdown.js +0 -46
- package/lib/writer/writer-ts-definitions-core.js +0 -753
- package/lib/writer/writer-ts-definitions.js +0 -64
package/README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# sveld
|
|
2
2
|
|
|
3
3
|
[![NPM][npm]][npm-url]
|
|
4
|
-

|
|
5
4
|

|
|
6
5
|
|
|
7
6
|
`sveld` is a TypeScript definition generator for Svelte components. It analyzes props, events, slots, and other component features through static analysis. Types and signatures can be defined using [JSDoc notation](https://jsdoc.app/). The tool can also generate component documentation in Markdown and JSON formats.
|
|
@@ -50,7 +49,7 @@ type $Props = {
|
|
|
50
49
|
*/
|
|
51
50
|
primary?: boolean;
|
|
52
51
|
|
|
53
|
-
[key: `data-${string}`]:
|
|
52
|
+
[key: `data-${string}`]: unknown;
|
|
54
53
|
};
|
|
55
54
|
|
|
56
55
|
export type ButtonProps = Omit<$RestProps, keyof $Props> & $Props;
|
|
@@ -222,13 +221,13 @@ npx sveld --json --markdown
|
|
|
222
221
|
|
|
223
222
|
### Node.js
|
|
224
223
|
|
|
225
|
-
You can also use `sveld` programmatically in Node.js.
|
|
224
|
+
You can also use `sveld` programmatically in Node.js. The package is **ESM-only**; `require("sveld")` is not supported. Use `import` or dynamic `import()`.
|
|
226
225
|
|
|
227
226
|
If no `input` is specified, `sveld` will infer the entry point based on the `package.json#svelte` field.
|
|
228
227
|
|
|
229
228
|
```js
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
import { sveld } from "sveld";
|
|
230
|
+
import pkg from "./package.json" with { type: "json" };
|
|
232
231
|
|
|
233
232
|
sveld({
|
|
234
233
|
input: "./src/index.js",
|
|
@@ -946,9 +945,16 @@ There are several ways to provide type information for contexts:
|
|
|
946
945
|
|
|
947
946
|
- Context keys must be string literals (dynamic keys are not supported)
|
|
948
947
|
- Variables passed to `setContext` should have JSDoc `@type` annotations for accurate types
|
|
949
|
-
- The generated type name follows the pattern: `{PascalCase}Context
|
|
950
|
-
|
|
951
|
-
|
|
948
|
+
- The generated type name follows the pattern: `{PascalCase}Context`. Separators (hyphens, underscores, dots, colons, slashes, spaces) are stripped and each segment is capitalized:
|
|
949
|
+
| Context Key | Generated Type Name |
|
|
950
|
+
| --- | --- |
|
|
951
|
+
| `"simple-modal"` | `SimpleModalContext` |
|
|
952
|
+
| `"user_settings"` | `UserSettingsContext` |
|
|
953
|
+
| `"Carbon.Modal"` | `CarbonModalContext` |
|
|
954
|
+
| `"Carbon:Modal"` | `CarbonModalContext` |
|
|
955
|
+
| `"app/modal"` | `AppModalContext` |
|
|
956
|
+
| `"My Context"` | `MyContextContext` |
|
|
957
|
+
| `"Tabs"` | `TabsContext` |
|
|
952
958
|
- If no type annotation is found, the type defaults to `any` with a warning
|
|
953
959
|
|
|
954
960
|
### `@restProps`
|