@chatbi-v/core 2.1.6 → 2.1.7

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.
@@ -529,64 +529,6 @@ interface PluginMetadata {
529
529
  }[];
530
530
  }
531
531
 
532
- /**
533
- * 服务注册中心 (Service Registry)
534
- * @description 核心应用层服务,作为微内核架构中的“中枢调度员”。
535
- * 主要职责:
536
- * 1. 服务解耦:允许插件将其内部功能暴露为“服务”,而无需与其他插件产生物理依赖。
537
- * 2. 动态发现:提供按名称查找服务的能力,支持服务热插拔。
538
- * 3. 依赖协调:通过 `waitFor` 机制解决插件间由于加载顺序导致的初始化依赖问题。
539
- *
540
- * 建议的服务命名规范: `pluginId.serviceName` (例如: `auth.sessionService`)
541
- */
542
- declare class ServiceRegistry {
543
- /** 存储已注册服务的 Map 对象 */
544
- private services;
545
- /** 存储正在等待特定服务的监听器集合 */
546
- private listeners;
547
- /**
548
- * 注册一个服务实现
549
- * @param name - 唯一的服务名称
550
- * @param service - 服务实例或对象
551
- */
552
- register(name: string, service: any): void;
553
- /**
554
- * 同步获取服务实例
555
- * @template T - 服务类型的泛型
556
- * @param name - 服务名称
557
- * @returns 服务实例,若不存在则返回 undefined
558
- */
559
- get<T = any>(name: string): T | undefined;
560
- /**
561
- * 异步等待并获取服务
562
- * @description 如果服务尚未注册,将返回一个 Promise,直到该服务被注册时 resolve。
563
- * 支持设置超时时间,防止因插件加载失败导致的永久挂起。
564
- *
565
- * @template T - 服务类型的泛型
566
- * @param name - 待等待的服务名称
567
- * @param timeout - 超时时间 (毫秒),默认 10000ms (10秒)。若为 0 则永不超时。
568
- * @returns 包含服务实例的 Promise
569
- * @throws {Error} 若在规定时间内服务未注册,则抛出超时异常。
570
- */
571
- waitFor<T = any>(name: string, timeout?: number): Promise<T>;
572
- /**
573
- * 检查服务是否已注册
574
- * @param name - 服务名称
575
- */
576
- has(name: string): boolean;
577
- /**
578
- * 注销特定的服务
579
- * @param name - 服务名称
580
- */
581
- unregister(name: string): void;
582
- /**
583
- * 清除所有已注册的服务和监听器
584
- * @description 通常仅在系统重置或大型热更新时使用。
585
- */
586
- clear(): void;
587
- }
588
- declare const serviceRegistry: ServiceRegistry;
589
-
590
532
  /**
591
533
  * 基于 Axios 的默认请求适配器
592
534
  */
