@native-sdk/cli 0.11.0 → 0.11.1

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 (182) hide show
  1. package/build/app.zig +73 -37
  2. package/build.zig +239 -5
  3. package/native-sdk.d.ts +5 -1
  4. package/package.json +13 -12
  5. package/packages/core/compile-surface/core.ts +30 -0
  6. package/packages/core/package-lock.json +6 -6
  7. package/packages/core/package.json +3 -3
  8. package/packages/core/scripts/scriptc-toolchain.json +44 -44
  9. package/packages/core/scripts/stage_external_core.mjs +27 -16
  10. package/packages/core/sdk/core.d.ts +24 -1
  11. package/packages/core/sdk/core.ts +51 -1
  12. package/packages/core/sdk/events.d.ts +5 -0
  13. package/packages/core/sdk/events.ts +10 -0
  14. package/packages/core/src/bridge_descriptors.ts +3 -3
  15. package/packages/core/src/checker.ts +20 -0
  16. package/packages/core/src/cli.ts +2 -11
  17. package/packages/core/src/context_menus.ts +76 -0
  18. package/packages/core/src/diagnostics.ts +7 -0
  19. package/packages/core/src/extent_program.ts +53 -0
  20. package/packages/core/src/frontend.ts +12 -10
  21. package/packages/core/src/markup_canonical.ts +140 -0
  22. package/packages/core/src/markup_construction.ts +189 -0
  23. package/packages/core/src/markup_display.ts +43 -0
  24. package/packages/core/src/markup_document.ts +226 -0
  25. package/packages/core/src/markup_elements.ts +225 -0
  26. package/packages/core/src/markup_expressions.ts +79 -0
  27. package/packages/core/src/markup_imports.ts +146 -0
  28. package/packages/core/src/markup_parser.ts +228 -0
  29. package/packages/core/src/markup_runtime.ts +93 -0
  30. package/packages/core/src/markup_scalars.ts +143 -0
  31. package/packages/core/src/markup_shapes.ts +243 -0
  32. package/packages/core/src/markup_specialized.ts +242 -0
  33. package/packages/core/src/markup_text.ts +86 -0
  34. package/packages/core/src/markup_values.ts +336 -0
  35. package/packages/core/src/portable_sources.json +24 -0
  36. package/packages/core/src/registered_font.ts +2 -3
  37. package/packages/core/src/runtime_policy.ts +24 -0
  38. package/packages/core/src/scalar_text.ts +1 -3
  39. package/packages/core/src/scroll_mutation.ts +86 -0
  40. package/packages/core/src/scroll_tree.ts +86 -0
  41. package/packages/core/src/service_contract.ts +53 -2
  42. package/packages/core/src/sqlite_cli.ts +3 -46
  43. package/packages/core/src/sqlite_codegen.ts +84 -0
  44. package/packages/core/src/staged_rebuild.ts +60 -0
  45. package/packages/core/src/view_bridge.ts +161 -0
  46. package/packages/core/src/view_check.ts +145 -0
  47. package/packages/core/src/view_evaluator.ts +823 -0
  48. package/packages/core/src/view_frontend.ts +340 -218
  49. package/packages/core/src/view_program.ts +221 -0
  50. package/packages/core/src/view_reload.ts +166 -0
  51. package/packages/core/src/view_reload_watch.ts +98 -0
  52. package/packages/core/src/view_sources.ts +34 -0
  53. package/packages/core/src/virtual_windows.ts +88 -0
  54. package/packages/core/src/web_panes.ts +67 -0
  55. package/packages/core/src/widget_continuity.ts +37 -0
  56. package/packages/core/src/widget_reconcile.ts +63 -0
  57. package/packages/core/src/widget_retention.ts +62 -0
  58. package/skill-data/native-ui/SKILL.md +2 -2
  59. package/skill-data/ts-core/SKILL.md +5 -3
  60. package/skill-data/ts-services/references/service-surface.md +29 -5
  61. package/src/app_runner/root.zig +14 -0
  62. package/src/app_runner/ts_compiled_view.zig +88 -17
  63. package/src/app_runner/ts_core_main.zig +43 -5
  64. package/src/app_runner/ts_core_mobile.zig +1 -1
  65. package/src/automation/server.zig +56 -3
  66. package/src/embed/host.zig +2 -0
  67. package/src/embed/tests.zig +2 -0
  68. package/src/embed/ui_host.zig +2 -0
  69. package/src/platform/keyboard_input.zig +32 -0
  70. package/src/platform/linux/root.zig +2 -0
  71. package/src/platform/macos/appkit_host.h +7 -2
  72. package/src/platform/macos/appkit_host.m +31 -9
  73. package/src/platform/macos/cef_host.mm +15 -1
  74. package/src/platform/macos/global_shortcuts.zig +138 -0
  75. package/src/platform/macos/key_codes.zig +102 -0
  76. package/src/platform/macos/keyboard_input.zig +81 -0
  77. package/src/platform/macos/root.zig +25 -3
  78. package/src/platform/macos/webview_inspection_test.m +106 -0
  79. package/src/platform/null_platform.zig +104 -0
  80. package/src/platform/root.zig +14 -0
  81. package/src/platform/types.zig +102 -0
  82. package/src/platform/windows/global_shortcuts.zig +157 -0
  83. package/src/platform/windows/key_codes.zig +63 -0
  84. package/src/platform/windows/keyboard_input.zig +136 -0
  85. package/src/platform/windows/root.zig +15 -0
  86. package/src/primitives/canvas/decision_reuse.zig +133 -0
  87. package/src/primitives/canvas/font_ttf.zig +27 -3
  88. package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
  89. package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
  90. package/src/primitives/canvas/fonts/OFL.txt +93 -0
  91. package/src/primitives/canvas/fonts/README.md +15 -0
  92. package/src/primitives/canvas/intrinsic_measure_policy.zig +4 -1
  93. package/src/primitives/canvas/markdown_tests.zig +3 -3
  94. package/src/primitives/canvas/reference.zig +3 -5
  95. package/src/primitives/canvas/reference_tests.zig +58 -0
  96. package/src/primitives/canvas/registered_font_policy.zig +1 -1
  97. package/src/primitives/canvas/root.zig +7 -4
  98. package/src/primitives/canvas/text_metrics.zig +32 -39
  99. package/src/primitives/canvas/text_metrics_tests.zig +52 -7
  100. package/src/primitives/canvas/text_query_policy.zig +142 -3
  101. package/src/primitives/canvas/text_scalar_policy.zig +80 -2
  102. package/src/primitives/canvas/tokens.zig +9 -0
  103. package/src/primitives/canvas/ui.zig +1 -0
  104. package/src/primitives/canvas/ui_markup.zig +69 -14
  105. package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
  106. package/src/primitives/canvas/ui_markup_compiled.zig +1407 -23
  107. package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
  108. package/src/primitives/canvas/ui_markup_construction.zig +146 -0
  109. package/src/primitives/canvas/ui_markup_display.zig +82 -0
  110. package/src/primitives/canvas/ui_markup_document.zig +196 -0
  111. package/src/primitives/canvas/ui_markup_elements.zig +163 -0
  112. package/src/primitives/canvas/ui_markup_expr.zig +192 -2
  113. package/src/primitives/canvas/ui_markup_imports.zig +262 -0
  114. package/src/primitives/canvas/ui_markup_parser.zig +117 -0
  115. package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
  116. package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
  117. package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
  118. package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
  119. package/src/primitives/canvas/ui_markup_text.zig +128 -0
  120. package/src/primitives/canvas/ui_markup_values.zig +368 -0
  121. package/src/primitives/canvas/ui_markup_view.zig +2817 -74
  122. package/src/primitives/canvas/virtual_extent_policy.zig +58 -0
  123. package/src/primitives/canvas/virtual_extents.zig +47 -33
  124. package/src/primitives/canvas/widget_metric_policy.zig +4 -1
  125. package/src/primitives/canvas/widget_runtime.zig +2 -1
  126. package/src/root.zig +5 -0
  127. package/src/runtime/api.zig +1 -0
  128. package/src/runtime/bridge_descriptor_policy.zig +1 -1
  129. package/src/runtime/bridge_payload.zig +2 -0
  130. package/src/runtime/canvas_widget_context_menu.zig +179 -0
  131. package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
  132. package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
  133. package/src/runtime/canvas_widget_runtime.zig +306 -92
  134. package/src/runtime/context_menu_policy.zig +112 -0
  135. package/src/runtime/core.zig +14 -0
  136. package/src/runtime/effects.zig +172 -4
  137. package/src/runtime/effects_host_tests.zig +25 -0
  138. package/src/runtime/flow.zig +1 -0
  139. package/src/runtime/flow_reference.zig +1 -0
  140. package/src/runtime/global_shortcuts.zig +75 -0
  141. package/src/runtime/keyboard_input.zig +86 -0
  142. package/src/runtime/root.zig +3 -0
  143. package/src/runtime/scroll_mutation_policy.zig +130 -0
  144. package/src/runtime/scroll_mutation_runtime.zig +158 -0
  145. package/src/runtime/scroll_tree_policy.zig +99 -0
  146. package/src/runtime/session_record.zig +7 -0
  147. package/src/runtime/staged_rebuild_policy.zig +83 -0
  148. package/src/runtime/system_services.zig +19 -0
  149. package/src/runtime/tests.zig +1 -0
  150. package/src/runtime/ts_core_host.zig +126 -0
  151. package/src/runtime/ts_ui_app.zig +24 -0
  152. package/src/runtime/ui_app.zig +274 -31
  153. package/src/runtime/ui_app_tests.zig +48 -179
  154. package/src/runtime/ui_app_window_tests.zig +133 -0
  155. package/src/runtime/view_reload.zig +226 -0
  156. package/src/runtime/view_widget_scroll.zig +30 -21
  157. package/src/runtime/view_widget_tree.zig +43 -13
  158. package/src/runtime/virtual_window_policy.zig +128 -0
  159. package/src/runtime/web_pane_policy.zig +111 -0
  160. package/src/runtime/web_pane_test_cases.zig +204 -0
  161. package/src/runtime/widget_continuity_policy.zig +73 -0
  162. package/src/runtime/widget_reconcile_policy.zig +81 -0
  163. package/src/runtime/widget_retention_policy.zig +75 -0
  164. package/src/runtime/window_views.zig +19 -4
  165. package/src/security/root.zig +1 -0
  166. package/src/tooling/templates.zig +8 -0
  167. package/src/tooling/ts_core.zig +84 -1
  168. package/src/tooling/verbs.zig +79 -15
  169. package/tools/corewire/core.test.ts +25 -3
  170. package/tools/corewire/core_abi.zig +4 -0
  171. package/tools/corewire/core_contract.ts +1 -1
  172. package/tools/corewire/core_goldens.json +75 -75
  173. package/tools/corewire/core_projection.ts +3 -2
  174. package/tools/corewire/emit_mirror.ts +19 -9
  175. package/tools/corewire/facade_templates.ts +1 -1
  176. package/tools/corewire/intake.test.ts +4 -0
  177. package/tools/corewire/intake_goldens.json +50 -50
  178. package/tools/corewire/invocation.test.ts +4 -0
  179. package/tools/corewire/invocation_goldens.json +3 -3
  180. package/tools/corewire/mirror_templates.ts +4 -0
  181. package/tools/corewire/profile_emission.ts +2 -0
  182. package/tools/corewire/sidecar.zig +2 -0
