@legalplace/wizardx-core 4.42.10-nightly.20251126151952 → 4.42.10-nightly.20251126154644
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PluginLoader.d.ts +31 -12
- package/dist/PluginLoader.js +211 -139
- package/dist/types/PluginConfig.type.d.ts +19 -1
- package/package.json +1 -1
package/dist/PluginLoader.d.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoadableComponent } from "@loadable/component";
|
|
3
|
+
import type { Action, Reducer } from "redux";
|
|
3
4
|
import type { Saga } from "redux-saga";
|
|
4
|
-
|
|
5
|
+
declare let pluginsStoreReducers: Record<string, Reducer<Record<string, any>, any>>;
|
|
6
|
+
declare const pluginsStoreSagas: Record<string, Saga[]>;
|
|
7
|
+
export type PluginAppStatesRegisterFunction = (currentAppStates: string[]) => string[];
|
|
8
|
+
export type PluginsPageAppStatesType = Record<string, string>;
|
|
9
|
+
export type actionOverrideFunction = (action: Action) => Action;
|
|
10
|
+
export interface IPluginsAppStatesComponents {
|
|
11
|
+
[key: string]: LoadableComponent<any>;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginsAppStatesDeclarations {
|
|
14
|
+
register: PluginAppStatesRegisterFunction;
|
|
15
|
+
pageAppState: PluginsPageAppStatesType;
|
|
16
|
+
components: IPluginsAppStatesComponents;
|
|
17
|
+
additionalRoutes?: Record<string, ReactComponent<any>>[];
|
|
18
|
+
}
|
|
19
|
+
declare let PluginsPageAppStates: PluginsPageAppStatesType;
|
|
5
20
|
type TPluginLoader = React.FC<PluginLoaderProps>;
|
|
6
21
|
export interface PluginLoaderProps {
|
|
7
22
|
anchor: string[];
|
|
@@ -16,16 +31,20 @@ export type ReplaceFragmentPropsType = {
|
|
|
16
31
|
fragmentName?: string;
|
|
17
32
|
children?: React.ReactNode;
|
|
18
33
|
};
|
|
19
|
-
export declare const ReplaceFragment:
|
|
34
|
+
export declare const ReplaceFragment: React.FC<ReplaceFragmentPropsType>;
|
|
20
35
|
export declare function registerReplacer(replacerName: string, Replacer: ReactComponent<any>): void;
|
|
21
|
-
export declare
|
|
36
|
+
export declare const registerPluginsAppStates: PluginAppStatesRegisterFunction;
|
|
37
|
+
export declare const loadPluginComponent: (name: string) => LoadableComponent<any> | undefined;
|
|
38
|
+
export declare const pluginPageAppState: (page: string) => string | false;
|
|
39
|
+
export declare const getPluginsPageAppStates: () => Readonly<typeof PluginsPageAppStates>;
|
|
40
|
+
export declare const getPluginsStoreReducers: () => Readonly<typeof pluginsStoreReducers>;
|
|
41
|
+
export declare const getPluginsStoreSagas: () => Readonly<typeof pluginsStoreSagas>;
|
|
42
|
+
export declare function RunActionAnchor(anchor: string, ...args: any[]): void;
|
|
43
|
+
export declare function RunOverrideActionAnchor(action: Action): Action<any>;
|
|
44
|
+
export declare const loadPlugins: (plugins?: Record<string, string>) => Promise<void>;
|
|
45
|
+
export declare const pluginsLoaded: () => boolean;
|
|
46
|
+
export declare const getPluginsAdditionalRoutes: () => Record<string, ReactComponent<any>>;
|
|
22
47
|
export declare function getPluginsReducers(): Record<string, Reducer<Record<string, any>, any>>;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare
|
|
25
|
-
export declare function clearPlugins(): void;
|
|
26
|
-
export declare const RunActionAnchor: () => void;
|
|
27
|
-
export declare const RunOverrideActionAnchor: () => void;
|
|
28
|
-
export declare const registerPluginsAppStates: (appStates: any) => any;
|
|
29
|
-
export declare const getPluginsStoreReducers: typeof getPluginsReducers;
|
|
30
|
-
export declare const getPluginsStoreSagas: typeof getPluginsSagas;
|
|
48
|
+
export declare function getPluginsSagas(): Record<string, Saga[]>;
|
|
49
|
+
export declare const clearPlugins: () => void;
|
|
31
50
|
export {};
|
package/dist/PluginLoader.js
CHANGED
|
@@ -1,184 +1,256 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
11
|
import React from "react";
|
|
3
12
|
import { getStore } from "./redux/store";
|
|
13
|
+
import { getHistory } from "./redux/routerHistory";
|
|
14
|
+
import { getConfig } from "./config";
|
|
4
15
|
import Globals from "./Globals";
|
|
16
|
+
import { INIT_PLUGINS } from "./redux/constants/app";
|
|
17
|
+
let globalAnchors = {};
|
|
18
|
+
let reduxAnchors = {};
|
|
19
|
+
let actionOverrideAnchor = {};
|
|
20
|
+
let replacers = {};
|
|
5
21
|
let pluginsStoreReducers = {};
|
|
6
|
-
|
|
7
|
-
|
|
22
|
+
const pluginsStoreSagas = {};
|
|
23
|
+
let cache = {};
|
|
24
|
+
let pluginsLoadingDone = false;
|
|
25
|
+
let PluginsAppStatesRegistrers = [];
|
|
26
|
+
let PluginsPageAppStates = {};
|
|
27
|
+
let PluginsAppStatesComponents = {};
|
|
28
|
+
let PluginAdditionRoutes = {};
|
|
8
29
|
export const PluginLoader = (props) => {
|
|
9
30
|
const { anchor } = props;
|
|
10
|
-
const
|
|
31
|
+
const anchorsList = !Array.isArray(anchor) ? [anchor] : anchor;
|
|
11
32
|
let Plugins = [];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return false;
|
|
22
|
-
for (let i = 0; i < anchor.length; i += 1) {
|
|
23
|
-
if (p.anchor[i] !== anchor[i] && p.anchor[i] !== "*")
|
|
24
|
-
return false;
|
|
33
|
+
for (let i = 0; i < anchorsList.length; i += 1) {
|
|
34
|
+
const currentAnchor = anchorsList[i];
|
|
35
|
+
if (Object.prototype.hasOwnProperty.call(globalAnchors, currentAnchor) &&
|
|
36
|
+
globalAnchors[currentAnchor].length > 0) {
|
|
37
|
+
const currentPlugins = globalAnchors[currentAnchor];
|
|
38
|
+
Plugins = [
|
|
39
|
+
...Plugins,
|
|
40
|
+
...currentPlugins.map((Plugin) => (_jsx(React.Suspense, { fallback: null, children: _jsx(Plugin, Object.assign({}, props.props)) }, `lpwp-${currentAnchor}-${Math.random()}`))),
|
|
41
|
+
];
|
|
25
42
|
}
|
|
26
|
-
console.log("Matched plugin", p);
|
|
27
|
-
return true;
|
|
28
|
-
});
|
|
29
|
-
if (matchedPlugins.length > 0) {
|
|
30
|
-
Plugins = matchedPlugins.map((p, i) => (_jsx(p.component, Object.assign({}, (props.props || {})), i)));
|
|
31
43
|
}
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
if (Plugins.length > 0) {
|
|
45
|
+
return _jsx(_Fragment, { children: Plugins });
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
34
48
|
};
|
|
35
49
|
export function replaceComponent(replacerName, OriginalComponent, componentName) {
|
|
50
|
+
const displayName = componentName ||
|
|
51
|
+
OriginalComponent.displayName ||
|
|
52
|
+
OriginalComponent.name ||
|
|
53
|
+
"Component";
|
|
54
|
+
const anchorsList = !Array.isArray(replacerName)
|
|
55
|
+
? [replacerName]
|
|
56
|
+
: replacerName;
|
|
36
57
|
let Replacer = null;
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
if (replacers[r])
|
|
41
|
-
Replacer = r;
|
|
42
|
-
});
|
|
58
|
+
const cacheKey = anchorsList.reduce((a, b) => a + b) + OriginalComponent.toString();
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(cache, cacheKey)) {
|
|
60
|
+
return cache[cacheKey];
|
|
43
61
|
}
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
for (let i = 0; i < anchorsList.length; i += 1) {
|
|
63
|
+
const currentAnchor = anchorsList[i];
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(replacers, currentAnchor)) {
|
|
65
|
+
Replacer = currentAnchor;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
46
68
|
}
|
|
69
|
+
let FinalComponent;
|
|
47
70
|
if (Replacer !== null) {
|
|
48
|
-
const BaseComponent = (props) => (
|
|
71
|
+
const BaseComponent = (props) => React.createElement(OriginalComponent, props, props.children);
|
|
49
72
|
const FinalReplacedComponent = replacers[Replacer].reduce((PreviousReplacer, CurrentReplacer) => {
|
|
50
73
|
const ReplacedComponent = (props) => (_jsx(React.Suspense, { fallback: null, children: _jsx(CurrentReplacer, Object.assign({}, props, { OriginalComponent: PreviousReplacer, children: props.children })) }));
|
|
51
74
|
return ReplacedComponent;
|
|
52
75
|
}, BaseComponent);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return FinalReplacedComponent;
|
|
76
|
+
FinalComponent = FinalReplacedComponent;
|
|
77
|
+
FinalComponent.displayName = `replacedComponent(${displayName})`;
|
|
57
78
|
}
|
|
58
|
-
|
|
79
|
+
else {
|
|
80
|
+
FinalComponent = OriginalComponent;
|
|
81
|
+
FinalComponent.displayName = `originalComponent(${displayName})`;
|
|
82
|
+
}
|
|
83
|
+
cache[cacheKey] = React.memo(FinalComponent);
|
|
84
|
+
return cache[cacheKey];
|
|
59
85
|
}
|
|
60
86
|
export const ReplaceFragment = ({ replacerName, fragmentName, children, }) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (replacers[r])
|
|
65
|
-
Replacer = r;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
else if (replacers[replacerName]) {
|
|
69
|
-
Replacer = replacerName;
|
|
70
|
-
}
|
|
71
|
-
if (Replacer !== null) {
|
|
72
|
-
const Fragment = (props) => _jsx(_Fragment, { children: props.children });
|
|
73
|
-
const FinalReplacedComponent = replacers[Replacer].reduce((PreviousReplacer, CurrentReplacer) => {
|
|
74
|
-
const ReplacedComponent = (props) => (_jsx(React.Suspense, { fallback: null, children: _jsx(CurrentReplacer, Object.assign({}, props, { OriginalComponent: PreviousReplacer, children: props.children })) }));
|
|
75
|
-
return ReplacedComponent;
|
|
76
|
-
}, Fragment);
|
|
77
|
-
if (fragmentName) {
|
|
78
|
-
FinalReplacedComponent.displayName = `Replaced(${fragmentName})`;
|
|
79
|
-
}
|
|
80
|
-
return _jsx(FinalReplacedComponent, { children: children });
|
|
81
|
-
}
|
|
82
|
-
return _jsx(_Fragment, { children: children });
|
|
87
|
+
const Fragment = () => _jsx(_Fragment, { children: children });
|
|
88
|
+
const FinalFragment = replaceComponent(replacerName, Fragment, `Fragment::${fragmentName}`);
|
|
89
|
+
return _jsx(FinalFragment, {});
|
|
83
90
|
};
|
|
84
91
|
export function registerReplacer(replacerName, Replacer) {
|
|
85
92
|
if (!replacers[replacerName])
|
|
86
93
|
replacers[replacerName] = [];
|
|
87
94
|
replacers[replacerName].push(Replacer);
|
|
88
95
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
const pluginAppStates = (declaration) => {
|
|
97
|
+
PluginsAppStatesRegistrers.push(declaration.register);
|
|
98
|
+
if (typeof declaration.pageAppState === "object")
|
|
99
|
+
Object.keys(declaration.pageAppState).forEach((appState) => {
|
|
100
|
+
if (typeof declaration.pageAppState[appState] === "string") {
|
|
101
|
+
const page = declaration.pageAppState[appState];
|
|
102
|
+
if (Object.prototype.hasOwnProperty.call(PluginsPageAppStates, appState)) {
|
|
103
|
+
throw new Error(`Plugins AppState "${appState}" already declared.`);
|
|
104
|
+
}
|
|
105
|
+
const samePageAppStates = Object.keys(PluginsPageAppStates).filter((currentAppState) => PluginsPageAppStates[currentAppState] === page);
|
|
106
|
+
if (samePageAppStates.length > 0)
|
|
107
|
+
throw new Error(`Plugins AppState page "${page}" already declared.`);
|
|
108
|
+
PluginsPageAppStates[appState] = page;
|
|
101
109
|
}
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
});
|
|
111
|
+
Object.keys(declaration.components).forEach((appState) => {
|
|
112
|
+
if (Object.prototype.hasOwnProperty.call(declaration, appState) === true)
|
|
113
|
+
throw new Error(`Plugin's appState ${appState} already declared previously`);
|
|
114
|
+
PluginsAppStatesComponents[appState] = declaration.components[appState];
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
export const registerPluginsAppStates = (currentAppStates) => {
|
|
118
|
+
let appStates = [...currentAppStates];
|
|
119
|
+
PluginsAppStatesRegistrers.forEach((register) => {
|
|
120
|
+
appStates = register(appStates);
|
|
121
|
+
});
|
|
122
|
+
return appStates;
|
|
123
|
+
};
|
|
124
|
+
export const loadPluginComponent = (name) => {
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(PluginsAppStatesComponents, name) ===
|
|
126
|
+
false) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
return PluginsAppStatesComponents[name];
|
|
130
|
+
};
|
|
131
|
+
export const pluginPageAppState = (page) => {
|
|
132
|
+
const appStates = Object.keys(PluginsPageAppStates).filter((appState) => PluginsPageAppStates[appState] === page);
|
|
133
|
+
if (appStates.length === 1)
|
|
134
|
+
return appStates[0];
|
|
135
|
+
if (appStates.length > 1)
|
|
136
|
+
throw new Error("Found multipled appStates when checking for plugins page name");
|
|
137
|
+
return false;
|
|
138
|
+
};
|
|
139
|
+
export const getPluginsPageAppStates = () => PluginsPageAppStates;
|
|
140
|
+
export const getPluginsStoreReducers = () => pluginsStoreReducers;
|
|
141
|
+
export const getPluginsStoreSagas = () => pluginsStoreSagas;
|
|
142
|
+
export function RunActionAnchor(anchor, ...args) {
|
|
143
|
+
if (Object.prototype.hasOwnProperty.call(reduxAnchors, anchor) &&
|
|
144
|
+
reduxAnchors[anchor].length > 0) {
|
|
145
|
+
reduxAnchors[anchor].forEach((currentFn) => {
|
|
146
|
+
currentFn.call(null, ...args);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
export function RunOverrideActionAnchor(action) {
|
|
151
|
+
let overridedAction = action;
|
|
152
|
+
if (Object.prototype.hasOwnProperty.call(actionOverrideAnchor, action.type) &&
|
|
153
|
+
actionOverrideAnchor[action.type].length > 0) {
|
|
154
|
+
actionOverrideAnchor[action.type].forEach((currentFn) => {
|
|
155
|
+
overridedAction = currentFn.call(null, overridedAction);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return overridedAction;
|
|
159
|
+
}
|
|
160
|
+
const loadPluginFiles = (pluginsList) => __awaiter(void 0, void 0, void 0, function* () {
|
|
161
|
+
const plugins = Object.keys(pluginsList);
|
|
162
|
+
const pluginModules = yield Promise.all(plugins.map((plugin) => Globals.loadPlugin(plugin)));
|
|
163
|
+
plugins.forEach((plugin, index) => {
|
|
164
|
+
const pluginModule = pluginModules[index];
|
|
165
|
+
const anchors = pluginModule.default;
|
|
166
|
+
const { loader } = pluginModule;
|
|
167
|
+
if (loader !== undefined) {
|
|
168
|
+
loader(getStore().dispatch, getHistory(), getConfig());
|
|
169
|
+
}
|
|
170
|
+
Object.keys(anchors).forEach((anchor) => {
|
|
171
|
+
if (anchor === "replace") {
|
|
172
|
+
Object.keys(anchors[anchor]).forEach((replacer) => {
|
|
173
|
+
if (!Object.prototype.hasOwnProperty.call(replacers, replacer)) {
|
|
174
|
+
replacers[replacer] = [];
|
|
175
|
+
}
|
|
176
|
+
replacers[replacer].push(anchors[anchor][replacer]);
|
|
177
|
+
});
|
|
104
178
|
return;
|
|
105
179
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
pluginPromise = Promise.resolve(pluginValue());
|
|
180
|
+
if (anchor === "appstates") {
|
|
181
|
+
pluginAppStates(anchors.appstates);
|
|
110
182
|
}
|
|
111
|
-
|
|
112
|
-
|
|
183
|
+
if (anchor === "redux") {
|
|
184
|
+
Object.keys(anchors[anchor]).forEach((action) => {
|
|
185
|
+
if (reduxAnchors[action] === undefined)
|
|
186
|
+
reduxAnchors[action] = [];
|
|
187
|
+
reduxAnchors[action].push(anchors[anchor][action]);
|
|
188
|
+
});
|
|
113
189
|
return;
|
|
114
190
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
console.warn(`Plugin "${key}" has invalid format, skipping...`);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
promises.push(pluginPromise.then((plugin) => {
|
|
127
|
-
if (!plugin)
|
|
191
|
+
if (anchor === "actionOverride") {
|
|
192
|
+
Object.keys(anchors[anchor]).forEach((action) => {
|
|
193
|
+
if (actionOverrideAnchor[action] === undefined)
|
|
194
|
+
actionOverrideAnchor[action] = [];
|
|
195
|
+
actionOverrideAnchor[action].push(anchors[anchor][action]);
|
|
196
|
+
});
|
|
128
197
|
return;
|
|
129
|
-
if (plugin.redux) {
|
|
130
|
-
pluginsStoreReducers = Object.assign(Object.assign({}, pluginsStoreReducers), { [key]: plugin.redux.reducer });
|
|
131
|
-
pluginsSagas = [...pluginsSagas, ...plugin.redux.sagas];
|
|
132
198
|
}
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
type: "@@PLUGIN/ADD_CONFIG",
|
|
138
|
-
payload: {
|
|
139
|
-
config: [...existingConfig, ...plugin.config],
|
|
140
|
-
},
|
|
199
|
+
if (anchor === "additionalRoutes") {
|
|
200
|
+
Object.keys(anchors[anchor]).forEach((route) => {
|
|
201
|
+
PluginAdditionRoutes[anchors[anchor][route].path] =
|
|
202
|
+
anchors[anchor][route].component;
|
|
141
203
|
});
|
|
204
|
+
return;
|
|
142
205
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
export function getPluginsReducers() {
|
|
150
|
-
return pluginsStoreReducers;
|
|
151
|
-
}
|
|
152
|
-
export function getPluginsAdditionalRoutes() {
|
|
153
|
-
const routes = [];
|
|
154
|
-
const plugins = getStore().getState().pluginsStore;
|
|
155
|
-
if ((plugins === null || plugins === void 0 ? void 0 : plugins.config) && Array.isArray(plugins.config)) {
|
|
156
|
-
plugins.config.forEach((p) => {
|
|
157
|
-
if (p.anchor[0] === "routes") {
|
|
158
|
-
routes.push(p);
|
|
206
|
+
if (anchor === "reduxStore" && anchors[anchor].reducer) {
|
|
207
|
+
pluginsStoreReducers[plugin] = anchors[anchor].reducer;
|
|
208
|
+
}
|
|
209
|
+
if (anchor === "reduxStore" && anchors[anchor].sagas) {
|
|
210
|
+
pluginsStoreSagas[plugin] = anchors[anchor].sagas;
|
|
159
211
|
}
|
|
212
|
+
if (!Object.prototype.hasOwnProperty.call(globalAnchors, anchor))
|
|
213
|
+
globalAnchors[anchor] = [];
|
|
214
|
+
globalAnchors[anchor].push(anchors[anchor]);
|
|
160
215
|
});
|
|
216
|
+
if (typeof anchors.onLoad === "function")
|
|
217
|
+
anchors.onLoad();
|
|
218
|
+
});
|
|
219
|
+
if (Object.keys(pluginsStoreReducers).length > 0 ||
|
|
220
|
+
Object.keys(pluginsStoreSagas).length > 0) {
|
|
221
|
+
getStore().dispatch({ type: INIT_PLUGINS });
|
|
161
222
|
}
|
|
162
|
-
|
|
223
|
+
});
|
|
224
|
+
export const loadPlugins = (plugins) => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
|
+
let pluginsList;
|
|
226
|
+
if (!plugins)
|
|
227
|
+
pluginsList = getConfig().plugins;
|
|
228
|
+
else
|
|
229
|
+
pluginsList = plugins;
|
|
230
|
+
if (pluginsList === undefined) {
|
|
231
|
+
pluginsList = getConfig().plugins;
|
|
232
|
+
}
|
|
233
|
+
yield loadPluginFiles(pluginsList);
|
|
234
|
+
pluginsLoadingDone = true;
|
|
235
|
+
});
|
|
236
|
+
export const pluginsLoaded = () => pluginsLoadingDone;
|
|
237
|
+
export const getPluginsAdditionalRoutes = () => PluginAdditionRoutes;
|
|
238
|
+
export function getPluginsReducers() {
|
|
239
|
+
return pluginsStoreReducers;
|
|
163
240
|
}
|
|
164
241
|
export function getPluginsSagas() {
|
|
165
|
-
return
|
|
242
|
+
return pluginsStoreSagas;
|
|
166
243
|
}
|
|
167
|
-
export
|
|
244
|
+
export const clearPlugins = () => {
|
|
245
|
+
globalAnchors = {};
|
|
246
|
+
reduxAnchors = {};
|
|
247
|
+
actionOverrideAnchor = {};
|
|
248
|
+
replacers = {};
|
|
249
|
+
PluginsAppStatesRegistrers = [];
|
|
250
|
+
PluginsPageAppStates = {};
|
|
251
|
+
PluginsAppStatesComponents = {};
|
|
252
|
+
PluginAdditionRoutes = {};
|
|
253
|
+
cache = {};
|
|
254
|
+
pluginsLoadingDone = false;
|
|
168
255
|
pluginsStoreReducers = {};
|
|
169
|
-
|
|
170
|
-
const store = getStore(false);
|
|
171
|
-
if (store) {
|
|
172
|
-
store.dispatch({
|
|
173
|
-
type: "@@PLUGIN/ADD_CONFIG",
|
|
174
|
-
payload: {
|
|
175
|
-
config: [],
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
export const RunActionAnchor = () => { };
|
|
181
|
-
export const RunOverrideActionAnchor = () => { };
|
|
182
|
-
export const registerPluginsAppStates = (appStates) => appStates || [];
|
|
183
|
-
export const getPluginsStoreReducers = getPluginsReducers;
|
|
184
|
-
export const getPluginsStoreSagas = getPluginsSagas;
|
|
256
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LoadableComponent } from "@loadable/component";
|
|
2
|
+
import type React from "react";
|
|
2
3
|
import type { Reducer } from "redux";
|
|
3
4
|
import type { ActionsLibraryType } from "./getActions.type";
|
|
4
5
|
import type { StateType } from "./State.type";
|
|
@@ -18,6 +19,23 @@ export type IPluginConfigReduxWithState<T extends Record<string, any> = {}, K ex
|
|
|
18
19
|
stateKey: K;
|
|
19
20
|
};
|
|
20
21
|
export interface IPlugin {
|
|
21
|
-
config
|
|
22
|
+
config?: IPluginConfig[];
|
|
22
23
|
redux?: IPluginConfigRedux;
|
|
24
|
+
reduxStore?: {
|
|
25
|
+
reducer: IPluginConfigReduxReducer;
|
|
26
|
+
sagas?: IPluginConfigReduxSaga[];
|
|
27
|
+
};
|
|
28
|
+
replace?: Record<string, React.ComponentType<any> | React.LazyExoticComponent<React.ComponentType<any>>>;
|
|
29
|
+
appstates?: {
|
|
30
|
+
register?: (currentAppStates: string[]) => string[];
|
|
31
|
+
pageAppState?: Record<string, string>;
|
|
32
|
+
components?: Record<string, React.ComponentType<any> | React.LazyExoticComponent<React.ComponentType<any>>>;
|
|
33
|
+
};
|
|
34
|
+
actionOverride?: Record<string, (action: any) => any>;
|
|
35
|
+
additionalRoutes?: Array<{
|
|
36
|
+
path: string;
|
|
37
|
+
component: React.ComponentType<any> | React.LazyExoticComponent<React.ComponentType<any>>;
|
|
38
|
+
}>;
|
|
39
|
+
paginationAfterNext?: React.ComponentType<any> | React.LazyExoticComponent<React.ComponentType<any>>;
|
|
40
|
+
[key: string]: any;
|
|
23
41
|
}
|