@storybook/server 6.5.9 → 7.0.0-alpha.10
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 +1 -317
- package/dist/chunk-43Y6KZXY.mjs +4 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +4 -0
- package/dist/config.mjs +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +4 -0
- package/dist/index.mjs +1 -0
- package/dist/public-types-07d4abb5.d.ts +42 -0
- package/package.json +34 -38
- package/preview.js +1 -0
- package/bin/build.js +0 -4
- package/bin/index.js +0 -3
- package/dist/cjs/client/index.js +0 -59
- package/dist/cjs/client/preview/config.js +0 -25
- package/dist/cjs/client/preview/globals.js +0 -8
- package/dist/cjs/client/preview/index.js +0 -52
- package/dist/cjs/client/preview/render.js +0 -192
- package/dist/cjs/client/preview/types.js +0 -5
- package/dist/cjs/lib/compiler/index.js +0 -21
- package/dist/cjs/lib/compiler/stringifier.js +0 -175
- package/dist/cjs/lib/compiler/types.js +0 -1
- package/dist/cjs/server/build.js +0 -9
- package/dist/cjs/server/framework-preset-server.js +0 -33
- package/dist/cjs/server/index.js +0 -9
- package/dist/cjs/server/loader.js +0 -14
- package/dist/cjs/server/options.js +0 -17
- package/dist/esm/client/index.js +0 -5
- package/dist/esm/client/preview/config.js +0 -4
- package/dist/esm/client/preview/globals.js +0 -3
- package/dist/esm/client/preview/index.js +0 -30
- package/dist/esm/client/preview/render.js +0 -161
- package/dist/esm/client/preview/types.js +0 -1
- package/dist/esm/lib/compiler/index.js +0 -13
- package/dist/esm/lib/compiler/stringifier.js +0 -137
- package/dist/esm/lib/compiler/types.js +0 -0
- package/dist/esm/server/build.js +0 -3
- package/dist/esm/server/framework-preset-server.js +0 -18
- package/dist/esm/server/index.js +0 -3
- package/dist/esm/server/loader.js +0 -4
- package/dist/esm/server/options.js +0 -8
- package/dist/modern/client/index.js +0 -5
- package/dist/modern/client/preview/config.js +0 -4
- package/dist/modern/client/preview/globals.js +0 -5
- package/dist/modern/client/preview/index.js +0 -24
- package/dist/modern/client/preview/render.js +0 -97
- package/dist/modern/client/preview/types.js +0 -1
- package/dist/modern/lib/compiler/index.js +0 -12
- package/dist/modern/lib/compiler/stringifier.js +0 -83
- package/dist/modern/lib/compiler/types.js +0 -0
- package/dist/modern/server/build.js +0 -3
- package/dist/modern/server/framework-preset-server.js +0 -18
- package/dist/modern/server/index.js +0 -3
- package/dist/modern/server/loader.js +0 -4
- package/dist/modern/server/options.js +0 -8
- package/dist/ts3.4/client/index.d.ts +0 -1
- package/dist/ts3.4/client/preview/config.d.ts +0 -4
- package/dist/ts3.4/client/preview/globals.d.ts +0 -1
- package/dist/ts3.4/client/preview/index.d.ts +0 -21
- package/dist/ts3.4/client/preview/render.d.ts +0 -5
- package/dist/ts3.4/client/preview/types.d.ts +0 -20
- package/dist/ts3.4/lib/compiler/index.d.ts +0 -2
- package/dist/ts3.4/lib/compiler/stringifier.d.ts +0 -7
- package/dist/ts3.4/lib/compiler/types.d.ts +0 -24
- package/dist/ts3.4/server/build.d.ts +0 -1
- package/dist/ts3.4/server/framework-preset-server.d.ts +0 -4
- package/dist/ts3.4/server/index.d.ts +0 -1
- package/dist/ts3.4/server/loader.d.ts +0 -2
- package/dist/ts3.4/server/options.d.ts +0 -3
- package/dist/ts3.9/client/index.d.ts +0 -1
- package/dist/ts3.9/client/preview/config.d.ts +0 -4
- package/dist/ts3.9/client/preview/globals.d.ts +0 -1
- package/dist/ts3.9/client/preview/index.d.ts +0 -21
- package/dist/ts3.9/client/preview/render.d.ts +0 -5
- package/dist/ts3.9/client/preview/types.d.ts +0 -20
- package/dist/ts3.9/lib/compiler/index.d.ts +0 -2
- package/dist/ts3.9/lib/compiler/stringifier.d.ts +0 -7
- package/dist/ts3.9/lib/compiler/types.d.ts +0 -24
- package/dist/ts3.9/server/build.d.ts +0 -1
- package/dist/ts3.9/server/framework-preset-server.d.ts +0 -4
- package/dist/ts3.9/server/index.d.ts +0 -1
- package/dist/ts3.9/server/loader.d.ts +0 -2
- package/dist/ts3.9/server/options.d.ts +0 -3
- package/preset.js +0 -1
- package/standalone.js +0 -8
package/README.md
CHANGED
|
@@ -1,317 +1 @@
|
|
|
1
|
-
# Storybook
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
Storybook for Server is a UI development environment for your plain HTML snippets rendered by your server backend.
|
|
6
|
-
With it, you can visualize different states of your UI components and develop them interactively.
|
|
7
|
-
|
|
8
|
-

