@chatbi-v/core 2.1.0 → 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-QET56C3T.mjs +51 -0
- package/dist/chunk-QET56C3T.mjs.map +1 -0
- package/dist/config-manager-3TKURRUT.mjs +9 -0
- package/dist/config-manager-3TKURRUT.mjs.map +1 -0
- package/dist/index.d.mts +1748 -0
- package/dist/index.d.ts +1745 -27
- package/dist/index.js +2833 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2685 -7
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -3
- package/dist/adapters/local-storage-adapter.d.ts +0 -61
- package/dist/adapters/scoped-storage-adapter.d.ts +0 -61
- package/dist/api/adapters/axios-adapter.d.ts +0 -10
- package/dist/api/engine.d.ts +0 -87
- package/dist/api/index.d.ts +0 -6
- package/dist/api/utils.d.ts +0 -14
- package/dist/api-context.d.ts +0 -8
- package/dist/application/service-registry.d.ts +0 -57
- package/dist/chunk-O74KYN5N.mjs +0 -1
- package/dist/components/PluginErrorBoundary.d.ts +0 -44
- package/dist/components/PluginSlot.d.ts +0 -35
- package/dist/components/SlotSkeletons.d.ts +0 -27
- package/dist/config-manager-LQITPSUA.mjs +0 -1
- package/dist/config-manager.d.ts +0 -34
- package/dist/domain/auto-loader.d.ts +0 -36
- package/dist/domain/models.d.ts +0 -42
- package/dist/domain/plugin-manager.d.ts +0 -215
- package/dist/domain/plugin-runtime.d.ts +0 -70
- package/dist/domain/plugin-sandbox.d.ts +0 -40
- package/dist/domain/storage-manager.d.ts +0 -74
- package/dist/event-bus.d.ts +0 -38
- package/dist/hooks/use-plugin-loader.d.ts +0 -35
- package/dist/hooks/use-storage-state.d.ts +0 -15
- package/dist/index.cjs +0 -12
- package/dist/plugin-context.d.ts +0 -8
- package/dist/ports/api-port.d.ts +0 -132
- package/dist/ports/event-bus-port.d.ts +0 -32
- package/dist/ports/plugin-port.d.ts +0 -308
- package/dist/ports/storage-port.d.ts +0 -49
- package/dist/sandbox/proxy-sandbox.d.ts +0 -45
- package/dist/sandbox/style-isolation.d.ts +0 -13
- package/dist/utils/date.d.ts +0 -32
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/logger.d.ts +0 -79
- package/dist/utils/url.d.ts +0 -16
package/dist/api/engine.d.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { ApiAdapter, ApiConfig, ApiEndpointConfig, ApiInterceptor, RequestOptions } from '../ports/api-port';
|
|
2
|
-
/**
|
|
3
|
-
* API 引擎核心类
|
|
4
|
-
* @description 负责加载配置并执行请求,支持策略模式切换底层请求实现
|
|
5
|
-
*/
|
|
6
|
-
export declare class ApiEngine {
|
|
7
|
-
private adapter;
|
|
8
|
-
private config;
|
|
9
|
-
private interceptors;
|
|
10
|
-
constructor(adapter?: ApiAdapter);
|
|
11
|
-
/**
|
|
12
|
-
* 注册拦截器
|
|
13
|
-
*/
|
|
14
|
-
registerInterceptor(interceptor: ApiInterceptor): void;
|
|
15
|
-
/**
|
|
16
|
-
* 移除拦截器
|
|
17
|
-
*/
|
|
18
|
-
unregisterInterceptor(interceptor: ApiInterceptor): void;
|
|
19
|
-
/**
|
|
20
|
-
* 切换请求适配器
|
|
21
|
-
* @param adapter 新的适配器实例
|
|
22
|
-
*/
|
|
23
|
-
useAdapter(adapter: ApiAdapter): void;
|
|
24
|
-
/**
|
|
25
|
-
* 注册 API 配置
|
|
26
|
-
* @param config 配置对象
|
|
27
|
-
*/
|
|
28
|
-
register(config: ApiConfig): void;
|
|
29
|
-
/**
|
|
30
|
-
* 获取接口配置
|
|
31
|
-
*/
|
|
32
|
-
getEndpoint(module: string, action: string): ApiEndpointConfig | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* 发起 API 请求
|
|
35
|
-
* @param module 模块名
|
|
36
|
-
* @param action 动作名
|
|
37
|
-
* @param data 请求数据 (Body 或 Query)
|
|
38
|
-
* @param options 请求选项
|
|
39
|
-
*/
|
|
40
|
-
call<T = any>(module: string, action: string, data?: any, options?: RequestOptions): Promise<T>;
|
|
41
|
-
/**
|
|
42
|
-
* 发起流式请求
|
|
43
|
-
* @param module 模块名
|
|
44
|
-
* @param action 动作名
|
|
45
|
-
* @param data 请求数据
|
|
46
|
-
* @param options 请求选项
|
|
47
|
-
*/
|
|
48
|
-
stream(module: string, action: string, data?: any, options?: RequestOptions): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* 准备请求配置,应用 URL 参数替换和请求拦截器
|
|
51
|
-
*/
|
|
52
|
-
private prepareRequestConfig;
|
|
53
|
-
/**
|
|
54
|
-
* 应用所有请求拦截器
|
|
55
|
-
*/
|
|
56
|
-
private applyRequestInterceptors;
|
|
57
|
-
/**
|
|
58
|
-
* 应用所有响应拦截器
|
|
59
|
-
* @returns 是否被劫持
|
|
60
|
-
*/
|
|
61
|
-
private applyResponseInterceptors;
|
|
62
|
-
/**
|
|
63
|
-
* 检查 HTTP 状态码
|
|
64
|
-
*/
|
|
65
|
-
private checkHttpStatus;
|
|
66
|
-
/**
|
|
67
|
-
* 提取响应数据
|
|
68
|
-
*/
|
|
69
|
-
private extractResponseData;
|
|
70
|
-
/**
|
|
71
|
-
* 处理业务错误
|
|
72
|
-
*/
|
|
73
|
-
private handleBusinessError;
|
|
74
|
-
/**
|
|
75
|
-
* 判断是否为 BaseResponse
|
|
76
|
-
*/
|
|
77
|
-
private isBaseResponse;
|
|
78
|
-
/**
|
|
79
|
-
* 严格判断是否为 AxiosResponse
|
|
80
|
-
*/
|
|
81
|
-
private isAxiosResponse;
|
|
82
|
-
/**
|
|
83
|
-
* 创建拦截上下文
|
|
84
|
-
*/
|
|
85
|
-
private createInterceptorContext;
|
|
86
|
-
}
|
|
87
|
-
export declare const apiEngine: ApiEngine;
|
package/dist/api/index.d.ts
DELETED
package/dist/api/utils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ApiConfig } from '../ports/api-port';
|
|
2
|
-
/**
|
|
3
|
-
* 自动检测是否处于 Mock 模式
|
|
4
|
-
*/
|
|
5
|
-
export declare function isMockMode(): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* 从文件模块映射中解析 API 配置
|
|
8
|
-
* @description 配合 Vite 的 import.meta.glob 使用,自动匹配定义文件和 Mock 文件
|
|
9
|
-
* @param definitionsMap API 定义文件映射 (import.meta.glob('./modules/*.ts', { eager: true }))
|
|
10
|
-
* @param mocksMap Mock 文件映射 (import.meta.glob('./modules/*.mock.ts', { eager: true }))
|
|
11
|
-
* @param useMock 是否启用 Mock (如果不传,将自动调用 isMockMode())
|
|
12
|
-
* @returns 合并后的 ApiConfig
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveApiModules(definitionsMap: Record<string, any>, mocksMap?: Record<string, any>): ApiConfig;
|
package/dist/api-context.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { ApiEngine } from './api';
|
|
3
|
-
export interface ApiProviderProps {
|
|
4
|
-
api: ApiEngine;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const ApiProvider: React.FC<ApiProviderProps>;
|
|
8
|
-
export declare const useApi: () => ApiEngine;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 服务注册中心 (Service Registry)
|
|
3
|
-
* @description 核心应用层服务,作为微内核架构中的“中枢调度员”。
|
|
4
|
-
* 主要职责:
|
|
5
|
-
* 1. 服务解耦:允许插件将其内部功能暴露为“服务”,而无需与其他插件产生物理依赖。
|
|
6
|
-
* 2. 动态发现:提供按名称查找服务的能力,支持服务热插拔。
|
|
7
|
-
* 3. 依赖协调:通过 `waitFor` 机制解决插件间由于加载顺序导致的初始化依赖问题。
|
|
8
|
-
*
|
|
9
|
-
* 建议的服务命名规范: `pluginId.serviceName` (例如: `auth.sessionService`)
|
|
10
|
-
*/
|
|
11
|
-
export declare class ServiceRegistry {
|
|
12
|
-
/** 存储已注册服务的 Map 对象 */
|
|
13
|
-
private services;
|
|
14
|
-
/** 存储正在等待特定服务的监听器集合 */
|
|
15
|
-
private listeners;
|
|
16
|
-
/**
|
|
17
|
-
* 注册一个服务实现
|
|
18
|
-
* @param name - 唯一的服务名称
|
|
19
|
-
* @param service - 服务实例或对象
|
|
20
|
-
*/
|
|
21
|
-
register(name: string, service: any): void;
|
|
22
|
-
/**
|
|
23
|
-
* 同步获取服务实例
|
|
24
|
-
* @template T - 服务类型的泛型
|
|
25
|
-
* @param name - 服务名称
|
|
26
|
-
* @returns 服务实例,若不存在则返回 undefined
|
|
27
|
-
*/
|
|
28
|
-
get<T = any>(name: string): T | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* 异步等待并获取服务
|
|
31
|
-
* @description 如果服务尚未注册,将返回一个 Promise,直到该服务被注册时 resolve。
|
|
32
|
-
* 支持设置超时时间,防止因插件加载失败导致的永久挂起。
|
|
33
|
-
*
|
|
34
|
-
* @template T - 服务类型的泛型
|
|
35
|
-
* @param name - 待等待的服务名称
|
|
36
|
-
* @param timeout - 超时时间 (毫秒),默认 10000ms (10秒)。若为 0 则永不超时。
|
|
37
|
-
* @returns 包含服务实例的 Promise
|
|
38
|
-
* @throws {Error} 若在规定时间内服务未注册,则抛出超时异常。
|
|
39
|
-
*/
|
|
40
|
-
waitFor<T = any>(name: string, timeout?: number): Promise<T>;
|
|
41
|
-
/**
|
|
42
|
-
* 检查服务是否已注册
|
|
43
|
-
* @param name - 服务名称
|
|
44
|
-
*/
|
|
45
|
-
has(name: string): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* 注销特定的服务
|
|
48
|
-
* @param name - 服务名称
|
|
49
|
-
*/
|
|
50
|
-
unregister(name: string): void;
|
|
51
|
-
/**
|
|
52
|
-
* 清除所有已注册的服务和监听器
|
|
53
|
-
* @description 通常仅在系统重置或大型热更新时使用。
|
|
54
|
-
*/
|
|
55
|
-
clear(): void;
|
|
56
|
-
}
|
|
57
|
-
export declare const serviceRegistry: ServiceRegistry;
|
package/dist/chunk-O74KYN5N.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s=class{config=new Map;set(t,e){this.config.set(t,e)}get(t){return this.config.get(t)}merge(t){Object.keys(t).forEach(e=>{let i=this.config.get(e),n=t[e];i&&typeof i=="object"&&n&&typeof n=="object"?this.config.set(e,{...i,...n}):this.config.set(e,n)})}getAll(){return Object.fromEntries(this.config)}},c=new s;export{s as a,c as b};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import React, { Component, ErrorInfo, ReactNode } from 'react';
|
|
2
|
-
/** 插件错误边界组件属性 */
|
|
3
|
-
interface Props {
|
|
4
|
-
/** 发生错误的插件 ID */
|
|
5
|
-
pluginId?: string;
|
|
6
|
-
/** 错误发生时的降级 UI */
|
|
7
|
-
fallback?: ReactNode;
|
|
8
|
-
/** 子组件内容 */
|
|
9
|
-
children: ReactNode;
|
|
10
|
-
/** 是否静默模式,开启后不显示任何错误 UI,仅记录日志 */
|
|
11
|
-
silent?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/** 插件错误边界组件状态 */
|
|
14
|
-
interface State {
|
|
15
|
-
/** 是否捕获到错误 */
|
|
16
|
-
hasError: boolean;
|
|
17
|
-
/** 捕获到的错误对象 */
|
|
18
|
-
error: Error | null;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 插件错误边界组件
|
|
22
|
-
* @description 核心组件,用于捕获子组件渲染过程中的 JavaScript 错误,记录日志并显示降级 UI。
|
|
23
|
-
* 确保单个插件的运行异常不会导致整个主应用或其他插件崩溃。
|
|
24
|
-
*/
|
|
25
|
-
export declare class PluginErrorBoundary extends Component<Props, State> {
|
|
26
|
-
constructor(props: Props);
|
|
27
|
-
/**
|
|
28
|
-
* 从错误中派生状态
|
|
29
|
-
* @param error - 捕获到的错误
|
|
30
|
-
*/
|
|
31
|
-
static getDerivedStateFromError(error: Error): State;
|
|
32
|
-
/**
|
|
33
|
-
* 捕获到错误后的回调
|
|
34
|
-
* @param error - 错误对象
|
|
35
|
-
* @param errorInfo - 错误堆栈信息
|
|
36
|
-
*/
|
|
37
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
38
|
-
/**
|
|
39
|
-
* 重置错误状态,尝试重新渲染
|
|
40
|
-
*/
|
|
41
|
-
handleRetry: () => void;
|
|
42
|
-
render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
43
|
-
}
|
|
44
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { PluginExtension, SlotPosition } from '../api';
|
|
3
|
-
/** 插件插槽组件属性 */
|
|
4
|
-
interface PluginSlotProps {
|
|
5
|
-
/** 插槽位置标识,决定渲染哪些插件扩展 */
|
|
6
|
-
slot: SlotPosition;
|
|
7
|
-
/** 传递给扩展组件的 Props 对象 */
|
|
8
|
-
props?: Record<string, any>;
|
|
9
|
-
/** 自定义容器类名 (Tailwind CSS) */
|
|
10
|
-
className?: string;
|
|
11
|
-
/** 自定义容器内联样式 */
|
|
12
|
-
style?: React.CSSProperties;
|
|
13
|
-
/**
|
|
14
|
-
* 自定义渲染函数
|
|
15
|
-
* @param item - 包含 key、组件和扩展元信息的对象
|
|
16
|
-
* @param index - 索引位置
|
|
17
|
-
*/
|
|
18
|
-
renderItem?: (item: {
|
|
19
|
-
key: string;
|
|
20
|
-
component: React.ReactNode;
|
|
21
|
-
extension: PluginExtension;
|
|
22
|
-
}, index: number) => React.ReactNode;
|
|
23
|
-
/** 骨架屏组件,当插槽内无插件扩展时显示的占位 UI */
|
|
24
|
-
skeleton?: React.ReactNode;
|
|
25
|
-
/** 回退组件,当插槽内无插件扩展时显示的 UI,优先级高于 skeleton */
|
|
26
|
-
fallback?: React.ReactNode;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 插件插槽组件
|
|
30
|
-
* @description UI 层的核心组件,用于在应用中声明一个“插槽”。
|
|
31
|
-
* 它会自动根据 slot 标识从 PluginManager 中获取所有注册的插件扩展组件并按顺序渲染。
|
|
32
|
-
* 支持订阅插件变更,实现动态热插拔。
|
|
33
|
-
*/
|
|
34
|
-
export declare const PluginSlot: React.FC<PluginSlotProps>;
|
|
35
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* 通用插槽骨架屏组件集合
|
|
4
|
-
* @description 提供一组预定义的骨架屏 UI,用于在插件加载或插槽内容未准备好时提供更好的用户体验。
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* 侧边栏图标骨架屏
|
|
8
|
-
* @param expanded - 是否处于展开状态
|
|
9
|
-
*/
|
|
10
|
-
export declare const SidebarIconSkeleton: React.FC<{
|
|
11
|
-
expanded?: boolean;
|
|
12
|
-
}>;
|
|
13
|
-
/**
|
|
14
|
-
* 状态栏项骨架屏
|
|
15
|
-
*/
|
|
16
|
-
export declare const StatusBarItemSkeleton: React.FC;
|
|
17
|
-
/**
|
|
18
|
-
* 头像骨架屏
|
|
19
|
-
*/
|
|
20
|
-
export declare const AvatarSkeleton: React.FC;
|
|
21
|
-
/**
|
|
22
|
-
* 通用块级骨架屏
|
|
23
|
-
* @param className - 自定义类名
|
|
24
|
-
*/
|
|
25
|
-
export declare const BlockSkeleton: React.FC<{
|
|
26
|
-
className?: string;
|
|
27
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-O74KYN5N.mjs";export{a as ConfigManager,b as configManager};
|
package/dist/config-manager.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 配置管理器
|
|
3
|
-
* @description 核心工具类,负责管理应用的全局系统配置以及各插件的初始化业务配置。
|
|
4
|
-
* 配置数据通常在应用启动时通过 `usePluginLoader` 注入,并作为插件运行时的取值回退来源。
|
|
5
|
-
*/
|
|
6
|
-
export declare class ConfigManager {
|
|
7
|
-
/** 内部存储配置的 Map 对象 */
|
|
8
|
-
private config;
|
|
9
|
-
/**
|
|
10
|
-
* 设置特定的配置项
|
|
11
|
-
* @param key - 配置键名(如 'system' 或插件 ID)
|
|
12
|
-
* @param value - 配置内容对象
|
|
13
|
-
*/
|
|
14
|
-
set(key: string, value: any): void;
|
|
15
|
-
/**
|
|
16
|
-
* 获取指定的配置项
|
|
17
|
-
* @param key - 配置键名
|
|
18
|
-
* @returns 配置内容,若不存在则返回 undefined
|
|
19
|
-
*/
|
|
20
|
-
get(key: string): any;
|
|
21
|
-
/**
|
|
22
|
-
* 批量合并配置对象
|
|
23
|
-
* @description 对顶层属性进行浅合并,若属性值为对象则进行一层深度的合并。
|
|
24
|
-
* @param config - 待合并的配置对象映射
|
|
25
|
-
*/
|
|
26
|
-
merge(config: Record<string, any>): void;
|
|
27
|
-
/**
|
|
28
|
-
* 获取当前存储的所有配置快照
|
|
29
|
-
* @returns 包含所有配置的普通对象
|
|
30
|
-
*/
|
|
31
|
-
getAll(): Record<string, any>;
|
|
32
|
-
}
|
|
33
|
-
/** 全局配置管理器单例 */
|
|
34
|
-
export declare const configManager: ConfigManager;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 插件注册表接口
|
|
3
|
-
* @description 键为插件 ID,值为一个返回插件定义的异步加载函数。
|
|
4
|
-
*/
|
|
5
|
-
export interface PluginRegistry {
|
|
6
|
-
[pluginId: string]: () => Promise<any>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 插件自动发现规则
|
|
10
|
-
*/
|
|
11
|
-
export interface DiscoveryRule {
|
|
12
|
-
/**
|
|
13
|
-
* 路径匹配标识。
|
|
14
|
-
* @example 'plugins' 或 '@chatbi-plugins'
|
|
15
|
-
*/
|
|
16
|
-
pathSegment: string;
|
|
17
|
-
/**
|
|
18
|
-
* 生成插件 ID 时的前缀。
|
|
19
|
-
* @example '@chatbi-v/plugin',最终生成如 '@chatbi-v/plugin-demo'
|
|
20
|
-
*/
|
|
21
|
-
idPrefix: string;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 解析插件注册表
|
|
25
|
-
* @description 核心逻辑:将 Vite 的 `import.meta.glob` 结果映射为标准的插件注册表。
|
|
26
|
-
* 它会根据预定义的路径匹配规则,从文件路径中提取插件目录名,并拼接前缀生成唯一的插件 ID。
|
|
27
|
-
*
|
|
28
|
-
* @param options - 包含待处理模块和匹配规则的选项对象
|
|
29
|
-
* @returns 解析后的 PluginRegistry 对象
|
|
30
|
-
*/
|
|
31
|
-
export declare const resolvePluginRegistry: (options: {
|
|
32
|
-
/** 原始模块映射 (来自 Vite glob) */
|
|
33
|
-
modules: Record<string, () => Promise<any>>;
|
|
34
|
-
/** 自定义发现规则 (可选) */
|
|
35
|
-
rules?: DiscoveryRule[];
|
|
36
|
-
}) => PluginRegistry;
|
package/dist/domain/models.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 成功状态码
|
|
3
|
-
*/
|
|
4
|
-
export declare const SUCCESS_CODE = "000000";
|
|
5
|
-
/**
|
|
6
|
-
* 基础 API 响应接口
|
|
7
|
-
* @template T 响应数据的类型
|
|
8
|
-
*/
|
|
9
|
-
export interface BaseResponse<T = any> {
|
|
10
|
-
/** 业务状态码 */
|
|
11
|
-
code: string | number;
|
|
12
|
-
/** 响应消息提示 */
|
|
13
|
-
message: string;
|
|
14
|
-
/** 业务响应数据主体 */
|
|
15
|
-
data: T;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 业务场景实体接口
|
|
19
|
-
* @description 描述系统中的业务分析场景
|
|
20
|
-
*/
|
|
21
|
-
export interface Scene {
|
|
22
|
-
/** 场景唯一标识符 */
|
|
23
|
-
id: string;
|
|
24
|
-
/** 场景名称 */
|
|
25
|
-
name: string;
|
|
26
|
-
/** 场景详细描述 */
|
|
27
|
-
description: string;
|
|
28
|
-
/** 场景内部代码/标识 */
|
|
29
|
-
code: string;
|
|
30
|
-
/** 场景创建者 ID 或名称 */
|
|
31
|
-
creator: string;
|
|
32
|
-
/** 创建时间字符串 (ISO 格式) */
|
|
33
|
-
createTime: string;
|
|
34
|
-
/** 该场景关联的物理数据表数量 */
|
|
35
|
-
tableCount: number;
|
|
36
|
-
/** 该场景关联的知识库数量 */
|
|
37
|
-
kbCount: number;
|
|
38
|
-
/** 该场景关联的预设问答对数量 */
|
|
39
|
-
qaCount: number;
|
|
40
|
-
/** 场景封面图 URL (可选) */
|
|
41
|
-
cover?: string;
|
|
42
|
-
}
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file plugin-manager.ts
|
|
3
|
-
* @description 插件管理器,负责插件的注册、生命周期管理、状态持久化及扩展点收集
|
|
4
|
-
* @author ChatBI Team
|
|
5
|
-
*/
|
|
6
|
-
import { DefaultEventBus } from '../event-bus';
|
|
7
|
-
import { Plugin, PluginExtension, RouteConfig, SlotPosition } from '../ports/plugin-port';
|
|
8
|
-
import { StoragePort } from '../ports/storage-port';
|
|
9
|
-
import { StorageManager } from './storage-manager';
|
|
10
|
-
/**
|
|
11
|
-
* 插件管理器
|
|
12
|
-
* @description 核心领域服务,负责插件的完整生命周期管理,包括扫描、注册、配置合并、状态切换及依赖解析。
|
|
13
|
-
*/
|
|
14
|
-
export declare class PluginManager {
|
|
15
|
-
/** 全局事件总线,用于插件间及插件与内核间的异步通信 */
|
|
16
|
-
readonly eventBus: DefaultEventBus;
|
|
17
|
-
/** 存储管理服务,负责插件私有存储和系统级状态的持久化 */
|
|
18
|
-
private storageManager;
|
|
19
|
-
/** 插件 ID 到运行时实例的映射表 */
|
|
20
|
-
private runtimes;
|
|
21
|
-
/** 插件 ID 到原始插件定义对象的映射表 */
|
|
22
|
-
private plugins;
|
|
23
|
-
/** 收集到的所有插件路由配置 */
|
|
24
|
-
private routes;
|
|
25
|
-
/** 收集到的所有插件扩展点配置,按插槽位置分组 */
|
|
26
|
-
private extensions;
|
|
27
|
-
/** 插件的启用状态和排序信息的内存缓存 */
|
|
28
|
-
private pluginStates;
|
|
29
|
-
/** 状态变更监听器集合,支持按插槽过滤 */
|
|
30
|
-
private listeners;
|
|
31
|
-
/** 按插槽位置存储的监听器,用于精确通知 */
|
|
32
|
-
private slotListeners;
|
|
33
|
-
/** 扩展点缓存,避免重复计算 */
|
|
34
|
-
private memoizedExtensions;
|
|
35
|
-
/** 路由缓存 */
|
|
36
|
-
private memoizedRoutes;
|
|
37
|
-
/** 传递给插件的共享上下文缓存 */
|
|
38
|
-
private sharedContext;
|
|
39
|
-
/** 收集到的插件工具函数集合 */
|
|
40
|
-
private utils;
|
|
41
|
-
/**
|
|
42
|
-
* 构造函数
|
|
43
|
-
* @param storage - 底层存储适配器
|
|
44
|
-
*/
|
|
45
|
-
constructor(storage: StoragePort);
|
|
46
|
-
/**
|
|
47
|
-
* 从持久化存储中恢复插件状态 (启用/禁用、排序等)
|
|
48
|
-
*/
|
|
49
|
-
private loadStates;
|
|
50
|
-
/**
|
|
51
|
-
* 将当前的插件状态持久化到存储中
|
|
52
|
-
*/
|
|
53
|
-
private saveStates;
|
|
54
|
-
/**
|
|
55
|
-
* 订阅插件状态的变更通知
|
|
56
|
-
* @param listener - 变更时的回调函数
|
|
57
|
-
* @param slot - (可选) 指定监听的插槽位置,若提供则仅在该插槽受影响时通知
|
|
58
|
-
* @returns 取消订阅的函数
|
|
59
|
-
*/
|
|
60
|
-
subscribe(listener: () => void, slot?: SlotPosition | string): () => void;
|
|
61
|
-
/**
|
|
62
|
-
* 获取存储管理器实例
|
|
63
|
-
* @returns StorageManager 实例
|
|
64
|
-
*/
|
|
65
|
-
getStorageManager(): StorageManager;
|
|
66
|
-
/**
|
|
67
|
-
* 触发状态变更通知
|
|
68
|
-
* @param affectedSlot - (可选) 受影响的插槽位置
|
|
69
|
-
*/
|
|
70
|
-
private notify;
|
|
71
|
-
/**
|
|
72
|
-
* 获取所有已注册的插件列表
|
|
73
|
-
* @description 结果会根据插件类型优先级和用户自定义排序进行排序
|
|
74
|
-
* @returns 排序后的插件数组
|
|
75
|
-
*/
|
|
76
|
-
getPlugins(): Plugin[];
|
|
77
|
-
/**
|
|
78
|
-
* 获取指定插件的状态信息
|
|
79
|
-
* @param pluginId - 插件 ID
|
|
80
|
-
* @returns 包含启用状态和排序值的对象
|
|
81
|
-
*/
|
|
82
|
-
getPluginState(pluginId: string): {
|
|
83
|
-
enabled: boolean;
|
|
84
|
-
order: number;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* 检查指定插件是否处于启用状态
|
|
88
|
-
* @param pluginId - 插件 ID
|
|
89
|
-
* @returns 是否启用
|
|
90
|
-
*/
|
|
91
|
-
isPluginEnabled(pluginId: string): boolean;
|
|
92
|
-
/**
|
|
93
|
-
* 切换插件的启用/禁用状态
|
|
94
|
-
* @description 禁用插件会立即触发其卸载生命周期并销毁运行时。
|
|
95
|
-
* @param pluginId - 插件 ID
|
|
96
|
-
* @param enabled - 目标状态
|
|
97
|
-
*/
|
|
98
|
-
togglePlugin(pluginId: string, enabled: boolean): void;
|
|
99
|
-
/**
|
|
100
|
-
* 设置插件的显示排序权重
|
|
101
|
-
* @param pluginId - 插件 ID
|
|
102
|
-
* @param order - 排序权重值
|
|
103
|
-
*/
|
|
104
|
-
setPluginOrder(pluginId: string, order: number): void;
|
|
105
|
-
/**
|
|
106
|
-
* 获取指定插件的运行时状态
|
|
107
|
-
* @param pluginId - 插件 ID
|
|
108
|
-
* @returns 'error' | 'mounted' | 'loaded' | 'initial'
|
|
109
|
-
*/
|
|
110
|
-
getPluginRuntimeStatus(pluginId: string): "error" | "mounted" | "loaded" | "initial";
|
|
111
|
-
/**
|
|
112
|
-
* 获取指定插件的运行时错误
|
|
113
|
-
* @param pluginId - 插件 ID
|
|
114
|
-
* @returns Error 对象或 null
|
|
115
|
-
*/
|
|
116
|
-
getPluginError(pluginId: string): Error | null;
|
|
117
|
-
/**
|
|
118
|
-
* 报告插件运行时错误 (通常由 ErrorBoundary 调用)
|
|
119
|
-
* @param pluginId - 插件 ID
|
|
120
|
-
* @param error - 错误对象
|
|
121
|
-
*/
|
|
122
|
-
reportPluginError(pluginId: string, error: Error): void;
|
|
123
|
-
/**
|
|
124
|
-
* 获取插件的完整能力声明
|
|
125
|
-
* @param pluginId - 插件 ID
|
|
126
|
-
* @returns 能力对象
|
|
127
|
-
*/
|
|
128
|
-
getUnifiedCapabilities(pluginId: string): import("..").PluginCapabilities;
|
|
129
|
-
/**
|
|
130
|
-
* 更新指定插件的某项配置
|
|
131
|
-
* @description 该操作会同步更新内存中的配置、持久化到存储并触发全局事件通知。
|
|
132
|
-
* @param pluginId - 插件 ID
|
|
133
|
-
* @param key - 配置键名
|
|
134
|
-
* @param value - 新的配置值
|
|
135
|
-
*/
|
|
136
|
-
updatePluginConfig(pluginId: string, key: string, value: any): void;
|
|
137
|
-
/**
|
|
138
|
-
* 获取指定插件的某项配置值
|
|
139
|
-
* @param pluginId - 插件 ID
|
|
140
|
-
* @param key - 配置键名
|
|
141
|
-
* @returns 配置值
|
|
142
|
-
*/
|
|
143
|
-
getPluginConfig(pluginId: string, key: string): any;
|
|
144
|
-
/**
|
|
145
|
-
* 获取系统全局配置 (非插件特定)
|
|
146
|
-
* @param key - 系统配置键名
|
|
147
|
-
* @returns 配置值
|
|
148
|
-
*/
|
|
149
|
-
getSystemConfig(key: string): any;
|
|
150
|
-
/**
|
|
151
|
-
* 获取由插件注册的服务实例
|
|
152
|
-
* @template T 服务接口类型
|
|
153
|
-
* @param name - 服务注册名称
|
|
154
|
-
* @returns 服务实例或 undefined
|
|
155
|
-
*/
|
|
156
|
-
getService<T = any>(name: string): T | undefined;
|
|
157
|
-
/**
|
|
158
|
-
* 获取指定插槽位置的所有已启用插件的扩展
|
|
159
|
-
* @param slot - 插槽位置标识
|
|
160
|
-
* @returns 排序后的扩展配置数组
|
|
161
|
-
*/
|
|
162
|
-
getExtensions(slot: SlotPosition | string): PluginExtension[];
|
|
163
|
-
/**
|
|
164
|
-
* 获取所有已启用插件注册的路由配置
|
|
165
|
-
* @returns 增强后的路由配置数组
|
|
166
|
-
*/
|
|
167
|
-
getRoutes(): RouteConfig[];
|
|
168
|
-
/**
|
|
169
|
-
* 注册一个新插件到管理器中
|
|
170
|
-
* @description 此阶段会执行元数据校验、存储 Schema 注册、配置合并及扩展点收集。
|
|
171
|
-
* @param plugin - 插件对象
|
|
172
|
-
* @param notify - 是否在注册完成后触发状态变更通知
|
|
173
|
-
*/
|
|
174
|
-
register(plugin: Plugin, notify?: boolean): void;
|
|
175
|
-
/**
|
|
176
|
-
* 初始化所有插件
|
|
177
|
-
* @param sharedContext 共享上下文
|
|
178
|
-
*/
|
|
179
|
-
initPlugins(sharedContext?: Record<string, any>): Promise<void>;
|
|
180
|
-
/**
|
|
181
|
-
* 获取排序后的插件 ID 列表 (处理依赖)
|
|
182
|
-
*/
|
|
183
|
-
private getSortedPluginIds;
|
|
184
|
-
/**
|
|
185
|
-
* 加载插件列表
|
|
186
|
-
* @param configs 插件配置
|
|
187
|
-
* @param registry 插件注册表 (动态导入函数)
|
|
188
|
-
*/
|
|
189
|
-
loadPlugins(configs: Record<string, any>, registry: Record<string, () => Promise<any>>): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* 加载远程插件
|
|
192
|
-
* @param pluginId 插件 ID
|
|
193
|
-
* @param url 远程 URL
|
|
194
|
-
* @param config 插件配置
|
|
195
|
-
*/
|
|
196
|
-
loadRemotePlugin(pluginId: string, url: string, config: any): Promise<Plugin | null>;
|
|
197
|
-
/**
|
|
198
|
-
* IIFE 模式加载插件
|
|
199
|
-
*/
|
|
200
|
-
private loadIIFEPlugin;
|
|
201
|
-
/**
|
|
202
|
-
* 实例化插件
|
|
203
|
-
*/
|
|
204
|
-
private instantiatePlugin;
|
|
205
|
-
private validatePlugin;
|
|
206
|
-
private handleBusinessPlugin;
|
|
207
|
-
private handleFunctionalPlugin;
|
|
208
|
-
private handleViewPlugin;
|
|
209
|
-
private handleThemePlugin;
|
|
210
|
-
private handleSystemPlugin;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* 全局插件管理器实例
|
|
214
|
-
*/
|
|
215
|
-
export declare const pluginManager: PluginManager;
|