@native-sdk/cli 0.5.2 → 0.5.4

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 (123) hide show
  1. package/build/app.zig +41 -1
  2. package/build.zig +264 -3
  3. package/native-sdk.d.ts +17 -1
  4. package/package.json +9 -9
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/packages/core/rt/rt.zig +138 -3
  8. package/packages/core/sdk/core.ts +225 -3
  9. package/packages/core/sdk/events.ts +39 -2
  10. package/packages/core/src/checker.ts +1 -1
  11. package/packages/core/src/emitter.ts +2625 -262
  12. package/packages/core/src/infer.ts +53 -7
  13. package/skill-data/automation/SKILL.md +7 -4
  14. package/skill-data/core/references/app-model-runtime.md +3 -0
  15. package/skill-data/native-ui/SKILL.md +4 -2
  16. package/skill-data/ts-core/SKILL.md +9 -1
  17. package/src/app_runner/root.zig +106 -1
  18. package/src/app_runner/ts_core_main.zig +4 -0
  19. package/src/automation/protocol.zig +20 -1
  20. package/src/embed/host.zig +27 -0
  21. package/src/embed/tests.zig +187 -0
  22. package/src/embed/ui_host.zig +4 -0
  23. package/src/platform/linux/gtk_host.c +112 -3
  24. package/src/platform/linux/root.zig +71 -0
  25. package/src/platform/macos/appkit_host.h +59 -2
  26. package/src/platform/macos/appkit_host.m +663 -34
  27. package/src/platform/macos/cef_host.mm +262 -10
  28. package/src/platform/macos/root.zig +126 -4
  29. package/src/platform/null_platform.zig +298 -5
  30. package/src/platform/null_platform_tests.zig +39 -0
  31. package/src/platform/root.zig +36 -0
  32. package/src/platform/types.zig +247 -8
  33. package/src/platform/windows/root.zig +134 -0
  34. package/src/platform/windows/webview2_host.cpp +152 -40
  35. package/src/primitives/app_manifest/comptime_scene.zig +5 -0
  36. package/src/primitives/app_manifest/root.zig +1 -0
  37. package/src/primitives/app_manifest/types.zig +32 -0
  38. package/src/primitives/canvas/chart.zig +7 -7
  39. package/src/primitives/canvas/chart_tests.zig +66 -0
  40. package/src/primitives/canvas/commands.zig +48 -0
  41. package/src/primitives/canvas/events.zig +161 -0
  42. package/src/primitives/canvas/font_ttf.zig +155 -8
  43. package/src/primitives/canvas/font_ttf_tests.zig +686 -0
  44. package/src/primitives/canvas/reference.zig +67 -8
  45. package/src/primitives/canvas/render_fingerprints.zig +8 -0
  46. package/src/primitives/canvas/root.zig +25 -0
  47. package/src/primitives/canvas/tests.zig +1 -0
  48. package/src/primitives/canvas/ui.zig +46 -9
  49. package/src/primitives/canvas/ui_markup.zig +82 -34
  50. package/src/primitives/canvas/ui_markup_binary.zig +4 -1
  51. package/src/primitives/canvas/ui_markup_binary_tests.zig +25 -0
  52. package/src/primitives/canvas/ui_markup_compiled.zig +63 -11
  53. package/src/primitives/canvas/ui_markup_compiled_tests.zig +88 -0
  54. package/src/primitives/canvas/ui_markup_contract.zig +10 -1
  55. package/src/primitives/canvas/ui_markup_contract_tests.zig +50 -0
  56. package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
  57. package/src/primitives/canvas/ui_markup_tests.zig +55 -9
  58. package/src/primitives/canvas/ui_markup_view.zig +81 -14
  59. package/src/primitives/canvas/ui_markup_view_tests.zig +219 -7
  60. package/src/primitives/canvas/ui_schema.zig +29 -0
  61. package/src/primitives/canvas/ui_schema_tests.zig +11 -11
  62. package/src/primitives/canvas/ui_tests.zig +31 -0
  63. package/src/primitives/canvas/vector.zig +258 -141
  64. package/src/primitives/canvas/widget_access.zig +1 -1
  65. package/src/primitives/canvas/widget_builtin_tests.zig +129 -0
  66. package/src/primitives/canvas/widget_layout.zig +9 -4
  67. package/src/primitives/canvas/widget_render.zig +78 -40
  68. package/src/primitives/canvas/widget_render_controls.zig +15 -4
  69. package/src/primitives/canvas/widget_semantics.zig +6 -1
  70. package/src/primitives/canvas/widget_semantics_tests.zig +168 -0
  71. package/src/primitives/canvas/widget_text_input.zig +118 -10
  72. package/src/primitives/canvas/widgets.zig +16 -0
  73. package/src/root.zig +12 -0
  74. package/src/runtime/api.zig +15 -0
  75. package/src/runtime/automation_commands.zig +33 -0
  76. package/src/runtime/automation_widget_dispatch.zig +64 -0
  77. package/src/runtime/bridge_payload.zig +7 -0
  78. package/src/runtime/bridge_responses.zig +5 -0
  79. package/src/runtime/builtin_bridge.zig +9 -4
  80. package/src/runtime/canvas_font_tests.zig +711 -5
  81. package/src/runtime/canvas_fonts.zig +120 -25
  82. package/src/runtime/canvas_frame_helpers.zig +15 -0
  83. package/src/runtime/canvas_image_tests.zig +221 -0
  84. package/src/runtime/canvas_images.zig +78 -19
  85. package/src/runtime/canvas_limits.zig +44 -8
  86. package/src/runtime/canvas_widget_clipboard_tests.zig +123 -0
  87. package/src/runtime/canvas_widget_context_menu_tests.zig +55 -0
  88. package/src/runtime/canvas_widget_events.zig +24 -4
  89. package/src/runtime/canvas_widget_runtime.zig +24 -7
  90. package/src/runtime/canvas_widget_state.zig +6 -1
  91. package/src/runtime/canvas_widget_text_tests.zig +277 -0
  92. package/src/runtime/core.zig +148 -9
  93. package/src/runtime/effects.zig +1664 -43
  94. package/src/runtime/effects_fetch_tests.zig +89 -1
  95. package/src/runtime/effects_file_tests.zig +41 -1
  96. package/src/runtime/effects_image_tests.zig +1304 -0
  97. package/src/runtime/effects_tests.zig +153 -0
  98. package/src/runtime/flow.zig +44 -0
  99. package/src/runtime/gpu_surface_events.zig +7 -0
  100. package/src/runtime/media_surface.zig +726 -0
  101. package/src/runtime/media_surface_tests.zig +1476 -0
  102. package/src/runtime/root.zig +20 -0
  103. package/src/runtime/session_blobs.zig +689 -0
  104. package/src/runtime/session_journal.zig +111 -20
  105. package/src/runtime/session_record.zig +27 -2
  106. package/src/runtime/session_replay.zig +168 -16
  107. package/src/runtime/session_tests.zig +2118 -4
  108. package/src/runtime/shell_layout.zig +7 -0
  109. package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
  110. package/src/runtime/testdata/fonts/OFL.txt +93 -0
  111. package/src/runtime/tests.zig +3 -0
  112. package/src/runtime/ts_core_host.zig +439 -4
  113. package/src/runtime/ts_core_host_tests.zig +41 -0
  114. package/src/runtime/ts_ui_app.zig +63 -0
  115. package/src/runtime/ui_app.zig +169 -6
  116. package/src/runtime/ui_app_tests.zig +334 -0
  117. package/src/runtime/ui_app_window_tests.zig +468 -0
  118. package/src/runtime/window_command_bridge_tests.zig +117 -0
  119. package/src/runtime/window_storage.zig +32 -0
  120. package/src/runtime/window_views.zig +61 -1
  121. package/src/tooling/manifest.zig +75 -0
  122. package/src/tooling/raw_manifest.zig +2 -0
  123. package/src/tooling/templates.zig +219 -1
