import type { EditorSimulation } from "./simulation.js"; import type { MaterialAsset, MaterialSelector } from "../material/materialAsset.js"; import { type StaticPrefabBake } from "./staticPrefab.js"; import { type SurfaceDelta, type TerraformDelta, type TerrainMaterialLayer, type WeightDelta } from "../world/terraform.js"; import type { EditorUiDocument, EditorUiPanelLayout } from "../ui/hudDocument.js"; import type { EditorGridCellEdit, EditorGridLayer } from "./grid.js"; import type { ParamSchema } from "../scene/sceneKinds.js"; import type { EditorCatalogEntry, EditorBake, EditorDocument, EditorEnvironment, EditorMarker, EditorMinimapBake, EditorNote, EditorPath, EditorTerrain, EditorVec3, EditorVolume } from "./types.js"; /** A single editor mutation — select, move, add, remove, undo/redo — dispatched to a session. */ export type EditorCommand = { type: "select"; ids: readonly string[]; } | { type: "clearSelection"; } | { type: "setTransform"; id: string; position?: EditorVec3; rotationY?: number; } | { type: "translate"; ids: readonly string[]; delta: EditorVec3; } | { type: "setParent"; ids: readonly string[]; parentId: string | null; } | { type: "addMarker"; marker: EditorMarker; } | { type: "addVolume"; volume: EditorVolume; } | { type: "addPath"; path: EditorPath; } | { type: "addNote"; note: EditorNote; } | { type: "setMarker"; id: string; patch: Partial>; } | { type: "setVolume"; id: string; patch: Partial>; } | { type: "setPath"; id: string; patch: Partial>; } | { type: "setNote"; id: string; patch: Partial>; } | { type: "setCatalogEntry"; catalogId: string; entryId: string; patch: { label?: string; meta?: Record; }; } | { type: "addCatalogEntry"; catalogId: string; entry: EditorCatalogEntry; } | { type: "removeCatalogEntry"; catalogId: string; entryId: string; } | { type: "addCatalog"; id: string; label?: string; schema?: ParamSchema; } | { type: "removeCatalog"; id: string; } | { type: "setCatalogSchema"; id: string; schema: ParamSchema; label?: string; } | { type: "remove"; id: string; } | { type: "removeMany"; ids: readonly string[]; } | { type: "duplicate"; ids: readonly string[]; offset?: EditorVec3; } | { type: "addFragment"; fragment: EditorDocument; offset?: EditorVec3; } | { type: "importDocument"; document: EditorDocument; } | { type: "importJson"; json: string; } | { type: "replaceDocument"; document: EditorDocument; } | { type: "setTerrain"; terrain: EditorTerrain; } | { type: "sculptTerrain"; delta: TerraformDelta; } | { type: "paintTerrain"; delta: SurfaceDelta; } | { type: "setTerrainLayers"; layers: readonly TerrainMaterialLayer[]; } | { type: "blendTerrain"; delta: WeightDelta; } | { type: "clearTerrain"; } | { type: "setMinimapBake"; minimap: EditorMinimapBake; } | { type: "setBake"; bake: EditorBake; } /** * Replace the scene-document environment/lighting bag. Pass `undefined` to clear authored sky/fog * so world.ts fallbacks apply again. The lighting workspace writes the full merged bag so * undo restores the previous snapshot as one step (use `coalesce` while scrubbing sliders). */ | { type: "setEnvironment"; environment: EditorEnvironment | undefined; } | { type: "setSimulation"; simulation: EditorSimulation | undefined; } | { type: "convertScatterToObjects"; pathId: string; markers: readonly EditorMarker[]; } | { type: "createPrefab"; id: string; name: string; ids: readonly string[]; } | { type: "insertPrefab"; prefabId: string; at: EditorVec3; instanceId?: string; } | { type: "detachPrefabInstance"; instanceId: string; } | { type: "deletePrefab"; prefabId: string; } | { type: "setPrefabStaticBake"; prefabId: string; bake: StaticPrefabBake | null; } | { type: "createCollection"; id: string; name: string; memberIds?: readonly string[]; } | { type: "renameCollection"; id: string; name: string; } | { type: "deleteCollection"; id: string; } | { type: "setCollectionMembers"; id: string; memberIds: readonly string[]; } | { type: "addToCollection"; id: string; ids: readonly string[]; } | { type: "removeFromCollection"; id: string; ids: readonly string[]; } | { type: "setCollectionFlags"; id: string; patch: { color?: string; locked?: boolean; visible?: boolean; }; } | { /** * Per-object lock/visibility flags on placeables. `locked: false` / `hidden: false` clear the * field so the document stays compact; collection locks are unchanged. */ type: "setObjectFlags"; ids: readonly string[]; patch: { locked?: boolean; hidden?: boolean; }; } | { type: "selectCollection"; id: string; } | { type: "batchSetProperties"; ids: readonly string[]; patch: { color?: string; label?: string; meta?: Record; }; } | { type: "upsertMaterialAsset"; asset: MaterialAsset; } | { type: "removeMaterialAsset"; id: string; } | { type: "assignMaterialAsset"; ids: readonly string[]; materialId: string; selector: MaterialSelector; } | { type: "clearMaterialAssets"; ids: readonly string[]; } | { type: "assignMaterial"; ids: readonly string[]; materialId: string; } | { type: "addGridLayer"; layer: EditorGridLayer; } | { type: "removeGridLayer"; id: string; } | { type: "setGridLayer"; id: string; patch: Partial>; } | { type: "paintGridCells"; id: string; cells: readonly EditorGridCellEdit[]; } | { type: "fillGridRect"; id: string; col0: number; row0: number; col1: number; row1: number; value: string; } | { type: "floodFillGrid"; id: string; col: number; row: number; value: string; } | { type: "resizeGridLayer"; id: string; cols: number; rows: number; } | { type: "setUiPanel"; id: string; patch: Partial; } | { type: "removeUiPanel"; id: string; } | { type: "setUi"; ui: EditorUiDocument | undefined; } | { type: "undo"; } | { type: "redo"; }; /** Per-dispatch options; `coalesce` merges consecutive same-key edits into one undo step. */ export interface EditorDispatchOptions { coalesce?: string; } /** The document plus current selection at a point in editor history. */ export interface EditorSessionState { document: EditorDocument; selection: string[]; } /** Stateful, undoable handle for driving scene edits from UI or an MCP agent. */ export interface EditorSession { getState(): EditorSessionState; subscribe(listener: (state: EditorSessionState) => void): () => void; dispatch(command: EditorCommand, options?: EditorDispatchOptions): EditorSessionState; /** Stage a command batch, then commit one undo step and notification; failures leave all state intact. */ transaction(commands: readonly EditorCommand[]): EditorTransactionResult; exportJson(pretty?: boolean): string; canUndo(): boolean; canRedo(): boolean; } /** Atomic command-batch outcome; a failure identifies the zero-based command index. */ export type EditorTransactionResult = { ok: true; state: EditorSessionState; changed: boolean; } | { ok: false; error: string; commandIndex?: number; }; /** Creates an editor session with undo/redo history seeded from an initial document. * Environment commands validate and copy their candidate bag before publishing state or history. * @internal */ export declare function createEditorSession(initial: EditorDocument, historyLimit?: number, validateDocument?: (document: EditorDocument) => void): EditorSession; /** Compact snapshot of a session state — counts, selection, and the selected object. * @internal */ export declare function summarizeEditorSession(state: EditorSessionState): { markers: number; volumes: number; paths: number; annotations: number; selection: string[]; selectedMarker?: EditorMarker; selectedVolume?: EditorVolume; };