@legalplace/wizardx-core 4.42.10-nightly.20251125160329 → 4.42.10-nightly.20251125161338
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
CHANGED
|
@@ -18,7 +18,7 @@ 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[];
|
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,13 +86,29 @@ 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(
|
|
92
|
-
if (plugin.redux) {
|
|
110
|
+
promises.push(pluginPromise.then((plugin) => {
|
|
111
|
+
if (plugin && plugin.redux) {
|
|
93
112
|
pluginsStoreReducers = Object.assign(Object.assign({}, pluginsStoreReducers), { [key]: plugin.redux.reducer });
|
|
94
113
|
pluginsSagas = [...pluginsSagas, ...plugin.redux.sagas];
|
|
95
114
|
}
|
|
@@ -105,11 +124,13 @@ export function getPluginsReducers() {
|
|
|
105
124
|
export function getPluginsAdditionalRoutes() {
|
|
106
125
|
const routes = [];
|
|
107
126
|
const plugins = getStore().getState().pluginsStore;
|
|
108
|
-
plugins.config.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
127
|
+
if ((plugins === null || plugins === void 0 ? void 0 : plugins.config) && Array.isArray(plugins.config)) {
|
|
128
|
+
plugins.config.forEach((p) => {
|
|
129
|
+
if (p.anchor[0] === "routes") {
|
|
130
|
+
routes.push(p);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
113
134
|
return routes;
|
|
114
135
|
}
|
|
115
136
|
export function getPluginsSagas() {
|
|
@@ -1,8 +1,11 @@
|
|
|
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;
|
|
6
9
|
const pluginsStoreReducers = getPluginsStoreReducers();
|
|
7
10
|
const plugins = Object.keys(pluginsStoreReducers);
|
|
8
11
|
const newState = Object.assign({}, state);
|