@native-sdk/cli 0.5.3 → 0.6.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 (172) hide show
  1. package/build/app.zig +91 -2
  2. package/build.zig +756 -5
  3. package/build.zig.zon +7 -0
  4. package/native-sdk.d.ts +19 -1
  5. package/package.json +9 -9
  6. package/packages/core/package-lock.json +2 -2
  7. package/packages/core/package.json +1 -1
  8. package/packages/core/rt/rt.zig +416 -9
  9. package/packages/core/sdk/core.ts +706 -5
  10. package/packages/core/sdk/events.ts +17 -8
  11. package/packages/core/src/checker.ts +305 -2
  12. package/packages/core/src/diagnostics.ts +12 -0
  13. package/packages/core/src/emitter.ts +3187 -264
  14. package/packages/core/src/typed_ast.ts +51 -4
  15. package/packages/core/src/types.ts +34 -1
  16. package/skill-data/native-ui/SKILL.md +42 -4
  17. package/skill-data/ts-core/SKILL.md +13 -3
  18. package/src/app_runner/root.zig +112 -10
  19. package/src/app_runner/ts_core_main.zig +4 -0
  20. package/src/automation/layout_fingerprint.zig +160 -0
  21. package/src/automation/protocol.zig +82 -33
  22. package/src/automation/root.zig +1 -0
  23. package/src/automation/server.zig +1 -1
  24. package/src/automation/snapshot.zig +68 -9
  25. package/src/automation/watcher.zig +1 -1
  26. package/src/embed/host.zig +5 -0
  27. package/src/embed/tests.zig +119 -1
  28. package/src/embed/ui_host.zig +13 -0
  29. package/src/platform/linux/gtk_host.c +639 -16
  30. package/src/platform/linux/gtk_host.h +25 -0
  31. package/src/platform/linux/root.zig +351 -7
  32. package/src/platform/macos/appkit_host.h +152 -8
  33. package/src/platform/macos/appkit_host.m +1816 -100
  34. package/src/platform/macos/cef_host.mm +372 -11
  35. package/src/platform/macos/root.zig +379 -11
  36. package/src/platform/null_platform.zig +696 -9
  37. package/src/platform/null_platform_tests.zig +35 -0
  38. package/src/platform/root.zig +42 -0
  39. package/src/platform/types.zig +524 -18
  40. package/src/platform/windows/root.zig +432 -9
  41. package/src/platform/windows/webview2_host.cpp +482 -45
  42. package/src/primitives/app_manifest/comptime_scene.zig +5 -0
  43. package/src/primitives/app_manifest/root.zig +1 -0
  44. package/src/primitives/app_manifest/types.zig +32 -0
  45. package/src/primitives/app_manifest/validation.zig +18 -0
  46. package/src/primitives/canvas/a11y_audit.zig +33 -11
  47. package/src/primitives/canvas/a11y_audit_tests.zig +20 -0
  48. package/src/primitives/canvas/drawing.zig +25 -0
  49. package/src/primitives/canvas/equality.zig +8 -0
  50. package/src/primitives/canvas/events.zig +103 -16
  51. package/src/primitives/canvas/frame.zig +125 -1
  52. package/src/primitives/canvas/layout_audit.zig +22 -5
  53. package/src/primitives/canvas/markdown_hostile_tests.zig +8 -4
  54. package/src/primitives/canvas/render_tests.zig +13 -10
  55. package/src/primitives/canvas/root.zig +48 -0
  56. package/src/primitives/canvas/terminal_box.zig +471 -0
  57. package/src/primitives/canvas/terminal_grid.zig +978 -0
  58. package/src/primitives/canvas/terminal_grid_tests.zig +1093 -0
  59. package/src/primitives/canvas/test_support.zig +1 -0
  60. package/src/primitives/canvas/tests.zig +2 -0
  61. package/src/primitives/canvas/text_tests.zig +39 -4
  62. package/src/primitives/canvas/tokens.zig +115 -12
  63. package/src/primitives/canvas/ui.zig +535 -12
  64. package/src/primitives/canvas/ui_markup.zig +253 -36
  65. package/src/primitives/canvas/ui_markup_binary.zig +4 -1
  66. package/src/primitives/canvas/ui_markup_compiled.zig +195 -9
  67. package/src/primitives/canvas/ui_markup_compiled_tests.zig +188 -8
  68. package/src/primitives/canvas/ui_markup_contract.zig +89 -6
  69. package/src/primitives/canvas/ui_markup_contract_tests.zig +65 -1
  70. package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
  71. package/src/primitives/canvas/ui_markup_huge_model_tests.zig +1 -0
  72. package/src/primitives/canvas/ui_markup_reflect.zig +75 -24
  73. package/src/primitives/canvas/ui_markup_tests.zig +178 -9
  74. package/src/primitives/canvas/ui_markup_view.zig +220 -11
  75. package/src/primitives/canvas/ui_markup_view_tests.zig +553 -28
  76. package/src/primitives/canvas/ui_schema.zig +110 -17
  77. package/src/primitives/canvas/ui_schema_tests.zig +18 -10
  78. package/src/primitives/canvas/ui_tests.zig +141 -9
  79. package/src/primitives/canvas/widget_access.zig +28 -2
  80. package/src/primitives/canvas/widget_anchored_tests.zig +48 -0
  81. package/src/primitives/canvas/widget_invalidation.zig +81 -1
  82. package/src/primitives/canvas/widget_layout.zig +59 -11
  83. package/src/primitives/canvas/widget_layout_tests.zig +125 -4
  84. package/src/primitives/canvas/widget_render.zig +272 -18
  85. package/src/primitives/canvas/widget_render_scroll.zig +108 -27
  86. package/src/primitives/canvas/widget_routing.zig +59 -7
  87. package/src/primitives/canvas/widget_runtime.zig +23 -0
  88. package/src/primitives/canvas/widget_runtime_tests.zig +149 -0
  89. package/src/primitives/canvas/widget_semantics.zig +119 -11
  90. package/src/primitives/canvas/widget_semantics_tests.zig +409 -0
  91. package/src/primitives/canvas/widget_tree.zig +17 -0
  92. package/src/primitives/canvas/widgets.zig +132 -0
  93. package/src/root.zig +23 -0
  94. package/src/runtime/api.zig +76 -5
  95. package/src/runtime/automation_commands.zig +20 -1
  96. package/src/runtime/automation_snapshot.zig +25 -1
  97. package/src/runtime/automation_widget_dispatch.zig +73 -8
  98. package/src/runtime/bridge_payload.zig +8 -0
  99. package/src/runtime/bridge_responses.zig +5 -0
  100. package/src/runtime/builtin_bridge.zig +9 -4
  101. package/src/runtime/canvas_font_tests.zig +439 -2
  102. package/src/runtime/canvas_fonts.zig +61 -6
  103. package/src/runtime/canvas_frame.zig +62 -7
  104. package/src/runtime/canvas_frame_animation_tests.zig +5 -4
  105. package/src/runtime/canvas_frame_helpers.zig +190 -1
  106. package/src/runtime/canvas_frame_invalidation_tests.zig +531 -0
  107. package/src/runtime/canvas_frame_patch_tests.zig +161 -10
  108. package/src/runtime/canvas_frame_retained_tests.zig +5 -2
  109. package/src/runtime/canvas_image_tests.zig +195 -0
  110. package/src/runtime/canvas_images.zig +45 -12
  111. package/src/runtime/canvas_widget_accessibility_tests.zig +1 -1
  112. package/src/runtime/canvas_widget_clipboard_tests.zig +40 -0
  113. package/src/runtime/canvas_widget_context_menu.zig +269 -32
  114. package/src/runtime/canvas_widget_context_menu_tests.zig +640 -14
  115. package/src/runtime/canvas_widget_display.zig +1 -1
  116. package/src/runtime/canvas_widget_event_tests.zig +1823 -0
  117. package/src/runtime/canvas_widget_events.zig +240 -24
  118. package/src/runtime/canvas_widget_runtime.zig +213 -29
  119. package/src/runtime/canvas_widget_scroll_driver_tests.zig +170 -7
  120. package/src/runtime/canvas_widget_scroll_drivers.zig +151 -17
  121. package/src/runtime/canvas_widget_scroll_tests.zig +435 -23
  122. package/src/runtime/canvas_widget_state.zig +6 -0
  123. package/src/runtime/canvas_widget_text_tests.zig +1 -1
  124. package/src/runtime/core.zig +131 -13
  125. package/src/runtime/effects.zig +8136 -180
  126. package/src/runtime/effects_channel_tests.zig +3519 -0
  127. package/src/runtime/effects_fetch_tests.zig +89 -1
  128. package/src/runtime/effects_file_tests.zig +41 -1
  129. package/src/runtime/effects_image_tests.zig +1304 -0
  130. package/src/runtime/effects_pty_tests.zig +1362 -0
  131. package/src/runtime/effects_tests.zig +167 -9
  132. package/src/runtime/effects_video_tests.zig +3609 -0
  133. package/src/runtime/flow.zig +42 -4
  134. package/src/runtime/gpu_surface_events.zig +473 -13
  135. package/src/runtime/media_surface.zig +116 -11
  136. package/src/runtime/media_surface_tests.zig +61 -0
  137. package/src/runtime/pty.zig +1252 -0
  138. package/src/runtime/pty_windows.zig +1780 -0
  139. package/src/runtime/root.zig +36 -0
  140. package/src/runtime/runtime_event_tests.zig +20 -1
  141. package/src/runtime/session_blobs.zig +689 -0
  142. package/src/runtime/session_journal.zig +432 -62
  143. package/src/runtime/session_record.zig +43 -2
  144. package/src/runtime/session_replay.zig +556 -20
  145. package/src/runtime/session_tests.zig +2087 -1
  146. package/src/runtime/shell_layout.zig +7 -0
  147. package/src/runtime/terminal_session.zig +1569 -0
  148. package/src/runtime/terminal_session_tests.zig +450 -0
  149. package/src/runtime/terminal_vt_ghostty.zig +15 -0
  150. package/src/runtime/terminal_vt_stub.zig +13 -0
  151. package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
  152. package/src/runtime/testdata/fonts/OFL.txt +93 -0
  153. package/src/runtime/tests.zig +8 -0
  154. package/src/runtime/ts_core_host.zig +1320 -45
  155. package/src/runtime/ts_core_host_tests.zig +1100 -1
  156. package/src/runtime/ts_ui_app.zig +23 -5
  157. package/src/runtime/ui_app.zig +2444 -69
  158. package/src/runtime/ui_app_tests.zig +3171 -744
  159. package/src/runtime/ui_app_virtual_variable_tests.zig +4 -2
  160. package/src/runtime/ui_app_window_tests.zig +736 -0
  161. package/src/runtime/view.zig +190 -2
  162. package/src/runtime/view_widget_scroll.zig +218 -68
  163. package/src/runtime/view_widget_text.zig +11 -2
  164. package/src/runtime/view_widget_tree.zig +111 -3
  165. package/src/runtime/window_command_bridge_tests.zig +117 -0
  166. package/src/runtime/window_storage.zig +77 -2
  167. package/src/runtime/window_view_runtime.zig +34 -2
  168. package/src/runtime/window_views.zig +62 -1
  169. package/src/terminal_session_tests_root.zig +15 -0
  170. package/src/tooling/manifest.zig +75 -0
  171. package/src/tooling/raw_manifest.zig +2 -0
  172. package/src/tooling/templates.zig +244 -8
