@esengine/ecs-framework 2.2.4 → 2.2.6

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @esengine/ecs-framework v2.2.4
2
+ * @esengine/ecs-framework v2.2.6
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -470,6 +470,8 @@ interface ICoreConfig {
470
470
  enableEntitySystems?: boolean;
471
471
  /** 调试配置 */
472
472
  debugConfig?: IECSDebugConfig;
473
+ /** WorldManager配置 */
474
+ worldManagerConfig?: IWorldManagerConfig;
473
475
  }
474
476
  /**
475
477
  * ECS调试数据接口
@@ -4754,6 +4756,18 @@ declare class SceneSerializer {
4754
4756
  * @param options 反序列化选项
4755
4757
  */
4756
4758
  static deserialize(scene: IScene, saveData: string | Uint8Array, options?: SceneDeserializationOptions): void;
4759
+ /**
4760
+ * 递归添加实体的所有子实体到场景
4761
+ *
4762
+ * 修复反序列化时子实体丢失的问题:
4763
+ * EntitySerializer.deserialize会提前设置子实体的scene引用,
4764
+ * 导致Entity.addChild的条件判断(!child.scene)跳过scene.addEntity调用。
4765
+ * 因此需要在SceneSerializer中统一递归添加所有子实体。
4766
+ *
4767
+ * @param entity 父实体
4768
+ * @param scene 目标场景
4769
+ */
4770
+ private static addChildrenRecursively;
4757
4771
  /**
4758
4772
  * 序列化场景自定义数据
4759
4773
  *
@@ -5144,11 +5158,11 @@ declare class Scene implements IScene {
5144
5158
  */
5145
5159
  private readonly logger;
5146
5160
  /**
5147
- * 性能监控器
5161
+ * 性能监控器缓存
5148
5162
  *
5149
- * 用于监控场景和系统的性能。可以在构造函数中注入,如果不提供则从Core获取。
5163
+ * 用于监控场景和系统的性能。从 ServiceContainer 获取。
5150
5164
  */
5151
- private readonly _performanceMonitor;
5165
+ private _performanceMonitor;
5152
5166
  /**
5153
5167
  * 场景是否已开始运行
5154
5168
  */
