@native-sdk/cli 0.6.0 → 0.6.1

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 CHANGED
@@ -1119,6 +1119,13 @@ pub fn build(b: *std.Build) void {
1119
1119
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NATIVE_SDK_APPKIT_GPU_INPUT_POINTER_CANCEL" },
1120
1120
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "_surfaceCursor = cursor ?: [NSCursor arrowCursor]" },
1121
1121
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NSCursor pointingHandCursor" },
1122
+ // A full-bounds canvas cursor rect geometrically overlaps a
1123
+ // higher-layer webview even though hit testing does not. The
1124
+ // workbench needs both halves: subtract the overlay from the
1125
+ // cursor rects and refuse a direct canvas cursor set there.
1126
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NSMutableArray<NSValue *> *visibleCursorRects" },
1127
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "surfaceView.coveredMouseRects = coveredRects" },
1128
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "if (!covered && NSPointInRect(mousePoint, self.bounds)) [_surfaceCursor set]" },
1122
1129
  });
1123
1130
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-widget-accessibility-actions", "Verify AppKit GPU widget accessibility actions route to the runtime", &.{
1124
1131
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "accessibilityPerformPress" },
@@ -1336,10 +1343,10 @@ pub fn build(b: *std.Build) void {
1336
1343
  linux_web_layer_audit_step.dependOn(&audit_webview_elf.step);
1337
1344
 
1338
1345
  const frontend_examples_step = b.step("test-examples-frontends", "Run frontend example tests");
1339
- addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-next", "Run Next example tests", "examples/next", .owned);
1340
- addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-react", "Run React example tests", "examples/react", .owned);
1341
- addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-svelte", "Run Svelte example tests", "examples/svelte", .owned);
1342
- addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-vue", "Run Vue example tests", "examples/vue", .owned);
1346
+ _ = addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-next", "Run Next example tests", "examples/next", .owned);
1347
+ _ = addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-react", "Run React example tests", "examples/react", .owned);
1348
+ _ = addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-svelte", "Run Svelte example tests", "examples/svelte", .owned);
1349
+ _ = addExampleTestStep(b, host_cli_exe, frontend_examples_step, "test-example-vue", "Run Vue example tests", "examples/vue", .owned);
1343
1350
  addFileContainsCheckStep(b, file_contains_checker, frontend_examples_step, "test-example-frontend-positioning", "Verify frontend example native shell positioning", &.{
1344
1351
  .{ .path = "examples/next/README.md", .pattern = "opens the native app shell with WebView content." },
1345
1352
  .{ .path = "examples/react/README.md", .pattern = "opens the native app shell with WebView content." },
@@ -1348,34 +1355,51 @@ pub fn build(b: *std.Build) void {
1348
1355
  });
1349
1356
 
1350
1357
  const native_examples_step = b.step("test-examples-native", "Run native-first example tests");
1351
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-command-app", "Run command app example tests", "examples/command-app", .owned);
1352
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-native-shell", "Run native shell example tests", "examples/native-shell", .owned);
1353
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-native-panels", "Run native panels example tests", "examples/native-panels", .owned);
1354
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-surface", "Run GPU surface example tests", "examples/gpu-surface", .managed);
1355
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-dashboard", "Run GPU dashboard example tests", "examples/gpu-dashboard", .managed);
1356
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-components", "Run GPU components example tests", "examples/gpu-components", .managed);
1357
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-ui-inbox", "Run ui builder inbox example tests", "examples/ui-inbox", .owned);
1358
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-kanban", "Run ui builder kanban example tests", "examples/kanban", .managed);
1359
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-habits", "Run markup habits example tests", "examples/habits", .managed);
1360
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-soundboard", "Run soundboard example tests", "examples/soundboard", .managed);
1361
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-video-player", "Run video player example tests", "examples/video-player", .managed);
1362
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-soundboard-ts", "Run soundboard-ts example tests", "examples/soundboard-ts", .managed);
1363
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-deck", "Run deck example tests", "examples/deck", .managed);
1364
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-markdown-viewer", "Run markdown viewer example tests", "examples/markdown-viewer", .managed);
1365
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-calculator", "Run calculator example tests", "examples/calculator", .managed);
1366
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-notes", "Run notes example tests", "examples/notes", .managed);
1367
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-split-collapse", "Run split collapse example tests", "examples/split-collapse", .managed);
1368
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-system-monitor", "Run system monitor example tests", "examples/system-monitor", .managed);
1369
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-terminal", "Run terminal example tests", "examples/terminal", .owned);
1370
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-workbench", "Run workbench example tests", "examples/workbench", .owned);
1371
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-system-monitor-ts", "Run system-monitor-ts example tests", "examples/system-monitor-ts", .managed);
1372
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-effects-probe", "Run effects probe example tests", "examples/effects-probe", .managed);
1373
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-channel-monitor", "Run channel monitor example tests", "examples/channel-monitor", .managed);
1374
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-menu-bar", "Run menu-bar lifecycle example tests", "examples/menu-bar", .managed);
1375
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-feed", "Run feed example tests", "examples/feed", .managed);
1376
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-canvas-preview", "Run canvas preview example tests", "examples/canvas-preview", .managed);
1377
- addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-capabilities", "Run capabilities example tests", "examples/capabilities", .owned);
1378
- addFileContainsCheckStep(b, file_contains_checker, native_examples_step, "test-example-capabilities-events", "Verify capabilities example event bridge names", &.{
1358
+ const native_example_shard_steps = [_]*std.Build.Step{
1359
+ b.step("test-examples-native-shard-1", "Run the first native-first example test shard"),
1360
+ b.step("test-examples-native-shard-2", "Run the second native-first example test shard"),
1361
+ b.step("test-examples-native-shard-3", "Run the third native-first example test shard"),
1362
+ b.step("test-examples-native-shard-4", "Run the fourth native-first example test shard"),
1363
+ };
1364
+ const native_example_steps = [_]*std.Build.Step{
1365
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-command-app", "Run command app example tests", "examples/command-app", .owned),
1366
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-native-shell", "Run native shell example tests", "examples/native-shell", .owned),
1367
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-native-panels", "Run native panels example tests", "examples/native-panels", .owned),
1368
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-surface", "Run GPU surface example tests", "examples/gpu-surface", .managed),
1369
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-dashboard", "Run GPU dashboard example tests", "examples/gpu-dashboard", .managed),
1370
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-gpu-components", "Run GPU components example tests", "examples/gpu-components", .managed),
1371
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-ui-inbox", "Run ui builder inbox example tests", "examples/ui-inbox", .owned),
1372
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-kanban", "Run ui builder kanban example tests", "examples/kanban", .managed),
1373
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-habits", "Run markup habits example tests", "examples/habits", .managed),
1374
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-soundboard", "Run soundboard example tests", "examples/soundboard", .managed),
1375
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-video-player", "Run video player example tests", "examples/video-player", .managed),
1376
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-soundboard-ts", "Run soundboard-ts example tests", "examples/soundboard-ts", .managed),
1377
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-deck", "Run deck example tests", "examples/deck", .managed),
1378
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-markdown-viewer", "Run markdown viewer example tests", "examples/markdown-viewer", .managed),
1379
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-calculator", "Run calculator example tests", "examples/calculator", .managed),
1380
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-notes", "Run notes example tests", "examples/notes", .managed),
1381
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-split-collapse", "Run split collapse example tests", "examples/split-collapse", .managed),
1382
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-system-monitor", "Run system monitor example tests", "examples/system-monitor", .managed),
1383
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-terminal", "Run terminal example tests", "examples/terminal", .owned),
1384
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-workbench", "Run workbench example tests", "examples/workbench", .owned),
1385
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-system-monitor-ts", "Run system-monitor-ts example tests", "examples/system-monitor-ts", .managed),
1386
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-effects-probe", "Run effects probe example tests", "examples/effects-probe", .managed),
1387
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-channel-monitor", "Run channel monitor example tests", "examples/channel-monitor", .managed),
1388
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-menu-bar", "Run menu-bar lifecycle example tests", "examples/menu-bar", .managed),
1389
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-feed", "Run feed example tests", "examples/feed", .managed),
1390
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-canvas-preview", "Run canvas preview example tests", "examples/canvas-preview", .managed),
1391
+ addExampleTestStep(b, host_cli_exe, native_examples_step, "test-example-capabilities", "Run capabilities example tests", "examples/capabilities", .owned),
1392
+ };
1393
+ for (native_example_shard_steps) |shard_step| {
1394
+ native_examples_step.dependOn(shard_step);
1395
+ }
1396
+ for (native_example_steps, 0..) |example_step, index| {
1397
+ native_example_shard_steps[index % native_example_shard_steps.len].dependOn(example_step);
1398
+ }
1399
+ // Keep this companion check in the same shard as capabilities. The
1400
+ // aggregate step depends on every shard, so `test-examples-native`
1401
+ // retains exactly the same coverage as before.
1402
+ addFileContainsCheckStep(b, file_contains_checker, native_example_shard_steps[2], "test-example-capabilities-events", "Verify capabilities example event bridge names", &.{
1379
1403
  .{ .path = "examples/capabilities/src/main.zig", .pattern = "native-sdk:drop:files" },
1380
1404
  });
1381
1405
 
@@ -3676,7 +3700,7 @@ fn addTestStep(b: *std.Build, name: []const u8, description: []const u8, artifac
3676
3700
  /// driven through plain in-dir `zig build`.
3677
3701
  const ExampleBuildShape = enum { managed, owned };
3678
3702
 
3679
- fn addExampleTestStep(b: *std.Build, cli_exe: *std.Build.Step.Compile, group: *std.Build.Step, name: []const u8, description: []const u8, example_path: []const u8, shape: ExampleBuildShape) void {
3703
+ fn addExampleTestStep(b: *std.Build, cli_exe: *std.Build.Step.Compile, group: *std.Build.Step, name: []const u8, description: []const u8, example_path: []const u8, shape: ExampleBuildShape) *std.Build.Step {
3680
3704
  const run = switch (shape) {
3681
3705
  .owned => b.addSystemCommand(&.{ "zig", "build", "test", "-Dplatform=null" }),
3682
3706
  .managed => managedExampleRun(b, cli_exe, &.{ "test", "-Dplatform=null" }),
@@ -3704,6 +3728,7 @@ fn addExampleTestStep(b: *std.Build, cli_exe: *std.Build.Step.Compile, group: *s
3704
3728
  const step = b.step(name, description);
3705
3729
  step.dependOn(&run.step);
3706
3730
  group.dependOn(&run.step);
3731
+ return step;
3707
3732
  }
3708
3733
 
3709
3734
  /// Run a `native` CLI verb (argv tail) against a managed example. The CLI
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,14 +32,14 @@
32
32
  "@typescript/typescript6": "6.0.2"
33
33
  },
34
34
  "optionalDependencies": {
35
- "@native-sdk/cli-darwin-arm64": "0.6.0",
36
- "@native-sdk/cli-darwin-x64": "0.6.0",
37
- "@native-sdk/cli-linux-arm64-gnu": "0.6.0",
38
- "@native-sdk/cli-linux-arm64-musl": "0.6.0",
39
- "@native-sdk/cli-linux-x64-gnu": "0.6.0",
40
- "@native-sdk/cli-linux-x64-musl": "0.6.0",
41
- "@native-sdk/cli-win32-arm64": "0.6.0",
42
- "@native-sdk/cli-win32-x64": "0.6.0"
35
+ "@native-sdk/cli-darwin-arm64": "0.6.1",
36
+ "@native-sdk/cli-darwin-x64": "0.6.1",
37
+ "@native-sdk/cli-linux-arm64-gnu": "0.6.1",
38
+ "@native-sdk/cli-linux-arm64-musl": "0.6.1",
39
+ "@native-sdk/cli-linux-x64-gnu": "0.6.1",
40
+ "@native-sdk/cli-linux-x64-musl": "0.6.1",
41
+ "@native-sdk/cli-win32-arm64": "0.6.1",
42
+ "@native-sdk/cli-win32-x64": "0.6.1"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.6.0",
9
+ "version": "0.6.1",
10
10
  "devDependencies": {
11
11
  "@typescript/old": "npm:typescript@6.0.3",
12
12
  "@typescript/typescript6": "6.0.2"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "The TypeScript authoring tier: the app-core subset, its dev-time transpiler to arena-backed Zig, and the SDK module cores import",
5
5
  "repository": {
6
6
  "type": "git",
@@ -581,6 +581,13 @@ static NSMutableDictionary *NativeSdkCredentialQuery(NSString *service, NSString
581
581
  @property(nonatomic, assign) uint64_t lastPacketDecodeNs;
582
582
  @property(nonatomic, assign) uint64_t lastPacketDrawNs;
583
583
  @property(nonatomic, strong) NSCursor *surfaceCursor;
584
+ /* Higher-layer sibling views covering this surface, in surface
585
+ * coordinates. AppKit cursor rects are geometric rather than hit-test
586
+ * aware: one full-bounds rect here would keep winning over an embedded
587
+ * WKWebView layered above the canvas (the workbench's browser pane), so
588
+ * resetCursorRects subtracts these occluders before registering the
589
+ * retained widget cursor. */
590
+ @property(nonatomic, strong) NSArray<NSValue *> *coveredMouseRects;
584
591
  @property(nonatomic, strong) NSTrackingArea *surfaceTrackingArea;
585
592
  @property(nonatomic, copy) NSString *markedText;
586
593
  @property(nonatomic, assign) NSRange markedTextRange;
@@ -5908,13 +5915,74 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
5908
5915
 
5909
5916
  - (void)resetCursorRects {
5910
5917
  [super resetCursorRects];
5911
- [self addCursorRect:self.bounds cursor:self.surfaceCursor ?: [NSCursor arrowCursor]];
5918
+ // Cursor rects do not honor sibling occlusion. Register the canvas
5919
+ // cursor only on the visible fragments left after higher-layer
5920
+ // native/web views are subtracted, so an overlaid WKWebView keeps
5921
+ // authority over its own link/text CSS cursors.
5922
+ NSMutableArray<NSValue *> *visibleCursorRects = [NSMutableArray arrayWithObject:[NSValue valueWithRect:self.bounds]];
5923
+ for (NSValue *coveredValue in self.coveredMouseRects) {
5924
+ NSRect covered = coveredValue.rectValue;
5925
+ NSMutableArray<NSValue *> *nextVisibleRects = [[NSMutableArray alloc] init];
5926
+ for (NSValue *visibleValue in visibleCursorRects) {
5927
+ NSRect visible = visibleValue.rectValue;
5928
+ NSRect intersection = NSIntersectionRect(visible, covered);
5929
+ if (NSIsEmptyRect(intersection)) {
5930
+ [nextVisibleRects addObject:visibleValue];
5931
+ continue;
5932
+ }
5933
+
5934
+ const CGFloat visibleMinX = NSMinX(visible);
5935
+ const CGFloat visibleMaxX = NSMaxX(visible);
5936
+ const CGFloat visibleMinY = NSMinY(visible);
5937
+ const CGFloat visibleMaxY = NSMaxY(visible);
5938
+ const CGFloat coveredMinX = NSMinX(intersection);
5939
+ const CGFloat coveredMaxX = NSMaxX(intersection);
5940
+ const CGFloat coveredMinY = NSMinY(intersection);
5941
+ const CGFloat coveredMaxY = NSMaxY(intersection);
5942
+
5943
+ if (coveredMinY > visibleMinY) {
5944
+ [nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
5945
+ visibleMinX, visibleMinY, visible.size.width, coveredMinY - visibleMinY)]];
5946
+ }
5947
+ if (coveredMaxY < visibleMaxY) {
5948
+ [nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
5949
+ visibleMinX, coveredMaxY, visible.size.width, visibleMaxY - coveredMaxY)]];
5950
+ }
5951
+ if (coveredMinX > visibleMinX) {
5952
+ [nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
5953
+ visibleMinX, coveredMinY, coveredMinX - visibleMinX, intersection.size.height)]];
5954
+ }
5955
+ if (coveredMaxX < visibleMaxX) {
5956
+ [nextVisibleRects addObject:[NSValue valueWithRect:NSMakeRect(
5957
+ coveredMaxX, coveredMinY, visibleMaxX - coveredMaxX, intersection.size.height)]];
5958
+ }
5959
+ }
5960
+ visibleCursorRects = nextVisibleRects;
5961
+ }
5962
+
5963
+ NSCursor *cursor = self.surfaceCursor ?: [NSCursor arrowCursor];
5964
+ for (NSValue *visibleValue in visibleCursorRects) {
5965
+ [self addCursorRect:visibleValue.rectValue cursor:cursor];
5966
+ }
5912
5967
  }
5913
5968
 
5914
5969
  - (void)setSurfaceCursor:(NSCursor *)cursor {
5915
5970
  _surfaceCursor = cursor ?: [NSCursor arrowCursor];
5916
5971
  [self.window invalidateCursorRectsForView:self];
5917
- [_surfaceCursor set];
5972
+ // The runtime changes cursor intent from mouseMoved:. Its tracking
5973
+ // area spans the geometric surface even where a sibling webview is
5974
+ // layered above it, so never let that immediate update clobber the
5975
+ // higher view's cursor. The visible cursor rect takes over again as
5976
+ // soon as the pointer returns to the canvas.
5977
+ NSPoint mousePoint = [self convertPoint:self.window.mouseLocationOutsideOfEventStream fromView:nil];
5978
+ BOOL covered = NO;
5979
+ for (NSValue *coveredValue in self.coveredMouseRects) {
5980
+ if (NSPointInRect(mousePoint, coveredValue.rectValue)) {
5981
+ covered = YES;
5982
+ break;
5983
+ }
5984
+ }
5985
+ if (!covered && NSPointInRect(mousePoint, self.bounds)) [_surfaceCursor set];
5918
5986
  }
5919
5987
 
5920
5988
  - (void)mouseDown:(NSEvent *)event {
@@ -8412,18 +8480,27 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
8412
8480
  }];
8413
8481
 
8414
8482
  for (NSUInteger index = 0; index < views.count; index++) {
8415
- if (![views[index] isKindOfClass:[NativeSdkWebView class]]) continue;
8416
- NativeSdkWebView *webView = (NativeSdkWebView *)views[index];
8483
+ NSView *coveredView = views[index];
8484
+ const BOOL isWebView = [coveredView isKindOfClass:[NativeSdkWebView class]];
8485
+ const BOOL isMetalSurface = [coveredView isKindOfClass:[NativeSdkMetalSurfaceView class]];
8486
+ if (!isWebView && !isMetalSurface) continue;
8417
8487
  NSMutableArray<NSValue *> *coveredRects = [[NSMutableArray alloc] init];
8418
8488
  for (NSUInteger coverIndex = index + 1; coverIndex < views.count; coverIndex++) {
8419
8489
  NSView *coveringView = views[coverIndex];
8420
8490
  if (coveringView.hidden) continue;
8421
- NSRect intersection = NSIntersectionRect(webView.frame, coveringView.frame);
8491
+ NSRect intersection = NSIntersectionRect(coveredView.frame, coveringView.frame);
8422
8492
  if (NSIsEmptyRect(intersection)) continue;
8423
- [coveredRects addObject:[NSValue valueWithRect:[webView convertRect:intersection fromView:contentView]]];
8493
+ [coveredRects addObject:[NSValue valueWithRect:[coveredView convertRect:intersection fromView:contentView]]];
8494
+ }
8495
+ if (isWebView) {
8496
+ NativeSdkWebView *webView = (NativeSdkWebView *)coveredView;
8497
+ webView.coveredMouseRects = coveredRects;
8498
+ [self applyCoveredMouseRects:coveredRects toWebView:webView];
8499
+ } else {
8500
+ NativeSdkMetalSurfaceView *surfaceView = (NativeSdkMetalSurfaceView *)coveredView;
8501
+ surfaceView.coveredMouseRects = coveredRects;
8502
+ [surfaceView.window invalidateCursorRectsForView:surfaceView];
8424
8503
  }
8425
- webView.coveredMouseRects = coveredRects;
8426
- [self applyCoveredMouseRects:coveredRects toWebView:webView];
8427
8504
  }
8428
8505
  }
8429
8506
 
@@ -65,11 +65,12 @@ pub const CanvasWidgetPointerEvent = struct {
65
65
  /// cursor, and text selection stay on `target`.
66
66
  press_target: ?canvas.WidgetHit = null,
67
67
  route: []const canvas.WidgetEventRouteEntry = &.{},
68
- /// A text edit this pointer gesture performed on `target` (the
69
- /// search field's built-in clear affordance). The runtime already
70
- /// applied it (the optimistic echo; the source tree is truth on the
71
- /// next rebuild); `UiApp` maps it through the tree's handler table
72
- /// to the field's `on_input` Msg so a model-owned buffer clears too.
68
+ /// A text edit this pointer gesture performed on `target` (an
69
+ /// editable field's caret/selection move, or the search field's
70
+ /// built-in clear affordance). The runtime already applied it (the
71
+ /// optimistic echo; the source tree is truth on the next rebuild);
72
+ /// `UiApp` maps it through the tree's handler table to the field's
73
+ /// `on_input` Msg so a model-owned buffer stays in lockstep too.
73
74
  edit: ?canvas.TextInputEvent = null,
74
75
  };
75
76
 
@@ -2080,6 +2080,11 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
2080
2080
  }
2081
2081
  }
2082
2082
  if (target_id == 0) return;
2083
+ const target_index = self.views[index].canvasWidgetNodeIndexById(target_id) orelse return;
2084
+ const target_widget = self.views[index].widget_layout_nodes[target_index].widget;
2085
+ const mirrors_editable_selection =
2086
+ canvas_widget_runtime.canvasWidgetEditableTextKind(target_widget.kind) and
2087
+ !target_widget.state.disabled;
2083
2088
 
2084
2089
  // The search field's built-in clear affordance: a press
2085
2090
  // inside the trailing clear region clears through the
@@ -2098,8 +2103,29 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
2098
2103
  pointer_event.pointer.point,
2099
2104
  pointer_event.pointer.phase == .move,
2100
2105
  pointer_event.pointer.click_count,
2101
- ) orelse return;
2102
- if (canvasDirtyRegionForView(self.views[index].frame, dirty)) |dirty_region| {
2106
+ );
2107
+ // Pointer placement lives first in the retained editor, but a
2108
+ // controlled field's model owns the TextBuffer that the next
2109
+ // keyboard edit will reduce. Stamp the resulting selection
2110
+ // onto the SAME pointer event so `UiApp` delivers
2111
+ // `.set_selection` through `on_input` before a later delete,
2112
+ // insert, or IME edit reaches that model. Without this echo,
2113
+ // the highlight was honest only in the runtime: selecting a
2114
+ // middle span and pressing Backspace let the model delete at
2115
+ // its stale end caret, and its rebuild overwrote the runtime's
2116
+ // correct optimistic edit.
2117
+ //
2118
+ // Stamp even when the retained state did not change. This is
2119
+ // the pointer counterpart of keyboard clear's resync rule: a
2120
+ // divergent model mirror must still hear the selection the
2121
+ // user established.
2122
+ if (mirrors_editable_selection) {
2123
+ const edited_widget = self.views[index].widget_layout_nodes[target_index].widget;
2124
+ const selection = edited_widget.text_selection orelse canvas.TextSelection.collapsed(edited_widget.text.len);
2125
+ pointer_event.edit = .{ .set_selection = selection };
2126
+ }
2127
+ const dirty_bounds = dirty orelse return;
2128
+ if (canvasDirtyRegionForView(self.views[index].frame, dirty_bounds)) |dirty_region| {
2103
2129
  self.invalidateFor(.state, dirty_region);
2104
2130
  } else {
2105
2131
  self.invalidateFor(.state, self.views[index].frame);
@@ -313,8 +313,8 @@ pub fn RuntimeGpuSurfaceEvents(comptime Runtime: type) type {
313
313
  } else {
314
314
  try CanvasWidgetEventMethods().updateCanvasWidgetControlFromPointer(self, pointer_event.*);
315
315
  try CanvasWidgetEventMethods().updateCanvasWidgetInteractionFromPointer(self, pointer_event.*);
316
- // The text pass may stamp a clear edit onto the
317
- // event for the app dispatch below.
316
+ // The text pass may stamp a caret/selection or clear
317
+ // edit onto the event for the app dispatch below.
318
318
  try CanvasWidgetEventMethods().updateCanvasWidgetTextFromPointer(self, pointer_event);
319
319
  try CanvasWidgetEventMethods().updateCanvasWidgetScrollFromPointer(self, pointer_event.*);
320
320
  try CanvasWidgetEventMethods().updateCanvasWidgetFocusFromPointer(self, pointer_event.*);
@@ -582,10 +582,11 @@ test "a recorded session replays to identical model state and fingerprints" {
582
582
  try std.testing.expect(recorded.model.stamp_ms != 0);
583
583
  try std.testing.expectEqual(@as(u32, 1), recorded.model.spectrum_count);
584
584
  try std.testing.expect(recorded.model.band_checksum != 0);
585
- // The typed insert, the DERIVED Escape-clear, and the sanitized
586
- // multi-line paste all reached the model's `on_input` mirror — the
587
- // paste landing STRIPPED of its line breaks (single-line rule).
588
- try std.testing.expectEqual(@as(u32, 3), recorded.model.query_edits);
585
+ // Both pointer caret placements, the typed insert, the DERIVED
586
+ // Escape-clear, and the sanitized multi-line paste all reached the
587
+ // model's `on_input` mirror — five edits total, with the paste
588
+ // landing STRIPPED of its line breaks (single-line rule).
589
+ try std.testing.expectEqual(@as(u32, 5), recorded.model.query_edits);
589
590
  try std.testing.expectEqualStrings("line oneline two", recorded.model.queryText());
590
591
  // Both pinch gestures reached the model: the raw stream's product
591
592
  // (1.25 * 0.75 = 0.9375) times the verb's exact 1.5.
@@ -4543,10 +4543,11 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
4543
4543
  },
4544
4544
  else => {},
4545
4545
  }
4546
- // A pointer gesture that performed a text edit (the search
4547
- // field's built-in clear) maps to the field's `on_input`
4548
- // Msg — the runtime already applied the edit; the model
4549
- // hears it here so a source-owned buffer clears too.
4546
+ // A pointer gesture that performed a text edit (editable
4547
+ // caret/selection placement or the search field's built-in
4548
+ // clear) maps to the field's `on_input` Msg — the runtime
4549
+ // already applied the edit; the model hears it here so a
4550
+ // source-owned buffer stays in lockstep too.
4550
4551
  if (pointer_event.edit) |edit| {
4551
4552
  if (pointer_event.target) |edit_target| {
4552
4553
  if (tree.msgForTextEdit(edit_target.id, edit)) |msg| {