@esengine/ecs-framework 2.2.3 → 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.3
2
+ * @esengine/ecs-framework v2.2.5
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -2517,7 +2517,7 @@ declare class PerformanceMonitor implements IService {
2517
2517
  /**
2518
2518
  * 查询条件类型
2519
2519
  */
2520
- interface QueryCondition {
2520
+ interface QueryCondition$1 {
2521
2521
  all: ComponentType[];
2522
2522
  any: ComponentType[];
2523
2523
  none: ComponentType[];
@@ -2636,7 +2636,7 @@ declare class Matcher {
2636
2636
  /**
2637
2637
  * 获取查询条件(只读)
2638
2638
  */
2639
- getCondition(): Readonly<QueryCondition>;
2639
+ getCondition(): Readonly<QueryCondition$1>;
2640
2640
  /**
2641
2641
  * 检查是否为空条件
2642
2642
  */
@@ -2863,55 +2863,6 @@ declare class Bits {
2863
2863
  getLowestBitIndex(): number;
2864
2864
  }
2865
2865
 
2866
- /**
2867
- * 组件类型管理器
2868
- * 负责管理组件类型的注册和ID分配
2869
- * 支持无限数量的组件类型(通过自动扩展 BitMask)
2870
- */
2871
- declare class ComponentTypeManager {
2872
- private static _instance;
2873
- private _componentTypes;
2874
- private _typeNames;
2875
- private _nextTypeId;
2876
- /**
2877
- * 获取单例实例
2878
- */
2879
- static get instance(): ComponentTypeManager;
2880
- private constructor();
2881
- /**
2882
- * 获取组件类型的ID
2883
- * @param componentType 组件类型构造函数
2884
- * @returns 组件类型ID
2885
- */
2886
- getTypeId(componentType: ComponentType$1): number;
2887
- /**
2888
- * 获取组件类型名称
2889
- * @param typeId 组件类型ID
2890
- * @returns 组件类型名称
2891
- */
2892
- getTypeName(typeId: number): string;
2893
- /**
2894
- * 创建包含指定组件类型的Bits对象
2895
- * @param componentTypes 组件类型构造函数数组
2896
- * @returns Bits对象
2897
- */
2898
- createBits(...componentTypes: ComponentType$1[]): Bits;
2899
- /**
2900
- * 获取实体的组件位掩码
2901
- * @param components 组件数组
2902
- * @returns Bits对象
2903
- */
2904
- getEntityBits(components: ComponentType$1[]): Bits;
2905
- /**
2906
- * 重置管理器(主要用于测试)
2907
- */
2908
- reset(): void;
2909
- /**
2910
- * 获取已注册的组件类型数量
2911
- */
2912
- get registeredTypeCount(): number;
2913
- }
2914
-
2915
2866
  /**
2916
2867
  * 稀疏集合实现
2917
2868
  *
@@ -3238,6 +3189,25 @@ interface Archetype {
3238
3189
  entities: Set<Entity>;
3239
3190
  }
3240
3191
 
3192
+ /**
3193
+ * 查询条件类型
3194
+ */
3195
+ declare enum QueryConditionType {
3196
+ /** 必须包含所有指定组件 */
3197
+ ALL = "all",
3198
+ /** 必须包含任意一个指定组件 */
3199
+ ANY = "any",
3200
+ /** 不能包含任何指定组件 */
3201
+ NONE = "none"
3202
+ }
3203
+ /**
3204
+ * 查询条件接口
3205
+ */
3206
+ interface QueryCondition {
3207
+ type: QueryConditionType;
3208
+ componentTypes: ComponentType[];
3209
+ mask: BitMask64Data;
3210
+ }
3241
3211
  /**
3242
3212
  * 实体查询结果接口
3243
3213
  */
@@ -3249,6 +3219,202 @@ interface QueryResult {
3249
3219
  /** 是否来自缓存 */
3250
3220
  fromCache: boolean;
3251
3221
  }
3222
+
3223
+ /**
3224
+ * 响应式查询变化类型
3225
+ */
3226
+ declare enum ReactiveQueryChangeType {
3227
+ /** 实体添加到查询结果 */
3228
+ ADDED = "added",
3229
+ /** 实体从查询结果移除 */
3230
+ REMOVED = "removed",
3231
+ /** 查询结果批量更新 */
3232
+ BATCH_UPDATE = "batch_update"
3233
+ }
3234
+ /**
3235
+ * 响应式查询变化事件
3236
+ */
3237
+ interface ReactiveQueryChange {
3238
+ /** 变化类型 */
3239
+ type: ReactiveQueryChangeType;
3240
+ /** 变化的实体 */
3241
+ entity?: Entity;
3242
+ /** 批量变化的实体 */
3243
+ entities?: readonly Entity[];
3244
+ /** 新增的实体列表(仅batch_update时有效) */
3245
+ added?: readonly Entity[];
3246
+ /** 移除的实体列表(仅batch_update时有效) */
3247
+ removed?: readonly Entity[];
3248
+ }
3249
+ /**
3250
+ * 响应式查询监听器
3251
+ */
3252
+ type ReactiveQueryListener = (change: ReactiveQueryChange) => void;
3253
+ /**
3254
+ * 响应式查询配置
3255
+ */
3256
+ interface ReactiveQueryConfig {
3257
+ /** 是否启用批量模式(减少通知频率) */
3258
+ enableBatchMode?: boolean;
3259
+ /** 批量模式的延迟时间(毫秒) */
3260
+ batchDelay?: number;
3261
+ /** 调试模式 */
3262
+ debug?: boolean;
3263
+ }
3264
+ /**
3265
+ * 响应式查询类
3266
+ *
3267
+ * 提供基于事件驱动的实体查询机制,只在实体/组件真正变化时触发通知。
3268
+ *
3269
+ * 核心特性:
3270
+ * - Event-driven: 基于事件的增量更新
3271
+ * - 精确通知: 只通知真正匹配的变化
3272
+ * - 性能优化: 避免每帧重复查询
3273
+ *
3274
+ * @example
3275
+ * ```typescript
3276
+ * // 创建响应式查询
3277
+ * const query = new ReactiveQuery(querySystem, {
3278
+ * type: QueryConditionType.ALL,
3279
+ * componentTypes: [Position, Velocity],
3280
+ * mask: createMask([Position, Velocity])
3281
+ * });
3282
+ *
3283
+ * // 订阅变化
3284
+ * query.subscribe((change) => {
3285
+ * if (change.type === ReactiveQueryChangeType.ADDED) {
3286
+ * console.log('新实体:', change.entity);
3287
+ * }
3288
+ * });
3289
+ *
3290
+ * // 获取当前结果
3291
+ * const entities = query.getEntities();
3292
+ * ```
3293
+ */
3294
+ declare class ReactiveQuery {
3295
+ /** 当前查询结果 */
3296
+ private _entities;
3297
+ /** 实体ID集合,用于快速查找 */
3298
+ private _entityIdSet;
3299
+ /** 查询条件 */
3300
+ private readonly _condition;
3301
+ /** 监听器列表 */
3302
+ private _listeners;
3303
+ /** 配置 */
3304
+ private readonly _config;
3305
+ /** 批量变化缓存 */
3306
+ private _batchChanges;
3307
+ /** 查询ID(用于调试) */
3308
+ private readonly _id;
3309
+ /** 是否已激活 */
3310
+ private _active;
3311
+ constructor(condition: QueryCondition, config?: ReactiveQueryConfig);
3312
+ /**
3313
+ * 生成查询ID
3314
+ */
3315
+ private generateQueryId;
3316
+ /**
3317
+ * 订阅查询变化
3318
+ *
3319
+ * @param listener 监听器函数
3320
+ * @returns 取消订阅的函数
3321
+ */
3322
+ subscribe(listener: ReactiveQueryListener): () => void;
3323
+ /**
3324
+ * 取消所有订阅
3325
+ */
3326
+ unsubscribeAll(): void;
3327
+ /**
3328
+ * 获取当前查询结果
3329
+ */
3330
+ getEntities(): readonly Entity[];
3331
+ /**
3332
+ * 获取查询结果数量
3333
+ */
3334
+ get count(): number;
3335
+ /**
3336
+ * 检查实体是否匹配查询条件
3337
+ *
3338
+ * @param entity 要检查的实体
3339
+ * @returns 是否匹配
3340
+ */
3341
+ matches(entity: Entity): boolean;
3342
+ /**
3343
+ * 通知实体添加
3344
+ *
3345
+ * 当Scene中添加实体时调用
3346
+ *
3347
+ * @param entity 添加的实体
3348
+ */
3349
+ notifyEntityAdded(entity: Entity): void;
3350
+ /**
3351
+ * 通知实体移除
3352
+ *
3353
+ * 当Scene中移除实体时调用
3354
+ *
3355
+ * @param entity 移除的实体
3356
+ */
3357
+ notifyEntityRemoved(entity: Entity): void;
3358
+ /**
3359
+ * 通知实体组件变化
3360
+ *
3361
+ * 当实体的组件发生变化时调用
3362
+ *
3363
+ * @param entity 变化的实体
3364
+ */
3365
+ notifyEntityChanged(entity: Entity): void;
3366
+ /**
3367
+ * 批量初始化查询结果
3368
+ *
3369
+ * @param entities 初始实体列表
3370
+ */
3371
+ initializeWith(entities: readonly Entity[]): void;
3372
+ /**
3373
+ * 添加到批量变化缓存
3374
+ */
3375
+ private addToBatch;
3376
+ /**
3377
+ * 刷新批量变化
3378
+ */
3379
+ private flushBatchChanges;
3380
+ /**
3381
+ * 通知所有监听器
3382
+ */
3383
+ private notifyListeners;
3384
+ /**
3385
+ * 暂停响应式查询
3386
+ *
3387
+ * 暂停后不再响应实体变化,但可以继续获取当前结果
3388
+ */
3389
+ pause(): void;
3390
+ /**
3391
+ * 恢复响应式查询
3392
+ */
3393
+ resume(): void;
3394
+ /**
3395
+ * 销毁响应式查询
3396
+ *
3397
+ * 释放所有资源,清空监听器和结果集
3398
+ */
3399
+ dispose(): void;
3400
+ /**
3401
+ * 获取查询条件
3402
+ */
3403
+ get condition(): QueryCondition;
3404
+ /**
3405
+ * 获取查询ID
3406
+ */
3407
+ get id(): string;
3408
+ /**
3409
+ * 检查是否激活
3410
+ */
3411
+ get active(): boolean;
3412
+ /**
3413
+ * 获取监听器数量
3414
+ */
3415
+ get listenerCount(): number;
3416
+ }
3417
+
3252
3418
  /**
3253
3419
  * 高性能实体查询系统
3254
3420
  *
@@ -3353,7 +3519,7 @@ declare class QuerySystem {
3353
3519
  * 查询包含所有指定组件的实体
3354
3520
  *
3355
3521
  * 返回同时包含所有指定组件类型的实体列表。
3356
- * 系统会自动选择最高效的查询策略,包括索引查找和缓存机制。
3522
+ * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
3357
3523
  *
3358
3524
  * @param componentTypes 要查询的组件类型列表
3359
3525
  * @returns 查询结果,包含匹配的实体和性能信息
@@ -3380,7 +3546,7 @@ declare class QuerySystem {
3380
3546
  * 查询包含任意指定组件的实体
3381
3547
  *
3382
3548
  * 返回包含任意一个指定组件类型的实体列表。
3383
- * 使用集合合并算法确保高效的查询性能。
3549
+ * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
3384
3550
  *
3385
3551
  * @param componentTypes 要查询的组件类型列表
3386
3552
  * @returns 查询结果,包含匹配的实体和性能信息
@@ -3397,7 +3563,7 @@ declare class QuerySystem {
3397
3563
  * 查询不包含任何指定组件的实体
3398
3564
  *
3399
3565
  * 返回不包含任何指定组件类型的实体列表。
3400
- * 适用于排除特定类型实体的查询场景。
3566
+ * 内部使用响应式查询作为智能缓存,自动跟踪实体变化,性能更优。
3401
3567
  *
3402
3568
  * @param componentTypes 要排除的组件类型列表
3403
3569
  * @returns 查询结果,包含匹配的实体和性能信息
@@ -3474,6 +3640,13 @@ declare class QuerySystem {
3474
3640
  * 清除所有查询缓存
3475
3641
  */
3476
3642
  private clearQueryCache;
3643
+ /**
3644
+ * 清除所有响应式查询
3645
+ *
3646
+ * 销毁所有响应式查询实例并清理索引
3647
+ * 通常在setEntities时调用以确保缓存一致性
3648
+ */
3649
+ private clearReactiveQueries;
3477
3650
  /**
3478
3651
  * 高效的缓存键生成
3479
3652
  */
@@ -3482,13 +3655,56 @@ declare class QuerySystem {
3482
3655
  * 清理查询缓存
3483
3656
  *
3484
3657
  * 用于外部调用清理缓存,通常在批量操作后使用。
3658
+ * 注意:此方法也会清理响应式查询缓存
3485
3659
  */
3486
3660
  clearCache(): void;
3661
+ /**
3662
+ * 创建响应式查询
3663
+ *
3664
+ * 响应式查询会自动跟踪实体/组件的变化,并通过事件通知订阅者。
3665
+ * 适合需要实时响应实体变化的场景(如UI更新、AI系统等)。
3666
+ *
3667
+ * @param componentTypes 查询的组件类型列表
3668
+ * @param config 可选的查询配置
3669
+ * @returns 响应式查询实例
3670
+ *
3671
+ * @example
3672
+ * ```typescript
3673
+ * const query = querySystem.createReactiveQuery([Position, Velocity], {
3674
+ * enableBatchMode: true,
3675
+ * batchDelay: 16
3676
+ * });
3677
+ *
3678
+ * query.subscribe((change) => {
3679
+ * if (change.type === ReactiveQueryChangeType.ADDED) {
3680
+ * console.log('新实体:', change.entity);
3681
+ * }
3682
+ * });
3683
+ * ```
3684
+ */
3685
+ createReactiveQuery(componentTypes: ComponentType[], config?: ReactiveQueryConfig): ReactiveQuery;
3686
+ /**
3687
+ * 销毁响应式查询
3688
+ *
3689
+ * 清理查询占用的资源,包括监听器和实体引用。
3690
+ * 销毁后的查询不应再被使用。
3691
+ *
3692
+ * @param query 要销毁的响应式查询
3693
+ *
3694
+ * @example
3695
+ * ```typescript
3696
+ * const query = querySystem.createReactiveQuery([Position, Velocity]);
3697
+ * // ... 使用查询
3698
+ * querySystem.destroyReactiveQuery(query);
3699
+ * ```
3700
+ */
3701
+ destroyReactiveQuery(query: ReactiveQuery): void;
3487
3702
  /**
3488
3703
  * 创建组件掩码
3489
3704
  *
3490
3705
  * 根据组件类型列表生成对应的位掩码。
3491
3706
  * 使用缓存避免重复计算。
3707
+ * 注意:必须使用ComponentRegistry来确保与Entity.componentMask使用相同的bitIndex
3492
3708
  *
3493
3709
  * @param componentTypes 组件类型列表
3494
3710
  * @returns 生成的位掩码
@@ -3540,6 +3756,67 @@ declare class QuerySystem {
3540
3756
  * @param entity 要查询的实体
3541
3757
  */
3542
3758
  getEntityArchetype(entity: Entity): Archetype | undefined;
3759
+ /**
3760
+ * 响应式查询集合(内部使用,作为智能缓存)
3761
+ * 传统查询API(queryAll/queryAny/queryNone)内部自动使用响应式查询优化性能
3762
+ */
3763
+ private _reactiveQueries;
3764
+ /**
3765
+ * 按组件类型索引的响应式查询
3766
+ * 用于快速定位哪些查询关心某个组件类型
3767
+ */
3768
+ private _reactiveQueriesByComponent;
3769
+ /**
3770
+ * 获取或创建内部响应式查询(作为智能缓存)
3771
+ *
3772
+ * @param queryType 查询类型
3773
+ * @param componentTypes 组件类型列表
3774
+ * @returns 响应式查询实例
3775
+ */
3776
+ private getOrCreateReactiveQuery;
3777
+ /**
3778
+ * 执行传统查询(内部使用,用于响应式查询初始化)
3779
+ *
3780
+ * @param queryType 查询类型
3781
+ * @param componentTypes 组件类型列表
3782
+ * @returns 匹配的实体列表
3783
+ */
3784
+ private executeTraditionalQuery;
3785
+ /**
3786
+ * 通知所有响应式查询实体已添加
3787
+ *
3788
+ * 使用组件类型索引,只通知关心该实体组件的查询
3789
+ *
3790
+ * @param entity 添加的实体
3791
+ */
3792
+ private notifyReactiveQueriesEntityAdded;
3793
+ /**
3794
+ * 通知响应式查询实体已移除
3795
+ *
3796
+ * 使用组件类型索引,只通知关心该实体组件的查询
3797
+ *
3798
+ * @param entity 移除的实体
3799
+ * @param componentTypes 实体移除前的组件类型列表
3800
+ */
3801
+ private notifyReactiveQueriesEntityRemoved;
3802
+ /**
3803
+ * 通知响应式查询实体已移除(后备方案)
3804
+ *
3805
+ * 当实体已经清空组件时使用,通知所有查询
3806
+ *
3807
+ * @param entity 移除的实体
3808
+ */
3809
+ private notifyReactiveQueriesEntityRemovedFallback;
3810
+ /**
3811
+ * 通知响应式查询实体已变化
3812
+ *
3813
+ * 使用混合策略:
3814
+ * 1. 首先通知关心实体当前组件的查询
3815
+ * 2. 然后通知所有其他查询(包括那些可能因为组件移除而不再匹配的查询)
3816
+ *
3817
+ * @param entity 变化的实体
3818
+ */
3819
+ private notifyReactiveQueriesEntityChanged;
3543
3820
  }
3544
3821
  /**
3545
3822
  * 查询构建器
@@ -4100,7 +4377,7 @@ declare class TypedQueryBuilder<TAll extends readonly ComponentConstructor[] = [
4100
4377
  *
4101
4378
  * @returns 查询条件对象
4102
4379
  */
4103
- getCondition(): QueryCondition;
4380
+ getCondition(): QueryCondition$1;
4104
4381
  /**
4105
4382
  * 获取required组件类型(用于类型推断)
4106
4383
  */
@@ -4477,6 +4754,18 @@ declare class SceneSerializer {
4477
4754
  * @param options 反序列化选项
4478
4755
  */
4479
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;
4480
4769
  /**
4481
4770
  * 序列化场景自定义数据
4482
4771
  *
@@ -5082,7 +5371,7 @@ declare class Scene implements IScene {
5082
5371
  * @Injectable()
5083
5372
  * class PhysicsSystem extends EntitySystem {
5084
5373
  * constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
5085
- * super(Matcher.of(Transform));
5374
+ * super(Matcher.empty().all(Transform));
5086
5375
  * }
5087
5376
  * }
5088
5377
  * scene.addEntityProcessor(PhysicsSystem);
@@ -5107,7 +5396,7 @@ declare class Scene implements IScene {
5107
5396
  * @Injectable()
5108
5397
  * @ECSSystem('Collision', { updateOrder: 5 })
5109
5398
  * class CollisionSystem extends EntitySystem implements IService {
5110
- * constructor() { super(Matcher.of(Collider)); }
5399
+ * constructor() { super(Matcher.empty().all(Collider)); }
5111
5400
  * dispose() {}
5112
5401
  * }
5113
5402
  *
@@ -5115,7 +5404,7 @@ declare class Scene implements IScene {
5115
5404
  * @ECSSystem('Physics', { updateOrder: 10 })
5116
5405
  * class PhysicsSystem extends EntitySystem implements IService {
5117
5406
  * constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
5118
- * super(Matcher.of(Transform, RigidBody));
5407
+ * super(Matcher.empty().all(Transform, RigidBody));
5119
5408
  * }
5120
5409
  * dispose() {}
5121
5410
  * }
@@ -5358,7 +5647,7 @@ declare class Scene implements IScene {
5358
5647
  * // 传统方式
5359
5648
  * class MovementSystem extends EntitySystem {
5360
5649
  * constructor() {
5361
- * super(Matcher.of(Transform, Velocity));
5650
+ * super(Matcher.empty().all(Transform, Velocity));
5362
5651
  * }
5363
5652
  *
5364
5653
  * protected process(entities: readonly Entity[]): void {
@@ -5373,7 +5662,7 @@ declare class Scene implements IScene {
5373
5662
  * // 类型安全方式
5374
5663
  * class MovementSystem extends EntitySystem<[typeof Transform, typeof Velocity]> {
5375
5664
  * constructor() {
5376
- * super(Matcher.of(Transform, Velocity));
5665
+ * super(Matcher.empty().all(Transform, Velocity));
5377
5666
  * }
5378
5667
  *
5379
5668
  * protected process(entities: readonly Entity[]): void {
@@ -6974,7 +7263,7 @@ interface SystemMetadata {
6974
7263
  * @ECSSystem('Physics', { updateOrder: 10 })
6975
7264
  * class PhysicsSystem extends EntitySystem {
6976
7265
  * constructor(@Inject(CollisionSystem) private collision: CollisionSystem) {
6977
- * super(Matcher.of(Transform, RigidBody));
7266
+ * super(Matcher.empty().all(Transform, RigidBody));
6978
7267
  * }
6979
7268
  * }
6980
7269
  * ```
@@ -9039,14 +9328,26 @@ declare class WebSocketManager {
9039
9328
  private handleConnectionFailure;
9040
9329
  }
9041
9330
 
9331
+ /**
9332
+ * 调试配置服务
9333
+ *
9334
+ * 管理调试系统的配置信息
9335
+ */
9336
+ declare class DebugConfigService implements IService {
9337
+ private _config;
9338
+ constructor();
9339
+ setConfig(config: IECSDebugConfig): void;
9340
+ getConfig(): IECSDebugConfig;
9341
+ isEnabled(): boolean;
9342
+ dispose(): void;
9343
+ }
9344
+
9042
9345
  /**
9043
9346
  * 调试管理器
9044
9347
  *
9045
9348
  * 整合所有调试数据收集器,负责收集和发送调试数据
9046
- *
9047
- * 通过构造函数接收SceneManager和PerformanceMonitor,避免直接依赖Core实例
9048
9349
  */
9049
- declare class DebugManager implements IService {
9350
+ declare class DebugManager implements IService, IUpdatable {
9050
9351
  private config;
9051
9352
  private webSocketManager;
9052
9353
  private entityCollector;
@@ -9060,13 +9361,8 @@ declare class DebugManager implements IService {
9060
9361
  private lastSendTime;
9061
9362
  private sendInterval;
9062
9363
  private isRunning;
9063
- /**
9064
- * 构造调试管理器
9065
- * @param sceneManager 场景管理器
9066
- * @param performanceMonitor 性能监控器
9067
- * @param config 调试配置
9068
- */
9069
- constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, config: IECSDebugConfig);
9364
+ private originalConsole;
9365
+ constructor(sceneManager: SceneManager, performanceMonitor: PerformanceMonitor, configService: DebugConfigService);
9070
9366
  /**
9071
9367
  * 启动调试管理器
9072
9368
  */
@@ -9076,13 +9372,26 @@ declare class DebugManager implements IService {
9076
9372
  */
9077
9373
  stop(): void;
9078
9374
  /**
9079
- * 更新配置
9375
+ * 拦截 console 日志并转发到编辑器
9080
9376
  */
9081
- updateConfig(config: IECSDebugConfig): void;
9377
+ private interceptConsole;
9082
9378
  /**
9083
- * 帧更新回调
9379
+ * 格式化日志消息
9084
9380
  */
9085
- onFrameUpdate(deltaTime: number): void;
9381
+ private formatLogMessage;
9382
+ /**
9383
+ * 安全的 JSON 序列化,支持循环引用和深度限制
9384
+ */
9385
+ private safeStringify;
9386
+ /**
9387
+ * 发送日志到编辑器
9388
+ */
9389
+ private sendLog;
9390
+ /**
9391
+ * 更新配置
9392
+ */
9393
+ updateConfig(config: IECSDebugConfig): void;
9394
+ update(deltaTime?: number): void;
9086
9395
  /**
9087
9396
  * 场景变更回调
9088
9397
  */
@@ -9767,6 +10076,156 @@ declare class PluginManager implements IService {
9767
10076
  dispose(): void;
9768
10077
  }
9769
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
+
9770
10229
  /**
9771
10230
  * 依赖注入装饰器
9772
10231
  *
@@ -9785,6 +10244,11 @@ interface InjectableMetadata {
9785
10244
  * 依赖列表
9786
10245
  */
9787
10246
  dependencies: Array<ServiceType<any> | string | symbol>;
10247
+ /**
10248
+ * 属性注入映射
10249
+ * key: 属性名, value: 服务类型
10250
+ */
10251
+ properties?: Map<string | symbol, ServiceType<any>>;
9788
10252
  }
9789
10253
  /**
9790
10254
  * 可更新元数据接口
@@ -9858,20 +10322,7 @@ declare function Updatable(priority?: number): ClassDecorator;
9858
10322
  *
9859
10323
  * 标记构造函数参数需要注入的服务类型
9860
10324
  *
9861
- * @param serviceType 服务类型标识符(类、字符串或Symbol)
9862
- *
9863
- * @example
9864
- * ```typescript
9865
- * @Injectable()
9866
- * class MySystem extends EntitySystem {
9867
- * constructor(
9868
- * @Inject(TimeService) private timeService: TimeService,
9869
- * @Inject(PhysicsService) private physics: PhysicsService
9870
- * ) {
9871
- * super();
9872
- * }
9873
- * }
9874
- * ```
10325
+ * @param serviceType 服务类型标识符
9875
10326
  */
9876
10327
  declare function Inject(serviceType: ServiceType<any> | string | symbol): ParameterDecorator;
9877
10328
  /**
@@ -10552,5 +11003,5 @@ declare function getFullPlatformConfig(): Promise<any>;
10552
11003
  declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
10553
11004
  declare function hasAdapter(): boolean;
10554
11005
 
10555
- export { AutoTyped, BitMask64Utils, Bits, COMPONENT_TYPE_NAME, ChangeOperation, Colors, Component, ComponentDataCollector, ComponentPool, ComponentPoolManager, ComponentRegistry, ComponentSerializer, ComponentSparseSet, ComponentStorage, ComponentTypeManager, ConsoleLogger, Core, 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, 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 };
10556
- 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, 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 };