@@ -748,6 +690,64 @@ interface ApiProviderProps {
748
690
  declare const ApiProvider: React.FC<ApiProviderProps>;
749
691
  declare const useApi: () => ApiEngine;
750
692
 
693
+ /**
694
+ * 服务注册中心 (Service Registry)
695
+ * @description 核心应用层服务,作为微内核架构中的“中枢调度员”。
696
+ * 主要职责:
697
+ * 1. 服务解耦:允许插件将其内部功能暴露为“服务”,而无需与其他插件产生物理依赖。
698
+ * 2. 动态发现:提供按名称查找服务的能力,支持服务热插拔。
699
+ * 3. 依赖协调:通过 `waitFor` 机制解决插件间由于加载顺序导致的初始化依赖问题。
700
+ *
701
+ * 建议的服务命名规范: `pluginId.serviceName` (例如: `auth.sessionService`)
702
+ */
703
+ declare class ServiceRegistry {
704
+ /** 存储已注册服务的 Map 对象 */
705
+ private services;
706
+ /** 存储正在等待特定服务的监听器集合 */
707
+ private listeners;
708
+ /**
709
+ * 注册一个服务实现
710
+ * @param name - 唯一的服务名称
711
+ * @param service - 服务实例或对象
712
+ */
713
+ register(name: string, service: any): void;
714
+ /**
715
+ * 同步获取服务实例
716
+ * @template T - 服务类型的泛型
717
+ * @param name - 服务名称
718
+ * @returns 服务实例,若不存在则返回 undefined
719
+ */
720
+ get<T = any>(name: string): T | undefined;
721
+ /**
722
+ * 异步等待并获取服务
723
+ * @description 如果服务尚未注册,将返回一个 Promise,直到该服务被注册时 resolve。
724
+ * 支持设置超时时间,防止因插件加载失败导致的永久挂起。
725
+ *
726
+ * @template T - 服务类型的泛型
727
+ * @param name - 待等待的服务名称
728
+ * @param timeout - 超时时间 (毫秒),默认 10000ms (10秒)。若为 0 则永不超时。
729
+ * @returns 包含服务实例的 Promise
730
+ * @throws {Error} 若在规定时间内服务未注册,则抛出超时异常。
731
+ */
732
+ waitFor<T = any>(name: string, timeout?: number): Promise<T>;
733
+ /**
734
+ * 检查服务是否已注册
735
+ * @param name - 服务名称
736
+ */
737
+ has(name: string): boolean;
738
+ /**
739
+ * 注销特定的服务
740
+ * @param name - 服务名称
741
+ */
742
+ unregister(name: string): void;
743
+ /**
744
+ * 清除所有已注册的服务和监听器
745
+ * @description 通常仅在系统重置或大型热更新时使用。
746
+ */
747
+ clear(): void;
748
+ }
749
+ declare const serviceRegistry: ServiceRegistry;
750
+
751
751
  /**
752
752
  * 配置管理器
753
753
  * @description 核心工具类,负责管理应用的全局系统配置以及各插件的初始化业务配置。
@@ -1546,6 +1546,36 @@ declare class ProxySandbox {
1546
1546
  private patchGlobalEffects;
1547
1547
  }
1548
1548
 
1549
+ /**
1550
+ * 日期时间格式化工具类
1551
+ */
1552
+ declare const dateUtils: {
1553
+ /**
1554
+ * 格式化日期为 YYYY-MM-DD
1555
+ */
1556
+ formatDate(date?: dayjs.ConfigType): string;
1557
+ /**
1558
+ * 格式化时间为 HH:mm:ss
1559
+ */
1560
+ formatTime(date?: dayjs.ConfigType): string;
1561
+ /**
1562
+ * 格式化日期时间为 YYYY-MM-DD HH:mm:ss
1563
+ */
1564
+ formatDateTime(date?: dayjs.ConfigType): string;
1565
+ /**
1566
+ * 获取当前时间戳(毫秒)
1567
+ */
1568
+ now(): number;
1569
+ /**
1570
+ * 获取相对时间(例如:几分钟前)
1571
+ */
1572
+ fromNow(date: dayjs.ConfigType): string;
1573
+ /**
1574
+ * 原始 dayjs 对象,用于更复杂的场景
1575
+ */
1576
+ dayjs: typeof dayjs;
1577
+ };
1578
+
1549
1579
  /**
1550
1580
  * 日志等级枚举
1551
1581
  */
@@ -1655,36 +1685,6 @@ declare const logger: Logger;
1655
1685
  */
1656
1686
  declare const createLogger: (prefix: string) => Logger;
1657
1687
 
1658
- /**
1659
- * 日期时间格式化工具类
1660
- */
1661
- declare const dateUtils: {
1662
- /**
1663
- * 格式化日期为 YYYY-MM-DD
1664
- */
1665
- formatDate(date?: dayjs.ConfigType): string;
1666
- /**
1667
- * 格式化时间为 HH:mm:ss
1668
- */
1669
- formatTime(date?: dayjs.ConfigType): string;
1670
- /**
1671
- * 格式化日期时间为 YYYY-MM-DD HH:mm:ss
1672
- */
1673
- formatDateTime(date?: dayjs.ConfigType): string;
1674
- /**
1675
- * 获取当前时间戳(毫秒)
1676
- */
1677
- now(): number;
1678
- /**
1679
- * 获取相对时间(例如:几分钟前)
1680
- */
1681
- fromNow(date: dayjs.ConfigType): string;
1682
- /**
1683
- * 原始 dayjs 对象,用于更复杂的场景
1684
- */
1685
- dayjs: typeof dayjs;
1686
- };
1687
-
1688
1688
  type KeepStrategy = 'first' | 'last' | 'search' | 'hash';
1689
1689
  /**
1690
1690
  * 把当前地址中所有出现的参数合并成一份。
@@ -1703,22 +1703,6 @@ declare function cleanUrlParams(keysToRemove: string[]): string;
1703
1703
 
1704
1704
  declare const version = "1.0.0";
1705
1705
 
1706
- /**
1707
- * Hook 配置选项
1708
- */
1709
- interface UseStorageStateOptions<T> {
1710
- defaultValue?: T;
1711
- scope?: 'plugin' | 'shared';
1712
- }
1713
- /**
1714
- * 统一存储状态 Hook
1715
- * @description 提供与 StorageManager 和 Schema Registry 集成的持久化状态 Hook。
1716
- * @param pluginId 定义该 Key 的插件 ID
1717
- * @param key 存储键名 (必须在 Schema 中注册)
1718
- * @param options 配置项,包含默认值和作用域
1719
- */
1720
- declare function useStorageState<T>(pluginId: string, key: string, options?: UseStorageStateOptions<T>): [T, (value: T | ((val: T) => T)) => void];
1721
-
1722
1706
  /** 插件加载 Hook 的配置选项 */
1723
1707
  interface PluginLoaderOptions {
1724
1708
  /** 插件发现规则,定义如何从模块列表中识别插件 */
@@ -1755,4 +1739,20 @@ declare const usePluginLoader: (options: PluginLoaderOptions) => {
1755
1739
  pluginVersion: number;
1756
1740
  };
1757
1741
 
1742
+ /**
1743
+ * Hook 配置选项
1744
+ */
1745
+ interface UseStorageStateOptions<T> {
1746
+ defaultValue?: T;
1747
+ scope?: 'plugin' | 'shared';
1748
+ }
1749
+ /**
1750
+ * 统一存储状态 Hook
1751
+ * @description 提供与 StorageManager 和 Schema Registry 集成的持久化状态 Hook。
1752
+ * @param pluginId 定义该 Key 的插件 ID
1753
+ * @param key 存储键名 (必须在 Schema 中注册)
1754
+ * @param options 配置项,包含默认值和作用域
1755
+ */
1756
+ declare function useStorageState<T>(pluginId: string, key: string, options?: UseStorageStateOptions<T>): [T, (value: T | ((val: T) => T)) => void];
1757
+
1758
1758
  export { type ApiAdapter, type ApiConfig, type ApiEndpointConfig, ApiEngine, type ApiInterceptor, ApiProvider, type ApiProviderProps, type ApiRequestConfig, type ApiResponseContext, AvatarSkeleton, AxiosAdapter, BasePlugin, type BaseResponse, BlockSkeleton, ConfigManager, DefaultEventBus, type DiscoveryRule, type ErrorStrategy, type EventBus, type EventBusPort, type EventCallback, type HttpMethod, LocalStorageAdapter, LogLevel, Logger, PLUGIN_TYPES, type Plugin, type PluginCapabilities, type PluginConfigItem, type PluginContext, PluginErrorBoundary, type PluginExtension, type PluginLifecycle, type PluginLoaderOptions, PluginManager, type PluginMetadata, PluginProvider, type PluginProviderProps, type PluginRegistry, PluginRuntime, PluginSandbox, PluginSlot, type PluginStorage, type PluginType, ProxySandbox, type RequestOptions, type RouteConfig, SUCCESS_CODE, type Scene, ScopedStorageAdapter, ServiceRegistry, SidebarIconSkeleton, Slot, type SlotPosition, SlotSkeletons, type SlotType, StatusBarItemSkeleton, type StorageItemSchema, StorageManager, type StoragePort, type StreamCallbacks, type TypedStorage, type UseStorageStateOptions, apiEngine, cleanUrlParams, configManager, createLogger, dateUtils, definePlugin, isMockMode, logger, normalizeParams, pluginManager, resolveApiModules, resolvePluginRegistry, serviceRegistry, useApi, usePluginLoader, usePluginManager, useStorageState, version };