fix(core): Cocos Creator 兼容性 - 类型导出修复

- 将 export interface 转换为 export type 以兼容 Rollup
- 分离类型导入/导出使用 import type 和 export type
- 修复 QueryCondition, QueryResult, SupportedTypedArray 等类型的重导出
This commit is contained in:
yhh
2025-12-22 14:54:38 +08:00
parent 66d9f428b3
commit 2381919a5c
53 changed files with 154 additions and 145 deletions

View File

@@ -18,7 +18,7 @@ const updatableMetadata = new WeakMap<Constructor, UpdatableMetadata>();
/**
* 可注入元数据接口
*/
export interface InjectableMetadata {
export type InjectableMetadata = {
/**
* 是否可注入
*/
@@ -39,7 +39,7 @@ export interface InjectableMetadata {
/**
* 可更新元数据接口
*/
export interface UpdatableMetadata {
export type UpdatableMetadata = {
/**
* 是否可更新
*/

View File

@@ -51,7 +51,7 @@ export enum PluginState {
* }
* ```
*/
export interface IPlugin {
export type IPlugin = {
/**
* 插件唯一名称
*
@@ -96,7 +96,7 @@ export interface IPlugin {
/**
* 插件元数据
*/
export interface IPluginMetadata {
export type IPluginMetadata = {
/**
* 插件名称
*/

View File

@@ -28,7 +28,7 @@
* Note: __phantom is a required property to ensure TypeScript preserves generic
* type information across packages.
*/
export interface ServiceToken<T> {
export type ServiceToken<T> = {
readonly id: symbol;
readonly name: string;
/**

View File

@@ -39,7 +39,7 @@ import { createServiceToken } from './PluginServiceRegistry';
* 运行时模式接口
* Runtime mode interface
*/
export interface IRuntimeMode {
export type IRuntimeMode = {
/**
* 是否为编辑器模式
* Whether in editor mode
@@ -110,7 +110,7 @@ type ModeChangeCallback = (mode: IRuntimeMode) => void;
* 运行时模式服务配置
* Runtime mode service configuration
*/
export interface RuntimeModeConfig {
export type RuntimeModeConfig = {
/** 是否为编辑器模式 | Whether in editor mode */
isEditor?: boolean;
/** 是否正在播放 | Whether playing */

View File

@@ -7,7 +7,7 @@ const logger = createLogger('ServiceContainer');
* 服务基础接口
* 所有通过 ServiceContainer 管理的服务都应该实现此接口
*/
export interface IService {
export type IService = {
/**
* 释放服务占用的资源
* 当服务被注销或容器被清空时调用

View File

@@ -11,7 +11,7 @@ export type ArchetypeId = BitMask64Data;
/**
* 原型数据结构
*/
export interface Archetype {
export type Archetype = {
/** 原型唯一标识符 */
id: ArchetypeId;
/** 包含的组件类型 */
@@ -23,7 +23,7 @@ export interface Archetype {
/**
* 原型查询结果
*/
export interface ArchetypeQueryResult {
export type ArchetypeQueryResult = {
/** 匹配的原型列表 */
archetypes: Archetype[];
/** 所有匹配实体的总数 */

View File

@@ -25,7 +25,7 @@ export enum CommandType {
* 延迟命令接口
* Deferred command interface
*/
export interface DeferredCommand {
export type DeferredCommand = {
/** 命令类型 | Command type */
type: CommandType;
/** 目标实体 | Target entity */

View File

@@ -1,6 +1,7 @@
import { Component } from '../Component';
import { BitMask64Utils, BitMask64Data } from '../Utils/BigIntCompatibility';
import { SoAStorage, SupportedTypedArray } from './SoAStorage';
import { SoAStorage } from './SoAStorage';
import type { SupportedTypedArray } from './SoAStorage';
import { createLogger } from '../../Utils/Logger';
import { getComponentTypeName, ComponentType } from '../Decorators';
import { ComponentRegistry, GlobalComponentRegistry } from './ComponentStorage/ComponentRegistry';

View File

@@ -43,7 +43,7 @@ export const COMPONENT_EDITOR_OPTIONS = Symbol('ComponentEditorOptions');
* 组件编辑器选项
* Component editor options
*/
export interface ComponentEditorOptions {
export type ComponentEditorOptions = {
/**
* 是否在 Inspector 中隐藏此组件
* Whether to hide this component in Inspector
@@ -72,7 +72,7 @@ export interface ComponentEditorOptions {
* 使用 Symbol 索引签名来类型安全地访问装饰器存储的元数据
* Uses Symbol index signature to safely access decorator-stored metadata
*/
export interface ComponentTypeMetadata {
export type ComponentTypeMetadata = {
readonly [COMPONENT_TYPE_NAME]?: string;
readonly [COMPONENT_DEPENDENCIES]?: string[];
readonly [COMPONENT_EDITOR_OPTIONS]?: ComponentEditorOptions;
@@ -82,7 +82,7 @@ export interface ComponentTypeMetadata {
* 可写的组件类型元数据(用于装饰器设置)
* Writable component type metadata (for decorator setting)
*/
export interface WritableComponentTypeMetadata {
export type WritableComponentTypeMetadata = {
[COMPONENT_TYPE_NAME]?: string;
[COMPONENT_DEPENDENCIES]?: string[];
[COMPONENT_EDITOR_OPTIONS]?: ComponentEditorOptions;

View File

@@ -16,7 +16,7 @@ import type { ComponentType } from './ComponentTypeUtils';
* Component Registry Interface.
* 组件注册表接口。
*/
export interface IComponentRegistry {
export type IComponentRegistry = {
/**
* Register component type and allocate bitmask.
* 注册组件类型并分配位掩码。

View File

@@ -13,7 +13,7 @@ export type AsyncEventHandler<T> = (event: T) => Promise<void>;
/**
* 事件监听器配置
*/
export interface EventListenerConfig {
export type EventListenerConfig = {
/** 是否只执行一次 */
once?: boolean;
/** 优先级(数字越大优先级越高) */
@@ -41,7 +41,7 @@ interface InternalEventListener {
/**
* 事件统计信息
*/
export interface EventStats {
export type EventStats = {
/** 事件类型 */
eventType: string;
/** 监听器数量 */
@@ -59,7 +59,7 @@ export interface EventStats {
/**
* 事件批处理配置
*/
export interface EventBatchConfig {
export type EventBatchConfig = {
/** 批处理大小 */
batchSize: number;
/** 批处理延迟(毫秒) */

View File

@@ -1,2 +1,3 @@
export { EventBus, GlobalEventBus } from '../EventBus';
export { TypeSafeEventSystem, EventListenerConfig, EventStats } from '../EventSystem';
export { TypeSafeEventSystem } from '../EventSystem';
export type { EventListenerConfig, EventStats } from '../EventSystem';

View File

@@ -6,10 +6,12 @@ import { createLogger } from '../../Utils/Logger';
import { getComponentTypeName } from '../Decorators';
import { Archetype, ArchetypeSystem } from './ArchetypeSystem';
import { ReactiveQuery, ReactiveQueryConfig } from './ReactiveQuery';
import { QueryCondition, QueryConditionType, QueryResult } from './QueryTypes';
import type { QueryCondition, QueryResult } from './QueryTypes';
import { QueryConditionType } from './QueryTypes';
import { CompiledQuery } from './Query/CompiledQuery';
export { QueryCondition, QueryConditionType, QueryResult };
export { QueryConditionType };
export type { QueryCondition, QueryResult };
export { CompiledQuery };
/**

View File

@@ -17,7 +17,7 @@ export enum QueryConditionType {
/**
* 查询条件接口
*/
export interface QueryCondition {
export type QueryCondition = {
type: QueryConditionType;
componentTypes: ComponentType[];
mask: BitMask64Data;
@@ -26,7 +26,7 @@ export interface QueryCondition {
/**
* 实体查询结果接口
*/
export interface QueryResult {
export type QueryResult = {
entities: readonly Entity[];
count: number;
/** 查询执行时间(毫秒) */

View File

@@ -1,5 +1,6 @@
import { Entity } from '../Entity';
import { QueryCondition, QueryConditionType } from './QueryTypes';
import type { QueryCondition } from './QueryTypes';
import { QueryConditionType } from './QueryTypes';
import { BitMask64Utils } from '../Utils/BigIntCompatibility';
import { createLogger } from '../../Utils/Logger';
@@ -20,7 +21,7 @@ export enum ReactiveQueryChangeType {
/**
* 响应式查询变化事件
*/
export interface ReactiveQueryChange {
export type ReactiveQueryChange = {
/** 变化类型 */
type: ReactiveQueryChangeType;
/** 变化的实体 */
@@ -41,7 +42,7 @@ export type ReactiveQueryListener = (change: ReactiveQueryChange) => void;
/**
* 响应式查询配置
*/
export interface ReactiveQueryConfig {
export type ReactiveQueryConfig = {
/** 是否启用批量模式(减少通知频率) */
enableBatchMode?: boolean;
/** 批量模式的延迟时间(毫秒) */

View File

@@ -54,7 +54,7 @@ const WeakRefImpl: IWeakRefConstructor = (
/**
* Entity引用记录
*/
export interface EntityRefRecord {
export type EntityRefRecord = {
component: IWeakRef<Component>;
propertyKey: string;
}

View File

@@ -8,7 +8,7 @@ import {
import { SoASerializer } from './SoASerializer';
// 重新导出类型,保持向后兼容
export { SupportedTypedArray, TypedArrayTypeName } from './SoATypeRegistry';
export type { SupportedTypedArray, TypedArrayTypeName } from './SoATypeRegistry';
export { SoATypeRegistry } from './SoATypeRegistry';
export { SoASerializer } from './SoASerializer';

View File

@@ -40,7 +40,7 @@ export type TypedArrayTypeName =
/**
* 字段元数据
*/
export interface FieldMetadata {
export type FieldMetadata = {
name: string;
type: 'number' | 'boolean' | 'string' | 'object';
arrayType?: TypedArrayTypeName;

View File

@@ -1,4 +1,5 @@
export { ComponentPool, ComponentPoolManager } from '../ComponentPool';
export { ComponentPoolManager } from '../ComponentPool';
export type { ComponentPool } from '../ComponentPool';
export { ComponentStorage, ComponentRegistry, GlobalComponentRegistry } from '../ComponentStorage';
export type { IComponentRegistry } from '../ComponentStorage';
export { EnableSoA, Float64, Float32, Int32, SerializeMap, SoAStorage } from '../SoAStorage';

View File

@@ -17,12 +17,8 @@
* ```
*/
// 从SoAStorage导入所有装饰器和类型
export {
// 启用装饰器
EnableSoA,
// 数值类型装饰器
Float64,
Float32,
Int32,
@@ -32,13 +28,10 @@ export {
Int8,
Uint8,
Uint8Clamped,
// 序列化装饰器
SerializeMap,
SerializeSet,
SerializeArray,
DeepCopy,
// 类型定义
SupportedTypedArray
DeepCopy
} from './SoAStorage';
export type { SupportedTypedArray } from './SoAStorage';

View File

@@ -48,7 +48,7 @@ interface GraphNode {
* 系统依赖信息
* System dependency info
*/
export interface SystemDependencyInfo {
export type SystemDependencyInfo = {
/** 系统名称 | System name */
name: string;
/** 在这些系统之前执行 | Execute before these systems */

View File

@@ -53,7 +53,7 @@ export const DEFAULT_STAGE_ORDER: readonly SystemStage[] = [
* 系统调度元数据
* System scheduling metadata
*/
export interface SystemSchedulingMetadata {
export type SystemSchedulingMetadata = {
/** 执行阶段 | Execution stage */
stage: SystemStage;
/** 在这些系统之前执行 | Execute before these systems */

View File

@@ -18,7 +18,7 @@ const ENTITY_REF_VALUES = Symbol('EntityRefValues');
/**
* EntityRef元数据
*/
export interface EntityRefMetadata {
export type EntityRefMetadata = {
properties: Set<string>;
}

View File

@@ -1,4 +1,8 @@
import 'reflect-metadata';
/**
* 属性元数据存储
* Property metadata storage
*/
const metadataStorage = new WeakMap<Function, Record<string, unknown>>();
export type PropertyType = 'number' | 'integer' | 'string' | 'boolean' | 'color' | 'vector2' | 'vector3' | 'vector4' | 'enum' | 'asset' | 'array' | 'animationClips' | 'collisionLayer' | 'collisionMask' | 'entityRef';
@@ -21,7 +25,7 @@ export type EnumOption = string | { label: string; value: any };
* Action button configuration for property fields
* 属性字段的操作按钮配置
*/
export interface PropertyAction {
export type PropertyAction = {
/** Action identifier | 操作标识符 */
id: string;
/** Button label | 按钮标签 */
@@ -36,7 +40,7 @@ export interface PropertyAction {
* 控制关系声明
* Control relationship declaration
*/
export interface PropertyControl {
export type PropertyControl = {
/** 被控制的组件名称 | Target component name */
component: string;
/** 被控制的属性名称 | Target property name */
@@ -253,25 +257,27 @@ export const PROPERTY_METADATA = Symbol.for('@esengine/property:metadata');
*/
export function Property(options: PropertyOptions): PropertyDecorator {
return (target: object, propertyKey: string | symbol) => {
const constructor = target.constructor;
const existingMetadata = Reflect.getMetadata(PROPERTY_METADATA, constructor) || {};
const constructor = target.constructor as Function;
const existingMetadata = metadataStorage.get(constructor) || {};
existingMetadata[propertyKey as string] = options;
Reflect.defineMetadata(PROPERTY_METADATA, existingMetadata, constructor);
metadataStorage.set(constructor, existingMetadata);
};
}
/**
* 获取组件类的所有属性元数据
* Get all property metadata for a component class
*/
export function getPropertyMetadata(target: Function): Record<string, PropertyOptions> | undefined {
return Reflect.getMetadata(PROPERTY_METADATA, target);
return metadataStorage.get(target) as Record<string, PropertyOptions> | undefined;
}
/**
* 检查组件类是否有属性元数据
* Check if a component class has property metadata
*/
export function hasPropertyMetadata(target: Function): boolean {
return Reflect.hasMetadata(PROPERTY_METADATA, target);
return metadataStorage.has(target);
}

View File

@@ -30,7 +30,7 @@ export const SYSTEM_TYPE_NAME = Symbol('SystemTypeName');
* 系统类型元数据接口
* System type metadata interface
*/
export interface SystemTypeMetadata {
export type SystemTypeMetadata = {
readonly [SYSTEM_TYPE_NAME]?: string;
readonly __systemMetadata__?: SystemMetadata;
}
@@ -74,7 +74,7 @@ type SystemConstructor<T extends EntitySystem = EntitySystem> = new (...args: an
* 组件装饰器配置选项
* Component decorator options
*/
export interface ComponentOptions {
export type ComponentOptions = {
/** 依赖的其他组件名称列表 | List of required component names */
requires?: string[];
@@ -150,7 +150,7 @@ export function ECSComponent(typeName: string, options?: ComponentOptions) {
* System 元数据配置
* System metadata configuration
*/
export interface SystemMetadata {
export type SystemMetadata = {
/**
* 更新顺序数值越小越先执行默认0
* Update order (lower values execute first, default 0)

View File

@@ -18,7 +18,7 @@ import type { IncrementalSnapshot, IncrementalSerializationOptions } from './Ser
*
* 定义场景应该实现的核心功能和属性,使用接口而非继承提供更灵活的实现方式。
*/
export interface IScene {
export type IScene = {
/**
* 场景名称
*/
@@ -362,7 +362,7 @@ export interface IScene {
/**
* 场景工厂接口
*/
export interface ISceneFactory<T extends IScene> {
export type ISceneFactory<T extends IScene> = {
/**
* 创建场景实例
*/
@@ -373,7 +373,7 @@ export interface ISceneFactory<T extends IScene> {
* 场景配置接口
* Scene configuration interface
*/
export interface ISceneConfig {
export type ISceneConfig = {
/**
* 场景名称
* Scene name

View File

@@ -14,7 +14,7 @@ import type { SerializationContext, SerializedEntityRef } from './SerializationC
export type { SerializableValue } from './ValueSerializer';
export interface SerializedComponent {
export type SerializedComponent = {
type: string;
version: number;
data: Record<string, SerializableValue>;

View File

@@ -15,7 +15,7 @@ import { SerializationContext } from './SerializationContext';
/**
* 序列化后的实体数据
*/
export interface SerializedEntity {
export type SerializedEntity = {
/**
* 实体ID运行时ID
*

View File

@@ -37,7 +37,7 @@ export enum ChangeOperation {
/**
* 实体变更记录
*/
export interface EntityChange {
export type EntityChange = {
/** 操作类型 */
operation: ChangeOperation;
/** 实体ID */
@@ -51,7 +51,7 @@ export interface EntityChange {
/**
* 组件变更记录
*/
export interface ComponentChange {
export type ComponentChange = {
/** 操作类型 */
operation: ChangeOperation;
/** 实体ID */
@@ -65,7 +65,7 @@ export interface ComponentChange {
/**
* 场景数据变更记录
*/
export interface SceneDataChange {
export type SceneDataChange = {
/** 操作类型 */
operation: ChangeOperation;
/** 变更的键 */
@@ -79,7 +79,7 @@ export interface SceneDataChange {
/**
* 增量序列化数据
*/
export interface IncrementalSnapshot {
export type IncrementalSnapshot = {
/** 快照版本号 */
version: number;
/** 时间戳 */
@@ -127,7 +127,7 @@ export type IncrementalSerializationFormat = 'json' | 'binary';
/**
* 增量序列化选项
*/
export interface IncrementalSerializationOptions {
export type IncrementalSerializationOptions = {
/**
* 是否包含组件数据的深度对比
* 默认true设为false可提升性能但可能漏掉组件内部字段变更

View File

@@ -35,7 +35,7 @@ export interface SerializedPrefabEntity extends SerializedEntity {
* 预制体元数据
* Prefab metadata
*/
export interface PrefabMetadata {
export type PrefabMetadata = {
/** 预制体名称 | Prefab name */
name: string;
/** 资产 GUID | Asset GUID */
@@ -58,7 +58,7 @@ export interface PrefabMetadata {
* 组件类型注册条目
* Component type registry entry
*/
export interface PrefabComponentTypeEntry {
export type PrefabComponentTypeEntry = {
/** 组件类型名称 | Component type name */
typeName: string;
/** 组件版本号 | Component version number */
@@ -69,7 +69,7 @@ export interface PrefabComponentTypeEntry {
* 预制体数据格式
* Prefab data format
*/
export interface PrefabData {
export type PrefabData = {
/** 预制体格式版本号 | Prefab format version number */
version: number;
/** 预制体元数据 | Prefab metadata */
@@ -84,7 +84,7 @@ export interface PrefabData {
* 预制体创建选项
* Prefab creation options
*/
export interface PrefabCreateOptions {
export type PrefabCreateOptions = {
/** 预制体名称 | Prefab name */
name: string;
/** 预制体描述 | Prefab description */
@@ -99,7 +99,7 @@ export interface PrefabCreateOptions {
* 预制体实例化选项
* Prefab instantiation options
*/
export interface PrefabInstantiateOptions {
export type PrefabInstantiateOptions = {
/** 父实体 ID | Parent entity ID */
parentId?: number;
/** 位置覆盖 | Position override */

View File

@@ -38,7 +38,7 @@ export type MigrationFunction = (
/**
* 场景序列化选项
*/
export interface SceneSerializationOptions {
export type SceneSerializationOptions = {
/**
* 要序列化的组件类型列表
* 如果未指定,则序列化所有可序列化的组件
@@ -69,7 +69,7 @@ export interface SceneSerializationOptions {
/**
* 场景反序列化选项
*/
export interface SceneDeserializationOptions {
export type SceneDeserializationOptions = {
/**
* 反序列化策略
* - 'merge': 合并到现有场景
@@ -97,7 +97,7 @@ export interface SceneDeserializationOptions {
/**
* 序列化后的场景数据
*/
export interface SerializedScene {
export type SerializedScene = {
/**
* 场景名称
*/

View File

@@ -6,7 +6,7 @@ import type { Component } from '../Component';
*
* Serialized entity reference format.
*/
export interface SerializedEntityRef {
export type SerializedEntityRef = {
/**
* 运行时 ID向后兼容
*

View File

@@ -16,7 +16,7 @@ export const SERIALIZE_OPTIONS = Symbol('SerializeOptions');
/**
* 可序列化配置选项
*/
export interface SerializableOptions {
export type SerializableOptions = {
/**
* 序列化版本号,用于数据迁移
*/
@@ -31,7 +31,7 @@ export interface SerializableOptions {
/**
* 字段序列化配置
*/
export interface FieldSerializeOptions {
export type FieldSerializeOptions = {
/**
* 自定义序列化器
*/
@@ -51,7 +51,7 @@ export interface FieldSerializeOptions {
/**
* 序列化元数据
*/
export interface SerializationMetadata {
export type SerializationMetadata = {
options: SerializableOptions;
fields: Map<string | symbol, FieldSerializeOptions>;
ignoredFields: Set<string | symbol>;

View File

@@ -19,7 +19,7 @@ export type WorkerProcessFunction<T extends Record<string, any> = any> = (
/**
* Worker配置接口
*/
export interface WorkerSystemConfig {
export type WorkerSystemConfig = {
/** 是否启用Worker并行处理 */
enableWorker?: boolean;
/** Worker数量默认为CPU核心数自动限制在系统最大值内 */

View File

@@ -17,7 +17,7 @@ export type BitMask64Segment = [number,number]
* 扩展模式128+位base[lo , hi] 作为第一段segments 存储额外的 64 位段
* segments[0] 对应 bit 64-127segments[1] 对应 bit 128-191以此类推
*/
export interface BitMask64Data {
export type BitMask64Data = {
base: BitMask64Segment;
/** 扩展段数组,每个元素是一个 64 位段,用于超过 64 位的场景 */
segments?: BitMask64Segment[];

View File

@@ -4,7 +4,7 @@ import { getComponentTypeName } from '../Decorators';
/**
* 查询条件类型
*/
export interface QueryCondition {
export type QueryCondition = {
all: ComponentType[];
any: ComponentType[];
none: ComponentType[];

View File

@@ -4,6 +4,7 @@ export { EntityProcessorList } from './EntityProcessorList';
export { IdentifierPool } from './IdentifierPool';
export { Matcher } from './Matcher';
export { Bits } from './Bits';
export { BitMask64Utils, BitMask64Data } from './BigIntCompatibility';
export { BitMask64Utils } from './BigIntCompatibility';
export type { BitMask64Data } from './BigIntCompatibility';
export { SparseSet } from './SparseSet';
export { ComponentSparseSet } from './ComponentSparseSet';

View File

@@ -10,7 +10,7 @@ const logger = createLogger('World');
* 全局系统接口
* 全局系统是在World级别运行的系统不依赖特定Scene
*/
export interface IGlobalSystem {
export type IGlobalSystem = {
/**
* 系统名称
*/
@@ -40,7 +40,7 @@ export interface IGlobalSystem {
/**
* World配置接口
*/
export interface IWorldConfig {
export type IWorldConfig = {
/**
* World名称
*/

View File

@@ -7,7 +7,7 @@ const logger = createLogger('WorldManager');
/**
* WorldManager配置接口
*/
export interface IWorldManagerConfig {
export type IWorldManagerConfig = {
/**
* 最大World数量
*/

View File

@@ -7,10 +7,12 @@ export * from './Utils';
export * from './Decorators';
export * from './Components';
export { Scene } from './Scene';
export { IScene, ISceneFactory, ISceneConfig } from './IScene';
export type { IScene, ISceneFactory, ISceneConfig } from './IScene';
export { SceneManager } from './SceneManager';
export { World, IWorldConfig } from './World';
export { WorldManager, IWorldManagerConfig } from './WorldManager';
export { World } from './World';
export type { IWorldConfig } from './World';
export { WorldManager } from './WorldManager';
export type { IWorldManagerConfig } from './WorldManager';
export * from './Core/Events';
export * from './Core/Query';
export * from './Core/Storage';

View File

@@ -2,7 +2,7 @@
* 平台适配器接口
* 用于适配不同的运行环境(浏览器、微信小游戏、字节跳动小游戏等)
*/
export interface IPlatformAdapter {
export type IPlatformAdapter = {
/**
* 平台名称
*/
@@ -60,7 +60,7 @@ export interface IPlatformAdapter {
/**
* Worker创建选项
*/
export interface WorkerCreationOptions {
export type WorkerCreationOptions = {
/**
* Worker类型
*/
@@ -80,7 +80,7 @@ export interface WorkerCreationOptions {
/**
* 平台Worker接口
*/
export interface PlatformWorker {
export type PlatformWorker = {
/**
* 发送消息到Worker
*/
@@ -110,7 +110,7 @@ export interface PlatformWorker {
/**
* 平台配置
*/
export interface PlatformConfig {
export type PlatformConfig = {
/**
* 最大Worker数量限制
*/
@@ -175,7 +175,7 @@ export interface PlatformConfig {
/**
* 平台检测结果
*/
export interface PlatformDetectionResult {
export type PlatformDetectionResult = {
/**
* 平台类型
*/

View File

@@ -14,7 +14,7 @@ const logger = createLogger('DebugPlugin');
/**
* ECS 调试插件统计信息
*/
export interface ECSDebugStats {
export type ECSDebugStats = {
scenes: SceneDebugInfo[];
totalEntities: number;
totalSystems: number;
@@ -24,7 +24,7 @@ export interface ECSDebugStats {
/**
* 场景调试信息
*/
export interface SceneDebugInfo {
export type SceneDebugInfo = {
name: string;
entityCount: number;
systems: SystemDebugInfo[];
@@ -34,7 +34,7 @@ export interface SceneDebugInfo {
/**
* 系统调试信息
*/
export interface SystemDebugInfo {
export type SystemDebugInfo = {
name: string;
enabled: boolean;
updateOrder: number;
@@ -49,7 +49,7 @@ export interface SystemDebugInfo {
/**
* 实体调试信息
*/
export interface EntityDebugInfo {
export type EntityDebugInfo = {
id: number;
name: string;
enabled: boolean;
@@ -61,7 +61,7 @@ export interface EntityDebugInfo {
/**
* 组件调试信息
*/
export interface ComponentDebugInfo {
export type ComponentDebugInfo = {
type: string;
data: any;
}

View File

@@ -3,7 +3,7 @@
*
* 实现此接口的服务将在每帧被Core自动调用update方法
*/
export interface IUpdatable {
export type IUpdatable = {
/**
* 每帧更新方法
*

View File

@@ -48,7 +48,7 @@ export type ComponentTypeMap<T extends readonly ComponentConstructor[]> = {
* 实体with组件的类型
* 表示一个实体确定拥有某些组件
*/
export interface EntityWithComponents<T extends readonly ComponentConstructor[]> {
export type EntityWithComponents<T extends readonly ComponentConstructor[]> = {
readonly id: number;
readonly name: string;
@@ -163,7 +163,7 @@ export type TypedEventHandler<T> = (data: T) => void | Promise<void>;
/**
* 系统生命周期钩子类型
*/
export interface SystemLifecycleHooks<T extends readonly ComponentConstructor[]> {
export type SystemLifecycleHooks<T extends readonly ComponentConstructor[]> = {
/**
* 实体添加到系统时调用
*/
@@ -188,7 +188,7 @@ export interface SystemLifecycleHooks<T extends readonly ComponentConstructor[]>
/**
* Fluent API构建器类型
*/
export interface TypeSafeBuilder<T> {
export type TypeSafeBuilder<T> = {
/**
* 完成构建
*/
@@ -198,7 +198,7 @@ export interface TypeSafeBuilder<T> {
/**
* 组件池类型
*/
export interface ComponentPool<T extends IComponent> {
export type ComponentPool<T extends IComponent> = {
/**
* 从池中获取组件实例
*/
@@ -223,11 +223,11 @@ export interface ComponentPool<T extends IComponent> {
/**
* 实体查询条件类型
*/
export interface TypedQueryCondition<
export type TypedQueryCondition<
All extends readonly ComponentConstructor[] = [],
Any extends readonly ComponentConstructor[] = [],
None extends readonly ComponentConstructor[] = []
> {
> = {
all: All;
any: Any;
none: None;

View File

@@ -14,7 +14,7 @@ export * from './IUpdatable';
* 定义组件的基本契约。
* 在 ECS 架构中,组件应该是纯数据容器,不包含业务逻辑。
*/
export interface IComponent {
export type IComponent = {
/** 组件唯一标识符 */
readonly id: number;
/** 组件所属的实体ID */
@@ -49,7 +49,7 @@ export interface IComponent {
*
* 为现有的EntitySystem类提供类型定义
*/
export interface ISystemBase {
export type ISystemBase = {
/** 系统名称 */
readonly systemName: string;
/** 更新顺序/优先级 */
@@ -69,7 +69,7 @@ export interface ISystemBase {
* 事件总线接口
* 提供类型安全的事件发布订阅机制
*/
export interface IEventBus {
export type IEventBus = {
/**
* 发射事件
* @param eventType 事件类型
@@ -145,7 +145,7 @@ export interface IEventBus {
/**
* 事件监听器配置接口
*/
export interface IEventListenerConfig {
export type IEventListenerConfig = {
/** 是否只执行一次 */
once?: boolean;
/** 优先级(数字越大优先级越高) */
@@ -159,7 +159,7 @@ export interface IEventListenerConfig {
/**
* 事件统计信息接口
*/
export interface IEventStats {
export type IEventStats = {
/** 事件类型 */
eventType: string;
/** 监听器数量 */
@@ -177,7 +177,7 @@ export interface IEventStats {
/**
* 事件数据基类接口
*/
export interface IEventData {
export type IEventData = {
/** 事件时间戳 */
timestamp: number;
/** 事件来源 */
@@ -245,7 +245,7 @@ export interface IPerformanceEventData extends IEventData {
/**
* ECS调试配置接口
*/
export interface IECSDebugConfig {
export type IECSDebugConfig = {
/** 是否启用调试 */
enabled: boolean;
/** WebSocket服务器URL */
@@ -269,7 +269,7 @@ export interface IECSDebugConfig {
/**
* Core配置接口
*/
export interface ICoreConfig {
export type ICoreConfig = {
/** 是否启用调试模式 */
debug?: boolean;
/** 调试配置 */
@@ -281,7 +281,7 @@ export interface ICoreConfig {
/**
* ECS调试数据接口
*/
export interface IECSDebugData {
export type IECSDebugData = {
/** 时间戳 */
timestamp: number;
/** 框架版本 */
@@ -307,7 +307,7 @@ export interface IECSDebugData {
/**
* 实体层次结构节点接口
*/
export interface IEntityHierarchyNode {
export type IEntityHierarchyNode = {
id: number;
name: string;
active: boolean;
@@ -325,7 +325,7 @@ export interface IEntityHierarchyNode {
/**
* 实体调试数据接口
*/
export interface IEntityDebugData {
export type IEntityDebugData = {
/** 总实体数 */
totalEntities: number;
/** 激活实体数 */
@@ -399,7 +399,7 @@ export interface IEntityDebugData {
/**
* 系统调试数据接口
*/
export interface ISystemDebugData {
export type ISystemDebugData = {
/** 总系统数 */
totalSystems: number;
/** 系统信息列表 */
@@ -422,7 +422,7 @@ export interface ISystemDebugData {
/**
* 性能调试数据接口
*/
export interface IPerformanceDebugData {
export type IPerformanceDebugData = {
/** ECS框架执行时间毫秒 */
frameTime: number;
/** 引擎总帧时间(毫秒) */
@@ -472,7 +472,7 @@ export interface IPerformanceDebugData {
/**
* 组件调试数据接口
*/
export interface IComponentDebugData {
export type IComponentDebugData = {
/** 组件类型数 */
componentTypes: number;
/** 组件实例总数 */
@@ -492,7 +492,7 @@ export interface IComponentDebugData {
/**
* 场景调试数据接口
*/
export interface ISceneDebugData {
export type ISceneDebugData = {
/** 当前场景名称 */
currentSceneName: string;
/** 场景是否已初始化 */

View File

@@ -17,7 +17,7 @@ import { Time } from '../Time';
/**
* 旧版 PerformanceMonitor 接口 (用于兼容)
*/
export interface ILegacyPerformanceMonitor {
export type ILegacyPerformanceMonitor = {
getAllSystemStats?: () => Map<string, {
averageTime: number;
minTime?: number;
@@ -33,7 +33,7 @@ export interface ILegacyPerformanceMonitor {
/**
* 热点函数项(支持递归层级)
*/
export interface IHotspotItem {
export type IHotspotItem = {
name: string;
category: string;
inclusiveTime: number;
@@ -51,7 +51,7 @@ export interface IHotspotItem {
/**
* 高级性能数据接口
*/
export interface IAdvancedProfilerData {
export type IAdvancedProfilerData = {
/** 当前帧信息 */
currentFrame: {
frameNumber: number;

View File

@@ -3,7 +3,7 @@ import type { LogLevel } from './Constants';
/**
* 日志接口
*/
export interface ILogger {
export type ILogger = {
debug(...args: unknown[]): void;
info(...args: unknown[]): void;
warn(...args: unknown[]): void;
@@ -14,7 +14,7 @@ export interface ILogger {
/**
* 日志颜色配置接口
*/
export interface LoggerColorConfig {
export type LoggerColorConfig = {
debug?: string;
info?: string;
warn?: string;
@@ -26,7 +26,7 @@ export interface LoggerColorConfig {
/**
* 日志配置
*/
export interface LoggerConfig {
export type LoggerConfig = {
/** 日志级别 */
level: LogLevel;
/** 是否启用时间戳 */

View File

@@ -1,7 +1,7 @@
/**
* 性能监控数据
*/
export interface PerformanceData {
export type PerformanceData = {
/** 系统名称 */
name: string;
/** 执行时间(毫秒) */
@@ -21,7 +21,7 @@ export interface PerformanceData {
/**
* 性能统计信息
*/
export interface PerformanceStats {
export type PerformanceStats = {
/** 总执行时间 */
totalTime: number;
/** 平均执行时间 */
@@ -57,7 +57,7 @@ export enum PerformanceWarningType {
/**
* 性能警告
*/
export interface PerformanceWarning {
export type PerformanceWarning = {
type: PerformanceWarningType;
systemName: string;
message: string;
@@ -71,7 +71,7 @@ export interface PerformanceWarning {
/**
* 性能阈值配置
*/
export interface PerformanceThresholds {
export type PerformanceThresholds = {
/** 执行时间阈值(毫秒) */
executionTime: {
warning: number;

View File

@@ -1,7 +1,7 @@
/**
* 可池化对象接口
*/
export interface IPoolable {
export type IPoolable = {
/**
* 重置对象状态,准备重用
*/
@@ -11,7 +11,7 @@ export interface IPoolable {
/**
* 对象池统计信息
*/
export interface PoolStats {
export type PoolStats = {
/** 池中对象数量 */
size: number;
/** 池的最大大小 */

View File

@@ -15,7 +15,7 @@ import { ProfileCategory } from './ProfilerTypes';
/**
* 自动分析配置
*/
export interface AutoProfilerConfig {
export type AutoProfilerConfig = {
/** 是否启用自动包装 */
enabled: boolean;
/** 采样间隔(毫秒),用于采样分析器 */

View File

@@ -35,7 +35,7 @@ export enum ProfileCategory {
/**
* 采样句柄
*/
export interface SampleHandle {
export type SampleHandle = {
id: string;
name: string;
category: ProfileCategory;
@@ -47,7 +47,7 @@ export interface SampleHandle {
/**
* 性能采样数据
*/
export interface ProfileSample {
export type ProfileSample = {
id: string;
name: string;
category: ProfileCategory;
@@ -66,7 +66,7 @@ export interface ProfileSample {
/**
* 聚合后的采样统计
*/
export interface ProfileSampleStats {
export type ProfileSampleStats = {
name: string;
category: ProfileCategory;
/** 包含时间(包含子调用) */
@@ -94,7 +94,7 @@ export interface ProfileSampleStats {
/**
* 内存快照
*/
export interface MemorySnapshot {
export type MemorySnapshot = {
timestamp: number;
/** 已使用堆内存 (bytes) */
usedHeapSize: number;
@@ -111,7 +111,7 @@ export interface MemorySnapshot {
/**
* 计数器数据
*/
export interface ProfileCounter {
export type ProfileCounter = {
name: string;
category: ProfileCategory;
value: number;
@@ -122,7 +122,7 @@ export interface ProfileCounter {
/**
* 单帧性能数据
*/
export interface ProfileFrame {
export type ProfileFrame = {
frameNumber: number;
startTime: number;
endTime: number;
@@ -142,7 +142,7 @@ export interface ProfileFrame {
/**
* 分析器配置
*/
export interface ProfilerConfig {
export type ProfilerConfig = {
/** 是否启用 */
enabled: boolean;
/** 最大历史帧数 */
@@ -164,7 +164,7 @@ export interface ProfilerConfig {
/**
* 长任务信息
*/
export interface LongTaskInfo {
export type LongTaskInfo = {
startTime: number;
duration: number;
attribution: string[];
@@ -173,7 +173,7 @@ export interface LongTaskInfo {
/**
* 调用关系节点
*/
export interface CallGraphNode {
export type CallGraphNode = {
name: string;
category: ProfileCategory;
/** 被调用次数 */
@@ -189,7 +189,7 @@ export interface CallGraphNode {
/**
* 性能分析报告
*/
export interface ProfileReport {
export type ProfileReport = {
startTime: number;
endTime: number;
totalFrames: number;

View File

@@ -1,4 +1,4 @@
export interface ITimer<TContext = unknown> {
export type ITimer<TContext = unknown> = {
context: TContext;
/**

View File

@@ -48,7 +48,7 @@ export type { InjectableMetadata, UpdatableMetadata } from './Core/DI';
export { Emitter, FuncPack } from './Utils/Emitter';
export { GlobalManager } from './Utils/GlobalManager';
export { TimerManager } from './Utils/Timers/TimerManager';
export { ITimer } from './Utils/Timers/ITimer';
export type { ITimer } from './Utils/Timers/ITimer';
export { Timer } from './Utils/Timers/Timer';
// 日志系统
@@ -77,7 +77,8 @@ export * from './Utils';
export * from './Types';
// 显式导出ComponentPool类解决与Types中ComponentPool接口的命名冲突
export { ComponentPool, ComponentPoolManager } from './ECS/Core/Storage';
export { ComponentPoolManager } from './ECS/Core/Storage';
export type { ComponentPool } from './ECS/Core/Storage';
// 平台适配
export * from './Platform';