@@ -0,0 +1,67 @@
1
+ /** Embedded WebView pane coordination (99). Native owns text and retained
2
+ * storage, supplies exact byte-equality lookup facts and OS outcomes, and
3
+ * executes copied plans. Reload identities remain two complete integer words.
4
+ */
5
+ function nscvWebPanes(request: Uint8Array): Uint8Array {
6
+ if (request.length < 8 || request[0] !== 99 || request[1]! > 3 || request[2]! > 15 || request[3] !== 0)
7
+ throw new Error("invalid web pane header");
8
+ const w = new DataView(request.buffer, request.byteOffset, request.byteLength);
9
+ const word = (at: number): number => w.getUint32(at, true);
10
+ const bounded = (at: number, capacity: number): number => word(at + 4) !== 0 || word(at) > capacity ? capacity : word(at);
11
+ const mode = request[1]!;
12
+ if (mode !== 0 && request[2] !== 0) throw new Error("invalid web pane numeric flags");
13
+ if (mode === 0) {
14
+ if (request.length < 32 || word(4) > 1024 || word(8) > 1 || word(12) !== 0 ||
15
+ request.length !== 32 + word(4) * 20 || word(8) === 0 && word(4) !== 0)
16
+ throw new Error("invalid web pane frame facts");
17
+ const result = new Uint8Array(24), out = new DataView(result.buffer);
18
+ let selected = 4294967295, at = 16;
19
+ for (let i = 0; i < word(4); i++) {
20
+ const row = 32 + i * 20;
21
+ if (word(row) > 1) throw new Error("invalid web pane anchor fact");
22
+ if (selected === 4294967295 && word(row) === 1) { selected = i; at = row + 4; }
23
+ }
24
+ out.setUint32(4, selected, true);
25
+ if (word(8) === 1 && selected === 4294967295) return result;
26
+ if (w.getFloat32(at + 8, true) < 1 || w.getFloat32(at + 12, true) < 1) { out.setUint32(0, 1, true); return result; }
27
+ out.setUint32(0, 2, true);
28
+ result.set(request.subarray(at, at + 16), 8);
29
+ for (let i = 0; i < 2; i++) {
30
+ const value = w.getFloat32(at + i * 4, true);
31
+ // The existing native numeric capability specifies opposite-zero
32
+ // extrema. NaN follows the numeric max operation's non-NaN operand.
33
+ const clamped = value === 0 ? (1 / value < 0 && (request[2]! & 4) !== 0 ? -0 : 0) : Number.isNaN(value) || value < 0 ? 0 : value;
34
+ out.setFloat32(8 + i * 4, clamped, true);
35
+ }
36
+ return result;
37
+ }
38
+ if (mode === 1) {
39
+ if (request.length !== 32 || word(4) > 4 || word(16) > 64 || word(24) !== 0 || word(28) !== 0)
40
+ throw new Error("invalid web pane slot facts");
41
+ const result = new Uint8Array(12), out = new DataView(result.buffer);
42
+ let selected = 4294967295;
43
+ for (let i = 0; i < 4; i++) {
44
+ if (request[20 + i]! > 1 || i >= word(4) && request[20 + i] !== 0) throw new Error("invalid web pane slot match");
45
+ if (i < word(4) && request[20 + i] === 1 && selected === 4294967295) selected = i;
46
+ }
47
+ if (selected !== 4294967295) out.setUint32(0, 1, true);
48
+ else if (word(4) < 4) { selected = word(4); out.setUint32(0, 2, true); out.setUint32(8, bounded(8, word(16)), true); }
49
+ out.setUint32(4, selected, true);
50
+ return result;
51
+ }
52
+ if (mode === 2) {
53
+ if (request.length !== 64 || word(4) > 7 || word(56) !== 0 || word(60) !== 0)
54
+ throw new Error("invalid web pane patch facts");
55
+ let equal = true;
56
+ for (let i = 0; i < 4; i++) if (!(Math.abs(Math.fround(w.getFloat32(24 + i * 4, true) - w.getFloat32(8 + i * 4, true))) < 0.25)) equal = false;
57
+ const tokensEqual = word(40) === word(48) && word(44) === word(52);
58
+ const flags = word(4), result = new Uint8Array(4);
59
+ result[0] = (equal ? 0 : 1) | ((flags & 4) !== 0 && ((flags & 1) !== 0 || (flags & 2) === 0 || !tokensEqual) ? 2 : 0);
60
+ return result;
61
+ }
62
+ if (request.length !== 32 || word(4) > 1 || word(16) > 4096 || word(20) !== 0 || word(24) !== 0 || word(28) !== 0)
63
+ throw new Error("invalid web pane commit facts");
64
+ const result = new Uint8Array(8), out = new DataView(result.buffer);
65
+ if (word(4) === 1) { out.setUint32(0, 1, true); out.setUint32(4, bounded(8, word(16)), true); }
66
+ return result;
67
+ }
@@ -0,0 +1,37 @@
1
+ /** Rebuild continuity over copied facts, without transporting identities or
2
+ * retained pointers. Tag 95: mode (0 layout, 1 semantics), two zero bytes,
3
+ * count u32LE, then 24-byte records. Each record has admission bits, three
4
+ * zeros, current y/x and previous y/x f32LE, and four zeros. Admission bits:
5
+ * keyed, scroll view, vertical/horizontal grant, previous scroll state,
6
+ * source semantics, source list metrics, source scroll metrics. Results use
7
+ * the same eight-byte header followed by one action byte per record:
8
+ * restore list metrics, restore scroll semantics, retain y/x velocity.
9
+ * Native owns exact first-match lookups and copies the selected full records.
10
+ */
11
+ function nscvWidgetContinuity(request: Uint8Array): Uint8Array {
12
+ if (request.length < 8 || request[0] !== 95 || request[1]! > 1 || request[2] !== 0 || request[3] !== 0)
13
+ throw new Error("invalid widget continuity header");
14
+ const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
15
+ const count = wire.getUint32(4, true), mode = request[1]!;
16
+ if (count > 1024 || request.length !== 8 + count * 24) throw new Error("invalid widget continuity table");
17
+ const output = new Uint8Array(8 + count);
18
+ output[0] = 95; output[1] = mode;
19
+ new DataView(output.buffer).setUint32(4, count, true);
20
+ for (let i = 0; i < count; i++) {
21
+ const at = 8 + i * 24, facts = request[at]!;
22
+ if (request[at + 1] !== 0 || request[at + 2] !== 0 || request[at + 3] !== 0 || wire.getUint32(at + 20, true) !== 0)
23
+ throw new Error("invalid widget continuity fact");
24
+ let action = 0;
25
+ if (mode === 1) {
26
+ if ((facts & (32 | 128)) === (32 | 128)) action = 2;
27
+ } else {
28
+ if ((facts & (32 | 64)) === (32 | 64)) action = 1;
29
+ if ((facts & (1 | 2 | 16)) === (1 | 2 | 16)) {
30
+ if ((facts & 4) !== 0 && wire.getFloat32(at + 4, true) === wire.getFloat32(at + 12, true)) action |= 4;
31
+ if ((facts & 8) !== 0 && wire.getFloat32(at + 8, true) === wire.getFloat32(at + 16, true)) action |= 8;
32
+ }
33
+ }
34
+ output[8 + i] = action;
35
+ }
36
+ return output;
37
+ }
@@ -0,0 +1,63 @@
1
+ /** One rebuild plan for controls and text. Native supplies exact storage
2
+ * lookups, byte/fingerprint equality and caret geometry; no retained pointer,
3
+ * text buffer, composition or code-cache identity crosses this wire.
4
+ * Header: tag 93, three zero bytes, count u32LE. Each 64-byte fact contains
5
+ * kind, admission flags, comparison flags, zero, four f32 values, selection
6
+ * flags and three zeros, four opaque u64 caret offsets, and eight zeros.
7
+ * Each output is action bits u32LE and a control value f32LE.
8
+ */
9
+ function nscvWidgetReconcile(request: Uint8Array): Uint8Array {
10
+ if (request.length < 8 || request[0] !== 93 || request[1] !== 0 || request[2] !== 0 || request[3] !== 0)
11
+ throw new Error("invalid widget reconcile header");
12
+ const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
13
+ const count = wire.getUint32(4, true);
14
+ if (count > 1024 || request.length !== 8 + count * 64) throw new Error("invalid widget reconcile table");
15
+ const output = new Uint8Array(8 + count * 8), out = new DataView(output.buffer);
16
+ output[0] = 93; out.setUint32(4, count, true);
17
+ for (let i = 0; i < count; i++) {
18
+ const at = 8 + i * 64, kind = request[at]!, admission = request[at + 1]!, facts = request[at + 2]!;
19
+ if (kind > 62 || facts > 127 || request[at + 3] !== 0 || request[at + 20]! > 127 ||
20
+ request[at + 21] !== 0 || request[at + 22] !== 0 || request[at + 23] !== 0 ||
21
+ wire.getUint32(at + 56, true) !== 0 || wire.getUint32(at + 60, true) !== 0)
22
+ throw new Error("invalid widget reconcile fact");
23
+ const editable = kind >= 35 && kind <= 39;
24
+ let actions = editable ? 1024 : 0, value = 0;
25
+ const eligible = (admission & 7) === 1;
26
+ if (eligible && (admission & 8) !== 0) {
27
+ const source = (facts & 1) !== 0, previous = (facts & 2) !== 0, retained = (facts & 4) !== 0;
28
+ const exclusive = kind === 14 || kind === 41 || kind === 42 || kind === 44 || kind === 46 || kind === 48;
29
+ if (kind === 32 || kind === 47 || kind === 49 || kind === 50 || exclusive) {
30
+ const selected = kind === 32 ? source || previous ? source : retained :
31
+ exclusive && (admission & 16) !== 0 && source !== previous ? source : retained;
32
+ actions |= 1 | (selected ? 2 : 0);
33
+ } else if (kind === 51) {
34
+ const current = wire.getFloat32(at + 4, true), prior = wire.getFloat32(at + 8, true);
35
+ const runtime = wire.getFloat32(at + 12, true);
36
+ const candidate = (admission & 16) === 0 || current === prior || (facts & 8) !== 0 ? runtime : current;
37
+ // Native clamp evaluates max(0, min(candidate, 1)); NaN selects the upper bound.
38
+ value = Number.isNaN(candidate) ? 1 : Math.max(0, Math.min(candidate, 1)); actions |= 4;
39
+ } else if (kind === 16) {
40
+ const minimum = wire.getFloat32(at + 16, true), retainedWidth = wire.getFloat32(at + 12, true);
41
+ value = Number.isNaN(retainedWidth) ? minimum : Math.max(minimum, retainedWidth); actions |= 8;
42
+ }
43
+ }
44
+ if (eligible && (admission & 32) !== 0) {
45
+ const selection = request[at + 20]!;
46
+ if (kind === 26) {
47
+ if ((selection & 1) === 0 && (facts & 48) === 48) actions |= 64;
48
+ } else if (editable) {
49
+ const packet = new Uint8Array(40);
50
+ packet[0] = 5; packet[1] = (facts & 64) !== 0 ? 1 : 0; packet[2] = (facts & 16) !== 0 ? 1 : 0;
51
+ packet[4] = selection & 7; packet[5] = (selection >>> 3) & 3; packet[6] = (selection >>> 5) & 3;
52
+ packet.set(request.subarray(at + 24, at + 56), 8);
53
+ const result = nscvTextReconcile(packet)[0]!;
54
+ if ((result & 2) !== 0) {
55
+ actions |= 32 | ((result & 1) !== 0 ? 16 : 0) | ((result & 4) !== 0 ? 64 : 0) | ((result & 8) !== 0 ? 128 : 0);
56
+ if ((admission & 64) !== 0) actions |= 256 | ((admission & 128) === 0 ? 512 : 0);
57
+ }
58
+ }
59
+ }
60
+ out.setUint32(8 + i * 8, actions, true); out.setFloat32(12 + i * 8, value, true);
61
+ }
62
+ return output;
63
+ }
@@ -0,0 +1,62 @@
1
+ /** Ordered rebuild collections and edge-triggered autofocus. Native supplies
2
+ * copied widget facts and owns retained storage, text fingerprints and buffers.
3
+ * Identities remain opaque eight-byte keys, including zero and max-u64. */
4
+ function nscvWidgetRetention(request: Uint8Array): Uint8Array {
5
+ if (request.length < 24 || request[0] !== 92 || request[1]! > 6 || request[2] !== 0 || request[3] !== 0)
6
+ throw new Error("invalid widget retention header");
7
+ const wire = new DataView(request.buffer, request.byteOffset, request.byteLength);
8
+ const operation = request[1]!, count = wire.getUint32(4, true), sources = wire.getUint32(8, true);
9
+ const capacity = wire.getUint32(12, true), states = wire.getUint32(16, true);
10
+ if (count > 1024 || sources > 1024 || capacity > 1024 || states > 1024 || wire.getUint32(20, true) !== 0 ||
11
+ request.length !== 24 + (count + sources) * 16 || (operation !== 5 && operation !== 6 && sources !== 0))
12
+ throw new Error("invalid widget retention table");
13
+ for (let i = 0; i < count + sources; i++) {
14
+ const at = 24 + i * 16;
15
+ if (request[at + 8]! > 62 || request[at + 9]! > 31 || request[at + 10] !== 0 || request[at + 11] !== 0)
16
+ throw new Error("invalid widget retention fact");
17
+ if (i >= count && (request[at + 9] !== 0 || wire.getUint32(at + 12, true) !== 0))
18
+ throw new Error("invalid widget retention source");
19
+ }
20
+ const entries: number[] = [], matches: number[] = [], flags: number[] = [];
21
+ let target = 4294967295;
22
+ // Capacity bounds the copied prefix, but autofocus must scan the whole tree:
23
+ // a newly requested target can occur beyond the tracked flag budget.
24
+ for (let i = 0; i < count; i++) {
25
+ const at = 24 + i * 16, kind = request[at + 8]!, fact = request[at + 9]!;
26
+ const nonzero = wire.getUint32(at, true) !== 0 || wire.getUint32(at + 4, true) !== 0;
27
+ const editable = kind >= 35 && kind <= 39;
28
+ const exclusive = kind === 41 || kind === 42 || kind === 44 || kind === 46 || kind === 48;
29
+ const control = exclusive || kind === 14 || kind === 16 || kind === 32 || kind >= 47 && kind <= 51;
30
+ const admit = nonzero && (operation === 0 ? kind === 6 || kind === 57 :
31
+ operation === 1 ? exclusive || kind === 14 || kind === 32 || kind === 51 :
32
+ operation === 2 ? control : operation === 3 ? kind === 6 && i < states :
33
+ operation === 4 ? editable : operation === 5 ? editable || kind === 26 && (fact & 6) === 6 :
34
+ (fact & 1) !== 0);
35
+ if (!admit) continue;
36
+ if (operation !== 6 && entries.length >= capacity) break;
37
+ let match = 4294967295;
38
+ if (operation === 5 || operation === 6) {
39
+ for (let j = 0; j < sources; j++) {
40
+ const source = 24 + (count + j) * 16;
41
+ if (wire.getUint32(at, true) === wire.getUint32(source, true) &&
42
+ wire.getUint32(at + 4, true) === wire.getUint32(source + 4, true) &&
43
+ (operation === 6 || kind === request[source + 8])) { match = j; break; }
44
+ }
45
+ }
46
+ if (operation === 6 && target === 4294967295 && match === 4294967295) target = i;
47
+ if (entries.length < capacity) {
48
+ entries.push(i); matches.push(match);
49
+ flags.push(((fact & 16) !== 0 || wire.getFloat32(at + 12, true) >= 0.5 ? 1 : 0) |
50
+ (kind === 16 ? 2 : 0) | ((fact & 8) !== 0 ? 4 : 0));
51
+ }
52
+ }
53
+ const output = new Uint8Array(16 + entries.length * 12), out = new DataView(output.buffer);
54
+ output[0] = 92; output[1] = operation;
55
+ out.setUint32(4, entries.length, true); out.setUint32(8, target, true);
56
+ for (let i = 0; i < entries.length; i++) {
57
+ out.setUint32(16 + i * 12, entries[i]!, true);
58
+ out.setUint32(20 + i * 12, matches[i]!, true);
59
+ out.setUint32(24 + i * 12, flags[i]!, true);
60
+ }
61
+ return output;
62
+ }
@@ -429,7 +429,7 @@ Color and radius come from the design tokens, referenced by token NAME — liter
429
429
  </row>
