@esengine/ecs-framework 2.2.7 → 2.2.9

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.7
2
+ * @esengine/ecs-framework v2.2.9
3
3
  * TypeScript definitions
4
4
  */
5
5
  /**
@@ -1097,27 +1097,6 @@ declare enum LogLevel {
1097
1097
  Fatal = 4,
1098
1098
  None = 5
1099
1099
  }
1100
- /**
1101
- * 日志接口
1102
- */
1103
- interface ILogger {
1104
- debug(message: string, ...args: unknown[]): void;
1105
- info(message: string, ...args: unknown[]): void;
1106
- warn(message: string, ...args: unknown[]): void;
1107
- error(message: string, ...args: unknown[]): void;
1108
- fatal(message: string, ...args: unknown[]): void;
1109
- }
1110
- /**
1111
- * 日志颜色配置接口
1112
- */
1113
- interface LoggerColorConfig {
1114
- debug?: string;
1115
- info?: string;
1116
- warn?: string;
1117
- error?: string;
1118
- fatal?: string;
1119
- reset?: string;
1120
- }
1121
1100
  /**
1122
1101
  * 预定义的颜色常量
1123
1102
  */
@@ -1142,6 +1121,28 @@ declare const Colors: {
1142
1121
  readonly BOLD: "\u001B[1m";
1143
1122
  readonly UNDERLINE: "\u001B[4m";
1144
1123
  };
1124
+
1125
+ /**
1126
+ * 日志接口
1127
+ */
1128
+ interface ILogger {
1129
+ debug(...args: unknown[]): void;
1130
+ info(...args: unknown[]): void;
1131
+ warn(...args: unknown[]): void;
1132
+ error(...args: unknown[]): void;
1133
+ fatal(...args: unknown[]): void;
1134
+ }
1135
+ /**
1136
+ * 日志颜色配置接口
1137
+ */
1138
+ interface LoggerColorConfig {
1139
+ debug?: string;
1140
+ info?: string;
1141
+ warn?: string;
1142
+ error?: string;
1143
+ fatal?: string;
1144
+ reset?: string;
1145
+ }
1145
1146
  /**
1146
1147
  * 日志配置
1147
1148
  */
@@ -1159,6 +1160,7 @@ interface LoggerConfig {
1159
1160
  /** 自定义颜色配置 */
1160
1161
  colors?: LoggerColorConfig;
1161
1162
  }
1163
+
1162
1164
  /**
1163
1165
  * 默认控制台日志实现
1164
1166
  */
@@ -1230,15 +1232,19 @@ declare class ConsoleLogger implements ILogger {
1230
1232
  */
1231
1233
  private getColors;
1232
1234
  }
1235
+
1233
1236
  /**
1234
1237
  * 日志管理器
1235
1238
  */
1236
1239
  declare class LoggerManager {
1237
1240
  private static _instance;
1238
1241
  private _loggers;
1239
- private _defaultLogger;
1242
+ private _defaultLogger?;
1240
1243
  private _defaultLevel;
1244
+ private _loggerFactory?;
1241
1245
  private constructor();
1246
+ private get defaultLogger();
1247
+ private createDefaultLogger;
1242
1248
  /**
1243
1249
  * 获取日志管理器实例
1244
1250
  * @returns 日志管理器实例
@@ -1277,6 +1283,11 @@ declare class LoggerManager {
1277
1283
  * 重置为默认颜色配置
1278
1284
  */
1279
1285
  resetColors(): void;
1286
+ /**
1287
+ * 设置日志器工厂方法
1288
+ * @param factory 日志器工厂方法
1289
+ */
1290
+ setLoggerFactory(factory: (name?: string) => ILogger): void;
1280
1291
  }
1281
1292
  /**
1282
1293
  * 默认日志器实例
@@ -1302,6 +1313,11 @@ declare function resetLoggerColors(): void;
1302
1313
  * @param level 日志级别
1303
1314
  */
1304
1315
  declare function setGlobalLogLevel(level: LogLevel): void;
1316
+ /**
1317
+ * 设置日志器工厂方法
1318
+ * @param factory 日志器工厂方法
1319
+ */
1320
+ declare function setLoggerFactory(factory: (name?: string) => ILogger): void;
1305
1321
 
1306
1322
  /**
1307
1323
  * 组件类型定义
@@ -5946,7 +5962,7 @@ declare abstract class EntitySystem<TComponents extends readonly ComponentConstr
5946
5962
  destroy(): void;
5947
5963
  /**
5948
5964
  * 获取Logger名称
5949
- * 子类可以重写此方法来自定义logger名称
5965
+ * 默认返回类的构造函数名称, 子类可以重写此方法来自定义logger名称
5950
5966
  */
5951
5967
  protected getLoggerName(): string;
5952
5968
  /**
@@ -6240,6 +6256,121 @@ interface IScene {
6240
6256
  * 获取实体处理器
6241
6257
  */
6242
6258
  getEntityProcessor<T extends EntitySystem>(type: new (...args: any[]) => T): T | null;
