import { s as JsonObject } from "./rng-BsXZg3D6.js"; //#region src/core/editor-switch.d.ts /** Where a camera is and what it looks at, in world space. */ interface CameraPose { position: [number, number, number]; target: [number, number, number]; } /** What the editor module needs to know to take over the page. */ interface EditorOpenOptions { /** The authored scene to edit. */ scene: JsonObject; /** Start the edit view here (continuity out of the running game). */ camera?: CameraPose; /** Called when the editor hands the page back — boot the game from `working`. */ play(working: JsonObject, camera?: CameraPose): void | Promise; /** * Called when the user leaves the editor by the ✕ — with the scene as the * editor has it. * * It carries the working scene for the same reason ▶ does: you have been * editing it, and half the time you have SAVED it. Handing back the scene the * page booted with instead would show you your own edit disappearing, which * is what it did until saving stopped reloading the page and made the * difference visible. `undefined` (an editor that does not offer one) leaves * the caller to fall back to whatever it opened with. */ exit?(working?: JsonObject): void | Promise; /** Persist edits (from `editor.save`). Omitted: no save button. */ save?(working: JsonObject): void | Promise; /** Asset-library search (from `editor.library`). Omitted: no 📚 buttons. */ library?: LibrarySearch; } /** * How a page opens its editor. * * Default: `import('incanto/editor')`, so `editor: true` is all a game needs. * Apps that alias the engine to source (the examples, the playground) map that * specifier themselves, or pass `open` and skip the resolution entirely. */ interface EditorSwitchOptions { open?(opts: EditorOpenOptions): void | Promise; /** Persist edits. Omitted: the editor's save button is hidden. */ save?(working: JsonObject): void | Promise; /** * Search the agent8 asset library from inside the game's editor. * * `true` means "my dev server serves `/api/library`" — add * `incantoLibrary()` from `incanto/vite` and this is the whole opt-in. A * function is your own transport. Omitted: the 📚 buttons are not rendered, * because a page with no catalog should show no button rather than one that * fails when pressed. */ library?: true | LibrarySearch; /** * The NEW game handle, after the editor's ▶ has rebooted into one. * * `reboot()` built a replacement and dropped it, so after one ✎→▶ round trip * the app's `game` referred to something that no longer existed: its * `dispose()` tore down the dead one and left the live one running, and its * `openEditor()` booted a third game on top of it. Both are inert now — a * stale handle does nothing — but an app that wants to keep working needs the * new one: * * ```ts * let game = await createGame3D({ * editor: { onReboot: (next) => { game = next; } }, * … * }); * ``` */ onReboot?(game: { dispose(): void; }): void; } /** Search the asset catalog: the shape the editor's browser consumes. */ type LibrarySearch = (query: { tags: string[]; keyword?: string; page?: number; limit?: number; }, token?: string) => Promise<{ items: unknown[]; page: number; hasNext: boolean; total?: number; }>; //#endregion export { EditorSwitchOptions as t };