storybook-solidjs-vite 10.1.2 → 10.3.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 (95) hide show
  1. package/README.md +76 -68
  2. package/dist/SolidComponentMetaManager-KXVARPHU.js +4 -0
  3. package/dist/SolidComponentMetaManager-KXVARPHU.js.map +1 -0
  4. package/dist/chunk-6566KBHG.js +816 -0
  5. package/dist/chunk-6566KBHG.js.map +1 -0
  6. package/dist/{chunk-4GZSFB75.js → chunk-7IQZHF5A.js} +3 -3
  7. package/dist/chunk-7IQZHF5A.js.map +1 -0
  8. package/dist/chunk-FGHVLJAL.js +42 -0
  9. package/dist/chunk-FGHVLJAL.js.map +1 -0
  10. package/dist/{chunk-XQXXS54C.js → chunk-GF3JOYAC.js} +7 -8
  11. package/dist/chunk-GF3JOYAC.js.map +1 -0
  12. package/dist/chunk-GZ3XWUGK.js +65 -0
  13. package/dist/chunk-GZ3XWUGK.js.map +1 -0
  14. package/dist/{chunk-W3QB2KPF.js → chunk-H7QHQTFU.js} +3 -3
  15. package/dist/{chunk-W3QB2KPF.js.map → chunk-H7QHQTFU.js.map} +1 -1
  16. package/dist/chunk-PZ5AY32C.js +9 -0
  17. package/dist/{chunk-G3PMV62Z.js.map → chunk-PZ5AY32C.js.map} +1 -1
  18. package/dist/{chunk-W35XFTHU.js → chunk-QRPXDQGQ.js} +4 -4
  19. package/dist/{chunk-W35XFTHU.js.map → chunk-QRPXDQGQ.js.map} +1 -1
  20. package/dist/entry-preview/argtypes.d.ts +2 -3
  21. package/dist/entry-preview/argtypes.js +2 -2
  22. package/dist/entry-preview/docs.js +2 -2
  23. package/dist/entry-preview/solid-1.js +2 -2
  24. package/dist/entry-preview/solid-2.js +2 -2
  25. package/dist/framework/node.d.ts +1 -2
  26. package/dist/framework/node.js +1 -1
  27. package/dist/framework/preset.d.ts +116 -4
  28. package/dist/framework/preset.js +970 -11
  29. package/dist/framework/preset.js.map +1 -1
  30. package/dist/index.d.ts +1 -2
  31. package/dist/index.js +5 -5
  32. package/dist/next.d.ts +1 -2
  33. package/dist/next.js +5 -5
  34. package/dist/renderer/playwright.js +1 -1
  35. package/dist/renderer.js +1 -1
  36. package/dist/toDocgenInfo-PQOQHVB2.js +4 -0
  37. package/dist/toDocgenInfo-PQOQHVB2.js.map +1 -0
  38. package/dist/{types-CixQ_ttK.d.ts → types-3qJHo3rN.d.ts} +3 -45
  39. package/package.json +6 -13
  40. package/src/codeExamples/enrichCsf.ts +106 -0
  41. package/src/codeExamples/generateCodeSnippet.test.ts +235 -0
  42. package/src/codeExamples/generateCodeSnippet.ts +728 -0
  43. package/src/codeExamples/invariant.ts +11 -0
  44. package/src/componentManifest/getComponents.ts +276 -0
  45. package/src/componentManifest/manifests.ts +257 -0
  46. package/src/componentManifest/solidComponentMeta/SolidComponentMetaManager.ts +260 -0
  47. package/src/componentManifest/solidComponentMeta/SolidComponentMetaProject.ts +421 -0
  48. package/src/componentManifest/solidComponentMeta/resolveProps.ts +494 -0
  49. package/src/componentManifest/solidComponentMetaPlugin.ts +67 -0
  50. package/src/componentManifest/toDocgenInfo.ts +57 -0
  51. package/src/componentManifest/types.ts +48 -0
  52. package/src/framework/preset.ts +23 -21
  53. package/src/framework/types.ts +3 -3
  54. package/src/renderer/docs/entry-preview-argtypes.ts +69 -4
  55. package/src/renderer/shared/create-define-preview.ts +0 -1
  56. package/src/renderer/v1/entry-preview.ts +3 -3
  57. package/src/renderer/v2/entry-preview.ts +8 -10
  58. package/template/cli-v2/js/Button.jsx +29 -0
  59. package/template/cli-v2/js/Button.stories.js +52 -0
  60. package/template/cli-v2/js/Header.jsx +54 -0
  61. package/template/cli-v2/js/Header.stories.js +32 -0
  62. package/template/cli-v2/js/Page.jsx +76 -0
  63. package/template/cli-v2/js/Page.stories.js +33 -0
  64. package/template/cli-v2/ts/Button.stories.ts +55 -0
  65. package/template/cli-v2/ts/Button.tsx +37 -0
  66. package/template/cli-v2/ts/Header.stories.ts +35 -0
  67. package/template/cli-v2/ts/Header.tsx +63 -0
  68. package/template/cli-v2/ts/Page.stories.ts +36 -0
  69. package/template/cli-v2/ts/Page.tsx +77 -0
  70. package/dist/chunk-4GZSFB75.js.map +0 -1
  71. package/dist/chunk-G3PMV62Z.js +0 -33
  72. package/dist/chunk-SHOV6BHW.js +0 -18415
  73. package/dist/chunk-SHOV6BHW.js.map +0 -1
  74. package/dist/chunk-XQXXS54C.js.map +0 -1
  75. package/src/renderer/docs/extractArgTypes.ts +0 -86
  76. package/src/renderer/docs/lib/captions.ts +0 -6
  77. package/src/renderer/docs/lib/defaultValues/createDefaultValue.ts +0 -87
  78. package/src/renderer/docs/lib/defaultValues/createFromRawDefaultProp.ts +0 -183
  79. package/src/renderer/docs/lib/defaultValues/generateArray.ts +0 -24
  80. package/src/renderer/docs/lib/defaultValues/generateObject.ts +0 -24
  81. package/src/renderer/docs/lib/defaultValues/index.ts +0 -2
  82. package/src/renderer/docs/lib/defaultValues/prettyIdentifier.ts +0 -28
  83. package/src/renderer/docs/lib/generateCode.ts +0 -70
  84. package/src/renderer/docs/lib/inspection/acornParser.test.ts +0 -257
  85. package/src/renderer/docs/lib/inspection/acornParser.ts +0 -241
  86. package/src/renderer/docs/lib/inspection/index.ts +0 -2
  87. package/src/renderer/docs/lib/inspection/inspectValue.ts +0 -17
  88. package/src/renderer/docs/lib/inspection/types.ts +0 -65
  89. package/src/renderer/docs/lib/isHtmlTag.ts +0 -5
  90. package/src/renderer/docs/propTypes/createType.ts +0 -433
  91. package/src/renderer/docs/propTypes/generateFuncSignature.ts +0 -70
  92. package/src/renderer/docs/propTypes/handleProp.ts +0 -51
  93. package/src/renderer/docs/propTypes/rawDefaultPropResolvers.ts +0 -36
  94. package/src/renderer/docs/propTypes/sortProps.ts +0 -18
  95. package/src/renderer/docs/typeScript/handleProp.ts +0 -31
