@native-sdk/cli 0.5.0 → 0.5.2

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 (60) hide show
  1. package/build/app.zig +198 -13
  2. package/build/ts_run.mjs +58 -19
  3. package/build.zig +42 -0
  4. package/package.json +13 -9
  5. package/packages/core/package-lock.json +4 -3
  6. package/packages/core/package.json +3 -2
  7. package/packages/core/src/typed_ast.ts +11 -1
  8. package/skill-data/native-ui/SKILL.md +2 -2
  9. package/src/platform/types.zig +9 -0
  10. package/src/platform/windows/webview2_host.cpp +24 -0
  11. package/src/primitives/canvas/layout_audit.zig +5 -5
  12. package/src/primitives/canvas/root.zig +6 -0
  13. package/src/primitives/canvas/tokens.zig +185 -7
  14. package/src/primitives/canvas/ui.zig +27 -5
  15. package/src/primitives/canvas/ui_markup.zig +27 -4
  16. package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
  17. package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
  18. package/src/primitives/canvas/ui_markup_tests.zig +47 -0
  19. package/src/primitives/canvas/ui_markup_view.zig +10 -1
  20. package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
  21. package/src/primitives/canvas/ui_schema.zig +15 -1
  22. package/src/primitives/canvas/ui_schema_tests.zig +5 -4
  23. package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
  24. package/src/primitives/canvas/widget_layout.zig +142 -3
  25. package/src/primitives/canvas/widget_layout_tests.zig +82 -0
  26. package/src/primitives/canvas/widget_metrics.zig +16 -8
  27. package/src/primitives/canvas/widget_tree.zig +14 -2
  28. package/src/primitives/canvas/widgets.zig +12 -0
  29. package/src/runtime/automation_widget_dispatch.zig +95 -28
  30. package/src/runtime/canvas_frame.zig +15 -0
  31. package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
  32. package/src/runtime/canvas_widget_context_menu.zig +3 -2
  33. package/src/runtime/canvas_widget_events.zig +1271 -3
  34. package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
  35. package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
  36. package/src/runtime/canvas_widget_state.zig +82 -5
  37. package/src/runtime/core.zig +30 -0
  38. package/src/runtime/effects.zig +1037 -133
  39. package/src/runtime/effects_fetch_tests.zig +42 -0
  40. package/src/runtime/effects_file_tests.zig +220 -0
  41. package/src/runtime/effects_tests.zig +287 -0
  42. package/src/runtime/flow.zig +24 -1
  43. package/src/runtime/gpu_surface_events.zig +44 -5
  44. package/src/runtime/session_journal.zig +25 -13
  45. package/src/runtime/session_record.zig +166 -0
  46. package/src/runtime/session_tests.zig +453 -0
  47. package/src/runtime/ui_app.zig +137 -39
  48. package/src/runtime/ui_app_tests.zig +681 -0
  49. package/src/runtime/ui_app_window_tests.zig +182 -0
  50. package/src/runtime/view.zig +86 -0
  51. package/src/runtime/view_widget_text.zig +18 -1
  52. package/src/runtime/view_widget_tree.zig +339 -20
  53. package/src/runtime/widget_bridge.zig +26 -0
  54. package/src/runtime/window_storage.zig +61 -15
  55. package/src/runtime/window_view_runtime.zig +13 -0
  56. package/src/runtime/window_views.zig +6 -0
  57. package/src/tooling/package.zig +311 -8
  58. package/src/tooling/templates.zig +97 -9
  59. package/src/tooling/ts_core.zig +626 -13
  60. package/src/tooling/verbs.zig +88 -2
