mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
27 lines
988 B
TypeScript
27 lines
988 B
TypeScript
/* eslint-disable prefer-destructuring */
|
|
import type { Addon_ClientStoryApi, Addon_Loadable } from '@storybook/types';
|
|
import { start } from '@storybook/preview-api';
|
|
import type { HtmlRenderer } from './types';
|
|
|
|
import { renderToCanvas, render } from './render';
|
|
|
|
const FRAMEWORK = 'html';
|
|
|
|
interface ClientApi extends Addon_ClientStoryApi<HtmlRenderer['storyResult']> {
|
|
configure(loader: Addon_Loadable, module: NodeModule): void;
|
|
forceReRender(): void;
|
|
raw: () => any; // todo add type
|
|
}
|
|
|
|
const api = start<HtmlRenderer>(renderToCanvas, { render });
|
|
|
|
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 forceReRender: ClientApi['forceReRender'] = api.forceReRender;
|
|
export const raw: ClientApi['raw'] = api.clientApi.raw;
|