6259
+ /**
6260
+ * 根据ID查找实体
6261
+ */
6262
+ findEntityById(id: number): Entity | null;
6263
+ /**
6264
+ * 根据名称查找实体
6265
+ */
6266
+ getEntityByName(name: string): Entity | null;
6267
+ /**
6268
+ * 根据标签查找实体
6269
+ */
6270
+ getEntitiesByTag(tag: number): Entity[];
6271
+ /**
6272
+ * 批量销毁实体
6273
+ */
6274
+ destroyEntities(entities: Entity[]): void;
6275
+ /**
6276
+ * 查询拥有所有指定组件的实体
6277
+ */
6278
+ queryAll(...componentTypes: any[]): {
6279
+ entities: readonly Entity[];
6280
+ };
6281
+ /**
6282
+ * 查询拥有任意一个指定组件的实体
6283
+ */
6284
+ queryAny(...componentTypes: any[]): {
6285
+ entities: readonly Entity[];
6286
+ };
6287
+ /**
6288
+ * 查询不包含指定组件的实体
6289
+ */
6290
+ queryNone(...componentTypes: any[]): {
6291
+ entities: readonly Entity[];
6292
+ };
6293
+ /**
6294
+ * 创建类型安全的查询构建器
6295
+ */
6296
+ query(): TypedQueryBuilder;
6297
+ /**
6298
+ * 通过类型获取System实例
6299
+ */
6300
+ getSystem<T extends EntitySystem>(systemType: ServiceType<T>): T | null;
6301
+ /**
6302
+ * 批量注册EntitySystem到场景
6303
+ */
6304
+ registerSystems(systemTypes: Array<ServiceType<EntitySystem>>): EntitySystem[];
6305
+ /**
6306
+ * 添加系统到场景
6307
+ */
6308
+ addSystem(system: EntitySystem): EntitySystem;
6309
+ /**
6310
+ * 从场景中删除系统
6311
+ */
6312
+ removeSystem(system: EntitySystem): void;
6313
+ /**
6314
+ * 获取场景统计信息
6315
+ */
6316
+ getStats(): {
6317
+ entityCount: number;
6318
+ processorCount: number;
6319
+ componentStorageStats: Map<string, any>;
6320
+ };
6321
+ /**
6322
+ * 获取场景的调试信息
6323
+ */
6324
+ getDebugInfo(): {
6325
+ name: string;
6326
+ entityCount: number;
6327
+ processorCount: number;
6328
+ isRunning: boolean;
6329
+ entities: Array<{
6330
+ name: string;
6331
+ id: number;
6332
+ componentCount: number;
6333
+ componentTypes: string[];
6334
+ }>;
6335
+ processors: Array<{
6336
+ name: string;
6337
+ updateOrder: number;
6338
+ entityCount: number;
6339
+ }>;
6340
+ componentStats: Map<string, any>;
6341
+ };
6342
+ /**
6343
+ * 序列化场景
6344
+ */
6345
+ serialize(options?: SceneSerializationOptions): string | Uint8Array;
6346
+ /**
6347
+ * 反序列化场景
6348
+ */
6349
+ deserialize(saveData: string | Uint8Array, options?: SceneDeserializationOptions): void;
6350
+ /**
6351
+ * 创建增量序列化的基础快照
6352
+ */
6353
+ createIncrementalSnapshot(options?: IncrementalSerializationOptions): void;
6354
+ /**
6355
+ * 增量序列化场景
6356
+ */
6357
+ serializeIncremental(options?: IncrementalSerializationOptions): IncrementalSnapshot;
6358
+ /**
6359
+ * 应用增量变更到场景
6360
+ */
6361
+ applyIncremental(incremental: IncrementalSnapshot | string | Uint8Array, componentRegistry?: Map<string, any>): void;
6362
+ /**
6363
+ * 更新增量快照基准
6364
+ */
6365
+ updateIncrementalSnapshot(options?: IncrementalSerializationOptions): void;
6366
+ /**
6367
+ * 清除增量快照
6368
+ */
6369
+ clearIncrementalSnapshot(): void;
6370
+ /**
6371
+ * 检查是否有增量快照
6372
+ */
6373
+ hasIncrementalSnapshot(): boolean;
6243
6374
  }
6244
6375
  /**
6245
6376
  * 场景工厂接口
@@ -6592,6 +6723,25 @@ declare class Entity {
6592
6723
  * @returns 组件实例数组
6593
6724
  */
6594
6725
  getComponents<T extends Component>(type: ComponentType<T>): T[];
6726
+ /**
6727
+ * 获取指定基类的组件(支持继承查找)
6728
+ *
6729
+ * 与 getComponent() 不同,此方法使用 instanceof 检查,支持子类查找。
6730
+ * 性能比位掩码查询稍慢,但支持继承层次结构。
6731
+ *
6732
+ * @param baseType - 组件基类类型
6733
+ * @returns 第一个匹配的组件实例,如果不存在则返回 null
6734
+ *
6735
+ * @example
6736
+ * ```typescript
6737
+ * // 查找 CompositeNodeComponent 或其子类
6738
+ * const composite = entity.getComponentByType(CompositeNodeComponent);
6739
+ * if (composite) {
6740
+ * // composite 可能是 SequenceNode, SelectorNode 等
6741
+ * }
6742
+ * ```
6743
+ */
6744
+ getComponentByType<T extends Component>(baseType: ComponentType<T>): T | null;
6595
6745
  /**
6596
6746
  * 添加子实体
6597
6747
  *
@@ -11014,5 +11164,5 @@ declare function getFullPlatformConfig(): Promise<any>;
11014
11164
  declare function supportsFeature(feature: 'worker' | 'shared-array-buffer' | 'transferable-objects' | 'module-worker'): boolean;
11015
11165
  declare function hasAdapter(): boolean;
11016
11166
 
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 };
11167
+ 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, setLoggerFactory, supportsFeature, tryGetComponent, updateComponent };
11018
11168
  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 };