@@ -101,6 +101,9 @@ var test_payload: ?[]const u8 = null;
101
101
  var test_timeout_ms: u32 = effects_mod.default_effect_fetch_timeout_ms;
102
102
  var test_response_mode: effects_mod.FetchResponseMode = .buffered;
103
103
  var test_max_line_bytes: usize = effects_mod.max_effect_line_bytes;
104
+ /// The poll idiom (one-shot): when set, the update reacts to a response
105
+ /// by immediately fetching the same key again.
106
+ var test_refetch_on_response: bool = false;
104
107
 
105
108
  fn fetchUpdate(model: *FetchModel, msg: FetchMsg, fx: *FetchEffects) void {
106
109
  switch (msg) {
@@ -118,7 +121,17 @@ fn fetchUpdate(model: *FetchModel, msg: FetchMsg, fx: *FetchEffects) void {
118
121
  }),
119
122
  .stop => fx.cancel(fetch_key),
120
123
  .line => |line| model.recordLine(line),
121
- .response => |response| model.record(response),
124
+ .response => |response| {
125
+ model.record(response);
126
+ if (test_refetch_on_response) {
127
+ test_refetch_on_response = false;
128
+ fx.fetch(.{
129
+ .key = fetch_key,
130
+ .url = test_url,
131
+ .on_response = FetchEffects.responseMsg(.response),
132
+ });
133
+ }
134
+ },
122
135
  }
