@esengine/ecs-framework 2.2.4 → 2.2.5

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.5
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -4754,6 +4754,18 @@ declare class SceneSerializer {
4754
4754
  * @param options 反序列化选项
4755
4755
  */
4756
4756
  static deserialize(scene: IScene, saveData: string | Uint8Array, options?: SceneDeserializationOptions): void;
4757
+ /**
4758
+ * 递归添加实体的所有子实体到场景
4759
+ *
4760
+ * 修复反序列化时子实体丢失的问题:
4761
+ * EntitySerializer.deserialize会提前设置子实体的scene引用,
4762
+ * 导致Entity.addChild的条件判断(!child.scene)跳过scene.addEntity调用。
4763
+ * 因此需要在SceneSerializer中统一递归添加所有子实体。
4764
+ *
4765
+ * @param entity 父实体
4766
+ * @param scene 目标场景
4767
+ */
4768
+ private static addChildrenRecursively;
4757
4769
  /**
4758
4770
  * 序列化场景自定义数据
4759
4771
  *
@@ -9349,6 +9361,7 @@ declare class DebugManager implements IService, IUpdatable {
9349
9361
  private lastSendTime;
9350
9362
  private sendInterval;
9351
9363
  private isRunning;
9364
+ private originalConsole;
9352
9365
  constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, configService: DebugConfigService);
9353
9366
  /**
9354
9367
  * 启动调试管理器
@@ -9358,6 +9371,22 @@ declare class DebugManager implements IService, IUpdatable {
9358
9371
  * 停止调试管理器
9359
9372
  */
9360
9373
  stop(): void;
9374
+ /**
9375
+ * 拦截 console 日志并转发到编辑器
9376
+ */
9377
+ private interceptConsole;
9378
+ /**
9379
+ * 格式化日志消息
9380
+ */
9381
+ private formatLogMessage;
9382
+ /**
9383
+ * 安全的 JSON 序列化,支持循环引用和深度限制
9384
+ */
9385
+ private safeStringify;
9386
+ /**
9387
+ * 发送日志到编辑器
9388
+ */
9389
+ private sendLog;
9361
9390
  /**
9362
9391
  * 更新配置
9363
9392
  */
@@ -10047,6 +10076,156 @@ declare class PluginManager implements IService {
10047
10076
  dispose(): void;
10048
10077
  }
10049
10078
 
10079
+ /**
10080
+ * ECS 调试插件统计信息
10081
+ */
10082
+ interface ECSDebugStats {
10083
+ scenes: SceneDebugInfo[];
10084
+ totalEntities: number;
10085
+ totalSystems: number;
10086
+ timestamp: number;
10087
+ }
10088
+ /**
10089
+ * 场景调试信息
10090
+ */
10091
+ interface SceneDebugInfo {
10092
+ name: string;
10093
+ entityCount: number;
10094
+ systems: SystemDebugInfo[];
10095
+ entities: EntityDebugInfo[];
10096
+ }
10097
+ /**
10098
+ * 系统调试信息
10099
+ */
10100
+ interface SystemDebugInfo {
10101
+ name: string;
10102
+ enabled: boolean;
10103
+ updateOrder: number;
10104
+ entityCount: number;
10105
+ performance?: {
10106
+ avgExecutionTime: number;
10107
+ maxExecutionTime: number;
10108
+ totalCalls: number;
10109
+ };
10110
+ }
10111
+ /**
10112
+ * 实体调试信息
10113
+ */
10114
+ interface EntityDebugInfo {
10115
+ id: number;
10116
+ name: string;
10117
+ enabled: boolean;
10118
+ tag: number;
10119
+ componentCount: number;
10120
+ components: ComponentDebugInfo[];
10121
+ }
10122
+ /**
10123
+ * 组件调试信息
10124
+ */
10125
+ interface ComponentDebugInfo {
10126
+ type: string;
10127
+ data: any;
10128
+ }
10129
+ /**
10130
+ * ECS 调试插件
10131
+ *
10132
+ * 提供运行时调试功能:
10133
+ * - 实时查看实体和组件信息
10134
+ * - System 执行统计
10135
+ * - 性能监控
10136
+ * - 实体查询
10137
+ *
10138
+ * @example
10139
+ * ```typescript
10140
+ * const core = Core.create();
10141
+ * const debugPlugin = new DebugPlugin({ autoStart: true, updateInterval: 1000 });
10142
+ * await core.pluginManager.install(debugPlugin);
10143
+ *
10144
+ * // 获取调试信息
10145
+ * const stats = debugPlugin.getStats();
10146
+ * console.log('Total entities:', stats.totalEntities);
10147
+ *
10148
+ * // 查询实体
10149
+ * const entities = debugPlugin.queryEntities({ tag: 1 });
10150
+ * ```
10151
+ */
10152
+ declare class DebugPlugin implements IPlugin, IService {
10153
+ readonly name = "@esengine/debug-plugin";
10154
+ readonly version = "1.0.0";
10155
+ private worldManager;
10156
+ private updateInterval;
10157
+ private updateTimer;
10158
+ private autoStart;
10159
+ /**
10160
+ * 创建调试插件实例
10161
+ *
10162
+ * @param options - 配置选项
10163
+ */
10164
+ constructor(options?: {
10165
+ autoStart?: boolean;
10166
+ updateInterval?: number;
10167
+ });
10168
+ /**
10169
+ * 安装插件
10170
+ */
10171
+ install(core: Core, services: ServiceContainer): Promise<void>;
10172
+ /**
10173
+ * 卸载插件
10174
+ */
10175
+ uninstall(): Promise<void>;
10176
+ /**
10177
+ * 实现 IService 接口
10178
+ */
10179
+ dispose(): void;
10180
+ /**
10181
+ * 启动调试监控
10182
+ */
10183
+ start(): void;
10184
+ /**
10185
+ * 停止调试监控
10186
+ */
10187
+ stop(): void;
10188
+ /**
10189
+ * 获取当前 ECS 统计信息
10190
+ */
10191
+ getStats(): ECSDebugStats;
10192
+ /**
10193
+ * 获取场景调试信息
10194
+ */
10195
+ getSceneInfo(scene: IScene): SceneDebugInfo;
10196
+ /**
10197
+ * 获取系统调试信息
10198
+ */
10199
+ private getSystemInfo;
10200
+ /**
10201
+ * 获取实体调试信息
10202
+ */
10203
+ getEntityInfo(entity: Entity): EntityDebugInfo;
10204
+ /**
10205
+ * 获取组件调试信息
10206
+ */
10207
+ private getComponentInfo;
10208
+ /**
10209
+ * 查询实体
10210
+ *
10211
+ * @param filter - 查询过滤器
10212
+ */
10213
+ queryEntities(filter: {
10214
+ sceneId?: string;
10215
+ tag?: number;
10216
+ name?: string;
10217
+ hasComponent?: string;
10218
+ }): EntityDebugInfo[];
10219
+ /**
10220
+ * 打印统计信息到日志
10221
+ */
10222
+ private logStats;
10223
+ /**
10224
+ * 导出调试数据为 JSON
10225
+ */
10226
+ exportJSON(): string;
10227
+ }
10228
+
10050
10229
  /**
10051
10230
  * 依赖注入装饰器
10052
10231
  *
@@ -10824,5 +11003,5 @@ declare function getFullPlatformConfig(): Promise<any>;
10824
11003
  declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
10825
11004
  declare function hasAdapter(): boolean;
10826
11005
 
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 };
11006
+ 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 };
11007
+ 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 };