@@ -128,7 +128,7 @@ pub fn RuntimeCanvasWidgetScrollDrivers(comptime Runtime: type) type {
128
128
  const dirty = try self.views[index].applyCanvasWidgetScrollDriverOffset(node_index, event.offset_y) orelse return;
129
129
 
130
130
  const previous_cursor = self.views[index].canvas_widget_cursor;
131
- self.views[index].reconcileCanvasWidgetRenderStateAfterScroll(null);
131
+ try CanvasWidgetEventMethods().reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent(self, index, null);
132
132
  if (previous_cursor != self.views[index].canvas_widget_cursor) {
133
133
  try CanvasWidgetEventMethods().syncCanvasWidgetCursorForView(self, index);
134
134
  }
@@ -25,6 +25,7 @@ const CanvasWidgetTextReconcileEntry = canvas_widget_runtime.CanvasWidgetTextRec
25
25
  const canvasWidgetLayoutTreeWithRuntimeReconcileState = canvas_widget_runtime.canvasWidgetLayoutTreeWithRuntimeReconcileState;
26
26
  const canvasWidgetEditableTextKind = canvas_widget_runtime.canvasWidgetEditableTextKind;
27
27
  const canvasWidgetAccessibilityActionSupported = widget_bridge.canvasWidgetAccessibilityActionSupported;
28
+ const platformWidgetAccessibilityActionKindFromCanvas = widget_bridge.platformWidgetAccessibilityActionKindFromCanvas;
28
29
  const canvasWidgetBooleanSelected = canvas_widget_runtime.canvasWidgetBooleanSelected;
29
30
 
30
31
  pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
@@ -95,6 +96,40 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
95
96
  // and force-pushing the clamp into the live bounce (visible
96
97
  // jitter). Non-driver platforms clamp exactly as before.
97
98
  canvas_widget_runtime.clampCanvasWidgetLayoutScrollOffsets(reconciled_nodes[0..reconciled_layout.nodes.len], null);
99
+ // Runtime-owned tooltip visibility normalizes BEFORE the
100
+ // diff: the retained tree carries the intent machine's
101
+ // hidden stamps on anchored tooltips while the source
102
+ // declares authored visibility, so diffing them as-is
103
+ // reported a spurious visibility invalidation (a dirty
104
+ // repaint region for chrome that never changed) on EVERY
105
+ // rebuild containing a hidden anchored tooltip. The stamp
106
+ // uses the prune VERDICT against the reconciled tree — the
107
+ // shown id adoption will actually keep — WITHOUT mutating
108
+ // the live intent registers yet: everything between here
109
+ // and a retained tree is fallible (`diffWithTokens` can
110
+ // overflow its invalidation scratch, and
111
+ // `copyWidgetLayoutTree` rejects node/anchored-surface
112
+ // limits and every retained-pool budget before it resets
113
+ // the pools), and a register prune applied ahead of a
114
+ // failure left the OLD tree stamped visible with cleared
115
+ // registers — a tooltip no transition could ever hide
116
+ // again. The register mutation lands inside
117
+ // `copyWidgetLayoutTree`'s own prune, after the fallible
118
+ // steps succeed, where it applies this same verdict; an
119
+ // unchanged rebuild still diffs clean, a SHOWN tooltip
120
+ // stays visibly shown across the rebuild (no hide-then-show
121
+ // frame pair), and a rebuild that breaks the shown binding
122
+ // still diffs the hide honestly.
123
+ const prospective_shown_tooltip_id = self.views[index].canvasTooltipShownIdSurvivingLayout(reconciled_layout);
124
+ // Pre-adoption tooltip bindings for the standing hover and
125
+ // keyboard focus-visible owners, captured while the OLD
126
+ // tree is still retained (the copy below replaces it): the
127
+ // adoption reconcile at the bottom compares them against
128
+ // the adopted tree to catch a tooltip mounted/replaced/
129
+ // rekeyed beneath a stable owner — a change neither the
130
+ // hover re-hit-test nor the register prune can see.
131
+ const adoption_tooltip_bindings = CanvasWidgetEventMethods(Runtime).captureCanvasTooltipAdoptionBindings(self, index);
132
+ self.views[index].applyCanvasTooltipVisibilityToNodesForShownId(reconciled_nodes[0..reconciled_layout.nodes.len], prospective_shown_tooltip_id);
98
133
  const invalidations = try canvas.WidgetLayoutTree.diffWithTokens(previous_layout, reconciled_layout, tokens, &self.canvas_widget_invalidations_scratch);
99
134
  const previous_render_state = self.views[index].canvasWidgetRenderState();
100
135
  const next_render_state = CanvasWidgetEventMethods(Runtime).canvasWidgetRenderStateAfterLayout(previous_render_state, reconciled_layout);
@@ -151,6 +186,16 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
151
186
  // the user was looking at, and the tween walks it to the
152
187
  // declared pose one presented frame at a time.
153
188
  try applyCanvasWidgetDisclosureTweenPlan(self, index, disclosure_plan);
189
+ // Re-hit-test the stationary pointer against the ADOPTED
190
+ // tree, after every pose restore above settles the frames
191
+ // the user actually sees and BEFORE the display refresh
192
+ // publishes them: the prune at the top validates only
193
+ // tooltip/owner identity and hover survives by ID, so a
194
+ // rebuild that MOVES a same-ID trigger away from (or
195
+ // under) the stationary pointer must step hover ownership
196
+ // and the tooltip intent machine exactly like the
197
+ // point-blind scroll paths do.
198
+ try CanvasWidgetEventMethods(Runtime).reconcileCanvasWidgetInteractionAfterLayoutAdoption(self, index, adoption_tooltip_bindings);
154
199
  const requested_frame = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
155
200
  if ((layout_dirty or widget_revision_changed) and !requested_frame) try CanvasFrameMethods(Runtime).requestCanvasFrameForView(self, index);
156
201
  return self.views[index].info();
@@ -187,6 +232,38 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
187
232
  const actions = AutomationWidgetMethods(Runtime).canvasWidgetActionsForId(self, index, action.id) orelse return error.InvalidCommand;
188
233
  if (!canvasWidgetAccessibilityActionSupported(actions, action.action)) return error.InvalidCommand;
189
234
 
235
+ // Session recording, outer-wins on BOTH entry surfaces: the
236
+ // platform AX path arrives with its journaled tag-23 event
237
+ // already on the recorder's staging stack (flow.zig staged
238
+ // it), but the DIRECT verb surfaces (an embed host's
239
+ // `widgetAction`, automation `widget_action` commands) reach
240
+ // here with no platform event at all. Their verbs journal
241
+ // only UNTARGETED children routed by focus, while the focus
242
+ // write itself (`focusAutomationCanvasWidget`) is a direct
243
+ // unjournaled state change — so a fresh replay delivered the
244
+ // children against whatever focus the session happened to
245
+ // hold and a first-in-session composition landed nowhere.
246
+ // Stage the same synthetic `widget_accessibility_action`
247
+ // record the platform path carries: its suppression window
248
+ // keeps the children out of the journal and replay re-runs
249
+ // this whole dispatch — focus included — through the tag-23
250
+ // arm in flow.zig. When the platform event IS already staged,
251
+ // this nested stage lands inside its suppression window as a
252
+ // never-written placeholder, so no double record; the commit
253
+ // below pops it symmetrically. Effect results drained during
254
+ // the verb still write through ahead of the record, and
255
+ // event_count/checkpoint ordinals only ever see the one
256
+ // surviving record (checkpoints fire at staging depth 0).
257
+ if (self.options.session_recorder) |recorder| recorder.stageEvent(.{ .widget_accessibility_action = .{
258
+ .window_id = window_id,
259
+ .label = label,
260
+ .id = action.id,
261
+ .action = platformWidgetAccessibilityActionKindFromCanvas(action.action),
262
+ .text = action.text,
263
+ .selection = if (action.selection) |selection| .{ .start = selection.anchor, .end = selection.focus } else null,
264
+ } });
265
+ defer if (self.options.session_recorder) |recorder| recorder.commitEvent();
266
+
190
267
  // Every assistive action rides the SAME machinery the
191
268
  // automation widget verbs use — the key-driven activation for
192
269
  // press/toggle/increment/decrement (quiet-list-row ring
@@ -209,10 +286,10 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
209
286
  .increment => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, self.views[index].canvasWidgetStepKey(action.id, .increment)),
