@chatbi-v/core 2.1.1 → 2.1.2
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/{chunk-4AJ6VW5G.mjs → chunk-QET56C3T.mjs} +1 -0
- package/dist/chunk-QET56C3T.mjs.map +1 -0
- package/dist/{config-manager-F3GYW4BE.mjs → config-manager-3TKURRUT.mjs} +2 -1
- package/dist/config-manager-3TKURRUT.mjs.map +1 -0
- package/dist/index.d.mts +1748 -0
- package/dist/index.d.ts +1748 -0
- package/dist/index.js +75 -47
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +60 -33
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -114,6 +114,7 @@ __export(index_exports, {
|
|
|
114
114
|
ServiceRegistry: () => ServiceRegistry,
|
|
115
115
|
SidebarIconSkeleton: () => SidebarIconSkeleton,
|
|
116
116
|
Slot: () => Slot,
|
|
117
|
+
SlotSkeletons: () => SlotSkeletons,
|
|
117
118
|
StatusBarItemSkeleton: () => StatusBarItemSkeleton,
|
|
118
119
|
StorageManager: () => StorageManager,
|
|
119
120
|
apiEngine: () => apiEngine,
|
|
@@ -542,6 +543,9 @@ var useApi = () => {
|
|
|
542
543
|
init_config_manager();
|
|
543
544
|
|
|
544
545
|
// src/components/PluginErrorBoundary.tsx
|
|
546
|
+
var import_react3 = require("react");
|
|
547
|
+
|
|
548
|
+
// src/domain/plugin-manager.ts
|
|
545
549
|
var import_react2 = require("react");
|
|
546
550
|
|
|
547
551
|
// src/adapters/local-storage-adapter.ts
|
|
@@ -1450,18 +1454,20 @@ var PluginManager = class {
|
|
|
1450
1454
|
* @param affectedSlot - (可选) 受影响的插槽位置
|
|
1451
1455
|
*/
|
|
1452
1456
|
notify(affectedSlot) {
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1457
|
+
(0, import_react2.startTransition)(() => {
|
|
1458
|
+
if (affectedSlot) {
|
|
1459
|
+
this.memoizedExtensions.delete(String(affectedSlot));
|
|
1460
|
+
} else {
|
|
1461
|
+
this.memoizedExtensions.clear();
|
|
1462
|
+
this.memoizedRoutes = null;
|
|
1463
|
+
}
|
|
1464
|
+
this.listeners.forEach((listener) => listener());
|
|
1465
|
+
if (affectedSlot) {
|
|
1466
|
+
this.slotListeners.get(String(affectedSlot))?.forEach((listener) => listener());
|
|
1467
|
+
} else {
|
|
1468
|
+
this.slotListeners.forEach((set) => set.forEach((listener) => listener()));
|
|
1469
|
+
}
|
|
1470
|
+
});
|
|
1465
1471
|
}
|
|
1466
1472
|
/**
|
|
1467
1473
|
* 获取所有已注册的插件列表
|
|
@@ -2016,7 +2022,7 @@ var pluginManager = new PluginManager(new LocalStorageAdapter());
|
|
|
2016
2022
|
// src/components/PluginErrorBoundary.tsx
|
|
2017
2023
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2018
2024
|
var logger7 = createLogger("PluginErrorBoundary");
|
|
2019
|
-
var PluginErrorBoundary = class extends
|
|
2025
|
+
var PluginErrorBoundary = class extends import_react3.Component {
|
|
2020
2026
|
constructor(props) {
|
|
2021
2027
|
super(props);
|
|
2022
2028
|
this.state = { hasError: false, error: null };
|
|
@@ -2026,7 +2032,10 @@ var PluginErrorBoundary = class extends import_react2.Component {
|
|
|
2026
2032
|
* @param error - 捕获到的错误
|
|
2027
2033
|
*/
|
|
2028
2034
|
static getDerivedStateFromError(error) {
|
|
2029
|
-
|
|
2035
|
+
if (error && typeof error.then === "function") {
|
|
2036
|
+
return { hasError: false, error: null };
|
|
2037
|
+
}
|
|
2038
|
+
return { hasError: true, error: error instanceof Error ? error : new Error(String(error)) };
|
|
2030
2039
|
}
|
|
2031
2040
|
/**
|
|
2032
2041
|
* 捕获到错误后的回调
|
|
@@ -2034,6 +2043,9 @@ var PluginErrorBoundary = class extends import_react2.Component {
|
|
|
2034
2043
|
* @param errorInfo - 错误堆栈信息
|
|
2035
2044
|
*/
|
|
2036
2045
|
componentDidCatch(error, errorInfo) {
|
|
2046
|
+
if (error && typeof error.then === "function") {
|
|
2047
|
+
return;
|
|
2048
|
+
}
|
|
2037
2049
|
logger7.error(`\u63D2\u4EF6 ${this.props.pluginId || "\u672A\u77E5"} \u6E32\u67D3\u53D1\u751F\u9519\u8BEF:`, error, errorInfo);
|
|
2038
2050
|
if (this.props.pluginId) {
|
|
2039
2051
|
console.warn(`[PluginError] \u63D2\u4EF6 "${this.props.pluginId}" \u6E32\u67D3\u5931\u8D25\u3002\u60A8\u53EF\u4EE5\u5728\u63D2\u4EF6\u7BA1\u7406\u9762\u677F\u67E5\u770B\u8BE6\u7EC6\u4FE1\u606F\u3002`);
|
|
@@ -2068,8 +2080,33 @@ var PluginErrorBoundary = class extends import_react2.Component {
|
|
|
2068
2080
|
};
|
|
2069
2081
|
|
|
2070
2082
|
// src/components/PluginSlot.tsx
|
|
2071
|
-
var
|
|
2083
|
+
var import_react4 = require("react");
|
|
2084
|
+
|
|
2085
|
+
// src/components/SlotSkeletons.tsx
|
|
2072
2086
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2087
|
+
var SidebarIconSkeleton = ({ expanded = false }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `flex items-center transition-all duration-300 relative
|
|
2088
|
+
${expanded ? "w-full" : "w-12 justify-center"} px-3 h-11 rounded-xl`, children: [
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-6 h-6 bg-slate-200 dark:bg-white/10 rounded-lg shrink-0 animate-pulse" }),
|
|
2090
|
+
expanded && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "ml-3 flex-1 h-4 bg-slate-200 dark:bg-white/10 rounded animate-pulse" })
|
|
2091
|
+
] });
|
|
2092
|
+
var StatusBarItemSkeleton = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "h-4 w-16 bg-slate-200 dark:bg-white/10 rounded animate-pulse" });
|
|
2093
|
+
var AvatarSkeleton = () => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "w-10 h-10 rounded-full bg-slate-200 dark:bg-white/10 animate-pulse" });
|
|
2094
|
+
var BlockSkeleton = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `bg-slate-200 dark:bg-white/10 rounded animate-pulse ${className || "w-full h-full"}` });
|
|
2095
|
+
var SlotSkeletons = ({ slot, expanded }) => {
|
|
2096
|
+
if (slot.includes("sidebar")) {
|
|
2097
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SidebarIconSkeleton, { expanded });
|
|
2098
|
+
}
|
|
2099
|
+
if (slot.includes("status")) {
|
|
2100
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StatusBarItemSkeleton, {});
|
|
2101
|
+
}
|
|
2102
|
+
if (slot.includes("avatar")) {
|
|
2103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AvatarSkeleton, {});
|
|
2104
|
+
}
|
|
2105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(BlockSkeleton, {});
|
|
2106
|
+
};
|
|
2107
|
+
|
|
2108
|
+
// src/components/PluginSlot.tsx
|
|
2109
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2073
2110
|
var PluginSlot = ({
|
|
2074
2111
|
slot,
|
|
2075
2112
|
props = {},
|
|
@@ -2079,8 +2116,8 @@ var PluginSlot = ({
|
|
|
2079
2116
|
skeleton,
|
|
2080
2117
|
fallback
|
|
2081
2118
|
}) => {
|
|
2082
|
-
const [, forceUpdate] = (0,
|
|
2083
|
-
(0,
|
|
2119
|
+
const [, forceUpdate] = (0, import_react4.useState)({});
|
|
2120
|
+
(0, import_react4.useEffect)(() => {
|
|
2084
2121
|
const unsubscribe = pluginManager.subscribe(() => {
|
|
2085
2122
|
forceUpdate({});
|
|
2086
2123
|
}, slot);
|
|
@@ -2092,47 +2129,36 @@ var PluginSlot = ({
|
|
|
2092
2129
|
logo: pluginManager.getSystemConfig("logo"),
|
|
2093
2130
|
version: pluginManager.getSystemConfig("version")
|
|
2094
2131
|
} : void 0;
|
|
2095
|
-
const mergedProps = (0,
|
|
2132
|
+
const mergedProps = (0, import_react4.useMemo)(() => ({
|
|
2096
2133
|
...props,
|
|
2097
2134
|
systemConfig
|
|
2098
2135
|
}), [props, systemConfig]);
|
|
2099
|
-
const items = (0,
|
|
2136
|
+
const items = (0, import_react4.useMemo)(() => {
|
|
2100
2137
|
return extensions.map((ext, index) => {
|
|
2101
2138
|
const Component2 = ext.component;
|
|
2102
2139
|
const key = ext.meta?.key || `${ext.slot}-${ext.order || 0}-${index}`;
|
|
2103
2140
|
return {
|
|
2104
2141
|
key,
|
|
2105
2142
|
extension: ext,
|
|
2106
|
-
component: /* @__PURE__ */ (0,
|
|
2143
|
+
component: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PluginErrorBoundary, { pluginId: ext._pluginId, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.Suspense, { fallback: skeleton || /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SlotSkeletons, { slot }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component2, { ...mergedProps }) }) }, key)
|
|
2107
2144
|
};
|
|
2108
2145
|
});
|
|
2109
2146
|
}, [extensions, mergedProps]);
|
|
2110
2147
|
if (items.length === 0) {
|
|
2111
2148
|
if (fallback) {
|
|
2112
|
-
return /* @__PURE__ */ (0,
|
|
2149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: fallback });
|
|
2113
2150
|
}
|
|
2114
2151
|
if (skeleton) {
|
|
2115
|
-
return /* @__PURE__ */ (0,
|
|
2152
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `plugin-slot plugin-slot-${slot} plugin-slot-skeleton ${className || ""}`, style, children: skeleton });
|
|
2116
2153
|
}
|
|
2117
2154
|
return null;
|
|
2118
2155
|
}
|
|
2119
2156
|
if (items.length === 1 && slot === "root-layout" && !className && !style && !renderItem) {
|
|
2120
|
-
return /* @__PURE__ */ (0,
|
|
2157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: items[0].component });
|
|
2121
2158
|
}
|
|
2122
|
-
return /* @__PURE__ */ (0,
|
|
2159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `plugin-slot plugin-slot-${slot} ${className || ""}`, style, children: renderItem ? items.map((item, index) => renderItem(item, index)) : items.map((item) => item.component) });
|
|
2123
2160
|
};
|
|
2124
2161
|
|
|
2125
|
-
// src/components/SlotSkeletons.tsx
|
|
2126
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
2127
|
-
var SidebarIconSkeleton = ({ expanded = false }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `flex items-center transition-all duration-300 relative
|
|
2128
|
-
${expanded ? "w-full" : "w-12 justify-center"} px-3 h-11 rounded-xl`, children: [
|
|
2129
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-6 h-6 bg-slate-200 dark:bg-white/10 rounded-lg shrink-0 animate-pulse" }),
|
|
2130
|
-
expanded && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "ml-3 flex-1 h-4 bg-slate-200 dark:bg-white/10 rounded animate-pulse" })
|
|
2131
|
-
] });
|
|
2132
|
-
var StatusBarItemSkeleton = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "h-4 w-16 bg-slate-200 dark:bg-white/10 rounded animate-pulse" });
|
|
2133
|
-
var AvatarSkeleton = () => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-10 h-10 rounded-full bg-slate-200 dark:bg-white/10 animate-pulse" });
|
|
2134
|
-
var BlockSkeleton = ({ className }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `bg-slate-200 dark:bg-white/10 rounded animate-pulse ${className || "w-full h-full"}` });
|
|
2135
|
-
|
|
2136
2162
|
// src/domain/auto-loader.ts
|
|
2137
2163
|
var logger8 = createLogger("AutoLoader");
|
|
2138
2164
|
var DEFAULT_RULES = [
|
|
@@ -2178,14 +2204,14 @@ var resolvePluginRegistry = (options) => {
|
|
|
2178
2204
|
var SUCCESS_CODE = "000000";
|
|
2179
2205
|
|
|
2180
2206
|
// src/plugin-context.tsx
|
|
2181
|
-
var
|
|
2207
|
+
var import_react5 = require("react");
|
|
2182
2208
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2183
|
-
var PluginContext = (0,
|
|
2209
|
+
var PluginContext = (0, import_react5.createContext)(null);
|
|
2184
2210
|
var PluginProvider = ({ manager, children }) => {
|
|
2185
2211
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PluginContext.Provider, { value: manager, children });
|
|
2186
2212
|
};
|
|
2187
2213
|
var usePluginManager = () => {
|
|
2188
|
-
const context = (0,
|
|
2214
|
+
const context = (0, import_react5.useContext)(PluginContext);
|
|
2189
2215
|
if (!context) {
|
|
2190
2216
|
throw new Error("usePluginManager must be used within a PluginProvider");
|
|
2191
2217
|
}
|
|
@@ -2670,15 +2696,15 @@ var dateUtils = {
|
|
|
2670
2696
|
var version = "1.0.0";
|
|
2671
2697
|
|
|
2672
2698
|
// src/hooks/use-storage-state.ts
|
|
2673
|
-
var
|
|
2699
|
+
var import_react6 = require("react");
|
|
2674
2700
|
function useStorageState(pluginId, key, options = {}) {
|
|
2675
2701
|
const { defaultValue, scope = "plugin" } = options;
|
|
2676
2702
|
const storageManager = pluginManager.getStorageManager();
|
|
2677
|
-
const getStorage = (0,
|
|
2703
|
+
const getStorage = (0, import_react6.useCallback)(() => {
|
|
2678
2704
|
const contextStorage = storageManager.getContextStorage(pluginId);
|
|
2679
2705
|
return scope === "shared" ? contextStorage.shared : contextStorage;
|
|
2680
2706
|
}, [pluginId, scope, storageManager]);
|
|
2681
|
-
const [state, setState] = (0,
|
|
2707
|
+
const [state, setState] = (0, import_react6.useState)(() => {
|
|
2682
2708
|
try {
|
|
2683
2709
|
if (typeof window === "undefined") return defaultValue;
|
|
2684
2710
|
const storage = getStorage();
|
|
@@ -2689,7 +2715,7 @@ function useStorageState(pluginId, key, options = {}) {
|
|
|
2689
2715
|
return defaultValue;
|
|
2690
2716
|
}
|
|
2691
2717
|
});
|
|
2692
|
-
const setValue = (0,
|
|
2718
|
+
const setValue = (0, import_react6.useCallback)((value) => {
|
|
2693
2719
|
try {
|
|
2694
2720
|
const valueToStore = value instanceof Function ? value(state) : value;
|
|
2695
2721
|
setState(valueToStore);
|
|
@@ -2703,13 +2729,13 @@ function useStorageState(pluginId, key, options = {}) {
|
|
|
2703
2729
|
}
|
|
2704
2730
|
|
|
2705
2731
|
// src/hooks/use-plugin-loader.ts
|
|
2706
|
-
var
|
|
2732
|
+
var import_react7 = require("react");
|
|
2707
2733
|
var logger10 = createLogger("PluginLoader");
|
|
2708
2734
|
var usePluginLoader = (options) => {
|
|
2709
|
-
const [pluginsLoaded, setPluginsLoaded] = (0,
|
|
2710
|
-
const [pluginVersion, setPluginVersion] = (0,
|
|
2711
|
-
const loadingRef = (0,
|
|
2712
|
-
(0,
|
|
2735
|
+
const [pluginsLoaded, setPluginsLoaded] = (0, import_react7.useState)(false);
|
|
2736
|
+
const [pluginVersion, setPluginVersion] = (0, import_react7.useState)(0);
|
|
2737
|
+
const loadingRef = (0, import_react7.useRef)(false);
|
|
2738
|
+
(0, import_react7.useEffect)(() => {
|
|
2713
2739
|
const unsubscribe = pluginManager.subscribe(() => {
|
|
2714
2740
|
logger10.debug("Plugin state changed, refreshing UI...");
|
|
2715
2741
|
setPluginVersion((v) => v + 1);
|
|
@@ -2782,6 +2808,7 @@ var usePluginLoader = (options) => {
|
|
|
2782
2808
|
ServiceRegistry,
|
|
2783
2809
|
SidebarIconSkeleton,
|
|
2784
2810
|
Slot,
|
|
2811
|
+
SlotSkeletons,
|
|
2785
2812
|
StatusBarItemSkeleton,
|
|
2786
2813
|
StorageManager,
|
|
2787
2814
|
apiEngine,
|
|
@@ -2803,3 +2830,4 @@ var usePluginLoader = (options) => {
|
|
|
2803
2830
|
useStorageState,
|
|
2804
2831
|
version
|
|
2805
2832
|
});
|
|
2833
|
+
//# sourceMappingURL=index.js.map
|