1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | const history_object_1 = require("@gongt/ts-stl-library/browser/history-object");
|
5 | const global_page_data_1 = require("@gongt/ts-stl-library/pattern/global-page-data");
|
6 | const react_router_redux_1 = require("react-router-redux");
|
7 | const client_1 = require("../../react-redux/client");
|
8 | const redux_router_store_1 = require("./redux-router.store");
|
9 | if (!react_router_redux_1.ConnectedRouter) {
|
10 | throw new TypeError('package `react-router-redux` not export ConnectedRouter, have you installed @next version?');
|
11 | }
|
12 | function reduxHandleReactRouter(react, redux, options = {}) {
|
13 | reduxHandleReactRouterBase(react, redux, () => {
|
14 | return options;
|
15 | });
|
16 | client_1.reactUseRedux(react);
|
17 | }
|
18 | exports.reduxHandleReactRouter = reduxHandleReactRouter;
|
19 | function reduxHandleReactRouterBase(react, redux, options) {
|
20 | const preventDuplicate = new global_page_data_1.GlobalVariable(react);
|
21 | if (preventDuplicate.has('reduxRouter')) {
|
22 | throw new TypeError('reduxHandleReactRouter(): duplicate call.');
|
23 | }
|
24 | if (preventDuplicate.has('router')) {
|
25 | throw new TypeError('reduxHandleReactRouter(): must not call reactUseRouter().');
|
26 | }
|
27 | if (preventDuplicate.has('redux')) {
|
28 | throw new TypeError('reduxHandleReactRouter(): must not call reactUseRedux().');
|
29 | }
|
30 | preventDuplicate.set('reduxRouter', true);
|
31 | react.wrapComponent('ConnectedRouter', react_router_redux_1.ConnectedRouter, (global) => {
|
32 | let history = history_object_1.createSingletonHistory(global, options(global));
|
33 | return {
|
34 | history,
|
35 | };
|
36 | });
|
37 | redux.useDynamic((global) => {
|
38 | return react_router_redux_1.routerMiddleware(history_object_1.createSingletonHistory(global, options(global)));
|
39 | });
|
40 | redux.register(redux_router_store_1.routing);
|
41 | }
|
42 | exports.reduxHandleReactRouterBase = reduxHandleReactRouterBase;
|
43 |
|
\ | No newline at end of file |