210
287
  .decrement => try AutomationWidgetMethods(Runtime).dispatchAutomationWidgetKey(self, app, index, action.id, self.views[index].canvasWidgetStepKey(action.id, .decrement)),
211
288
  .set_text => try AutomationWidgetMethods(Runtime).setAutomationCanvasWidgetText(self, app, index, action.id, action.text),
212
- .set_selection => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .{ .set_selection = action.selection orelse return error.InvalidCommand }),
213
- .set_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .{ .set_composition = .{ .text = action.text } }),
214
- .commit_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .commit_composition),
215
- .cancel_composition => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, index, action.id, .cancel_composition),
289
+ .set_selection => try AutomationWidgetMethods(Runtime).editAutomationCanvasWidgetText(self, app, index, action.id, .{ .set_selection = action.selection orelse return error.InvalidCommand }),
290
+ .set_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_set_composition, action.text),
291
+ .commit_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_commit_composition, ""),
292
+ .cancel_composition => try AutomationWidgetMethods(Runtime).composeAutomationCanvasWidgetText(self, app, index, action.id, .ime_cancel_composition, ""),
216
293
  .select => try AutomationWidgetMethods(Runtime).selectAutomationCanvasWidget(self, index, action.id),
217
294
  .drag => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetDrag(self, app, index, action.id, action.text),
218
295
  .drop_files => try AutomationWidgetMethods(Runtime).dispatchAutomationCanvasWidgetFileDrop(self, app, index, action.id, action.text),
@@ -233,7 +310,7 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
233
310
 
234
311
  const dirty = try self.views[index].stepCanvasWidgetKineticScroll(dt_ms) orelse return self.views[index].info();
235
312
  const previous_cursor = self.views[index].canvas_widget_cursor;
236
- self.views[index].reconcileCanvasWidgetRenderStateAfterScroll(null);
313
+ try CanvasWidgetEventMethods(Runtime).reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent(self, index, null);
237
314
  if (previous_cursor != self.views[index].canvas_widget_cursor) try CanvasWidgetEventMethods(Runtime).syncCanvasWidgetCursorForView(self, index);
238
315
  try CanvasWidgetEventMethods(Runtime).invalidateForCanvasWidgetDirty(self, index, dirty);
