import { type MountCrowdyStudioOptions } from '../mount.js'; import type { CrowdyStudioController, CrowdyStudioPlayerCompute, CrowdyStudioPlayerWallet } from '../controller.js'; import type { CrowdyStudioProjectProvider } from '../models.js'; import type { CrowdyAgentMode, CrowdyAgentPreemptionReason, CrowdyStudioAgentController, CrowdyStudioAgentTransportV1 } from '../../crowdy-agent/index.js'; import type { AgentControlLeaseManager, AgentControlLeaseManagerOptionsV1, PlayerHostAdapterV1 } from '../../player-host/index.js'; import type { PlayerCodeGridBounds, PlayerCodeHostCall, PlayerCodePresentation } from '../../player-runtime/player-code-broker.js'; import { type CrowdyStudioEmbedDockStorage } from './dock.js'; import type { CrowdyStudioTextHud } from './hud-layer.js'; export type CrowdyStudioEmbedDisplayMode = 'docked' | 'fullscreen'; /** * The studio-facing domain services the embed needs. `CrowdyClient` * satisfies this structurally, so most games pass their client directly. */ export interface CrowdyStudioEmbedServices { crowdyStudio: CrowdyStudioProjectProvider; playerCompute: CrowdyStudioPlayerCompute; playerWallet?: CrowdyStudioPlayerWallet; /** Production agent transport; omission keeps the agent fail-closed/hidden. */ crowdyStudioAgent?: CrowdyStudioAgentTransportV1; } export interface CrowdyStudioEmbedTargetPermission { canWrite: boolean; canRun: boolean; } export interface CrowdyStudioEmbedTargetPermissions { SERVER: CrowdyStudioEmbedTargetPermission; CLIENT: CrowdyStudioEmbedTargetPermission; } export interface CrowdyStudioEmbedHandle { readonly api: 'crowdy-studio'; readonly controller: CrowdyStudioController; readonly agent: CrowdyStudioAgentController | null; readonly controlLeaseManager: AgentControlLeaseManager | null; destroy(): void; } export interface CrowdyStudioEmbedAgentSessionOptions { mode?: CrowdyAgentMode; providerDataConsent?: boolean; /** Prefixes the generated per-session idempotency key. */ idempotencyKeyPrefix?: string; } /** Static, game-lifetime configuration for the embed shell. */ export interface CrowdyStudioEmbedOptions { client: CrowdyStudioEmbedServices; appId: string | (() => string); /** Header title. Defaults to "Crowdy Studio". */ title?: string; /** Game name used in the screen-reader description of the panel. */ gameName?: string; /** * Keyboard code that closes the studio from chrome (not from text entry). * Defaults to `KeyM` to match the common open keybind; `null` disables the * key entirely. Escape always closes. */ closeKeyCode?: string | null; agentSession?: CrowdyStudioEmbedAgentSessionOptions; controlGate?: AgentControlLeaseManagerOptionsV1; onLocalPreempt?(reason: CrowdyAgentPreemptionReason): void; /** * Suppress gameplay input and return a restoration callback. Used only by * the narrow-screen modal; the desktop dock remains non-modal. */ suppressGameplayInput?(): () => void; /** Re-measure the game canvas and HUD after dock geometry changes. */ onLayoutChange?(): void; onAgentMounted?(handle: CrowdyStudioEmbedHandle): void; onAgentUnavailable?(message: string): void; onAgentUnmounted?(): void; /** Called after the panel closes for any reason (Escape, key, close()). */ onClosed?(): void; dockStorage?: CrowdyStudioEmbedDockStorage | null; /** Browser-regression-only fault/config injection; never set by a game. */ runtimeOverrides?: Partial; } /** Per-open context: the grid the player is editing and its capabilities. */ export interface CrowdyStudioEmbedContext { gridId: string; /** Chunk AABB; required to run CLIENT projects. */ grid?: PlayerCodeGridBounds; targetPermissions: CrowdyStudioEmbedTargetPermissions; /** Optional provenance note rendered under the permission cards. */ permissionsNote?: string; /** Same-origin glue worker URL; required to run CLIENT projects. */ workerUrl?: string; /** Allow-listed world reads/writes for CLIENT projects. */ onHostCall?(call: PlayerCodeHostCall): Promise; /** Text-only HUD sink; enables the drawer HUD preview when provided. */ hud?: CrowdyStudioTextHud; /** Custom presentation routing; defaults to `hud` when omitted. */ onPresentation?(presentation: PlayerCodePresentation): void; /** Game Play adapter; with `client.crowdyStudioAgent` enables the agent. */ playerHost?: PlayerHostAdapterV1; } /** * Responsive game shell around CrowdyJS's project-first Crowdy Studio. * Desktop uses a resizable right dock; narrow screens use a focus-trapped * modal. Construct once per game and `toggle(context)` per open. */ export declare class CrowdyStudioEmbed { private readonly options; private root; private mountElement; private statusElement; private drawerElement; private drawerButton; private handle; private context; private previousFocus; private restoreGameplayInput; private unmountHudPreview; private mountGeneration; private displayMode; private readonly dock; constructor(options: CrowdyStudioEmbedOptions); get open(): boolean; get modal(): boolean; get mode(): CrowdyStudioEmbedDisplayMode | null; toggle(context: CrowdyStudioEmbedContext): void; destroy(): void; close(): void; private show; /** * Single compact header row: title, context pill, on-demand Context drawer * toggle, Close. Project context and permission details live in the drawer * so every workflow starts with maximum studio space. */ private header; /** * On-demand context drawer: grid context, effective permissions, and (when * a HUD sink is supplied) a lazily mounted HUD preview. Hidden by default; * toggled from the header. */ private drawer; private toggleDrawer; private mountStudio; /** Assemble mount options from the game client + per-open context. */ private mountSdkStudio; private currentAppId; private agentIdempotencyKey; private presentationSource; private accessibleDescription; private shortcutHint; private closeKeyLabel; private closeKeyCode; private readonly viewportResize; private updateDisplayMode; private enterModalMode; private leaveModalMode; private applyDockWidth; private clearDockWidth; private readonly keyDown; private readonly documentKeyDown; private readonly captureEscape; private handleDialogKey; private trapTab; private readonly stopKeyboardEvent; private readonly documentKeyUp; private readonly keepFocusInside; } /** Convenience factory mirroring the class constructor. */ export declare function createCrowdyStudioEmbed(options: CrowdyStudioEmbedOptions): CrowdyStudioEmbed; //# sourceMappingURL=panel.d.ts.map