@legalplace/wizardx-core 4.42.10-nightly.20251125151716 → 4.42.10-nightly.20251125154431
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useDispatch(): import("redux").Dispatch<
|
|
1
|
+
export declare function useDispatch(): import("redux").Dispatch<import("redux").AnyAction>;
|
|
@@ -5,4 +5,4 @@ export type SelectorArguments<F extends SelectorFunction> = F extends (state: St
|
|
|
5
5
|
export type SelectorReturn<F extends SelectorFunction> = F extends (state: StateType, ...a: any[]) => infer R ? R : never;
|
|
6
6
|
export type SelectorCacheKeyFunction<T extends SelectorFunction> = (state: StateType, ...a: SelectorArguments<T>) => string | false;
|
|
7
7
|
export declare function createSelector<T extends SelectorFunction, R = SelectorReturn<T>>(selector: T, cacheKey?: SelectorCacheKeyFunction<T> | false): (...args: SelectorArguments<T>) => Readonly<R>;
|
|
8
|
-
export declare const selectorsMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: Action) => Action
|
|
8
|
+
export declare const selectorsMiddleware: (mpi: MiddlewareAPI<Dispatch, StateType>) => (next: Dispatch) => (action: Action) => Action;
|
|
@@ -6,22 +6,25 @@ export function createSelector(selector, cacheKey) {
|
|
|
6
6
|
const cache = selectorsCache.create();
|
|
7
7
|
return (...args) => {
|
|
8
8
|
let state;
|
|
9
|
-
if (
|
|
10
|
-
throw new Error("
|
|
9
|
+
if (!globalMPI) {
|
|
10
|
+
throw new Error("Selectors middleware not initialized. Ensure the store is created before using selectors.");
|
|
11
|
+
}
|
|
11
12
|
try {
|
|
12
13
|
state = globalMPI.getState();
|
|
13
14
|
}
|
|
14
15
|
catch (e) {
|
|
15
|
-
throw new Error("
|
|
16
|
+
throw new Error("Selectors cannot be used while a reducer is executing. " +
|
|
17
|
+
"Use selectors in components, sagas, or middlewares instead.");
|
|
16
18
|
}
|
|
17
19
|
if (cacheKey === false) {
|
|
18
20
|
return selector(state, ...args);
|
|
19
21
|
}
|
|
20
22
|
const currentKey = typeof cacheKey === "function"
|
|
21
23
|
? cacheKey(state, ...args)
|
|
22
|
-
: [SelectorsStateTrack, ...args].reduce((
|
|
23
|
-
if (!currentKey)
|
|
24
|
+
: [SelectorsStateTrack, ...args].reduce((acc, val) => acc + String(val), "");
|
|
25
|
+
if (!currentKey) {
|
|
24
26
|
return selector(state, ...args);
|
|
27
|
+
}
|
|
25
28
|
if (!cache.has(currentKey)) {
|
|
26
29
|
const value = selector(state, ...args);
|
|
27
30
|
cache.add(currentKey, value);
|
|
@@ -30,11 +33,12 @@ export function createSelector(selector, cacheKey) {
|
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
export const selectorsMiddleware = (mpi) => (next) => (action) => {
|
|
36
|
+
globalMPI = mpi;
|
|
33
37
|
const result = next(action);
|
|
38
|
+
SelectorsStateTrack += 1;
|
|
34
39
|
if (action.type === RESET_STATE) {
|
|
35
40
|
selectorsCache.clear();
|
|
41
|
+
SelectorsStateTrack = 0;
|
|
36
42
|
}
|
|
37
|
-
globalMPI = mpi;
|
|
38
|
-
SelectorsStateTrack += 1;
|
|
39
43
|
return result;
|
|
40
44
|
};
|
package/dist/redux/store.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { Store } from "redux";
|
|
2
2
|
import type { StateType } from "../types/State.type";
|
|
3
|
-
export declare const createAppStore: (historyType?: "browser" | "memory") => Store<StateType
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<StateType, any> & {
|
|
7
|
-
dispatch: unknown;
|
|
8
|
-
};
|
|
3
|
+
export declare const createAppStore: (historyType?: "browser" | "memory") => Store<StateType>;
|
|
4
|
+
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<StateType>;
|
package/dist/redux/store.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { configureStore } from "@reduxjs/toolkit";
|
|
2
2
|
import { connectRouter, routerMiddleware } from "connected-react-router";
|
|
3
|
-
import { composeWithDevTools } from "redux-devtools-extension";
|
|
4
3
|
import { appReducer } from "./reducers/app";
|
|
5
4
|
import { userReducer } from "./reducers/user";
|
|
6
5
|
import { referencesReducer } from "./reducers/references";
|
|
@@ -31,29 +30,71 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
31
30
|
return store;
|
|
32
31
|
}
|
|
33
32
|
const history = createHistory(historyType);
|
|
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,
|
|
44
|
-
});
|
|
45
33
|
const sagaMiddleware = getSagaMiddleware();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
store = configureStore({
|
|
35
|
+
reducer: {
|
|
36
|
+
router: connectRouter(history),
|
|
37
|
+
app: appReducer,
|
|
38
|
+
user: userReducer,
|
|
39
|
+
references: referencesReducer,
|
|
40
|
+
inputs: inputsReducer,
|
|
41
|
+
mandatories: mandatoriesReducer,
|
|
42
|
+
conditions: conditionsReducer,
|
|
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,
|
|
89
|
+
});
|
|
51
90
|
sagasRunner(sagaMiddleware);
|
|
52
91
|
subscribeListeners(store);
|
|
92
|
+
store.dispatch({ type: "@@WIZARDX/INIT" });
|
|
53
93
|
return store;
|
|
54
94
|
};
|
|
55
95
|
export const getStore = (throwIfDoesNotExist = true) => {
|
|
56
|
-
if (store === undefined && throwIfDoesNotExist)
|
|
57
|
-
throw new Error("Store not yet created");
|
|
96
|
+
if (store === undefined && throwIfDoesNotExist) {
|
|
97
|
+
throw new Error("Store not yet created. Call createAppStore() first before accessing the store.");
|
|
98
|
+
}
|
|
58
99
|
return store;
|
|
59
100
|
};
|
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.20251125154431",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -60,6 +60,7 @@
|
|
|
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",
|
|
63
64
|
"axios": "^0.24.0",
|
|
64
65
|
"connected-react-router": "^6.8.0",
|
|
65
66
|
"crypto-js": "^4.1.1",
|