@@ -4042,3 +4042,337 @@ test "windowed virtual list scrolls, re-windows, budgets to the viewport, and fi
4042
4042
  try std.testing.expectEqual(@as(usize, 600), first_index + mounted);
4043
4043
  try std.testing.expect(mounted >= 25);
4044
4044
  }
4045
+
4046
+ // ------------------------------------------------------- pinch channel
4047
+
4048
+ const ZoomModel = struct {
4049
+ /// Cumulative gesture scale: the running product of `1 + delta`
4050
+ /// across change events — the semantics the channel documents.
4051
+ scale: f32 = 1,
4052
+ begins: u32 = 0,
4053
+ ends: u32 = 0,
4054
+ anchor_x: f32 = 0,
4055
+ anchor_y: f32 = 0,
4056
+ /// Source-identity mirrors: the window and view the last pinch
4057
+ /// event named (x/y are view-local, so a coordinate without its
4058
+ /// view is not a position — multi-window apps tell pinches apart
4059
+ /// by these).
4060
+ window_id: u64 = 0,
4061
+ label: []const u8 = "",
4062
+ };
4063
+
4064
+ const ZoomMsg = union(enum) {
4065
+ pinch: zero_platform.PinchEvent,
4066
+ };
4067
+
4068
+ const ZoomApp = ui_app_model.UiApp(ZoomModel, ZoomMsg);
4069
+
4070
+ fn zoomUpdate(model: *ZoomModel, msg: ZoomMsg) void {
4071
+ switch (msg) {
4072
+ .pinch => |pinch| {
4073
+ model.window_id = pinch.window_id;
4074
+ model.label = pinch.label;
4075
+ switch (pinch.phase) {
4076
+ .begin => {
4077
+ model.begins += 1;
4078
+ model.anchor_x = pinch.x;
4079
+ model.anchor_y = pinch.y;
4080
+ },
4081
+ .change => model.scale *= (1 + pinch.scale),
4082
+ .end => model.ends += 1,
4083
+ }
4084
+ },
4085
+ }
4086
+ }
4087
+
4088
+ fn zoomView(ui: *ZoomApp.Ui, model: *const ZoomModel) ZoomApp.Ui.Node {
4089
+ return ui.column(.{ .gap = 8, .padding = 12 }, .{
4090
+ ui.text(.{}, ui.fmt("Zoom {d:.2}", .{model.scale})),
4091
+ });
4092
+ }
4093
+
4094
+ fn zoomPinch(pinch: zero_platform.PinchEvent) ?ZoomMsg {
4095
+ return .{ .pinch = pinch };
4096
+ }
4097
+
4098
+ test "trackpad pinch reaches the app through on_pinch with product-of-deltas scale" {
4099
+ const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
4100
+ defer harness.destroy(std.testing.allocator);
4101
+ harness.null_platform.gpu_surfaces = true;
4102
+
4103
+ const app_state = try std.testing.allocator.create(ZoomApp);
4104
+ defer std.testing.allocator.destroy(app_state);
4105
+ app_state.* = ZoomApp.init(std.heap.page_allocator, .{}, .{
4106
+ .name = "ui-app-zoom",
4107
+ .scene = counter_scene,
4108
+ .canvas_label = canvas_label,
4109
+ .update = zoomUpdate,
4110
+ .view = zoomView,
4111
+ .on_pinch = zoomPinch,
4112
+ });
4113
+ defer app_state.deinit();
4114
+ const app = app_state.app();
4115
+ try harness.start(app);
4116
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
4117
+ .label = canvas_label,
4118
+ .size = geometry.SizeF.init(400, 300),
4119
+ .scale_factor = 2,
4120
+ .frame_index = 1,
4121
+ .timestamp_ns = 1_000_000,
4122
+ .nonblank = true,
4123
+ } });
4124
+ try std.testing.expect(app_state.installed);
4125
+
4126
+ // begin -> change -> change -> change -> end, the host's phase
4127
+ // stream: the model hears every phase, the pointer anchor rides
4128
+ // x/y, and the cumulative scale is the PRODUCT of (1 + delta) —
4129
+ // two +25% steps land on 1.5625, never the 1.45 a sum-of-deltas
4130
+ // would produce (deltas are raw NSEvent.magnification, the
4131
+ // multiplicative per-event delta per the engine convention; see
4132
+ // the doctrine note in appkit_host.m).
4133
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4134
+ .window_id = 1,
4135
+ .label = canvas_label,
4136
+ .kind = .pinch_begin,
4137
+ .x = 120,
4138
+ .y = 80,
4139
+ } });
4140
+ try std.testing.expectEqual(@as(u32, 1), app_state.model.begins);
4141
+ try std.testing.expectEqual(@as(f32, 120), app_state.model.anchor_x);
4142
+ try std.testing.expectEqual(@as(f32, 80), app_state.model.anchor_y);
4143
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4144
+ .window_id = 1,
4145
+ .label = canvas_label,
4146
+ .kind = .pinch_change,
4147
+ .x = 120,
4148
+ .y = 80,
4149
+ .scale = 0.25,
4150
+ } });
4151
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4152
+ .window_id = 1,
4153
+ .label = canvas_label,
4154
+ .kind = .pinch_change,
4155
+ .x = 120,
4156
+ .y = 80,
4157
+ .scale = 0.25,
4158
+ } });
4159
+ try std.testing.expectEqual(@as(f32, 1.5625), app_state.model.scale);
4160
+ try std.testing.expectEqual(@as(u32, 0), app_state.model.ends);
4161
+ // A terminal-delta Ended: AppKit's Ended/Cancelled event still
4162
+ // carries the magnification since the previous event, so the host
4163
+ // forwards it as one last change BEFORE the end marker — the
4164
+ // product folds it in (1.5625 * 1.25 = 1.953125, binary-exact).
4165
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4166
+ .window_id = 1,
4167
+ .label = canvas_label,
4168
+ .kind = .pinch_change,
4169
+ .x = 120,
4170
+ .y = 80,
4171
+ .scale = 0.25,
4172
+ } });
4173
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4174
+ .window_id = 1,
4175
+ .label = canvas_label,
4176
+ .kind = .pinch_end,
4177
+ .x = 120,
4178
+ .y = 80,
4179
+ } });
4180
+ try std.testing.expectEqual(@as(u32, 1), app_state.model.ends);
4181
+ try std.testing.expectEqual(@as(f32, 1.953125), app_state.model.scale);
4182
+ // The dispatched Msgs rebuilt the view from the model.
4183
+ try std.testing.expect(try retainedTextExists(&harness.runtime, "Zoom 1.95"));
4184
+
4185
+ // A zero-delta Ended is just the end marker: begin then end moves
4186
+ // no scale.
4187
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4188
+ .window_id = 1,
4189
+ .label = canvas_label,
4190
+ .kind = .pinch_begin,
4191
+ .x = 120,
4192
+ .y = 80,
4193
+ } });
4194
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4195
+ .window_id = 1,
4196
+ .label = canvas_label,
4197
+ .kind = .pinch_end,
4198
+ .x = 120,
4199
+ .y = 80,
4200
+ } });
4201
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.begins);
4202
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.ends);
4203
+ try std.testing.expectEqual(@as(f32, 1.953125), app_state.model.scale);
4204
+
4205
+ // Non-pinch raw input never leaks into the channel: a scroll leaves
4206
+ // the model untouched.
4207
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4208
+ .window_id = 1,
4209
+ .label = canvas_label,
4210
+ .kind = .scroll,
4211
+ .delta_y = 24,
4212
+ } });
4213
+ try std.testing.expectEqual(@as(f32, 1.953125), app_state.model.scale);
4214
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.begins);
4215
+
4216
+ // The automation verb drives the same real events: one full gesture
4217
+ // whose change carries scale - 1, anchor defaulting to the view
4218
+ // center, so tests and users can pinch without a trackpad.
4219
+ app_state.model = .{};
4220
+ var command_buffer: [96]u8 = undefined;
4221
+ const pinch_default = try std.fmt.bufPrint(&command_buffer, "widget-pinch {s} 1.5", .{canvas_label});
4222
+ try harness.runtime.dispatchAutomationCommand(app, pinch_default);
4223
+ try std.testing.expectEqual(@as(u32, 1), app_state.model.begins);
4224
+ try std.testing.expectEqual(@as(u32, 1), app_state.model.ends);
4225
+ try std.testing.expectEqual(@as(f32, 1.5), app_state.model.scale);
4226
+ try std.testing.expectEqual(@as(f32, 200), app_state.model.anchor_x);
4227
+ try std.testing.expectEqual(@as(f32, 150), app_state.model.anchor_y);
4228
+
4229
+ // An explicit anchor point rides through; the cumulative scale keeps
4230
+ // compounding across gestures exactly as deltas compound within one.
4231
+ const pinch_at = try std.fmt.bufPrint(&command_buffer, "widget-pinch {s} 0.5 40 60", .{canvas_label});
4232
+ try harness.runtime.dispatchAutomationCommand(app, pinch_at);
4233
+ try std.testing.expectEqual(@as(f32, 0.75), app_state.model.scale);
4234
+ try std.testing.expectEqual(@as(f32, 40), app_state.model.anchor_x);
4235
+ try std.testing.expectEqual(@as(f32, 60), app_state.model.anchor_y);
4236
+
4237
+ // A malformed scale is loud driver misuse, not a dispatched gesture
4238
+ // (the product of 1 + delta can never reach a non-positive scale).
4239
+ const pinch_bad = try std.fmt.bufPrint(&command_buffer, "widget-pinch {s} 0", .{canvas_label});
4240
+ try std.testing.expectError(error.InvalidCommand, harness.runtime.dispatchAutomationCommand(app, pinch_bad));
4241
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.begins);
4242
+
4243
+ // The f32 wire can betray the parser's `scale > 0` guard: a tiny
4244
+ // positive scale rounds `scale - 1` to exactly -1 — factor 0 on the
4245
+ // wire — so the dispatch refuses it with the wire-minimum teaching
4246
+ // instead of emitting a zoom through zero scale. Nothing dispatches:
4247
+ // no begin, no journaled partial gesture.
4248
+ const pinch_tiny = try std.fmt.bufPrint(&command_buffer, "widget-pinch {s} 1e-20", .{canvas_label});
4249
+ try std.testing.expectError(error.PinchScaleBelowWireMinimum, harness.runtime.dispatchAutomationCommand(app, pinch_tiny));
4250
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.begins);
4251
+ try std.testing.expectEqual(@as(f32, 0.75), app_state.model.scale);
4252
+
4253
+ // The smallest accepted scale — the first f32 above 2^-25 — round-
4254
+ // trips with a positive factor: its delta rounds to -1 + 2^-24, so
4255
+ // the factor is exactly 2^-24 and the model's product stays > 0
4256
+ // (0.75 * 2^-24 = 0x1.8p-25, binary-exact).
4257
+ const pinch_min = try std.fmt.bufPrint(&command_buffer, "widget-pinch {s} 2.9802326e-8", .{canvas_label});
4258
+ try harness.runtime.dispatchAutomationCommand(app, pinch_min);
4259
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.begins);
4260
+ try std.testing.expectEqual(@as(u32, 3), app_state.model.ends);
4261
+ try std.testing.expect(app_state.model.scale > 0);
4262
+ try std.testing.expectEqual(@as(f32, 0x1.8p-25), app_state.model.scale);
4263
+ }
4264
+
4265
+ const zoom_pair_main_views = [_]app_manifest.ShellView{
4266
+ .{ .label = "zoom-main-canvas", .kind = .gpu_surface, .fill = true, .gpu_backend = .metal },
4267
+ };
4268
+ const zoom_pair_inspector_views = [_]app_manifest.ShellView{
4269
+ .{ .label = "zoom-inspector-canvas", .kind = .gpu_surface, .fill = true, .gpu_backend = .metal },
4270
+ };
4271
+ const zoom_pair_windows = [_]app_manifest.ShellWindow{ .{
4272
+ .label = "main",
4273
+ .title = "Zoom",
4274
+ .width = 400,
4275
+ .height = 300,
4276
+ .views = &zoom_pair_main_views,
4277
+ }, .{
4278
+ .label = "inspector",
4279
+ .title = "Zoom Inspector",
4280
+ .width = 300,
4281
+ .height = 300,
4282
+ .views = &zoom_pair_inspector_views,
4283
+ } };
4284
+ const zoom_pair_scene: app_manifest.ShellConfig = .{ .windows = &zoom_pair_windows };
4285
+
4286
+ test "pinch identity distinguishes windows and views in the Msg" {
4287
+ // Two windows, two gpu-surface views: the pinch channel forwards
4288
+ // the source identity (window_id + view label) the journaled
4289
+ // platform event already carries, so a multi-window app hears WHICH
4290
+ // view a gesture zoomed — x/y are view-local, and a coordinate
4291
+ // without its view is not a position.
4292
+ const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
4293
+ defer harness.destroy(std.testing.allocator);
4294
+ harness.null_platform.gpu_surfaces = true;
4295
+
4296
+ const app_state = try std.testing.allocator.create(ZoomApp);
4297
+ defer std.testing.allocator.destroy(app_state);
4298
+ app_state.* = ZoomApp.init(std.heap.page_allocator, .{}, .{
4299
+ .name = "ui-app-zoom-pair",
4300
+ .scene = zoom_pair_scene,
4301
+ .canvas_label = "zoom-main-canvas",
4302
+ .update = zoomUpdate,
4303
+ .view = zoomView,
4304
+ .on_pinch = zoomPinch,
4305
+ });
4306
+ defer app_state.deinit();
4307
+ const app = app_state.app();
4308
+ try harness.start(app);
4309
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
4310
+ .label = "zoom-main-canvas",
4311
+ .size = geometry.SizeF.init(400, 300),
4312
+ .scale_factor = 2,
4313
+ .frame_index = 1,
4314
+ .timestamp_ns = 1_000_000,
4315
+ .nonblank = true,
4316
+ } });
4317
+ try std.testing.expect(app_state.installed);
4318
+
4319
+ // A gesture on the main window's canvas names its source on every
4320
+ // phase.
4321
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4322
+ .window_id = 1,
4323
+ .label = "zoom-main-canvas",
4324
+ .kind = .pinch_begin,
4325
+ .x = 100,
4326
+ .y = 50,
4327
+ } });
4328
+ try std.testing.expectEqual(@as(u64, 1), app_state.model.window_id);
4329
+ try std.testing.expectEqualStrings("zoom-main-canvas", app_state.model.label);
4330
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4331
+ .window_id = 1,
4332
+ .label = "zoom-main-canvas",
4333
+ .kind = .pinch_change,
4334
+ .x = 100,
4335
+ .y = 50,
4336
+ .scale = 0.25,
4337
+ } });
4338
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4339
+ .window_id = 1,
4340
+ .label = "zoom-main-canvas",
4341
+ .kind = .pinch_end,
4342
+ .x = 100,
4343
+ .y = 50,
4344
+ } });
4345
+ try std.testing.expectEqual(@as(f32, 1.25), app_state.model.scale);
4346
+
4347
+ // A gesture on the second window's view is distinguishable: same
4348
+ // channel, different identity in the Msg.
4349
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4350
+ .window_id = 2,
4351
+ .label = "zoom-inspector-canvas",
4352
+ .kind = .pinch_begin,
4353
+ .x = 10,
4354
+ .y = 20,
4355
+ } });
4356
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4357
+ .window_id = 2,
4358
+ .label = "zoom-inspector-canvas",
4359
+ .kind = .pinch_change,
4360
+ .x = 10,
4361
+ .y = 20,
4362
+ .scale = -0.5,
4363
+ } });
4364
+ try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
4365
+ .window_id = 2,
4366
+ .label = "zoom-inspector-canvas",
4367
+ .kind = .pinch_end,
4368
+ .x = 10,
4369
+ .y = 20,
4370
+ } });
4371
+ try std.testing.expectEqual(@as(u64, 2), app_state.model.window_id);
4372
+ try std.testing.expectEqualStrings("zoom-inspector-canvas", app_state.model.label);
4373
+ // Both gestures compounded the one model's zoom (1.25 * 0.5,
4374
+ // binary-exact) and every phase was heard.
4375
+ try std.testing.expectEqual(@as(f32, 0.625), app_state.model.scale);
4376
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.begins);
4377
+ try std.testing.expectEqual(@as(u32, 2), app_state.model.ends);
4378
+ }