1 | export { default as loadable } from '@loadable/component';
|
2 | import { RouteConfig, MatchedRoute } from 'react-router-config';
|
3 | export { RouteConfig } from 'react-router-config';
|
4 | import * as effector from 'effector';
|
5 | import { Event, Domain, Store, Unit } from 'effector';
|
6 | import * as history from 'history';
|
7 | import * as React from 'react';
|
8 |
|
9 | interface HistoryChange {
|
10 | pathname: string;
|
11 | hash: string;
|
12 | search: string;
|
13 | action: 'PUSH' | 'POP' | 'REPLACE';
|
14 | }
|
15 |
|
16 | declare function createBrowserApplication(config: {
|
17 | ready: Event<void>;
|
18 | routes: RouteConfig[];
|
19 | domain?: Domain;
|
20 | }): {
|
21 | navigation: {
|
22 | history: history.History<unknown>;
|
23 | historyPush: effector.Effect<string, void, Error>;
|
24 | historyPushSearch: effector.Effect<string, void, Error>;
|
25 | historyReplace: effector.Effect<string, void, Error>;
|
26 | historyChanged: Event<HistoryChange>;
|
27 | historyEmitCurrent: Event<void>;
|
28 | $redirectTo: effector.Store<string>;
|
29 | };
|
30 | };
|
31 |
|
32 | interface HatchParams {
|
33 | params: Record<string, string>;
|
34 | query: Record<string, string>;
|
35 | }
|
36 |
|
37 |
|
38 |
|
39 | interface Hatch {
|
40 | enter: Event<HatchParams>;
|
41 | update: Event<HatchParams>;
|
42 | exit: Event<void>;
|
43 | $opened: Store<boolean>;
|
44 | $params: Store<Record<string, string>>;
|
45 | $query: Store<Record<string, string>>;
|
46 | $props: Store<HatchParams>;
|
47 | }
|
48 | interface Config {
|
49 | enter: Event<HatchParams>;
|
50 | update: Event<HatchParams>;
|
51 | exit: Event<void>;
|
52 | domain?: Domain;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | declare function createHatch(config_?: Config | Domain): Hatch;
|
60 | declare function withHatch<C extends React.ComponentType>(hatch: Hatch, component: C): C;
|
61 | declare function getHatch<T extends React.ComponentType<any>>(component: T): Hatch | undefined;
|
62 | declare function lookupHatch<P>(match: MatchedRoute<P>): Hatch | undefined;
|
63 |
|
64 | declare type KeysOfEffectorApi<API> = {
|
65 | [KEY in keyof API]: API[KEY] extends Unit<any> ? KEY : never;
|
66 | }[keyof API];
|
67 | declare function contract<Properties extends string, Page extends Record<Properties, unknown>>(config: {
|
68 | page: Page;
|
69 | model: Pick<Page, KeysOfEffectorApi<Page>>;
|
70 | }): void;
|
71 |
|
72 | declare const createPages: (routes: RouteConfig[]) => JSX.Element;
|
73 |
|
74 | export { Hatch, HatchParams, contract, createBrowserApplication, createHatch, createPages, getHatch, lookupHatch, withHatch };
|