This commit is contained in:
Norbert de Langen 2022-09-28 09:39:04 +02:00
parent 5272feac51
commit d3eab19d5b
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
14 changed files with 66 additions and 14 deletions

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
export {
storiesOf,
setAddon,

View File

@ -39,7 +39,7 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "node ../../../scripts/prepare.js"
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/addons": "7.0.0-alpha.34",
@ -67,8 +67,7 @@
},
"bundler": {
"entries": [
"./src/index.tsx",
"./src/shortcut.ts"
"./src/index.ts"
]
},
"gitHead": "fc90fc875462421c1faa35862ac4bc436de8e75f"

View File

@ -11,6 +11,8 @@ import {
setGlobalRender,
} from './ClientApi';
export type { GetStorybookKind, GetStorybookStory } from './ClientApi';
export * from './types';
export * from './queryparams';

View File

@ -1,3 +1,6 @@
/// <reference types="node" />
/// <reference types="webpack-env" />
import { logger } from '@storybook/client-logger';
import { Path, ModuleExports } from '@storybook/store';
import { Loadable, RequireContext, LoaderFunction } from './types';

View File

@ -5,7 +5,7 @@ import { PreviewWeb } from '@storybook/preview-web';
import type { AnyFramework, ArgsStoryFn } from '@storybook/csf';
import { createChannel } from '@storybook/channel-postmessage';
import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';
import { FORCE_RE_RENDER } from '@storybook/core-events';
import type { Path, WebProjectAnnotations } from '@storybook/store';
import { Loadable } from './types';
@ -24,16 +24,45 @@ const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
};
interface RendererImplementation<TFramework extends AnyFramework> {
decorateStory?: WebProjectAnnotations<TFramework>['applyDecorators'];
render?: ArgsStoryFn<TFramework>;
}
interface ClientAPIFacade {
/* deprecated */
addDecorator: (...args: any[]) => never;
/* deprecated */
addParameters: (...args: any[]) => never;
/* deprecated */
clearDecorators: (...args: any[]) => never;
/* deprecated */
addLoader: (...args: any[]) => never;
/* deprecated */
setAddon: (...args: any[]) => never;
/* deprecated */
getStorybook: (...args: any[]) => never;
/* deprecated */
storiesOf: (...args: any[]) => never;
/* deprecated */
raw: (...args: any[]) => never;
}
interface StartReturnValue<TFramework extends AnyFramework> {
/* deprecated */
forceReRender: () => void;
/* deprecated */
getStorybook: any;
/* deprecated */
configure: any;
/* deprecated */
clientApi: ClientApi<TFramework> | ClientAPIFacade;
}
export function start<TFramework extends AnyFramework>(
renderToDOM: WebProjectAnnotations<TFramework>['renderToDOM'],
{
decorateStory,
render,
}: {
decorateStory?: WebProjectAnnotations<TFramework>['applyDecorators'];
render?: ArgsStoryFn<TFramework>;
} = {}
) {
{ decorateStory, render }: RendererImplementation<TFramework> = {}
): StartReturnValue<TFramework> {
if (globalWindow) {
// To enable user code to detect if it is running in Storybook
globalWindow.IS_STORYBOOK = true;
@ -84,9 +113,8 @@ export function start<TFramework extends AnyFramework>(
}
return {
forceReRender: () => channel.emit(Events.FORCE_RE_RENDER),
forceReRender: () => channel.emit(FORCE_RE_RENDER),
getStorybook: (): void[] => [],
raw: (): void => {},
clientApi,
// This gets called each time the user calls configure (i.e. once per HMR)

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
export * from './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
import './globals';
export * from './public-api';

View File

@ -1,3 +1,5 @@
/// <reference types="webpack-env" />
// @ts-expect-error (Converted from ts-ignore)
import global from 'global';