@native-sdk/cli 0.9.4 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +75 -57
  3. package/build/ts_run.mjs +1 -1
  4. package/build.zig +20 -2
  5. package/package.json +11 -10
  6. package/packages/core/package-lock.json +12 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/compiler_command.mjs +1 -1
  9. package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
  10. package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
  11. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  12. package/packages/core/sdk/events.d.ts +33 -4
  13. package/packages/core/sdk/events.ts +45 -6
  14. package/packages/core/src/checker.ts +103 -8
  15. package/packages/core/src/modules.ts +6 -2
  16. package/packages/core/src/sqlite_cli.ts +22 -2
  17. package/packages/core/src/typed_ast.ts +4 -2
  18. package/packages/core/src/types.ts +8 -8
  19. package/schemas/app.schema.json +446 -0
  20. package/skill-data/core/SKILL.md +53 -15
  21. package/skill-data/core/references/project-anatomy.md +6 -6
  22. package/skill-data/native-ui/SKILL.md +26 -5
  23. package/skill-data/ts-core/SKILL.md +6 -6
  24. package/skill-data/ts-services/references/service-surface.md +1 -1
  25. package/skills/native-sdk/SKILL.md +2 -2
  26. package/src/app_runner/root.zig +25 -0
  27. package/src/automation/snapshot.zig +91 -3
  28. package/src/platform/macos/appkit_host.h +66 -2
  29. package/src/platform/macos/appkit_host.m +735 -24
  30. package/src/platform/macos/cef_host.mm +208 -9
  31. package/src/platform/macos/root.zig +205 -3
  32. package/src/platform/null_platform.zig +50 -1
  33. package/src/platform/null_platform_tests.zig +53 -0
  34. package/src/platform/root.zig +12 -0
  35. package/src/platform/types.zig +73 -0
  36. package/src/platform/windows/root.zig +88 -15
  37. package/src/primitives/app_manifest/tests.zig +19 -0
  38. package/src/primitives/app_manifest/validation.zig +14 -2
  39. package/src/primitives/canvas/font_ttf.zig +24 -0
  40. package/src/primitives/canvas/gpu.zig +5 -0
  41. package/src/primitives/canvas/reference.zig +41 -16
  42. package/src/primitives/canvas/reference_tests.zig +63 -0
  43. package/src/primitives/canvas/render_tests.zig +1 -1
  44. package/src/primitives/canvas/root.zig +1 -0
  45. package/src/primitives/canvas/serialization.zig +1 -0
  46. package/src/primitives/canvas/test_support.zig +1 -0
  47. package/src/primitives/canvas/text.zig +1 -0
  48. package/src/primitives/canvas/text_layout.zig +84 -15
  49. package/src/primitives/canvas/text_layout_hash.zig +3 -1
  50. package/src/primitives/canvas/text_layout_types.zig +3 -0
  51. package/src/primitives/canvas/text_metrics.zig +28 -1
  52. package/src/primitives/canvas/text_tests.zig +61 -6
  53. package/src/primitives/canvas/ui.zig +9 -0
  54. package/src/primitives/canvas/ui_markup.zig +29 -0
  55. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  56. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  57. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  58. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  59. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  60. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  61. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  62. package/src/primitives/canvas/ui_schema.zig +9 -0
  63. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  64. package/src/primitives/canvas/ui_tests.zig +4 -2
  65. package/src/primitives/canvas/widget_render.zig +13 -2
  66. package/src/primitives/canvas/widget_render_controls.zig +1 -0
  67. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  68. package/src/root.zig +6 -0
  69. package/src/runtime/automation_snapshot.zig +3 -0
  70. package/src/runtime/canvas_fonts.zig +87 -0
  71. package/src/runtime/core.zig +1 -0
  72. package/src/runtime/flow.zig +8 -1
  73. package/src/runtime/native_command_event_tests.zig +58 -0
  74. package/src/runtime/state.zig +14 -0
  75. package/src/runtime/system_services.zig +62 -0
  76. package/src/runtime/ts_ui_app.zig +161 -33
  77. package/src/runtime/ui_app.zig +33 -1
  78. package/src/runtime/ui_app_tests.zig +63 -0
  79. package/src/runtime/validation.zig +87 -1
  80. package/src/tooling/android.zig +5 -4
  81. package/src/tooling/buildgraph.zig +24 -8
  82. package/src/tooling/db.zig +1 -1
  83. package/src/tooling/doctor.zig +1 -1
  84. package/src/tooling/ios.zig +5 -4
  85. package/src/tooling/json_to_zon.zig +136 -0
  86. package/src/tooling/manifest.zig +199 -35
  87. package/src/tooling/package.zig +33 -0
  88. package/src/tooling/raw_manifest.zig +11 -0
  89. package/src/tooling/root.zig +2 -0
  90. package/src/tooling/templates.zig +210 -116
  91. package/src/tooling/ts_core.zig +11 -7
  92. package/src/tooling/update.zig +576 -0
  93. package/src/tooling/verbs.zig +7 -6
  94. package/src/tooling/web_engine.zig +17 -1
  95. package/src/updater/c_api.zig +123 -0
  96. package/src/updater/feed.zig +215 -0
  97. package/src/updater/root.zig +10 -0
@@ -4,13 +4,13 @@ Use this when creating, orienting in, or restructuring a Native SDK app.
4
4
 
5
5
  ## Generated project files
6
6
 
7
- A default zero-config app ships no build files at all. Its authored files are `app.zon`, `src/core.ts`, and `src/app.native` (+ `assets/`). `native check` validates the TypeScript core, markup, and manifest without generating a build graph; `native dev|test|build` compile the app to native code and synthesize the build graph into `.native/build/` (gitignored). `build.zig`/`build.zig.zon` appear only in apps that own their build (`native eject`, the `--full` scaffold, or an expanded example). A Zig core is an explicit alternative created with `--template zig-core`, not something to infer from the SDK's implementation or older examples.
7
+ A default zero-config app ships no build files at all. Its authored files are `app.json`, `src/core.ts`, and `src/app.native` (+ `assets/`). Existing `app.zon` manifests remain fully supported. `native check` validates the TypeScript core, markup, and manifest without generating a build graph; `native dev|test|build` compile the app to native code and synthesize the build graph into `.native/build/` (gitignored). `build.zig`/`build.zig.zon` appear only in apps that own their build (`native eject`, the `--full` scaffold, or an expanded example). A Zig core is an explicit alternative created with `--template zig-core`, not something to infer from the SDK's implementation or older examples.
8
8
 
9
9
  Files by path:
10
10
 
11
11
  - `build.zig`: Zig build graph. Expanded scaffolds expose platform selection, trace mode, debug overlay, automation, JS bridge, web engine overrides, frontend install/build/dev steps, tests, and package steps.
12
12
  - `build.zig.zon`: Zig package manifest and dependency declaration.
