@storybook/sveltekit 8.0.0-alpha.0 → 8.0.0-alpha.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.
- package/README.md +0 -10
- package/dist/{index-4b5cffbe.d.ts → index-82e4147f.d.ts} +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +1 -1
- package/package.json +6 -6
- package/template/stories_svelte-kit-prerelease-ts/forms.stories.js +26 -0
- package/template/stories_svelte-kit-prerelease-ts/hrefs.stories.js +53 -0
- package/template/stories_svelte-kit-prerelease-ts/navigation.stories.js +84 -0
- package/template/stories_svelte-kit-prerelease-ts/stores.stories.js +116 -0
- package/template/stories_svelte-kit-prerelease-ts/ts-docs.stories.js +12 -0
package/README.md
CHANGED
|
@@ -185,16 +185,6 @@ export const MyStory = {
|
|
|
185
185
|
|
|
186
186
|
You'll get this error when manually upgrading from 6.5 to 7.0. You need to remove the `svelteOptions` property in `.storybook/main.js`, as that is not supported by Storybook 7.0 + SvelteKit. The property is also not necessary anymore because the Vite and Svelte configurations are loaded automatically in Storybook 7.0.
|
|
187
187
|
|
|
188
|
-
### Error: `Cannot read properties of undefined (reading 'disable_scroll_handling')` in preview
|
|
189
|
-
|
|
190
|
-
> Some stories don't load, instead they show the following error in the preview:
|
|
191
|
-
>
|
|
192
|
-
> ```
|
|
193
|
-
> Cannot read properties of undefined (reading 'disable_scroll_handling')
|
|
194
|
-
> ```
|
|
195
|
-
|
|
196
|
-
You'll experience this if anything in your story is importing from `$app/forms` or `$app/navigation`, which is currently not supported. To get around this, separate your component into a shallow parent component that imports what's needed and passes it to a child component via props. This way you can write stories for your child component and mock any of the necessary modules by passing props in.
|
|
197
|
-
|
|
198
188
|
## Acknowledgements
|
|
199
189
|
|
|
200
190
|
Integrating with SvelteKit would not have been possible if it weren't for the fantastic efforts by the Svelte core team - especially [Ben McCann](https://twitter.com/benjaminmccann) - to make integrations with the wider ecosystem possible.
|
|
@@ -2823,6 +2823,7 @@ interface CLIOptions {
|
|
|
2823
2823
|
enableCrashReports?: boolean;
|
|
2824
2824
|
host?: string;
|
|
2825
2825
|
initialPath?: string;
|
|
2826
|
+
exactPort?: boolean;
|
|
2826
2827
|
/**
|
|
2827
2828
|
* @deprecated Use 'staticDirs' Storybook Configuration option instead
|
|
2828
2829
|
*/
|
|
@@ -3007,6 +3008,10 @@ interface StorybookConfigRaw {
|
|
|
3007
3008
|
* This will make sure that your story renders the same no matter if docgen is enabled or not.
|
|
3008
3009
|
*/
|
|
3009
3010
|
disallowImplicitActionsInRenderV8?: boolean;
|
|
3011
|
+
/**
|
|
3012
|
+
* Enable asynchronous component rendering in NextJS framework
|
|
3013
|
+
*/
|
|
3014
|
+
experimentalNextRSC?: boolean;
|
|
3010
3015
|
};
|
|
3011
3016
|
build?: TestBuildConfig;
|
|
3012
3017
|
stories: StoriesEntry[];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { F as FrameworkOptions, H as HrefConfig, N as NormalizedHrefConfig, S as StorybookConfig, a as SvelteKitParameters } from './index-
|
|
1
|
+
export { F as FrameworkOptions, H as HrefConfig, N as NormalizedHrefConfig, S as StorybookConfig, a as SvelteKitParameters } from './index-82e4147f.js';
|
|
2
2
|
import '@storybook/builder-vite';
|
|
3
3
|
import 'file-system-cache';
|
|
4
4
|
import '@babel/core';
|
package/dist/preset.d.ts
CHANGED
package/dist/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preset_exports={};__export(preset_exports,{core:()=>core,previewAnnotations:()=>previewAnnotations,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_preset=require("@storybook/svelte-vite/preset"),import_builder_vite=require("@storybook/builder-vite"),import_path=require("path");function configOverrides(){return{name:"storybook:sveltekit-overrides",apply:"build",config:()=>({build:{ssr:!1}})}}var import_node_path=require("path")
|
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var preset_exports={};__export(preset_exports,{core:()=>core,previewAnnotations:()=>previewAnnotations,viteFinal:()=>viteFinal});module.exports=__toCommonJS(preset_exports);var import_preset=require("@storybook/svelte-vite/preset"),import_builder_vite=require("@storybook/builder-vite"),import_path=require("path");function configOverrides(){return{name:"storybook:sveltekit-overrides",apply:"build",config:()=>({build:{ssr:!1}})}}var import_node_path=require("path");function mockSveltekitStores(){return{name:"storybook:sveltekit-mock-stores",config:()=>({resolve:{alias:{$app:(0,import_node_path.resolve)(__dirname,"../src/mocks/app/")}}})}}var getAbsolutePath=input=>(0,import_path.dirname)(require.resolve((0,import_path.join)(input,"package.json"))),core={builder:getAbsolutePath("@storybook/builder-vite"),renderer:getAbsolutePath("@storybook/svelte")},previewAnnotations=(entry=[])=>[...entry,(0,import_path.join)((0,import_path.dirname)(require.resolve("@storybook/sveltekit/package.json")),"dist/preview.mjs")],viteFinal=async(config,options)=>{let baseConfig=await(0,import_preset.viteFinal)(config,options),{plugins=[]}=baseConfig;return plugins=(await(0,import_builder_vite.withoutVitePlugins)(plugins,["vite-plugin-sveltekit-compile","vite-plugin-sveltekit-guard"])).concat(configOverrides()).concat(mockSveltekitStores()),{...baseConfig,plugins}};0&&(module.exports={core,previewAnnotations,viteFinal});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/sveltekit",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.2",
|
|
4
4
|
"description": "Storybook for SvelteKit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@storybook/addon-actions": "8.0.0-alpha.
|
|
57
|
-
"@storybook/builder-vite": "8.0.0-alpha.
|
|
58
|
-
"@storybook/svelte": "8.0.0-alpha.
|
|
59
|
-
"@storybook/svelte-vite": "8.0.0-alpha.
|
|
56
|
+
"@storybook/addon-actions": "8.0.0-alpha.2",
|
|
57
|
+
"@storybook/builder-vite": "8.0.0-alpha.2",
|
|
58
|
+
"@storybook/svelte": "8.0.0-alpha.2",
|
|
59
|
+
"@storybook/svelte-vite": "8.0.0-alpha.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "^18.0.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"vite": "^4.0.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"svelte": "^
|
|
67
|
+
"svelte": "^4.0.0 || ^5.0.0-next.16",
|
|
68
68
|
"vite": "^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Forms from './Forms.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/forms',
|
|
6
|
+
component: Forms,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const enhance = fn();
|
|
11
|
+
|
|
12
|
+
export const Enhance = {
|
|
13
|
+
async play({ canvasElement }) {
|
|
14
|
+
const canvas = within(canvasElement);
|
|
15
|
+
const button = canvas.getByText('enhance');
|
|
16
|
+
button.click();
|
|
17
|
+
expect(enhance).toHaveBeenCalled();
|
|
18
|
+
},
|
|
19
|
+
parameters: {
|
|
20
|
+
sveltekit_experimental: {
|
|
21
|
+
forms: {
|
|
22
|
+
enhance,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Hrefs from './Hrefs.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/hrefs',
|
|
6
|
+
component: Hrefs,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const DefaultActions = {
|
|
11
|
+
async play({ canvasElement }) {
|
|
12
|
+
const canvas = within(canvasElement);
|
|
13
|
+
// eslint-disable-next-line no-undef
|
|
14
|
+
const initialUrl = window.location.toString();
|
|
15
|
+
|
|
16
|
+
const basicHref = canvas.getByText('/basic-href');
|
|
17
|
+
basicHref.click();
|
|
18
|
+
|
|
19
|
+
const complexHref = canvas.getByText(
|
|
20
|
+
'/deep/nested/link?with=true&multiple-params=200#and-an-id'
|
|
21
|
+
);
|
|
22
|
+
complexHref.click();
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line no-undef
|
|
25
|
+
const finalUrl = window.location.toString();
|
|
26
|
+
expect(finalUrl).toBe(initialUrl);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const basicStringMatch = fn();
|
|
31
|
+
const noMatch = fn();
|
|
32
|
+
const exactStringMatch = fn();
|
|
33
|
+
const regexMatch = fn();
|
|
34
|
+
|
|
35
|
+
export const Callbacks = {
|
|
36
|
+
parameters: {
|
|
37
|
+
sveltekit_experimental: {
|
|
38
|
+
hrefs: {
|
|
39
|
+
'/basic-href': basicStringMatch,
|
|
40
|
+
'/basic': noMatch,
|
|
41
|
+
'/deep/nested/link?with=true&multiple-params=200#and-an-id': exactStringMatch,
|
|
42
|
+
'nested/link\\?with': { callback: regexMatch, asRegex: true },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
play: async (ctx) => {
|
|
47
|
+
await DefaultActions.play(ctx);
|
|
48
|
+
expect(basicStringMatch).toHaveBeenCalledTimes(1);
|
|
49
|
+
expect(noMatch).not.toHaveBeenCalled();
|
|
50
|
+
expect(exactStringMatch).toHaveBeenCalledTimes(1);
|
|
51
|
+
expect(regexMatch).toHaveBeenCalledTimes(1);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { expect, fn, within } from '@storybook/test';
|
|
2
|
+
import Navigation from './Navigation.svelte';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'stories/sveltekit/modules/navigation',
|
|
6
|
+
component: Navigation,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const goto = fn();
|
|
11
|
+
|
|
12
|
+
export const Goto = {
|
|
13
|
+
async play({ canvasElement }) {
|
|
14
|
+
const canvas = within(canvasElement);
|
|
15
|
+
const button = canvas.getByText('goto');
|
|
16
|
+
button.click();
|
|
17
|
+
expect(goto).toHaveBeenCalledWith('/storybook-goto');
|
|
18
|
+
},
|
|
19
|
+
parameters: {
|
|
20
|
+
sveltekit_experimental: {
|
|
21
|
+
navigation: {
|
|
22
|
+
goto,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const DefaultActions = {};
|
|
29
|
+
|
|
30
|
+
const invalidate = fn();
|
|
31
|
+
|
|
32
|
+
export const Invalidate = {
|
|
33
|
+
async play({ canvasElement }) {
|
|
34
|
+
const canvas = within(canvasElement);
|
|
35
|
+
const button = canvas.getByText('invalidate', { exact: true });
|
|
36
|
+
button.click();
|
|
37
|
+
expect(invalidate).toHaveBeenCalledWith('/storybook-invalidate');
|
|
38
|
+
},
|
|
39
|
+
parameters: {
|
|
40
|
+
sveltekit_experimental: {
|
|
41
|
+
navigation: {
|
|
42
|
+
invalidate,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const invalidateAll = fn();
|
|
49
|
+
|
|
50
|
+
export const InvalidateAll = {
|
|
51
|
+
async play({ canvasElement }) {
|
|
52
|
+
const canvas = within(canvasElement);
|
|
53
|
+
const button = canvas.getByText('invalidateAll');
|
|
54
|
+
button.click();
|
|
55
|
+
expect(invalidateAll).toHaveBeenCalledWith();
|
|
56
|
+
},
|
|
57
|
+
parameters: {
|
|
58
|
+
sveltekit_experimental: {
|
|
59
|
+
navigation: {
|
|
60
|
+
invalidateAll,
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const afterNavigateFn = fn();
|
|
67
|
+
|
|
68
|
+
export const AfterNavigate = {
|
|
69
|
+
async play() {
|
|
70
|
+
expect(afterNavigateFn).toHaveBeenCalledWith({ test: 'passed' });
|
|
71
|
+
},
|
|
72
|
+
args: {
|
|
73
|
+
afterNavigateFn,
|
|
74
|
+
},
|
|
75
|
+
parameters: {
|
|
76
|
+
sveltekit_experimental: {
|
|
77
|
+
navigation: {
|
|
78
|
+
afterNavigate: {
|
|
79
|
+
test: 'passed',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import Stores from './Stores.svelte';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'stories/sveltekit/modules/stores',
|
|
5
|
+
component: Stores,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const AllUndefined = {};
|
|
10
|
+
|
|
11
|
+
export const PageStore = {
|
|
12
|
+
parameters: {
|
|
13
|
+
sveltekit_experimental: {
|
|
14
|
+
stores: {
|
|
15
|
+
page: {
|
|
16
|
+
data: {
|
|
17
|
+
test: 'passed',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const NavigatingStore = {
|
|
26
|
+
parameters: {
|
|
27
|
+
sveltekit_experimental: {
|
|
28
|
+
stores: {
|
|
29
|
+
navigating: {
|
|
30
|
+
route: {
|
|
31
|
+
id: '/storybook',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const UpdatedStore = {
|
|
40
|
+
parameters: {
|
|
41
|
+
sveltekit_experimental: {
|
|
42
|
+
stores: {
|
|
43
|
+
updated: true,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const PageAndNavigatingStore = {
|
|
50
|
+
parameters: {
|
|
51
|
+
sveltekit_experimental: {
|
|
52
|
+
stores: {
|
|
53
|
+
page: {
|
|
54
|
+
data: {
|
|
55
|
+
test: 'passed',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
navigating: {
|
|
59
|
+
route: {
|
|
60
|
+
id: '/storybook',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const PageAndUpdatedStore = {
|
|
69
|
+
parameters: {
|
|
70
|
+
sveltekit_experimental: {
|
|
71
|
+
stores: {
|
|
72
|
+
page: {
|
|
73
|
+
data: {
|
|
74
|
+
test: 'passed',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
updated: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const NavigatingAndUpdatedStore = {
|
|
84
|
+
parameters: {
|
|
85
|
+
sveltekit_experimental: {
|
|
86
|
+
stores: {
|
|
87
|
+
navigating: {
|
|
88
|
+
route: {
|
|
89
|
+
id: '/storybook',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
updated: true,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const AllThreeStores = {
|
|
99
|
+
parameters: {
|
|
100
|
+
sveltekit_experimental: {
|
|
101
|
+
stores: {
|
|
102
|
+
page: {
|
|
103
|
+
data: {
|
|
104
|
+
test: 'passed',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
navigating: {
|
|
108
|
+
route: {
|
|
109
|
+
id: '/storybook',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
updated: true,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
};
|