修复动态require导致的跨平台错误
新增emitter的dispose方法用于清理事件 启用composite增量编译
This commit is contained in:
@@ -14,7 +14,7 @@ async function main() {
|
||||
|
||||
// 执行Rollup构建
|
||||
console.log('📦 执行 Rollup 构建...');
|
||||
execSync('rollup -c rollup.config.cjs', { stdio: 'inherit' });
|
||||
execSync('npx rollup -c rollup.config.cjs', { stdio: 'inherit' });
|
||||
|
||||
// 生成package.json
|
||||
console.log('📋 生成 package.json...');
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{
|
||||
"name": "@esengine/ecs-framework",
|
||||
"version": "2.1.35",
|
||||
"version": "2.1.41",
|
||||
"description": "用于Laya、Cocos Creator等JavaScript游戏引擎的高性能ECS框架",
|
||||
"type": "module",
|
||||
"main": "bin/index.js",
|
||||
"types": "bin/index.d.ts",
|
||||
"exports": {
|
||||
@@ -30,7 +29,7 @@
|
||||
"egret"
|
||||
],
|
||||
"scripts": {
|
||||
"clean": "rimraf bin dist",
|
||||
"clean": "rimraf bin dist tsconfig.tsbuildinfo",
|
||||
"build:ts": "tsc",
|
||||
"prebuild": "npm run clean",
|
||||
"build": "npm run build:ts",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IComponentDebugData } from '../../Types';
|
||||
import { Core } from '../../Core';
|
||||
import { ComponentPoolManager } from '../../ECS/Core/ComponentPool';
|
||||
|
||||
/**
|
||||
* 组件数据收集器
|
||||
@@ -49,7 +50,6 @@ export class ComponentDataCollector {
|
||||
let poolSizes = new Map<string, number>();
|
||||
|
||||
try {
|
||||
const { ComponentPoolManager } = require('../../ECS/Core/ComponentPool');
|
||||
const poolManager = ComponentPoolManager.getInstance();
|
||||
const poolStats = poolManager.getPoolStats();
|
||||
const utilizations = poolManager.getPoolUtilization();
|
||||
|
||||
@@ -7,6 +7,8 @@ import { SceneDataCollector } from './SceneDataCollector';
|
||||
import { WebSocketManager } from './WebSocketManager';
|
||||
import { Core } from '../../Core';
|
||||
import { Component } from '../../ECS/Component';
|
||||
import { ComponentPoolManager } from '../../ECS/Core/ComponentPool';
|
||||
import { Pool } from '../../Utils/Pool';
|
||||
|
||||
/**
|
||||
* 调试管理器
|
||||
@@ -639,7 +641,6 @@ export class DebugManager {
|
||||
|
||||
try {
|
||||
// 尝试获取组件池统计
|
||||
const { ComponentPoolManager } = require('../../ECS/Core/ComponentPool');
|
||||
const poolManager = ComponentPoolManager.getInstance();
|
||||
const poolStats = poolManager.getPoolStats();
|
||||
|
||||
@@ -662,8 +663,7 @@ export class DebugManager {
|
||||
|
||||
try {
|
||||
// 尝试获取通用对象池统计
|
||||
const { Pool } = require('../../Utils/Pool');
|
||||
const poolStats = Pool.getStats();
|
||||
const poolStats = Pool.getAllPoolStats();
|
||||
|
||||
for (const [typeName, stats] of Object.entries(poolStats)) {
|
||||
const poolData = stats as {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { IEntityDebugData } from '../../Types';
|
||||
import { Core } from '../../Core';
|
||||
import { Entity } from '../../ECS/Entity';
|
||||
import { Component } from '../../ECS/Component';
|
||||
import { ComponentTypeManager } from '../../ECS/Utils/ComponentTypeManager';
|
||||
|
||||
/**
|
||||
* 实体数据收集器
|
||||
@@ -712,7 +713,6 @@ export class EntityDataCollector {
|
||||
|
||||
if (!typeName || typeName === 'Object' || typeName === 'Function') {
|
||||
try {
|
||||
const { ComponentTypeManager } = require('../../ECS/Utils/ComponentTypeManager');
|
||||
const typeManager = ComponentTypeManager.instance;
|
||||
const componentType = component.constructor as any;
|
||||
const typeId = typeManager.getTypeId(componentType);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { IPerformanceDebugData } from '../../Types';
|
||||
import { Time } from '../Time';
|
||||
import { Core } from '../../Core';
|
||||
|
||||
/**
|
||||
* 性能数据收集器
|
||||
@@ -64,7 +65,6 @@ export class PerformanceDataCollector {
|
||||
if (!performanceMonitor) {
|
||||
// 尝试从Core实例获取性能监视器
|
||||
try {
|
||||
const { Core } = require('../../Core');
|
||||
const coreInstance = Core.Instance;
|
||||
if (coreInstance && (coreInstance as any)._performanceMonitor) {
|
||||
performanceMonitor = (coreInstance as any)._performanceMonitor;
|
||||
|
||||
@@ -78,4 +78,39 @@ export class Emitter<T, TContext = unknown> {
|
||||
let list = this._messageTable.get(eventType);
|
||||
return list ? list.some(observer => observer.func === handler) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定事件类型的所有监听器
|
||||
* @param eventType 事件类型
|
||||
*/
|
||||
public removeAllObservers(eventType?: T): void {
|
||||
if (eventType !== undefined) {
|
||||
this._messageTable.delete(eventType);
|
||||
} else {
|
||||
this._messageTable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放所有资源,清理所有监听器
|
||||
*/
|
||||
public dispose(): void {
|
||||
this._messageTable.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取事件类型数量
|
||||
*/
|
||||
public getEventTypeCount(): number {
|
||||
return this._messageTable.size;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定事件类型的监听器数量
|
||||
* @param eventType 事件类型
|
||||
*/
|
||||
public getObserverCount(eventType: T): number {
|
||||
const list = this._messageTable.get(eventType);
|
||||
return list ? list.length : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,9 @@ export type { ILogger, LoggerConfig } from './Utils/Logger';
|
||||
// ECS核心组件
|
||||
export * from './ECS';
|
||||
|
||||
// 事件系统
|
||||
export { ECSEventType, EventPriority, EVENT_TYPES, EventTypeValidator } from './ECS/CoreEvents';
|
||||
|
||||
// 工具类和类型定义
|
||||
export * from './Utils';
|
||||
export * from './Types';
|
||||
@@ -8,6 +8,7 @@
|
||||
"outDir": "./bin",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
"composite": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
Reference in New Issue
Block a user