13
- - `app.zon`: app manifest read by CLI/build/package/doctor tooling.
13
+ - `app.json`: default app manifest read by CLI/build/package/doctor tooling. `app.zon` is the supported alternative.
14
14
  - `src/core.ts`: the default app core — `Model`, `Msg`, `update`, pure helpers, effects (`Cmd`), and subscriptions (`Sub`).
15
15
  - `src/app.native`: the default app view — elements, layout, bindings, and typed message dispatch.
16
16
  - `src/main.zig`: present for an explicitly selected Zig core or lower-level WebView/runtime app; app state, `app()` method, source resolver, optional bridge dispatcher, lifecycle callbacks.
@@ -18,9 +18,9 @@ Files by path:
18
18
  - `assets/`: icons and other package resources.
19
19
  - `frontend/`: framework app when using Next, Vite, React, Svelte, or Vue.
20
20
 
21
- ## app.zon responsibilities
21
+ ## App manifest responsibilities
22
22
 
23
- Keep product-level metadata and policies in `app.zon`:
23
+ Keep product-level metadata and policies in `app.json` (or `app.zon` in an existing project):
24
24
 
25
25
  ```zig
26
26
  .{
@@ -115,11 +115,11 @@ zig build test-package-cef-layout -Dplatform=macos
115
115
 
116
116
  ## Layering rule
117
117
 
118
- - If changing app identity, packaging inputs, permissions, origins, windows, frontend dist/dev paths, or web engine, update `app.zon`.
118
+ - If changing app identity, packaging inputs, permissions, origins, windows, frontend dist/dev paths, or web engine, update the app's manifest.
119
119
  - If changing default app state, messages, transitions, effects, subscriptions, or derived bindings, update `src/core.ts` and follow the `ts-core` skill.
120
120
  - If changing the default app UI, update `src/app.native` and follow the `native-ui` skill.
121
121
  - If changing runtime services, platform setup, automation, logging, security wiring, or builtin bridge policy, update `src/runner.zig`.
122
122
  - If an existing lower-level/Zig app changes native lifecycle callbacks, bridge handlers, source selection, or Zig-core behavior, update its `src/main.zig`.
123
123
  - If changing UI, routes, CSS, or web calls, update `frontend/`.
124
124
 
125
- Do not add `src/main.zig`, `src/runner.zig`, or an owned build merely to implement ordinary behavior in a default TypeScript app. Do not put package metadata in app state or bypass `app.zon` policy for convenience.
125
+ Do not add `src/main.zig`, `src/runner.zig`, or an owned build merely to implement ordinary behavior in a default TypeScript app. Do not put package metadata in app state or bypass manifest policy for convenience.
@@ -34,7 +34,7 @@ export function statusItem(model: Model): StatusItemState {
34
34
  activationCommand: asciiBytes("app.refresh"),
35
35
  alternateActivationCommand: asciiBytes("player.toggle"),
36
36
  openCommand: asciiBytes("app.refresh"),
37
- presentation: { title: model.playing ? utf8Bytes("MB PLAY") : utf8Bytes("MB"), width: 62, tone: "normal", iconOpacity: 1, monospaced: true },
37
+ presentation: { title: model.playing ? utf8Bytes("MB PLAY") : utf8Bytes("MB"), width: 62, tone: "normal", iconOpacity: 1, monospaced: true, fontSize: 13, fontWeight: "semibold" },
38
38
  items: [
39
39
  { id: 1, label: utf8Bytes("Open"), command: asciiBytes("app.open"), separator: false, enabled: true, detail: asciiBytes(""), role: "command", key: asciiBytes(""), modifiers: { primary: false, command: false, control: false, option: false, shift: false } },
40
40
  { id: 0, label: asciiBytes(""), command: asciiBytes(""), separator: true, enabled: false, detail: asciiBytes(""), role: "command", key: asciiBytes(""), modifiers: { primary: false, command: false, control: false, option: false, shift: false } },
@@ -44,7 +44,7 @@ export function statusItem(model: Model): StatusItemState {
44
44
  }
45
45
  ```
46
46
 
47
- Presentation fields are `title`, `width`, `tone`, `iconOpacity`, and `monospaced`. Rows add secondary `detail`, a semantic `command | info | header | hero | agent | context` role, a key equivalent, and all five modifier booleans to the ordinary id/label/command/separator/enabled fields. Actionable rows need unique non-zero whole u32 ids; separators conventionally use id 0, and the menu cap is 32 rows. `examples/menu-bar` is the full TypeScript + Native markup hide/Open/Quit lifecycle. The lower-level Zig `Options.status_item` / `status_item_fn` recipe appears below for Zig cores and custom wiring.
47
+ Presentation fields style the persistent menu-bar item. Inside its dropdown, `metric` carries prominent primary/secondary text, `segmented` carries up to eight typed command options, and `chart` carries 1–32 bounded values with captions and accessibility. These are generic composable row payloads, not text conventions.
48
48
 
49
49
  ## App wiring (Zig cores and extensions only)
50
50
 
@@ -215,7 +215,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
215
215
  | `skeleton`, `spinner` | loading leaves | size `skeleton` with `width`/`height` |
216
216
  | `icon` | vector icon leaf | `name` picks the icon: a bare literal is a curated built-in stroke icon (compile-checked; 49 names: search, plus, x, x-circle, check, check-circle, chevron-up/down/left/right, arrow-up/down/right, menu, panel-left, panel-right, settings, terminal, wrench, trash, edit, copy, external-link, play, pause, skip-back/forward, shuffle, repeat, music, volume, info, alert, download, save, folder, folder-open, file-text, sun, moon, eye, clock, git-pull-request, git-merge, git-branch, circle-dot, archive, refresh-cw, send); `app:<name>` reaches an icon the app registered at boot with `canvas.icons.registerAppIcons` (declare the table as `pub const app_icons` on the app root so `native check` verifies the name against the model contract), and one `{binding}` defers the choice to model data - an unknown resolved name draws the missing-icon fallback (a slashed circle) with a Debug warning naming the value, never a silent gap; tint with `foreground`, size with `width`/`height` |
217
217
  | `media-surface` | media surface leaf | composites a texture produced OUTSIDE the widget tree (video decoder, camera, an external renderer like mpv) into the layout like any widget — clipped, z-ordered, rounded. `surface="{binding}"` (required) binds the model-owned u64 surface id a Zig-tier producer targets (`runtime.acquireMediaSurfaceProducer` pushes RGBA8 frames, latest-wins, paced by the presented-frame clock; 0 = unbound, draws nothing; usable ids are nonzero values below the reserved bit 63). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content). Texture contents are presentation chrome: goldens, reference screenshots, and session replay show the deterministic id-derived placeholder, never producer frames |
