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, ArgsEnhancer, 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 | _initialGlobals: Args;
|
19 | _defaultGlobals: Args;
|
20 | _globalMetadata: StoryMetadata;
|
21 | _kinds: Record<string, KindMetadata>;
|
22 | _stories: StoreData;
|
23 | _argsEnhancers: ArgsEnhancer[];
|
24 | _argTypesEnhancers: ArgTypesEnhancer[];
|
25 | _selectionSpecifier?: StoreSelectionSpecifier;
|
26 | _selection?: StoreSelection;
|
27 | constructor(params: {
|
28 | channel: Channel;
|
29 | });
|
30 | setupListeners(): void;
|
31 | startConfiguring(): void;
|
32 | finishConfiguring(): void;
|
33 | addGlobalMetadata({ parameters, decorators, loaders }: StoryMetadata): void;
|
34 | clearGlobalDecorators(): void;
|
35 | ensureKind(kind: string): void;
|
36 | addKindMetadata(kind: string, { parameters, decorators, loaders }: StoryMetadata): void;
|
37 | addArgsEnhancer(argsEnhancer: ArgsEnhancer): void;
|
38 | addArgTypesEnhancer(argTypesEnhancer: ArgTypesEnhancer): void;
|
39 | combineStoryParameters(parameters: Parameters, kind: StoryKind): Parameters;
|
40 | shouldBlockAddingStory(id: string): boolean;
|
41 | shouldBlockAddingKindMetadata(kind: string): boolean;
|
42 | addStory({ id, kind, name, storyFn: original, parameters: storyParameters, decorators: storyDecorators, loaders: storyLoaders, }: AddStoryArgs, { applyDecorators, allowUnsafe, }: {
|
43 | applyDecorators: (fn: LegacyStoryFn, decorators: DecoratorFunction[]) => any;
|
44 | } & AllowUnsafeOption): void;
|
45 | remove: (id: string, { allowUnsafe }?: AllowUnsafeOption) => void;
|
46 | removeStoryKind(kind: string, { allowUnsafe }?: AllowUnsafeOption): void;
|
47 | updateGlobals(newGlobals: Args): void;
|
48 | updateStoryArgs(id: string, newArgs: Args): void;
|
49 | resetStoryArgs(id: string, argNames?: string[]): void;
|
50 | fromId: (id: string) => PublishedStoreItem | null;
|
51 | raw(options?: StoryOptions): PublishedStoreItem[];
|
52 | sortedStories(): StoreItem[];
|
53 | extract(options?: StoryOptions & {
|
54 | normalizeParameters?: boolean;
|
55 | }): {};
|
56 | clearError(): void;
|
57 | setError: (err: ErrorLike) => void;
|
58 | getError: () => ErrorLike | undefined;
|
59 | setSelectionSpecifier(selectionSpecifier: StoreSelectionSpecifier): void;
|
60 | setSelection(selection: StoreSelection): void;
|
61 | isSingleStoryMode(): boolean;
|
62 | getSelection: () => StoreSelection;
|
63 | getDataForManager: () => {
|
64 | v: number;
|
65 | globalParameters: Parameters;
|
66 | globals: Args;
|
67 | error: ErrorLike;
|
68 | kindParameters: {
|
69 | [x: string]: Parameters;
|
70 | };
|
71 | stories: {};
|
72 | };
|
73 | getStoriesJsonData: () => {
|
74 | v: number;
|
75 | globalParameters: Pick<Parameters, string>;
|
76 | kindParameters: {
|
77 | [x: string]: Pick<Parameters, string>;
|
78 | };
|
79 | stories: {};
|
80 | };
|
81 | pushToManager: () => void;
|
82 | getStoryKinds(): string[];
|
83 | getStoriesForKind: (kind: string) => PublishedStoreItem[];
|
84 | getRawStory(kind: string, name: string): PublishedStoreItem;
|
85 | cleanHooks(id: string): void;
|
86 | cleanHooksForKind(kind: string): void;
|
87 | getStorybook(): GetStorybookKind[];
|
88 | private mergeAdditionalDataToStory;
|
89 | }
|
90 | export {};
|