430
430
  ```
431
431
 
432
- References resolve against the app's LIVE tokens on every rebuild (`finalizeWithTokens`), so a themed app (`tokens`/`tokens_fn`) re-resolves them when the theme changes — dark mode flips `surface` automatically. The DEFAULT theme follows the system appearance: an app that sets neither `tokens` nor `tokens_fn` derives the stock tokens from the OS light/dark setting (plus high-contrast and reduce-motion) and re-themes live when the user flips it. A TypeScript core may export `themeState(model: Model): ThemeState` (from `@native-sdk/core/events`) to derive optional `pack`, `colorScheme` (`light`/`dark`/`system`), `accent` (`#rrggbb`), `highContrast`, and `reduceMotion` from model state. Omitted fields inherit app.zon, and omitted/system scheme follows the OS. Omitted accessibility flags follow the OS; explicit flags retain model appearance during replay. Effective high contrast suppresses accents. `themePack(model)` remains supported for pack-only apps, but never export both. Pass explicit `tokens` for a fixed look, or `tokens_fn` for a fully model-owned custom palette; those complete-token paths take precedence over themeState. Forced scheme is canvas-token scope in v1 — native title bars and WebViews continue following the OS. An explicit `style` value set in Zig always wins over a token ref on the same field. Unknown token names and malformed model accents are validation errors.
432
+ References resolve against the app's LIVE tokens on every rebuild (`finalizeWithTokens`), so a themed app (`tokens`/`tokens_fn`) re-resolves them when the theme changes — dark mode flips `surface` automatically. The DEFAULT theme follows the system appearance: an app that sets neither `tokens` nor `tokens_fn` derives the stock tokens from the OS light/dark setting (plus high-contrast and reduce-motion) and re-themes live when the user flips it. A TypeScript core may export `themeState(model: Model): ThemeState` (from `@native-sdk/core/events`) to derive optional `pack`, `colorScheme` (`light`/`dark`/`system`), `accent` (`#rrggbb`), `highContrast`, and `reduceMotion` from model state. Omitted fields inherit app.zon, and omitted/system scheme follows the OS. Omitted accessibility flags follow the OS; explicit flags retain model appearance during replay. Effective high contrast suppresses accents. `themePack(model)` remains supported for pack-only apps, but never export both. Pass explicit `tokens` for a fixed look, or `tokens_fn` for a fully model-owned custom palette; those complete-token paths take precedence over themeState. On macOS, the requested scheme also applies to native window chrome and child controls, including secondary windows. `system` clears the window override and resumes OS appearance. WebView content remains responsible for its own styling. An explicit `style` value set in Zig always wins over a token ref on the same field. Unknown token names and malformed model accents are validation errors.
433
433
 