218
- | `image` | runtime image leaf | draws a RUNTIME-REGISTERED image by its model-owned u64 ImageId — the id `Cmd.imageLoad` (TS) or `fx.loadImage`/`fx.registerImageBytes` (Zig) registered pixels under. `image="{binding}"` (required) binds a model field/fn; ids are model data, never markup literals, and 0 draws nothing (store the id only when the load reports loaded — see the Images section). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content) |
218
+ | `image` | runtime image leaf | draws a RUNTIME-REGISTERED image by its model-owned u64 ImageId — the id `Cmd.imageLoad` (TS) or `fx.loadImage`/`fx.registerImageBytes` (Zig) registered pixels under. `image="{binding}"` (required) binds a model field/fn; ids are model data, never markup literals, and 0 draws nothing (store the id only when the load reports loaded — see the Images section). `source-x`/`source-y`/`source-width`/`source-height` select one atlas region in decoded-image pixel coordinates (declare all four). No intrinsic size — give it `width`/`height` or `grow`; display-only (presses fall through); `label` it (pictorial content) |
219
219
  | `code` | bare highlighted source/editor | `source="{binding}"` (required) provides source text and `language="tsx"` selects a literal lexer name; the component supplies no background, border, radius, shadow, or padding, so wrap it in a panel/card when chrome is wanted. It is read-only by default; `editable on-input="edit"` opts into multiline editing while retaining highlighting. It wraps by default, `line-numbers` opts into logical line numbers, `added-lines="5"` / `removed-lines="2-4"` add Geist-style diff rows without changing copied source, and `wrap="false"` preserves lines inside one horizontal scroll region. HTML-family highlighting distinguishes HTML/XML/SVG and JSX/TSX tags, attributes, strings, comments, and embedded expressions. Zig builder: `ui.code(CodeOptions, source)` |
220
220
  | `markdown` | rendered markdown subtree | leaf; `source` is one `{binding}` — see "Markdown in markup" |
221
221
  | `stepper` > `step` | composite stage track | `active="{index}"` (required) derives each step's completed/active/pending state; steps are text leaves (no attributes) joined by connectors; stepper also takes `key`, `global-key`, `label` |
@@ -224,7 +224,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
224
224
  | `context-menu` | consumed by its parent | right-click menu on its DIRECT parent (a hit-target kind or an element with `on-press`/`on-double-press`/`on-toggle`/`on-hold`/`on-drag`); metadata, never a flow child. Children: `menu-item`s (`on-press` required, `disabled` optional, no `icon`) and bare `separator`s, with `if`/`else`/`for` around them. Attribute-less; presents natively where the host has a menu presenter, as an anchored surface elsewhere — see "Context menus" |
225
225
  | `input-group` > `textarea` + `input-group-actions` | composite grouped input | the composer shape: ONE bordered field wrapping exactly one `textarea` (first — document order is focus order) plus an optional `input-group-actions` row of controls inside the same border. The group wears the focus ring for its focused descendant and the textarea's own chrome dissolves automatically, so the whole group reads as one field; the textarea keeps its full behavior (`text`, `placeholder`, `on-input`, `on-submit`, `autofocus`, and optional `submit-on-enter`). Group takes `label`, `width`, `height`, `min-width`, `grow`, `key`, `global-key`; the actions row takes `gap` and holds ordinary elements (`if`/`else`/`for` work — swap send for stop while streaming) — put a `<spacer grow="1"/>` between leading and trailing controls (`Ui.inputGroup`/`Ui.inputGroupActions` are the Zig-view equivalents) |
226
226
 
227
- Not markup-expressible (deliberately — write these as Zig view functions with `canvas.Ui`): `icon_button` (`<button icon="...">` with empty content is the declarative icon button), `data_grid` (per-column cell templates), `popover`/`menu_surface` (anchored to runtime geometry), `segmented_control` (use `tabs`/`toggle-group`: `<button>` children of `<tabs>` lower to segmented triggers automatically, so the active tab lifts per the house treatment). Charts ARE expressible: `<chart>` with `<series values="{binding}">` children binding model f32 iterables — see the Charts section (`.band` series and dynamic series composition stay with `ui.chart`). Built-in vector icons ARE expressible: `<icon name="search"/>` (closed, compile-checked name set; `Ui.icon` is the Zig-view equivalent). App-authored icons: `canvas.svg_icon.parseComptime(@embedFile("icons/logo.svg"))` parses any SVG in the common 24x24 stroke-icon dialect at comptime; register the parsed table once at boot with `canvas.icons.registerAppIcons(&table)` and draw by name via `ui.appIcon(.{...}, "logo")` or `ElementOptions.icon` — registered names render exactly like built-ins on every draw path. Markup `<icon>`/`<button icon>` stay built-in-only (the compiled engine validates names at comptime, where runtime registrations cannot exist — engine parity). Runtime images ARE expressible: `<image image="{cover}" width="120" height="80" label="Cover art"/>` and `<avatar image="{user_image}">CT</avatar>` bind a `u64` ImageId model field/fn (the id is just model data; 0 draws nothing / keeps the initials fallback) — see the Images section; the `image` binding is required on the leaf (an unbound `<image>` is dead markup) and stays avatar+image scoped.
227
+ Not markup-expressible (deliberately — write these as Zig view functions with `canvas.Ui`): `icon_button` (`<button icon="...">` with empty content is the declarative icon button), `data_grid` (per-column cell templates), `popover`/`menu_surface` (anchored to runtime geometry), `segmented_control` (use `tabs`/`toggle-group`: `<button>` children of `<tabs>` lower to segmented triggers automatically, so the active tab lifts per the house treatment). Charts ARE expressible: `<chart>` with `<series values="{binding}">` children binding model f32 iterables — see the Charts section (`.band` series and dynamic series composition stay with `ui.chart`). Built-in vector icons ARE expressible: `<icon name="search"/>` (closed, compile-checked name set; `Ui.icon` is the Zig-view equivalent). App-authored icons: `canvas.svg_icon.parseComptime(@embedFile("icons/logo.svg"))` parses any SVG in the common 24x24 stroke-icon dialect at comptime; register the parsed table once at boot with `canvas.icons.registerAppIcons(&table)` and draw by name via `ui.appIcon(.{...}, "logo")` or `ElementOptions.icon` — registered names render exactly like built-ins on every draw path. Markup `<icon>`/`<button icon>` stay built-in-only (the compiled engine validates names at comptime, where runtime registrations cannot exist — engine parity). Runtime images ARE expressible: `<image image="{cover}" width="120" height="80" label="Cover art"/>` and `<avatar image="{user_image}">CT</avatar>` bind a `u64` ImageId model field/fn (the id is just model data; 0 draws nothing / keeps the initials fallback) — see the Images section; the `image` binding is required on the leaf (an unbound `<image>` is dead markup) and stays avatar+image scoped. Add all four `source-x`/`source-y`/`source-width`/`source-height` attributes to draw one decoded-pixel sub-rectangle from a shared atlas.
228
228
 
