1 | import { StoryGetter, StoryContext, Args } from './types';
|
2 | interface Hook {
|
3 | name: string;
|
4 | memoizedState?: any;
|
5 | deps?: any[] | undefined;
|
6 | }
|
7 | interface Effect {
|
8 | create: () => (() => void) | void;
|
9 | destroy?: (() => void) | void;
|
10 | }
|
11 | declare type Decorator = (getStory: StoryGetter, context: StoryContext) => any;
|
12 | declare type AbstractFunction = (...args: any[]) => any;
|
13 | export declare class HooksContext {
|
14 | hookListsMap: WeakMap<AbstractFunction, Hook[]>;
|
15 | mountedDecorators: Set<AbstractFunction>;
|
16 | prevMountedDecorators: Set<AbstractFunction>;
|
17 | currentHooks: Hook[];
|
18 | nextHookIndex: number;
|
19 | currentPhase: 'MOUNT' | 'UPDATE' | 'NONE';
|
20 | currentEffects: Effect[];
|
21 | prevEffects: Effect[];
|
22 | currentDecoratorName: string | null;
|
23 | hasUpdates: boolean;
|
24 | currentContext: StoryContext | null;
|
25 | renderListener: () => void;
|
26 | constructor();
|
27 | init(): void;
|
28 | clean(): void;
|
29 | getNextHook(): Hook;
|
30 | triggerEffects(): void;
|
31 | addRenderListeners(): void;
|
32 | removeRenderListeners(): void;
|
33 | }
|
34 | export declare const applyHooks: (applyDecorators: (getStory: StoryGetter, decorators: Decorator[]) => StoryGetter) => (getStory: StoryGetter, decorators: Decorator[]) => (context: StoryContext) => any;
|
35 | export declare function useMemo<T>(nextCreate: () => T, deps?: any[]): T;
|
36 | export declare function useCallback<T>(callback: T, deps?: any[]): T;
|
37 | export declare function useRef<T>(initialValue: T): {
|
38 | current: T;
|
39 | };
|
40 | export declare function useState<S>(initialState: (() => S) | S): [S, (update: ((prevState: S) => S) | S) => void];
|
41 | export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void];
|
42 | export declare function useReducer<S, I, A>(reducer: (state: S, action: A) => S, initialArg: I, init: (initialArg: I) => S): [S, (action: A) => void];
|
43 | export declare function useEffect(create: () => (() => void) | void, deps?: any[]): void;
|
44 | export interface Listener {
|
45 | (...args: any[]): void;
|
46 | }
|
47 | export interface EventMap {
|
48 | [eventId: string]: Listener;
|
49 | }
|
50 | export declare function useChannel(eventMap: EventMap, deps?: any[]): any;
|
51 | export declare function useStoryContext(): StoryContext;
|
52 | export declare function useParameter<S>(parameterKey: string, defaultValue?: S): S | undefined;
|
53 | export declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: [string]) => void];
|
54 | export declare function useGlobals(): [Args, (newGlobals: Args) => void];
|
55 | export {};
|