434
434
  One Zig-only style knob rides beside the tokens: `ElementOptions.style = .{ .quiet_hover = true }` silences a pressable surface's pointer HOVER wash only — press and selection fills, the focus ring, cursor intent, and hit testing stay — for image-forward content tiles (cover art, photo cards) where the pointer rests on content rather than a control register. Acting controls (list rows, menu items, buttons, tab triggers) keep their washes: there the hover fill IS the affordance.
435
435
 
@@ -1282,7 +1282,7 @@ Tests that touch files or clocks get their `Io` from `std.testing.io`. The full
1282
1282
 
1283
1283
  `native markup check src/view.native` — instant grammar/structure validation with `file:line:column` errors, including the font-coverage tofu guard: literal text with a codepoint outside the bundled face (⌘, ✓, ⑂, dingbats, CJK) is a teaching error naming the character, because it renders as a tofu box on the reference/screenshot and mobile paths — register a font that covers it (`UiApp.Options.fonts`) and bind the text from the model (the guard skips `{bindings}`), or use a vector icon (`icon=` / `<icon name>`) or plain words. Dynamic strings get the same lesson as a Debug-build `zero_canvas_ui` diagnostic when the view builds. The accessibility lint rides the same pass: unnamed interactive controls and role misuse are errors, unnamed images and redundant labels are warnings (`--strict` promotes).