229
229
  ## Attributes
230
230
 
@@ -979,6 +979,27 @@ The view binds that model-owned id in either tier; `0` is the no-image sentinel
979
979
  <avatar image="{avatar}" label="Octocat">OC</avatar>
980
980
  ```
981
981
 
982
+ One registered image can be a texture atlas. The source rectangle uses
983
+ decoded-image pixel coordinates; declare all four markup attributes, or set
984
+ the equivalent `ElementOptions.image_src` `geometry.RectF` in a Zig view.
985
+ Cropped widgets use nearest sampling so adjacent atlas regions cannot bleed:
986
+
987
+ ```html
988
+ <image image="{atlas}" source-x="64" source-y="32"
989
+ source-width="24" source-height="24" width="48" height="48"
990
+ label="Warning badge" />
991
+ ```
992
+
993
+ ```zig
994
+ ui.image(.{
995
+ .image = model.atlas_image,
996
+ .image_src = geometry.RectF.init(64, 32, 24, 24),
997
+ .width = 48,
998
+ .height = 48,
999
+ .semantics = .{ .label = "Warning badge" },
1000
+ })
1001
+ ```
1002
+
982
1003
  ### Zig cores and extensions: direct registration
983
1004
 
984
1005
  Image pixels are runtime-registered resources keyed by a caller-chosen `ImageId` (`u64` in the model, effect-key style; 0 = no image). The framework bundles NO codecs — encoded bytes decode through the platform (CGImageSource / gdk-pixbuf / WIC) via `PlatformServices.decode_image_fn`. Registration lives on the effects channel (synchronous calls, not effects — no Msg follows):
@@ -995,7 +1016,7 @@ Image pixels are runtime-registered resources keyed by a caller-chosen `ImageId`
995
1016
  ```
996
1017
 
997
1018
  ```zig
998
- // Zig views (image and icon content is markup-excluded):
1019
+ // Zig views:
999
1020
  ui.avatar(.{ .image = model.avatar_image, .semantics = .{ .label = "Octocat" } }, "OC"),
1000
1021
  ui.image(.{ .image = model.chart_image, .width = 120, .height = 80, .semantics = .{ .label = "Chart" } }),
1001
1022
  ```
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: ts-core
3
- description: Authoring guide for the primary Native SDK app-logic path: TypeScript app cores - Model, Msg, update, and the pure functions they call, written in the closed app-core subset, checked by the @native-sdk/core frontend, and compiled ahead-of-time to native code by the external core compiler. Use for new apps unless the user explicitly chose Zig, when writing or modifying a src/core.ts app core, fixing subset checker errors (NS1001-NS1069), or deciding how to express state, messages, text (bytes and the byte-text string methods), text input, continuous controls (sliders, scroll), effects (Cmd), subscriptions (Sub), the host-event wiring channels (frameMsg, keyMsg, pinchMsg, dropMsg, appearanceMsg, chromeMsg, envMsgs, app.zon assets), derived values, the view_unbound lint opt-out, local mutation of owned arrays, or how to split a core into modules under src/ (relative imports, namespace imports, @native-sdk/core/text, @native-sdk/core/events). Use ts-services alongside this guide for src/services work.
3
+ description: Authoring guide for the primary Native SDK app-logic path: TypeScript app cores - Model, Msg, update, and the pure functions they call, written in the closed app-core subset, checked by the @native-sdk/core frontend, and compiled ahead-of-time to native code by the external core compiler. Use for new apps unless the user explicitly chose Zig, when writing or modifying a src/core.ts app core, fixing subset checker errors (NS1001-NS1069), or deciding how to express state, messages, text (bytes and the byte-text string methods), text input, continuous controls (sliders, scroll), effects (Cmd), subscriptions (Sub), the host-event wiring channels (frameMsg, keyMsg, pinchMsg, dropMsg, appearanceMsg, chromeMsg, envMsgs, app manifest assets), derived values, the view_unbound lint opt-out, local mutation of owned arrays, or how to split a core into modules under src/ (relative imports, namespace imports, @native-sdk/core/text, @native-sdk/core/events). Use ts-services alongside this guide for src/services work.
4
4
  ---
5
5
 
6
6
  # Author app cores in the TypeScript subset
7
7
 
8
8
  TypeScript is the primary app-authoring language. An app core is a Native SDK app's deterministic logic: `Model` (the app state), `Msg` (a discriminated union of everything that can happen), `update(model, msg)` (the one pure transition function), and the pure helpers they call. You write it as a TypeScript module rooted at `src/core.ts` - splitting into more modules under `src/` when it grows (see "Splitting a core into modules") - and the build checks the whole import graph with the `@native-sdk/core` frontend and compiles it to native code with the external core compiler. No JS engine ships in the binary — the program either passes the subset checker and compiles to native, or you get a teaching error naming the rule, the fix, and the reason. The same file is executable TypeScript: it typechecks with stock tsc and runs unmodified under node, so you can poke behavior with plain node scripts before the native build.
9
9
 
