// @native-sdk/core/events — the canonical event record types the host and // markup deliver into an app core, an SDK LIBRARY module: pure type // declarations in the app-core subset, emitted into your core when imported // and absent when not. Under node the same file resolves as-is. // // Every record here matches, field for field, the structural shape a // runtime matcher expects — markup's `on-input`/`on-scroll` mirrors // (`declaredTextInputUnion`/`declaredScrollStateRecord`), the generated // wiring's channel builders (`frameMsg`/`keyMsg`/`pinchMsg`/`dropMsg`/ // `appearanceMsg`/`chromeMsg`), and the audio event arm validator. Matching stays // STRUCTURAL either way (type identity cannot cross the emission // boundary), so declaring the same shape in your own core remains legal; // these exports exist so no core has to re-type the vocabulary and no // hand-rolled mirror can drift. One home per type: the text-input family // lives with the byte-splice engine in `@native-sdk/core/text` and is // re-exported here, so `@native-sdk/core/events` resolves every event // record an app binds. (Importing this module pulls `./text.ts` into the // emitted core with it; unused engine functions cost source lines, never // binary — Zig compiles only what the core references.) // // Names are unique across a core's whole module graph (NS1038): a core // that imports one of these types cannot also declare its own record // under the same name — delete the in-file mirror and import it instead. // // How each type is bound: // - `TextInputEvent`, `ScrollState`: Msg-arm PAYLOAD fields — // `{ kind: "draft_edit"; edit: TextInputEvent }`, // `{ kind: "scrolled"; scroll: ScrollState }`. // - `FrameEvent`, `KeyEvent`, `PinchEvent`, `FileDropEvent`: the wiring channels' // parameter records — `frameMsg(model, frame: FrameEvent)`, // `keyMsg(key: KeyEvent)`, `pinchMsg(pinch: PinchEvent)`, // `dropMsg(drop: FileDropEvent)`. // - `ColorScheme`, `ChromeInsets`, `ChromeButtons`, `AudioState`: field // types INSIDE the arm records the `appearanceMsg`/`chromeMsg`/audio // routes name (the arms themselves stay inline unions of `kind` plus // the event's fields — the subset has no intersection arms). // - `AppearanceEvent`, `ChromeEvent`, `AudioEvent`: the full arm // payload shapes, canonical and importable for helper signatures // (an arm value is structurally assignable to its event record). // - `ThemeState`: the model-derived built-in theme axes returned by // `themeState(model)`; omitted fields inherit the manifest/system. // - `StatusItemState`, `StatusItemDescriptor`, and their nested records: // the model-derived shell returned by `statusItem(model)` or keyed // `statusItems(model)`; the generated launcher refreshes shell, // presentation, visibility, and menu after committed model changes. export type { TextCaretDirection, TextCaretMove, TextSelection, TextInputEvent } from "./text.ts"; /// The stock theme axes a TypeScript core may derive from committed model /// state. Omit `pack`/`accent` to inherit app.zon; omit `colorScheme` (or /// return `"system"`) to follow the OS. High contrast and reduced motion /// remain system-owned, and high contrast suppresses accent overrides. export type ThemeStatePack = "house" | "geist"; export type ThemeStateColorScheme = "light" | "dark" | "system"; export type ThemeState = { readonly pack?: ThemeStatePack; readonly colorScheme?: ThemeStateColorScheme; readonly accent?: string; }; /// One row in a menu-bar status item's menu. Non-separator rows need a /// unique non-zero `id`, a non-empty `label`, and (when actionable) a /// command name accepted by `commandMsg`. Rich readout roles may carry /// secondary `detail`; command rows may carry a key equivalent. Core row /// records have one exact shape; only the documented rich payloads and /// presentation typography may be omitted. /// A status item may expose at most 32 rows. export type StatusItemTone = "normal" | "warning" | "critical"; export type StatusItemFontWeight = "regular" | "medium" | "semibold" | "bold"; export type StatusItemMenuRole = "command" | "info" | "header" | "hero" | "agent" | "context" | "segmented" | "chart"; export interface StatusItemModifiers { readonly primary: boolean; readonly command: boolean; readonly control: boolean; readonly option: boolean; readonly shift: boolean; } export type StatusItemPresentation = { readonly title: Uint8Array; readonly width: number; readonly tone: StatusItemTone; readonly iconOpacity: number; readonly monospaced: boolean; /// Omit to keep the platform menu-bar default size. readonly fontSize?: number; /// Omit to keep regular weight. readonly fontWeight?: StatusItemFontWeight; }; export interface StatusItemSegmentOption { readonly id: number; readonly label: Uint8Array; readonly command: Uint8Array; readonly selected: boolean; readonly enabled: boolean; } export interface StatusItemSegmentedRow { readonly options: readonly StatusItemSegmentOption[]; } export interface StatusItemMetricRow { readonly primaryText: Uint8Array; readonly secondaryText: Uint8Array; readonly accessibilityLabel: Uint8Array; } export interface StatusItemChartRow { readonly values: readonly number[]; readonly minValue: number; readonly maxValue: number; readonly leadingCaption: Uint8Array; readonly trailingSummary: Uint8Array; readonly accessibilityLabel: Uint8Array; } export type StatusItemMenuItem = { readonly id: number; readonly label: Uint8Array; readonly command: Uint8Array; readonly separator: boolean; readonly enabled: boolean; readonly detail: Uint8Array; readonly role: StatusItemMenuRole; readonly key: Uint8Array; readonly modifiers: StatusItemModifiers; /// Present exactly when `role` is `segmented`. readonly segmented?: StatusItemSegmentedRow; /// Present on a `hero` row to declare a typed dropdown metric block. readonly metric?: StatusItemMetricRow; /// Present exactly when `role` is `chart`. readonly chart?: StatusItemChartRow; }; /// The generated launcher's model-derived menu-bar status item. Export /// `statusItem(model: Model): StatusItemState` from `src/core.ts`; its /// shell, presentation, and rows are re-derived after every committed model /// update. Byte slices are borrowed only for that apply, so returning literals /// or freshly built arrays is safe. export interface StatusItemState { readonly iconPath: Uint8Array; readonly tooltip: Uint8Array; readonly activationCommand: Uint8Array; readonly alternateActivationCommand: Uint8Array; readonly openCommand: Uint8Array; readonly presentation: StatusItemPresentation; readonly items: readonly StatusItemMenuItem[]; } /// One independently reconciled menu-bar status item. Export /// `statusItems(model: Model): readonly StatusItemDescriptor[]`; `id` /// preserves the native item while all remaining fields update live. export interface StatusItemDescriptor { readonly id: number; readonly visible: boolean; readonly iconPath: Uint8Array; readonly tooltip: Uint8Array; readonly activationCommand: Uint8Array; readonly alternateActivationCommand: Uint8Array; readonly openCommand: Uint8Array; readonly presentation: StatusItemPresentation; readonly items: readonly StatusItemMenuItem[]; } /// What the user's close affordance does for a model-declared secondary /// window. `quit` really closes it and routes `onCloseCommand`; `hide` keeps /// the native window and view tree alive for `Cmd.showWindow(label)`. export type WindowClosePolicy = "quit" | "hide"; export type WindowTitlebarStyle = "standard" | "hidden_inset" | "hidden_inset_tall" | "chromeless"; export type WindowRestorePolicy = "clamp_to_visible_screen" | "center_on_primary"; /// Author-facing input to `windowDescriptor`; omitted fields receive the /// same defaults as UiApp.WindowDescriptor. export interface WindowDescriptorSpec { readonly label: Uint8Array; readonly canvasLabel: Uint8Array; readonly title?: Uint8Array; readonly width?: number; readonly height?: number; readonly x?: number | null; readonly y?: number | null; readonly resizable?: boolean; readonly restorePolicy?: WindowRestorePolicy; readonly minWidth?: number; readonly minHeight?: number; readonly titlebar?: WindowTitlebarStyle; readonly transparent?: boolean; readonly alwaysOnTop?: boolean; readonly clickThrough?: boolean; readonly activateOnShow?: boolean; readonly allowsFullscreen?: boolean; readonly closePolicy?: WindowClosePolicy; readonly onCloseCommand?: Uint8Array; } /// One independently reconciled secondary window returned by /// `windows(model)`. The generated launcher compiles /// `src/windows/