package/README.md CHANGED
@@ -9,19 +9,20 @@
9
9
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE)
10
10
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/solidjs-community/storybook/pulls)
11
11
 
12
- [Storybook](https://storybook.js.org/) **framework adapter** for [SolidJS](https://solidjs.com/), using Vite.
13
-
14
- Adds SolidJS support to Storybook.
12
+ [Storybook](https://storybook.js.org/) framework adapter for [SolidJS](https://solidjs.com/) on Vite.
15
13
 
16
14
  ## ✨ Features
17
15
 
18
- - Solid 1 and Solid 2 support
19
- - Vite-powered builder
20
- - TypeScript-first setup
21
- - ArgTypes generation from TypeScript
22
- - [CSF Next](https://storybook.js.org/docs/api/csf/csf-next) factory API (optional)
23
- - Compatible with Storybook addons
24
- - Integrated testing (Vitest, Playwright)
16
+ - [Solid 1](#solid-1) and [Solid 2](#solid-2) support
17
+ - [Vite-powered builder](https://storybook.js.org/docs/builders/vite)
18
+ - [TypeScript-first setup](https://storybook.js.org/docs/configure/integration/typescript)
19
+ - Automatic props in [Controls and Docs](#docgen)
20
+ - [Autodocs code snippets](#autodocs-code-snippets) static JSX **Show code** blocks from story source (CSF Next + CSF3, enabled by default)
21
+ - [Components manifest](https://storybook.js.org/docs/ai/manifests) for AI agents ([debugger](#components-manifest-debugger))
22
+ - [Storybook MCP](https://storybook.js.org/docs/ai/mcp/overview) support ([setup](#storybook-mcp))
23
+ - [CSF Next](https://storybook.js.org/docs/api/csf/csf-next) factory API ([setup](#csf-next), optional)
24
+ - [Integrated testing](https://storybook.js.org/docs/writing-tests) (Vitest, Playwright)
25
+ - [Compatible with Storybook addons](https://storybook.js.org/docs/addons)
25
26
 
26
27
  ## 🚀 Getting Started
27
28
 
@@ -29,26 +30,18 @@ Run in your project:
29
30
 
30
31
  ```bash
31
32
  npx create-storybook --type=solid
32
- ```
33
-
34
- Then start Storybook:
35
-
36
- ```bash
37
- bun run storybook
33
+ npm run storybook
38
34
  ```
39
35
 
40
36
  Open the URL shown in the terminal.
41
37
 
42
38
  ## ⚙️ Configuration
43
39
 
44
- You can customize Vite and Storybook as usual.
45
-
46
- - Add stories in `src/**/*.stories.tsx` or `src/**/*.stories.js`
47
- - Use Storybook addons for additional functionality
40
+ Customize Vite and Storybook as usual. Add stories in `src/**/*.stories.{tsx,js}` and install addons as needed.
48
41
 
49
42
  ### Solid 1
50
43
 
51
- On Solid 1, import from `storybook-solidjs-vite` in config, preview, and stories:
44
+ Import from `storybook-solidjs-vite` in config, preview, and stories:
52
45
 
53
46
  ```ts
54
47
  // .storybook/main.ts
@@ -68,19 +61,19 @@ import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite';
68
61
 
69
62
  ### Solid 2
70
63
 
71
- On Solid 2, use `storybook-solidjs-vite/next` in preview and stories — the types there match the Solid 2 renderer:
64
+ Use `storybook-solidjs-vite/next` in preview and stories:
72
65
 
73
66
  ```ts
74
67
  import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite/next';
75
68
  ```
76
69
 
77
- Imports without `/next` often still run, but TypeScript may complain because those types describe the Solid 1 renderer.
70
+ Imports without `/next` may still run, but TypeScript can complain.
78
71
 
79
- In `main.ts` either framework name is fine: `storybook-solidjs-vite` reads the major version from your installed `solid-js`, and `storybook-solidjs-vite/next` forces Solid 2.
72
+ In `main.ts`, either framework name works: `storybook-solidjs-vite` reads the major version from `solid-js`; `storybook-solidjs-vite/next` forces Solid 2.
80
73
 
81
74
  ```ts
82
- framework: 'storybook-solidjs-vite'
83
- framework: 'storybook-solidjs-vite/next'
75
+ framework: 'storybook-solidjs-vite' // Solid auto-detect
76
+ framework: 'storybook-solidjs-vite/next' // Solid 2 only
84
77
  ```
85
78
 
86
79
  ### CSF Next
@@ -100,7 +93,7 @@ export default defineMain({
100
93
  // .storybook/preview.tsx
101
94
  import { definePreview } from 'storybook-solidjs-vite';
102
95
  // for Solid 2, use:
103
- // import { definePreview } from 'storybook-solidjs-vite/next';
96
+ import { definePreview } from 'storybook-solidjs-vite/next';
104
97
  ```
105
98
 
106
99
  ```ts
@@ -117,15 +110,13 @@ export const Primary = meta.story({
117
110
  });
118
111
  ```
119
112
 
120
- ### TypeScript docgen
113
+ ### Docgen
121
114
 
122
- TypeScript props for docs and controls are generated with [@joshwooding/vite-plugin-react-docgen-typescript](https://github.com/joshwooding/vite-plugin-react-docgen-typescript).
115
+ Props for **Controls**, **Docs**, and the **components manifest** come from a TypeScript LanguageService extractor aligned with Storybook's `react-component-meta` format.
123
116
 
124
- Configure it with framework.options.docgen in .storybook/main.ts.
117
+ Enabled by default. Inspect output in the [manifest debugger](#components-manifest-debugger).
125
118
 
126
- `false` disable docgen
127
- `true` (default) — enable docgen with the default configuration
128
- `object` — override default configuration
119
+ To disable:
129
120
 
130
121
  ```ts
131
122
  import type { StorybookConfig } from 'storybook-solidjs-vite';
@@ -133,73 +124,90 @@ import type { StorybookConfig } from 'storybook-solidjs-vite';
133
124
  const config: StorybookConfig = {
134
125
  framework: {
135
126
  name: 'storybook-solidjs-vite',
136
- options: {
137
- docgen: {
138
- savePropValueAsString: true,
139
- shouldExtractLiteralValuesFromEnum: true,
140
- propFilter: (prop: any) =>
141
- prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
142
- },
143
- },
127
+ options: { docgen: false },
144
128
  },
145
129
  };
146
130
 
147
131
  export default config;
148
132
  ```
149
133
 
150
- ## 🎨 Decorators
134
+ ### Autodocs code snippets
135
+
136
+ **Show code** blocks are static snippets generated from story source at index time (`experimentalCodeExamples`). Enabled by default.
137
+
138
+ To disable:
139
+
140
+ ```ts
141
+ import type { StorybookConfig } from 'storybook-solidjs-vite';
142
+
143
+ const config: StorybookConfig = {
144
+ features: {
145
+ experimentalCodeExamples: false
146
+ },
147
+ };
148
+
149
+ export default config;
150
+ ```
151
151
 
152
- On args or globals changes, Storybook re-runs decorators and stories — the same model as React, where each update calls your functions again. Solid updates through fine-grained signals and usually does not need that.
152
+ ### Storybook MCP
153
153
 
154
- If a decorator returns JSX, the extra runs can leave duplicate nodes in the DOM.
154
+ Solid projects can use [Storybook MCP](https://storybook.js.org/docs/ai/mcp/overview) so AI agents can list components, read prop docs from component meta, and preview stories. Requires docgen (enabled by default) and `@storybook/addon-docs`.
155
+
156
+ ```bash
157
+ npx storybook add @storybook/addon-mcp
158
+ ```
159
+
160
+ See [Storybook MCP docs](https://storybook.js.org/docs/ai/mcp/overview#2-add-the-mcp-server-to-your-agent) for agent setup.
161
+
162
+ ### Components manifest debugger
163
+
164
+ Storybook builds [JSON manifests](https://storybook.js.org/docs/ai/manifests) from CSF stories and component source — names, props, JSDoc, story ids, and more. Enabled by default (`features.componentsManifest`). Prop data comes from [docgen](#docgen); story snippets use the same [code generator](#autodocs-code-snippets).
165
+
166
+ While Storybook runs (or in a static build):
167
+
168
+ - **Debugger UI:** `http://localhost:6006/manifests/components.html` — browse manifests and generation errors/warnings
169
+ - **Components JSON:** `http://localhost:6006/manifests/components.json`
170
+ - **Docs JSON:** `http://localhost:6006/manifests/docs.json` (when MDX docs are present)
171
+
172
+ ## 🎨 Decorators
173
+
174
+ On args or globals changes, Storybook re-runs decorators and stories functions follows React reactivity model. Solid updates via fine-grained signals and usually doesn't need that. JSX decorators re-run can leave duplicate DOM nodes. To avoid this, use `createJSXDecorator` function to define decorators that return JSX.
155
175
 
156
176
  ### createJSXDecorator
157
177
 
158
- Use for decorators that return JSX. Ensures they run only once per story mount.
178
+ For decorators that return JSX. Runs once per story mount — `context.globals` and `context.args` are reactive stores, so bindings in JSX still update without re-running the decorator:
159
179
 
160
180
  ```tsx
161
181
  import { createJSXDecorator } from 'storybook-solidjs-vite';
162
182
 
163
- export const decorator = createJSXDecorator((Story) => {
164
- return (
165
- <main>
166
- <Story />
167
- </main>
168
- );
169
- });
183
+ export const withLayout = createJSXDecorator((Story, context) => (
184
+ <main data-theme={context.globals.theme}>
185
+ <Story />
186
+ </main>
187
+ ));
170
188
  ```
171
189
 
172
190
  ### createDecorator
173
191
 
174
- Use for decorators that do not return JSX.
192
+ For side effects that should run on every story update — e.g. sync `document.body` when globals change:
175
193
 
176
194
  ```tsx
177
195
  import { createDecorator } from 'storybook-solidjs-vite';
178
196
 
179
- export const decorator = createDecorator((Story) => {
197
+ export const withTheme = createDecorator((Story, context) => {
198
+ // Will run on every story update
199
+ document.body.setAttribute('data-theme', context.globals.theme);
180
200
  return Story();
181
201
  });
182
202
  ```
183
203
 
184
- ### Manual flag
185
-
186
- ```tsx
187
- import { IS_SOLID_JSX_FLAG } from 'storybook-solidjs-vite';
188
-
189
- export const decorator = (Story) => {
190
- return <div><Story /></div>;
191
- };
192
-
193
- decorator[IS_SOLID_JSX_FLAG] = true;
194
- ```
195
-
196
204
  ## 🔄 Migration from v9
197
205
 
198
- Check out [Migration Guide](./MIGRATION.md) for the instructions and breaking changes.
206
+ See [Migration Guide](./MIGRATION.md) for breaking changes.
199
207
 
200
208
  ## 🤝 Contributing
201
209
 
202
- Contributions, issues and feature requests are welcome! Feel free to [open an issue](https://github.com/solidjs-community/storybook/issues) or submit a PR.
210
+ Issues and PRs welcome [open an issue](https://github.com/solidjs-community/storybook/issues) or submit a pull request.
203
211
 
204
212
  ## 📖 License
205
213
 
@@ -0,0 +1,4 @@
1
+ export { DOCGEN_ENGINE, MANIFEST_DOCGEN_ENGINE, SolidComponentMetaManager, getOrCreateSolidComponentMetaManager } from './chunk-6566KBHG.js';
2
+ import './chunk-PZ5AY32C.js';
3
+ //# sourceMappingURL=SolidComponentMetaManager-KXVARPHU.js.map
4
+ //# sourceMappingURL=SolidComponentMetaManager-KXVARPHU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"SolidComponentMetaManager-KXVARPHU.js"}