1284
1284
 
1285
- The model side checks at check time too: the model-contract step (refreshed by `native test`, or run directly as `zig build model-contract` in an app that owns its build) reflects Model/Msg into `zig-out/model-contract.zon`, and `native check` (or `markup check` run in the app directory) then verifies every binding path, iterable, `key` field, message tag, payload type, and expression type against the app's real surface — did-you-mean over your actual field names, and type errors naming the core's type. It also WARNS on model state and Msg tags no view uses; a TypeScript core exports `viewUnbound = ["name"] as const`, while a Zig core declares `pub const view_unbound = .{ "name" };` (`--strict` turns the warnings into failures). State consumed only by a Zig-built view needs `view_unbound` too, because the markup checker cannot see Zig view reads. A stale artifact degrades to grammar-only checking with a loud note ("model contract: not yet built - bindings checked structurally only; run `native test` to enable typed checks"); binding paths and message tags are always re-enforced when the app builds (and on hot reload).
1285
+ The model side checks at check time too. For a TypeScript core (`src/core.ts`), `native check` compiles `src/app.native` and `src/windows/*.native` against the core's contract with the build's own view compiler, so every binding path, iterable, `key` field, message tag, payload type, and expression type is checked against the current core with no artifact to refresh. For a Zig core, the model-contract step (refreshed by `native test`, or run directly as `zig build model-contract` in an app that owns its build) reflects Model/Msg into `zig-out/model-contract.zon`, and `native check` (or `markup check` run in the app directory) verifies the same things against it, with did-you-mean over your actual field names and type errors naming the core's type. Both WARN on model state and Msg tags no view uses; a TypeScript core exports `viewUnbound = ["name"] as const`, while a Zig core declares `pub const view_unbound = .{ "name" };` (`--strict` turns the warnings into failures). State consumed only by a Zig-built view needs `view_unbound` too, because the markup checker cannot see Zig view reads. A stale Zig artifact degrades to grammar-only checking with a loud note ("model contract: not yet built - bindings checked structurally only; run `native test` to enable typed checks"); binding paths and message tags are always re-enforced when the app builds (and on hot reload).
1286
1286
 
1287
1287
  ## Testing pattern (Zig cores)
1288
1288
 
@@ -102,7 +102,7 @@ Logic:
102
102
  - **Exceptions — `throw`/`try`/`catch`/`finally` as pure control flow.** Inside a core, exceptions are deterministic: `throw` carries a subset VALUE and unwinds to the nearest enclosing `catch` — across helper calls, out of array-method callbacks (a `throw` inside `.map`'s callback exits the whole loop, like JS), through nested `try`s, with `finally` running on every path (fall-through, `return`, `break`/`continue`, and throw alike). The discipline is two rules. First (NS1057): thrown values are kind-tagged subset shapes — throw kind-discriminated records (`throw { kind: "bad_digit", at: i } as ParseError`, where `ParseError` is an interface with a string-literal `kind` field or a `kind`-discriminated union; a single-shape core may also throw a number), and SEVERAL distinct shapes may throw: the checker collects every shape the core throws into its implicit thrown union. The catch binding IS that union — narrow it in place with kind tests, no `as` ceremony: `catch (e) { if (e.kind === "bad_digit") return -e.at; if (e.kind === "io") return e.code; return -1; }` (or `switch (e.kind)` — tsc cannot prove exhaustiveness over the implicit union, so give the switch a `default` or a trailing return). Bare rethrow (`throw e;`) re-raises the bound value — a narrowed arm included — and `catch { ... }` needs no binding; the single-`as` form (`const err = e as ParseError;`) stays legal in single-shape cores (and for a DECLARED union whose arms equal the thrown set — declare `type AppError = ... | ...` and `as AppError` works). What teaches: untagged values in a heterogeneous set, two shapes sharing one `kind` with different payloads, asserting one member shape of a multi-shape core, the binding escaping untyped into a call/store/return, and `throw new Error(...)` (engine error objects carry stack traces with no native layout). Second (NS1058): `finally` never redirects control flow — no `return`/`throw`/`break`-out inside it (JS's own no-unsafe-finally rule; loops fully inside the finally may break within themselves). An UNCAUGHT throw that reaches an exported function's boundary is a defined deterministic panic — exactly where node's process would crash. A throw mid-mutation of an owned array keeps the mutations applied so far, exactly like JS — the catch sees the array as node would.
103
103
  - **Local function values — const helpers hoist.** `const scale = (x: number): number => x * 3;` (arrow or `function` expression) hoists to an ordinary module-level fn when it is capture-free (module constants and other const helpers are fine to reference; enclosing locals/params are not — pass them as parameters), fully annotated (every parameter and the return type), and used only by direct calls (`scale(v)`, recursion included) or as an array-method callback (`xs.map(scale)`, comparators included). Everything else teaches NS1054: captures, missing annotations, `let` bindings, returning/storing the value, passing it to your own functions, calling through a record field. Capturing a locally-owned array also ENDS its ownership at the capture (a later mutation is the NS1051 teach) — the stored closure would retain the reference.
104
104
 