@@ -5195,6 +5209,12 @@ declare class Scene implements IScene {
5195
5209
  * 创建场景实例
5196
5210
  */
5197
5211
  constructor(config?: ISceneConfig);
5212
+ /**
5213
+ * 获取性能监控器
5214
+ *
5215
+ * 从 ServiceContainer 获取,如果未注册则创建默认实例(向后兼容)
5216
+ */
5217
+ private get performanceMonitor();
5198
5218
  /**
5199
5219
  * 初始化场景
5200
5220
  *
@@ -6146,6 +6166,12 @@ interface IScene {
6146
6166
  * 引用追踪器
6147
6167
  */
6148
6168
  readonly referenceTracker: ReferenceTracker;
6169
+ /**
6170
+ * 服务容器
6171
+ *
6172
+ * 场景级别的依赖注入容器,用于管理服务的生命周期。
6173
+ */
6174
+ readonly services: ServiceContainer;
6149
6175
  /**
6150
6176
  * 获取系统列表
6151
6177
  */
@@ -6232,13 +6258,6 @@ interface ISceneConfig {
6232
6258
  * 场景名称
6233
6259
  */
6234
6260
  name?: string;
6235
- /**
6236
- * 性能监控器实例(可选)
6237
- *
6238
- * 如果不提供,Scene会自动从Core.services获取全局PerformanceMonitor。
6239
- * 提供此参数可以实现场景级别的独立性能监控。
6240
- */
6241
- performanceMonitor?: any;
6242
6261
  }
6243
6262
 
6244
6263
  /**
@@ -7757,11 +7776,15 @@ declare class SceneManager implements IService {
7757
7776
  * 场景切换回调函数
7758
7777
  */
7759
7778
  private _onSceneChangedCallback?;
7779
+ /**
7780
+ * 性能监控器(从 Core 注入)
7781
+ */
7782
+ private _performanceMonitor;
7760
7783
  /**
7761
7784
  * 默认场景ID
7762
7785
  */
7763
7786
  private static readonly DEFAULT_SCENE_ID;
7764
- constructor();
7787
+ constructor(performanceMonitor?: PerformanceMonitor);
7765
7788
  /**
7766
7789
  * 设置场景切换回调
7767
7790
  *
@@ -9349,6 +9372,7 @@ declare class DebugManager implements IService, IUpdatable {
9349
9372
  private lastSendTime;
9350
9373
  private sendInterval;
9351
9374
  private isRunning;
9375
+ private originalConsole;
9352
9376
  constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, configService: DebugConfigService);
9353
9377
  /**
9354
9378
  * 启动调试管理器
@@ -9358,6 +9382,22 @@ declare class DebugManager implements IService, IUpdatable {
9358
9382
  * 停止调试管理器
9359
9383
  */
9360
9384
  stop(): void;
9385
+ /**
9386
+ * 拦截 console 日志并转发到编辑器
9387
+ */
9388
+ private interceptConsole;
9389
+ /**
9390
+ * 格式化日志消息
9391
+ */
9392
+ private formatLogMessage;
9393
+ /**
9394
+ * 安全的 JSON 序列化,支持循环引用和深度限制
9395
+ */
9396
+ private safeStringify;
9397
+ /**
9398
+ * 发送日志到编辑器
9399
+ */
9400
+ private sendLog;
9361
9401
  /**
9362
9402
  * 更新配置
9363
9403
  */
@@ -10047,6 +10087,156 @@ declare class PluginManager implements IService {
10047
10087
  dispose(): void;
10048
10088
  }
10049
10089
 
10090
+ /**
10091
+ * ECS 调试插件统计信息
10092
+ */
10093
+ interface ECSDebugStats {
10094
+ scenes: SceneDebugInfo[];
10095
+ totalEntities: number;
10096
+ totalSystems: number;
10097
+ timestamp: number;
10098
+ }
10099
+ /**
10100
+ * 场景调试信息
10101
+ */
10102
+ interface SceneDebugInfo {
10103
+ name: string;
10104
+ entityCount: number;
10105
+ systems: SystemDebugInfo[];
10106
+ entities: EntityDebugInfo[];
10107
+ }
10108
+ /**
10109
+ * 系统调试信息
10110
+ */
10111
+ interface SystemDebugInfo {
10112
+ name: string;
10113
+ enabled: boolean;
10114
+ updateOrder: number;
10115
+ entityCount: number;
10116
+ performance?: {
10117
+ avgExecutionTime: number;
10118
+ maxExecutionTime: number;
10119
+ totalCalls: number;
10120
+ };
10121
+ }
10122
+ /**
10123
+ * 实体调试信息
10124
+ */
10125
+ interface EntityDebugInfo {
10126
+ id: number;
10127
+ name: string;
10128
+ enabled: boolean;
10129
+ tag: number;
10130
+ componentCount: number;
10131
+ components: ComponentDebugInfo[];
10132
+ }
10133
+ /**
10134
+ * 组件调试信息
10135
+ */
10136
+ interface ComponentDebugInfo {
10137
+ type: string;
10138
+ data: any;
10139
+ }
10140
+ /**
10141
+ * ECS 调试插件
10142
+ *
10143
+ * 提供运行时调试功能:
10144
+ * - 实时查看实体和组件信息
10145
+ * - System 执行统计
10146
+ * - 性能监控
10147
+ * - 实体查询
10148
+ *
10149
+ * @example
10150
+ * ```typescript
10151
+ * const core = Core.create();
10152
+ * const debugPlugin = new DebugPlugin({ autoStart: true, updateInterval: 1000 });
10153
+ * await core.pluginManager.install(debugPlugin);
10154
+ *
10155
+ * // 获取调试信息
10156
+ * const stats = debugPlugin.getStats();
10157
+ * console.log('Total entities:', stats.totalEntities);
10158
+ *
10159
+ * // 查询实体
10160
+ * const entities = debugPlugin.queryEntities({ tag: 1 });
10161
+ * ```
10162
+ */
10163
+ declare class DebugPlugin implements IPlugin, IService {
10164
+ readonly name = "@esengine/debug-plugin";
10165
+ readonly version = "1.0.0";
10166
+ private worldManager;
10167
+ private updateInterval;
10168
+ private updateTimer;
10169
+ private autoStart;
10170
+ /**
10171
+ * 创建调试插件实例
10172
+ *
10173
+ * @param options - 配置选项
10174
+ */
10175
+ constructor(options?: {
10176
+ autoStart?: boolean;
10177
+ updateInterval?: number;
10178
+ });
10179
+ /**
10180
+ * 安装插件
10181
+ */
10182
+ install(core: Core, services: ServiceContainer): Promise<void>;
10183
+ /**
10184
+ * 卸载插件
10185
+ */
10186
+ uninstall(): Promise<void>;
10187
+ /**
10188
+ * 实现 IService 接口
10189
+ */
10190
+ dispose(): void;
10191
+ /**
10192
+ * 启动调试监控
10193
+ */
10194
+ start(): void;
10195
+ /**
10196
+ * 停止调试监控
10197
+ */
10198
+ stop(): void;
10199
+ /**
10200
+ * 获取当前 ECS 统计信息
10201
+ */
10202
+ getStats(): ECSDebugStats;
10203
+ /**
10204
+ * 获取场景调试信息
10205
+ */
10206
+ getSceneInfo(scene: IScene): SceneDebugInfo;
10207
+ /**
10208
+ * 获取系统调试信息
10209
+ */
10210
+ private getSystemInfo;
10211
+ /**
10212
+ * 获取实体调试信息
10213
+ */
10214
+ getEntityInfo(entity: Entity): EntityDebugInfo;
10215
+ /**
10216
+ * 获取组件调试信息
10217
+ */
10218
+ private getComponentInfo;
10219
+ /**
10220
+ * 查询实体
10221
+ *
10222
+ * @param filter - 查询过滤器
10223
+ */
10224
+ queryEntities(filter: {
10225
+ sceneId?: string;
10226
+ tag?: number;
10227
+ name?: string;
10228
+ hasComponent?: string;
10229
+ }): EntityDebugInfo[];
10230
+ /**
10231
+ * 打印统计信息到日志
10232
+ */
10233
+ private logStats;
10234
+ /**
10235
+ * 导出调试数据为 JSON
10236
+ */
10237
+ exportJSON(): string;
10238
+ }
10239
+
10050
10240
  /**
10051
10241
  * 依赖注入装饰器
10052
10242
  *
@@ -10824,5 +11014,5 @@ declare function getFullPlatformConfig(): Promise<any>;
10824
11014
  declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
10825
11015
  declare function hasAdapter(): boolean;
10826
11016
 
10827
- export { AutoTyped, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, DebugConfigService, DebugManager, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, HighPrecision, IdentifierPool, IgnoreSerialization, IncrementalSerializer, Inject, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, MigrationBuilder, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PluginManager, PluginState, Pool, PoolManager, ProcessingSystem, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeInference, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, buildEntity, createECSAPI, createInstance, createLogger, createQuery, getBasicWorkerConfig, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getFullPlatformConfig, getOrAddComponent, getSceneByEntityId, getSerializationMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, hasAdapter, hasAnyComponent, hasComponents, hasEntityRef, isComponentArray, isComponentType, isSerializable, isUpdatable, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, supportsFeature, tryGetComponent, updateComponent };
10828
- export type { AnyComponentConstructor, BitMask64Data, ComponentChange, ComponentConstructor, ComponentInstance, ComponentMigrationFunction, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, EntityChange, EntityRefMetadata, EntityRefRecord, EntityWithComponents, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, LoggerColorConfig, LoggerConfig, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, SceneDataChange, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };
11017
+ export { AutoTyped, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ConsoleLogger, Core, DebugConfigService, DebugManager, DebugPlugin, DeepCopy, ECSComponent, ECSEventType, ECSFluentAPI, ECSSystem, ENTITY_REF_METADATA, EVENT_TYPES, Emitter, EnableSoA, Entity, EntityDataCollector, EntityList, EntityProcessorList, EntityRef, EntitySerializer, EntitySystem, EventBus, EventPriority, EventTypeValidator, Float32, Float64, FuncPack, GlobalEventBus, GlobalManager, HighPrecision, IdentifierPool, IgnoreSerialization, IncrementalSerializer, Inject, Injectable, Int16, Int32, Int8, IntervalSystem, LogLevel, Logger, LoggerManager, Matcher, MigrationBuilder, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, PlatformDetector, PlatformManager, PluginManager, PluginState, Pool, PoolManager, ProcessingSystem, QuerySystem, ReactiveQuery, ReactiveQueryChangeType, ReferenceTracker, SERIALIZABLE_METADATA, SERIALIZE_FIELD, SERIALIZE_OPTIONS, SYSTEM_TYPE_NAME, Scene, SceneDataCollector, SceneManager, SceneSerializer, Serializable, Serialize, SerializeArray, SerializeAsMap, SerializeAsSet, SerializeMap, SerializeSet, ServiceContainer, ServiceLifetime, SoAStorage, SparseSet, SystemDataCollector, Time, Timer, TimerManager, TypeInference, TypeSafeEventSystem, TypeUtils, TypedEntityBuilder, TypedQueryBuilder, TypedQueryResult, Uint16, Uint32, Uint8, Uint8Clamped, Updatable, VersionMigrationManager, WebSocketManager, WorkerEntitySystem, World, WorldManager, addAndConfigure, buildEntity, createECSAPI, createInstance, createLogger, createQuery, getBasicWorkerConfig, getComponentInstanceTypeName, getComponentTypeName, getComponents, getCurrentAdapter, getEntityRefMetadata, getFullPlatformConfig, getOrAddComponent, getSceneByEntityId, getSerializationMetadata, getSystemInstanceTypeName, getSystemMetadata, getSystemTypeName, getUpdatableMetadata, hasAdapter, hasAnyComponent, hasComponents, hasEntityRef, isComponentArray, isComponentType, isSerializable, isUpdatable, queryFor, queryForAll, registerInjectable, registerPlatformAdapter, requireComponent, resetLoggerColors, setGlobalLogLevel, setLoggerColors, supportsFeature, tryGetComponent, updateComponent };
11018
+ export type { AnyComponentConstructor, BitMask64Data, ComponentChange, ComponentConstructor, ComponentDebugInfo, ComponentInstance, ComponentMigrationFunction, ComponentType$1 as ComponentType, ComponentTypeMap, ComponentTypeName, ComponentTypeNames, DataOnly, DeepPartial, DeepReadonly, DeserializationStrategy, ECSDebugStats, EntityChange, EntityDebugInfo, EntityRefMetadata, EntityRefRecord, EntityWithComponents, EventListenerConfig, EventStats, ExtractComponents, FieldSerializeOptions, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEntityHierarchyNode, IEventBus, IEventData, IEventListenerConfig, IEventStats, ILogger, IPerformanceDebugData, IPerformanceEventData, IPlatformAdapter, IPlugin, IPluginMetadata, IPoolable, IScene, ISceneConfig, ISceneDebugData, ISceneEventData, ISceneFactory, IService, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, IUpdatable, IWorldConfig, IWorldManagerConfig, IncrementalSerializationFormat, IncrementalSerializationOptions, IncrementalSnapshot, InjectableMetadata, LoggerColorConfig, LoggerConfig, MigrationFunction, PartialComponent, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PlatformConfig, PlatformDetectionResult, PlatformWorker, PoolStats, QueryResult$1 as QueryResult, ReactiveQueryChange, ReactiveQueryConfig, ReactiveQueryListener, ReadonlyComponent, SceneDataChange, SceneDebugInfo, SceneDeserializationOptions, SceneMigrationFunction, SceneSerializationOptions, SerializableComponent, SerializableFields, SerializableOptions, SerializationFormat, SerializationMetadata, SerializedComponent, SerializedEntity, SerializedScene, ServiceType, SharedArrayBufferProcessFunction, SupportedTypedArray, SystemDebugInfo, SystemEntityType, SystemLifecycleHooks, SystemMetadata, TypeSafeBuilder, TypedEventHandler, TypedQueryCondition, UpdatableMetadata, ValidComponent, ValidComponentArray, WorkerCreationOptions, WorkerProcessFunction, WorkerSystemConfig };