@storybook/vue 5.2.1 → 5.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/vue",
3
- "version": "5.2.1",
3
+ "version": "5.2.5",
4
4
  "description": "Storybook for Vue: Develop Vue Component in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -15,6 +15,13 @@
15
15
  "directory": "app/vue"
16
16
  },
17
17
  "license": "MIT",
18
+ "files": [
19
+ "bin/**/*",
20
+ "dist/**/*",
21
+ "README.md",
22
+ "*.js",
23
+ "*.d.ts"
24
+ ],
18
25
  "main": "dist/client/index.js",
19
26
  "types": "dist/client/index.d.ts",
20
27
  "bin": {
@@ -26,8 +33,9 @@
26
33
  "prepare": "node ../../scripts/prepare.js"
27
34
  },
28
35
  "dependencies": {
29
- "@storybook/addons": "5.2.1",
30
- "@storybook/core": "5.2.1",
36
+ "@storybook/addons": "5.2.5",
37
+ "@storybook/core": "5.2.5",
38
+ "@types/webpack-env": "^1.13.9",
31
39
  "common-tags": "^1.8.0",
32
40
  "core-js": "^3.0.1",
33
41
  "global": "^4.3.2",
@@ -55,5 +63,5 @@
55
63
  "publishConfig": {
56
64
  "access": "public"
57
65
  },
58
- "gitHead": "5497d2ea8d47c4573d245126e6f3f45bc176c12d"
66
+ "gitHead": "6e80db697f865f833cf3e250573a7ce36e0ee02a"
59
67
  }