105
- Not yet in v1 — genuine roadmap deferrals, each stopping with a loud, tailored NS9001 naming the rewrite (never missing basic syntax; the banned-with-a-rule families live in "What the subset means" above). The rule-level deferrals carry `class: "deferred"` in the diagnostics catalogue — NS1011 (Map/Set), NS1019 (fixed arity), NS1040 (regexes), NS1042 (generators), NS1044 (BigInt/Symbol) — and their diagnostics say the capability is deliberately deferred, not impossible; the list below is the method-level remainder: `.toSorted()`/`.sort()` without a comparator (JS ToString ordering; pass `(a, b) => a - b`), `.reduce` without an initial value (a taught NS1007 — JS throws on an empty array) or with an index parameter (use a classic loop), `.indexOf`/`.includes` on record arrays (match a field with `.find`/`.findIndex`), `.join` on number arrays (elements are float-valued; join byte values instead), float values (`/`, `**`, `Math.round`, `Math.sqrt`, float `Math.floor`-family results) where an integer is required such as an index (a taught NS1016 — those values can be fractional or NaN), Math methods beyond the batch above, `Number` methods beyond the three classifiers, float-valued template holes (JS float-to-string fidelity is a runtime v2 surface), arrays of unions (`readonly View[]`) or arrays of byte-strings (`readonly Uint8Array[]`) as model fields (wrap the element in a single-field interface), a collect spawn's stderr tail (v1 delivers the exit code and stdout; stderr is not surfaced — put diagnostics on stdout or check the code), per-line truncation flags (a stdout or response line over its configured bound arrives cut, without a flag), and non-timer subscriptions (`Sub.timer` is the one subscription; one-shot needs are `Cmd.delay`, and process/fetch/audio streams are Cmd-initiated, not subscribed).
105
+ Not yet in v1 — genuine roadmap deferrals, each stopping with a loud, tailored NS9001 naming the rewrite (never missing basic syntax; the banned-with-a-rule families live in "What the subset means" above). The rule-level deferrals carry `class: "deferred"` in the diagnostics catalogue — NS1011 (Map/Set), NS1019 (fixed arity), NS1040 (regexes), NS1042 (generators), NS1044 (BigInt/Symbol) — and their diagnostics say the capability is deliberately deferred, not impossible; the list below is the method-level remainder: `.toSorted()`/`.sort()` without a comparator (JS ToString ordering; pass `(a, b) => a - b`), `.reduce` without an initial value (a taught NS1007 — JS throws on an empty array) or with an index parameter (use a classic loop), `.indexOf`/`.includes` on record arrays (match a field with `.find`/`.findIndex`), `.join` on number arrays (elements are float-valued; join byte values instead), float values (`/`, `**`, `Math.round`, `Math.sqrt`, float `Math.floor`-family results) where an integer is required such as an index (a taught NS1016 — those values can be fractional or NaN), Math methods beyond the batch above, `Number` methods beyond the three classifiers, float-valued template holes (JS float-to-string fidelity is a runtime v2 surface), arrays of unions (`readonly View[]`) or arrays of byte-strings (`readonly Uint8Array[]`) as model fields (wrap the element in a single-field interface), a collect spawn's stderr tail (v1 delivers the exit code and stdout; stderr is not surfaced — put diagnostics on stdout or check the code), per-line truncation flags (a stdout or response line over its configured bound arrives cut, without a flag), and subscriptions beyond `Sub.timer`, `Sub.globalShortcut`, and generated live queries (one-shot needs are `Cmd.delay`, and process/fetch/audio streams are Cmd-initiated, not subscribed).
106
106
 
107
107
  ## Effects are Cmd data
108
108
 
@@ -153,6 +153,7 @@ These map directly onto the host's effect engine — files, HTTP, the clipboard,
153
153
  - `Cmd.openExternalUrl(url)` — open an HTTP(S) URL in the system browser, fire-and-forget. `url` is bytes; the runtime validates it and enforces `security.navigation.external_links` before entering the platform service. Invalid, denied, or unavailable requests fail closed; fake execution and replay never open one.
154
154
  - `Cmd.revealPath(path)` — reveal a byte path in Finder, Files, or Explorer, fire-and-forget. Runtime path validation stays in force; invalid or unavailable requests fail closed, and fake execution/replay never reveal one.
155
155
  - `Cmd.credentials.set(key, secret, { key?, ok, err })` / `Cmd.credentials.get(key, route)` / `Cmd.credentials.delete(key, route)` — app-scoped Keychain on macOS/iOS, Secret Service/libsecret on Linux, Credential Manager on Windows, and AndroidKeyStore-wrapped authenticated ciphertext on Android. The authored credential key is a NUL-free string (UTF-8, ≤256 bytes); the manifest app id (≤128 bytes) supplies the service namespace, and secrets are `Uint8Array` values through 2,560 bytes (the cross-platform floor set by WinCred). Set/delete deliver empty bytes on `ok`; get delivers secret bytes; the closed err reasons are `miss`, `denied`, `locked`, `io_failed`, `over_bound`, and `rejected`. Declare BOTH `"credentials"` in `app.zon` capabilities and permissions; NS1071 warns when the capability is absent, NS1072 errors when permission is absent, and NS1073 reserves `core.credentials.*` for the typed factories. Never retain a returned secret in Model: consume its Msg immediately to construct the next effect. Recording stores only a successful get's length, per-session salt, and a placeholder digest independent of the secret (never the secret or a blob); replay delivers deterministic same-length placeholder bytes, and devhost keeps an in-memory map while printing only `<redacted, N bytes>`.
156
+ - `Cmd.keyboard.sendChord({ key, primary?, command?, control?, option?, shift? }, { key?, ok, err })` / `Cmd.keyboard.accessStatus({ prompt? }, route)` — send a key chord into whichever app has keyboard focus (other apps, through the OS; this is not in-app automation). The chord has the `Sub.globalShortcut` binding shape (`key` is `asciiBytes` from the shortcut key vocabulary) but needs no modifier. Both arms carry one `Uint8Array`: chord `ok` is empty, access `ok` is `granted`, `denied`, or `not_required`. Err reasons are `rejected` (missing `"keyboard_input"` permission — NS1075 catches it at check time, including raw `native-sdk.keyboard.*` requests), `unsupported` (Linux, mobile), `invalid_request`, `denied` (macOS Accessibility not granted; nothing posted), `blocked` (Windows refused the input), and `failed`. `ok` means posted, not delivered: Windows drops input to elevated windows without an error. Do not send a chord equal to one of the app's own global shortcuts. Replay, fake execution, and devhost never post input.
156
157
  - `Cmd.formatLocalTime(timestampMs, "date" | "time" | "datetime", { key?, ok, err })` — format epoch milliseconds (the same unit `Cmd.now` produces) through the host's current locale and local time zone; `ok` carries localized UTF-8 bytes. This is deliberately an effect rather than a pure helper: locale/timezone are ambient state, so the observed bytes journal and replay without consulting the replay machine. Err reasons are `invalid_request`, `unsupported`, and `failed`.
157
158
  - `Cmd.delay(key, ms, "fired")` — a keyed ONE-SHOT timer: dispatches the named arm once, `ms` from now, with the fire time (ms) as its single number payload (the same arm shape `Cmd.now` and `Sub.timer` target). Re-issuing a live delay key re-arms it from now — that is the debounce discipline (`Cmd.delay("autosave", 800, "save_now")` on every keystroke, one fire after the pause). `Cmd.cancel(key)` drops it silently. The interval is 1ms to one year; a literal outside that stops the build (NS1030).
158
159
 
