@native-sdk/cli 0.5.1 → 0.5.3
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.zig +41 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/events.ts +39 -2
- package/packages/core/src/checker.ts +1 -1
- package/packages/core/src/emitter.ts +39 -3
- package/packages/core/src/infer.ts +53 -7
- package/skill-data/automation/SKILL.md +7 -4
- package/skill-data/core/references/app-model-runtime.md +3 -0
- package/skill-data/native-ui/SKILL.md +3 -2
- package/src/app_runner/root.zig +25 -0
- package/src/automation/protocol.zig +20 -1
- package/src/embed/host.zig +27 -0
- package/src/embed/tests.zig +69 -0
- package/src/embed/ui_host.zig +4 -0
- package/src/platform/macos/appkit_host.h +11 -0
- package/src/platform/macos/appkit_host.m +130 -0
- package/src/platform/macos/root.zig +34 -0
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +3 -0
- package/src/platform/types.zig +118 -4
- package/src/primitives/canvas/chart.zig +7 -7
- package/src/primitives/canvas/chart_tests.zig +66 -0
- package/src/primitives/canvas/commands.zig +48 -0
- package/src/primitives/canvas/events.zig +161 -0
- package/src/primitives/canvas/font_ttf.zig +155 -8
- package/src/primitives/canvas/font_ttf_tests.zig +686 -0
- package/src/primitives/canvas/reference.zig +67 -8
- package/src/primitives/canvas/render_fingerprints.zig +8 -0
- package/src/primitives/canvas/root.zig +26 -0
- package/src/primitives/canvas/tokens.zig +170 -7
- package/src/primitives/canvas/ui.zig +62 -7
- package/src/primitives/canvas/ui_markup.zig +51 -4
- package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +49 -4
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +160 -0
- package/src/primitives/canvas/ui_markup_contract.zig +9 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +24 -0
- package/src/primitives/canvas/ui_markup_tests.zig +73 -0
- package/src/primitives/canvas/ui_markup_view.zig +63 -5
- package/src/primitives/canvas/ui_markup_view_tests.zig +151 -2
- package/src/primitives/canvas/ui_schema.zig +31 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -11
- package/src/primitives/canvas/ui_tests.zig +31 -0
- package/src/primitives/canvas/vector.zig +258 -141
- package/src/primitives/canvas/widget_access.zig +1 -1
- package/src/primitives/canvas/widget_builtin_tests.zig +259 -0
- package/src/primitives/canvas/widget_layout.zig +13 -5
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_render.zig +78 -40
- package/src/primitives/canvas/widget_render_controls.zig +15 -4
- package/src/primitives/canvas/widget_semantics.zig +6 -1
- package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
- package/src/primitives/canvas/widget_text_input.zig +118 -10
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +28 -0
- package/src/root.zig +5 -0
- package/src/runtime/api.zig +13 -0
- package/src/runtime/automation_commands.zig +33 -0
- package/src/runtime/automation_widget_dispatch.zig +159 -28
- package/src/runtime/canvas_font_tests.zig +272 -3
- package/src/runtime/canvas_fonts.zig +60 -20
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_frame_helpers.zig +15 -0
- package/src/runtime/canvas_image_tests.zig +26 -0
- package/src/runtime/canvas_images.zig +33 -7
- package/src/runtime/canvas_limits.zig +44 -8
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
- package/src/runtime/canvas_widget_events.zig +1295 -7
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_runtime.zig +24 -7
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +88 -6
- package/src/runtime/canvas_widget_text_tests.zig +277 -0
- package/src/runtime/core.zig +112 -6
- package/src/runtime/flow.zig +51 -1
- package/src/runtime/gpu_surface_events.zig +51 -5
- package/src/runtime/media_surface.zig +726 -0
- package/src/runtime/media_surface_tests.zig +1476 -0
- package/src/runtime/root.zig +9 -0
- package/src/runtime/session_journal.zig +52 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +575 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_ui_app.zig +56 -0
- package/src/runtime/ui_app.zig +64 -1
- package/src/runtime/ui_app_tests.zig +794 -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/runtime/root.zig
CHANGED
|
@@ -154,6 +154,15 @@ pub const RegisteredCanvasImage = runtime_canvas_images.RegisteredCanvasImage;
|
|
|
154
154
|
pub const max_registered_canvas_images = runtime_canvas_images.max_registered_canvas_images;
|
|
155
155
|
pub const max_registered_canvas_image_pixel_bytes = runtime_canvas_images.max_registered_canvas_image_pixel_bytes;
|
|
156
156
|
|
|
157
|
+
// The media-surface producer channel (media_surface.zig): the handle
|
|
158
|
+
// type `Runtime.acquireMediaSurfaceProducer` returns rides the public
|
|
159
|
+
// root so producer callbacks can be TYPED (the docs' mpv recipe takes a
|
|
160
|
+
// `MediaSurfaceProducer` parameter), alongside the channel budgets.
|
|
161
|
+
const runtime_media_surface = @import("media_surface.zig");
|
|
162
|
+
pub const MediaSurfaceProducer = runtime_media_surface.MediaSurfaceProducer;
|
|
163
|
+
pub const max_media_surface_channels = runtime_media_surface.max_media_surface_channels;
|
|
164
|
+
pub const max_media_surface_pixel_bytes = runtime_media_surface.max_media_surface_pixel_bytes;
|
|
165
|
+
|
|
157
166
|
const runtime_canvas_fonts = @import("canvas_fonts.zig");
|
|
158
167
|
pub const max_registered_canvas_fonts = runtime_canvas_fonts.max_registered_canvas_fonts;
|
|
159
168
|
pub const max_registered_canvas_font_bytes = runtime_canvas_fonts.max_registered_canvas_font_bytes;
|
|
@@ -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/pinch, 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,15 @@ 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; v5
|
|
79
|
+
/// added the pinch magnification `scale` field to gpu-surface input
|
|
80
|
+
/// records (a layout change every v4 reader would misparse) plus the
|
|
81
|
+
/// `pinch_begin`/`pinch_change`/`pinch_end` input kinds (codes 12-14).
|
|
82
|
+
pub const format_version: u32 = 5;
|
|
75
83
|
|
|
76
84
|
// ------------------------------------------------------------- budgets
|
|
77
85
|
//
|
|
@@ -525,6 +533,8 @@ pub fn encodeEvent(event: platform.Event, buffer: []u8) JournalError![]const u8
|
|
|
525
533
|
try cursor.writeInt(u64, @intCast(composition_cursor));
|
|
526
534
|
}
|
|
527
535
|
try writeModifiers(&cursor, input.modifiers);
|
|
536
|
+
// v5: the pinch magnification delta (0 on non-pinch kinds).
|
|
537
|
+
try cursor.writeF32(input.scale);
|
|
528
538
|
},
|
|
529
539
|
.gpu_surface_scroll_driver => |driver| {
|
|
530
540
|
try cursor.writeEnum(EventTag.gpu_surface_scroll_driver);
|
|
@@ -751,6 +761,8 @@ pub fn decodeEvent(bytes: []const u8, storage: *EventDecodeStorage) JournalError
|
|
|
751
761
|
.text = text,
|
|
752
762
|
.composition_cursor = composition_cursor,
|
|
753
763
|
.modifiers = try readModifiers(&cursor),
|
|
764
|
+
// v5: the pinch magnification delta (0 on non-pinch kinds).
|
|
765
|
+
.scale = try cursor.readF32(),
|
|
754
766
|
} };
|
|
755
767
|
},
|
|
756
768
|
.gpu_surface_scroll_driver => blk: {
|
|
@@ -1067,7 +1079,7 @@ pub const Reader = struct {
|
|
|
1067
1079
|
pub fn describeError(err: JournalError) []const u8 {
|
|
1068
1080
|
return switch (err) {
|
|
1069
1081
|
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",
|
|
1082
|
+
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
1083
|
error.JournalTruncated => "journal ends mid-record (the recording was cut off) - re-record, and keep the app running until it exits cleanly",
|
|
1072
1084
|
error.JournalCorrupt => "journal payload does not decode (damaged or hand-edited bytes)",
|
|
1073
1085
|
error.JournalRecordOverBudget => "journal claims a record beyond max_session_record_bytes - the file is damaged or hostile",
|
|
@@ -1225,6 +1237,26 @@ test "event codec round-trips every payload variant" {
|
|
|
1225
1237
|
try testing.expectEqualStrings("7", decoded.gpu_surface_input.text);
|
|
1226
1238
|
try testing.expectEqual(@as(?usize, 3), decoded.gpu_surface_input.composition_cursor);
|
|
1227
1239
|
try testing.expect(decoded.gpu_surface_input.modifiers.control);
|
|
1240
|
+
try testing.expectEqual(@as(f32, 0), decoded.gpu_surface_input.scale);
|
|
1241
|
+
}
|
|
1242
|
+
{
|
|
1243
|
+
// v5: pinch records carry the magnification delta and the
|
|
1244
|
+
// gesture kinds appended at codes 12-14.
|
|
1245
|
+
const decoded = try roundTripEvent(.{ .gpu_surface_input = .{
|
|
1246
|
+
.label = "timeline-canvas",
|
|
1247
|
+
.kind = .pinch_change,
|
|
1248
|
+
.timestamp_ns = 6,
|
|
1249
|
+
.x = 160,
|
|
1250
|
+
.y = 120,
|
|
1251
|
+
.scale = 0.25,
|
|
1252
|
+
} });
|
|
1253
|
+
try testing.expectEqual(platform.GpuSurfaceInputKind.pinch_change, decoded.gpu_surface_input.kind);
|
|
1254
|
+
try testing.expectEqual(@as(f32, 0.25), decoded.gpu_surface_input.scale);
|
|
1255
|
+
try testing.expectEqual(@as(f32, 160), decoded.gpu_surface_input.x);
|
|
1256
|
+
const begin = try roundTripEvent(.{ .gpu_surface_input = .{ .label = "timeline-canvas", .kind = .pinch_begin } });
|
|
1257
|
+
try testing.expectEqual(platform.GpuSurfaceInputKind.pinch_begin, begin.gpu_surface_input.kind);
|
|
1258
|
+
const end = try roundTripEvent(.{ .gpu_surface_input = .{ .label = "timeline-canvas", .kind = .pinch_end } });
|
|
1259
|
+
try testing.expectEqual(platform.GpuSurfaceInputKind.pinch_end, end.gpu_surface_input.kind);
|
|
1228
1260
|
}
|
|
1229
1261
|
{
|
|
1230
1262
|
const decoded = try roundTripEvent(.{ .widget_accessibility_action = .{
|
|
@@ -1435,6 +1467,13 @@ test "reader refuses bad magic and version skew" {
|
|
|
1435
1467
|
@memcpy(skewed[0..len], buffer[0..len]);
|
|
1436
1468
|
std.mem.writeInt(u32, skewed[magic.len..][0..4], format_version + 1, .little);
|
|
1437
1469
|
try testing.expectError(error.JournalUnsupportedVersion, Reader.init(skewed[0..len]));
|
|
1470
|
+
// Older journals are refused the same way — and, symmetrically, a
|
|
1471
|
+
// reader built before a version bump refuses a NEWER journal at the
|
|
1472
|
+
// preamble instead of reporting an unknown payload code as
|
|
1473
|
+
// corruption (the v4 bump's reason: v3 readers would have called a
|
|
1474
|
+
// journaled composition verb code corrupt).
|
|
1475
|
+
std.mem.writeInt(u32, skewed[magic.len..][0..4], format_version - 1, .little);
|
|
1476
|
+
try testing.expectError(error.JournalUnsupportedVersion, Reader.init(skewed[0..len]));
|
|
1438
1477
|
}
|
|
1439
1478
|
|
|
1440
1479
|
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);
|