import { default as React } from 'react'; import { AppRegistryEntry, AppAssociation, AppLifecycle, JsonValue } from '../types'; import { AppMenu, AppRole } from '../os/contract'; /** * App authoring factory (#128). * * `defineApp()` turns a component into a fully-formed {@link AppRegistryEntry} * with sensible defaults, so a custom app is one typed call instead of a * hand-written object literal against several unwritten rules. */ /** * Props an app receives on restore. They are persisted to storage to rebuild * the window after a refresh, so they MUST be JSON-serializable — the * `JsonValue` constraint makes a non-serializable prop (function, element, * class instance) a COMPILE-TIME error instead of a silent refresh bug. */ export type SerializableProps = Record; /** Window sizing/behavior for a registered app. */ export interface AppWindowConfig { width?: number; height?: number; minWidth?: number; minHeight?: number; /** Initial position; omit to center. */ left?: number; top?: number; /** Only one instance may be open at a time. Default false. */ singleton?: boolean; isMaximized?: boolean; resizable?: boolean; } export interface DefineAppConfig { /** Unique app id (used to open the app and match filesystem `.app` fields). */ id: string; /** Fallback display name; prefer `nameKey` for i18n. */ name: string; /** i18n key for the window title; falls back to `name`. */ nameKey?: string; /** `XPIcon` id. Defaults to `'app_window'`. */ icon?: string; /** Restrict to culture ids (e.g. `['zh']`); omit for all cultures. */ locales?: string[]; /** Window size/behavior. Defaults to 400×300, non-singleton, resizable. */ window?: AppWindowConfig; /** Open/close/focus callbacks (runtime only — never persisted). */ lifecycle?: AppLifecycle; /** Make the app openable from a filesystem node whose `.app` equals `appField`. */ associations?: AppAssociation[]; /** Semantic implementation role selected indirectly by OS packages. */ role?: AppRole; /** Menu command data rendered by the active OS package. */ menus?: AppMenu[]; /** Runtime command sink for `menus`; receives the active window id. */ onMenuCommand?: (commandId: string, windowId: string) => void; /** * The app component. It may also receive an injected `windowId`. Its own * props (`TProps`) must be JSON-serializable (see {@link SerializableProps}). */ component: React.ComponentType; } /** * Wrap a component so the registry can restore it from persisted (`unknown`) * props. Exported for authors who build an {@link AppRegistryEntry} by hand and * want the same `unknown → props` cast the built-ins use. */ export declare const restoreApp:

>(Component: React.ComponentType

) => { (props: unknown): React.JSX.Element; displayName: string; }; /** * Define a desktop application in one typed call. * * @example * ```tsx * const HelloApp = defineApp({ * id: 'Hello', * name: 'Hello', * component: () =>

Hello from Windows XP!
, * }); * // * ``` */ export declare function defineApp>(config: DefineAppConfig): AppRegistryEntry;