10
- A whole TS app starts as three files of truth and zero Zig: `src/core.ts` (this guide; plus core-class modules it imports under `src/`), `src/app.native` (the markup view over the core's model), and `app.zon` (windows, identity, permissions). Optional ordinary-TypeScript service modules live under `src/services/` and are never imported by the core; load `native skills get ts-services` for that boundary. `native init` scaffolds the three-file base; the build detects `src/core.ts` in the tree (never a flag or config — a tree with both `src/core.ts` and `src/main.zig` is a teaching error) and generates the wiring outside the app. The loop:
10
+ A whole TS app starts as three files of truth and zero Zig: `src/core.ts` (this guide; plus core-class modules it imports under `src/`), `src/app.native` (the markup view over the core's model), and `app.json` (windows, identity, permissions). Existing `app.zon` manifests remain supported. Optional ordinary-TypeScript service modules live under `src/services/` and are never imported by the core; load `native skills get ts-services` for that boundary. `native init` scaffolds the three-file base; the build detects `src/core.ts` in the tree (never a flag or config — a tree with both `src/core.ts` and `src/main.zig` is a teaching error) and generates the wiring outside the app. The loop:
11
11
 
12
12
  ```sh
13
13
  native dev --core # the fastest loop: run the core under node's virtual host —
@@ -15,7 +15,7 @@ native dev --core # the fastest loop: run the core under node's virtual host
15
15
  # for bytes payloads, {"advance":1000} to run virtual timers),
16
16
  # watch the model + effect transcript. Logic only, no renderer.
17
17
  native dev # build and run the real app (markup hot reload)
18
- native check # subset-check core.ts + validate markup + app.zon
18
+ native check # subset-check core.ts + validate markup + app.json/app.zon
19
19
  native build # ReleaseFast binary; native test runs the app's tests
20
20
  ```
21
21
 
@@ -197,7 +197,7 @@ export function statusItem(model: Model): StatusItemState {
197
197
  activationCommand: asciiBytes("app.refresh"),
198
198
  alternateActivationCommand: asciiBytes("player.toggle"),
199
199
  openCommand: asciiBytes("app.refresh"),
200
- presentation: { title: model.playing ? utf8Bytes("MB PLAY") : utf8Bytes("MB"), width: 62, tone: "normal", iconOpacity: 1, monospaced: true },
200
+ presentation: { title: model.playing ? utf8Bytes("MB PLAY") : utf8Bytes("MB"), width: 62, tone: "normal", iconOpacity: 1, monospaced: true, fontSize: 13, fontWeight: "semibold" },
201
201
  items: [
202
202
  { id: 1, label: utf8Bytes("Open"), command: asciiBytes("app.open"), separator: false, enabled: true, detail: asciiBytes(""), role: "command", key: asciiBytes(""), modifiers: { primary: false, command: false, control: false, option: false, shift: false } },
203
203
  { id: 0, label: asciiBytes(""), command: asciiBytes(""), separator: true, enabled: false, detail: asciiBytes(""), role: "command", key: asciiBytes(""), modifiers: { primary: false, command: false, control: false, option: false, shift: false } },
@@ -207,7 +207,7 @@ export function statusItem(model: Model): StatusItemState {
207
207
  }
208
208
  ```
209
209
 
210
- The canonical records live in `@native-sdk/core/events`. Shell fields are `iconPath`, `tooltip`, `activationCommand`, `alternateActivationCommand`, and `openCommand`; all commands route through `commandMsg(name): Msg | null`. Presentation is exact: `title`, `width` (0 = host default), `tone` (`normal | warning | critical`), `iconOpacity` (0…1), and `monospaced`. Every row has id/label/command/separator/enabled plus byte `detail`, `role` (`command | info | header | hero | agent | context`), byte `key`, and the five explicit modifier booleans. Actionable rows need unique non-zero whole u32 ids and a non-empty label, separators conventionally use id 0, and the runtime cap is 32 rows per item. Row membership and every shell/presentation/menu field may derive from the model. Linux does not implement status items today.
210
+ The canonical records live in `@native-sdk/core/events`. Shell fields are `iconPath`, `tooltip`, `activationCommand`, `alternateActivationCommand`, and `openCommand`; all commands route through `commandMsg(name): Msg | null`. Presentation requires `title`, `width` (0 = host default), `tone`, `iconOpacity`, and `monospaced`; optional `fontSize` (omitted/0 = platform default) and `fontWeight` (omitted = `regular`; otherwise `regular | medium | semibold | bold`) add typography without breaking older cores. Use `statusItems` to compose several persistent menu-bar text/icon items with independent typography; attach the dropdown rows to whichever descriptor should open it. Actionable rows need unique non-zero whole u32 ids, and the runtime cap is 32 rows per item. Linux does not implement status items today.
211
211
 
212
212
  For multiple items export `statusItems(model): readonly StatusItemDescriptor[]` instead (never both helpers). A descriptor has the singular fields plus stable non-zero `id` identity and live `visible`. Presence creates, absence removes, and changed icon/title/tooltip/visibility/activation/menu fields patch only that id; one menu update never recreates any native item. macOS supports eight simultaneous items. Row ids are scoped to one menu, so different status items may reuse them. This is the Vercel-shaped spend-indicator plus persistent-control-item surface.
213
213
 
@@ -396,7 +396,7 @@ export type Msg = /* ... */ | { readonly kind: "library_scrolled"; readonly scro
396
396
  The generated wiring detects each channel from an export (export exists → wired; a wrong shape is a taught NS1033). Event records are matched by field name, STRUCTURALLY: import them from `@native-sdk/core/events` (`FrameEvent`, `KeyEvent`, `PinchEvent`, `FileDropEvent`, `ColorScheme`, `ChromeInsets`/`ChromeButtons`) or declare the same shapes in your core — both emit as your module's types and match identically. The `appearanceMsg`/`chromeMsg` arms themselves stay inline union members (`kind` plus the event's fields — the subset has no intersection arms); the SDK's `AppearanceEvent`/`ChromeEvent` records are those arms' canonical payload shapes, importable for helper signatures.
397
397
 
398
398
  - **`commandMsg(name: string): Msg | null`** — menus, shortcuts, and chrome tabs, by command id (string equality works on `string` values).
399
- - **`statusItem(model: Model): StatusItemState` / `statusItems(model: Model): readonly StatusItemDescriptor[]`** — one complete menu-bar item, or a stable-id collection: live icon/tooltip/visibility/click hooks, presentation, and dropdown. The generated launcher reconciles after committed updates; import the exact records from `@native-sdk/core/events`.
399
+ - **`statusItem(model: Model): StatusItemState` / `statusItems(model: Model): readonly StatusItemDescriptor[]`** — one complete menu-bar item, or a stable-id collection. Presentation includes generic title typography. Dropdown rows include a typed `metric` block, typed segmented options, and bounded chart data; never encode these as text conventions. The generated launcher reconciles after committed updates.
400
400
  - **`themeState(model: Model): ThemeState`** — the stock theme's model-owned pack, color scheme, and accent. Import `ThemeState` from `@native-sdk/core/events`; each field is optional (`pack`, `colorScheme`, `accent`). Omit a field to inherit app.zon, use `colorScheme: "system"` (or omit it) to follow the OS, and spell accents exactly `#rrggbb`. High contrast/reduced motion remain system-owned and high contrast suppresses accents. `themePack(model)` remains the pack-only compatibility helper; export one or the other, never both. Complete `tokens_fn`/`tokens` wiring takes precedence. Forced scheme applies to canvas tokens in v1; native chrome and WebViews remain OS-themed.
401
401
  - **`windows(model: Model): readonly WindowDescriptor[]`** — the model-declared secondary-window set. The launcher compiles `src/windows/<label>.native`, reconciles descriptor presence after committed updates, projects `closePolicy`, and routes a `.quit` `onCloseCommand` through `commandMsg`.
402
402
  - **`frameMsg(model: Model, frame: FrameEvent): Msg | null`** — presented frames. `FrameEvent` is exactly `{ width, height, timestampMs, intervalMs }` numbers (canvas points; fractional milliseconds). Return null for frames that change nothing — the idle law holds exactly when an idle app dispatches nothing (a frame arm that always returns a Msg would spin the loop at full frame rate). The installing frame is excluded; the first PRESENTED frame corrects any seeded value.
@@ -6,7 +6,7 @@
6
6
  Verify without writing:
7
7
  node packages/core/scripts/gen_service_surface.mjs --check -->
8
8
 
9
- # Service compile surface — scriptc 0.0.33
9
+ # Service compile surface — scriptc 0.0.35
10
10
 
11
11
  What TypeScript under `src/services/` can use, as stated by the pinned
12
12
  compiler itself (surface manifest schema 1, 527 entries:
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: native-sdk
3
- description: Discovery skill for the Native SDK, the complete toolkit for building native desktop applications. Apps are authored in TypeScript + declarative Native markup (.native) by default and compiled to native code with no JS runtime in the binary; Zig cores are an explicit alternative, and WebViews are the optional web-content path. Use when the user asks what the Native SDK is, how to build a Native SDK app, author native UI, scaffold an app, configure app.zon, add bridge commands, embed web content, package an app, test a running app, or automate a Native SDK app.
3
+ description: Discovery skill for the Native SDK, the complete toolkit for building native desktop applications. Apps are authored in TypeScript + declarative Native markup (.native) by default and compiled to native code with no JS runtime in the binary; Zig cores are an explicit alternative, and WebViews are the optional web-content path. Use when the user asks what the Native SDK is, how to build a Native SDK app, author native UI, scaffold an app, configure app.json or legacy app.zon, add bridge commands, embed web content, package an app, test a running app, or automate a Native SDK app.
4
4
  allowed-tools: Bash(native:*), Bash(npx @native-sdk/cli:*)
5
5
  hidden: true
6
6
  ---
@@ -31,4 +31,4 @@ cd my_app
31
31
  native dev
32
32
  ```
33
33
 
34
- `native init my_app` generates the primary three-file app: `app.zon`, `src/app.native` (the markup view), and `src/core.ts` (`Model`, `Msg`, `update`). Inspect the tree before editing an existing app and preserve the core language it already uses. `src/main.zig` means the app explicitly uses the Zig-core template; web-frontend shells additionally carry `frontend/` and usually owned build/runtime wiring.
34
+ `native init my_app` generates the primary three-file app: `app.json`, `src/app.native` (the markup view), and `src/core.ts` (`Model`, `Msg`, `update`). Existing `app.zon` manifests remain supported. Inspect the tree before editing an existing app and preserve the core language it already uses. `src/main.zig` means the app explicitly uses the Zig-core template; web-frontend shells additionally carry `frontend/` and usually owned build/runtime wiring.
@@ -95,6 +95,9 @@ pub const RunOptions = struct {
95
95
  .window_title = self.window_title,
96
96
  .bundle_id = self.bundle_id,
97
97
  .icon_path = self.icon_path,
98
+ .update_feed_url = manifestUpdateString("feed_url"),
99
+ .update_public_key = manifestUpdateString("public_key"),
100
+ .update_check_on_start = manifestUpdateCheckOnStart(),
98
101
  .main_window = .{
99
102
  .id = 1,
100
103
  .label = "main",
@@ -155,6 +158,23 @@ pub const RunOptions = struct {
155
158
  }
156
159
  };
157
160
 
161
+ fn manifestUpdateString(comptime field: []const u8) []const u8 {
162
+ if (comptime !@hasField(@TypeOf(app_manifest), "updates")) return "";
163
+ const updates = app_manifest.updates;
164
+ if (comptime !@hasField(@TypeOf(updates), field)) return "";
165
+ const value = @field(updates, field);
166
+ return switch (@typeInfo(@TypeOf(value))) {
167
+ .optional => value orelse "",
168
+ else => value,
169
+ };
170
+ }
171
+
172
+ fn manifestUpdateCheckOnStart() bool {
173
+ if (comptime !@hasField(@TypeOf(app_manifest), "updates")) return false;
174
+ if (comptime !@hasField(@TypeOf(app_manifest.updates), "check_on_start")) return false;
175
+ return app_manifest.updates.check_on_start;
176
+ }
177
+
158
178
  const CommandStorage = struct {
159
179
  commands: [native_sdk.app_manifest.max_commands]native_sdk.Command = undefined,
160
180
 
@@ -1256,6 +1276,11 @@ test "RunOptions resolves manifest commands menus and shortcuts" {
1256
1276
  .app_name = "runner-fixture",
1257
1277
  .bundle_id = "dev.native_sdk.runner_fixture",
1258
1278
  };
1279
+ var info_buffers: StateBuffers = .{};
1280
+ const app_info = options.appInfo(&info_buffers);
1281
+ try std.testing.expectEqualStrings("https://example.com/native-update.json", app_info.update_feed_url);
1282
+ try std.testing.expectEqualStrings("11qYAYKxCrfVS/7TyWQHOg7hcvPapiMlrwIaaPcHURo=", app_info.update_public_key);
1283
+ try std.testing.expect(app_info.update_check_on_start);
1259
1284
 
1260
1285
  var command_storage: CommandStorage = .{};
1261
1286
  const commands = options.resolvedCommands(&command_storage);
@@ -228,6 +228,9 @@ pub const TrayItem = struct {
228
228
  role: platform.TrayItemRole = .command,
229
229
  key: []const u8 = "",
230
230
  modifiers: platform.ShortcutModifiers = .{},
231
+ segmented: ?platform.TraySegmentedRow = null,
232
+ metric: ?platform.TrayMetricRow = null,
233
+ chart: ?platform.TrayChartRow = null,
231
234
  };
232
235
 
233
236
  /// The live status item (tray): current button title + dropdown items.
@@ -643,6 +646,42 @@ pub fn writeText(input: Input, writer: anytype) !void {
643
646
  try writer.writeAll(" tray-item separator\n");
644
647
  continue;
645
648
  }
649
+ if (item.segmented) |segmented| {
650
+ try writer.print(" tray-item #{d} role=segmented options={d}\n", .{ item.id, segmented.options.len });
651
+ for (segmented.options) |option| {
652
+ try writer.print(" tray-segment #{d} label=", .{option.id});
653
+ try writeQuotedSnapshotText(option.label, writer);
654
+ try writer.writeAll(" command=");
655
+ try writeQuotedSnapshotText(option.command, writer);
656
+ try writer.print(" selected={any} enabled={any}\n", .{ option.selected, option.enabled });
657
+ }
658
+ continue;
659
+ }
660
+ if (item.metric) |metric| {
661
+ try writer.print(" tray-item #{d} role=metric primary=", .{item.id});
662
+ try writeQuotedSnapshotText(metric.primary_text, writer);
663
+ try writer.writeAll(" secondary=");
664
+ try writeQuotedSnapshotText(metric.secondary_text, writer);
665
+ try writer.writeAll(" accessibility=");
666
+ try writeQuotedSnapshotText(metric.accessibility_label, writer);
667
+ try writer.writeByte('\n');
668
+ continue;
669
+ }
670
+ if (item.chart) |chart| {
671
+ try writer.print(" tray-item #{d} role=chart caption=", .{item.id});
672
+ try writeQuotedSnapshotText(chart.leading_caption, writer);
673
+ try writer.writeAll(" summary=");
674
+ try writeQuotedSnapshotText(chart.trailing_summary, writer);
675
+ try writer.writeAll(" accessibility=");
676
+ try writeQuotedSnapshotText(chart.accessibility_label, writer);
677
+ try writer.print(" domain=({d},{d}) values=", .{ chart.min_value, chart.max_value });
678
+ for (chart.values, 0..) |value, index| {
679
+ if (index > 0) try writer.writeByte(',');
680
+ try writer.print("{d}", .{value});
681
+ }
682
+ try writer.writeByte('\n');
683
+ continue;
684
+ }
646
685
  try writer.print(" tray-item #{d} label=\"{s}\" command=\"{s}\" enabled={any} detail=\"{s}\" role={s} key=\"{s}\" modifiers=(primary={any},command={any},control={any},option={any},shift={any})\n", .{
647
686
  item.id,
648
687
  item.label,
@@ -982,24 +1021,36 @@ test "snapshot emits the frame_profile line only while profiling" {
982
1021
  try std.testing.expect(std.mem.indexOf(u8, off_writer.buffered(), "frame_profile") == null);
983
1022
  }
984
1023
 
985
- test "snapshot emits tray title and dropdown items" {
986
- var buffer: [1024]u8 = undefined;
1024
+ test "snapshot emits tray title and typed dropdown items" {
1025
+ var buffer: [2048]u8 = undefined;
987
1026
  var writer = std.Io.Writer.fixed(&buffer);
988
1027
  const windows = [_]Window{.{ .title = "Test", .bounds = geometry.RectF.init(0, 0, 100, 100) }};
1028
+ const segments = [_]platform.TraySegmentOption{
1029
+ .{ .id = 20, .label = "Day", .command = "range.day", .selected = true },
1030
+ .{ .id = 21, .label = "Week", .command = "range.week", .enabled = false },
1031
+ };
1032
+ const chart_values = [_]f32{ 0.25, 0.5, 1 };
989
1033
  const items = [_]TrayItem{
990
1034
  .{ .id = 1, .label = "Refresh", .command = "app.refresh" },
1035
+ .{ .role = .hero, .metric = .{ .primary_text = "2,494 requests", .secondary_text = "Today · production", .accessibility_label = "2,494 requests today in production" } },
991
1036
  .{ .separator = true },
992
1037
  .{ .id = 10, .label = "Fix crash on resize", .command = "issue.select.0", .enabled = false, .detail = "warning ⚠", .role = .agent, .key = "q", .modifiers = .{ .command = true } },
1038
+ .{ .role = .segmented, .segmented = .{ .options = &segments } },
1039
+ .{ .role = .chart, .chart = .{ .values = &chart_values, .min_value = 0, .max_value = 1, .leading_caption = "CPU", .trailing_summary = "50%", .accessibility_label = "CPU history, 50 percent" } },
993
1040
  };
994
1041
  try writeText(.{
995
1042
  .windows = &windows,
996
1043
  .trays = &.{.{ .id = 7, .title = "ZN 3", .visible = false, .items = &items }},
997
1044
  }, &writer);
998
1045
  const text = writer.buffered();
999
- try std.testing.expect(std.mem.indexOf(u8, text, "\ntray #7 title=\"ZN 3\" visible=false items=3\n") != null);
1046
+ try std.testing.expect(std.mem.indexOf(u8, text, "\ntray #7 title=\"ZN 3\" visible=false items=6\n") != null);
1000
1047
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
1001
1048
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item separator\n") != null);
1049
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #0 role=metric primary=\"2,494 requests\" secondary=\"Today · production\" accessibility=\"2,494 requests today in production\"\n") != null);
1002
1050
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false detail=\"warning ⚠\" role=agent key=\"q\" modifiers=(primary=false,command=true,control=false,option=false,shift=false)\n") != null);
1051
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #0 role=segmented options=2\n") != null);
1052
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-segment #20 label=\"Day\" command=\"range.day\" selected=true enabled=true\n") != null);
1053
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #0 role=chart caption=\"CPU\" summary=\"50%\" accessibility=\"CPU history, 50 percent\" domain=(0,1) values=0.25,0.5,1\n") != null);
1003
1054
 
1004
1055
  // No tray -> no tray lines.
1005
1056
  var empty_buffer: [512]u8 = undefined;
@@ -1008,6 +1059,43 @@ test "snapshot emits tray title and dropdown items" {
1008
1059
  try std.testing.expect(std.mem.indexOf(u8, empty_writer.buffered(), "tray") == null);
1009
1060
  }
1010
1061
 
1062
+ test "snapshot escapes hostile typed tray row text" {
1063
+ var buffer: [4096]u8 = undefined;
1064
+ var writer = std.Io.Writer.fixed(&buffer);
1065
+ const windows = [_]Window{.{ .title = "Test", .bounds = geometry.RectF.init(0, 0, 100, 100) }};
1066
+ const segments = [_]platform.TraySegmentOption{.{
1067
+ .id = 20,
1068
+ .label = "Day\"\nnext\\",
1069
+ .command = "range.\"day\n",
1070
+ }};
1071
+ const chart_values = [_]f32{0.5};
1072
+ const items = [_]TrayItem{
1073
+ .{ .role = .segmented, .segmented = .{ .options = &segments } },
1074
+ .{ .role = .hero, .metric = .{
1075
+ .primary_text = "2\"\nrequests",
1076
+ .secondary_text = "Today\r\\production",
1077
+ .accessibility_label = "metric\t\x01",
1078
+ } },
1079
+ .{ .role = .chart, .chart = .{
1080
+ .values = &chart_values,
1081
+ .leading_caption = "CPU\"\n",
1082
+ .trailing_summary = "50%\\\r",
1083
+ .accessibility_label = "chart\t\x7f",
1084
+ } },
1085
+ };
1086
+ try writeText(.{
1087
+ .windows = &windows,
1088
+ .trays = &.{.{ .items = &items }},
1089
+ }, &writer);
1090
+ const text = writer.buffered();
1091
+ try std.testing.expect(std.mem.indexOf(u8, text, "tray-segment #20 label=\"Day\\\"\\nnext\\\\\" command=\"range.\\\"day\\n\"") != null);
1092
+ try std.testing.expect(std.mem.indexOf(u8, text, "role=metric primary=\"2\\\"\\nrequests\" secondary=\"Today\\r\\\\production\" accessibility=\"metric\\t\\u0001\"") != null);
1093
+ try std.testing.expect(std.mem.indexOf(u8, text, "role=chart caption=\"CPU\\\"\\n\" summary=\"50%\\\\\\r\" accessibility=\"chart\\t\\u007f\"") != null);
1094
+ // Header, window, tray, segmented wrapper, segment, metric, and chart:
1095
+ // hostile values inject no additional line-oriented records.
1096
+ try std.testing.expectEqual(@as(usize, 7), std.mem.count(u8, text, "\n"));
1097
+ }
1098
+
1011
1099
  test "snapshot emits configured command and app-menu catalogs" {
1012
1100
  var buffer: [2048]u8 = undefined;
1013
1101
  var writer = std.Io.Writer.fixed(&buffer);
@@ -367,6 +367,27 @@ typedef struct {
367
367
  typedef void (*native_sdk_appkit_event_callback_t)(void *context, const native_sdk_appkit_event_t *event);
368
368
  typedef void (*native_sdk_appkit_bridge_callback_t)(void *context, uint64_t window_id, const char *webview_label, size_t webview_label_len, const char *message, size_t message_len, const char *origin, size_t origin_len);
369
369
 
370
+ typedef struct native_sdk_update_verify_result {
371
+ int ok;
372
+ int error_code;
373
+ size_t version_len;
374
+ size_t archive_url_len;
375
+ size_t release_notes_len;
376
+ uint64_t archive_bytes;
377
+ char sha256[64];
378
+ } native_sdk_update_verify_result_t;
379
+
380
+ native_sdk_update_verify_result_t native_sdk_update_verify_feed(
381
+ const char *envelope, size_t envelope_len,
382
+ const char *public_key, size_t public_key_len,
383
+ const char *bundle_id, size_t bundle_id_len,
384
+ const char *current_version, size_t current_version_len,
385
+ const char *target, size_t target_len,
386
+ char *version_out, size_t version_capacity,
387
+ char *archive_url_out, size_t archive_url_capacity,
388
+ char *release_notes_out, size_t release_notes_capacity);
389
+ int native_sdk_update_verify_archive(const char *path, size_t path_len, uint64_t expected_bytes, const char *sha256, size_t sha256_len);
390
+
370
391
  // show_policy 0 = immediate (ordered front at create), 1 = deferred to
371
392
  // the first canvas present (present-before-show: the window is created
372
393
  // ordered-out and `makeKeyAndOrderFront` runs after the first
@@ -396,6 +417,8 @@ void native_sdk_appkit_set_dock_icon_rgba(native_sdk_appkit_host_t *host, const
396
417
  // Debug dev-run path falls back to this when its masked render fails,
397
418
  // keeping the pre-masking behavior (icon shown unshaped) as the floor.
398
419
  void native_sdk_appkit_set_dock_icon_file(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
420
+ void native_sdk_appkit_configure_updates(native_sdk_appkit_host_t *host, const char *feed_url, size_t feed_url_len, const char *public_key, size_t public_key_len, int check_on_start, const char *target, size_t target_len);
421
+ int native_sdk_appkit_check_for_updates(native_sdk_appkit_host_t *host, int user_initiated);
399
422
  void native_sdk_appkit_run(native_sdk_appkit_host_t *host, native_sdk_appkit_event_callback_t callback, void *context);
400
423
  // The host-side shutdown request: a failed event emit asks the host to
401
424
  // deliver SHUTDOWN and stop. While the run loop is live the delivery is
@@ -616,6 +639,8 @@ double native_sdk_appkit_measure_text(uint64_t font_id, double size, const char
616
639
  * not valid UTF-8 or the font id cannot resolve (the engine then keeps
617
640
  * its per-prefix path for that run). */
618
641
  int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const char *text, size_t text_len, float *advances);
642
+ /* Shaped glyph-path bounds for one line, relative to its baseline. */
643
+ int native_sdk_appkit_measure_text_ink(uint64_t font_id, double size, const char *text, size_t text_len, double *min_x, double *max_x, double *min_y, double *max_y);
619
644
 
620
645
  // Register engine-validated TrueType bytes under a canvas font id so
621
646
  // measurement and packet text drawing resolve the id to this exact face.
@@ -705,6 +730,44 @@ typedef struct {
705
730
 
706
731
  typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t status_item_id, uint32_t item_id);
707
732
 
733
+ typedef struct {
734
+ uint32_t item_id;
735
+ const char *label;
736
+ size_t label_len;
737
+ int selected;
738
+ int enabled;
739
+ } native_sdk_appkit_tray_segment_option_t;
740
+
741
+ typedef struct {
742
+ size_t row_index;
743
+ const native_sdk_appkit_tray_segment_option_t *options;
744
+ size_t option_count;
745
+ } native_sdk_appkit_tray_segmented_row_t;
746
+
747
+ typedef struct {
748
+ size_t row_index;
749
+ const char *primary_text;
750
+ size_t primary_text_len;
751
+ const char *secondary_text;
752
+ size_t secondary_text_len;
753
+ const char *accessibility_label;
754
+ size_t accessibility_label_len;
755
+ } native_sdk_appkit_tray_metric_row_t;
756
+
757
+ typedef struct {
758
+ size_t row_index;
759
+ const float *values;
760
+ size_t value_count;
761
+ double min_value;
762
+ double max_value;
763
+ const char *leading_caption;
764
+ size_t leading_caption_len;
765
+ const char *trailing_summary;
766
+ size_t trailing_summary_len;
767
+ const char *accessibility_label;
768
+ size_t accessibility_label_len;
769
+ } native_sdk_appkit_tray_chart_row_t;
770
+
708
771
  /* One native scroll driver's desired state (see PlatformServices
709
772
  * set_gpu_surface_scroll_drivers_fn). Frame coordinates are view-local
710
773
  * canvas points (top-left origin, y-down); the host flips to AppKit
@@ -772,15 +835,16 @@ int native_sdk_appkit_show_context_menu(native_sdk_appkit_host_t *host, uint64_t
772
835
  native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_open_dialog_opts_t *opts, char *buffer, size_t buffer_len);
773
836
  size_t native_sdk_appkit_show_save_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_save_dialog_opts_t *opts, char *buffer, size_t buffer_len);
774
837
  int native_sdk_appkit_show_message_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_message_dialog_opts_t *opts);
775
- void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
838
+ void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
776
839
  void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *tooltip, size_t tooltip_len, int visible, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
777
840
  void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t status_item_id, const uint32_t *item_ids, const char *const *labels, const size_t *label_lens, const int *separators, const int *enabled_flags, const char *const *details, const size_t *detail_lens, const int *roles, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
841
+ void native_sdk_appkit_update_tray_rich_rows(native_sdk_appkit_host_t *host, uint32_t status_item_id, const native_sdk_appkit_tray_segmented_row_t *segmented_rows, size_t segmented_count, const native_sdk_appkit_tray_metric_row_t *metric_rows, size_t metric_count, const native_sdk_appkit_tray_chart_row_t *chart_rows, size_t chart_count);
778
842
  /* Retitle the live status item's button without re-creating it (create
779
843
  * would flicker and reshuffle the menu bar). Empty title falls back to
780
844
  * the icon-only square well, or the app-name initial when there is no
781
845
  * icon either — the same fallbacks as create. */
782
846
  void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len);
783
- void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced);
847
+ void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight);
784
848
  void native_sdk_appkit_remove_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id);
785
849
  void native_sdk_appkit_set_tray_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_tray_callback_t callback, void *context);
786
850