@chatbi-v/core 2.0.0 → 2.0.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/README.md +45 -20
- package/dist/domain/auto-loader.d.ts +3 -19
- package/dist/domain/plugin-manager.d.ts +9 -3
- package/dist/domain/plugin-runtime.d.ts +5 -0
- package/dist/hooks/use-plugin-loader.d.ts +2 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +145 -78
- package/dist/index.plugin.js +5106 -0
- package/dist/ports/plugin-port.d.ts +26 -2
- package/package.json +4 -4
- package/dist/index.cjs +0 -2118
|
@@ -157,9 +157,9 @@ export interface PluginContext {
|
|
|
157
157
|
export interface Plugin extends PluginLifecycle {
|
|
158
158
|
/**
|
|
159
159
|
* 插件 ID
|
|
160
|
-
* @description 必须与 metadata.id
|
|
160
|
+
* @description 必须与 metadata.id 一致,且定义为只读(通常通过 getter 实现)
|
|
161
161
|
*/
|
|
162
|
-
id: string;
|
|
162
|
+
readonly id: string;
|
|
163
163
|
metadata: PluginMetadata;
|
|
164
164
|
/** 插件提供的组件(可选) */
|
|
165
165
|
components?: Record<string, React.ComponentType<any>>;
|
|
@@ -168,6 +168,30 @@ export interface Plugin extends PluginLifecycle {
|
|
|
168
168
|
/** 默认配置(可选) */
|
|
169
169
|
defaultConfig?: Record<string, any>;
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* 插件基础类
|
|
173
|
+
* @deprecated 建议统一使用工厂模式 definePlugin() 定义插件,以消除类与对象定义的歧义。
|
|
174
|
+
* @description 解决插件定义时 id 与 metadata.id 重复定义的问题,并提供基础生命周期管理
|
|
175
|
+
*/
|
|
176
|
+
export declare abstract class BasePlugin implements Plugin {
|
|
177
|
+
abstract metadata: PluginMetadata;
|
|
178
|
+
/**
|
|
179
|
+
* 插件 ID
|
|
180
|
+
* @description 自动从 metadata.id 获取
|
|
181
|
+
*/
|
|
182
|
+
get id(): string;
|
|
183
|
+
onLoad?(context: PluginContext): void | Promise<void>;
|
|
184
|
+
onMount?(context: PluginContext): void;
|
|
185
|
+
onUnmount?(context: PluginContext): void;
|
|
186
|
+
onConfigChange?(newConfig: any, oldConfig: any): void;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* 辅助函数:定义插件并自动从 metadata.id 注入顶级 id
|
|
190
|
+
* @description 解决插件定义时 id 与 metadata.id 重复定义的问题,提高代码优雅度
|
|
191
|
+
* @param plugin 插件定义(不包含顶级 id)
|
|
192
|
+
* @returns 完整的插件对象
|
|
193
|
+
*/
|
|
194
|
+
export declare function definePlugin(plugin: Omit<Plugin, 'id'>): Plugin;
|
|
171
195
|
export interface PluginMetadata {
|
|
172
196
|
id: string;
|
|
173
197
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatbi-v/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"main": "dist/index.cjs",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=18.0.0",
|
|
27
|
-
"react-dom": ">=18.0.0"
|
|
28
|
-
"@chatbi-v/cli": "1.0.9"
|
|
27
|
+
"react-dom": ">=18.0.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
30
|
"tsup": "^8.5.1",
|
|
32
31
|
"vite": "^5.4.21",
|
|
33
|
-
"@chatbi-v/
|
|
32
|
+
"@chatbi-v/cli": "2.0.2",
|
|
33
|
+
"@chatbi-v/tsconfig": "2.0.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "chatbi-cli build",
|