1 | import { Channel } from '@storybook/channels';
|
2 | import { Parameters, Args, LegacyStoryFn, StoryKind } from '@storybook/addons';
|
3 | import { DecoratorFunction, StoryMetadata, StoreData, AddStoryArgs, StoreItem, PublishedStoreItem, ErrorLike, GetStorybookKind, ArgTypesEnhancer, StoreSelectionSpecifier, StoreSelection } from './types';
|
4 | interface StoryOptions {
|
5 | includeDocsOnly?: boolean;
|
6 | }
|
7 | declare type KindMetadata = StoryMetadata & {
|
8 | order: number;
|
9 | };
|
10 | interface AllowUnsafeOption {
|
11 | allowUnsafe?: boolean;
|
12 | }
|
13 | export default class StoryStore {
|
14 | _error?: ErrorLike;
|
15 | _channel: Channel;
|
16 | _configuring: boolean;
|
17 | _globals: Args;
|
18 | _globalMetadata: StoryMetadata;
|
19 | _kinds: Record<string, KindMetadata>;
|
20 | _stories: StoreData;
|
21 | _argTypesEnhancers: ArgTypesEnhancer[];
|
22 | _selectionSpecifier?: StoreSelectionSpecifier;
|
23 | _selection?: StoreSelection;
|
24 | constructor(params: {
|
25 | channel: Channel;
|
26 | });
|
27 | setupListeners(): void;
|
28 | startConfiguring(): void;
|
29 | storeGlobals(): void;
|
30 | finishConfiguring(): void;
|
31 | addGlobalMetadata({ parameters, decorators, loaders }: StoryMetadata): void;
|
32 | clearGlobalDecorators(): void;
|
33 | ensureKind(kind: string): void;
|
34 | addKindMetadata(kind: string, { parameters, decorators, loaders }: StoryMetadata): void;
|
35 | addArgTypesEnhancer(argTypesEnhancer: ArgTypesEnhancer): void;
|
36 | combineStoryParameters(parameters: Parameters, kind: StoryKind): Parameters;
|
37 | addStory({ id, kind, name, storyFn: original, parameters: storyParameters, decorators: storyDecorators, loaders: storyLoaders, }: AddStoryArgs, { applyDecorators, allowUnsafe, }: {
|
38 | applyDecorators: (fn: LegacyStoryFn, decorators: DecoratorFunction[]) => any;
|
39 | } & AllowUnsafeOption): void;
|
40 | remove: (id: string, { allowUnsafe }?: AllowUnsafeOption) => void;
|
41 | removeStoryKind(kind: string, { allowUnsafe }?: AllowUnsafeOption): void;
|
42 | updateGlobals(newGlobals: Args): void;
|
43 | updateStoryArgs(id: string, newArgs: Args): void;
|
44 | resetStoryArgs(id: string, argNames?: string[]): void;
|
45 | fromId: (id: string) => PublishedStoreItem | null;
|
46 | raw(options?: StoryOptions): PublishedStoreItem[];
|
47 | sortedStories(): StoreItem[];
|
48 | extract(options?: StoryOptions & {
|
49 | normalizeParameters?: boolean;
|
50 | }): {};
|
51 | clearError(): void;
|
52 | setError: (err: ErrorLike) => void;
|
53 | getError: () => ErrorLike | undefined;
|
54 | setSelectionSpecifier(selectionSpecifier: StoreSelectionSpecifier): void;
|
55 | setSelection(selection: StoreSelection): void;
|
56 | getSelection: () => StoreSelection;
|
57 | getDataForManager: () => {
|
58 | v: number;
|
59 | globalParameters: Parameters;
|
60 | globals: Args;
|
61 | error: ErrorLike;
|
62 | kindParameters: {
|
63 | [x: string]: Parameters;
|
64 | };
|
65 | stories: {};
|
66 | };
|
67 | getStoriesJsonData: () => {
|
68 | v: number;
|
69 | globalParameters: Pick<Parameters, string>;
|
70 | kindParameters: {
|
71 | [x: string]: Pick<Parameters, string>;
|
72 | };
|
73 | stories: {};
|
74 | };
|
75 | pushToManager: () => void;
|
76 | getStoryKinds(): string[];
|
77 | getStoriesForKind: (kind: string) => PublishedStoreItem[];
|
78 | getRawStory(kind: string, name: string): PublishedStoreItem;
|
79 | cleanHooks(id: string): void;
|
80 | cleanHooksForKind(kind: string): void;
|
81 | getStorybook(): GetStorybookKind[];
|
82 | private mergeAdditionalDataToStory;
|
83 | }
|
84 | export {};
|