239
316
  _ = try CanvasWidgetDisplayMethods(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
@@ -222,6 +222,18 @@ pub const Runtime = struct {
222
222
  next_window_id: platform.WindowId = 2,
223
223
  next_view_id: platform.ViewId = 1,
224
224
  invalidated: bool = true,
225
+ /// Whether the platform currently reports the app ACTIVE (frontmost
226
+ /// on macOS — the state the `.app_activated`/`.app_deactivated`
227
+ /// lifecycle events flip). Stamped in the dispatch loop from those
228
+ /// journaled events, so replay reproduces it deterministically.
229
+ /// Defaults true: a launching app is treated as active until the
230
+ /// platform says otherwise, because some hosts deliver input before
231
+ /// the first activation event and suppressing intent until one
232
+ /// arrived would deaden hover on hosts that never send it. The
233
+ /// tooltip intent machine consults this: an INACTIVE app reveals
234
+ /// and arms nothing — including a rebuild the app performs from its
235
+ /// own deactivation callback.
236
+ app_active: bool = true,
225
237
  /// Whether the app's stop hook (`App.stop`) has been delivered.
226
238
  /// Normally the platform's `.app_shutdown` event delivers it; the
227
239
  /// run loop's exit path checks this flag and delivers a missed stop
@@ -645,6 +657,22 @@ pub const Runtime = struct {
645
657
  return self.surface.safe_area_insets;
646
658
  }
647
659
 
660
+ /// The OS window-control cluster's frame in a canvas view's LOCAL
661
+ /// coordinates (Windows: the DWM min/max/close buttons; macOS: the
662
+ /// traffic lights), from the platform's live chrome report. Zero-sized
663
+ /// when no controls overlay the content — standard-chrome windows,
664
+ /// fullscreen, platforms without the concept — and translated by the
665
+ /// view's window-content frame so a docked canvas judges the overlap
666
+ /// in its own space. This is the geometry `UiApp` consults to keep a
667
+ /// drag header's content out from under the cluster.
668
+ pub fn windowControlsForView(self: *const Runtime, window_id: platform.WindowId, label: []const u8) geometry.RectF {
669
+ const zero = geometry.RectF.init(0, 0, 0, 0);
670
+ const buttons = self.options.platform.services.windowChrome(window_id).buttons.normalized();
671
+ if (buttons.width <= 0 or buttons.height <= 0) return zero;
672
+ const view_frame = (self.absoluteViewFrame(window_id, label, 0) catch return buttons).normalized();
673
+ return geometry.RectF.init(buttons.x - view_frame.x, buttons.y - view_frame.y, buttons.width, buttons.height);
674
+ }
675
+
648
676
  pub fn listCommands(self: *const Runtime, output: []Command) []const Command {
649
677
  const count = @min(output.len, self.options.commands.len);
650
678
  for (self.options.commands[0..count], 0..) |command, index| {
@@ -727,6 +755,7 @@ pub const Runtime = struct {
727
755
  const refreshCanvasWidgetDisplayList = CanvasWidgetDisplayMethods.refreshCanvasWidgetDisplayList;
728
756
 
729
757
  const CanvasWidgetEventMethods = runtime_canvas_widget_events.RuntimeCanvasWidgetEvents(Runtime);
758
+ pub const advanceCanvasTooltipIntentForFrame = CanvasWidgetEventMethods.advanceCanvasTooltipIntentForFrame;
730
759
  pub const routeCanvasWidgetPointerInput = CanvasWidgetEventMethods.routeCanvasWidgetPointerInput;
731
760
  pub const routeCanvasWidgetKeyboardInput = CanvasWidgetEventMethods.routeCanvasWidgetKeyboardInput;
732
761
  pub const routeCanvasWidgetTextInput = CanvasWidgetEventMethods.routeCanvasWidgetTextInput;
@@ -775,6 +804,7 @@ pub const Runtime = struct {
775
804
  const selectAutomationCanvasWidget = AutomationWidgetMethods.selectAutomationCanvasWidget;
776
805
  const setAutomationCanvasWidgetText = AutomationWidgetMethods.setAutomationCanvasWidgetText;
777
806
  const editAutomationCanvasWidgetText = AutomationWidgetMethods.editAutomationCanvasWidgetText;
807
+ const composeAutomationCanvasWidgetText = AutomationWidgetMethods.composeAutomationCanvasWidgetText;
778
808
  const dispatchAutomationCanvasWidgetDrag = AutomationWidgetMethods.dispatchAutomationCanvasWidgetDrag;
779
809
  const dispatchAutomationCanvasWidgetFileDrop = AutomationWidgetMethods.dispatchAutomationCanvasWidgetFileDrop;
780
810
  };