@chatbi-v/core 1.0.4 → 2.0.1

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.
@@ -0,0 +1,75 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // src/config-manager.ts
28
+ var ConfigManager = class {
29
+ /** 存储配置的 Map */
30
+ config = /* @__PURE__ */ new Map();
31
+ /**
32
+ * 设置配置项
33
+ * @param key 配置键
34
+ * @param value 配置值
35
+ */
36
+ set(key, value) {
37
+ this.config.set(key, value);
38
+ }
39
+ /**
40
+ * 获取配置项
41
+ * @param key 配置键
42
+ */
43
+ get(key) {
44
+ return this.config.get(key);
45
+ }
46
+ /**
47
+ * 合并配置
48
+ * @param config 配置对象
49
+ */
50
+ merge(config) {
51
+ Object.keys(config).forEach((key) => {
52
+ const existing = this.config.get(key);
53
+ const incoming = config[key];
54
+ if (existing && typeof existing === "object" && incoming && typeof incoming === "object") {
55
+ this.config.set(key, { ...existing, ...incoming });
56
+ } else {
57
+ this.config.set(key, incoming);
58
+ }
59
+ });
60
+ }
61
+ /**
62
+ * 获取所有配置
63
+ */
64
+ getAll() {
65
+ return Object.fromEntries(this.config);
66
+ }
67
+ };
68
+ var configManager = new ConfigManager();
69
+
70
+ export {
71
+ __commonJS,
72
+ __toESM,
73
+ ConfigManager,
74
+ configManager
75
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfigManager,
3
3
  configManager
4
- } from "./chunk-G3OU7D3Y.mjs";
4
+ } from "./chunk-IOE2RMEZ.mjs";
5
5
  export {
6
6
  ConfigManager,
7
7
  configManager
@@ -3,21 +3,13 @@ export interface PluginRegistry {
3
3
  }
4
4
  export interface DiscoveryRule {
5
5
  /**
6
- * 插件发现的 Glob 模式 (例如: '@chatbi-plugins/*\/src/index.{ts,tsx}')
7
- */
8
- pattern: string;
9
- /**
10
- * 路径标识部分(用于从绝对路径中提取 ID,例如 'packages/plugins')
6
+ * 路径匹配标识(如 'plugins' '@chatbi-plugins'
11
7
  */
12
8
  pathSegment: string;
13
9
  /**
14
- * 生成插件 ID 时的前缀
10
+ * 生成插件 ID 时的前缀(如 '@chatbi-v/plugin')
15
11
  */
16
12
  idPrefix: string;
17
- /**
18
- * 可选的别名映射
19
- */
20
- alias?: string;
21
13
  }
22
14
  /**
23
15
  * 自动发现并解析插件
@@ -25,13 +17,5 @@ export interface DiscoveryRule {
25
17
  */
26
18
  export declare const resolvePluginRegistry: (options: {
27
19
  modules: Record<string, () => Promise<any>>;
28
- baseUrl: string;
29
- rules: DiscoveryRule[];
20
+ rules?: DiscoveryRule[];
30
21
  }) => PluginRegistry;
31
- /**
32
- * 核心插件发现方法
33
- * @description 该方法应在应用层被调用,但逻辑集成在 core 中。
34
- * 注意:由于 Vite import.meta.glob 必须使用字面量的限制,
35
- * 这里使用一个覆盖范围合理的模式,并通过 rules 进行精确匹配。
36
- */
37
- export declare const discoverPlugins: (rules: DiscoveryRule[], baseUrl: string) => PluginRegistry;
@@ -104,9 +104,6 @@ export declare class PluginManager {
104
104
  * @param slot 插槽位置
105
105
  */
106
106
  getExtensions(slot: SlotPosition | string): PluginExtension[];
107
- /**
108
- * 获取所有收集到的路由
109
- */
110
107
  getRoutes(): RouteConfig[];
111
108
  /**
112
109
  * 注册插件
@@ -1,6 +1,8 @@
1
1
  export interface PluginLoaderOptions {
2
2
  /** 插件发现规则 */
3
3
  discoveryRules?: any[];
4
+ /** 插件模块映射 (由 Vite import.meta.glob 生成) */
5
+ modules?: Record<string, () => Promise<any>>;
4
6
  /** 预注册的插件注册表 (可选,用于离线或手动加载) */
5
7
  registry?: Record<string, () => Promise<any>>;
6
8
  /** 插件配置映射 */