export declare function asciiBytes(s: string): Uint8Array; export declare function utf8Bytes(s: string): Uint8Array; export type Msgish = { readonly kind: string; }; import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.js"; export declare function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor; /** Cooperative cancellation capability supplied by generated service hosts. */ export interface ServiceCancellation { /** True after Cmd.cancel or the operation deadline requests cancellation. */ readonly cancelled: () => boolean; /** Throw a boundary-tagged cancellation error when cancellation was requested. */ readonly throwIfCancelled: () => void; } export type TimestampKind = M extends Msgish ? { [K in Exclude]-?: M[K] extends number ? [Exclude] extends [K] ? M["kind"] : never : never; }[Exclude] : never; export type BytesKind = M extends Msgish ? { [K in Exclude]-?: M[K] extends Uint8Array ? [Exclude] extends [K] ? M["kind"] : never : never; }[Exclude] : never; export type ServiceKind = M extends Msgish ? { [K in Exclude]-?: M[K] extends P ? P extends M[K] ? [Exclude] extends [K] ? M["kind"] : never : never : never; }[Exclude] : never; export interface ServiceRoute { readonly key?: string; readonly ok: ServiceKind; readonly err: BytesKind; } export interface ServiceStreamRoute extends ServiceRoute { readonly channelKey: number; readonly event: ChannelEventKind; } export type EmptyKind = M extends Msgish ? [Exclude] extends [never] ? M["kind"] : never : never; export type FetchedKind = M extends Msgish ? { [K in Exclude]-?: M[K] extends Uint8Array ? Exclude extends infer O ? O extends keyof M ? M[O] extends number ? [Exclude] extends [never] ? M["kind"] : never : never : never : never : never; }[Exclude] : never; export interface EnvMsg { readonly env: string; readonly msg: BytesKind; } export type AudioState = "loaded" | "position" | "completed" | "failed" | "rejected" | "spectrum"; export type AudioEventArm = { readonly state: AudioState; readonly positionMs: number; readonly durationMs: number; readonly playing: boolean; readonly buffering: boolean; readonly bands: Uint8Array; }; export type AudioEventKind = M extends Msgish ? [Exclude] extends [keyof AudioEventArm] ? [keyof AudioEventArm] extends [Exclude] ? M extends Msgish & AudioEventArm ? [AudioState] extends [M["state"]] ? M["kind"] : never : never : never : never : never; export type VideoState = "loaded" | "position" | "completed" | "failed" | "rejected"; export type VideoEventArm = { readonly state: VideoState; readonly positionMs: number; readonly durationMs: number; readonly playing: boolean; readonly buffering: boolean; readonly width: number; readonly height: number; }; export type VideoEventKind = M extends Msgish ? [Exclude] extends [keyof VideoEventArm] ? [keyof VideoEventArm] extends [Exclude] ? M extends Msgish & VideoEventArm ? [VideoState] extends [M["state"]] ? M["kind"] : never : never : never : never : never; export type ImageState = "loaded" | "rejected" | "not_found" | "io_failed" | "connect_failed" | "tls_failed" | "protocol_failed" | "timed_out" | "http_status" | "cancelled" | "too_large" | "unsupported" | "decode_failed" | "registry_full" | "alloc_failed"; export type ImageEventArm = { readonly id: number; readonly state: ImageState; readonly width: number; readonly height: number; readonly status: number; }; export type ImageEventKind = M extends Msgish ? [Exclude] extends [keyof ImageEventArm] ? [keyof ImageEventArm] extends [Exclude] ? M extends Msgish & ImageEventArm ? [ImageState] extends [M["state"]] ? M["kind"] : never : never : never : never : never; export type ChannelState = "data" | "closed" | "rejected"; export type ChannelEventArm = { readonly key: number; readonly state: ChannelState; readonly bytes: Uint8Array; readonly droppedPending: number; readonly droppedTotal: number; }; export type ChannelEventKind = M extends Msgish ? [Exclude] extends [keyof ChannelEventArm] ? [keyof ChannelEventArm] extends [Exclude] ? M extends Msgish & ChannelEventArm ? [ChannelState] extends [M["state"]] ? M["kind"] : never : never : never : never : never; export interface ChannelRoute { readonly event: ChannelEventKind; } export type AudioCaptureSource = "microphone" | "system"; export type AudioCaptureState = "started" | "data" | "failed" | "stopped" | "rejected"; export type AudioCaptureSampleRate = 16000 | 24000 | 48000; export type AudioCaptureChannels = 1 | 2; export interface AudioCaptureSpec { readonly source: AudioCaptureSource; readonly sampleRate?: AudioCaptureSampleRate; readonly channels?: AudioCaptureChannels; } export type AudioCaptureEventArm = { readonly key: number; readonly state: AudioCaptureState; readonly source: AudioCaptureSource; readonly sampleRate: number; readonly channels: number; readonly timestampMs: number; readonly frames: number; readonly pcm: Uint8Array; readonly droppedPending: number; readonly droppedTotal: number; }; export type AudioCaptureEventKind = M extends Msgish ? [Exclude] extends [keyof AudioCaptureEventArm] ? [keyof AudioCaptureEventArm] extends [Exclude] ? M extends Msgish & AudioCaptureEventArm ? [AudioCaptureState] extends [M["state"]] ? [AudioCaptureSource] extends [M["source"]] ? M["kind"] : never : never : never : never : never : never; export interface AudioCaptureRoute { readonly event: AudioCaptureEventKind; } export type PtyState = "output" | "exit"; export type PtyExitReason = "exited" | "signaled" | "cancelled" | "rejected" | "spawn_failed"; export type PtyEventArm = { readonly key: Uint8Array; readonly state: PtyState; readonly bytes: Uint8Array; readonly code: number; readonly reason: PtyExitReason; readonly signal: number; readonly droppedWrites: number; }; export type PtyEventKind = M extends Msgish ? [Exclude] extends [keyof PtyEventArm] ? [keyof PtyEventArm] extends [Exclude] ? M extends Msgish & PtyEventArm ? [PtyState] extends [M["state"]] ? [PtyExitReason] extends [M["reason"]] ? M["kind"] : never : never : never : never : never : never; export interface PtyRoute { readonly key?: string; readonly cols?: number; readonly rows?: number; readonly term?: string; readonly event: PtyEventKind; } export type HostScalar = number | boolean | Uint8Array; export type HostRecord = { readonly [field: string]: HostScalar; }; export interface RequestRoute { readonly key?: string; readonly ok: BytesKind; readonly err: BytesKind; } export interface WriteRoute { readonly key?: string; readonly ok: EmptyKind; readonly err: BytesKind; } export interface FileReadStreamRoute { readonly key?: string; readonly chunk: BytesKind; readonly done: TimestampKind; readonly err: BytesKind; } export interface FileStatArm { readonly exists: boolean; readonly size: number; readonly mtimeMs: number; } export type FileStatKind = M extends Msgish ? [Exclude] extends [keyof FileStatArm] ? [keyof FileStatArm] extends [Exclude] ? M extends Msgish & FileStatArm ? M["kind"] : never : never : never : never; export interface FileStatRoute { readonly key?: string; readonly ok: FileStatKind; readonly err: BytesKind; } export interface StoreScanOptions { readonly limit?: number; readonly after?: string | Uint8Array; } export interface DbText { readonly __dbText: true; readonly bytes: ReadonlyArray; } export declare function dbText(bytes: Uint8Array): DbText; export type DbValue = null | number | string | Uint8Array | boolean | DbText; export type DbStatement = readonly [sql: string, params: ReadonlyArray]; export interface DbRowsRoute { readonly key?: string; readonly page: BytesKind; readonly done: EmptyKind; readonly err: BytesKind; } export interface TypedRowsRoute extends DbRowsRoute { readonly __row?: Row; } export interface TypedDbStatement { readonly sql: string; readonly params: ReadonlyArray; readonly __typedDbStatement: true; } export interface FetchRoute { readonly key?: string; readonly ok: FetchedKind; readonly err: BytesKind; } export interface FetchStreamRoute { readonly key?: string; readonly line: BytesKind; readonly ok: TimestampKind; readonly err: BytesKind; } export interface SpawnRoute { readonly key?: string; readonly stdin?: Uint8Array; readonly line?: BytesKind; readonly exit: TimestampKind; readonly err: BytesKind; } export interface SpawnCollectRoute { readonly key?: string; readonly stdin?: Uint8Array; readonly collect: true; readonly exit: FetchedKind; readonly err: BytesKind; } export interface AudioSource { readonly path?: Uint8Array; readonly url?: Uint8Array; readonly cachePath?: Uint8Array; readonly expectedBytes?: number; } export interface AudioRoute { readonly event: AudioEventKind; } export interface VideoSource { readonly surface: number; readonly path?: Uint8Array; readonly url?: Uint8Array; readonly autoplay?: boolean; readonly loop?: boolean; readonly muted?: boolean; } export interface VideoRoute { readonly event: VideoEventKind; } export interface ImageSource { readonly path?: Uint8Array; readonly url?: Uint8Array; readonly cachePath?: Uint8Array; readonly expectedBytes?: number; } export interface ImageRoute { readonly event: ImageEventKind; } export type FetchMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD"; export interface FetchSpec { readonly url: Uint8Array; readonly method?: FetchMethod; readonly headers?: { readonly [name: string]: string | Uint8Array; }; readonly body?: Uint8Array; readonly timeoutMs?: number; } export interface FetchStreamSpec extends FetchSpec { readonly maxLineBytes?: number; } export interface NotificationSpec { readonly id?: Uint8Array; readonly title: Uint8Array; readonly subtitle?: Uint8Array; readonly body?: Uint8Array; readonly actionLabel?: Uint8Array; readonly actionCommand?: Uint8Array; } export type LocalTimeStyle = "date" | "time" | "datetime"; export type Cmd = { readonly op: "none"; } | { readonly op: "persist"; } | { readonly op: "now"; readonly msgKind: string; } | { readonly op: "host"; readonly name: string; readonly args: readonly number[]; } | { readonly op: "host_bytes"; readonly name: string; readonly payload: Uint8Array; } | { readonly op: "request"; readonly name: string; readonly key: string; readonly okKind: string; readonly errKind: string; readonly typedService: boolean; readonly payload: Uint8Array; } | { readonly op: "service_stream_request"; readonly name: string; readonly key: string; readonly okKind: string; readonly errKind: string; readonly typedService: true; readonly channelKey: number; readonly eventKind: string; readonly maxPending: number; readonly payload: Uint8Array; } | { readonly op: "cancel"; readonly key: string; } | { readonly op: "read_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; } | { readonly op: "write_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; readonly bytes: Uint8Array; } | { readonly op: "append_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; readonly bytes: Uint8Array; } | { readonly op: "stat_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; } | { readonly op: "delete_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; } | { readonly op: "read_file_stream"; readonly key: string; readonly chunkKind: string; readonly doneKind: string; readonly errKind: string; readonly path: Uint8Array; } | { readonly op: "write_file_stream"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; } | { readonly op: "write_file_chunk"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly bytes: Uint8Array; } | { readonly op: "write_file_close"; readonly key: string; readonly okKind: string; readonly errKind: string; } | { readonly op: "store_set"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly storeKey: string; readonly bytes: Uint8Array; } | { readonly op: "store_get" | "store_delete"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly storeKey: string; } | { readonly op: "store_scan"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly prefix: string; readonly limit: number; readonly after: string | Uint8Array; } | { readonly op: "store_set_many"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly entries: ReadonlyArray; } | { readonly op: "db_query"; readonly key: string; readonly pageKind: string; readonly doneKind: string; readonly errKind: string; readonly sql: string; readonly params: ReadonlyArray; } | { readonly op: "db_exec"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly statements: ReadonlyArray; } | { readonly op: "fetch"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly method: FetchMethod; readonly timeoutMs: number; readonly url: Uint8Array; readonly headers: readonly { readonly name: string; readonly value: string | Uint8Array; }[]; readonly body: Uint8Array; } | { readonly op: "fetch_stream"; readonly key: string; readonly lineKind: string; readonly okKind: string; readonly errKind: string; readonly method: FetchMethod; readonly timeoutMs: number; readonly maxLineBytes: number; readonly url: Uint8Array; readonly headers: readonly { readonly name: string; readonly value: string | Uint8Array; }[]; readonly body: Uint8Array; } | { readonly op: "clip_write"; readonly bytes: Uint8Array; } | { readonly op: "clip_read"; readonly key: string; readonly okKind: string; readonly errKind: string; } | { readonly op: "show_notification"; readonly id: Uint8Array; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array; readonly actionLabel: Uint8Array; readonly actionCommand: Uint8Array; } | { readonly op: "delay"; readonly key: string; readonly afterMs: number; readonly msgKind: string; } | { readonly op: "spawn"; readonly key: string; readonly lineKind: string; readonly exitKind: string; readonly errKind: string; readonly collect: boolean; readonly argv: readonly Uint8Array[]; readonly stdin: Uint8Array; } | { readonly op: "audio_play"; readonly key: string; readonly eventKind: string; readonly path: Uint8Array; readonly url: Uint8Array; readonly cachePath: Uint8Array; readonly expectedBytes: number; } | { readonly op: "audio_ctl"; readonly key: string; readonly verb: "pause" | "resume" | "stop" | "seek" | "volume"; readonly value: number; } | { readonly op: "video_load"; readonly key: string; readonly eventKind: string; readonly surface: number; readonly path: Uint8Array; readonly url: Uint8Array; readonly autoplay: boolean; readonly loop: boolean; readonly muted: boolean; } | { readonly op: "video_ctl"; readonly key: string; readonly verb: "play" | "pause" | "stop" | "seek" | "volume" | "muted" | "loop"; readonly value: number; } | { readonly op: "window_show"; readonly label: string; } | { readonly op: "window_hide"; readonly label: string; } | { readonly op: "dock_presence"; readonly visible: boolean; } | { readonly op: "quit_app"; } | { readonly op: "image_load"; readonly id: number; readonly eventKind: string; readonly path: Uint8Array; readonly url: Uint8Array; readonly cachePath: Uint8Array; readonly expectedBytes: number; } | { readonly op: "image_cancel"; readonly id: number; } | { readonly op: "image_unregister"; readonly id: number; } | { readonly op: "channel_open"; readonly key: number; readonly eventKind: string; readonly maxPending: number; } | { readonly op: "channel_close"; readonly key: number; } | { readonly op: "audio_capture_start"; readonly key: number; readonly source: AudioCaptureSource; readonly sampleRate: number; readonly channels: number; readonly eventKind: string; } | { readonly op: "audio_capture_stop"; readonly key: number; } | { readonly op: "pty_spawn"; readonly key: string; readonly eventKind: string; readonly cols: number; readonly rows: number; readonly term: string; readonly argv: readonly Uint8Array[]; } | { readonly op: "pty_write"; readonly key: string; readonly bytes: Uint8Array; } | { readonly op: "pty_resize"; readonly key: string; readonly cols: number; readonly rows: number; } | { readonly op: "pty_kill"; readonly key: string; } | { readonly op: "batch"; readonly cmds: readonly Cmd[]; }; export declare function hostRecordBytes(payload: HostRecord): Uint8Array; export declare function serviceConcat(parts: readonly Uint8Array[]): Uint8Array; export declare function serviceBoolBytes(value: boolean): Uint8Array; export declare function serviceF64Bytes(value: number): Uint8Array; export declare function serviceI64Bytes(value: number): Uint8Array; export declare function serviceBytes(value: Uint8Array): Uint8Array; export declare function serviceEnumBytes(index: number): Uint8Array; export declare function serviceUnionBytes(index: number): Uint8Array; export declare function serviceOptionalBytes(value: Uint8Array | null): Uint8Array; export declare function serviceSliceBytes(values: readonly Uint8Array[]): Uint8Array; declare function hostCmd(name: string, payload: Uint8Array | HostRecord): Cmd; declare function hostCmd(name: string, ...args: readonly number[]): Cmd; declare function fetchCmd(spec: FetchSpec, route: FetchRoute): Cmd; declare function fetchCmd(spec: FetchStreamSpec, route: FetchStreamRoute): Cmd; export declare const Cmd: { none: Cmd; persist(): Cmd; now(msgKind: TimestampKind): Cmd; host: typeof hostCmd; request(name: string, payload: Uint8Array | HostRecord, route: RequestRoute): Cmd; serviceRequest(name: string, payload: Uint8Array, route: ServiceRoute): Cmd; serviceStreamRequest(name: string, channelKey: number, payload: Uint8Array, route: ServiceStreamRoute, maxPending: number): Cmd; cancel(key: string): Cmd; readFile(path: Uint8Array, route: RequestRoute): Cmd; writeFile(path: Uint8Array, bytes: Uint8Array, route: WriteRoute): Cmd; appendFile(path: Uint8Array, bytes: Uint8Array, route: WriteRoute): Cmd; statFile(path: Uint8Array, route: FileStatRoute): Cmd; deleteFile(path: Uint8Array, route: WriteRoute): Cmd; readFileStream(path: Uint8Array, route: FileReadStreamRoute): Cmd; writeFileStream(key: string, path: Uint8Array, route: WriteRoute): Cmd; writeFileChunk(key: string, bytes: Uint8Array, route: WriteRoute): Cmd; writeFileClose(key: string, route: WriteRoute): Cmd; store: { set(storeKey: string, bytes: Uint8Array, route: WriteRoute): Cmd; get(storeKey: string, route: RequestRoute): Cmd; delete(storeKey: string, route: WriteRoute): Cmd; scan(prefix: string, options: StoreScanOptions, route: RequestRoute): Cmd; setMany(entries: ReadonlyArray, route: WriteRoute): Cmd; }; credentials: { set(credentialKey: string, secret: Uint8Array, route: WriteRoute): Cmd; get(credentialKey: string, route: RequestRoute): Cmd; delete(credentialKey: string, route: WriteRoute): Cmd; }; db: { query(sql: string, params: ReadonlyArray, route: DbRowsRoute): Cmd; exec(statements: ReadonlyArray, route: WriteRoute): Cmd; }; fetch: typeof fetchCmd; clipboardWrite(bytes: Uint8Array): Cmd; clipboardRead(route: RequestRoute): Cmd; showNotification(spec: NotificationSpec): Cmd; openExternalUrl(url: Uint8Array): Cmd; revealPath(path: Uint8Array): Cmd; formatLocalTime(timestampMs: number, style: LocalTimeStyle, route: RequestRoute): Cmd; delay(key: string, ms: number, msgKind: TimestampKind): Cmd; spawn(argv: readonly Uint8Array[], route: SpawnRoute | SpawnCollectRoute): Cmd; audioPlay(key: string, source: AudioSource, route: AudioRoute): Cmd; audioPause(key: string): Cmd; audioResume(key: string): Cmd; audioStop(key: string): Cmd; audioSeek(key: string, ms: number): Cmd; audioSetVolume(key: string, volume: number): Cmd; videoLoad(key: string, source: VideoSource, route: VideoRoute): Cmd; videoPlay(key: string): Cmd; videoPause(key: string): Cmd; videoStop(key: string): Cmd; videoSeek(key: string, ms: number): Cmd; videoSetVolume(key: string, volume: number): Cmd; videoSetMuted(key: string, muted: boolean): Cmd; videoSetLoop(key: string, loop: boolean): Cmd; showWindow(label: string): Cmd; hideWindow(label: string): Cmd; setDockPresence(visible: boolean): Cmd; launchAtLoginStatus(route: RequestRoute): Cmd; setLaunchAtLogin(enabled: boolean, route: RequestRoute): Cmd; quitApp(): Cmd; imageLoad(id: number, source: ImageSource, route: ImageRoute): Cmd; imageCancel(id: number): Cmd; imageUnregister(id: number): Cmd; channelOpen(key: number, route: ChannelRoute): Cmd; channelClose(key: number): Cmd; audioCaptureStart(key: number, spec: AudioCaptureSpec, route: AudioCaptureRoute): Cmd; audioCaptureStop(key: number): Cmd; ptySpawn(argv: readonly Uint8Array[], route: PtyRoute): Cmd; ptyWrite(key: string, bytes: Uint8Array): Cmd; ptyResize(key: string, cols: number, rows: number): Cmd; ptyKill(key: string): Cmd; batch(cmds: readonly Cmd[]): Cmd; }; export type Sub = { readonly op: "none"; } | { readonly op: "timer"; readonly key: string; readonly everyMs: number; readonly msgKind: string; } | { readonly op: "db_live"; readonly key: string; readonly pageKind: string; readonly doneKind: string; readonly errKind: string; readonly sql: string; readonly params: ReadonlyArray; readonly tables: readonly string[]; } | { readonly op: "batch"; readonly subs: readonly Sub[]; }; export declare const Sub: { none: Sub; timer(key: string, everyMs: number, msgKind: TimestampKind): Sub; batch(subs: readonly Sub[]): Sub; }; export {};