@@ -1,14 +0,0 @@
1
- export {
2
- storiesOf,
3
- setAddon,
4
- addDecorator,
5
- addParameters,
6
- configure,
7
- getStorybook,
8
- forceReRender,
9
- raw,
10
- } from './preview';
11
-
12
- if (module && module.hot && module.hot.decline) {
13
- module.hot.decline();
14
- }
@@ -1,14 +0,0 @@
1
- /* eslint-disable no-underscore-dangle */
2
- import { window } from 'global';
3
-
4
- if (window.parent !== window) {
5
- try {
6
- window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__;
7
- window.parent.__VUE_DEVTOOLS_CONTEXT__ = window.document;
8
- } catch (error) {
9
- // The above lines can throw if we do not have access to the parent frame -- i.e. cross origin
10
- }
11
- }
12
-
13
- window.STORYBOOK_REACT_CLASSES = {};
14
- window.STORYBOOK_ENV = 'vue';
@@ -1,138 +0,0 @@
1
- /* eslint-disable prefer-destructuring */
2
- import Vue, { VueConstructor, ComponentOptions } from 'vue';
3
- import { start } from '@storybook/core/client';
4
- import {
5
- ClientStoryApi,
6
- StoryFn,
7
- DecoratorFunction,
8
- StoryContext,
9
- Loadable,
10
- } from '@storybook/addons';
11
-
12
- import './globals';
13
- import { IStorybookSection, StoryFnVueReturnType } from './types';
14
-
15
- import render, { VALUES } from './render';
16
- import { extractProps } from './util';
17
-
18
- export const WRAPS = 'STORYBOOK_WRAPS';
19
-
20
- function prepare(
21
- rawStory: StoryFnVueReturnType,
22
- innerStory?: VueConstructor
23
- ): VueConstructor | null {
24
- let story: ComponentOptions<Vue> | VueConstructor;
25
-
26
- if (typeof rawStory === 'string') {
27
- story = { template: rawStory };
28
- } else if (rawStory != null) {
29
- story = rawStory as ComponentOptions<Vue>;
30
- } else {
31
- return null;
32
- }
33
-
34
- // @ts-ignore
35
- // eslint-disable-next-line no-underscore-dangle
36
- if (!story._isVue) {
37
- if (innerStory) {
38
- story.components = { ...(story.components || {}), story: innerStory };
39
- }
40
- story = Vue.extend(story);
41
- // @ts-ignore // https://github.com/storybookjs/storybook/pull/7578#discussion_r307984824
42
- } else if (story.options[WRAPS]) {
43
- return story as VueConstructor;
44
- }
45
-
46
- return Vue.extend({
47
- // @ts-ignore // https://github.com/storybookjs/storybook/pull/7578#discussion_r307985279
48
- [WRAPS]: story,
49
- // @ts-ignore // https://github.com/storybookjs/storybook/pull/7578#discussion_r307984824
50
- [VALUES]: { ...(innerStory ? innerStory.options[VALUES] : {}), ...extractProps(story) },
51
- functional: true,
52
- render(h, { data, parent, children }) {
53
- return h(
54
- story,
55
- {
56
- ...data,
57
- // @ts-ignore // https://github.com/storybookjs/storybook/pull/7578#discussion_r307986196
58
- props: { ...(data.props || {}), ...parent.$root[VALUES] },
59
- },
60
- children
61
- );
62
- },
63
- });
64
- }
65
-
66
- const defaultContext: StoryContext = {
67
- id: 'unspecified',
68
- name: 'unspecified',
69
- kind: 'unspecified',
70
- parameters: {},
71
- };
72
-
73
- function decorateStory(
74
- storyFn: StoryFn<StoryFnVueReturnType>,
75
- decorators: DecoratorFunction<VueConstructor>[]
76
- ): StoryFn<VueConstructor> {
77
- return decorators.reduce(
78
- (decorated: StoryFn<VueConstructor>, decorator) => (context: StoryContext = defaultContext) => {
79
- let story;
80
-
81
- const decoratedStory = decorator(p => {
82
- story = decorated(
83
- p
84
- ? {
85
- ...context,
86
- ...p,
87
- parameters: {
88
- ...context.parameters,
89
- ...p.parameters,
90
- },
91
- }
92
- : context
93
- );
94
-
95
- return story;
96
- }, context);
97
-
98
- if (!story) {
99
- story = decorated(context);
100
- }
101
-
102
- if (decoratedStory === story) {
103
- return story;
104
- }
105
-
106
- return prepare(decoratedStory, story);
107
- },
108
- context => prepare(storyFn(context))
109
- );
110
- }
111
- const framework = 'vue';
112
-
113
- interface ClientApi extends ClientStoryApi<StoryFnVueReturnType> {
114
- setAddon(addon: any): void;
115
- configure(loader: Loadable, module: NodeModule): void;
116
- getStorybook(): IStorybookSection[];
117
- clearDecorators(): void;
118
- forceReRender(): void;
119
- raw: () => any; // todo add type
120
- load: (...args: any[]) => void;
121
- }
122
-
123
- const api = start(render, { decorateStory });
124
-
125
- export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
126
- return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({
127
- framework,
128
- });
129
- };
130
-
131
- export const configure: ClientApi['configure'] = (...args) => api.configure(...args, framework);
132
- export const addDecorator: ClientApi['addDecorator'] = api.clientApi.addDecorator;
133
- export const addParameters: ClientApi['addParameters'] = api.clientApi.addParameters;
134
- export const clearDecorators: ClientApi['clearDecorators'] = api.clientApi.clearDecorators;
135
- export const setAddon: ClientApi['setAddon'] = api.clientApi.setAddon;
136
- export const forceReRender: ClientApi['forceReRender'] = api.forceReRender;
137
- export const getStorybook: ClientApi['getStorybook'] = api.clientApi.getStorybook;
138
- export const raw: ClientApi['raw'] = api.clientApi.raw;
@@ -1,58 +0,0 @@
1
- import { stripIndents } from 'common-tags';
2
- import Vue from 'vue';
3
- import { RenderMainArgs } from './types';
4
-
5
- export const COMPONENT = 'STORYBOOK_COMPONENT';
6
- export const VALUES = 'STORYBOOK_VALUES';
7
-
8
- const root = new Vue({
9
- data() {
10
- return {
11
- [COMPONENT]: undefined,
12
- [VALUES]: {},
13
- };
14
- },
15
- render(h) {
16
- const children = this[COMPONENT] ? [h(this[COMPONENT])] : undefined;
17
- return h('div', { attrs: { id: 'root' } }, children);
18
- },
19
- });
20
-
21
- export default function render({
22
- storyFn,
23
- selectedKind,
24
- selectedStory,
25
- showMain,
26
- showError,
27
- showException,
28
- forceRender,
29
- }: RenderMainArgs) {
30
- Vue.config.errorHandler = showException;
31
-
32
- const element = storyFn();
33
-
34
- if (!element) {
35
- showError({
36
- title: `Expecting a Vue component from the story: "${selectedStory}" of "${selectedKind}".`,
37
- description: stripIndents`
38
- Did you forget to return the Vue component from the story?
39
- Use "() => ({ template: '<my-comp></my-comp>' })" or "() => ({ components: MyComp, template: '<my-comp></my-comp>' })" when defining the story.
40
- `,
41
- });
42
- return;
43
- }
44
-
45
- showMain();
46
-
47
- // at component creation || refresh by HMR
48
- if (!root[COMPONENT] || !forceRender) {
49
- root[COMPONENT] = element;
50
- }
51
-
52
- // @ts-ignore https://github.com/storybookjs/storybook/pull/7578#discussion_r307986139
53
- root[VALUES] = element.options[VALUES];
54
-
55
- if (!root.$el) {
56
- root.$mount('#root');
57
- }
58
- }
@@ -1,31 +0,0 @@
1
- import { Component, VueConstructor } from 'vue';
2
- import { StoryFn } from '@storybook/addons';
3
- // TODO, 'any' should be what is actually expected from a storyFn
4
-
5
- export interface ShowErrorArgs {
6
- title: string;
7
- description: string;
8
- }
9
-
10
- export interface RenderMainArgs {
11
- storyFn: StoryFn<VueConstructor>;
12
- selectedKind: string;
13
- selectedStory: string;
14
- showMain: () => void;
15
- showError: (args: ShowErrorArgs) => void;
16
- showException: (...args: any[]) => void;
17
- forceRender: boolean;
18
- }
19
-
20
- // TODO: some vue expert needs to look at this
21
- export type StoryFnVueReturnType = string | Component;
22
-
23
- export interface IStorybookStory {
24
- name: string;
25
- render: () => any;
26
- }
27
-
28
- export interface IStorybookSection {
29
- kind: string;
30
- stories: IStorybookStory[];
31
- }
@@ -1,23 +0,0 @@
1
- import { VueConstructor } from 'vue';
2
-
3
- function getType(fn: Function) {
4
- const match = fn && fn.toString().match(/^\s*function (\w+)/);
5
- return match ? match[1] : '';
6
- }
7
-
8
- // https://github.com/vuejs/vue/blob/dev/src/core/util/props.js#L92
9
- function resolveDefault({ type, default: def }: any) {
10
- if (typeof def === 'function' && getType(type) !== 'Function') {
11
- // known limitation: we don't have the component instance to pass
12
- return def.call();
13
- }
14
-
15
- return def;
16
- }
17
-
18
- export function extractProps(component: VueConstructor) {
19
- // @ts-ignore this options business seems not good according to the types
20
- return Object.entries(component.options.props || {})
21
- .map(([name, prop]) => ({ [name]: resolveDefault(prop) }))
22
- .reduce((wrap, prop) => ({ ...wrap, ...prop }), {});
23
- }
@@ -1,4 +0,0 @@
1
- import { buildStatic } from '@storybook/core/server';
2
- import options from './options';
3
-
4
- buildStatic(options);
@@ -1,35 +0,0 @@
1
- import VueLoaderPlugin from 'vue-loader/lib/plugin';
2
- import { Configuration } from 'webpack';
3
-
4
- export function webpack(config: Configuration) {
5
- return {
6
- ...config,
7
- plugins: [...config.plugins, new VueLoaderPlugin()],
8
- module: {
9
- ...config.module,
10
- rules: [
11
- ...config.module.rules,
12
- {
13
- test: /\.vue$/,
14
- loader: require.resolve('vue-loader'),
15
- options: {},
16
- },
17
- ],
18
- },
19
- resolve: {
20
- ...config.resolve,
21
- extensions: [...config.resolve.extensions, '.vue'],
22
- alias: {
23
- ...config.resolve.alias,
24
- vue$: require.resolve('vue/dist/vue.esm.js'),
25
- },
26
- },
27
- };
28
- }
29
-
30
- export function babelDefault(config: any) {
31
- return {
32
- ...config,
33
- presets: [...config.presets, require.resolve('babel-preset-vue')],
34
- };
35
- }
@@ -1,4 +0,0 @@
1
- import { buildDev } from '@storybook/core/server';
2
- import options from './options';
3
-
4
- buildDev(options);
@@ -1,6 +0,0 @@
1
- const packageJson = require('../../package.json');
2
-
3
- export default {
4
- packageJson,
5
- frameworkPresets: [require.resolve('./framework-preset-vue.js')],
6
- };
package/src/typings.d.ts DELETED
@@ -1,6 +0,0 @@
1
- declare module '@storybook/core/*';
2
- declare module 'global';
3
- // todo check for correct types
4
- declare module 'webpack/lib/RuleSet';
5
-
6
- declare module 'vue-loader/lib/plugin';
package/tsconfig.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": "./src",
5
- "types": ["webpack-env"],
6
- "resolveJsonModule": true
7
- },
8
- "include": [
9
- "src/**/*"
10
- ],
11
- "exclude": [
12
- "src/**/*.test.*"
13
- ]
14
- }