* feat: 添加 Tilemap 编辑器插件和组件生命周期支持 * feat(editor-core): 添加声明式插件注册 API * feat(editor-core): 改进tiledmap结构合并tileset进tiledmapeditor * feat: 添加 editor-runtime SDK 和插件系统改进 * fix(ci): 修复SceneResourceManager里变量未使用问题
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { IService } from '@esengine/ecs-framework';
|
|
import { ICompiler } from './ICompiler';
|
|
|
|
export class CompilerRegistry implements IService {
|
|
private compilers: Map<string, ICompiler> = new Map();
|
|
|
|
register(compiler: ICompiler): void {
|
|
if (this.compilers.has(compiler.id)) {
|
|
console.warn(`Compiler with id "${compiler.id}" is already registered. Overwriting.`);
|
|
}
|
|
this.compilers.set(compiler.id, compiler);
|
|
}
|
|
|
|
unregister(compilerId: string): void {
|
|
this.compilers.delete(compilerId);
|
|
}
|
|
|
|
get(compilerId: string): ICompiler | undefined {
|
|
return this.compilers.get(compilerId);
|
|
}
|
|
|
|
getAll(): ICompiler[] {
|
|
return Array.from(this.compilers.values());
|
|
}
|
|
|
|
clear(): void {
|
|
this.compilers.clear();
|
|
}
|
|
|
|
dispose(): void {
|
|
this.clear();
|
|
}
|
|
}
|
|
|
|
// Service identifier for DI registration (用于跨包插件访问)
|
|
// 使用 Symbol.for 确保跨包共享同一个 Symbol
|
|
export const ICompilerRegistry = Symbol.for('ICompilerRegistry');
|