@esengine/ecs-framework 2.1.22 → 2.1.24

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.1.22
2
+ * @esengine/ecs-framework v2.1.24
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -769,8 +769,10 @@ interface IECSDebugConfig {
769
769
  websocketUrl: string;
770
770
  /** 是否自动重连 */
771
771
  autoReconnect?: boolean;
772
- /** 数据更新间隔(毫秒) */
772
+ /** 数据更新间隔(毫秒)- 已弃用,使用debugFrameRate替代 */
773
773
  updateInterval?: number;
774
+ /** 调试数据发送帧率 (60fps, 30fps, 15fps) */
775
+ debugFrameRate?: 60 | 30 | 15;
774
776
  /** 数据通道配置 */
775
777
  channels: {
776
778
  entities: boolean;
@@ -850,6 +852,44 @@ interface IEntityDebugData {
850
852
  componentCount: number;
851
853
  components: string[];
852
854
  }>;
855
+ /** 实体层次结构(根实体) */
856
+ entityHierarchy?: Array<{
857
+ id: number;
858
+ name: string;
859
+ active: boolean;
860
+ enabled: boolean;
861
+ activeInHierarchy: boolean;
862
+ componentCount: number;
863
+ componentTypes: string[];
864
+ parentId: number | null;
865
+ children: any[];
866
+ depth: number;
867
+ tag: number;
868
+ updateOrder: number;
869
+ }>;
870
+ /** 实体详细信息映射 */
871
+ entityDetailsMap?: Record<number, {
872
+ id: number;
873
+ name: string;
874
+ active: boolean;
875
+ enabled: boolean;
876
+ activeInHierarchy: boolean;
877
+ destroyed: boolean;
878
+ tag: number;
879
+ updateOrder: number;
880
+ componentMask: string;
881
+ parentId: number | null;
882
+ parentName: string | null;
883
+ childCount: number;
884
+ childIds: number[];
885
+ depth: number;
886
+ components: Array<{
887
+ typeName: string;
888
+ properties: Record<string, any>;
889
+ }>;
890
+ componentCount: number;
891
+ componentTypes: string[];
892
+ }>;
853
893
  }
854
894
  /**
855
895
  * 系统调试数据接口
@@ -3957,94 +3997,118 @@ declare class EntityBatchOperator {
3957
3997
  declare function createECSAPI(scene: Scene, querySystem: QuerySystem, eventSystem: TypeSafeEventSystem): ECSFluentAPI;
3958
3998
 
3959
3999
  /**
3960
- * ECS调试报告器 - WebSocket模式
3961
- *
3962
- * 负责收集ECS框架的运行时调试数据并通过WebSocket发送到调试服务器
4000
+ * 实体数据收集器
3963
4001
  */
3964
- declare class DebugReporter {
3965
- private config;
3966
- private core;
3967
- private timer?;
3968
- private ws?;
3969
- private lastFrameTime;
3970
- private frameCount;
3971
- private lastFpsTime;
3972
- private fps;
3973
- private sceneStartTime;
3974
- private isConnected;
3975
- private reconnectAttempts;
3976
- private maxReconnectAttempts;
3977
- private frameTimeHistory;
3978
- private maxHistoryLength;
3979
- /**
3980
- * 构造函数
3981
- * @param core Core实例
3982
- * @param config 调试配置
3983
- */
3984
- constructor(core: Core, config: IECSDebugConfig);
3985
- /**
3986
- * 启动调试报告器
3987
- */
3988
- private start;
4002
+ declare class EntityDataCollector {
4003
+ collectEntityData(): IEntityDebugData;
4004
+ getRawEntityList(): Array<{
4005
+ id: number;
4006
+ name: string;
4007
+ active: boolean;
4008
+ enabled: boolean;
4009
+ activeInHierarchy: boolean;
4010
+ componentCount: number;
4011
+ componentTypes: string[];
4012
+ parentId: number | null;
4013
+ childIds: number[];
4014
+ depth: number;
4015
+ tag: number;
4016
+ updateOrder: number;
4017
+ }>;
4018
+ getEntityDetails(entityId: number): any;
4019
+ private getSceneInfo;
4020
+ collectEntityDataWithMemory(): IEntityDebugData;
4021
+ private collectArchetypeData;
4022
+ private getArchetypeDistributionFast;
4023
+ private getTopEntitiesByComponentsFast;
4024
+ private collectArchetypeDataWithMemory;
4025
+ private extractArchetypeStatistics;
4026
+ private extractArchetypeStatisticsWithMemory;
4027
+ private getArchetypeDistribution;
4028
+ private getArchetypeDistributionWithMemory;
4029
+ private getTopEntitiesByComponents;
4030
+ private getTopEntitiesByComponentsWithMemory;
4031
+ private getEmptyEntityDebugData;
4032
+ private calculateFallbackEntityStats;
4033
+ estimateEntityMemoryUsage(entity: any): number;
4034
+ calculateObjectSize(obj: any, excludeKeys?: string[]): number;
4035
+ private buildEntityHierarchyTree;
3989
4036
  /**
3990
- * 停止调试报告器
4037
+ * 构建实体层次结构节点
3991
4038
  */
3992
- stop(): void;
4039
+ private buildEntityHierarchyNode;
3993
4040
  /**
3994
- * 更新配置
3995
- * @param newConfig 新配置
4041
+ * 构建实体详情映射
3996
4042
  */
3997
- updateConfig(newConfig: IECSDebugConfig): void;
4043
+ private buildEntityDetailsMap;
3998
4044
  /**
3999
- * 连接WebSocket
4045
+ * 构建实体基础信息
4000
4046
  */
4001
- private connectWebSocket;
4047
+ private buildFallbackEntityInfo;
4002
4048
  /**
4003
- * 启动数据流
4049
+ * 提取组件详细信息
4004
4050
  */
4005
- private startDataStream;
4051
+ extractComponentDetails(components: Component[]): Array<{
4052
+ typeName: string;
4053
+ properties: Record<string, any>;
4054
+ }>;
4006
4055
  /**
4007
- * 发送消息
4056
+ * 获取组件的完整属性信息(仅在需要时调用)
4008
4057
  */
4009
- private send;
4058
+ getComponentProperties(entityId: number, componentIndex: number): Record<string, any>;
4010
4059
  /**
4011
- * 处理接收到的消息
4012
- * @param message 消息内容
4060
+ * 格式化属性值
4013
4061
  */
4014
- private handleMessage;
4062
+ private formatPropertyValue;
4015
4063
  /**
4016
- * 收集调试数据
4017
- * @returns 调试数据对象
4064
+ * 格式化对象第一层
4018
4065
  */
4019
- private collectDebugData;
4066
+ private formatObjectFirstLevel;
4020
4067
  /**
4021
- * 更新FPS计算
4068
+ * 创建懒加载占位符
4022
4069
  */
4023
- private updateFPS;
4070
+ private createLazyLoadPlaceholder;
4024
4071
  /**
4025
- * 获取框架版本
4072
+ * 获取对象摘要信息
4026
4073
  */
4027
- private getFrameworkVersion;
4074
+ private getObjectSummary;
4028
4075
  /**
4029
- * 获取当前场景名称
4076
+ * 生成对象ID
4030
4077
  */
4031
- private getCurrentSceneName;
4078
+ private generateObjectId;
4032
4079
  /**
4033
- * 收集实体数据
4080
+ * 展开懒加载对象(供调试面板调用)
4034
4081
  */
4035
- private collectEntityData;
4082
+ expandLazyObject(entityId: number, componentIndex: number, propertyPath: string): any;
4036
4083
  /**
4037
- * 获取实体详情
4084
+ * 根据路径获取对象
4038
4085
  */
4039
- private getEntityDetails;
4086
+ private getObjectByPath;
4087
+ }
4088
+
4089
+ /**
4090
+ * 系统数据收集器
4091
+ */
4092
+ declare class SystemDataCollector {
4040
4093
  /**
4041
4094
  * 收集系统数据
4042
4095
  */
4043
- private collectSystemData;
4096
+ collectSystemData(performanceMonitor: any): ISystemDebugData;
4097
+ }
4098
+
4099
+ /**
4100
+ * 性能数据收集器
4101
+ */
4102
+ declare class PerformanceDataCollector {
4103
+ private frameTimeHistory;
4104
+ private maxHistoryLength;
4105
+ private lastGCCount;
4106
+ private gcCollections;
4107
+ private lastMemoryCheck;
4044
4108
  /**
4045
4109
  * 收集性能数据
4046
4110
  */
4047
- private collectPerformanceData;
4111
+ collectPerformanceData(performanceMonitor: any): IPerformanceDebugData;
4048
4112
  /**
4049
4113
  * 获取ECS框架整体性能数据
4050
4114
  */
@@ -4058,46 +4122,212 @@ declare class DebugReporter {
4058
4122
  */
4059
4123
  private getMemoryDetails;
4060
4124
  /**
4061
- * 收集组件数据
4125
+ * 更新GC计数
4126
+ */
4127
+ private updateGCCount;
4128
+ }
4129
+
4130
+ /**
4131
+ * 组件数据收集器
4132
+ */
4133
+ declare class ComponentDataCollector {
4134
+ private static componentSizeCache;
4135
+ /**
4136
+ * 收集组件数据(轻量版,不计算实际内存大小)
4137
+ */
4138
+ collectComponentData(): IComponentDebugData;
4139
+ /**
4140
+ * 获取组件类型的估算内存大小(基于预设值,不进行实际计算)
4062
4141
  */
4063
- private collectComponentData;
4142
+ private getEstimatedComponentSize;
4143
+ private calculateQuickObjectSize;
4064
4144
  /**
4065
- * 计算组件实际内存大小
4145
+ * 为内存快照功能提供的详细内存计算
4146
+ * 只在用户主动请求内存快照时调用
4066
4147
  */
4067
- private calculateComponentMemorySize;
4148
+ calculateDetailedComponentMemory(typeName: string): number;
4068
4149
  /**
4069
- * 估算对象内存大小(字节)
4150
+ * 估算对象内存大小(仅用于内存快照)
4151
+ * 优化版本:减少递归深度,提高性能
4070
4152
  */
4071
4153
  private estimateObjectSize;
4154
+ static clearCache(): void;
4155
+ }
4156
+
4157
+ /**
4158
+ * 场景数据收集器
4159
+ */
4160
+ declare class SceneDataCollector {
4161
+ private sceneStartTime;
4072
4162
  /**
4073
4163
  * 收集场景数据
4074
4164
  */
4075
- private collectSceneData;
4165
+ collectSceneData(): ISceneDebugData;
4076
4166
  /**
4077
- * 手动触发数据收集
4078
- * @returns 当前调试数据
4167
+ * 设置场景开始时间
4079
4168
  */
4080
- getDebugData(): IECSDebugData;
4169
+ setSceneStartTime(time: number): void;
4170
+ }
4171
+
4172
+ /**
4173
+ * WebSocket连接管理器
4174
+ */
4175
+ declare class WebSocketManager {
4176
+ private ws?;
4177
+ private isConnected;
4178
+ private reconnectAttempts;
4179
+ private maxReconnectAttempts;
4180
+ private reconnectInterval;
4181
+ private url;
4182
+ private autoReconnect;
4183
+ private reconnectTimer?;
4184
+ private onOpen?;
4185
+ private onClose?;
4186
+ private onError?;
4187
+ private messageHandler?;
4188
+ constructor(url: string, autoReconnect?: boolean);
4081
4189
  /**
4082
- * 重置场景时间
4190
+ * 设置消息处理回调
4083
4191
  */
4084
- onSceneChanged(): void;
4192
+ setMessageHandler(handler: (message: any) => void): void;
4193
+ /**
4194
+ * 连接WebSocket
4195
+ */
4196
+ connect(): Promise<void>;
4197
+ /**
4198
+ * 断开连接
4199
+ */
4200
+ disconnect(): void;
4201
+ /**
4202
+ * 发送数据
4203
+ */
4204
+ send(data: any): void;
4085
4205
  /**
4086
4206
  * 获取连接状态
4087
4207
  */
4088
- get connected(): boolean;
4208
+ getConnectionStatus(): boolean;
4089
4209
  /**
4090
- * 手动重连
4210
+ * 设置最大重连次数
4091
4211
  */
4092
- reconnect(): void;
4212
+ setMaxReconnectAttempts(attempts: number): void;
4093
4213
  /**
4094
- * 获取Archetype分布
4214
+ * 设置重连间隔
4095
4215
  */
4096
- private getArchetypeDistribution;
4216
+ setReconnectInterval(interval: number): void;
4097
4217
  /**
4098
- * 获取组件数量最多的实体
4218
+ * 计划重连
4099
4219
  */
4100
- private getTopEntitiesByComponents;
4220
+ private scheduleReconnect;
4221
+ /**
4222
+ * 处理接收到的消息
4223
+ */
4224
+ private handleMessage;
4225
+ private handleOpen;
4226
+ private handleClose;
4227
+ private handleError;
4228
+ private handleConnectionFailure;
4229
+ }
4230
+
4231
+ /**
4232
+ * 调试管理器
4233
+ *
4234
+ * 整合所有调试数据收集器,负责收集和发送调试数据
4235
+ */
4236
+ declare class DebugManager {
4237
+ private config;
4238
+ private webSocketManager;
4239
+ private entityCollector;
4240
+ private systemCollector;
4241
+ private performanceCollector;
4242
+ private componentCollector;
4243
+ private sceneCollector;
4244
+ private frameCounter;
4245
+ private lastSendTime;
4246
+ private sendInterval;
4247
+ private isRunning;
4248
+ constructor(core: Core, config: IECSDebugConfig);
4249
+ /**
4250
+ * 启动调试管理器
4251
+ */
4252
+ start(): void;
4253
+ /**
4254
+ * 停止调试管理器
4255
+ */
4256
+ stop(): void;
4257
+ /**
4258
+ * 更新配置
4259
+ */
4260
+ updateConfig(config: IECSDebugConfig): void;
4261
+ /**
4262
+ * 帧更新回调
4263
+ */
4264
+ onFrameUpdate(deltaTime: number): void;
4265
+ /**
4266
+ * 场景变更回调
4267
+ */
4268
+ onSceneChanged(): void;
4269
+ /**
4270
+ * 处理来自调试面板的消息
4271
+ */
4272
+ private handleMessage;
4273
+ /**
4274
+ * 处理展开懒加载对象请求
4275
+ */
4276
+ private handleExpandLazyObjectRequest;
4277
+ /**
4278
+ * 处理获取组件属性请求
4279
+ */
4280
+ private handleGetComponentPropertiesRequest;
4281
+ /**
4282
+ * 处理获取原始实体列表请求
4283
+ */
4284
+ private handleGetRawEntityListRequest;
4285
+ /**
4286
+ * 处理获取实体详情请求
4287
+ */
4288
+ private handleGetEntityDetailsRequest;
4289
+ /**
4290
+ * 处理内存快照请求
4291
+ */
4292
+ private handleMemorySnapshotRequest;
4293
+ /**
4294
+ * 捕获内存快照
4295
+ */
4296
+ private captureMemorySnapshot;
4297
+ /**
4298
+ * 收集基础内存信息
4299
+ */
4300
+ private collectBaseMemoryInfo;
4301
+ /**
4302
+ * 收集组件内存统计(仅用于内存快照)
4303
+ */
4304
+ private collectComponentMemoryStats;
4305
+ private collectSystemMemoryStats;
4306
+ private calculateQuickSystemSize;
4307
+ /**
4308
+ * 收集对象池内存统计
4309
+ */
4310
+ private collectPoolMemoryStats;
4311
+ /**
4312
+ * 收集性能统计信息
4313
+ */
4314
+ private collectPerformanceStats;
4315
+ /**
4316
+ * 获取内存大小分类
4317
+ */
4318
+ private getMemorySizeCategory;
4319
+ /**
4320
+ * 获取调试数据
4321
+ */
4322
+ getDebugData(): IECSDebugData;
4323
+ /**
4324
+ * 连接WebSocket
4325
+ */
4326
+ private connectWebSocket;
4327
+ /**
4328
+ * 发送调试数据
4329
+ */
4330
+ private sendDebugData;
4101
4331
  }
4102
4332
 
4103
4333
  /**
@@ -4190,11 +4420,11 @@ declare class Core {
4190
4420
  */
4191
4421
  _scene?: Scene;
4192
4422
  /**
4193
- * 调试报告器
4423
+ * 调试管理器
4194
4424
  *
4195
4425
  * 负责收集和发送调试数据。
4196
4426
  */
4197
- _debugReporter?: DebugReporter;
4427
+ _debugManager?: DebugManager;
4198
4428
  /**
4199
4429
  * Core配置
4200
4430
  */
@@ -5518,5 +5748,5 @@ declare class Time {
5518
5748
  static checkEvery(interval: number, lastTime: number): boolean;
5519
5749
  }
5520
5750
 
5521
- export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentIndexManager, ComponentPool, ComponentPoolManager, ComponentStorage, ComponentTypeManager, Core, DirtyFlag, DirtyTrackingSystem, ECSEventType, ECSFluentAPI, EVENT_TYPES, Emitter, Entity, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, FuncPack, GlobalEventBus, GlobalManager, HashComponentIndex, IdentifierPool, IndexType, IndexUpdateBatcher, IntervalSystem, Matcher, NumberExtension, PassiveSystem, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, createECSAPI };
5751
+ export { ArchetypeSystem, AsyncEventHandler$1 as AsyncEventHandler, BitMaskOptimizer, BitmapComponentIndex, Bits, Component, ComponentDataCollector, ComponentIndexManager, ComponentPool, ComponentPoolManager, ComponentStorage, ComponentTypeManager, Core, DebugManager, DirtyFlag, DirtyTrackingSystem, ECSEventType, ECSFluentAPI, EVENT_TYPES, Emitter, Entity, EntityDataCollector, EntityList, EntityManager, EntityProcessorList, EntityQueryBuilder, EntitySystem, EventBus, EventHandler$1 as EventHandler, EventPriority, EventTypeValidator, FuncPack, GlobalEventBus, GlobalManager, HashComponentIndex, IdentifierPool, IndexType, IndexUpdateBatcher, IntervalSystem, Matcher, NumberExtension, PassiveSystem, PerformanceDataCollector, PerformanceMonitor, PerformanceWarningType, Pool, PoolManager, ProcessingSystem, QuerySystem, Scene, SceneDataCollector, SystemDataCollector, TieredObjectPool, Time, Timer, TimerManager, TypeSafeEventSystem, TypeUtils, WebSocketManager, createECSAPI };
5522
5752
  export type { Archetype, ArchetypeQueryResult, ComponentType$1 as ComponentType, DirtyData, DirtyListener, EventListenerConfig, EventStats, IComponent, IComponentDebugData, IComponentEventData, ICoreConfig, IECSDebugConfig, IECSDebugData, IEntityDebugData, IEntityEventData, IEventBus, IEventData, IEventListenerConfig, IEventStats, IPerformanceDebugData, IPerformanceEventData, IPoolable, ISceneDebugData, ISceneEventData, ISystemBase, ISystemDebugData, ISystemEventData, ITimer, PerformanceData, PerformanceStats, PerformanceThresholds, PerformanceWarning, PoolStats };