@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.
- package/build/app.zig +198 -13
- package/build/ts_run.mjs +58 -19
- package/build.zig +42 -0
- package/package.json +13 -9
- package/packages/core/package-lock.json +4 -3
- package/packages/core/package.json +3 -2
- package/packages/core/src/typed_ast.ts +11 -1
- package/skill-data/native-ui/SKILL.md +2 -2
- package/src/platform/types.zig +9 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tokens.zig +185 -7
- package/src/primitives/canvas/ui.zig +27 -5
- package/src/primitives/canvas/ui_markup.zig +27 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +47 -0
- package/src/primitives/canvas/ui_markup_view.zig +10 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
- package/src/primitives/canvas/ui_schema.zig +15 -1
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
- package/src/primitives/canvas/widget_layout.zig +142 -3
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +12 -0
- package/src/runtime/automation_widget_dispatch.zig +95 -28
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_events.zig +1271 -3
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +82 -5
- package/src/runtime/core.zig +30 -0
- package/src/runtime/effects.zig +1037 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/flow.zig +24 -1
- package/src/runtime/gpu_surface_events.zig +44 -5
- package/src/runtime/session_journal.zig +25 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +453 -0
- package/src/runtime/ui_app.zig +137 -39
- package/src/runtime/ui_app_tests.zig +681 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
- package/src/tooling/package.zig +311 -8
- package/src/tooling/templates.zig +97 -9
- package/src/tooling/ts_core.zig +626 -13
- package/src/tooling/verbs.zig +88 -2
|
@@ -61,6 +61,10 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
61
61
|
// so accordion reveals replay frame for frame exactly
|
|
62
62
|
// like split fractions do.
|
|
63
63
|
try self.advanceCanvasWidgetDisclosureTweenForFrame(index, frame_event.timestamp_ns);
|
|
64
|
+
// The anchored-tooltip hover-intent delay fires on the
|
|
65
|
+
// same recorded clock: a dwell past the delay shows its
|
|
66
|
+
// tooltip on a deterministic frame, replayed exactly.
|
|
67
|
+
try self.advanceCanvasTooltipIntentForFrame(index, frame_event.timestamp_ns);
|
|
64
68
|
try dispatchPendingCanvasWidgetScrollEvents(self, app, index);
|
|
65
69
|
// A settling tween notes its ONE split-resize event with
|
|
66
70
|
// no input in flight; drain it here so the controlled
|
|
@@ -180,6 +184,16 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
180
184
|
if (runtimeFindViewIndex(self, input_event.window_id, input_event.label)) |index| {
|
|
181
185
|
self.views[index].recordGpuSurfaceInputTimestamp(input_event.timestamp_ns);
|
|
182
186
|
}
|
|
187
|
+
// The whole consumed stream still feeds the tooltip
|
|
188
|
+
// intent choke point: every pointer-carrying event
|
|
189
|
+
// updates the stored position (a later point-blind
|
|
190
|
+
// reconcile must hit-test where the pointer really is),
|
|
191
|
+
// the secondary down resets the machine before the menu
|
|
192
|
+
// presents ("pointer-down dismisses" holds for EVERY
|
|
193
|
+
// button — no tooltip floats behind or over the native
|
|
194
|
+
// menu), and a consumed cancel is still the pointer
|
|
195
|
+
// leaving the view.
|
|
196
|
+
try CanvasWidgetEventMethods().reconcileCanvasTooltipIntentForConsumedPointerInput(self, input_event);
|
|
183
197
|
if (input_event.kind == .pointer_down) {
|
|
184
198
|
try setFocusedView(self, input_event.window_id, input_event.label);
|
|
185
199
|
self.invalidated = true;
|
|
@@ -244,7 +258,17 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
244
258
|
// click on the native titlebar. Dismissal above still ran:
|
|
245
259
|
// clicking the header closes an open surface first.
|
|
246
260
|
window_drag_started = try CanvasWidgetEventMethods().startCanvasWidgetWindowDragFromPointer(self, input_event, pointer_event.*);
|
|
247
|
-
if (
|
|
261
|
+
if (window_drag_started) {
|
|
262
|
+
// The drag consumed the down, but "pointer-down
|
|
263
|
+
// dismisses" still holds — and the down still
|
|
264
|
+
// carried a position the intent machine must
|
|
265
|
+
// record: the OS owning the pointer from here must
|
|
266
|
+
// not strand an armed or shown tooltip (the
|
|
267
|
+
// matching up may never arrive), and a later
|
|
268
|
+
// point-blind reconcile must hit-test where the
|
|
269
|
+
// pointer really went down.
|
|
270
|
+
try CanvasWidgetEventMethods().reconcileCanvasTooltipIntentForConsumedPointerInput(self, input_event);
|
|
271
|
+
} else {
|
|
248
272
|
try CanvasWidgetEventMethods().updateCanvasWidgetControlFromPointer(self, pointer_event.*);
|
|
249
273
|
try CanvasWidgetEventMethods().updateCanvasWidgetInteractionFromPointer(self, pointer_event.*);
|
|
250
274
|
// The text pass may stamp a clear edit onto the
|
|
@@ -297,11 +321,19 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
297
321
|
&clipboard_paste_buffer,
|
|
298
322
|
);
|
|
299
323
|
}
|
|
300
|
-
|
|
301
|
-
|
|
324
|
+
// The text pass stamps the edit it derived and applied onto
|
|
325
|
+
// the event (Escape's clear included), so the app dispatch
|
|
326
|
+
// below hears exactly the edit the retained editor performed.
|
|
327
|
+
if (widget_keyboard_event) |*keyboard_event| {
|
|
328
|
+
// Keyboard activation counts as a press for tooltips:
|
|
329
|
+
// Space/Enter on the focused trigger dismisses its
|
|
330
|
+
// armed/shown tooltip before the control mutation and
|
|
331
|
+
// app dispatch observe the input.
|
|
332
|
+
try CanvasWidgetEventMethods().updateCanvasTooltipIntentForKeyboardActivation(self, keyboard_event.*);
|
|
333
|
+
try CanvasWidgetEventMethods().updateCanvasWidgetControlFromKeyboard(self, keyboard_event.*);
|
|
302
334
|
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, keyboard_event);
|
|
303
335
|
}
|
|
304
|
-
|
|
336
|
+
var widget_text_input_event = if (widget_surface_dismissed)
|
|
305
337
|
null
|
|
306
338
|
else
|
|
307
339
|
CanvasWidgetEventMethods().routeCanvasWidgetTextInput(self, input_event, &self.widget_event_route_entries) catch |err| switch (err) {
|
|
@@ -311,7 +343,7 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
|
|
|
311
343
|
=> null,
|
|
312
344
|
else => return err,
|
|
313
345
|
};
|
|
314
|
-
if (widget_text_input_event)
|
|
346
|
+
if (widget_text_input_event) |*text_input_event| {
|
|
315
347
|
try CanvasWidgetEventMethods().updateCanvasWidgetTextFromKeyboard(self, text_input_event);
|
|
316
348
|
}
|
|
317
349
|
// The refresh batch stays open across the app dispatches
|
|
@@ -609,11 +641,18 @@ fn setFocusedView(self: anytype, window_id: platform.WindowId, label: []const u8
|
|
|
609
641
|
for (self.views[0..self.view_count], 0..) |*view, view_index| {
|
|
610
642
|
if (view.window_id != window_id) continue;
|
|
611
643
|
const previous_state = view.canvasWidgetRenderState();
|
|
644
|
+
const was_focused = view.focused;
|
|
612
645
|
view.focused = std.mem.eql(u8, view.label, label);
|
|
613
646
|
const next_state = view.canvasWidgetRenderState();
|
|
614
647
|
if (!runtime_canvas_widget_events.RuntimeCanvasWidgetEvents(@TypeOf(self.*)).canvasWidgetRenderStatesEqual(previous_state, next_state)) {
|
|
615
648
|
try runtime_canvas_widget_events.RuntimeCanvasWidgetEvents(@TypeOf(self.*)).invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, next_state);
|
|
616
649
|
}
|
|
650
|
+
// A view losing focus drops its tooltip state and re-stamps
|
|
651
|
+
// hidden — input landing in a sibling view must not leave the
|
|
652
|
+
// blurred view's tooltip floating.
|
|
653
|
+
if (was_focused and !view.focused) {
|
|
654
|
+
try runtime_canvas_widget_events.RuntimeCanvasWidgetEvents(@TypeOf(self.*)).resetCanvasTooltipIntentForViewBlur(self, view_index);
|
|
655
|
+
}
|
|
617
656
|
}
|
|
618
657
|
for (self.webviews[0..self.webview_count]) |*webview| {
|
|
619
658
|
if (webview.window_id == window_id) webview.focused = std.mem.eql(u8, webview.label, label);
|
|
@@ -44,16 +44,17 @@
|
|
|
44
44
|
//! reordering any journaled enum is a format break: bump
|
|
45
45
|
//! `format_version` when one moves.
|
|
46
46
|
//!
|
|
47
|
-
//! Coverage note: automation driving
|
|
48
|
-
//!
|
|
49
|
-
//!
|
|
50
|
-
//!
|
|
51
|
-
//!
|
|
52
|
-
//!
|
|
53
|
-
//!
|
|
54
|
-
//!
|
|
55
|
-
//!
|
|
56
|
-
//!
|
|
47
|
+
//! Coverage note: automation driving is fully journaled. Verbs that
|
|
48
|
+
//! synthesize PLATFORM events (widget-click/hold/context-press/drag/
|
|
49
|
+
//! wheel/key, resize, menu-command, shortcut, tray-action) journal
|
|
50
|
+
//! those events; every widget-action verb — including the direct-
|
|
51
|
+
//! surface ones (focus, select, set_selection, set_text, and the
|
|
52
|
+
//! composition edits) — journals as the outer-wins
|
|
53
|
+
//! `widget_accessibility_action` record its dispatch stages, with the
|
|
54
|
+
//! events it synthesizes inside suppressed as that record's children.
|
|
55
|
+
//! Replaying the action record re-runs the verb through the same
|
|
56
|
+
//! dispatch, so recorded sessions may drive text and selection through
|
|
57
|
+
//! any verb.
|
|
57
58
|
|
|
58
59
|
const std = @import("std");
|
|
59
60
|
const geometry = @import("geometry");
|
|
@@ -70,8 +71,12 @@ pub const magic = "NSDKSJNL";
|
|
|
70
71
|
/// enum orders bumps this; readers refuse other versions loudly rather
|
|
71
72
|
/// than misreading yesterday's shape. v2 added the stream `buffering`
|
|
72
73
|
/// flag to audio event and audio effect records; v3 added the spectrum
|
|
73
|
-
/// band bytes to both (and the `.spectrum` audio kind)
|
|
74
|
-
|
|
74
|
+
/// band bytes to both (and the `.spectrum` audio kind); v4 added the
|
|
75
|
+
/// composition verbs (`set_composition`/`commit_composition`/
|
|
76
|
+
/// `cancel_composition`, codes 11-13) to the accessibility-action
|
|
77
|
+
/// record's verb enum — a v3 reader hitting one of those codes would
|
|
78
|
+
/// have reported the file corrupt instead of refusing the skew.
|
|
79
|
+
pub const format_version: u32 = 4;
|
|
75
80
|
|
|
76
81
|
// ------------------------------------------------------------- budgets
|
|
77
82
|
//
|
|
@@ -1067,7 +1072,7 @@ pub const Reader = struct {
|
|
|
1067
1072
|
pub fn describeError(err: JournalError) []const u8 {
|
|
1068
1073
|
return switch (err) {
|
|
1069
1074
|
error.JournalBadMagic => "not a session journal (bad magic) - record one with NATIVE_SDK_SESSION_RECORD=<path>",
|
|
1070
|
-
error.JournalUnsupportedVersion => "journal format version differs from this build - re-record the session with the same build that replays it",
|
|
1075
|
+
error.JournalUnsupportedVersion => std.fmt.comptimePrint("journal format version differs from the v{d} this build reads and writes - re-record the session with the same build that replays it", .{format_version}),
|
|
1071
1076
|
error.JournalTruncated => "journal ends mid-record (the recording was cut off) - re-record, and keep the app running until it exits cleanly",
|
|
1072
1077
|
error.JournalCorrupt => "journal payload does not decode (damaged or hand-edited bytes)",
|
|
1073
1078
|
error.JournalRecordOverBudget => "journal claims a record beyond max_session_record_bytes - the file is damaged or hostile",
|
|
@@ -1435,6 +1440,13 @@ test "reader refuses bad magic and version skew" {
|
|
|
1435
1440
|
@memcpy(skewed[0..len], buffer[0..len]);
|
|
1436
1441
|
std.mem.writeInt(u32, skewed[magic.len..][0..4], format_version + 1, .little);
|
|
1437
1442
|
try testing.expectError(error.JournalUnsupportedVersion, Reader.init(skewed[0..len]));
|
|
1443
|
+
// Older journals are refused the same way — and, symmetrically, a
|
|
1444
|
+
// reader built before a version bump refuses a NEWER journal at the
|
|
1445
|
+
// preamble instead of reporting an unknown payload code as
|
|
1446
|
+
// corruption (the v4 bump's reason: v3 readers would have called a
|
|
1447
|
+
// journaled composition verb code corrupt).
|
|
1448
|
+
std.mem.writeInt(u32, skewed[magic.len..][0..4], format_version - 1, .little);
|
|
1449
|
+
try testing.expectError(error.JournalUnsupportedVersion, Reader.init(skewed[0..len]));
|
|
1438
1450
|
}
|
|
1439
1451
|
|
|
1440
1452
|
test "reader fails loudly on truncation at every boundary" {
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
//! BEFORE the event record — the ordering replay depends on (feed the
|
|
7
7
|
//! stub executor, then dispatch). Nested dispatches (automation commands
|
|
8
8
|
//! inside `frame_requested`) commit innermost-first for the same reason.
|
|
9
|
+
//! One exception: events nested inside a dispatched accessibility
|
|
10
|
+
//! action are suppressed — replaying the action re-derives them, so the
|
|
11
|
+
//! outer record is the whole representation (see `stageEvent`).
|
|
9
12
|
//!
|
|
10
13
|
//! Recording must never take the app down: any failure — a sink write
|
|
11
14
|
//! error, an over-budget event, a journal past its size budget — flips
|
|
@@ -46,7 +49,14 @@ pub const SessionRecorder = struct {
|
|
|
46
49
|
/// checkpoint follows each published frame.
|
|
47
50
|
last_checkpoint_frame: u64 = 0,
|
|
48
51
|
depth: usize = 0,
|
|
52
|
+
/// Staging-stack depth of the `widget_accessibility_action` event
|
|
53
|
+
/// currently being dispatched, if any. While set, nested
|
|
54
|
+
/// stage/commit pairs are suppressed: the outer action record is the
|
|
55
|
+
/// journal's WHOLE representation of the interaction (see
|
|
56
|
+
/// `stageEvent`).
|
|
57
|
+
suppress_owner_depth: ?usize = null,
|
|
49
58
|
staged_lens: [journal.max_session_event_depth]usize = [_]usize{0} ** journal.max_session_event_depth,
|
|
59
|
+
staged_suppressed: [journal.max_session_event_depth]bool = [_]bool{false} ** journal.max_session_event_depth,
|
|
50
60
|
staged: [journal.max_session_event_depth][journal.max_session_event_bytes]u8 = undefined,
|
|
51
61
|
/// Encode scratch for effect payloads (up to a whole file read).
|
|
52
62
|
effect_buffer: [journal.max_session_record_bytes]u8 = undefined,
|
|
@@ -72,15 +82,55 @@ pub const SessionRecorder = struct {
|
|
|
72
82
|
/// Serialize `event` into the staging stack. Effect results drained
|
|
73
83
|
/// during its dispatch write directly to the stream; `commitEvent`
|
|
74
84
|
/// then appends the event record after them.
|
|
85
|
+
///
|
|
86
|
+
/// Accessibility actions journal OUTER-WINS: a dispatched
|
|
87
|
+
/// `widget_accessibility_action` synthesizes real platform events
|
|
88
|
+
/// (a press dispatches its Enter key, set_text a select-all plus a
|
|
89
|
+
/// text input, composition its ime inputs) through the same choke
|
|
90
|
+
/// point, so recording both the action and its children would make
|
|
91
|
+
/// replay dispatch the children twice — once from their own records,
|
|
92
|
+
/// then again when replaying the action re-runs the verb. The outer
|
|
93
|
+
/// record wins because the children are deterministic derivations of
|
|
94
|
+
/// the action against runtime state replay has already rebuilt, and
|
|
95
|
+
/// because it keeps the ASSISTIVE semantics visible in the journal
|
|
96
|
+
/// ("press on widget 12", not an anonymous key event). While the
|
|
97
|
+
/// action sits on the staging stack, nested stage/commit pairs are
|
|
98
|
+
/// therefore suppressed — staged as placeholders so commit pairing
|
|
99
|
+
/// stays balanced, never written, never counted (`event_count` must
|
|
100
|
+
/// keep matching the records a replay reader will actually see;
|
|
101
|
+
/// checkpoints fire only at depth 0, so no ordinal can land inside
|
|
102
|
+
/// the suppressed window). Effect results are NOT suppressed: they
|
|
103
|
+
/// write directly to the stream and still precede the action record,
|
|
104
|
+
/// exactly the feed-then-dispatch order replay depends on. BOTH
|
|
105
|
+
/// entry surfaces stage the action record: the platform AX event
|
|
106
|
+
/// path stages it at the dispatch choke point, and the direct verb
|
|
107
|
+
/// surfaces (an embed host's `widgetAction`, automation
|
|
108
|
+
/// `widget_action` commands) stage a synthetic one inside
|
|
109
|
+
/// `dispatchCanvasWidgetAccessibilityAction` — without it, their
|
|
110
|
+
/// journaled children were untargeted inputs routed by focus while
|
|
111
|
+
/// the verb's focus write stayed unjournaled, so a fresh replay
|
|
112
|
+
/// delivered them against the wrong editor. A second accessibility
|
|
113
|
+
/// action staged while one is already on the stack (the direct
|
|
114
|
+
/// dispatch reached through a staged platform AX event) is just a
|
|
115
|
+
/// suppressed placeholder: the outermost action owns the window and
|
|
116
|
+
/// the journal keeps exactly one record.
|
|
75
117
|
pub fn stageEvent(self: *SessionRecorder, event: platform.Event) void {
|
|
76
118
|
if (!self.began or self.failed or self.finished) return;
|
|
77
119
|
if (self.depth >= journal.max_session_event_depth) {
|
|
78
120
|
return self.fail("dispatch nesting exceeded max_session_event_depth - this is a runtime bug, not a session shape");
|
|
79
121
|
}
|
|
122
|
+
if (self.suppress_owner_depth != null) {
|
|
123
|
+
self.staged_suppressed[self.depth] = true;
|
|
124
|
+
self.staged_lens[self.depth] = 0;
|
|
125
|
+
self.depth += 1;
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
80
128
|
const encoded = journal.encodeEvent(event, &self.staged[self.depth]) catch {
|
|
81
129
|
return self.fail("a platform event exceeded max_session_event_bytes");
|
|
82
130
|
};
|
|
83
131
|
self.staged_lens[self.depth] = encoded.len;
|
|
132
|
+
self.staged_suppressed[self.depth] = false;
|
|
133
|
+
if (event == .widget_accessibility_action) self.suppress_owner_depth = self.depth;
|
|
84
134
|
self.depth += 1;
|
|
85
135
|
}
|
|
86
136
|
|
|
@@ -90,6 +140,10 @@ pub const SessionRecorder = struct {
|
|
|
90
140
|
if (!self.began or self.failed or self.finished) return;
|
|
91
141
|
if (self.depth == 0) return;
|
|
92
142
|
self.depth -= 1;
|
|
143
|
+
if (self.staged_suppressed[self.depth]) return;
|
|
144
|
+
if (self.suppress_owner_depth) |owner_depth| {
|
|
145
|
+
if (owner_depth == self.depth) self.suppress_owner_depth = null;
|
|
146
|
+
}
|
|
93
147
|
self.writeRecord(.event, self.staged[self.depth][0..self.staged_lens[self.depth]]);
|
|
94
148
|
if (!self.failed) self.event_count += 1;
|
|
95
149
|
}
|
|
@@ -294,6 +348,118 @@ test "recorder commits nested events innermost-first" {
|
|
|
294
348
|
try testing.expect(outer.event == .frame_requested);
|
|
295
349
|
}
|
|
296
350
|
|
|
351
|
+
test "accessibility actions suppress their synthesized children in the journal" {
|
|
352
|
+
var buffer_sink = BufferSink{};
|
|
353
|
+
const recorder = try testing.allocator.create(SessionRecorder);
|
|
354
|
+
defer testing.allocator.destroy(recorder);
|
|
355
|
+
recorder.* = SessionRecorder.init(buffer_sink.sink());
|
|
356
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "demo" });
|
|
357
|
+
|
|
358
|
+
// An AX press dispatches its synthesized Enter key through the same
|
|
359
|
+
// choke point: the nested event must not land — replaying the action
|
|
360
|
+
// re-derives it — but an effect result drained during the dispatch
|
|
361
|
+
// still writes through, ahead of the action record.
|
|
362
|
+
recorder.stageEvent(.{ .widget_accessibility_action = .{
|
|
363
|
+
.window_id = 1,
|
|
364
|
+
.label = "canvas",
|
|
365
|
+
.id = 7,
|
|
366
|
+
.action = .press,
|
|
367
|
+
} });
|
|
368
|
+
recorder.stageEvent(.{ .gpu_surface_input = .{
|
|
369
|
+
.window_id = 1,
|
|
370
|
+
.label = "canvas",
|
|
371
|
+
.kind = .key_down,
|
|
372
|
+
.key = "enter",
|
|
373
|
+
} });
|
|
374
|
+
recorder.recordEffect(.{ .kind = .line, .key = 3, .payload = "drained" });
|
|
375
|
+
recorder.commitEvent();
|
|
376
|
+
recorder.commitEvent();
|
|
377
|
+
// Suppression ends with the action: a later top-level input records.
|
|
378
|
+
recorder.stageEvent(.{ .gpu_surface_input = .{
|
|
379
|
+
.window_id = 1,
|
|
380
|
+
.label = "canvas",
|
|
381
|
+
.kind = .key_down,
|
|
382
|
+
.key = "tab",
|
|
383
|
+
} });
|
|
384
|
+
recorder.commitEvent();
|
|
385
|
+
recorder.recordCheckpoint(1, 0xbeef);
|
|
386
|
+
recorder.finish();
|
|
387
|
+
try testing.expect(!recorder.failed);
|
|
388
|
+
|
|
389
|
+
var reader = try journal.Reader.init(buffer_sink.bytes());
|
|
390
|
+
_ = (try reader.next()).?; // header
|
|
391
|
+
const effect = (try reader.next()).?;
|
|
392
|
+
try testing.expectEqualStrings("drained", effect.effect.payload);
|
|
393
|
+
const action = (try reader.next()).?;
|
|
394
|
+
try testing.expectEqual(platform.WidgetAccessibilityActionKind.press, action.event.widget_accessibility_action.action);
|
|
395
|
+
const key = (try reader.next()).?;
|
|
396
|
+
try testing.expectEqualStrings("tab", key.event.gpu_surface_input.key);
|
|
397
|
+
// The checkpoint ordinal and end counts see only the two surviving
|
|
398
|
+
// events — coherent with what a replay reader will process.
|
|
399
|
+
const checkpoint = (try reader.next()).?;
|
|
400
|
+
try testing.expectEqual(@as(u64, 2), checkpoint.checkpoint.event_ordinal);
|
|
401
|
+
const end = (try reader.next()).?;
|
|
402
|
+
try testing.expectEqual(@as(u64, 2), end.end.event_count);
|
|
403
|
+
try testing.expectEqual(@as(u64, 1), end.end.effect_count);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
test "a nested accessibility action stays a suppressed placeholder" {
|
|
407
|
+
var buffer_sink = BufferSink{};
|
|
408
|
+
const recorder = try testing.allocator.create(SessionRecorder);
|
|
409
|
+
defer testing.allocator.destroy(recorder);
|
|
410
|
+
recorder.* = SessionRecorder.init(buffer_sink.sink());
|
|
411
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "demo" });
|
|
412
|
+
|
|
413
|
+
// The platform AX event path stages tag 23 at the dispatch choke
|
|
414
|
+
// point, then `dispatchCanvasWidgetAccessibilityAction` stages its
|
|
415
|
+
// synthetic copy of the same action: the inner stage must ride the
|
|
416
|
+
// suppression window as a placeholder (one journal record, the
|
|
417
|
+
// outer one), and suppression must survive the inner commit so the
|
|
418
|
+
// verb's children staged AFTER it stay suppressed too.
|
|
419
|
+
recorder.stageEvent(.{ .widget_accessibility_action = .{
|
|
420
|
+
.window_id = 1,
|
|
421
|
+
.label = "canvas",
|
|
422
|
+
.id = 7,
|
|
423
|
+
.action = .set_text,
|
|
424
|
+
.text = "outer",
|
|
425
|
+
} });
|
|
426
|
+
recorder.stageEvent(.{ .widget_accessibility_action = .{
|
|
427
|
+
.window_id = 1,
|
|
428
|
+
.label = "canvas",
|
|
429
|
+
.id = 7,
|
|
430
|
+
.action = .set_text,
|
|
431
|
+
.text = "synthetic",
|
|
432
|
+
} });
|
|
433
|
+
recorder.stageEvent(.{ .gpu_surface_input = .{
|
|
434
|
+
.window_id = 1,
|
|
435
|
+
.label = "canvas",
|
|
436
|
+
.kind = .text_input,
|
|
437
|
+
.text = "outer",
|
|
438
|
+
} });
|
|
439
|
+
recorder.commitEvent();
|
|
440
|
+
recorder.commitEvent();
|
|
441
|
+
recorder.commitEvent();
|
|
442
|
+
// The window closed with the outer action: a later input records.
|
|
443
|
+
recorder.stageEvent(.{ .gpu_surface_input = .{
|
|
444
|
+
.window_id = 1,
|
|
445
|
+
.label = "canvas",
|
|
446
|
+
.kind = .key_down,
|
|
447
|
+
.key = "tab",
|
|
448
|
+
} });
|
|
449
|
+
recorder.commitEvent();
|
|
450
|
+
recorder.finish();
|
|
451
|
+
try testing.expect(!recorder.failed);
|
|
452
|
+
|
|
453
|
+
var reader = try journal.Reader.init(buffer_sink.bytes());
|
|
454
|
+
_ = (try reader.next()).?; // header
|
|
455
|
+
const action = (try reader.next()).?;
|
|
456
|
+
try testing.expectEqualStrings("outer", action.event.widget_accessibility_action.text);
|
|
457
|
+
const key = (try reader.next()).?;
|
|
458
|
+
try testing.expectEqualStrings("tab", key.event.gpu_surface_input.key);
|
|
459
|
+
const end = (try reader.next()).?;
|
|
460
|
+
try testing.expectEqual(@as(u64, 2), end.end.event_count);
|
|
461
|
+
}
|
|
462
|
+
|
|
297
463
|
test "recorder fails loudly once and seals nothing after a sink error" {
|
|
298
464
|
var buffer_sink = BufferSink{ .fail_after = 32 };
|
|
299
465
|
const recorder = try testing.allocator.create(SessionRecorder);
|