123
136
  }
124
137
 
@@ -1071,3 +1084,78 @@ test "real fetch cancels mid-flight with exactly one cancelled terminal" {
1071
1084
  try std.testing.expectEqual(@as(usize, 1), h.app_state.model.response_count);
1072
1085
  try std.testing.expectEqual(@as(usize, 0), h.app_state.effects.activeCount());
1073
1086
  }
1087
+
1088
+ test "a fetch response still undelivered occupies its key against a second fetch; delivery frees it" {
1089
+ var h = try Harness.create();
1090
+ defer h.destroy();
1091
+ const fx = &h.app_state.effects;
1092
+ fx.executor = .fake;
1093
+
1094
+ test_url = "https://api.example.com/v1/data";
1095
+ test_method = .GET;
1096
+ test_headers = &.{};
1097
+ test_payload = null;
1098
+ test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
1099
+ test_response_mode = .buffered;
1100
+ test_max_line_bytes = effects_mod.max_effect_line_bytes;
1101
+ try h.app_state.dispatch(&h.harness.runtime, 1, .start);
1102
+ try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
1103
+
1104
+ // The fed response queues the terminal and parks the slot in
1105
+ // `.draining` — posted but undelivered. A second fetch of the same
1106
+ // key inside that window must reject: under session replay the
1107
+ // first request is still a parked `.running` fake here (its
1108
+ // journaled response feeds at the recorded delivery position), so
1109
+ // a live accept would journal a Msg stream replay rejects.
1110
+ try fx.feedResponse(fetch_key, 200, "first");
1111
+ try h.app_state.dispatch(&h.harness.runtime, 1, .start);
1112
+ try std.testing.expectEqual(@as(usize, 0), fx.pendingFetchCount());
1113
+
1114
+ // Delivery order: the staged rejection first (loop-side pending),
1115
+ // then the queued response.
1116
+ try h.drainWakes();
1117
+ try std.testing.expectEqual(@as(usize, 2), h.app_state.model.response_count);
1118
+ try std.testing.expectEqual(@as(usize, 1), h.app_state.model.rejected_count);
1119
+ try std.testing.expectEqual(effects_mod.EffectFetchOutcome.ok, h.app_state.model.outcome.?);
1120
+
1121
+ // The window ends at delivery: the same key fetches again.
1122
+ try h.app_state.dispatch(&h.harness.runtime, 1, .start);
1123
+ try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
1124
+ try fx.feedResponse(fetch_key, 201, "second");
1125
+ try h.drainWakes();
1126
+ try std.testing.expectEqual(@as(usize, 3), h.app_state.model.response_count);
1127
+ try std.testing.expectEqual(@as(u16, 201), h.app_state.model.status);
1128
+ }
1129
+
1130
+ test "an update that refetches the same key from its own response parks instead of rejecting" {
1131
+ var h = try Harness.create();
1132
+ defer h.destroy();
1133
+ const fx = &h.app_state.effects;
1134
+ fx.executor = .fake;
1135
+
1136
+ test_url = "https://api.example.com/v1/poll";
1137
+ test_method = .GET;
1138
+ test_headers = &.{};
1139
+ test_payload = null;
1140
+ test_timeout_ms = effects_mod.default_effect_fetch_timeout_ms;
1141
+ test_response_mode = .buffered;
1142
+ test_max_line_bytes = effects_mod.max_effect_line_bytes;
1143
+ test_refetch_on_response = true;
1144
+ try h.app_state.dispatch(&h.harness.runtime, 1, .start);
1145
+ try fx.feedResponse(fetch_key, 200, "first");
1146
+
1147
+ // The drain retires the slot BEFORE the terminal Msg reaches
1148
+ // update, so the handler's refetch of its own key is a fresh
1149
+ // accepted fetch — the poll idiom must not regress.
1150
+ try h.drainWakes();
1151
+ try std.testing.expectEqual(@as(usize, 1), h.app_state.model.response_count);
1152
+ try std.testing.expectEqual(@as(usize, 0), h.app_state.model.rejected_count);
1153
+ try std.testing.expectEqual(@as(usize, 1), fx.pendingFetchCount());
1154
+
1155
+ // The refetched occupancy is fully live: its own terminal delivers.
1156
+ try fx.feedResponse(fetch_key, 201, "second");
1157
+ try h.drainWakes();
1158
+ try std.testing.expectEqual(@as(usize, 2), h.app_state.model.response_count);
1159
+ try std.testing.expectEqual(@as(u16, 201), h.app_state.model.status);
1160
+ try std.testing.expectEqual(@as(usize, 0), h.app_state.model.rejected_count);
1161
+ }
@@ -73,6 +73,9 @@ const file_key: u64 = 77;
73
73
  // Set by each test before dispatching `.save`/`.load`.
