refactor: reorganize package structure and decouple framework packages (#338)

* refactor: reorganize package structure and decouple framework packages

## Package Structure Reorganization
- Reorganized 55 packages into categorized subdirectories:
  - packages/framework/ - Generic framework (Laya/Cocos compatible)
  - packages/engine/ - ESEngine core modules
  - packages/rendering/ - Rendering modules (WASM dependent)
  - packages/physics/ - Physics modules
  - packages/streaming/ - World streaming
  - packages/network-ext/ - Network extensions
  - packages/editor/ - Editor framework and plugins
  - packages/rust/ - Rust WASM engine
  - packages/tools/ - Build tools and SDK

## Framework Package Decoupling
- Decoupled behavior-tree and blueprint packages from ESEngine dependencies
- Created abstracted interfaces (IBTAssetManager, IBehaviorTreeAssetContent)
- ESEngine-specific code moved to esengine/ subpath exports
- Framework packages now usable with Cocos/Laya without ESEngine

## CI Configuration
- Updated CI to only type-check and lint framework packages
- Added type-check:framework and lint:framework scripts

## Breaking Changes
- Package import paths changed due to directory reorganization
- ESEngine integrations now use subpath imports (e.g., '@esengine/behavior-tree/esengine')

* fix: update es-engine file path after directory reorganization

* docs: update README to focus on framework over engine

* ci: only build framework packages, remove Rust/WASM dependencies

* fix: remove esengine subpath from behavior-tree and blueprint builds

ESEngine integration code will only be available in full engine builds.
Framework packages are now purely engine-agnostic.

* fix: move network-protocols to framework, build both in CI

* fix: update workflow paths from packages/core to packages/framework/core

* fix: exclude esengine folder from type-check in behavior-tree and blueprint

* fix: update network tsconfig references to new paths

* fix: add test:ci:framework to only test framework packages in CI

* fix: only build core and math npm packages in CI

* fix: exclude test files from CodeQL and fix string escaping security issue
This commit is contained in:
YHH
2025-12-26 14:50:35 +08:00
committed by GitHub
parent a84ff902e4
commit 155411e743
1936 changed files with 4147 additions and 11578 deletions

View File

@@ -0,0 +1,174 @@
/**
* Material System Service Tokens
* 材质系统服务令牌
*
* 遵循"谁定义接口,谁导出 Token"原则。
* Following "who defines interface, who exports Token" principle.
*/
import { createServiceToken } from '@esengine/ecs-framework';
import type { Material } from './Material';
import type { Shader } from './Shader';
import type { IEngineBridge } from './MaterialManager';
import type { IAssetManager } from '@esengine/asset-system';
// ============================================================================
// Material Manager Interface
// ============================================================================
/**
* MaterialManager 接口
* MaterialManager interface
*
* 提供材质和着色器管理功能。
* Provides material and shader management functionality.
*/
export interface IMaterialManager {
// ========== Initialization | 初始化 ==========
/**
* 设置引擎桥接
* Set engine bridge for Rust communication
*/
setEngineBridge(bridge: IEngineBridge): void;
/**
* 设置资产管理器
* Set asset manager for loading assets
*/
setAssetManager(assetManager: IAssetManager): void;
/**
* 初始化内置材质
* Initialize built-in materials
*/
initializeBuiltInMaterials(): Promise<void>;
// ========== Shader Management | 着色器管理 ==========
/**
* 注册着色器
* Register a shader
*/
registerShader(shader: Shader): Promise<number>;
/**
* 通过 ID 获取着色器
* Get shader by ID
*/
getShader(id: number): Shader | undefined;
/**
* 通过名称获取着色器
* Get shader by name
*/
getShaderByName(name: string): Shader | undefined;
/**
* 移除着色器
* Remove a shader
*/
removeShader(id: number): boolean;
/**
* 从路径加载着色器
* Load shader from path
*/
loadShaderByPath(path: string): Promise<number>;
// ========== Material Management | 材质管理 ==========
/**
* 注册材质
* Register a material
*/
registerMaterial(material: Material): Promise<number>;
/**
* 通过 ID 获取材质
* Get material by ID
*/
getMaterial(id: number): Material | undefined;
/**
* 通过名称获取材质
* Get material by name
*/
getMaterialByName(name: string): Material | undefined;
/**
* 移除材质
* Remove a material
*/
removeMaterial(id: number): boolean;
/**
* 从路径加载材质
* Load material from path
*/
loadMaterialByPath(path: string): Promise<number>;
/**
* 克隆材质
* Clone a material
*/
cloneMaterial(materialId: number, newName?: string): Promise<Material | null>;
// ========== Built-in Materials | 内置材质 ==========
/**
* 获取默认材质 ID
* Get default material ID
*/
getDefaultMaterialId(): number;
/**
* 获取灰度材质 ID
* Get grayscale material ID
*/
getGrayscaleMaterialId(): number;
/**
* 获取着色材质 ID
* Get tint material ID
*/
getTintMaterialId(): number;
/**
* 获取闪烁材质 ID
* Get flash material ID
*/
getFlashMaterialId(): number;
/**
* 获取轮廓材质 ID
* Get outline material ID
*/
getOutlineMaterialId(): number;
// ========== Uniform Management | Uniform 管理 ==========
/**
* 设置材质 uniform 值
* Set material uniform value
*/
setMaterialUniform(materialId: number, name: string, value: any): boolean;
// ========== Lifecycle | 生命周期 ==========
/**
* 销毁管理器,释放所有资源
* Destroy manager and release all resources
*/
destroy(): void;
}
// ============================================================================
// Service Token
// ============================================================================
/**
* MaterialManager 服务令牌
* MaterialManager service token
*/
export const MaterialManagerToken = createServiceToken<IMaterialManager>('materialManager');