import type { AppMsg, BoxProps, KuiMsg, Msg, EnterProp, GeneratedSpecProps, KuiNode, MenuItemInput, MenuItemRole, TextProps, } from './jsx-runtime.js'; export type { KuiNode, KuiElement, Msg, KuiMsg, AppMsg } from './jsx-runtime.js'; // The menu inputs live beside the other prop types, because `` // takes one; they are re-exported here because `Ctx.openMenu` takes one // too, and an app should not have to know which file a type sits in. export type { MenuItemInput, MenuItemRole, MenuInput, MenuBarInput } from './jsx-runtime.js'; export type { ColorToken, FamilyToken, LengthToken } from './jsx-runtime.js'; // -- events ------------------------------------------------------------------ // An event arrives as the message its handler declared // (docs/adr/0047-an-event-arrives-as-the-message-its-handler-declared.md): // a node that declares `onDrag={{ kind: 'pan' }}` hears a drag as // `{ kind: 'pan', drag: { phase, x, y, dx, dy, parent } }` — the message // as declared plus one field, named for the event, holding its data. The // envelope's `event` (`UiEvent.event`) says which event it was; the // payload no longer does. A `null` handler declares the behaviour and // names no message, so its events arrive as the field alone // (`{ drag: { … } }`), and `{}` for an event with no data. A message // that is not a map — a string, a number, a boolean, a list — is kept // under `tag`, even when the event has no data: `onClick: 'save'` is // heard as `{ tag: 'save' }` (decision 3), so every payload a node sends // is a map (`Arrived`). The shapes are `EVENTS` in // crates/kui-core/src/schema.rs, the table docs/props.md is generated from. // // Each event has three types: its data (`DragEvent`), the field that // carries it (`WithDrag`, an interface, so `extends` works), and a helper // that adds the field to the app's own message (`DragMsg`). Register // the messages as they arrive — `DragMsg<{ kind: 'pan' }>` — and the // handler prop (`onDrag`) takes them as declared, without the field: // `HandlerMsg`. A message registered without the field does not // fit the prop, so pairing a message with the wrong handler fails at the // node. A bare message with a field is registered as it arrives — // `DragMsg<{ tag: 'pan' }>` — and the prop takes `'pan'` back // (`Declared`). // // What has no node of its own — a resize, the window's keyboard, a // modifier change, the OS's documents — is declared where the window is // (ADR 0048): the root box's `windowEvents` group (`WindowEvents`), a // `windows` entry's `onWindow` / `onDismiss` (`WindowDecl`), and // ``. They arrive as the app's own messages too, so // `update` takes the registered messages and nothing else. /** The registered messages that carry the event field `W`, as a node * declares them: without the field, which the core writes in. Every * handler prop is typed as this — `onDrag` as `HandlerMsg`, * `onKey` as `HandlerMsg` — so only a registered message * with that field fits it. `W` may be a union, for a handler that * delivers several events; the `keyof` and the `Omit` distribute, so * each message keeps its own fields. Left un-augmented (no `KuiMsg`), * it is `Msg`, any plain data, as every prop is. */ export type HandlerMsg = KuiMsg extends { msg: infer M } ? Extract extends infer E ? E extends unknown ? Declared> : never : never : Msg; /** A message that is not a map — a string, a number, a boolean, a list. A * node may declare one; it arrives under `tag` (`Arrived`). */ export type BareMsg = string | number | boolean | readonly unknown[]; /** The message `M` a node declared, as the app hears it (ADR 0047, * decision 3): every node payload is a map. A map arrives as it is (with * the event's field added where the event has data); a bare message — * `onClick: 'save'`, a number, a list — arrives under `tag` beside that * field, `{ tag: 'save' }`, even when the event has no data; `null` * arrives as the field alone, or `{}`. This is what `update` is handed * and what `UiEvent.payload` is: an app registers the messages it * declares (`'save'`) and reads them as they arrive (`msg.tag`). It * leaves a map alone, so it is a no-op on an all-map union and on a * union already mapped through it. */ export type Arrived = M extends null | undefined ? { [field: string]: Msg } : M extends BareMsg ? { tag: M } : M; /** The other way round, for a handler prop: a registered message that is * `{ tag }` and nothing else once the event's field is left out may be * declared bare — `DragMsg<{ tag: 'pan' }>` registered, `onDrag="pan"` * declared — as well as spelled out. Anything else is declared as it is. */ export type Declared = M extends { tag: infer T extends BareMsg } ? [Exclude] extends [never] ? T | M : M : M; /** A rect in logical viewport px: a container's, the node's own. */ export interface EventRect { x: number; y: number; w: number; h: number; } /** What a click on a `cells` grid, or inside an `onKey` sink that draws * `role="line"` rows, can say beyond "it was clicked" — and, on a map * message, what it was made with. A plain click arrives as declared (a * bare message under `tag`), with no `click` field; this is there only * where the click can say more. */ export interface ClickEvent { /** On a `cells` grid: the cell under the pointer, clamped to the grid. */ cell?: { row: number; col: number }; /** Inside an `onKey` sink that draws `role="line"` rows: the line and * the byte in its text, as a drag carries them, whether the point is * within that line's own box, and the press's click count. */ line?: number; byte?: number; inside?: boolean; clicks?: number; /** On a map message: the modifiers held for a ⌘-click or a * Shift-click (backlog C101's facts). */ mods?: { shift: boolean; ctrl: boolean; alt: boolean; super: boolean }; /** On a map message: the key that made the click, Enter or Space. */ key?: 'enter' | 'space'; } /** A pointer-captured drag on an `onDrag` node. `x`/`y` are where the * pointer is; `dx`/`dy` are its displacement **from the press point**, in * every phase — `start` carries zero, a `move` how far the pointer is from * where it pressed, `end` the whole distance — so a handler sets * `value = start + dx` rather than summing deltas, and can commit from * `end` alone. Nothing is dropped under the click slop (3 px, measured * from the press): the first `move` already carries the whole distance. * `parent` is the container rect, so fractions need no geometry query. */ export interface DragEvent { phase: 'start' | 'move' | 'end'; x: number; y: number; dx: number; dy: number; parent: EventRect; /** On a `cells` grid: the cell under the pointer, clamped to the grid. */ cell?: { row: number; col: number }; /** Inside an `onKey` sink that draws `role="line"` rows: the line, the * byte in its text, whether the point is within that line's own box, * and the press's click count. */ line?: number; byte?: number; inside?: boolean; clicks?: number; } /** A key press on the focused `onKey` sink — and its release too, as * `phase: 'up'`, when the sink also declares `keyUp`; without that flag a * sink hears presses only, so a keymap runs each binding once. `code` is a * character or a name ("left", "f5"), `text` what the press would insert * (null for a chord — but for a Mac's Option while it composes, ⌥- typing * "–" — and on every release), `repeat` set when the OS * auto-repeated the press. A key only comes up where it went down: a release * whose press the sink never got is dropped, and focus leaving while a key is * held delivers the `up` first — so a held-key binding cannot be left stuck * down. */ export interface KeyEvent { phase: 'down' | 'up'; code: string; /** The US-QWERTY key at that *position*, spelled as `code` is — bind * it when you want the finger rather than the label (WASD stays a * square on every layout). A shifted letter arrives as the upper-case * letter in `code` with `shift` set, as the OS spells it, and as the * lower-case one here. */ physical: string; shift: boolean; ctrl: boolean; alt: boolean; super: boolean; text: string | null; repeat: boolean; /** Which of a key's twins it was (backlog F108): the left or right * modifier, the keypad's digit, operator or Enter (`code` is still * "1", "enter"), else "standard". */ location: KeyLocationName; /** Caps Lock and Num Lock as the press left them: a lock key's own * press reports the state it made (backlog RG96). */ caps_lock: boolean; num_lock: boolean; } /** Where a key sits, for the keys that have twins (`KeyEvent.location`). */ export type KeyLocationName = 'standard' | 'left' | 'right' | 'numpad'; /** Text an IME committed at the end of a composition, on the focused * `onKey` sink (or the nearest one above the focused control) — the one * committed text the platform never reports as a key press carrying * `text`, so insert it as you would a key's `text`. Plain typing does not * arrive this way: the `key` event already carries it, and a sink hearing * both would type every character twice. A focused `` takes the * commit itself and reports its `change`. Assistive technology replacing * a custom editor's selection arrives this way too: text to insert over * the selection. * * The answer to a `requestPaste()` arrives the same way, with `pasted` * set (backlog DX14) — an IME's commit never has it — and with what the * pasteboard marked it (backlog F84): `concealed` for a secret a password * manager copied — show it to no one, keep it nowhere — and `transient` * for text not to keep in a history. A marker that is not set is absent, * never `false`. */ export interface TextEvent { text: string; pasted?: true; concealed?: true; transient?: true; } /** An in-progress IME composition on the focused `onKey` sink: `text` is * the uncommitted string to show inline at the caret, `cursor` the byte * range inside it the IME's own caret covers (null when it does not say), * and an empty `text` means the composition ended without a commit. The * OS candidate window is anchored for you: the `line` carrying `caret` * says where (`imeRect()` headless). */ export interface PreeditEvent { text: string; cursor: [number, number] | null; } /** Assistive technology set the selection of a custom editor — an `onKey` * sink that draws its own `role="line"` rows (ADR 0047): line ordinals * among the drawn lines and byte offsets into their text, the end that * stays (`anchor`) and the caret (`focus`). */ export interface SelectEvent { anchor: { line: number; offset: number }; focus: { line: number; offset: number }; } /** A copy reached rows of a `selectable` virtual list that no frame built * (ADR 0017, tier 3): the core cannot read text it never laid out, so it * asks the app, on the scope, for the range — `from`/`to` are row indices * (`index`, the row's data index) and byte offsets into each row's text — * and the app answers with `answerSelectionRange(text)`, which is what * reaches the clipboard. Only while `requestCopy()` answered `asked`; a * late answer changes nothing. A Select All over a list that declared * `rowCount` asks for `0..rowCount - 1` with `to.byte` past the last * row's length (the row was never built) — cut it to the row. */ export interface SelectionRangeEvent { from: { index: number; byte: number }; to: { index: number; byte: number }; } /** A secondary-button (right) press on an `onContextMenu` node — on the * press, not the release. `x`/`y` are logical viewport coordinates: where * the menu goes. The core opens nothing; declare the menu as a `modal` * float and stop declaring it on `dismiss`, or `openMenu`. */ export interface ContextMenuEvent { x: number; y: number; } /** A menu row was chosen, from a menu opened for an `onMenu` node — a * `` * option object carried that no menu row reads. */ warnUnknownProps(props: [string, string][]): void /** * What assistive technology sees of the last frame (see * `AccessTree`). A window hands it to the platform by itself * (AccessKit); this is for tests and tooling. */ accessTree(): AccessTree /** * A request from assistive technology on a node: an `AccessAction` * name the node advertises, with `value` the new text for * `setValue`. It arrives as the event a user doing the same * would cause (ADR 0047): a click, a slider's or an editor's * `change`, an `onKey` sink's `text` or `select`. `key` is either spelling of the node — the hex key * an event carried (16 digits), or the label its `key` prop * declared, resolved through the last frame (see `focus`). * Resolved like its pointer/keyboard equivalent, so the resulting * events come out of `pollEvents`. A real screen reader's * requests arrive through a window on their own. */ access(key: string, action: AccessAction, value?: string | AccessArg): void /** * Hover state as of the last frame. `key` is either spelling, * as for `focus`: the label a `key` prop declared, or the hex * key an event carried. For plain hover styling prefer the * `hoverBg` / `pressedBg` props — the core resolves those without * a round trip. */ isHovered(key: string): boolean /** * Press state as of the last frame; `key` is either spelling, * as for `isHovered`. */ isPressed(key: string): boolean /** * Whether any member of the hover group `group` (the * `hoverGroup` name) is hovered, as of the last frame. */ isGroupHovered(group: string): boolean /** * Whether any member of the hover group `group` holds a * press, as of the last frame (backlog C92). */ isGroupPressed(group: string): boolean /** * Whether files dragged in from the OS are over `key` — for * drop-dependent layout; the colour swap is the * `dropBg` prop. `key` is either spelling, as for `isHovered`. */ isDropTarget(key: string): boolean /** * The `onDrop` zone the dragged files are over, as the hex key * an event carries, or null — what a driver answers the OS * with after each `dragFiles`, and what a test reads to say a * zone was found. */ dropTarget(): string | null /** * The pointer shape for where the pointer is now, in the `cursor` * prop's own vocabulary: whatever the topmost node under it * declared with `cursor`, and when it declared nothing, * `'text'` over an editor or a `selectable` scope and * `'default'` over everything else — an `onClick`, `focusable` * or `onDrag` node included, as a native button is, so a hand * or a grab is the view's to declare (the stock `button` * declares `'pointer'` itself). A captured drag keeps the * dragged node's shape wherever the pointer goes; no pointer at * all is `'default'`. A window applies it to the real cursor by * itself and only touches it when the answer changes; this is * for tests and drivers. */ cursorShape(): CursorShape /** * Whether a node holds keyboard focus — any node: an editor, an * `onKey` sink, a button Tab landed on (see `focused`). `key` is * a hex key or a declared label, as for `focus`. */ isFocused(key: string): boolean /** * The node holding keyboard focus (hex key), or null. Tab / * Shift-Tab walk every control in tree order, Enter and Space * press the focused one, and the arrows nudge a focused * slider — `press("tab")`, `press(" ")`, `press("right")`, * which is what a keyboard sends. (`key("tab")` is the half * of that press the core acts on, for a test that means to * drive one channel; `keyDown` is the other half, the one an * `onKey` sink hears.) */ focused(): string | null /** * Whether focus got where it is by keyboard or assistive * technology rather than a click — when it shows (the ring, or * `focusBg`). */ focusVisible(): boolean /** * Whether the window's "Tab moves focus" toggle is on * (backlog C99): a multiline editor whose Tab would type * walks the focus ring instead. Ctrl+M flips it in such an * editor (Ctrl+Shift+M on macOS); what a status label reads. */ tabMovesFocus(): boolean /** * Sets the appearance the host's `dark` / `light` * conditions read in place of the palette's (backlog C113): * `'light'`, `'dark'`, or null for the palette's again. */ setRulesAppearance(appearance?: string | undefined | null): void /** * The caret's blink phase — `true` draws it. A * custom editor reads it in `view` and skips its caret node * on the off phase, keeping the `caret` row on its `line` * either way; the window's clock sets it while a focused * `` or such a line has a caret, and parks it hidden * while the window has no keyboard. Always `true` headless. */ caretVisible(): boolean /** * The frame clock in seconds (backlog F134): the one the * tweens and cycles read, `setTime` or the loop's own, 0 * before either. Read a deadline off it rather than off * `Date.now()`, so `advance` moves both. */ now(): number /** * Asks for a frame at `at` on the frame clock (backlog F135), * in seconds: a toast's expiry, a sequence's next beat. Nothing * is owed until then, so `animating()` stays false; a window * sleeps to it and draws, and the earliest time asked for wins. * A headless loop's `advance` past it draws the frame it ends * on, as it does for a `tick`. */ requestFrameAt(at: number): void /** * The exit the node `key` leaves by if it leaves in the frame * that finishes next (backlog F136), over the `exit` it * declared: `{dx: 400, opacity: 0}`, the same fields as * `exit`. A card a button throws aside is removed in the same * handler, with no frame drawn first to aim it. It aims a node * that declares an `exit`, with that node's transition, and is * forgotten when that frame finishes. */ exitWith(key: string, exit: EnterProp): void /** * The frame-clock time the next asked-for frame is due at, in * seconds; `null` when none was asked for. */ nextFrameAt(): number | null /** * Whether there is a caret to blink: a focused ``'s, or * the `caret` a `line` under the focused sink declares — unless * the line declares it `caretSolid`, which * anchors and reads but arms no clock. What the window's * clock is armed on; headless, what a test reads to see that * an idle view asks for no frame. */ hasCaret(): boolean /** * The driver's half of the blink: sets the phase. A window * runs its own clock; headless, a test drives it to see the * off phase drawn. */ setCaretVisible(visible: boolean): void /** * Moves keyboard focus to a node now (an editor, an `onKey` sink, * a control, a `focusable` box); `keyFocus` on a box is the * declarative, edge-triggered form. * * `key` is either spelling of the node: the 16-digit hex key an * event carried, or the label its `key` prop declared — * `focus('note')` — resolved through the last frame, so a node * the user has never touched can be named. Labels are unique * among siblings, not across the tree: when two nodes declare * the same one, the first in tree order wins and an * `ambiguous-key` warning says so. A label no node declared * throws. */ focus(key: string): void /** * The hex key of the node a key label names — the label a `key` * prop declared, not the accessible name a reader hears * (`keyNamed`), resolved through the frame being built so * far and then the last finished one — or null when no node * declared it. The door for holding a key across frames; * every call that takes a key takes the label too, so this * is for caching one, or for checking that a name reached * the view. Two nodes on one label under different parents * resolve to the first in tree order and raise * `ambiguous-key` — among the host's own first, and a * plugin's component is answered from its own nodes only. */ keyOf(label: string): string | null /** * The reverse of `keyOf`: the label the node with this hex key * (as an event carries it) was opened under, in the frame * being built so far and then the last finished one — or null * for an auto-keyed node, a key no frame declared, or a string * that is not a key. What a key from `focused()`, an event or * a log turns back into; the label is the local one, so two * rows of a list under different parents answer the same. */ labelOf(key: string): string | null /** * The hex key of the first node in the last finished frame * whose accessible name is `name` (backlog F137) — its * `label` prop, else its own text, else a control's derived * name — so a test clicks "the button named Like" as a reader * would: `ctx.access(ctx.keyNamed('Like')!, 'click')`, or * `app.access(…)` on a headless app, which settles what * follows through `update`. (`click` is the pointer's, at * coordinates, on an app.) Not `keyOf`'s key label, which a * reader never hears. Null when no node has the name; two * raise `ambiguous-name`. */ keyNamed(name: string): string | null blur(): void /** * What Tab does, as a call — for an `onKey` sink that binds Tab * itself and wants to hand the keyboard on: the next focusable * node in tree order, wrapping. */ focusNext(): void /** What Shift-Tab does. */ focusPrev(): void /** * Enters a focus region — a box declared `focusRegion`, named by * the label its `key` prop declares or by the hex key an event * carried — or the main ring for `null`. Focus lands on what that * ring last held if the node is still there, else its * `initialFocus`, else its first stop, and shows. * * Resolved when the next frame finishes, like `focusNext`, so * the `update` that toggles a dock on may enter it in the same * turn — which is why a label is taken as a name to hold rather * than resolved now: the node need not exist yet. A frame that * then declares no `focusRegion` under the name raises * `focus-region-without-node` and moves nothing. */ focusRegion(key?: string | undefined | null): void /** * Focuses item `index` of a list, table or other composite — * named by the label its `key` prop declares or the hex key an * event carried — when the next frame finishes (backlog C125): * the item opened with that data `index`, a row a windowed list * did not build being scrolled to and landed on the frame that * builds it (an index past `rowCount` is the last row), else, * where items carry no index, the item at that place. A focused * item that vanishes hands focus to the item now at its place on * its own; this names one. */ focusItem(key: string, index: number): void /** * The focus region in effect — the hex key of the `focusRegion` * node whose ring Tab walks — or `null` for the main ring. What * a chord that toggles between a dock and the app reads to know * which way it is going. */ region(): string | null /** * Scrolls whatever contains a node so it shows — "scroll to the * selected row", which needs the container geometry only the core * has. The request resolves against the *next* frame's layout (one * is requested), so a row the view is about to declare for the * first time reveals fine. If that frame does not declare the key, * or nothing above it scrolls, it is a no-op and is not kept for a * later frame; two reveals before one frame are contradictory, so * the last wins. `key` is a hex key or a declared label, as for * `focus`. A label the last frame did not declare is resolved * when the coming frame finishes, so a row that frame declares * for the first time is reachable by name too; one it does not * declare either is a `label-without-node` warning. */ reveal(key: string): void /** * A scroll container's retained offset `{x, y}` as the last layout * clamped it (positive = content moved up / left) — the number to * keep in a model and hand back to `setScroll`. Zero for a node * that never scrolled. */ scrollOffset(key: string): ScrollOffset /** * Everything the last layout resolved for the scroll container * `key`: its box `{x, y, w, h}`, its content size `{contentW, * contentH}` and the clamped `offset` — `null` for a key no layout * has resolved as a container. * * This is what makes a long list affordable. The core builds every * child a view declares, so ten thousand rows cost ten thousand * rows; knowing `h` and `offset.y`, a view renders the rows that * fit plus two spacers holding the space of the rest. Read while * building, it describes the previous frame, so a resize slices one * frame late — render a row or two extra at each end. */ scrollGeometry(key: string): ScrollGeometry | null /** * The rect the last frame laid `key` out at, `{x, y, w, h}` * in logical viewport px, for a node that declared `onLayout` * — the `layout` event's numbers, read back during the next * build with no event and no model field; `null` for any * other key. Read while building, it * describes the previous frame, like `scrollGeometry`. */ layoutOf(key: string): { x: number, y: number, w: number, h: number } | null /** * Where the pointer is over `key`, `{x, y, w, h}`: its place * from the node's top-left and the node's size, as of the * last frame (backlog C119) — over it while `0 <= x < w` and * `0 <= y < h`. `null` while the pointer is outside the * window, and for a node the last frame gave neither a hit * region (`hoverable`, `onHover`, anything that takes the * pointer) nor an `onLayout` rect. A pointer move is a frame, * so a view that follows the pointer reads it each frame. */ pointerIn(key: string): { x: number, y: number, w: number, h: number } | null /** * Where a point lands in the text a keyed node drew: a byte * offset into its text and the visual row within that node — * counted across every run the key covers, so a `line` row of * inline runs is one row and a wrapped run as many as it * wrapped to; not the ordinal `line` node a pointer event's * `line` names — or null for a key that drew no * text. A `role="none"` subtree under the key (a gutter) is * not its text, as the access tree reads it. `x`/`y` are the logical viewport px a * `click` or `drag` event carries, so a custom editor turns the * event into a caret position with one call — no prefix * measuring, no cell-width arithmetic. A node holding several * text runs (a `line` row of token runs) answers across them * in order, the way the access tree reads the line. Answered * from the frame that finished: the layout the pointer was * over. */ textHit(key: string, x: number, y: number): TextHit | null /** * Opens a context menu at `(x, y)` over the node `key`, with * `items` as plain objects: `{label, role, enabled, id, * accel}`, all but `label` optional. `role` is one of * `custom` (the default), `separator`, `cut`, `copy`, * `paste`, `selectAll` or `lookUp`; the standard ones take * their own wording when `label` is empty, and the core * performs the ones it can. * * Choosing a row posts `key`'s `onMenu` message with `menu: * {role, item}` in it, or nothing where `key` declares none, * and closes the menu; a press outside it or Escape closes it * with nothing posted. What an app answering its own * `onContextMenu` calls — and what the core calls itself for * a right-click nobody claimed, so the two menus are one * implementation. * * `options.maxWidth` / `options.maxHeight` hold the menu and * its submenus to a size, logical px: a row wider is * ellipsized, a menu taller scrolls (backlog F210). One left * out, or not above 0, is the room the menu is drawn in. * `options.inWindow` keeps the menu drawn in the window where * the runner would show one that does not fit in a popup * window of its own. */ openMenu(key: string, x: number, y: number, items: MenuItemInput[], options?: { maxWidth?: number; maxHeight?: number; inWindow?: boolean } | null): boolean /** * Drains what choosing a menu row left for the host: the * clipboard, which is the host's in this library. Each entry * is `{kind}` — `"setClipboard"` with `text` (and `html` * where there is formatting to carry), `"paste"` asking for * what is on the clipboard (deliver it back with `commit()`, * which a focused editor takes as typing and a focused * `onKey` sink hears as a `text` event), * or `"lookUp"` with the `text` to show a definition panel * for at `x`, `y`. * * A windowed app never needs this — the driver drains it — * but a headless one does: nothing else empties the queue, * and a Copy nobody drains is a copy that never happened. * Asks for the platform's Open, Save or folder dialog: * `{mode, multiple, title, filters: [{name, extensions}], * directory, fileName, tag}`, every field optional. The answer * is a `files` event, the dialog's `tag` with `files: {paths}` * in it — `paths` empty when the user cancelled. A window's runner shows the dialog; a * headless context queues it for `takeFileRequests`. False when * one is already out: one dialog at a time. */ requestFiles(dialog?: FileDialogOptions): boolean /** Whether a file dialog asked for is still unanswered. */ awaitingFiles(): boolean /** * The file dialog asked for and not yet taken — at most one — * as `requestFiles` took it, for a host that shows it itself. * A window never needs this: its runner drains and shows it. * Answer with `answerFiles`. */ takeFileRequests(): FileDialogOptions[] takeMenuActions(): MenuAction[] /** * Puts `text` on the system clipboard — the action a menu's * Copy queues, with a door on it for an `onKey` sink that * hears the raw `Ctrl-c` and had nowhere to bind it. * `html` is a second flavour beside the text for the * host to offer, never in place of it. A window applies it * at its next drain (after every input and every frame); a * headless `Ctx` hands it out through `takeMenuActions()`. */ setClipboard(text: string, html?: string | undefined | null): void /** * Puts a secret on the system clipboard the way a password * manager does: a window writes it marked * concealed and transient — `org.nspasteboard.ConcealedType` * and `TransientType` on macOS, the exclusion formats on * Windows — so no clipboard manager shows or keeps it. A * headless `Ctx` hands it out through `takeMenuActions()` as * `{kind:"setClipboardSecret", text}`. */ setClipboardSecret(text: string): void /** * Puts files on the system clipboard, as a file manager's * Copy does — "Copy file" on an attachment: a window writes * them as the platform's file list (`CF_HDROP` on Windows, * file URLs on macOS, `text/uri-list` on Linux), so they paste * into a file manager or a mail as the files. The paths as the * app names them; the window makes them absolute. False, and * nothing queued, for none. A headless `Ctx` hands it out * through `takeMenuActions()` as * `{kind:"setClipboardFiles", paths}` (backlog F247). */ setClipboardFiles(paths: Array): boolean /** * Puts a picture on the system clipboard — `width` by `height` * straight RGBA, what `capture()` and `decodeImage` hand out, * copied — as the platform's image type: "Copy image". A * window writes it at its next drain; a headless `Ctx` hands it * out through `takeMenuActions()` as `{kind:"setClipboardImage", * width, height}`. False, and nothing queued, when `rgba` is * not `width * height * 4` bytes or the size is zero. */ setClipboardImage(width: number, height: number, rgba: Uint8Array): boolean /** * Asks for what is on the clipboard — the action a menu's * Paste queues. A window reads the clipboard and hands the * text back as a paste: a focused `` takes it as * typing, and a focused `onKey` sink hears it as its message * with `text: {text}` in it — with `concealed: true` / * `transient: true` there where the pasteboard marked it so * — so an app that owns its text inserts a * paste the way it inserts a committed IME string and never * reads the clipboard itself. Headless, the request comes out * of `takeMenuActions()` as `{kind:"paste"}` and the test * answers it with `paste(text, marks)` or `commit(...)`. */ requestPaste(): void /** * Whether a paste asked for is still unanswered: one ask at a * time — a second `requestPaste` while one is out is dropped, * and the `commit` that answers it (an empty one for an empty * clipboard) lets the next through. */ awaitingPaste(): boolean /** * The menu this window has open, or null: * `{target, x, y, items}`. What a host rendering menus itself * reads after `setNativeMenus(true)` — the core then keeps * the menu as state and draws none of it — and answers with * `activateMenuItem` or `closeMenu`. A row reads exactly as a * `menuBar()` row does (`menu_item_json`). */ menu(): OpenMenu | null /** * Tells the core this host shows menus itself. It then keeps * the open menu as state and draws none of it: read it with * `menu()`, show it, and report back with `activateMenuItem` * or `closeMenu`. Off by default, which is the menu this * library draws. */ setNativeMenus(on: boolean): void /** * The application menu the frame declared, or null: * `{revision, menus: [{label, enabled, items}]}`. What a * host with a menu bar of its own reads after * `setNativeMenuBar(true)`; `revision` changes only when the * declaration does, so a host rebuilds nothing until it moves. */ menuBar(): MenuBarState | null /** * Tells the core the platform owns the menu bar, so * `` draws nothing and this host is the one handing * the declaration over (`menuBar()`) and reporting what was * chosen (`activateMenuBarItem`). Off by default, which is * the bar this library draws. */ setNativeMenuBar(on: boolean): void /** * Reports that the platform's menu bar chose row `item` of * menu `menu` — the same path a press on the drawn bar's row * takes. False when the app hears nothing: a row that is not * there, or a `` that declares no `onMenu` (ADR 0048). */ activateMenuBarItem(menu: number, item: number): boolean /** * `activateMenuBarItem` for a row inside a submenu of menu * `menu`, by its path through the rows' `items`. False for a * row that is not there or that opens a submenu. */ activateMenuBarPath(menu: number, path: Array): boolean /** * Tells the core this host can show the platform's definition * panel. The standard Look Up row is then offered where it * means something, and a force click over text asks for one. */ setLookupAvailable(on: boolean): void /** * Reports that the host's own menu chose row `index` — the * same path a press on the drawn menu's row takes. An index * past the end closes the menu and posts nothing. False when * nothing was taken: no menu was open, or the row cannot be * chosen — disabled, or a separator — in which case the menu * stays open and nothing is posted. */ activateMenuItem(index: number): boolean /** * `activateMenuItem` for a row inside a submenu, by its path * through the rows' `items`: `[2, 0]` is the first row of the * third row's submenu. False where `activateMenuItem` is, and * for a row that opens a submenu, which is never chosen. */ activateMenuPath(path: Array): boolean /** Closes whatever menu is open; true when there was one. */ closeMenu(): boolean /** * Asks for the selection as text: `{ text, asked }`. * * `text` is the selection when the core has all of it. When * the selection reaches rows a virtual list never built, * `asked` is true instead and a `selectionrange` event — * the scope's `onSelectionRange` message with `selectionrange: * {from: {index, byte}, to: {index, byte}}` in it — is posted * on the scope — the rows behind that gap are the app's, so the * app answers with `answerSelectionRange`, and the answer is * what reaches the clipboard. */ requestCopy(): { text: string | null, asked: boolean } /** * Answers a `typeahead` event (ADR 0070) with the data index of * the row the search names, in the composite `key` (either * spelling) that asked: the core goes there, scrolling to a * row the frame did not build. False when that composite asked * nothing, or focus has left it. */ answerTypeahead(key: string, index: number): boolean /** * Answers a `selectionrange` ask with the text for the range * it named, whole. False when nothing asked — a late answer * cannot overwrite what has been copied since. */ answerSelectionRange(text: string): boolean /** * The window's selected text: what a `selectable` scope has * selected, or the focused ``'s selection, whichever * the window holds — starting either clears the other, so * there is never a choice to make. Null with no selection, * `""` when a selection exists but covers nothing (a press * that placed both ends together). */ selectionText(): string | null /** * The text selection's two ends as the drag made them: * `{anchor: {index, byte}, focus: {index, byte}}`, `index` the * data index of the virtualised row the end is in (null * outside every virtualised row — the `index` a * `selectionrange` ask would name) and `byte` the offset in * that row's own text. Directed, so a Shift-click that kept * the anchor reads as one. Null with no text * selection; a grid's is `cellSelection()`. */ selectionEnds(): SelectionEnds | null /** * A `cells` grid's selection, the window's when it lives in * one: the grid's key, `anchor` and `focus` as the drag made * them — each an absolute `line` (`originLine` plus the row, * so a scroll does not move it) and a `col` — and `block` * for a rectangular one. Null when the * window's selection is not a grid's; a text selection's ends * are `selectionEnds()`. */ cellSelection(): CellSelection | null /** * The selection as HTML, carrying the formatting the text * declared — bold, italic, a span's own colour — and *not* * the node's colour, which is the app's theme rather than * the text's. * Null with no text selection. Meant as a second clipboard * flavour beside the plain text, never instead of it. */ selectionHtml(): string | null /** * Selects every run inside the selection scope a keyed node * declared (`selectable`), first byte to last — Select All, * scoped. False when that node drew no text, or is not a * scope. Text the frame built but never drew is included: * the selection is over the scope's text, not over what fits * on screen. */ selectAllIn(key: string): boolean /** * Drops the window's selection, whichever it is. True when * there was one to drop. */ clearSelection(): boolean /** * The caret rect for a byte offset in the text a keyed node * drew: logical viewport px, zero wide, one line tall — where * a caret, a selection edge or an IME candidate window goes. * A byte past the text is the end; null for a key that drew * no text. */ caretRect(key: string, byte: number): Rect | null /** * Where the OS candidate window goes while a composition is * under way: the focused ``'s caret, or a custom editor's * `line` carrying `caret`; null when nothing with a caret is * focused. The windowed driver applies it itself; headless, * it is what a test reads to see the anchor moved. */ imeRect(): Rect | null /** * Sets that offset the way the wheel would; the next frame's * layout clamps it, so `(0, 0)` jumps to the top and a huge `y` to * the end without knowing the content height. */ setScroll(key: string, x: number, y: number): void /** * Moves the scroll container `key` by the content that moved * under it — `drawn` for where the content is drawn (and an * eased leg's start), `target` for the retained offset — with * no ease asked or ended and no frame asked for: a correction to * the frame the view is building. What `list()` calls when the * rows it measured came out another height than the estimate * they stood at, so the row under the pointer stays put. * A label nothing declared yet is the first * frame, which has nothing to correct. */ shiftScroll(key: string, drawn: number, target: number): void /** * Scrolls the container `key` for a drag the app holds with * the pointer at `x`, `y`, when the pointer is in the edge * zone inside `rect` — usually the container's own * `scrollGeometry` — or past it, by `edgeScrollFeel`: at * once, faster the deeper and the longer it is held, fully * deep when pinned against the window's edge. Returns what it * moved, `{ x, y }` positive toward later content, and asks * for the next frame so a pointer held still goes on * scrolling; `null` out of the zones, at the end that way, or * for a key that is no scroll container. Call it once a frame * while the drag is held — from the view — and place the * drag's live end under the pointer after; not before the * drag has left its press's click slop. kui's own caret drag * and drag-select scroll by the same feel on their own. */ edgeScroll(key: string, x: number, y: number, rect: Rect): { x: number, y: number } | null /** * The names of every window open right now, `"main"` first, * then in the order they opened — what a view's root * `windows` declared and the diff has opened. `view(model, * window)` is called once per name. */ windows(): Array /** * The name of the window this core draws: `"main"`, or the * name the declaration that opened `env().window.id` used. */ windowName(): string /** * Asks the driver to resize a window to `width`×`height` logical * px. A request and not a declaration: a window's `size` config * is read on the frame it opens and never again, because the user * owns a window's size once it exists, so this is the only way an * app moves a live one. Queued the way `reveal` is — a `KuiWindow` * applies it on its next pump, and the window answers with the * ordinary `resize` event carrying the size it actually became, * while a headless `Ctx` has no window and simply keeps the * request. `window` is the id events carry (`env().window.id`), * 0 for the main window. */ setWindowSize(window: number, width: number, height: number): void /** * Asks the driver to give a window keyboard focus; queued the same * way. Advisory: whether the window manager agreed shows up as * `env().focused` on the frames that follow, not as a reply. */ focusWindow(window: number): void /** Display names, indexed by setWindowFullscreen's display. */ displayNames(): Array /** Request borderless fullscreen on the current or chosen display. */ setWindowFullscreen(window: number, enabled: boolean, display?: number | undefined | null): void /** Show or hide a window without losing its context. */ setWindowVisible(window: number, visible: boolean): void /** Have OS close hide a window while another stays visible. */ setWindowCloseHides(window: number, enabled: boolean): void editText(key: string): string | null /** * Replaces an editor's text, leaving the caret at the end. * * It reaches an editor that does not exist yet: the `update` * that opens a rename field runs a frame ahead of the view * that declares it, so the text is held for the frame that * declares this name and seeds the editor there, over * `initial`. Name it by the label its `key` prop declares — * the spelling that needs nothing to exist yet, since the * hex key comes from an event the editor has not fired. * Either spelling works, as for `focus`; a label the last * frame declared lands at once, and one it did not is held. * Held for that one frame — a name nothing declares on it * drops its text with an `edit-text-without-editor` warning, * so a name the view spells differently is a line rather * than a field that opens with the wrong text. * * A redraw is asked for only when the text reached an editor. * A held seed changed nothing on screen, and the frame that * will — the view that declares the editor — is the app's: * a redraw here re-lowered the *retained* tree, which declares * no editor, and that was the frame the hold expired on when * the call came from a `dispatch` outside the loop * (`runWindowed` draws that model before it pumps). */ setEditText(key: string, text: string): void } /** * Decoded pixels (`decodeImage`): `width` by `height`, four bytes each * (RGBA), row by row from the top left, alpha not premultiplied — what * `addImage`, `updateImage` and a window's `icon` take. */ export interface DecodedImage { width: number height: number rgba: Buffer } /** * A finished frame as pixels (`capture`): `width` by `height` physical * pixels, four bytes each (RGBA), row by row from the top left, alpha not * premultiplied — what `addImage` takes — and the scale it was drawn at. */ export interface Capture { width: number height: number scale: number rgba: Buffer } /** * Every frame of an animated image (`decodeAnimation`), each the whole * canvas, with the seconds each shows and how many times the sequence * plays (absent: for ever). */ export interface DecodedAnimation { width: number height: number frames: Array delays: Array loops?: number } /** * Which frame shows at a moment (`animationAt`), and the seconds after * the start the next is due — `Infinity` once a finite animation has * played out. */ export interface AnimationShowing { index: number next: number } /** * Decodes PNG, JPEG, WebP or GIF bytes (an animated file's first frame) * with the runner's decoder (backlog F138), so an app that ships a photo * needs no image package: `ctx.addImage(d.width, d.height, d.rgba)`. * Throws, naming why, for bytes that are not an image or do not decode. * Loads a DTCG token file, or a Resolver Module document composing * several (ADR 0062), into kui's token shape: `tokens` is what * `setTokens` takes (`ctx.setTokens(loadTokens('brand.resolver.json').tokens)`), * colours with a light and a dark half; `names` says which DTCG path each * name came from; `warnings` names every token skipped or changed (a * shadow kui has no kind for, a colour clamped into sRGB). `source` is a * path, or a token document already parsed. Throws when the file will not * read or parse or the resolver cannot be resolved. */ export declare function loadTokens(source: string | object, options?: DtcgOptions): LoadedTokens export declare function decodeImage(bytes: Buffer): DecodedImage /** * What `encodeImage` takes beside the pixels: `quality` for a JPEG, 1 to * 100 (absent: 90). */ export interface EncodeOptions { quality?: number } /** * Encodes straight RGBA — `width` by `height` pixels, four bytes each, * what `capture()` and `decodeImage` hand out — as a file's bytes with * the runner's encoders (ADR 0054), so a test or a probe keeps a capture * with no image package: `writeFileSync('shot.png', encodeImage('png', * s.width, s.height, s.rgba))`. `png` is lossless at the fast setting, * `jpeg` lossy at `quality` with alpha dropped, `webp` lossless, `gif` 256 * colours. Throws, naming why, for another format, a size of zero or * pixels that are not that size. */ export declare function encodeImage(format: 'png' | 'jpeg' | 'webp' | 'gif', width: number, height: number, rgba: Buffer, options?: EncodeOptions): Buffer /** * Shows the file or folder at `path` in the system's file manager — * selected in Finder or Explorer, its folder opened elsewhere — and * returns once it has started (backlog F203): "Show in folder" beside a * file the app saved. Throws, naming why, for a path that does not exist * or a file manager that would not start. */ export declare function showInFolder(path: string): void /** * Opens the recording at `path` in kui-perf, the trace inspector — `kui * perf `, the `kui` on `PATH` — and returns once that has started * (backlog F253): what applies the devtools' `openRecording` action. * Throws, naming why, for a file that does not exist or no `kui` that * would start. */ export declare function openRecording(path: string): void /** * Opens `target` with what the system opens it with — a file in its * app, a folder in the file manager, a URL (`https:`, `mailto:`, …) in * the browser or mail client — and returns once that has started * (backlog F203). Throws, naming why, for a path that does not exist or * a tool that would not start. */ export declare function openExternal(target: string): void /** * Begins a span named `name` where the window is not at hand — a * library deep in a stack — on the recording of the window whose span is * open now on this thread (an `update` the loop times, a span of the * app's), nested in the span open now (backlog F215). 0 while none is, * which `threadSpanEnd` ignores. */ export declare function threadSpanBegin(name: string): number /** * Ends the span `threadSpanBegin` began, and any opened inside it and * left open; 0, or an id with no begin, is nothing. */ export declare function threadSpanEnd(id: number): void /** * What an `AnimationEncoder` takes beside its size: `loops`, how many * times it plays (absent or 0: for ever). */ export interface AnimationEncoderOptions { loops?: number } /** * An animated PNG or GIF written a frame at a time (ADR 0054): `add` * each frame — the whole canvas, straight RGBA, a `capture()`'s `rgba` — * with the seconds it shows, then `finish` for the file's bytes. It keeps * only the rectangle each frame changed, folds a frame that changed * nothing into the time of the one before, and gives a frame too short * for the format (1 ms for `png`, 20 ms for `gif`) to the next, so a * recording at retina size holds two whole frames and the changes. */ export declare class AnimationEncoder { /** * An encoder for `width` by `height` frames as `png` (an animated PNG, * every colour exact) or `gif` (256 colours). Throws, naming why, for * another format or a size it cannot hold. */ constructor(format: 'png' | 'gif', width: number, height: number, options?: AnimationEncoderOptions) /** * Adds a frame that shows for `seconds`. Throws, naming why, for * pixels that are not a frame's size, a time that is negative or not * finite, or an encoder already finished. */ add(rgba: Buffer, seconds: number): void /** * The file's bytes; the encoder is spent. Throws, naming why, with no * frame added or when it was finished already. */ finish(): Buffer } /** * Decodes every frame of an animated GIF, PNG (APNG) or WebP, each the * whole canvas, and the seconds each shows; a GIF frame asking for 10 ms * or less shows for 100, as browsers show it. A still image is one frame * shown for ever. Play it on the frame clock with `animationAt`, * `updateImage` and `requestFrameAt`. */ export declare function decodeAnimation(bytes: Buffer): DecodedAnimation /** * Which of the frames with these `delays` shows `elapsed` seconds after * the animation started, playing `loops` times (null or 0 for ever), and when * the next is due: `animationAt(gif.delays, gif.loops, ctx.now() - * started)`, then `updateImage` when the index moved and * `requestFrameAt(started + next)`. */ export declare function animationAt(delays: Array, loops: number | undefined | null, elapsed: number): AnimationShowing /** Byte stride of one quad in the `quads()` buffer. */ export declare function quadStride(): number /** Byte stride of one clip in the `clips()` buffer. */ export declare function clipStride(): number /** * A real kui window (winit + wgpu) driven from Node. The event loop is * pumped, not run: call `pump()` between libuv turns so winit and libuv share * the main thread — or prefer `runWindowed`, which does that for you, unless * you are building your own loop. One event loop per process (winit event * loops are not recreatable on every platform), any number of windows on * it: a view whose root declares `windows` opens more, `windows()` lists * them, and `setView` takes the name of the one a tree is for. */ export declare class KuiWindow { /** * Options: `{width, height, minWidth, minHeight, maxWidth, maxHeight, * chrome: "native" | "custom" | "borderless", textAa: "auto" | "gray" * | "subpixel", frameLatency, system, icon, appId, backdrop, titlebar: * "standard" | "medium" | "tall"}`. The min/max pairs bound what the user can * resize the window to; either half may stand alone. `system` pins part of `env.system` over what the OS * says, for the life of the window — `{motion: 'reduced'}` is what a * user who asked for less motion would get, on a machine whose owner * did not; `icon: {rgba, width, height, resource}` is every window's * icon; see `WindowOptions`. */ constructor(title: string, options?: WindowOptions) /** * Which window the per-window doors — `focus`, `editText`, * `setEditText`, `isHovered`, `scrollGeometry`, `openMenu`, * `selectionText`, `setTheme`, `setMetrics`, `setTokens`, the * devtools setters, input injection — address from here on: a name * from `windows()`, or the id an event carries in `window`; left out, * the main window. Returns whether that window is open now; until it * is, the doors address the main window. `runWindowed` aims the * surface at the window whose view it is calling and at the window * an event came from before handing the surface to `update`, so an * app that never calls this reads and writes the window it is being * asked about. Resources, `windows()`, `pump` and * `pollEvents` are the session's and unaffected. */ useWindow(window?: string | number): boolean /** * `setView` with a flat binary instruction stream (see `Ctx::frame_binary`). * Copied once so redraws (resize, hover) can re-lower it between pumps. * `window` names which window the tree is for — `"main"` when left * out; the names `windows()` lists otherwise. */ setViewBinary(stream: Float64Array, strings: Uint8Array, window?: string | undefined | null): void /** * Processes pending OS events without blocking. Returns false once the * window has closed. */ pump(): boolean /** * Registers what the window calls as it goes for good — its close * button, `close()`, Quit from the menu or the dock — once, from * inside the `pump()` that saw it and before that pump returns. * On macOS a Quit ends the process inside that pump: * `pump()` never returns, `runWindowed` never resolves and nothing * after it runs, not even `process.on('exit')` — so this is the only * thing an app runs on ⌘Q. `runWindowed` registers its config's * `teardown(model)` here; a driver of its own does the same. The * window is gone by then: the callback saves and returns. A window * door it calls anyway throws, and a shared one (`editText`, * `pollEvents`, …) reads a blank core instead of the closing window's, * which the pump in flight still holds. The last registration wins. */ onTeardown(callback: () => void): void /** * `pump`, but parked for up to `timeoutMs` — returning the moment an * OS event or a `Waker` wake arrives, and otherwise when the time is * up. Returns false once the window has closed. `timeoutMs` is clamped * to an hour; anything not finite and positive parks not at all. * * **What this buys is latency, and it is not what `runWindowed` idles * on.** The wake is the event itself rather than the next tick after * it, so the period stops setting the response time — but two measured * things make it the wrong default, and both surprise: * * - **It does not save CPU; it costs.** winit 0.30's macOS pump stops * on the *first* wake of any kind, so a park does not hold: a 200 ms * park runs 101 ms on average. Against polling at the same period, a * 32 ms period is 49 pumps a second and 4.59% of a core parked, * against 30 pumps and 1.80% polled. * - **A blocked main thread is a blocked libuv**, and Node cannot be * asked whether that is safe — `process.getActiveResourcesInfo()` * reports nothing for an in-flight `fs.readFile`. Behind a 50 ms * park, 200 sequential `await readFile` went from 6 ms to 4 s. * * So reach for it only in a loop that owns its whole process and does * no async I/O, and wants the latency. Otherwise `pump()` on a timer * is both cheaper and safer — which is what `runWindowed` does. */ pumpUntil(timeoutMs: number): boolean /** * How long until the window next needs a pump, in ms — `null` when * nothing the runner knows about is due. * * A driver on a fixed interval hits every deadline the shell has * already worked out a whole interval late: the caret blink, a * transition's next frame, the audio poll, a window's first-frame * retry. Ask after each pump and sleep to the answer instead, which is * what `runWindowed` does. It only ever asks for *sooner* — whether an * OS event is waiting is not something it can say, so a driver still * needs a ceiling of its own. */ nextDeadlineMs(): number | null /** * The viewport the app lays out into, in logical px, plus the scale * factor: `{width, height, scale}` — the window's inner size, less * the devtools' dock while the panel is docked. * Readable before the first frame (in `setup` and `init`, where * `env().viewport` is still 0×0), and re-reported as a * `resize: {width, height, scale}` in the root's * `windowEvents.onResize` message (a `ResizeMsg`) whenever the window changes size, moves to a * display with another DPI, or the dock comes, goes or is dragged. * It used to be the window's inner size, so an app that seeded * its tiers from it under `KUI_DEVTOOLS=1` drew for the whole window. */ size(): WindowSize /** * Frame timing measured by the runner — what the latency HUD draws, * as data: `{frames, framesTotal, pumps, wokenPumps, last: {inputMs, * viewMs, layoutMs, renderMs, waitMs, totalMs, workMs} | null, * avgTotalMs, maxTotalMs, avgWorkMs, maxWorkMs}`. The averages and * maxima are over the last 120 frames and `frames` is how many of * those the ring holds — its fill, one per painted frame up to 120, so * a window that paints only when something changes stays below it for * as long as it idles. `framesTotal` and `pumps` are the monotonic * counts of every frame painted and every `pump()` taken, so two * readings a second apart are that second's frame and * pump rates. `wokenPumps` counts the pumps that found an OS event or * a wake — a key, the pointer crossing, a focus change, a resize, a * reader asking — so two readings a second apart with it * unmoved are a second the desktop left the window alone, and every * frame in it was the app's own. `waitMs` is vsync backpressure; * `workMs` is everything else. */ frameStats(): FrameTiming /** Asks the window to close; the next pump returns false. */ close(): void /** * Registers a w×h RGBA image (pixels copied); returns its id for * ``. Stable until `removeImage`. */ addImage(width: number, height: number, rgba: Buffer): string removeImage(id: string): void /** * Replaces an image's pixels in place (copied): the id is * unchanged, so every `` shows the new pixels * next frame with no view change; `width`/`height` may differ * from the registration. From the first update on the image * is drawn from a texture of its own — a video frame, a * camera, a plot the app rasterised itself. A dead id warns * `foreign-resource` and changes nothing. */ updateImage(id: string, width: number, height: number, rgba: Buffer): void /** * Registers a WGSL fragment function; returns its id for * ``. Throws when the source does not * compile, with the compiler's message in the app's own line * numbers. Idempotent by source, so the same text gets the * same id without being validated twice. */ addFragment(wgsl: string): string removeFragment(id: string): void /** * Registers a font from file bytes (TTF/OTF/TTC); returns its id * for the `font` prop on `` / ``. Throws when the * data holds no usable face. */ addFont(data: Buffer): string /** * Registers an installed font by family name; null when none * matches (see `systemFontFamilies`). Also finds families loaded * with `loadFontsDir` / `loadFontFile`; the same family gets the * same id. */ addSystemFont(name: string): string | null /** * Registers a font file by path (memory-mapped); throws when it * cannot be read or holds no usable face. */ loadFontFile(path: string): string /** * Loads every font file under a folder (recursively) so its * families can be picked by name with `addSystemFont`; returns * the face count. */ loadFontsDir(dir: string): number /** * Scans the system's fonts again, so a font installed while the * app runs is found (kui scans them once a process); returns how * many faces came and went, 0 when nothing did. Tens of * milliseconds: call it when the set may have changed, not * every frame. */ reloadSystemFonts(): number /** * The fonts asked, in order, for a character the text's own * family has no glyph for, before the platform's fallback list * — whose first choice on macOS is the system's proportional * face. Ids from `addFont` / `addSystemFont` / `loadFontFile`; * one that names no font is left out, and `[]` is the * platform's list alone. `mono` text asks them straight after * its own face, ahead of the machine's other monospaced faces. * A new list shapes every text again; the same list twice is * nothing. */ setFallbackFonts(ids: Array): void removeFont(id: string): void /** * Family names of every font the core can see, installed or * loaded (sorted). */ systemFontFamilies(): Array /** * The families `systemFontFamilies` names, in its order, each * with what its faces say they are: `monospaced` (every face * fixed-pitch), `weights` (sorted, each once) and `italic`. * Read from what the font database recorded * when it scanned each face, so a font picker can put the * monospaced ones first without loading a file or shaping a * glyph. */ systemFonts(): Array /** * Registers a sound from its encoded bytes (wav/ogg/mp3/flac); * returns its id for `