项目文件夹

文件
wehub-resource-sync c48612c494
CI / E2E Tests (push) Has been cancelled
CI / Lint, Typecheck & Unit Tests (push) Has been cancelled
Docs Build / Build docs site (push) Has been cancelled
Publish @openmaic packages / Build, validate & publish (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:23 +08:00

26 行
1.1 KiB
TypeScript

import type { SceneType } from '@/lib/types/stage';
import type { SceneEditorRegistry, SceneEditorSurface } from './scene-editor-surface';
const surfaces = new Map<SceneType, SceneEditorSurface>();
export const sceneEditorRegistry: SceneEditorRegistry = {
register: (surface) => {
// Re-registering the same instance is benign (HMR re-executes module init
// and the second pass passes the identical surface object). Only warn when
// a different surface tries to take the slot, since that silently masks
// bugs like accidental double-imports from divergent paths.
const existing = surfaces.get(surface.sceneType);
if (existing && existing !== surface && process.env.NODE_ENV !== 'production') {
console.warn(
`[sceneEditorRegistry] overwriting existing surface for "${surface.sceneType}". ` +
`If this is HMR, call unregister first.`,
);
}
surfaces.set(surface.sceneType, surface as SceneEditorSurface);
},
unregister: (sceneType) => {
surfaces.delete(sceneType);
},
resolve: (sceneType) => surfaces.get(sceneType),
};