74
74
  var test_path: []const u8 = "";
75
75
  var test_bytes: []const u8 = "";
76
+ /// The reload idiom (one-shot): when set, the update reacts to a file
77
+ /// terminal by immediately reading the same key again.
78
+ var test_reread_on_result: bool = false;
76
79
 
77
80
  fn fileUpdate(model: *FileModel, msg: FileMsg, fx: *FileEffects) void {
78
81
  switch (msg) {
@@ -88,7 +91,17 @@ fn fileUpdate(model: *FileModel, msg: FileMsg, fx: *FileEffects) void {
88
91
  .on_result = FileEffects.fileMsg(.file_result),
89
92
  }),
90
93
  .stop => fx.cancel(file_key),
91
- .file_result => |result| model.record(result),
94
+ .file_result => |result| {
95
+ model.record(result);
96
+ if (test_reread_on_result) {
97
+ test_reread_on_result = false;
98
+ fx.readFile(.{
99
+ .key = file_key,
100
+ .path = test_path,
101
+ .on_result = FileEffects.fileMsg(.file_result),
102
+ });
103
+ }
104
+ },
92
105
  }
93
106
  }
94
107
 
@@ -237,6 +250,33 @@ test "cancelling a fake file effect delivers one cancelled terminal" {
237
250
  try std.testing.expectError(error.EffectNotFound, fx.feedFileResult(file_key, .ok, ""));
238
251
  }
