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.
Files changed (54) hide show
  1. package/README.md +46 -4
  2. package/cli.js +1 -1
  3. package/lib/ComponentParser.d.ts +164 -398
  4. package/lib/ast-guards.d.ts +2 -0
  5. package/lib/browser.d.ts +39 -0
  6. package/lib/browser.js +268 -0
  7. package/lib/bundle.d.ts +9 -4
  8. package/lib/chunk-1p4ka68s.js +2 -0
  9. package/lib/chunk-72hx9e9w.js +20 -0
  10. package/lib/chunk-7qz0hzgw.js +217 -0
  11. package/lib/chunk-8xw75w8t.js +10 -0
  12. package/lib/chunk-cxrw7gzr.js +2 -0
  13. package/lib/chunk-jdnsv86e.js +1 -0
  14. package/lib/chunk-pmj8c3yv.js +6 -0
  15. package/lib/chunk-s9mzxa4y.js +1 -0
  16. package/lib/chunk-v4q9vw0y.js +62 -0
  17. package/lib/chunk-xkrgedm4.js +4 -0
  18. package/lib/chunk-zva3xjwa.js +13 -0
  19. package/lib/cli-entry.d.ts +12 -0
  20. package/lib/cli-entry.js +1 -0
  21. package/lib/get-svelte-entry.d.ts +0 -1
  22. package/lib/index.js +1 -484
  23. package/lib/parse-cache.d.ts +1 -1
  24. package/lib/parse-entry-exports.d.ts +2 -2
  25. package/lib/parse-exports.d.ts +5 -1
  26. package/lib/parsed-component-metadata.d.ts +13 -0
  27. package/lib/parser/bindings.d.ts +0 -2
  28. package/lib/parser/context.d.ts +13 -51
  29. package/lib/parser/events.d.ts +0 -2
  30. package/lib/parser/jsdoc.d.ts +0 -4
  31. package/lib/parser/prop-shared.d.ts +84 -0
  32. package/lib/parser/props.d.ts +6 -2
  33. package/lib/parser/rest-props.d.ts +0 -2
  34. package/lib/parser/runes-detection.d.ts +13 -0
  35. package/lib/parser/scopes.d.ts +23 -7
  36. package/lib/parser/slots.d.ts +1 -6
  37. package/lib/parser/source-position.d.ts +0 -4
  38. package/lib/parser/type-resolution.d.ts +4 -14
  39. package/lib/parser/typescript-casts.d.ts +1 -0
  40. package/lib/parser/utils.d.ts +1 -0
  41. package/lib/parser/variable-jsdoc.d.ts +12 -0
  42. package/lib/parser-stack.d.ts +20 -0
  43. package/lib/path.d.ts +0 -1
  44. package/lib/resolve-types.d.ts +1 -1
  45. package/lib/svelte-parse.d.ts +4 -0
  46. package/lib/svelte-version.d.ts +1 -0
  47. package/lib/writer/Writer.d.ts +7 -29
  48. package/lib/writer/WriterMarkdown.d.ts +0 -2
  49. package/lib/writer/markdown-format-utils.d.ts +0 -84
  50. package/lib/writer/writer-json.d.ts +2 -12
  51. package/lib/writer/writer-markdown.d.ts +0 -2
  52. package/lib/writer/writer-ts-definitions-core.d.ts +1 -9
  53. package/lib/writer/writer-ts-definitions.d.ts +1 -28
  54. package/package.json +6 -1
