storybook-framework-qwik 0.0.1 → 0.0.3
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/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/preset.d.ts +5 -0
- package/dist/preset.js +1 -2
- package/dist/preview.d.ts +4 -0
- package/dist/preview.js +25 -11
- package/dist/qwik-city-decorator.d.ts +3 -0
- package/dist/qwik-city-decorator.js +12 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.js +1 -0
- package/package.json +25 -17
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './types.js';
|
package/dist/preset.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { StorybookConfig } from '@storybook/builder-vite';
|
|
2
|
+
export declare const core: StorybookConfig['core'];
|
|
3
|
+
export declare const viteFinal: StorybookConfig['viteFinal'];
|
|
4
|
+
export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
|
|
5
|
+
export declare const previewHead: (head: string) => string;
|
package/dist/preset.js
CHANGED
|
@@ -2,10 +2,9 @@ import { mergeConfig } from 'vite';
|
|
|
2
2
|
import { QWIK_LOADER } from '@builder.io/qwik/loader';
|
|
3
3
|
export const core = {
|
|
4
4
|
builder: '@storybook/builder-vite',
|
|
5
|
-
renderer: '
|
|
5
|
+
renderer: 'storybook-framework-qwik',
|
|
6
6
|
};
|
|
7
7
|
export const viteFinal = async (defaultConfig, options) => {
|
|
8
|
-
console.log('VITE THING');
|
|
9
8
|
const config = mergeConfig(defaultConfig, {
|
|
10
9
|
build: {
|
|
11
10
|
target: 'es2020',
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ArgsStoryFn, RenderContext } from '@storybook/types';
|
|
2
|
+
import { QwikRenderer } from './types.js';
|
|
3
|
+
export declare const render: ArgsStoryFn<QwikRenderer<unknown>>;
|
|
4
|
+
export declare function renderToCanvas<T>({ storyFn, showMain, showError }: RenderContext<QwikRenderer<T>>, canvasElement: QwikRenderer<T>['canvasElement']): Promise<void>;
|
package/dist/preview.js
CHANGED
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import { render } from '@builder.io/qwik';
|
|
2
|
-
import { QwikCityMockProvider } from '@builder.io/qwik-city';
|
|
1
|
+
import { render as renderQwik } from '@builder.io/qwik';
|
|
3
2
|
import { jsx as _jsx } from '@builder.io/qwik/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return
|
|
3
|
+
// returns the Qwik component as a JSX element (</MyComponent>)
|
|
4
|
+
// If a story has a custom renderer, it will replace this function.
|
|
5
|
+
export const render = (args, context) => {
|
|
6
|
+
const { component } = context;
|
|
7
|
+
if (typeof component === 'function') {
|
|
8
|
+
return component(args, context.name);
|
|
9
|
+
}
|
|
10
|
+
return component;
|
|
12
11
|
};
|
|
13
|
-
export
|
|
12
|
+
export async function renderToCanvas({ storyFn, showMain, showError }, canvasElement) {
|
|
13
|
+
const container = document.createElement('div');
|
|
14
|
+
const tree = _jsx(storyFn, {}, 'qwik-story');
|
|
15
|
+
await renderQwik(container, tree);
|
|
16
|
+
canvasElement.childNodes.forEach((c) => c.remove());
|
|
17
|
+
canvasElement.append(container);
|
|
18
|
+
showMain();
|
|
19
|
+
}
|
|
20
|
+
// I don't know how to to HMR stuff correctly, and Vite seems to keep referencing old files when you make a change.
|
|
21
|
+
// Force a reload when vite notifies of an update as a dirty temporary workaround.
|
|
22
|
+
const viteHotMeta = import.meta.hot;
|
|
23
|
+
if (viteHotMeta) {
|
|
24
|
+
viteHotMeta.on('vite:afterUpdate', () => {
|
|
25
|
+
document.location.reload();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from '@builder.io/qwik/jsx-runtime';
|
|
2
|
+
import { QwikCityMockProvider } from '@builder.io/qwik-city';
|
|
3
|
+
/** Wraps story in QwikCityMockProvider */
|
|
4
|
+
export const qwikCityDecorator = (Story) => {
|
|
5
|
+
const storyNode = Story();
|
|
6
|
+
// equal to <QwikCityMockProvider><Story/></QwikCityMockProvider>
|
|
7
|
+
const tree = _jsx(QwikCityMockProvider, // avoid qwik-city types in return type
|
|
8
|
+
{
|
|
9
|
+
children: storyNode,
|
|
10
|
+
}, 'QwikCityMockProvider');
|
|
11
|
+
return tree;
|
|
12
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component } from '@builder.io/qwik';
|
|
2
|
+
import { WebRenderer } from '@storybook/types';
|
|
3
|
+
export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
|
|
4
|
+
import type { AnnotatedStoryFn, Args, ComponentAnnotations, StoryAnnotations, DecoratorFunction, LoaderFunction, StoryContext as GenericStoryContext, StrictArgs } from '@storybook/types';
|
|
5
|
+
export interface QwikRenderer<T> extends WebRenderer {
|
|
6
|
+
component: Component<T>;
|
|
7
|
+
storyResult: ReturnType<Component<T>>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Metadata to configure the stories for a component.
|
|
11
|
+
*
|
|
12
|
+
* @see [Default export](https://storybook.js.org/docs/formats/component-story-format/#default-export)
|
|
13
|
+
*/
|
|
14
|
+
export type Meta<TArgs = Args> = ComponentAnnotations<QwikRenderer<TArgs>, TArgs>;
|
|
15
|
+
/**
|
|
16
|
+
* Story function that represents a CSFv2 component example.
|
|
17
|
+
*
|
|
18
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
19
|
+
*/
|
|
20
|
+
export type StoryFn<TArgs = Args> = AnnotatedStoryFn<QwikRenderer<TArgs>, TArgs>;
|
|
21
|
+
/**
|
|
22
|
+
* Story function that represents a CSFv3 component example.
|
|
23
|
+
*
|
|
24
|
+
* @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
|
|
25
|
+
*/
|
|
26
|
+
export type StoryObj<TArgs = Args> = StoryAnnotations<QwikRenderer<TArgs>, TArgs>;
|
|
27
|
+
export type Decorator<TArgs = StrictArgs> = DecoratorFunction<QwikRenderer<TArgs>, TArgs>;
|
|
28
|
+
export type Loader<TArgs = StrictArgs> = LoaderFunction<QwikRenderer<TArgs>, TArgs>;
|
|
29
|
+
export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<QwikRenderer<TArgs>, TArgs>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "storybook-framework-qwik",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Storybook for Qwik: View Qwik components in isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
7
|
-
"
|
|
7
|
+
"hydration",
|
|
8
|
+
"resumable",
|
|
9
|
+
"qwik",
|
|
10
|
+
"reactive",
|
|
11
|
+
"framework",
|
|
12
|
+
"components",
|
|
13
|
+
"builder.io"
|
|
8
14
|
],
|
|
9
15
|
"type": "module",
|
|
10
16
|
"//": "not sure why dist/preview is needed, but it is",
|
|
@@ -29,14 +35,20 @@
|
|
|
29
35
|
"import": "./dist/preview.js",
|
|
30
36
|
"types": "./dist/preview.d.ts"
|
|
31
37
|
},
|
|
38
|
+
"./qwik-city-decorator": {
|
|
39
|
+
"require": "./dist/qwik-city-decorator.js",
|
|
40
|
+
"import": "./dist/qwik-city-decorator.js",
|
|
41
|
+
"types": "./dist/qwik-city-decorator.d.ts"
|
|
42
|
+
},
|
|
32
43
|
"./package.json": "./package.json"
|
|
33
44
|
},
|
|
34
|
-
"homepage": "
|
|
45
|
+
"homepage": "https://github.com/literalpie/storybook-framework-qwik",
|
|
35
46
|
"bugs": {
|
|
36
|
-
"
|
|
47
|
+
"url": "https://github.com/literalpie/storybook-framework-qwik"
|
|
37
48
|
},
|
|
38
49
|
"repository": {
|
|
39
50
|
"type": "git",
|
|
51
|
+
"url": "https://github.com/literalpie/storybook-framework-qwik.git",
|
|
40
52
|
"directory": "app/qwik"
|
|
41
53
|
},
|
|
42
54
|
"license": "MIT",
|
|
@@ -44,7 +56,8 @@
|
|
|
44
56
|
"README.md",
|
|
45
57
|
"./dist/*.js",
|
|
46
58
|
"*.js",
|
|
47
|
-
"*.d.ts"
|
|
59
|
+
"*.d.ts",
|
|
60
|
+
"./dist/*.d.ts"
|
|
48
61
|
],
|
|
49
62
|
"main": "dist/index.js",
|
|
50
63
|
"module": "dist/index.js",
|
|
@@ -54,18 +67,13 @@
|
|
|
54
67
|
"build": "tsc --outDir ./dist --listEmittedFiles"
|
|
55
68
|
},
|
|
56
69
|
"dependencies": {
|
|
57
|
-
"@builder
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"@
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"@
|
|
64
|
-
"@storybook/core-server": "7.0.0-beta.9",
|
|
65
|
-
"@storybook/html": "7.0.0-beta.9",
|
|
66
|
-
"@storybook/node-logger": "7.0.0-beta.9",
|
|
67
|
-
"@storybook/preview-web": "7.0.0-beta.9",
|
|
68
|
-
"magic-string": "^0.26.1"
|
|
70
|
+
"@storybook/builder-vite": "^7.0.0-beta.7"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"@builder.io/qwik": "^0.15.2"
|
|
74
|
+
},
|
|
75
|
+
"optionalDependencies": {
|
|
76
|
+
"@builder.io/qwik-city": "^0.0.128"
|
|
69
77
|
},
|
|
70
78
|
"devDependencies": {
|
|
71
79
|
"@types/node": "^16.0.0",
|