UNPKG

3.54 kBTypeScriptView Raw
1import * as _storybook_core_types from '@storybook/core/types';
2import { StoryIndex, PreparedStory, NormalizedStoriesSpecifier, StorybookConfig as StorybookConfig$1 } from '@storybook/core/types';
3import { ReactRenderer } from '@storybook/react';
4import * as react_jsx_runtime from 'react/jsx-runtime';
5import { Channel } from '@storybook/core/channels';
6import { StoryContext } from '@storybook/csf';
7import { PreviewWithSelection } from '@storybook/core/preview-api';
8import { Theme } from '@storybook/react-native-theming';
9export { Theme, darkTheme, theme } from '@storybook/react-native-theming';
10
11interface Storage {
12 getItem: (key: string) => Promise<string | null>;
13 setItem: (key: string, value: string) => Promise<void>;
14}
15type StoryKind = string;
16type StoryName = string;
17type InitialSelection = `${StoryKind}--${StoryName}` | {
18 /**
19 * Kind is the default export name or the storiesOf("name") name
20 */
21 kind: StoryKind;
22 /**
23 * Name is the named export or the .add("name") name
24 */
25 name: StoryName;
26};
27type DeepPartial<T> = T extends object ? {
28 [P in keyof T]?: DeepPartial<T[P]>;
29} : T;
30type Params = {
31 onDeviceUI?: boolean;
32 enableWebsockets?: boolean;
33 query?: string;
34 host?: string;
35 port?: number;
36 secured?: boolean;
37 initialSelection?: InitialSelection;
38 shouldPersistSelection?: boolean;
39 theme: DeepPartial<Theme>;
40 storage?: Storage;
41};
42declare class View {
43 _storyIndex: StoryIndex;
44 _setStory: (story: StoryContext<ReactRenderer>) => void;
45 _forceRerender: () => void;
46 _ready: boolean;
47 _preview: PreviewWithSelection<ReactRenderer>;
48 _asyncStorageStoryId: string;
49 _webUrl: string;
50 _storage: Storage;
51 _channel: Channel;
52 _idToPrepared: Record<string, PreparedStory<ReactRenderer>>;
53 constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
54 _getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
55 storySpecifier: string;
56 viewMode: string;
57 }>;
58 _getServerChannel: (params?: Partial<Params>) => Channel;
59 createPreparedStoryMapping: () => Promise<void>;
60 getStorybookUI: (params?: Partial<Params>) => () => react_jsx_runtime.JSX.Element;
61}
62
63/** Configuration options that are needed at startup, only serialisable values are possible */
64interface ReactNativeOptions {
65 /**
66 * Note that this is for future and play functions are not yet fully supported on native.
67 */
68 playFn?: boolean;
69}
70declare function prepareStories({ storyEntries, options, }: {
71 storyEntries: Array<NormalizedStoriesSpecifier & {
72 req: any;
73 }>;
74 options?: ReactNativeOptions;
75}): {
76 index: StoryIndex;
77 importMap: Record<string, any>;
78};
79declare const getProjectAnnotations: (view: View, annotations: any[]) => () => Promise<_storybook_core_types.NormalizedProjectAnnotations<ReactRenderer>>;
80declare function start({ annotations, storyEntries, options, }: {
81 storyEntries: Array<NormalizedStoriesSpecifier & {
82 req: any;
83 }>;
84 annotations: any[];
85 options?: ReactNativeOptions;
86}): View;
87declare function updateView(viewInstance: View, annotations: any[], normalizedStories: Array<NormalizedStoriesSpecifier & {
88 req: any;
89}>, options?: ReactNativeOptions): void;
90
91interface StorybookConfig {
92 stories: StorybookConfig$1['stories'];
93 addons: string[];
94 reactNative?: ReactNativeOptions;
95}
96
97export { StorybookConfig, getProjectAnnotations, prepareStories, start, updateView };