|
|
9
|
-
|
|
10
|
-
Storybook runs outside of your app.
|
|
11
|
-
So you can develop UI components in isolation without worrying about app specific dependencies and requirements.
|
|
12
|
-
|
|
13
|
-
## Getting Started
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
cd my-app
|
|
17
|
-
npx sb init -t server
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
To configure the server that Storybook will connect to, export a global parameter `parameters.server.url` in `.storybook/preview.js`:
|
|
21
|
-
|
|
22
|
-
```js
|
|
23
|
-
export const parameters = {
|
|
24
|
-
server: {
|
|
25
|
-
url: `http://localhost:${port}/storybook_preview`,
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The URL you connect to should have the ability to render a story, see [server rendering](#server-rendering) below.
|
|
31
|
-
|
|
32
|
-
For more information visit: [storybook.js.org](https://storybook.js.org)
|
|
33
|
-
|
|
34
|
-
## Writing Stories
|
|
35
|
-
|
|
36
|
-
To write a story, use whatever API is natural for your server-side rendering framework to generate set of JSON or YAML files of stories analogous to CSF files (see the [`server-kitchen-sink`](../../examples/server-kitchen-sink/stories) example for ideas).
|
|
37
|
-
|
|
38
|
-
```json
|
|
39
|
-
{
|
|
40
|
-
"title": "Component",
|
|
41
|
-
"parameters": {
|
|
42
|
-
"options": { "component": "my_widget" }
|
|
43
|
-
},
|
|
44
|
-
"stories": [
|
|
45
|
-
{
|
|
46
|
-
"name": "Default",
|
|
47
|
-
"parameters": {
|
|
48
|
-
"server": { "id": "path/of/your/story" }
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
In your `.storybook/main.js` you simply provide a glob specifying the location of those JSON files, e.g.
|
|
56
|
-
|
|
57
|
-
```js
|
|
58
|
-
module.exports = {
|
|
59
|
-
stories: ['../stories/**/*.stories.json'],
|
|
60
|
-
};
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Notice that the JSON does not specify a rendering function -- `@storybook/server` will instead call your `parameters.server.url` with the story's server id appended.
|
|
64
|
-
|
|
65
|
-
For example the JSON story above is requivalent to the CSF3 definition:
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
export default {
|
|
69
|
-
title: 'Component',
|
|
70
|
-
parameters: {
|
|
71
|
-
options: {
|
|
72
|
-
component: 'my_widget',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const Default = {
|
|
78
|
-
name: 'Default',
|
|
79
|
-
parameters: {
|
|
80
|
-
server: {
|
|
81
|
-
id: 'path/of/your/story"',
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
With the story HTML will be fetched from the server by making a GET request to http://localhost/storybook_preview/path/of/your/story`
|
|
88
|
-
|
|
89
|
-
### Ruby/Rails support
|
|
90
|
-
|
|
91
|
-
In particular the [View Component::Storybook](https://github.com/jonspalmer/view_component_storybook) gem provides a Ruby API for easily creating the above with a Ruby/Rails DSL (as well as providing a server rendering endpoint).
|
|
92
|
-
|
|
93
|
-
## Server rendering
|
|
94
|
-
|
|
95
|
-
The server rendering side of things is relatively straightfoward. When you browse to a story in the sidebar, Storybook will make a `fetch` request to `${parameters.server.url}/{parameters.server.id}` and display the HTML that is returned.
|
|
96
|
-
|
|
97
|
-
You need to ensure the route in your server app renders the appropriate HTML when called in that fashion.
|
|
98
|
-
|
|
99
|
-
### Passing parameters to the server
|
|
100
|
-
|
|
101
|
-
Many components are likely to be dynamic - responding to parameters that change their content or appearance. `@storybook\server` has two mechanisms for passing those parameters to the server - `params` and `args`. Parameters defined in this way are appended to the fetch url as query string parameters. The server endpoint is responsible for interpreting those parameters and vary the returned html appropriately
|
|
102
|
-
|
|
103
|
-
#### Constant parameters with `params`
|
|
104
|
-
|
|
105
|
-
Static parameters can be defined using the `params` story parameter. For example suppose you have a Button component that has a label and color options:
|
|
106
|
-
|
|
107
|
-
```json
|
|
108
|
-
{
|
|
109
|
-
"title": "Buttons",
|
|
110
|
-
"stories": [
|
|
111
|
-
{
|
|
112
|
-
"name": "Red",
|
|
113
|
-
"parameters": {
|
|
114
|
-
"server": {
|
|
115
|
-
"id": "button",
|
|
116
|
-
"params": { "color": "red", "label": "Stop" }
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"name": "Green",
|
|
122
|
-
"parameters": {
|
|
123
|
-
"server": {
|
|
124
|
-
"id": "button",
|
|
125
|
-
"params": { "color": "green", "label": "OK" }
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
The Red and Green story HTML will be fetched from the urls `server.url/controls/button?color=red&label=Stop` and `server.url/controls/button?color=green&label=OK`
|
|
134
|
-
|
|
135
|
-
Like all story parameters server params can be defined in the default export and overridden in stories.
|
|
136
|
-
|
|
137
|
-
```json
|
|
138
|
-
{
|
|
139
|
-
"title": "Buttons",
|
|
140
|
-
"parameters": {
|
|
141
|
-
"server": {
|
|
142
|
-
"params": { "color": "red" }
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
"stories": [
|
|
146
|
-
{
|
|
147
|
-
"name": "Default",
|
|
148
|
-
"parameters": {
|
|
149
|
-
"server": {
|
|
150
|
-
"id": "button",
|
|
151
|
-
"params": { "label": "Stop" }
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
"name": "Green",
|
|
157
|
-
"parameters": {
|
|
158
|
-
"server": {
|
|
159
|
-
"id": "button",
|
|
160
|
-
"params": { "color": "green", "label": "OK" }
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
#### Dynamic parameters with `args` and Controls
|
|
169
|
-
|
|
170
|
-
Dynamic parameters can be defined using args and the Controls addon
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{
|
|
174
|
-
"title": "Buttons",
|
|
175
|
-
"stories": [
|
|
176
|
-
{
|
|
177
|
-
"name": "Red",
|
|
178
|
-
"parameters": {
|
|
179
|
-
"server": {
|
|
180
|
-
"id": "button"
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
"args": { "color": "red", "label": "Stop" }
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
"name": "Green",
|
|
187
|
-
"parameters": {
|
|
188
|
-
"server": {
|
|
189
|
-
"id": "button"
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
"args": { "color": "green", "label": "Go" }
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
Story args are passed to the server as url query parameters just like `params` except now they can be varied on the Controls addon panel.
|
|
199
|
-
|
|
200
|
-
Just like CSF stories we can define `argTypes` to specify the controls used in the controls panel. `argTypes` can be defined at the default or story level.
|
|
201
|
-
|
|
202
|
-
```json
|
|
203
|
-
{
|
|
204
|
-
"title": "Buttons",
|
|
205
|
-
"argTypes": {
|
|
206
|
-
"color": { "control": { "type": "color" } }
|
|
207
|
-
},
|
|
208
|
-
"stories": [
|
|
209
|
-
{
|
|
210
|
-
"name": "Red",
|
|
211
|
-
"parameters": {
|
|
212
|
-
"server": {
|
|
213
|
-
"id": "button"
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
"args": { "color": "red", "label": "Stop" }
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"name": "Green",
|
|
220
|
-
"parameters": {
|
|
221
|
-
"server": {
|
|
222
|
-
"id": "button"
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
"args": { "color": "green", "label": "Go" }
|
|
226
|
-
}
|
|
227
|
-
]
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Addon compatibility
|
|
232
|
-
|
|
233
|
-
Storybook also comes with a lot of [addons](https://storybook.js.org/addons) and a great API to customize as you wish. As some addons assume the story is rendered in JS, they may not work with `@storybook/server` (yet!).
|
|
234
|
-
|
|
235
|
-
Many addons that act on the manager side (such as `backgrounds` and `viewport`) will work out of the box with `@storybook/server` -- you can configure them with parameters written on the server as usual.
|
|
236
|
-
|
|
237
|
-
### Controls
|
|
238
|
-
|
|
239
|
-
To configure controls, simple add `args` and `argTypes` keys to the story JSON much like you would CSF:
|
|
240
|
-
|
|
241
|
-
```json
|
|
242
|
-
{
|
|
243
|
-
"title": "Controls",
|
|
244
|
-
"stories": [
|
|
245
|
-
{
|
|
246
|
-
"name": "Button",
|
|
247
|
-
"parameters": {
|
|
248
|
-
"server": { "id": "controls/button" }
|
|
249
|
-
},
|
|
250
|
-
"args": { "button_text": "Push Me", "color": "red" },
|
|
251
|
-
"argTypes": { "button_text": { "control": { "type": "color" } } }
|
|
252
|
-
}
|
|
253
|
-
]
|
|
254
|
-
}
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
The controls values will be added to your story URL as query parameters.
|
|
258
|
-
|
|
259
|
-
### Actions
|
|
260
|
-
|
|
261
|
-
To use actions, use the `parameters.actions.handles` parameter:
|
|
262
|
-
|
|
263
|
-
```json
|
|
264
|
-
{
|
|
265
|
-
"title": "Actions",
|
|
266
|
-
"stories": [
|
|
267
|
-
{
|
|
268
|
-
"name": "Button",
|
|
269
|
-
"parameters": {
|
|
270
|
-
"server": { "id": "actions/button" },
|
|
271
|
-
"actions": {
|
|
272
|
-
"handles": ["mouseover", "click .btn"]
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
]
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
## Advanced Configuration
|
|
281
|
-
|
|
282
|
-
### fetchStoryHtml
|
|
283
|
-
|
|
284
|
-
For control over how `@storybook/server` fetches Html from the server you can provide a `fetchStoryHtml` function as a parameter. You would typically set this in `.storybook/preview.js` but it's just a regular Storybook parameter so could be overridden at the stories or story level.
|
|
285
|
-
|
|
286
|
-
```javascript
|
|
287
|
-
// .storybook/preview.js
|
|
288
|
-
|
|
289
|
-
const fetchStoryHtml = async (url, path, params, context) => {
|
|
290
|
-
// Custom fetch implementation
|
|
291
|
-
// ....
|
|
292
|
-
return html;
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
export const parameters = {
|
|
296
|
-
server: {
|
|
297
|
-
url: `http://localhost:${port}/storybook_preview`,
|
|
298
|
-
fetchStoryHtml,
|
|
299
|
-
},
|
|
300
|
-
};
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
`fetchStoryHtml` should be an async function with the following signature
|
|
304
|
-
|
|
305
|
-
```javascript
|
|
306
|
-
type FetchStoryHtmlType = (
|
|
307
|
-
url: string,
|
|
308
|
-
id: string,
|
|
309
|
-
params: any,
|
|
310
|
-
context: StoryContext
|
|
311
|
-
) => Promise<string | Node>;
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
- url: Server url configured by the `parameters.server.url`
|
|
315
|
-
- id: Id of the story being rendered given by `parameters.server.id`
|
|
316
|
-
- params: Merged story params `parameters.server.params`and story args
|
|
317
|
-
- context: The context of the story
|
|
1
|
+
# Storybook Server renderer
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var h=Object.defineProperty;var l=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var y=(r,t,e)=>t in r?h(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,n=(r,t)=>{for(var e in t||(t={}))T.call(t,e)&&y(r,e,t[e]);if(l)for(var e of l(t))x.call(t,e)&&y(r,e,t[e]);return r};var f=(r,t)=>h(r,"name",{value:t,configurable:!0});import C from"global";import D from"ts-dedent";import{simulatePageLoad as U,simulateDOMContentLoaded as $}from"@storybook/preview-web";var{fetch:A,Node:I}=C,P=f(async(r,t,e,o)=>{let s=new URL(`${r}/${t}`);return s.search=new URLSearchParams(n(n({},o.globals),e)).toString(),(await A(s)).text()},"defaultFetchStoryHtml"),j=f((r,t)=>{let e=n({},r);return Object.keys(t).forEach(o=>{let s=t[o],{control:a}=s,d=a&&a.type.toLowerCase(),p=e[o];switch(d){case"date":e[o]=new Date(p).toISOString();break;case"object":e[o]=JSON.stringify(p);break;default:}}),e},"buildStoryArgs"),k=f(r=>{},"render");async function q({id:r,title:t,name:e,showMain:o,showError:s,forceRemount:a,storyFn:d,storyContext:p,storyContext:{parameters:g,args:u,argTypes:L}},c){d();let m=j(u,L),{server:{url:w,id:S,fetchStoryHtml:b=P,params:M}}=g,H=S||r,O=n(n({},M),m),i=await b(w,H,O,p);if(o(),typeof i=="string")c.innerHTML=i,U(c);else if(i instanceof I){if(c.firstChild===i&&a===!1)return;c.innerHTML="",c.appendChild(i),$()}else s({title:`Expecting an HTML snippet or DOM node from the story: "${e}" of "${t}".`,description:D`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}f(q,"renderToDOM");export{f as a,k as b,q as c};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RenderContext } from '@storybook/store';
|
|
2
|
+
import { a as StoryFn, S as ServerFramework } from './public-types-07d4abb5.js';
|
|
3
|
+
import '@storybook/csf';
|
|
4
|
+
|
|
5
|
+
declare const render: StoryFn<ServerFramework>;
|
|
6
|
+
declare function renderToDOM({ id, title, name, showMain, showError, forceRemount, storyFn, storyContext, storyContext: { parameters, args, argTypes }, }: RenderContext<ServerFramework>, domElement: Element): Promise<void>;
|
|
7
|
+
|
|
8
|
+
declare const parameters: {
|
|
9
|
+
framework: "server";
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { parameters, render, renderToDOM };
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var P=Object.create;var n=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,N=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var g=(t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,a=(t,e)=>{for(var r in e||(e={}))u.call(e,r)&&g(t,r,e[r]);if(h)for(var r of h(e))R.call(e,r)&&g(t,r,e[r]);return t};var p=(t,e)=>n(t,"name",{value:e,configurable:!0});var k=(t,e)=>{for(var r in e)n(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of v(e))!u.call(t,o)&&o!==r&&n(t,o,{get:()=>e[o],enumerable:!(s=j(e,o))||s.enumerable});return t};var w=(t,e,r)=>(r=t!=null?P(N(t)):{},m(e||!t||!t.__esModule?n(r,"default",{value:t,enumerable:!0}):r,t)),F=t=>m(n({},"__esModule",{value:!0}),t);var K={};k(K,{parameters:()=>G,render:()=>S,renderToDOM:()=>b});module.exports=F(K);var L=w(require("global")),M=w(require("ts-dedent")),l=require("@storybook/preview-web"),{fetch:V,Node:q}=L.default,z=p(async(t,e,r,s)=>{let o=new URL(`${t}/${e}`);return o.search=new URLSearchParams(a(a({},s.globals),r)).toString(),(await V(o)).text()},"defaultFetchStoryHtml"),B=p((t,e)=>{let r=a({},t);return Object.keys(e).forEach(s=>{let o=e[s],{control:c}=o,y=c&&c.type.toLowerCase(),d=r[s];switch(y){case"date":r[s]=new Date(d).toISOString();break;case"object":r[s]=JSON.stringify(d);break;default:}}),r},"buildStoryArgs"),S=p(t=>{},"render");async function b({id:t,title:e,name:r,showMain:s,showError:o,forceRemount:c,storyFn:y,storyContext:d,storyContext:{parameters:x,args:O,argTypes:T}},i){y();let D=B(O,T),{server:{url:H,id:C,fetchStoryHtml:U=z,params:$}}=x,A=C||t,I=a(a({},$),D),f=await U(H,A,I,d);if(s(),typeof f=="string")i.innerHTML=f,(0,l.simulatePageLoad)(i);else if(f instanceof q){if(i.firstChild===f&&c===!1)return;i.innerHTML="",i.appendChild(f),(0,l.simulateDOMContentLoaded)()}else o({title:`Expecting an HTML snippet or DOM node from the story: "${r}" of "${e}".`,description:M.default`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}p(b,"renderToDOM");var G={framework:"server"};0&&(module.exports={parameters,render,renderToDOM});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as r,c as e}from"./chunk-43Y6KZXY.mjs";var a={framework:"server"};export{a as parameters,r as render,e as renderToDOM};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as lib_store_dist_types from 'lib/store/dist/types';
|
|
2
|
+
import * as lib_client_api_dist_types_ClientApi from 'lib/client-api/dist/types/ClientApi';
|
|
3
|
+
import * as _storybook_csf from '@storybook/csf';
|
|
4
|
+
export { ArgTypes, Args, Parameters, StoryContext } from '@storybook/csf';
|
|
5
|
+
import * as _storybook_addons from '@storybook/addons';
|
|
6
|
+
import { ClientStoryApi, Loadable } from '@storybook/addons';
|
|
7
|
+
import { S as ServerFramework, I as IStorybookSection } from './public-types-07d4abb5.js';
|
|
8
|
+
export { M as Meta, c as Story, a as StoryFn, b as StoryObj } from './public-types-07d4abb5.js';
|
|
9
|
+
|
|
10
|
+
interface ClientApi extends ClientStoryApi<ServerFramework['storyResult']> {
|
|
11
|
+
setAddon(addon: any): void;
|
|
12
|
+
configure(loader: Loadable, module: NodeModule): void;
|
|
13
|
+
getStorybook(): IStorybookSection[];
|
|
14
|
+
clearDecorators(): void;
|
|
15
|
+
forceReRender(): void;
|
|
16
|
+
raw: () => any;
|
|
17
|
+
}
|
|
18
|
+
declare const storiesOf: ClientApi['storiesOf'];
|
|
19
|
+
declare const configure: ClientApi['configure'];
|
|
20
|
+
declare const addDecorator: (() => never) | ((decorator: _storybook_csf.DecoratorFunction<ServerFramework, _storybook_addons.Args>) => void);
|
|
21
|
+
declare const addParameters: (() => never) | (({ globals, globalTypes, ...parameters }: _storybook_csf.Parameters & {
|
|
22
|
+
globals?: _storybook_csf.Globals;
|
|
23
|
+
globalTypes?: _storybook_csf.GlobalTypes;
|
|
24
|
+
}) => void);
|
|
25
|
+
declare const clearDecorators: (() => never) | (() => void);
|
|
26
|
+
declare const setAddon: (() => never) | ((addon: any) => void);
|
|
27
|
+
declare const getStorybook: (() => never) | (() => lib_client_api_dist_types_ClientApi.GetStorybookKind<ServerFramework>[]);
|
|
28
|
+
declare const raw: (() => never) | (() => lib_store_dist_types.BoundStory<ServerFramework>[]);
|
|
29
|
+
declare const forceReRender: (() => never) | (() => void);
|
|
30
|
+
|
|
31
|
+
export { addDecorator, addParameters, clearDecorators, configure, forceReRender, getStorybook, raw, setAddon, storiesOf };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var v=Object.create;var a=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,K=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var w=(t,r,o)=>r in t?a(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,c=(t,r)=>{for(var o in r||(r={}))O.call(r,o)&&w(t,o,r[o]);if(h)for(var o of h(r))W.call(r,o)&&w(t,o,r[o]);return t};var s=(t,r)=>a(t,"name",{value:r,configurable:!0});var B=(t,r)=>{for(var o in r)a(t,o,{get:r[o],enumerable:!0})},x=(t,r,o,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of F(r))!O.call(t,e)&&e!==o&&a(t,e,{get:()=>r[e],enumerable:!(n=E(r,e))||n.enumerable});return t};var y=(t,r,o)=>(o=t!=null?v(K(t)):{},x(r||!t||!t.__esModule?a(o,"default",{value:t,enumerable:!0}):o,t)),J=t=>x(a({},"__esModule",{value:!0}),t);var at={};B(at,{addDecorator:()=>Z,addParameters:()=>tt,clearDecorators:()=>rt,configure:()=>X,forceReRender:()=>st,getStorybook:()=>et,raw:()=>nt,setAddon:()=>ot,storiesOf:()=>Q});module.exports=J(at);var S=y(require("global")),{window:Y}=S.default;Y.STORYBOOK_ENV="SERVER";var D=require("@storybook/core-client");var b=y(require("global")),L=y(require("ts-dedent")),m=require("@storybook/preview-web"),{fetch:_,Node:q}=b.default,z=s(async(t,r,o,n)=>{let e=new URL(`${t}/${r}`);return e.search=new URLSearchParams(c(c({},n.globals),o)).toString(),(await _(e)).text()},"defaultFetchStoryHtml"),G=s((t,r)=>{let o=c({},t);return Object.keys(r).forEach(n=>{let e=r[n],{control:i}=e,u=i&&i.type.toLowerCase(),d=o[n];switch(u){case"date":o[n]=new Date(d).toISOString();break;case"object":o[n]=JSON.stringify(d);break;default:}}),o},"buildStoryArgs"),M=s(t=>{},"render");async function R({id:t,title:r,name:o,showMain:n,showError:e,forceRemount:i,storyFn:u,storyContext:d,storyContext:{parameters:H,args:C,argTypes:P}},f){u();let U=G(C,P),{server:{url:$,id:I,fetchStoryHtml:N=z,params:V}}=H,j=I||t,k=c(c({},V),U),p=await N($,j,k,d);if(n(),typeof p=="string")f.innerHTML=p,(0,m.simulatePageLoad)(f);else if(p instanceof q){if(f.firstChild===p&&i===!1)return;f.innerHTML="",f.appendChild(p),(0,m.simulateDOMContentLoaded)()}else e({title:`Expecting an HTML snippet or DOM node from the story: "${o}" of "${r}".`,description:L.default`
|
|
2
|
+
Did you forget to return the HTML snippet from the story?
|
|
3
|
+
Use "() => <your snippet or node>" or when defining the story.
|
|
4
|
+
`})}s(R,"renderToDOM");var T="server",g=(0,D.start)(R,{render:M}),Q=s((t,r)=>g.clientApi.storiesOf(t,r).addParameters({framework:T}),"storiesOf"),X=s((...t)=>g.configure(T,...t),"configure"),{addDecorator:Z,addParameters:tt,clearDecorators:rt,setAddon:ot,getStorybook:et,raw:nt}=g.clientApi,{forceReRender:st}=g;var A;(A=module==null?void 0:module.hot)==null||A.decline();0&&(module.exports={addDecorator,addParameters,clearDecorators,configure,forceReRender,getStorybook,raw,setAddon,storiesOf});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as s,c as a}from"./chunk-43Y6KZXY.mjs";import p from"global";var{window:m}=p;m.STORYBOOK_ENV="SERVER";import{start as f}from"@storybook/core-client";var c="server",o=f(a,{render:s}),R=e((r,d)=>o.clientApi.storiesOf(r,d).addParameters({framework:c}),"storiesOf"),g=e((...r)=>o.configure(c,...r),"configure"),{addDecorator:w,addParameters:u,clearDecorators:A,setAddon:E,getStorybook:b,raw:D}=o.clientApi,{forceReRender:S}=o;var i;(i=module==null?void 0:module.hot)==null||i.decline();export{w as addDecorator,u as addParameters,A as clearDecorators,g as configure,S as forceReRender,b as getStorybook,D as raw,E as setAddon,R as storiesOf};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations } from '@storybook/csf';
|
|
2
|
+
|
|
3
|
+
declare type StoryFnServerReturnType = any;
|
|
4
|
+
declare type ServerFramework = {
|
|
5
|
+
component: string;
|
|
6
|
+
storyResult: StoryFnServerReturnType;
|
|
7
|
+
};
|
|
8
|
+
interface IStorybookStory {
|
|
9
|
+
name: string;
|
|
10
|
+
render: (context: any) => any;
|
|
11
|
+
}
|
|
12
|
+
interface IStorybookSection {
|
|
13
|
+
kind: string;
|
|
14
|
+
stories: IStorybookStory[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Metadata to configure the stories for a component.
|
|
19
|
+
*
|
|
20
|
+
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
|
|
21
|
+
*/
|
|
22
|
+
declare type Meta<TArgs = Args> = ComponentAnnotations<ServerFramework, TArgs>;
|
|
23
|
+
/**
|
|
24
|
+
* Story function that represents a CSFv2 component example.
|
|
25
|
+
*
|
|
26
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
27
|
+
*/
|
|
28
|
+
declare type StoryFn<TArgs = Args> = AnnotatedStoryFn<ServerFramework, TArgs>;
|
|
29
|
+
/**
|
|
30
|
+
* Story function that represents a CSFv3 component example.
|
|
31
|
+
*
|
|
32
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
33
|
+
*/
|
|
34
|
+
declare type StoryObj<TArgs = Args> = StoryAnnotations<ServerFramework, TArgs>;
|
|
35
|
+
/**
|
|
36
|
+
* Story function that represents a CSFv3 component example.
|
|
37
|
+
*
|
|
38
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
39
|
+
*/
|
|
40
|
+
declare type Story<TArgs = Args> = StoryObj<TArgs>;
|
|
41
|
+
|
|
42
|
+
export { IStorybookSection as I, Meta as M, ServerFramework as S, StoryFn as a, StoryObj as b, Story as c };
|
package/package.json
CHANGED
|
@@ -1,74 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/server",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Storybook
|
|
3
|
+
"version": "7.0.0-alpha.10",
|
|
4
|
+
"description": "Storybook Server renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
7
7
|
],
|
|
8
|
-
"homepage": "https://github.com/storybookjs/storybook/tree/main/
|
|
8
|
+
"homepage": "https://github.com/storybookjs/storybook/tree/main/renderers/server",
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/storybookjs/storybook/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": "https://github.com/storybookjs/storybook.git",
|
|
15
|
-
"directory": "
|
|
15
|
+
"directory": "renderers/server"
|
|
16
16
|
},
|
|
17
17
|
"funding": {
|
|
18
18
|
"type": "opencollective",
|
|
19
19
|
"url": "https://opencollective.com/storybook"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.js",
|
|
25
|
+
"import": "./dist/index.mjs",
|
|
26
|
+
"types": "./dist/index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./preview": {
|
|
29
|
+
"require": "./dist/config.js",
|
|
30
|
+
"import": "./dist/config.mjs",
|
|
31
|
+
"types": "./dist/config.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./package.json": {
|
|
34
|
+
"require": "./package.json",
|
|
35
|
+
"import": "./package.json",
|
|
36
|
+
"types": "./package.json"
|
|
30
37
|
}
|
|
31
38
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"storybook-server": "./bin/index.js"
|
|
36
|
-
},
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
37
42
|
"files": [
|
|
38
|
-
"bin/**/*",
|
|
39
43
|
"dist/**/*",
|
|
40
44
|
"README.md",
|
|
41
45
|
"*.js",
|
|
42
46
|
"*.d.ts"
|
|
43
47
|
],
|
|
44
48
|
"scripts": {
|
|
45
|
-
"prepare": "
|
|
49
|
+
"prepare": "esrun ../../scripts/prepare/bundle.ts"
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
|
-
"@storybook/addons": "
|
|
49
|
-
"@storybook/
|
|
50
|
-
"@storybook/client-api": "6.5.9",
|
|
51
|
-
"@storybook/core": "6.5.9",
|
|
52
|
-
"@storybook/core-common": "6.5.9",
|
|
52
|
+
"@storybook/addons": "7.0.0-alpha.10",
|
|
53
|
+
"@storybook/core-client": "7.0.0-alpha.10",
|
|
53
54
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
54
|
-
"@storybook/
|
|
55
|
-
"@storybook/
|
|
56
|
-
"@storybook/store": "6.5.9",
|
|
57
|
-
"@types/node": "^14.14.20 || ^16.0.0",
|
|
58
|
-
"@types/webpack-env": "^1.16.0",
|
|
55
|
+
"@storybook/preview-web": "7.0.0-alpha.10",
|
|
56
|
+
"@storybook/store": "7.0.0-alpha.10",
|
|
59
57
|
"core-js": "^3.8.2",
|
|
60
58
|
"global": "^4.4.0",
|
|
61
59
|
"react": "16.14.0",
|
|
62
60
|
"react-dom": "16.14.0",
|
|
63
|
-
"
|
|
64
|
-
"regenerator-runtime": "^0.13.7",
|
|
65
|
-
"safe-identifier": "^0.4.1",
|
|
66
|
-
"ts-dedent": "^2.0.0",
|
|
67
|
-
"yaml-loader": "^0.6.0"
|
|
61
|
+
"ts-dedent": "^2.0.0"
|
|
68
62
|
},
|
|
69
63
|
"devDependencies": {
|
|
70
|
-
"
|
|
71
|
-
"yaml": "^1.10.0"
|
|
64
|
+
"@digitak/esrun": "^3.2.2"
|
|
72
65
|
},
|
|
73
66
|
"engines": {
|
|
74
67
|
"node": ">=10.13.0"
|
|
@@ -76,6 +69,9 @@
|
|
|
76
69
|
"publishConfig": {
|
|
77
70
|
"access": "public"
|
|
78
71
|
},
|
|
79
|
-
"
|
|
80
|
-
|
|
72
|
+
"bundlerEntrypoint": [
|
|
73
|
+
"./src/index.ts",
|
|
74
|
+
"./src/config.ts"
|
|
75
|
+
],
|
|
76
|
+
"gitHead": "b13dd8fb52819d73d4983148af8ffc5d683e8b75"
|
|
81
77
|
}
|
package/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/config';
|
package/bin/build.js
DELETED
package/bin/index.js
DELETED
package/dist/cjs/client/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "addDecorator", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _preview.addDecorator;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "addParameters", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _preview.addParameters;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "configure", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _preview.configure;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "forceReRender", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _preview.forceReRender;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "getStorybook", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _preview.getStorybook;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "raw", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _preview.raw;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
Object.defineProperty(exports, "setAddon", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _preview.setAddon;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
Object.defineProperty(exports, "storiesOf", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function get() {
|
|
51
|
-
return _preview.storiesOf;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
var _preview = require("./preview");
|
|
56
|
-
|
|
57
|
-
if (module && module.hot && module.hot.decline) {
|
|
58
|
-
module.hot.decline();
|
|
59
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parameters = void 0;
|
|
7
|
-
Object.defineProperty(exports, "render", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _render.render;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(exports, "renderToDOM", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _render.renderToDOM;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _render = require("./render");
|
|
21
|
-
|
|
22
|
-
var parameters = {
|
|
23
|
-
framework: 'server'
|
|
24
|
-
};
|
|
25
|
-
exports.parameters = parameters;
|