@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.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConfigManager,
|
|
3
3
|
configManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-QET56C3T.mjs";
|
|
5
5
|
|
|
6
6
|
// src/ports/plugin-port.ts
|
|
7
7
|
var PLUGIN_TYPES = ["business", "functional", "view", "theme", "renderer", "system"];
|
|
@@ -407,6 +407,9 @@ var useApi = () => {
|
|
|
407
407
|
// src/components/PluginErrorBoundary.tsx
|
|
408
408
|
import { Component } from "react";
|
|
409
409
|
|
|
410
|
+
// src/domain/plugin-manager.ts
|
|
411
|
+
import { startTransition } from "react";
|
|
412
|
+
|
|
410
413
|
// src/adapters/local-storage-adapter.ts
|
|
411
414
|
var LocalStorageAdapter = class {
|
|
412
415
|
/** 命名空间前缀,所有存入的键名都会自动添加此前缀 */
|
|
@@ -1309,18 +1312,20 @@ var PluginManager = class {
|
|
|
1309
1312
|
* @param affectedSlot - (可选) 受影响的插槽位置
|
|
1310
1313
|
*/
|
|
1311
1314
|
notify(affectedSlot) {
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1315
|
+
startTransition(() => {
|
|
1316
|
+
if (affectedSlot) {
|
|
1317
|
+
this.memoizedExtensions.delete(String(affectedSlot));
|
|
1318
|
+
} else {
|
|
1319
|
+
this.memoizedExtensions.clear();
|
|
1320
|
+
this.memoizedRoutes = null;
|
|
1321
|
+
}
|
|
1322
|
+
this.listeners.forEach((listener) => listener());
|
|
1323
|
+
if (affectedSlot) {
|
|
1324
|
+
this.slotListeners.get(String(affectedSlot))?.forEach((listener) => listener());
|
|
1325
|
+
} else {
|
|
1326
|
+
this.slotListeners.forEach((set) => set.forEach((listener) => listener()));
|
|
1327
|
+
}
|
|
1328
|
+
});
|
|
1324
1329
|
}
|
|
1325
1330
|
/**
|
|
1326
1331
|
* 获取所有已注册的插件列表
|
|
@@ -1885,7 +1890,10 @@ var PluginErrorBoundary = class extends Component {
|
|
|
1885
1890
|
* @param error - 捕获到的错误
|
|
1886
1891
|
*/
|
|
1887
1892
|
static getDerivedStateFromError(error) {
|
|
1888
|
-
|
|
1893
|
+
if (error && typeof error.then === "function") {
|
|
1894
|
+
return { hasError: false, error: null };
|
|
1895
|
+
}
|
|
1896
|
+
return { hasError: true, error: error instanceof Error ? error : new Error(String(error)) };
|
|
1889
1897
|
}
|
|
1890
1898
|
/**
|
|
1891
1899
|
* 捕获到错误后的回调
|
|
@@ -1893,6 +1901,9 @@ var PluginErrorBoundary = class extends Component {
|
|
|
1893
1901
|
* @param errorInfo - 错误堆栈信息
|
|
1894
1902
|
*/
|
|
1895
1903
|
componentDidCatch(error, errorInfo) {
|
|
1904
|
+
if (error && typeof error.then === "function") {
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1896
1907
|
logger7.error(`\u63D2\u4EF6 ${this.props.pluginId || "\u672A\u77E5"} \u6E32\u67D3\u53D1\u751F\u9519\u8BEF:`, error, errorInfo);
|
|
1897
1908
|
if (this.props.pluginId) {
|
|
1898
1909
|
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`);
|
|
@@ -1927,8 +1938,33 @@ var PluginErrorBoundary = class extends Component {
|
|
|
1927
1938
|
};
|
|
1928
1939
|
|
|
1929
1940
|
// src/components/PluginSlot.tsx
|
|
1930
|
-
import { useMemo, useState, useEffect } from "react";
|
|
1931
|
-
|
|
1941
|
+
import { useMemo, useState, useEffect, Suspense } from "react";
|
|
1942
|
+
|
|
1943
|
+
// src/components/SlotSkeletons.tsx
|
|
1944
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
1945
|
+
var SidebarIconSkeleton = ({ expanded = false }) => /* @__PURE__ */ jsxs("div", { className: `flex items-center transition-all duration-300 relative
|
|
1946
|
+
${expanded ? "w-full" : "w-12 justify-center"} px-3 h-11 rounded-xl`, children: [
|
|
1947
|
+
/* @__PURE__ */ jsx3("div", { className: "w-6 h-6 bg-slate-200 dark:bg-white/10 rounded-lg shrink-0 animate-pulse" }),
|
|
1948
|
+
expanded && /* @__PURE__ */ jsx3("div", { className: "ml-3 flex-1 h-4 bg-slate-200 dark:bg-white/10 rounded animate-pulse" })
|
|
1949
|
+
] });
|
|
1950
|
+
var StatusBarItemSkeleton = () => /* @__PURE__ */ jsx3("div", { className: "h-4 w-16 bg-slate-200 dark:bg-white/10 rounded animate-pulse" });
|
|
1951
|
+
var AvatarSkeleton = () => /* @__PURE__ */ jsx3("div", { className: "w-10 h-10 rounded-full bg-slate-200 dark:bg-white/10 animate-pulse" });
|
|
1952
|
+
var BlockSkeleton = ({ className }) => /* @__PURE__ */ jsx3("div", { className: `bg-slate-200 dark:bg-white/10 rounded animate-pulse ${className || "w-full h-full"}` });
|
|
1953
|
+
var SlotSkeletons = ({ slot, expanded }) => {
|
|
1954
|
+
if (slot.includes("sidebar")) {
|
|
1955
|
+
return /* @__PURE__ */ jsx3(SidebarIconSkeleton, { expanded });
|
|
1956
|
+
}
|
|
1957
|
+
if (slot.includes("status")) {
|
|
1958
|
+
return /* @__PURE__ */ jsx3(StatusBarItemSkeleton, {});
|
|
1959
|
+
}
|
|
1960
|
+
if (slot.includes("avatar")) {
|
|
1961
|
+
return /* @__PURE__ */ jsx3(AvatarSkeleton, {});
|
|
1962
|
+
}
|
|
1963
|
+
return /* @__PURE__ */ jsx3(BlockSkeleton, {});
|
|
1964
|
+
};
|
|
1965
|
+
|
|
1966
|
+
// src/components/PluginSlot.tsx
|
|
1967
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
1932
1968
|
var PluginSlot = ({
|
|
1933
1969
|
slot,
|
|
1934
1970
|
props = {},
|
|
@@ -1962,36 +1998,25 @@ var PluginSlot = ({
|
|
|
1962
1998
|
return {
|
|
1963
1999
|
key,
|
|
1964
2000
|
extension: ext,
|
|
1965
|
-
component: /* @__PURE__ */
|
|
2001
|
+
component: /* @__PURE__ */ jsx4(PluginErrorBoundary, { pluginId: ext._pluginId, children: /* @__PURE__ */ jsx4(Suspense, { fallback: skeleton || /* @__PURE__ */ jsx4(SlotSkeletons, { slot }), children: /* @__PURE__ */ jsx4(Component2, { ...mergedProps }) }) }, key)
|
|
1966
2002
|
};
|
|
1967
2003
|
});
|
|
1968
2004
|
}, [extensions, mergedProps]);
|
|
1969
2005
|
if (items.length === 0) {
|
|
1970
2006
|
if (fallback) {
|
|
1971
|
-
return /* @__PURE__ */
|
|
2007
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: fallback });
|
|
1972
2008
|
}
|
|
1973
2009
|
if (skeleton) {
|
|
1974
|
-
return /* @__PURE__ */
|
|
2010
|
+
return /* @__PURE__ */ jsx4("div", { className: `plugin-slot plugin-slot-${slot} plugin-slot-skeleton ${className || ""}`, style, children: skeleton });
|
|
1975
2011
|
}
|
|
1976
2012
|
return null;
|
|
1977
2013
|
}
|
|
1978
2014
|
if (items.length === 1 && slot === "root-layout" && !className && !style && !renderItem) {
|
|
1979
|
-
return /* @__PURE__ */
|
|
2015
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: items[0].component });
|
|
1980
2016
|
}
|
|
1981
|
-
return /* @__PURE__ */
|
|
2017
|
+
return /* @__PURE__ */ jsx4("div", { className: `plugin-slot plugin-slot-${slot} ${className || ""}`, style, children: renderItem ? items.map((item, index) => renderItem(item, index)) : items.map((item) => item.component) });
|
|
1982
2018
|
};
|
|
1983
2019
|
|
|
1984
|
-
// src/components/SlotSkeletons.tsx
|
|
1985
|
-
import { jsx as jsx4, jsxs } from "react/jsx-runtime";
|
|
1986
|
-
var SidebarIconSkeleton = ({ expanded = false }) => /* @__PURE__ */ jsxs("div", { className: `flex items-center transition-all duration-300 relative
|
|
1987
|
-
${expanded ? "w-full" : "w-12 justify-center"} px-3 h-11 rounded-xl`, children: [
|
|
1988
|
-
/* @__PURE__ */ jsx4("div", { className: "w-6 h-6 bg-slate-200 dark:bg-white/10 rounded-lg shrink-0 animate-pulse" }),
|
|
1989
|
-
expanded && /* @__PURE__ */ jsx4("div", { className: "ml-3 flex-1 h-4 bg-slate-200 dark:bg-white/10 rounded animate-pulse" })
|
|
1990
|
-
] });
|
|
1991
|
-
var StatusBarItemSkeleton = () => /* @__PURE__ */ jsx4("div", { className: "h-4 w-16 bg-slate-200 dark:bg-white/10 rounded animate-pulse" });
|
|
1992
|
-
var AvatarSkeleton = () => /* @__PURE__ */ jsx4("div", { className: "w-10 h-10 rounded-full bg-slate-200 dark:bg-white/10 animate-pulse" });
|
|
1993
|
-
var BlockSkeleton = ({ className }) => /* @__PURE__ */ jsx4("div", { className: `bg-slate-200 dark:bg-white/10 rounded animate-pulse ${className || "w-full h-full"}` });
|
|
1994
|
-
|
|
1995
2020
|
// src/domain/auto-loader.ts
|
|
1996
2021
|
var logger8 = createLogger("AutoLoader");
|
|
1997
2022
|
var DEFAULT_RULES = [
|
|
@@ -2592,7 +2617,7 @@ var usePluginLoader = (options) => {
|
|
|
2592
2617
|
}) : {};
|
|
2593
2618
|
const finalRegistry = { ...discoveredRegistry, ...manualRegistry };
|
|
2594
2619
|
if (options.systemConfig) {
|
|
2595
|
-
const { configManager: configManager2 } = await import("./config-manager-
|
|
2620
|
+
const { configManager: configManager2 } = await import("./config-manager-3TKURRUT.mjs");
|
|
2596
2621
|
configManager2.set("system", options.systemConfig);
|
|
2597
2622
|
}
|
|
2598
2623
|
await pluginManager.loadPlugins(pluginConfigs, finalRegistry);
|
|
@@ -2640,6 +2665,7 @@ export {
|
|
|
2640
2665
|
ServiceRegistry,
|
|
2641
2666
|
SidebarIconSkeleton,
|
|
2642
2667
|
Slot,
|
|
2668
|
+
SlotSkeletons,
|
|
2643
2669
|
StatusBarItemSkeleton,
|
|
2644
2670
|
StorageManager,
|
|
2645
2671
|
apiEngine,
|
|
@@ -2661,3 +2687,4 @@ export {
|
|
|
2661
2687
|
useStorageState,
|
|
2662
2688
|
version
|
|
2663
2689
|
};
|
|
2690
|
+
//# sourceMappingURL=index.mjs.map
|