@legalplace/wizardx-core 4.42.10-nightly.20251125160107 → 4.42.10-nightly.20251125160911
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/App.js +1 -1
- package/dist/PluginLoader.d.ts +2 -2
- package/dist/PluginLoader.js +53 -11
- package/dist/WizardCore.js +3 -2
- package/dist/redux/reducers/pluginsStore.js +8 -2
- package/dist/redux/store.d.ts +5 -3
- package/dist/redux/store.js +21 -62
- package/dist/routing/RouterSync.d.ts +1 -0
- package/dist/routing/RouterSync.js +12 -0
- package/dist/types/State.type.d.ts +2 -1
- package/package.json +2 -2
package/dist/App.js
CHANGED
|
@@ -77,7 +77,7 @@ class WizardXCore extends React.Component {
|
|
|
77
77
|
getStore().dispatch(resetStateAction());
|
|
78
78
|
}
|
|
79
79
|
render() {
|
|
80
|
-
return (
|
|
80
|
+
return (_jsx(Provider, { store: getStore(), children: _jsx(ConnectedRouter, { history: getHistory(), children: _jsxs(Switch, { children: [_jsx(Route, { path: "/p/:path", component: PluginRoute }), _jsx(Route, { path: getConfig().router.smartscriptPath, exact: true, strict: true, component: SmartScriptComponent }), _jsx(Route, { path: getConfig().router.wizardInstancePath, component: ViewComponent }), _jsx(Route, { path: getConfig().router.wizardPath, component: ViewComponent }), !window.location.href.includes("smartscript") && (_jsx(Route, { component: RedirectHandler }))] }) }) }));
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
export default WizardXCore;
|
package/dist/PluginLoader.d.ts
CHANGED
|
@@ -18,14 +18,14 @@ export type ReplaceFragmentPropsType = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare const ReplaceFragment: ({ replacerName, fragmentName, children, }: ReplaceFragmentPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
export declare function registerReplacer(replacerName: string, Replacer: ReactComponent<any>): void;
|
|
21
|
-
export declare function loadPlugins(plugins?: Record<string, () => Promise<IPlugin
|
|
21
|
+
export declare function loadPlugins(plugins?: Record<string, (() => Promise<IPlugin>) | Promise<IPlugin> | IPlugin>): Promise<any>;
|
|
22
22
|
export declare function getPluginsReducers(): Record<string, Reducer<Record<string, any>, any>>;
|
|
23
23
|
export declare function getPluginsAdditionalRoutes(): IPluginConfig[];
|
|
24
24
|
export declare function getPluginsSagas(): Saga[];
|
|
25
25
|
export declare function clearPlugins(): void;
|
|
26
26
|
export declare const RunActionAnchor: () => void;
|
|
27
27
|
export declare const RunOverrideActionAnchor: () => void;
|
|
28
|
-
export declare const registerPluginsAppStates: () =>
|
|
28
|
+
export declare const registerPluginsAppStates: (appStates: any) => any;
|
|
29
29
|
export declare const getPluginsStoreReducers: typeof getPluginsReducers;
|
|
30
30
|
export declare const getPluginsStoreSagas: typeof getPluginsSagas;
|
|
31
31
|
export {};
|
package/dist/PluginLoader.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { getStore } from "./redux/store";
|
|
4
4
|
let pluginsStoreReducers = {};
|
|
@@ -8,6 +8,9 @@ export const PluginLoader = (props) => {
|
|
|
8
8
|
const { anchor } = props;
|
|
9
9
|
const plugins = getStore().getState().pluginsStore;
|
|
10
10
|
let Plugins = [];
|
|
11
|
+
if (!plugins || !plugins.config || !Array.isArray(plugins.config)) {
|
|
12
|
+
return _jsx(_Fragment, {});
|
|
13
|
+
}
|
|
11
14
|
const matchedPlugins = plugins.config.filter((p) => {
|
|
12
15
|
if (p.anchor.length !== anchor.length)
|
|
13
16
|
return false;
|
|
@@ -83,16 +86,44 @@ export function loadPlugins(plugins) {
|
|
|
83
86
|
}
|
|
84
87
|
const store = getStore();
|
|
85
88
|
Object.keys(plugins).forEach((key) => {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
const pluginValue = plugins[key];
|
|
90
|
+
let pluginPromise;
|
|
91
|
+
if (typeof pluginValue === "function") {
|
|
92
|
+
try {
|
|
93
|
+
pluginPromise = Promise.resolve(pluginValue());
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error(`Failed to execute plugin "${key}" loader:`, error);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else if (pluginValue && typeof pluginValue === "object" && "then" in pluginValue) {
|
|
101
|
+
pluginPromise = pluginValue;
|
|
102
|
+
}
|
|
103
|
+
else if (pluginValue && typeof pluginValue === "object") {
|
|
104
|
+
pluginPromise = Promise.resolve(pluginValue);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
console.warn(`Plugin "${key}" has invalid format, skipping...`);
|
|
89
108
|
return;
|
|
90
109
|
}
|
|
91
|
-
promises.push(
|
|
110
|
+
promises.push(pluginPromise.then((plugin) => {
|
|
111
|
+
if (!plugin)
|
|
112
|
+
return;
|
|
92
113
|
if (plugin.redux) {
|
|
93
114
|
pluginsStoreReducers = Object.assign(Object.assign({}, pluginsStoreReducers), { [key]: plugin.redux.reducer });
|
|
94
115
|
pluginsSagas = [...pluginsSagas, ...plugin.redux.sagas];
|
|
95
116
|
}
|
|
117
|
+
if (plugin.config && Array.isArray(plugin.config)) {
|
|
118
|
+
const currentState = store.getState().pluginsStore;
|
|
119
|
+
const existingConfig = currentState.config || [];
|
|
120
|
+
store.dispatch({
|
|
121
|
+
type: "@@PLUGIN/ADD_CONFIG",
|
|
122
|
+
payload: {
|
|
123
|
+
config: [...existingConfig, ...plugin.config],
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
96
127
|
}).catch((error) => {
|
|
97
128
|
console.error(`Failed to load plugin "${key}":`, error);
|
|
98
129
|
}));
|
|
@@ -105,11 +136,13 @@ export function getPluginsReducers() {
|
|
|
105
136
|
export function getPluginsAdditionalRoutes() {
|
|
106
137
|
const routes = [];
|
|
107
138
|
const plugins = getStore().getState().pluginsStore;
|
|
108
|
-
plugins.config.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
139
|
+
if ((plugins === null || plugins === void 0 ? void 0 : plugins.config) && Array.isArray(plugins.config)) {
|
|
140
|
+
plugins.config.forEach((p) => {
|
|
141
|
+
if (p.anchor[0] === "routes") {
|
|
142
|
+
routes.push(p);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
113
146
|
return routes;
|
|
114
147
|
}
|
|
115
148
|
export function getPluginsSagas() {
|
|
@@ -118,9 +151,18 @@ export function getPluginsSagas() {
|
|
|
118
151
|
export function clearPlugins() {
|
|
119
152
|
pluginsStoreReducers = {};
|
|
120
153
|
pluginsSagas = [];
|
|
154
|
+
const store = getStore(false);
|
|
155
|
+
if (store) {
|
|
156
|
+
store.dispatch({
|
|
157
|
+
type: "@@PLUGIN/ADD_CONFIG",
|
|
158
|
+
payload: {
|
|
159
|
+
config: [],
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
}
|
|
121
163
|
}
|
|
122
164
|
export const RunActionAnchor = () => { };
|
|
123
165
|
export const RunOverrideActionAnchor = () => { };
|
|
124
|
-
export const registerPluginsAppStates = () =>
|
|
166
|
+
export const registerPluginsAppStates = (appStates) => appStates || [];
|
|
125
167
|
export const getPluginsStoreReducers = getPluginsReducers;
|
|
126
168
|
export const getPluginsStoreSagas = getPluginsSagas;
|
package/dist/WizardCore.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Provider } from "react-redux";
|
|
4
4
|
import { getStore, createAppStore } from "./redux/store";
|
|
@@ -17,6 +17,7 @@ import { externalPartnerRedirectUrl } from "./helpers/redirectionConfig";
|
|
|
17
17
|
import { autoSave } from "./helpers/autosave.helper";
|
|
18
18
|
import { NOT_FOUND_PAGE_LINK } from "./constants/links.constant";
|
|
19
19
|
import { RouterProvider } from "./routing/context";
|
|
20
|
+
import { RouterSync } from "./routing/RouterSync";
|
|
20
21
|
const getRouteComponent = (pathname, params) => {
|
|
21
22
|
if (pathname.startsWith("/p/")) {
|
|
22
23
|
const pluginPath = params.path || pathname.replace("/p/", "");
|
|
@@ -134,7 +135,7 @@ class WizardCore extends React.Component {
|
|
|
134
135
|
return (_jsx(Provider, { store: store, children: _jsx(RedirectHandler, { navigate: navigate }) }));
|
|
135
136
|
}
|
|
136
137
|
if (routerAdapter) {
|
|
137
|
-
return (_jsx(Provider, { store: store, children:
|
|
138
|
+
return (_jsx(Provider, { store: store, children: _jsxs(RouterProvider, { adapter: routerAdapter, children: [_jsx(RouterSync, {}), _jsx(WizardCoreContent, {})] }) }));
|
|
138
139
|
}
|
|
139
140
|
console.warn("WizardCore: No routing mechanism provided. Pass either 'routerAdapter' or 'routing' props.");
|
|
140
141
|
return (_jsx(Provider, { store: store, children: _jsx("div", { children: "No routing configured" }) }));
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { getPluginsStoreReducers } from "../../PluginLoader";
|
|
2
2
|
import { RESET_STATE } from "../constants/app";
|
|
3
|
-
|
|
3
|
+
const initialState = {
|
|
4
|
+
config: [],
|
|
5
|
+
};
|
|
6
|
+
export const pluginsStoreReducer = (state = initialState, action) => {
|
|
4
7
|
if (action.type === RESET_STATE)
|
|
5
|
-
return
|
|
8
|
+
return initialState;
|
|
9
|
+
if (action.type === "@@PLUGIN/ADD_CONFIG") {
|
|
10
|
+
return Object.assign(Object.assign({}, state), { config: action.payload.config });
|
|
11
|
+
}
|
|
6
12
|
const pluginsStoreReducers = getPluginsStoreReducers();
|
|
7
13
|
const plugins = Object.keys(pluginsStoreReducers);
|
|
8
14
|
const newState = Object.assign({}, state);
|
package/dist/redux/store.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { Store } from "redux";
|
|
1
|
+
import type { Store, EmptyObject, AnyAction } from "redux";
|
|
2
2
|
import type { StateType } from "../types/State.type";
|
|
3
|
-
export declare const createAppStore: (historyType?: "browser" | "memory") =>
|
|
4
|
-
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<StateType
|
|
3
|
+
export declare const createAppStore: (historyType?: "browser" | "memory") => void;
|
|
4
|
+
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<EmptyObject & StateType, AnyAction> & {
|
|
5
|
+
dispatch: unknown;
|
|
6
|
+
};
|
package/dist/redux/store.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { combineReducers, legacy_createStore as createStore, applyMiddleware } from "redux";
|
|
2
2
|
import { connectRouter, routerMiddleware } from "connected-react-router";
|
|
3
|
+
import { composeWithDevTools } from "redux-devtools-extension";
|
|
3
4
|
import { appReducer } from "./reducers/app";
|
|
4
5
|
import { userReducer } from "./reducers/user";
|
|
5
6
|
import { referencesReducer } from "./reducers/references";
|
|
@@ -27,74 +28,32 @@ let store;
|
|
|
27
28
|
export const createAppStore = (historyType = "browser") => {
|
|
28
29
|
if (store !== undefined) {
|
|
29
30
|
createHistory(historyType);
|
|
30
|
-
return
|
|
31
|
+
return;
|
|
31
32
|
}
|
|
32
33
|
const history = createHistory(historyType);
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
smartscript: smartscriptReducer,
|
|
44
|
-
pluginsStore: pluginsStoreReducer,
|
|
45
|
-
},
|
|
46
|
-
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
47
|
-
serializableCheck: {
|
|
48
|
-
ignoredActions: [
|
|
49
|
-
"@@router/LOCATION_CHANGE",
|
|
50
|
-
"@@router/CALL_HISTORY_METHOD",
|
|
51
|
-
],
|
|
52
|
-
ignoredPaths: ["router"],
|
|
53
|
-
},
|
|
54
|
-
immutableCheck: Globals.appEnv !== "production",
|
|
55
|
-
})
|
|
56
|
-
.concat([
|
|
57
|
-
pluginsHookMiddleware,
|
|
58
|
-
routerMiddleware(history),
|
|
59
|
-
sagaMiddleware,
|
|
60
|
-
paginationWatcherMiddleware,
|
|
61
|
-
selectorsMiddleware,
|
|
62
|
-
conditionsWatcherMiddleware,
|
|
63
|
-
prefillerWatcherMiddleware,
|
|
64
|
-
evaluationsWatcherMiddleware,
|
|
65
|
-
multiplesActionsMiddleware,
|
|
66
|
-
mandatoriesWatcherMiddleware,
|
|
67
|
-
smartscriptMiddleware,
|
|
68
|
-
thirdPartyScriptsMiddleware,
|
|
69
|
-
]),
|
|
70
|
-
devTools: Globals.appEnv !== "production"
|
|
71
|
-
? {
|
|
72
|
-
name: "WizardX Core",
|
|
73
|
-
trace: true,
|
|
74
|
-
traceLimit: 25,
|
|
75
|
-
features: {
|
|
76
|
-
pause: true,
|
|
77
|
-
lock: true,
|
|
78
|
-
persist: true,
|
|
79
|
-
export: true,
|
|
80
|
-
import: "custom",
|
|
81
|
-
jump: true,
|
|
82
|
-
skip: true,
|
|
83
|
-
reorder: true,
|
|
84
|
-
dispatch: true,
|
|
85
|
-
test: true,
|
|
86
|
-
},
|
|
87
|
-
}
|
|
88
|
-
: false,
|
|
34
|
+
const wizardxReducers = combineReducers({
|
|
35
|
+
router: connectRouter(history),
|
|
36
|
+
app: appReducer,
|
|
37
|
+
user: userReducer,
|
|
38
|
+
references: referencesReducer,
|
|
39
|
+
inputs: inputsReducer,
|
|
40
|
+
mandatories: mandatoriesReducer,
|
|
41
|
+
conditions: conditionsReducer,
|
|
42
|
+
smartscript: smartscriptReducer,
|
|
43
|
+
pluginsStore: pluginsStoreReducer,
|
|
89
44
|
});
|
|
45
|
+
const sagaMiddleware = getSagaMiddleware();
|
|
46
|
+
const appliedMiddlewares = applyMiddleware(pluginsHookMiddleware, routerMiddleware(history), sagaMiddleware, paginationWatcherMiddleware, selectorsMiddleware, conditionsWatcherMiddleware, prefillerWatcherMiddleware, evaluationsWatcherMiddleware, multiplesActionsMiddleware, mandatoriesWatcherMiddleware, smartscriptMiddleware, thirdPartyScriptsMiddleware);
|
|
47
|
+
const middlewares = Globals.appEnv !== "production"
|
|
48
|
+
? composeWithDevTools(appliedMiddlewares)
|
|
49
|
+
: appliedMiddlewares;
|
|
50
|
+
store = createStore(wizardxReducers, middlewares);
|
|
90
51
|
sagasRunner(sagaMiddleware);
|
|
91
52
|
subscribeListeners(store);
|
|
92
53
|
store.dispatch({ type: "@@WIZARDX/INIT" });
|
|
93
|
-
return store;
|
|
94
54
|
};
|
|
95
55
|
export const getStore = (throwIfDoesNotExist = true) => {
|
|
96
|
-
if (store === undefined && throwIfDoesNotExist)
|
|
97
|
-
throw new Error("Store not yet created
|
|
98
|
-
}
|
|
56
|
+
if (store === undefined && throwIfDoesNotExist)
|
|
57
|
+
throw new Error("Store not yet created");
|
|
99
58
|
return store;
|
|
100
59
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RouterSync: () => null;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useDispatch } from "react-redux";
|
|
3
|
+
import { useLocation } from "./context";
|
|
4
|
+
import { push } from "connected-react-router";
|
|
5
|
+
export const RouterSync = () => {
|
|
6
|
+
const location = useLocation();
|
|
7
|
+
const dispatch = useDispatch();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
dispatch(push(location.pathname + location.search));
|
|
10
|
+
}, [location.pathname, location.search, dispatch]);
|
|
11
|
+
return null;
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.42.10-nightly.
|
|
3
|
+
"version": "4.42.10-nightly.20251125160911",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"@legalplace/typeorm-constants": "^3.74.4",
|
|
61
61
|
"@loadable/component": "^5.15.0",
|
|
62
62
|
"@redux-saga/core": "^1.1.3",
|
|
63
|
-
"@reduxjs/toolkit": "^2.11.0",
|
|
64
63
|
"axios": "^0.24.0",
|
|
65
64
|
"connected-react-router": "^6.8.0",
|
|
66
65
|
"crypto-js": "^4.1.1",
|
|
@@ -112,6 +111,7 @@
|
|
|
112
111
|
"jest-junit": "^13.0.0",
|
|
113
112
|
"lodash": "^4.17.21",
|
|
114
113
|
"react-async-ssr": "^0.7.2",
|
|
114
|
+
"redux-devtools-extension": "^2.13.9",
|
|
115
115
|
"redux-mock-store": "^1.5.4",
|
|
116
116
|
"regenerator-runtime": "^0.13.9",
|
|
117
117
|
"rimraf": "^3.0.2",
|