mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
/* eslint-disable prefer-destructuring */
|
|
import { start } from '@storybook/core-client';
|
|
import type { ClientStoryApi, Loadable } from '@storybook/addons';
|
|
import type { HtmlFramework, IStorybookSection } from './types';
|
|
|
|
import { renderToDOM } from './render';
|
|
|
|
const FRAMEWORK = 'html';
|
|
|
|
interface ClientApi extends ClientStoryApi<HtmlFramework['storyResult']> {
|
|
setAddon(addon: any): void;
|
|
configure(loader: Loadable, module: NodeModule): void;
|
|
getStorybook(): IStorybookSection[];
|
|
clearDecorators(): void;
|
|
forceReRender(): void;
|
|
raw: () => any; // todo add type
|
|
}
|
|
|
|
const api = start(renderToDOM);
|
|
|
|
export const storiesOf: ClientApi['storiesOf'] = (kind, m) => {
|
|
return (api.clientApi.storiesOf(kind, m) as ReturnType<ClientApi['storiesOf']>).addParameters({
|
|
framework: FRAMEWORK,
|
|
});
|
|
};
|
|
|
|
export const configure: ClientApi['configure'] = (...args) => api.configure(FRAMEWORK, ...args);
|
|
export const addDecorator: ClientApi['addDecorator'] = api.clientApi
|
|
.addDecorator as ClientApi['addDecorator'];
|
|
export const addParameters: ClientApi['addParameters'] = api.clientApi
|
|
.addParameters as ClientApi['addParameters'];
|
|
export const clearDecorators: ClientApi['clearDecorators'] = api.clientApi.clearDecorators;
|
|
export const setAddon: ClientApi['setAddon'] = api.clientApi.setAddon;
|
|
export const forceReRender: ClientApi['forceReRender'] = api.forceReRender;
|
|
export const getStorybook: ClientApi['getStorybook'] = api.clientApi.getStorybook;
|
|
export const raw: ClientApi['raw'] = api.clientApi.raw;
|