import { default as React } from 'react'; import { NotifyOptions } from '../context/TrayContext'; import { ScheduleOptions } from '../context/SchedulerContext'; import { XPClockApi } from '../context/ClockContext'; import { PrintJob } from '../context/PrintSpoolerContext'; import { FileNode } from '../types'; import { XPSnapshot } from '../snapshot'; import { XPEvent, XPEventListener } from '../events'; import { QQProfile } from '../data/qq/types'; import { LessonMode } from '../lesson/types'; import { RehearsalState, ScenarioDebugState } from '../devtools/rehearsalChannel'; import { FlagValue } from '../scenario/types'; /** Filesystem actuation from outside the desktop (#115). Paths are absolute. */ export interface XPFsApi { /** Read a file node's text content, or null if missing / not a text file. */ readFile: (path: string[]) => string | null; /** Set a file node's content (persists). */ writeFile: (path: string[], content: string) => void; /** Create a file/folder at path. `node.type` defaults to 'file'. */ createFile: (path: string[], node?: Partial) => void; /** Delete the file or folder at path. */ deleteFile: (path: string[]) => void; /** Return the raw node at path, or null. */ getNode: (path: string[]) => FileNode | null; /** Whether a node exists at path. */ exists: (path: string[]) => boolean; /** Persistently clear a node's `locked` flag. */ unlockNode: (path: string[]) => void; } /** Session control (#115). */ export interface XPSessionApi { login: (password?: string) => boolean; logout: () => void; shutdown: () => void; restart: () => void; /** Finish a `reload: 'manual'` power sequence. */ completePowerTransition: () => void; } /** Appearance control (#115). */ export interface XPAppearanceApi { setWallpaper: (idOrUrl: string) => void; setLanguage: (lang: string) => void; } /** A window as seen from outside the desktop. */ export interface XPWindowInfo { id: string; appId: string; title: string; isMinimized: boolean; isMaximized: boolean; } /** Window introspection + control (#115). */ export interface XPWindowsApi { list: () => XPWindowInfo[]; focus: (id: string) => void; minimize: (id: string) => void; maximize: (id: string) => void; restore: (id: string) => void; } /** * QQ Messenger actuation (#119) — lets a scenario/host drive the buddy chat: * open the client (or a specific chat), have a buddy come online, or push an * incoming message. Content otherwise flows from the culture package's `qq` * profile; `loadProfile` replaces it at runtime. */ export interface XPQQApi { /** Open the QQ client; with `buddyId`, also open (or focus) that chat window. */ open: (buddyId?: string) => string | null; /** Deliver a message with QQ typing/queueing; false until the buddy profile is loaded. */ sendMessage: (buddyId: string, text: string) => boolean; /** Whether the live QQ profile currently contains this buddy. */ hasBuddy: (buddyId: string) => boolean; /** Idempotently load the active culture's profile for host-driven rehearsal. */ ensureProfile: () => void; /** Bring a buddy online now (knock sound + tray blink + "上线了" balloon). */ bringOnline: (buddyId: string) => void; /** Replace the live QQ profile (buddies/groups/scripts) and restart the session. */ loadProfile: (profile: QQProfile) => void; } /** * Rehearsal / deterministic seek (#207) — the author's iteration-loop unlock. * Replays the scenario's canonical walkthrough prefix through the headless * solver to jump to any beat's exact state in a second, without replaying events * onto the bus (so no external side effects). Requires the scenario to declare a * `rehearsal.walkthrough`; the methods no-op / return false otherwise. */ export interface XPScenarioApi { /** Jump to a named beat's state. Returns false if the beat / walkthrough is unknown. */ seekTo: (beat: string) => boolean; /** Jump to a tape index (clamped; −1 = pristine start). */ seekToIndex: (index: number) => void; /** Step one beat back (re-solve the shorter prefix). */ stepBack: () => void; /** Step one beat forward. */ stepForward: () => void; /** Leave rehearsal and restore the pre-rehearsal live save. */ exitRehearsal: () => void; /** The current rehearsal cursor (active flag, index, tape length, named beats). */ getState: () => RehearsalState; /** Set one flag through the live scenario runtime. Returns false without a scenario. */ setFlag: (flag: string, value: FlagValue) => boolean; /** Inspect live flags, trigger fire budgets, and condition traces. */ getDebugState: () => ScenarioDebugState; } /** * Imperative handle exposed via `ref` on (#76, extended in #115): * lets the host drive the desktop programmatically (demos, tests, scenario * scripting). The five original top-level methods are kept for backward * compatibility; new capabilities are grouped by domain. */ export interface XPHandle { /** Open a registered app by id, optionally passing component props. */ openApp: (appId: string, props?: Record) => string | null; /** * Open a filesystem node by absolute path (resolves the right app). * This is a privileged host operation and does not show user password gates; * use the desktop or Explorer when emulating user navigation. */ openFile: (path: string[]) => string | null; /** * Follow a link out of the fiction to a real URL (#136). New tab by default; * pass `{ newTab: false }` to navigate the current tab. Emits `link:external`. */ openExternal: (url: string, opts?: { newTab?: boolean; }) => void; /** * Build a shareable permalink (`?open=…`) that reproduces `windowId` on a * fresh load (#136). Returns null for component-only windows (no source path) * or without a DOM. */ getShareUrl: (windowId: string) => string | null; /** Close a window by id. */ closeWindow: (id: string) => void; /** Show an XP dialog. */ showAlert: (title: string, message: string) => void; /** Clear all persisted desktop state (localStorage + IndexedDB) and reload. */ reset: () => void; /** Filesystem actuation. */ fs: XPFsApi; /** Session control. */ session: XPSessionApi; /** Appearance control. */ appearance: XPAppearanceApi; /** Window introspection + control. */ windows: XPWindowsApi; /** QQ Messenger actuation (#119). */ qq: XPQQApi; /** Instance-local virtual system clock (#275). */ clock: Pick; /** Data-driven virtual print spooler (#276). */ print: { addJob: (job: Omit & { submittedAt?: string; }) => void; updateJob: (id: string, updates: Partial) => void; removeJob: (id: string) => void; }; /** Play a named XP system sound. */ sound: { play: (name: string) => void; }; /** Pop an XP tray balloon notification (#118). Returns the notification id. */ notify: (options: NotifyOptions) => string; /** Inject an event onto the same bus `onEvent` and scenario triggers read. */ emit: (event: XPEvent) => void; /** * Schedule an event to fire after a delay or at a wall-clock deadline (#130). * Pending schedules persist per instance and fire on next load if the * deadline passed while the page was closed. Returns the schedule id. */ schedule: (options: ScheduleOptions) => string; /** Cancel a pending schedule by id (#130). */ cancelSchedule: (id: string) => void; /** * Start a guided lesson by id (#141) in `try` (default), `do`, or `watch` * mode. Returns false if no lesson with that id was registered via the * `lessons` prop. Emits `lesson:*` events; progress persists per instance. */ startLesson: (lessonId: string, mode?: LessonMode) => boolean; /** Stop the running lesson and clear its saved progress (#141). */ stopLesson: () => void; /** Rehearsal / deterministic seek over the scenario's walkthrough (#207). */ scenario: XPScenarioApi; /** Capture the full desktop state as a portable, versioned snapshot (#117). */ getSnapshot: () => XPSnapshot; /** * Replace this instance's state with a snapshot and reload to rehydrate. * Throws {@link XPSnapshotVersionError} for a missing/too-new version. */ loadSnapshot: (snapshot: XPSnapshot) => Promise; } /** Subscribes the host's onEvent callback to the bus. Renders nothing. */ export declare const XPEventBridge: React.FC<{ onEvent?: XPEventListener; }>; /** Wires the imperative handle to the live contexts. Renders nothing. */ export declare const XPImperativeApi: React.ForwardRefExoticComponent<{ storagePrefix?: string; } & React.RefAttributes>;