239
252
 
253
+ test "an update that rereads the same key from its own file result parks instead of rejecting" {
254
+ var h = try Harness.create();
255
+ defer h.destroy();
256
+ const fx = &h.app_state.effects;
257
+ fx.executor = .fake;
258
+
259
+ test_path = "sessions/state.json";
260
+ test_bytes = "";
261
+ test_reread_on_result = true;
262
+ try h.app_state.dispatch(&h.harness.runtime, 1, .load);
263
+ try fx.feedFileResult(file_key, .ok, "{\"stage\":\"one\"}");
264
+
265
+ // The drain retires the slot BEFORE the terminal Msg reaches
266
+ // update, so the handler's reread of its own key is a fresh
267
+ // accepted file effect — the reload idiom must not regress.
268
+ try h.drainWakes();
269
+ try std.testing.expectEqual(@as(usize, 1), h.app_state.model.result_count);
270
+ try std.testing.expectEqual(effects_mod.EffectFileOutcome.ok, h.app_state.model.last_outcome.?);
271
+ try std.testing.expectEqual(@as(usize, 1), fx.pendingFileCount());
272
+
273
+ // The reread occupancy is fully live: its own terminal delivers.
274
+ try fx.feedFileResult(file_key, .ok, "{\"stage\":\"two\"}");
275
+ try h.drainWakes();
276
+ try std.testing.expectEqual(@as(usize, 2), h.app_state.model.result_count);
277
+ try std.testing.expectEqualStrings("{\"stage\":\"two\"}", h.app_state.model.bytesPrefix());
278
+ }
279
+
240
280
  test "file requests that cannot run are rejected loudly, never silently" {
241
281
  var h = try Harness.create();
242
282
  defer h.destroy();