@native-sdk/cli 0.9.0 → 0.9.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 +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -2450,7 +2450,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2450
2450
|
return true;
|
|
2451
2451
|
}
|
|
2452
2452
|
|
|
2453
|
-
pub fn updateCanvasWidgetControlFromPointer(self: *Runtime, pointer_event: CanvasWidgetPointerEvent) anyerror!void {
|
|
2453
|
+
pub fn updateCanvasWidgetControlFromPointer(self: *Runtime, pointer_event: *CanvasWidgetPointerEvent) anyerror!void {
|
|
2454
2454
|
const index = runtimeFindViewIndex(self, pointer_event.window_id, pointer_event.view_label) orelse return;
|
|
2455
2455
|
if (self.views[index].kind != .gpu_surface) return;
|
|
2456
2456
|
|
|
@@ -2461,6 +2461,12 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2461
2461
|
// one gesture. For controls hit directly (checkbox, slider,
|
|
2462
2462
|
// chip) both resolve to themselves — behavior is unchanged.
|
|
2463
2463
|
const resolved_pressed_id = canvasWidgetResolvedPressedId(self, index, self.views[index].canvas_widget_pressed_id);
|
|
2464
|
+
const radio_selection = pointer_event.pointer.phase == .up and resolved_pressed_id != 0 and radio: {
|
|
2465
|
+
const hit = pointer_event.press_target orelse break :radio false;
|
|
2466
|
+
break :radio hit.kind == .radio and
|
|
2467
|
+
hit.id == resolved_pressed_id and
|
|
2468
|
+
hit.bounds.normalized().containsPoint(pointer_event.pointer.point);
|
|
2469
|
+
};
|
|
2464
2470
|
const toggle_animation = self.views[index].canvasWidgetToggleAnimationForPointer(
|
|
2465
2471
|
pointer_event.pointer,
|
|
2466
2472
|
pointer_event.press_target,
|
|
@@ -2470,9 +2476,11 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2470
2476
|
pointer_event.pointer,
|
|
2471
2477
|
pointer_event.press_target,
|
|
2472
2478
|
resolved_pressed_id,
|
|
2473
|
-
)
|
|
2479
|
+
);
|
|
2480
|
+
if (radio_selection) pointer_event.pointer.radio_selection_changed = dirty != null;
|
|
2481
|
+
const dirty_bounds = dirty orelse return;
|
|
2474
2482
|
if (toggle_animation) |animation| try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).scheduleCanvasWidgetToggleAnimation(self, index, animation);
|
|
2475
|
-
if (canvasDirtyRegionForView(self.views[index].frame,
|
|
2483
|
+
if (canvasDirtyRegionForView(self.views[index].frame, dirty_bounds)) |dirty_region| {
|
|
2476
2484
|
self.invalidateFor(.state, dirty_region);
|
|
2477
2485
|
} else {
|
|
2478
2486
|
self.invalidateFor(.state, self.views[index].frame);
|
|
@@ -2480,18 +2488,27 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2480
2488
|
_ = try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, index);
|
|
2481
2489
|
}
|
|
2482
2490
|
|
|
2483
|
-
pub fn updateCanvasWidgetControlFromKeyboard(self: *Runtime, keyboard_event: CanvasWidgetKeyboardEvent) anyerror!void {
|
|
2491
|
+
pub fn updateCanvasWidgetControlFromKeyboard(self: *Runtime, keyboard_event: *CanvasWidgetKeyboardEvent) anyerror!void {
|
|
2484
2492
|
const index = runtimeFindViewIndex(self, keyboard_event.window_id, keyboard_event.view_label) orelse return;
|
|
2485
2493
|
if (self.views[index].kind != .gpu_surface) return;
|
|
2486
2494
|
const target = keyboard_event.target orelse return;
|
|
2487
2495
|
|
|
2496
|
+
const radio_selection = if (target.kind == .radio)
|
|
2497
|
+
if (canvas.widgetKeyboardControlIntent(self.views[index].widget_layout_nodes[target.index].widget, keyboard_event.keyboard)) |intent|
|
|
2498
|
+
intent.kind == .select
|
|
2499
|
+
else
|
|
2500
|
+
false
|
|
2501
|
+
else
|
|
2502
|
+
false;
|
|
2488
2503
|
const toggle_animation = self.views[index].canvasWidgetToggleAnimationForKeyboard(target.id, keyboard_event.keyboard);
|
|
2489
|
-
const dirty = try self.views[index].applyCanvasWidgetControlKeyboard(target.id, keyboard_event.keyboard)
|
|
2504
|
+
const dirty = try self.views[index].applyCanvasWidgetControlKeyboard(target.id, keyboard_event.keyboard);
|
|
2505
|
+
if (radio_selection) keyboard_event.keyboard.radio_selection_changed = dirty != null;
|
|
2506
|
+
const dirty_bounds = dirty orelse return;
|
|
2490
2507
|
if (toggle_animation) |animation| try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).scheduleCanvasWidgetToggleAnimation(self, index, animation);
|
|
2491
2508
|
const previous_cursor = self.views[index].canvas_widget_cursor;
|
|
2492
2509
|
if (target.kind == .scroll_view) try reconcileCanvasWidgetRenderStateAfterScrollWithTooltipIntent(self, index, null);
|
|
2493
2510
|
if (previous_cursor != self.views[index].canvas_widget_cursor) try syncCanvasWidgetCursorForView(self, index);
|
|
2494
|
-
if (canvasDirtyRegionForView(self.views[index].frame,
|
|
2511
|
+
if (canvasDirtyRegionForView(self.views[index].frame, dirty_bounds)) |dirty_region| {
|
|
2495
2512
|
self.invalidateFor(.state, dirty_region);
|
|
2496
2513
|
} else {
|
|
2497
2514
|
self.invalidateFor(.state, self.views[index].frame);
|
|
@@ -2509,7 +2526,6 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2509
2526
|
const index = runtimeFindViewIndex(self, pointer_event.window_id, pointer_event.view_label) orelse return 0;
|
|
2510
2527
|
if (self.views[index].kind != .gpu_surface or !self.views[index].focused) return 0;
|
|
2511
2528
|
const focused_id = self.views[index].canvas_widget_focused_id;
|
|
2512
|
-
if (focused_id == 0) return 0;
|
|
2513
2529
|
|
|
2514
2530
|
const previous_cursor = self.views[index].canvas_widget_cursor;
|
|
2515
2531
|
const dismissal = try self.views[index].dismissCanvasWidgetSurfaceForPointerOutsideFocusedTarget(focused_id, pointer_event.route) orelse return 0;
|
|
@@ -2701,11 +2717,33 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2701
2717
|
}
|
|
2702
2718
|
}
|
|
2703
2719
|
const direction: canvas.WidgetFocusDirection = if (input_event.modifiers.shift) .backward else .forward;
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2720
|
+
var target = self.views[index].canvasWidgetRovingTabTarget(current_id, direction) orelse return false;
|
|
2721
|
+
var moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, true);
|
|
2722
|
+
if (!moved and target.id != (current_id orelse 0)) {
|
|
2723
|
+
// A selected radio may be a valid LOGICAL group entry
|
|
2724
|
+
// while fully hidden by a fixed clip. The focus setter
|
|
2725
|
+
// first gave every runtime scroll ancestor a chance to
|
|
2726
|
+
// reveal it; if it is still unreachable, keep the group
|
|
2727
|
+
// in the Tab order through a visible radio. When the
|
|
2728
|
+
// entire group is clipped, continue the one-stop walk
|
|
2729
|
+
// from the failed entry to the next visible control.
|
|
2730
|
+
if (self.views[index].canvasWidgetNodeIndexById(target.id)) |target_index| {
|
|
2731
|
+
if (canvas_widget_runtime.canvasWidgetRovingTabScope(layout, target_index)) |scope| {
|
|
2732
|
+
if (canvas_widget_runtime.canvasWidgetRovingTabVisibleEntryTarget(layout, scope)) |visible| {
|
|
2733
|
+
if (visible.id != target.id) {
|
|
2734
|
+
target = visible;
|
|
2735
|
+
moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, true);
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
if (!moved) {
|
|
2741
|
+
const fallback = self.views[index].canvasWidgetRovingTabTarget(target.id, direction) orelse return false;
|
|
2742
|
+
if (fallback.id == target.id) return false;
|
|
2743
|
+
target = fallback;
|
|
2744
|
+
moved = try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, true);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2709
2747
|
if (moved and
|
|
2710
2748
|
(canvasWidgetTerminalOwnsTabInput(layout, target) or
|
|
2711
2749
|
canvasWidgetCodeEditorOwnsTabInput(layout, target)))
|
|
@@ -2743,6 +2781,20 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2743
2781
|
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2744
2782
|
}
|
|
2745
2783
|
const target = canvasWidgetGroupFocusEdgeTarget(layout, focused, edge) orelse return false;
|
|
2784
|
+
if (focused.kind == .radio and canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(layout, focused.index) != null) {
|
|
2785
|
+
const retry_direction: canvas.WidgetFocusDirection = switch (edge) {
|
|
2786
|
+
.first => .right,
|
|
2787
|
+
.last => .left,
|
|
2788
|
+
};
|
|
2789
|
+
return try setCanvasWidgetRadioGroupFocusFromKeyboardMoved(
|
|
2790
|
+
self,
|
|
2791
|
+
index,
|
|
2792
|
+
current_id,
|
|
2793
|
+
target,
|
|
2794
|
+
retry_direction,
|
|
2795
|
+
preserve_focus_visible,
|
|
2796
|
+
);
|
|
2797
|
+
}
|
|
2746
2798
|
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2747
2799
|
}
|
|
2748
2800
|
const direction = canvasWidgetSpatialFocusDirection(input_event) orelse return false;
|
|
@@ -2768,6 +2820,16 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2768
2820
|
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2769
2821
|
}
|
|
2770
2822
|
if (canvasWidgetGroupDirectionalFocusTarget(layout, focused, direction)) |target| {
|
|
2823
|
+
if (focused.kind == .radio and canvas_widget_runtime.canvasWidgetRadioGroupScopeIndex(layout, focused.index) != null) {
|
|
2824
|
+
return try setCanvasWidgetRadioGroupFocusFromKeyboardMoved(
|
|
2825
|
+
self,
|
|
2826
|
+
index,
|
|
2827
|
+
current_id,
|
|
2828
|
+
target,
|
|
2829
|
+
direction,
|
|
2830
|
+
preserve_focus_visible,
|
|
2831
|
+
);
|
|
2832
|
+
}
|
|
2771
2833
|
return try setCanvasWidgetFocusFromKeyboardMoved(self, index, current_id, target.id, preserve_focus_visible);
|
|
2772
2834
|
}
|
|
2773
2835
|
const target = layout.focusTarget(focused_id, direction) orelse return false;
|
|
@@ -2781,18 +2843,74 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2781
2843
|
return target_id != 0 and target_id != previous and self.views[view_index].canvas_widget_focused_id == target_id;
|
|
2782
2844
|
}
|
|
2783
2845
|
|
|
2846
|
+
/// Logical radio traversal admits scroll-clipped targets so the
|
|
2847
|
+
/// focus setter can reveal them. A fixed clip cannot be scrolled;
|
|
2848
|
+
/// after such a candidate stays unreachable, continue around the
|
|
2849
|
+
/// same nearest group until a visible radio accepts focus or the
|
|
2850
|
+
/// bounded walk returns to its starting point.
|
|
2851
|
+
fn setCanvasWidgetRadioGroupFocusFromKeyboardMoved(
|
|
2852
|
+
self: *Runtime,
|
|
2853
|
+
view_index: usize,
|
|
2854
|
+
previous_id: ?canvas.ObjectId,
|
|
2855
|
+
initial_target: canvas.WidgetFocusTarget,
|
|
2856
|
+
direction: canvas.WidgetFocusDirection,
|
|
2857
|
+
focus_visible: bool,
|
|
2858
|
+
) anyerror!bool {
|
|
2859
|
+
const previous = previous_id orelse 0;
|
|
2860
|
+
var target = initial_target;
|
|
2861
|
+
var attempts: usize = 0;
|
|
2862
|
+
while (attempts < self.views[view_index].widget_layout_node_count) : (attempts += 1) {
|
|
2863
|
+
if (target.id == 0 or target.id == previous) return false;
|
|
2864
|
+
if (try setCanvasWidgetFocusFromKeyboardMoved(self, view_index, previous_id, target.id, focus_visible)) return true;
|
|
2865
|
+
|
|
2866
|
+
const next = canvas_widget_runtime.canvasWidgetRadioGroupDirectionalFocusTarget(
|
|
2867
|
+
self.views[view_index].widgetLayoutTree(),
|
|
2868
|
+
target,
|
|
2869
|
+
direction,
|
|
2870
|
+
) orelse return false;
|
|
2871
|
+
if (next.id == target.id or next.id == initial_target.id) return false;
|
|
2872
|
+
target = next;
|
|
2873
|
+
}
|
|
2874
|
+
return false;
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2784
2877
|
pub fn setCanvasWidgetFocusFromKeyboard(self: *Runtime, view_index: usize, target_id: canvas.ObjectId) anyerror!void {
|
|
2785
2878
|
try setCanvasWidgetFocusFromKeyboardWithVisibility(self, view_index, target_id, true);
|
|
2786
2879
|
}
|
|
2787
2880
|
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2881
|
+
pub const CanvasWidgetFocusReveal = struct {
|
|
2882
|
+
target: canvas.WidgetFocusTarget,
|
|
2883
|
+
scroll_dirty: ?geometry.RectF,
|
|
2884
|
+
};
|
|
2885
|
+
|
|
2886
|
+
/// Validate a programmatic focus reveal without changing retained
|
|
2887
|
+
/// geometry. Automation uses this before asking the platform to
|
|
2888
|
+
/// focus the view, keeping both halves of the operation untouched
|
|
2889
|
+
/// when either the target or the platform focus request is invalid.
|
|
2890
|
+
pub fn canRevealCanvasWidgetFocusTarget(self: *const Runtime, view_index: usize, target_id: canvas.ObjectId) bool {
|
|
2891
|
+
if (view_index >= self.view_count or target_id == 0) return false;
|
|
2892
|
+
const layout = self.views[view_index].widgetLayoutTree();
|
|
2893
|
+
if (layout.focusTargetById(target_id) == null) {
|
|
2894
|
+
const node_index = canvas_widget_runtime.canvasWidgetLayoutNodeIndexById(layout, target_id) orelse return false;
|
|
2895
|
+
_ = canvas_widget_runtime.canvasWidgetLogicalFocusTarget(layout, node_index) orelse return false;
|
|
2896
|
+
}
|
|
2897
|
+
return self.views[view_index].canScrollCanvasWidgetIntoView(target_id);
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
/// Resolve a programmatic focus target without applying the pointer
|
|
2901
|
+
/// path's geometry clip first, reveal it through runtime-owned scroll
|
|
2902
|
+
/// ancestors, then re-verify the ordinary visible focus contract.
|
|
2903
|
+
/// Keyboard traversal, autofocus, and automation all enter through
|
|
2904
|
+
/// this seam so an offscreen logical target is never focused before
|
|
2905
|
+
/// its retained geometry and semantics have caught up with the scroll.
|
|
2906
|
+
pub fn revealCanvasWidgetFocusTarget(self: *Runtime, view_index: usize, target_id: canvas.ObjectId) anyerror!?CanvasWidgetFocusReveal {
|
|
2907
|
+
if (view_index >= self.view_count or target_id == 0) return null;
|
|
2908
|
+
const layout = self.views[view_index].widgetLayoutTree();
|
|
2909
|
+
if (layout.focusTargetById(target_id) == null) {
|
|
2910
|
+
const node_index = canvas_widget_runtime.canvasWidgetLayoutNodeIndexById(layout, target_id) orelse return null;
|
|
2911
|
+
_ = canvas_widget_runtime.canvasWidgetLogicalFocusTarget(layout, node_index) orelse return null;
|
|
2912
|
+
}
|
|
2791
2913
|
|
|
2792
|
-
// Roving tree/list navigation may resolve a logical row that
|
|
2793
|
-
// is currently clipped. Reveal it before the focus write so
|
|
2794
|
-
// keyboard routing, semantics, and rendering all see an
|
|
2795
|
-
// ordinary visible target during this same key event.
|
|
2796
2914
|
const scroll_dirty = try self.views[view_index].scrollCanvasWidgetIntoView(target_id);
|
|
2797
2915
|
if (scroll_dirty) |dirty| {
|
|
2798
2916
|
const previous_cursor = self.views[view_index].canvas_widget_cursor;
|
|
@@ -2804,12 +2922,19 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2804
2922
|
self.invalidateFor(.state, self.views[view_index].frame);
|
|
2805
2923
|
}
|
|
2806
2924
|
}
|
|
2807
|
-
|
|
2808
|
-
//
|
|
2809
|
-
//
|
|
2810
|
-
//
|
|
2811
|
-
|
|
2812
|
-
|
|
2925
|
+
|
|
2926
|
+
// A fixed clip cannot be repaired by scrolling. Re-check the
|
|
2927
|
+
// pointer-visible contract only after every scrollable ancestor
|
|
2928
|
+
// has had its chance to reveal the logical target.
|
|
2929
|
+
const target = self.views[view_index].widgetLayoutTree().focusTargetById(target_id) orelse return null;
|
|
2930
|
+
return .{ .target = target, .scroll_dirty = scroll_dirty };
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
fn setCanvasWidgetFocusFromKeyboardWithVisibility(self: *Runtime, view_index: usize, target_id: canvas.ObjectId, focus_visible: bool) anyerror!void {
|
|
2934
|
+
const next_focus_visible_id: canvas.ObjectId = if (focus_visible) target_id else 0;
|
|
2935
|
+
if (self.views[view_index].canvas_widget_focused_id == target_id and self.views[view_index].canvas_widget_focus_visible_id == next_focus_visible_id) return;
|
|
2936
|
+
|
|
2937
|
+
const reveal = try revealCanvasWidgetFocusTarget(self, view_index, target_id) orelse return;
|
|
2813
2938
|
const previous_state = self.views[view_index].canvasWidgetRenderState();
|
|
2814
2939
|
self.views[view_index].canvas_widget_focused_id = target_id;
|
|
2815
2940
|
self.views[view_index].canvas_widget_focus_visible_id = next_focus_visible_id;
|
|
@@ -2842,7 +2967,7 @@ pub fn RuntimeCanvasWidgetEvents(comptime Runtime: type) type {
|
|
|
2842
2967
|
}
|
|
2843
2968
|
}
|
|
2844
2969
|
try invalidateForCanvasWidgetRenderStateChange(self, view_index, previous_state, self.views[view_index].canvasWidgetRenderState());
|
|
2845
|
-
if (scroll_dirty != null) {
|
|
2970
|
+
if (reveal.scroll_dirty != null) {
|
|
2846
2971
|
_ = try runtime_canvas_widget_display.RuntimeCanvasWidgetDisplay(Runtime).refreshCanvasWidgetDisplayListIfOwned(self, view_index);
|
|
2847
2972
|
}
|
|
2848
2973
|
}
|
|
@@ -236,6 +236,54 @@ test "runtime escape with no focused widget dismisses the topmost mounted anchor
|
|
|
236
236
|
try std.testing.expect(!retained.findById(1).?.widget.semantics.hidden);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
test "escape and outside dismissal follow explicit anchored surface layers" {
|
|
240
|
+
const TestApp = struct {
|
|
241
|
+
fn app(self: *@This()) App {
|
|
242
|
+
return .{ .context = self, .name = "gpu-widget-layered-surface-dismiss", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
247
|
+
defer harness.destroy(std.testing.allocator);
|
|
248
|
+
harness.null_platform.gpu_surfaces = true;
|
|
249
|
+
var app_state: TestApp = .{};
|
|
250
|
+
try harness.start(app_state.app());
|
|
251
|
+
|
|
252
|
+
_ = try harness.runtime.createView(.{
|
|
253
|
+
.window_id = 1,
|
|
254
|
+
.label = "canvas",
|
|
255
|
+
.kind = .gpu_surface,
|
|
256
|
+
.frame = geometry.RectF.init(0, 0, 320, 180),
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
const elevated = canvas.Widget{
|
|
260
|
+
.id = 2,
|
|
261
|
+
.kind = .dropdown_menu,
|
|
262
|
+
.frame = geometry.RectF.init(0, 0, 120, 60),
|
|
263
|
+
.layer = 500,
|
|
264
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(20, 20) } },
|
|
265
|
+
};
|
|
266
|
+
const later_default = canvas.Widget{
|
|
267
|
+
.id = 3,
|
|
268
|
+
.kind = .dropdown_menu,
|
|
269
|
+
.frame = geometry.RectF.init(0, 0, 120, 60),
|
|
270
|
+
.layout = .{ .anchor = .{ .offset = 0, .point = geometry.PointF.init(40, 40) } },
|
|
271
|
+
};
|
|
272
|
+
const root = canvas.Widget{ .id = 1, .kind = .stack, .children = &.{ elevated, later_default } };
|
|
273
|
+
|
|
274
|
+
var outside_nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
275
|
+
const outside_layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 320, 180), &outside_nodes);
|
|
276
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", outside_layout);
|
|
277
|
+
const outside = try harness.runtime.views[0].dismissCanvasWidgetSurfaceForPointerOutsideFocusedTarget(0, &.{}) orelse return error.TestUnexpectedResult;
|
|
278
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), outside.id);
|
|
279
|
+
|
|
280
|
+
var escape_nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
281
|
+
const escape_layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 320, 180), &escape_nodes);
|
|
282
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", escape_layout);
|
|
283
|
+
const escape = try harness.runtime.views[0].dismissCanvasWidgetSurfaceFromEscape(0) orelse return error.TestUnexpectedResult;
|
|
284
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), escape.id);
|
|
285
|
+
}
|
|
286
|
+
|
|
239
287
|
test "runtime dismisses canvas floating surfaces from automation and accessibility actions" {
|
|
240
288
|
const TestApp = struct {
|
|
241
289
|
fn app(self: *@This()) App {
|