@@ -310,6 +311,7 @@ export function subscriptions(model: Model): Sub<Msg> {
310
311
 
311
312
  - `Sub.none` — no subscriptions (everything paused).
312
313
  - `Sub.timer(key, everyMs, "tick")` — a repeating timer named by its string-literal key; each fire dispatches the named arm with the current time (ms) as its single number payload (the same arm shape `Cmd.now` targets). The interval may derive from the model.
314
+ - `Sub.globalShortcut("talk", { key: asciiBytes("space"), option: true }, "talk")` — a system-wide shortcut that fires while other apps have focus, registered while declared and re-registered when the binding changes. The arm is exactly `{ id: Uint8Array; state: GlobalShortcutState }` (import the state from `@native-sdk/core/events`); states are `registered`, `pressed`, `released`, `conflict`, `unsupported`, and `rejected`. Up to 16 per app with unique 1-64 byte ids, and every key except `f1`-`f12` needs a modifier other than Shift; a bad or duplicate id, a 17th shortcut, or a bad binding reports `rejected`, and a combination another shortcut owns reports `conflict`. macOS and Windows only; Linux reports `unsupported`.
313
315
  - `Sub.batch([...])` — several at once.
314
316
 
315
317
  Sub values follow the Cmd purity rule with their own home (NS1025): built inline in `subscriptions`' return path, never stored, never returned from anywhere else. Debounced re-arm falls out of reconciliation — change the key or interval and the timer re-arms; drop it from the set and it stops.
@@ -455,7 +457,7 @@ The generated wiring detects each channel from an export (export exists → wire
455
457
  - **`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.
456
458
  - **`tokenOverrides(model: Model): ThemeDesignTokenOverrides`** — model-derived colors, typography, spacing, geometry, controls, and motion over the selected stock theme. Import the complete optional record from `@native-sdk/core/theme`; omitted members inherit the resolved stock register. Colors use normalized RGBA. Numbers cross the helper ABI as f64; native registration validates font ids and ranges and explicitly converts GPU values to f32. The runtime stamps device scale and installs its layout policies after applying the overrides. Full native `tokens`/`tokens_fn` configurations retain precedence.
457
459
  - **`assets.fonts` in the manifest** — declare bundled TrueType faces as `{ "id": 64, "path": "assets/mono.ttf" }`. Ids start at 64 and remain permanent; at most eight faces register before the first layout. Reference their ids through `tokenOverrides` typography. Missing, oversized, or invalid files fail startup. The same asset tree is included in packaging.
458
- - **`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`, `highContrast`, `reduceMotion`). Omit a field to inherit app.zon, use `colorScheme: "system"` (or omit it) to follow the OS, and spell accents exactly `#rrggbb`. Omitted `highContrast`/`reduceMotion` follow the OS; explicit values retain model-owned appearance during replay. Effective 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.
460
+ - **`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`, `highContrast`, `reduceMotion`). Omit a field to inherit app.zon, use `colorScheme: "system"` (or omit it) to follow the OS, and spell accents exactly `#rrggbb`. Omitted `highContrast`/`reduceMotion` follow the OS; explicit values retain model-owned appearance during replay. Effective 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. On macOS, the requested scheme also applies to native window chrome and child controls, including secondary windows. `system` clears the window override and resumes OS appearance. WebView content remains responsible for its own styling.
459
461
  - **`webPanes(model: Model): readonly WebViewPane[]`** — model-declared geometry, URL, and reload state for existing scene WebViews; see Model-declared WebView panes.
460
462
  - **`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`.
461
463
  - **`frameMsg(model: Model, frame: FrameEvent): Msg | null`** — presented frames. `FrameEvent` carries `{ width, height, timestampMs, intervalMs }` numbers (canvas points; fractional milliseconds) plus `timestampNs` and `intervalNs` as exact decimal ASCII bytes. Use the byte clocks for nanosecond-sensitive animation; converting the fractional-millisecond number back loses large-u64 precision. Existing structural four-number events remain supported. Return null for frames that change nothing — the idle law holds exactly when an idle app dispatches nothing. The installing frame is excluded.
@@ -682,7 +684,7 @@ Builds compile the whole app — the core archive, service executables or in-pro
682
684
 
683
685
  Scaffolded apps carry an editor surface (`package.json`, `tsconfig.json`, and a CLI-managed `node_modules/@native-sdk/core` copy, npm-managed after the package is published): it exists so stock tsc/editors resolve `@native-sdk/core`, it is NEVER build truth (every `native` verb works with node_modules deleted; check/dev/build re-materialize it), and it is not a language marker — tree detection still keys on `src/core.ts` alone. Do not hand-edit or vendor files under `node_modules/`.
684
686
 
685
- **Refresh the model contract after shape changes.** `native check`'s typed markup pass reads `zig-out/model-contract.zon`, an artifact of the LAST build/test — after changing Model fields or Msg kinds, run `native test` (or `zig build model-contract` in an app that owns its build.zig) before trusting `native check`. A stale contract reports phantom hard errors (`unknown message tag`, `binding does not name a model field`) that name your NEW state — the state is fine; the artifact is old. And never delete `src/app.native` in response to a note about nothing embedding it: on the TypeScript track the generated wiring embeds the view from outside the app tree, so that file is always wired.
687
+ **`native check` types your markup against the current core.** It compiles `src/app.native` and `src/windows/*.native` against the contract it just derived from `src/core.ts`, with the same view compiler the build uses — there is no artifact to refresh after changing Model fields or Msg kinds. A binding error reads `src/app.native:L:C: error: compiled TypeScript view: …`; unused Model fields, helpers and Msg kinds are warnings (opt out with `export const viewUnbound`; `--strict` fails on them). Never delete `src/app.native` in response to a note about nothing embedding it: on the TypeScript track the generated wiring embeds the view from outside the app tree, so that file is always wired.
686
688
 
687
689
  The frontend is the checker: run it after every meaningful edit and read the diagnostics — they always name the rule, the idiomatic rewrite, and the reason. Inside an app, `native check` runs it for you (plus markup and app.zon validation); in a core-only workspace, invoke it directly:
688
690
 
@@ -6,11 +6,11 @@
6
6
  Verify without writing:
7
7
  node packages/core/scripts/gen_service_surface.mjs --check -->
8
8
 
9
- # Service compile surface — scriptc 0.3.0
9
+ # Service compile surface — scriptc 0.3.2
10
10
 
11
11
  What TypeScript under `src/services/` can use, as stated by the pinned
12
- compiler itself (surface manifest schema 2, 650 entries:
13
- 522 static, 128 unsupported).
12
+ compiler itself (surface manifest schema 2, 674 entries:
13
+ 548 static, 126 unsupported).
14
14
 
15
15
  How to read the tables:
16
16
 
@@ -182,7 +182,6 @@ manifest row in the Notes column:
182
182
  | `node-builtin.cluster.isMaster` | cluster.isMaster | static | | constant value read |
183
183
  | `node-builtin.cluster.isPrimary` | cluster.isPrimary | static | | constant value read |
184
184
  | `node-builtin.cluster.isWorker` | cluster.isWorker | static | | constant value read |
185
- | `node-builtin.console.Console` | console.Console | unsupported | `SC2020` | custom Console instances are not supported yet; direct node:console log/info/debug/error/warn calls use the process output streams |
186
185
  | `node-builtin.crypto.createCipheriv` | crypto.createCipheriv | unsupported | `SC2020` | symmetric ciphers need a cipher stack the static runtime does not vendor — the lowered crypto surface is hashing, randomness, and the introspection statics |
187
186
  | `node-builtin.crypto.createDecipheriv` | crypto.createDecipheriv | unsupported | `SC2020` | symmetric ciphers need a cipher stack the static runtime does not vendor — the lowered crypto surface is hashing, randomness, and the introspection statics |
188
187
  | `node-builtin.crypto.createDiffieHellman` | crypto.createDiffieHellman | unsupported | `SC2020` | asymmetric-key operations need a public-key stack (bignum, RSA/EC/EdDSA math) and a KeyObject value model — neither exists in the static runtime, so no faithful lowering can be small; the lowered crypto surface is hashing, randomness, and the introspection statics |
@@ -293,29 +292,47 @@ manifest row in the Notes column:
293
292
  | `node-builtin.net.getDefaultAutoSelectFamilyAttemptTimeout` | net.getDefaultAutoSelectFamilyAttemptTimeout | static | | |
294
293
  | `node-builtin.net.setDefaultAutoSelectFamilyAttemptTimeout` | net.setDefaultAutoSelectFamilyAttemptTimeout | static | | |
295
294
  | `node-builtin.os.EOL` | os.EOL | static | | constant value read |
295
+ | `node-builtin.os.arch` | os.arch | static | | |
296
296
  | `node-builtin.os.availableParallelism` | os.availableParallelism | static | | |
297
+ | `node-builtin.os.constants` | os.constants | static | | the platform's dlopen, errno, signals and priority groups; members a platform lacks read as undefined |
298
+ | `node-builtin.os.cpus` | os.cpus | static | | |
299
+ | `node-builtin.os.devNull` | os.devNull | static | | constant value read |
300
+ | `node-builtin.os.endianness` | os.endianness | static | | |
301
+ | `node-builtin.os.freemem` | os.freemem | static | | |
302
+ | `node-builtin.os.getPriority` | os.getPriority | static | | |
297
303
  | `node-builtin.os.homedir` | os.homedir | static | | |
304
+ | `node-builtin.os.hostname` | os.hostname | static | | |
305
+ | `node-builtin.os.loadavg` | os.loadavg | static | | |
306
+ | `node-builtin.os.machine` | os.machine | static | | |
298
307
  | `node-builtin.os.networkInterfaces` | os.networkInterfaces | static | | |
299
308
  | `node-builtin.os.platform` | os.platform | static | | |
300
309
  | `node-builtin.os.release` | os.release | static | | |
301
310
  | `node-builtin.os.tmpdir` | os.tmpdir | static | | |
302
311
  | `node-builtin.os.totalmem` | os.totalmem | static | | |
303
312
  | `node-builtin.os.type` | os.type | static | | |
313
+ | `node-builtin.os.uptime` | os.uptime | static | | |
304
314
  | `node-builtin.os.userInfo` | os.userInfo | static | | |
315
+ | `node-builtin.os.version` | os.version | static | | |
305
316
  | `node-builtin.path.basename` | path.basename | static | | |
306
317
  | `node-builtin.path.delimiter` | path.delimiter | static | | constant value read |
307
318
  | `node-builtin.path.dirname` | path.dirname | static | | |
308
319
  | `node-builtin.path.extname` | path.extname | static | | |
320
+ | `node-builtin.path.format` | path.format | static | | |
309
321
  | `node-builtin.path.isAbsolute` | path.isAbsolute | static | | |
310
322
  | `node-builtin.path.join` | path.join | static | | |
323
+ | `node-builtin.path.matchesGlob` | path.matchesGlob | static | | |
311
324
  | `node-builtin.path.normalize` | path.normalize | static | | |
325
+ | `node-builtin.path.parse` | path.parse | static | | |
312
326
  | `node-builtin.path.posix.basename` | path/posix.basename | static | | |
313
327
  | `node-builtin.path.posix.delimiter` | path/posix.delimiter | static | | constant value read |
314
328
  | `node-builtin.path.posix.dirname` | path/posix.dirname | static | | |
315
329
  | `node-builtin.path.posix.extname` | path/posix.extname | static | | |
330
+ | `node-builtin.path.posix.format` | path/posix.format | static | | |
316
331
  | `node-builtin.path.posix.isAbsolute` | path/posix.isAbsolute | static | | |
317
332
  | `node-builtin.path.posix.join` | path/posix.join | static | | |
333
+ | `node-builtin.path.posix.matchesGlob` | path/posix.matchesGlob | static | | |
318
334
  | `node-builtin.path.posix.normalize` | path/posix.normalize | static | | |
335
+ | `node-builtin.path.posix.parse` | path/posix.parse | static | | |
319
336
  | `node-builtin.path.posix.relative` | path/posix.relative | static | | |
320
337
  | `node-builtin.path.posix.resolve` | path/posix.resolve | static | | |
321
338
  | `node-builtin.path.posix.sep` | path/posix.sep | static | | constant value read |
@@ -328,9 +345,12 @@ manifest row in the Notes column:
328
345
  | `node-builtin.path.win32.delimiter` | path/win32.delimiter | static | | constant value read |
329
346
  | `node-builtin.path.win32.dirname` | path/win32.dirname | static | | |
330
347
  | `node-builtin.path.win32.extname` | path/win32.extname | static | | |
348
+ | `node-builtin.path.win32.format` | path/win32.format | static | | |
331
349
  | `node-builtin.path.win32.isAbsolute` | path/win32.isAbsolute | static | | |
332
350
  | `node-builtin.path.win32.join` | path/win32.join | static | | |
351
+ | `node-builtin.path.win32.matchesGlob` | path/win32.matchesGlob | static | | |
333
352
  | `node-builtin.path.win32.normalize` | path/win32.normalize | static | | |
353
+ | `node-builtin.path.win32.parse` | path/win32.parse | static | | |
334
354
  | `node-builtin.path.win32.relative` | path/win32.relative | static | | |
335
355
  | `node-builtin.path.win32.resolve` | path/win32.resolve | static | | |
336
356
  | `node-builtin.path.win32.sep` | path/win32.sep | static | | constant value read |
@@ -368,7 +388,6 @@ manifest row in the Notes column:
368
388
  | `node-builtin.querystring.stringify` | querystring.stringify | static | | |
369
389
  | `node-builtin.querystring.unescape` | querystring.unescape | static | | |
370
390
  | `node-builtin.readline.createInterface` | readline.createInterface | static | | |
371
- | `node-builtin.stream.consumers.arrayBuffer` | stream/consumers.arrayBuffer | unsupported | `SC2020` | collecting a stream directly into an ArrayBuffer has no native lowering yet; buffer(stream) collects the same bytes as a Buffer |
372
391
  | `node-builtin.stream.consumers.blob` | stream/consumers.blob | unsupported | `SC2020` | Blob values have no representation in a compiled binary — buffer(stream) collects the same bytes as a Buffer, text(stream) the decoded text |
373
392
  | `node-builtin.timers.promises.setImmediate` | timers/promises.setImmediate | static | | |
374
393
  | `node-builtin.timers.promises.setTimeout` | timers/promises.setTimeout | static | | |
@@ -381,9 +400,14 @@ manifest row in the Notes column:
381
400
  | `node-builtin.url.fileURLToPath` | url.fileURLToPath | static | | |
382
401
  | `node-builtin.url.fileURLToPathBuffer` | url.fileURLToPathBuffer | static | | |
383
402
  | `node-builtin.url.pathToFileURL` | url.pathToFileURL | static | | |
403
+ | `node-builtin.util.callbackify` | util.callbackify | static | | |
404
+ | `node-builtin.util.debug` | util.debug | static | | |
405
+ | `node-builtin.util.debuglog` | util.debuglog | static | | |
406
+ | `node-builtin.util.deprecate` | util.deprecate | static | | |
384
407
  | `node-builtin.util.getSystemErrorMap` | util.getSystemErrorMap | static | | |
385
408
  | `node-builtin.util.getSystemErrorMessage` | util.getSystemErrorMessage | static | | |
386
409
  | `node-builtin.util.getSystemErrorName` | util.getSystemErrorName | static | | |
410
+ | `node-builtin.util.inherits` | util.inherits | static | | |
387
411
  | `node-builtin.util.isDeepStrictEqual` | util.isDeepStrictEqual | static | | |
388
412
  | `node-builtin.util.parseArgs` | util.parseArgs | static | | |
389
413
  | `node-builtin.util.parseEnv` | util.parseEnv | static | | |
@@ -92,6 +92,10 @@ pub const RunOptions = struct {
92
92
  .version = manifestStringField("version"),
93
93
  .description = manifestStringField("description"),
94
94
  .has_web_content = manifestHasWebContent(),
95
+ .webview_inspection = if (@hasDecl(build_options, "webview_inspection"))
96
+ build_options.webview_inspection orelse (@import("builtin").mode == .Debug)
97
+ else
98
+ @import("builtin").mode == .Debug,
95
99
  .declares_tray = manifestDeclaresTrayCapability(),
96
100
  .dock_visible = manifestDockVisible(),
97
101
  .window_title = self.window_title,
@@ -1408,3 +1412,13 @@ fn prepareStateStore(io: std.Io, env_map: *std.process.Environ.Map, app_info: *n
1408
1412
  }
1409
1413
  return store;
1410
1414
  }
1415
+
1416
+ test "runner inspection capability follows the app build mode and explicit override" {
1417
+ var buffers: StateBuffers = .{};
1418
+ const info = (RunOptions{ .app_name = "inspection-test", .bundle_id = "dev.native_sdk.inspection_test" }).appInfo(&buffers);
1419
+ if (comptime @hasDecl(build_options, "webview_inspection_expected")) {
1420
+ try std.testing.expectEqual(build_options.webview_inspection_expected, info.webview_inspection);
1421
+ }
1422
+ // Direct embedding stays default-deny, including inside Debug builds.
1423
+ try std.testing.expect(!(native_sdk.AppInfo{}).webview_inspection);
1424
+ }