package/README.md CHANGED
@@ -132,6 +132,7 @@ export default class Button extends SvelteComponentTyped<
132
132
  - [CLI](#cli)
133
133
  - [CI: API-drift checks (`--check`)](#ci-api-drift-checks---check)
134
134
  - [Node.js](#nodejs)
135
+ - [Browser](#browser)
135
136
  - [Config File](#config-file)
136
137
  - [Publishing to NPM](#publishing-to-npm)
137
138
  - [Available Options](#available-options)
@@ -568,6 +569,51 @@ sveld({
568
569
  });
569
570
  ```
570
571
 
572
+ ### Browser
573
+
574
+ `sveld/browser` is a Node-free subpath export for running `sveld` client-side — e.g. an in-browser Svelte playground or REPL that parses whatever `.svelte` source the user typed and renders docs for it live. It bundles with Vite, esbuild, webpack, or Rollup without a `node:fs`/`node:path` polyfill.
575
+
576
+ It covers parsing one component's source and rendering that result to any output format `sveld` supports (JSON, Markdown, `.d.ts`, Custom Elements Manifest). It does not cover project-wide glob scanning, the config file, or the CLI/Vite plugin (`sveld()`/`pluginSveld()`) — those walk the filesystem and only make sense in Node. Use the main `sveld` entry point for those.
577
+
578
+ ```ts
579
+ import {
580
+ asNormalizedPath,
581
+ ComponentParser,
582
+ buildComponentApiDocument,
583
+ writeMarkdownCore,
584
+ writeTsDefinition,
585
+ buildCustomElementsManifest,
586
+ } from "sveld/browser";
587
+
588
+ const parser = new ComponentParser();
589
+ const moduleName = "Button";
590
+ const filePath = "Button.svelte";
591
+ const parsed = parser.parseSvelteComponent(source, { moduleName, filePath });
592
+
593
+ // `parseSvelteComponent` returns component metadata only; add `moduleName`
594
+ // and `filePath` yourself to match the `ComponentDocApi` shape the writers expect.
595
+ const component = { ...parsed, moduleName, filePath: asNormalizedPath(filePath) };
596
+ const components = new Map([[moduleName, component]]);
597
+
598
+ // JSON
599
+ const jsonDoc = buildComponentApiDocument(components);
600
+
601
+ // Markdown
602
+ const markdown = writeMarkdownCore(components);
603
+
604
+ // TypeScript definitions (per component)
605
+ const dts = writeTsDefinition(jsonDoc.components[0]);
606
+
607
+ // Custom Elements Manifest
608
+ const cem = buildCustomElementsManifest(components, {
609
+ resolveModulePath: (component) => component.filePath,
610
+ });
611
+ ```
612
+
613
+ `ComponentParser` is stateful but reusable across parses — call `parseSvelteComponent` again on the same instance for the next component instead of constructing a new one each time.
614
+
615
+ See [`playground/`](playground) in this repo for a working example: it parses Svelte source typed into an editor and renders JSON, Markdown, TypeScript, and Custom Elements Manifest tabs, all client-side.
616
+
571
617
  ### Config File
572
618
 
573
619
  Put a `sveld.config.js`, `sveld.config.mjs`, or `sveld.config.ts` at your project root to set defaults for the CLI and the programmatic `sveld()` API.
@@ -637,12 +683,8 @@ The `svelte` condition lets bundlers that understand it (Vite, Rollup, webpack v
637
683
  - **`glob`** (boolean, optional): Enable glob mode to analyze all `*.svelte` files.
638
684
  - **`documentExports`** (boolean, optional): Include consts, functions, and types from the entry barrel in JSON (`exports`) and Markdown ("Exports"). Off by default. See [Documenting Entry Exports](#documenting-entry-exports).
639
685
  - **`types`** (boolean, optional, default: `true`): Generate TypeScript definitions.
640
- <<<<<<< HEAD
641
686
  - **`typesOptions`** (object, optional): Options for TypeScript definition generation, including `outDir`, `preamble`, and `format`.
642
687
  - **`format`** (`"class"` | `"component"`, optional, default: `"class"`): `.d.ts` output shape. `"class"` extends `SvelteComponentTyped`; `"component"` emits the Svelte 5 `Component` type. Also available as `--types-format`. See [`.d.ts` output format](#dts-output-format-typesoptionsformat).
643
- =======
644
- - **`typesOptions`** (object, optional): Options for TypeScript definition generation, including `outDir` and `preamble`.
645
- >>>>>>> 0724225 (feat(writer)!: remove prettier entirely)
646
688
  - **`json`** (boolean, optional): Generate component documentation in JSON format.
647
689
  - **`jsonOptions`** (object, optional): Options for JSON output.
648
690
  - **`markdown`** (boolean, optional): Generate component documentation in Markdown format.
package/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import("./lib/index.js")
3
+ import("./lib/cli-entry.js")
4
4
  .then(({ cli }) => cli(process))
5
5
  .catch((error) => {
6
6
  console.error(error);