@native-sdk/cli 0.8.3 → 0.9.0
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 +905 -61
- package/build.zig +674 -373
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +6 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +455 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +214 -2
- package/packages/core/sdk/core.ts +715 -42
- package/packages/core/sdk/events.d.ts +50 -0
- package/packages/core/sdk/events.ts +75 -0
- package/packages/core/src/checker.ts +528 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1849 -18
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +84 -18
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +3 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +55 -8
- package/skill-data/ts-core/SKILL.md +92 -40
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +268 -4
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +115 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +121 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +41 -18
- package/src/platform/macos/appkit_host.h +26 -3
- package/src/platform/macos/appkit_host.m +1051 -129
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +270 -36
- package/src/platform/macos/root.zig +312 -34
- package/src/platform/null_platform.zig +281 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +16 -0
- package/src/platform/types.zig +279 -15
- package/src/platform/windows/root.zig +243 -21
- package/src/platform/windows/webview2_host.cpp +464 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +34 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +296 -114
- package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +29 -5
- package/src/root.zig +56 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +31 -13
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2568 -75
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +52 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +5 -0
- package/src/runtime/ts_core_host.zig +1189 -118
- package/src/runtime/ts_core_host_tests.zig +638 -11
- package/src/runtime/ts_ui_app.zig +537 -1
- package/src/runtime/ui_app.zig +160 -19
- package/src/runtime/ui_app_tests.zig +203 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +11 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +1248 -2
- package/src/tooling/package.zig +953 -6
- package/src/tooling/raw_manifest.zig +65 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +216 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +414 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -93,7 +93,7 @@ test "layout install publishes native scroll drivers and suppresses engine scrol
|
|
|
93
93
|
// The retained scroll node is marked natively driven and the engine
|
|
94
94
|
// scrollbar (widget part slots 2 and 3) is not emitted.
|
|
95
95
|
const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
96
|
-
try std.testing.expect(retained.nodes[0].widget.native_scroll);
|
|
96
|
+
try std.testing.expect(retained.nodes[0].widget.runtime_flags.native_scroll);
|
|
97
97
|
_ = try harness.runtime.emitCanvasWidgetDisplayList(1, "canvas", .{});
|
|
98
98
|
const display_list = try harness.runtime.canvasDisplayList(1, "canvas");
|
|
99
99
|
for (display_list.commands) |command| {
|
|
@@ -113,6 +113,39 @@ test "layout install publishes native scroll drivers and suppresses engine scrol
|
|
|
113
113
|
try std.testing.expectEqual(@as(f32, 120.0), snapshot.widgets[0].scroll.content_extent);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
test "programmatic scroll offsets clamp before native drivers adopt them" {
|
|
117
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
118
|
+
defer harness.destroy(std.testing.allocator);
|
|
119
|
+
harness.null_platform.gpu_surfaces = true;
|
|
120
|
+
harness.null_platform.gpu_surface_scroll_drivers = true;
|
|
121
|
+
var app_state: PassiveApp = .{};
|
|
122
|
+
try harness.start(app_state.app());
|
|
123
|
+
|
|
124
|
+
_ = try harness.runtime.createView(.{
|
|
125
|
+
.window_id = 1,
|
|
126
|
+
.label = "canvas",
|
|
127
|
+
.kind = .gpu_surface,
|
|
128
|
+
.frame = geometry.RectF.init(10, 20, 180, 72),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Apps deliberately use an out-of-range source value for "scroll to
|
|
132
|
+
// end". Clamp that intent against the laid-out content BEFORE the
|
|
133
|
+
// native driver or retained frames can expose the raw displacement.
|
|
134
|
+
var nodes: [5]canvas.WidgetLayoutNode = undefined;
|
|
135
|
+
const layout = try scrollFixtureLayout(&nodes, 1_000_000);
|
|
136
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
137
|
+
|
|
138
|
+
const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
139
|
+
try std.testing.expectEqual(@as(f32, 48), retained.nodes[0].widget.value);
|
|
140
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(0, -48, 180, 32), retained.nodes[1].frame);
|
|
141
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(0, 40, 180, 32), retained.nodes[3].frame);
|
|
142
|
+
|
|
143
|
+
const drivers = harness.null_platform.scrollDrivers();
|
|
144
|
+
try std.testing.expectEqual(@as(usize, 1), drivers.len);
|
|
145
|
+
try std.testing.expectEqual(@as(f32, 48), drivers[0].offset_y);
|
|
146
|
+
try std.testing.expectEqual(@as(f32, 120), drivers[0].content_size.height);
|
|
147
|
+
}
|
|
148
|
+
|
|
116
149
|
test "a region's rubber-band opt-in reaches its driver spec" {
|
|
117
150
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
118
151
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -201,6 +234,16 @@ test "driver offsets scroll retained scroll views and pass through overscroll" {
|
|
|
201
234
|
try std.testing.expectEqualDeep(geometry.RectF.init(0, 10, 180, 32), retained.nodes[1].frame);
|
|
202
235
|
try std.testing.expect(!harness.runtime.views[0].canvasWidgetKineticScrollActive());
|
|
203
236
|
|
|
237
|
+
// A controlled model may immediately echo that driver offset through
|
|
238
|
+
// on-scroll. It is still the live user bounce, not a programmatic
|
|
239
|
+
// source move, so the rebuild must preserve it without clamping.
|
|
240
|
+
var echo_nodes: [5]canvas.WidgetLayoutNode = undefined;
|
|
241
|
+
const echo_layout = try scrollFixtureLayout(&echo_nodes, -10);
|
|
242
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", echo_layout);
|
|
243
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
244
|
+
try std.testing.expectEqual(@as(f32, -10), retained.nodes[0].widget.value);
|
|
245
|
+
try std.testing.expectEqualDeep(geometry.RectF.init(0, 10, 180, 32), retained.nodes[1].frame);
|
|
246
|
+
|
|
204
247
|
// The OS scroller settles the bounce and reports the rested offset.
|
|
205
248
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_scroll_driver = .{
|
|
206
249
|
.window_id = 1,
|
|
@@ -409,7 +452,7 @@ test "scroll drivers stay unpublished without platform support" {
|
|
|
409
452
|
|
|
410
453
|
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.scroll_driver_set_count);
|
|
411
454
|
const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
412
|
-
try std.testing.expect(!retained.nodes[0].widget.native_scroll);
|
|
455
|
+
try std.testing.expect(!retained.nodes[0].widget.runtime_flags.native_scroll);
|
|
413
456
|
|
|
414
457
|
// Engine scrollbar still draws for engine-owned scrolling.
|
|
415
458
|
_ = try harness.runtime.emitCanvasWidgetDisplayList(1, "canvas", .{});
|
|
@@ -483,7 +526,7 @@ test "windowed virtual lists ride the native scroll driver with the full virtual
|
|
|
483
526
|
// The retained region is natively driven: engine scrollbar and
|
|
484
527
|
// engine physics stand down.
|
|
485
528
|
var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
486
|
-
try std.testing.expect(retained.nodes[0].widget.native_scroll);
|
|
529
|
+
try std.testing.expect(retained.nodes[0].widget.runtime_flags.native_scroll);
|
|
487
530
|
|
|
488
531
|
// A driver-reported offset scrolls the window (the optimistic echo
|
|
489
532
|
// translates the built rows; the app's rebuild re-windows).
|
|
@@ -505,7 +548,7 @@ test "windowed virtual lists ride the native scroll driver with the full virtual
|
|
|
505
548
|
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", legacy_layout);
|
|
506
549
|
try std.testing.expectEqual(@as(usize, 0), harness.null_platform.scrollDrivers().len);
|
|
507
550
|
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
508
|
-
try std.testing.expect(!retained.nodes[0].widget.native_scroll);
|
|
551
|
+
try std.testing.expect(!retained.nodes[0].widget.runtime_flags.native_scroll);
|
|
509
552
|
}
|
|
510
553
|
|
|
511
554
|
test "a rebuild mid-overscroll keeps the driver's offset and pushes nothing" {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//! momentum, overlay scrollbars, and rubber-band for regions that opt
|
|
4
4
|
//! into it — while the engine keeps rendering the content. The runtime:
|
|
5
5
|
//!
|
|
6
|
-
//! - stamps `widget.native_scroll` on every non-virtualized `.scroll_view`
|
|
6
|
+
//! - stamps `widget.runtime_flags.native_scroll` on every non-virtualized `.scroll_view`
|
|
7
7
|
//! (and every RUNTIME-SCROLLED virtual list — a virtualized scroll_view
|
|
8
8
|
//! with a declared item count, whose driver content size is the full
|
|
9
9
|
//! virtual extent) so engine scrollbars and engine kinetic physics
|
|
@@ -52,7 +52,7 @@ pub fn RuntimeCanvasWidgetScrollDrivers(comptime Runtime: type) type {
|
|
|
52
52
|
pub fn stampCanvasWidgetNativeScroll(self: *const Runtime, nodes: []canvas.WidgetLayoutNode) void {
|
|
53
53
|
if (!canvasWidgetScrollDriversSupported(self)) return;
|
|
54
54
|
for (nodes) |*node| {
|
|
55
|
-
if (canvasWidgetScrollDriverEligible(node.*)) node.widget.native_scroll = true;
|
|
55
|
+
if (canvasWidgetScrollDriverEligible(node.*)) node.widget.runtime_flags.native_scroll = true;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -117,7 +117,7 @@ pub fn RuntimeCanvasWidgetScrollDrivers(comptime Runtime: type) type {
|
|
|
117
117
|
}
|
|
118
118
|
for (view.widget_layout_nodes[0..view.widget_layout_node_count], 0..) |*node, node_index| {
|
|
119
119
|
if (!canvasWidgetScrollDriverEligible(node.*)) continue;
|
|
120
|
-
node.widget.native_scroll = true;
|
|
120
|
+
node.widget.runtime_flags.native_scroll = true;
|
|
121
121
|
if (count >= drivers.len) continue;
|
|
122
122
|
|
|
123
123
|
const viewport = node.frame.inset(node.widget.layout.padding).normalized();
|
|
@@ -701,6 +701,8 @@ test "runtime applies source-driven autofocus on the edge, never on the level" {
|
|
|
701
701
|
try std.testing.expectEqual(@as(canvas.ObjectId, 7), harness.runtime.views[0].canvas_widget_focused_id);
|
|
702
702
|
try std.testing.expectEqual(@as(canvas.ObjectId, 7), harness.runtime.views[0].canvas_widget_focus_visible_id);
|
|
703
703
|
try std.testing.expect(harness.runtime.views[0].focused);
|
|
704
|
+
const focused_layout = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
705
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), focused_layout.findById(7).?.widget.text_selection.?);
|
|
704
706
|
|
|
705
707
|
// The user moves focus; re-applying the SAME layout (flag held true)
|
|
706
708
|
// must not steal it back — edge-triggered, level-ignored.
|
|
@@ -372,6 +372,57 @@ test "tree keymap walks visible rows, collapses, expands, and selects through re
|
|
|
372
372
|
try std.testing.expect(!after_enter.findById(12).?.widget.state.selected);
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
+
test "tree roving focus only shows a ring after Tab entry" {
|
|
376
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
377
|
+
defer harness.destroy(std.testing.allocator);
|
|
378
|
+
harness.null_platform.gpu_surfaces = true;
|
|
379
|
+
var app_state: ObservingApp = .{};
|
|
380
|
+
const app = app_state.app();
|
|
381
|
+
try harness.start(app);
|
|
382
|
+
|
|
383
|
+
_ = try harness.runtime.createView(.{
|
|
384
|
+
.window_id = 1,
|
|
385
|
+
.label = "canvas",
|
|
386
|
+
.kind = .gpu_surface,
|
|
387
|
+
.frame = geometry.RectF.init(0, 0, 240, 100),
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
const rows = [_]canvas.Widget{
|
|
391
|
+
treeRowPanel(11, 0, 24, null, &.{}),
|
|
392
|
+
treeRowPanel(12, 30, 24, null, &.{}),
|
|
393
|
+
};
|
|
394
|
+
var nodes: [4]canvas.WidgetLayoutNode = undefined;
|
|
395
|
+
const layout = try canvas.layoutWidgetTree(
|
|
396
|
+
.{ .id = 10, .kind = .tree, .children = &rows },
|
|
397
|
+
geometry.RectF.init(0, 0, 240, 100),
|
|
398
|
+
&nodes,
|
|
399
|
+
);
|
|
400
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
401
|
+
const view = &harness.runtime.views[0];
|
|
402
|
+
|
|
403
|
+
// Pointer entry is quiet. Roving to the next row with ArrowDown
|
|
404
|
+
// must preserve that modality instead of flashing a focus ring
|
|
405
|
+
// before the selection echo rebuilds the tree.
|
|
406
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_down, .x = 10, .y = 10, .button = 0 } });
|
|
407
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_up, .x = 10, .y = 10, .button = 0 } });
|
|
408
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 11), view.canvas_widget_focused_id);
|
|
409
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 0), view.canvas_widget_focus_visible_id);
|
|
410
|
+
|
|
411
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
412
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 12), view.canvas_widget_focused_id);
|
|
413
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 0), view.canvas_widget_focus_visible_id);
|
|
414
|
+
|
|
415
|
+
// Tab is the explicit focus-visible entry. Once it establishes the
|
|
416
|
+
// ring, roving arrows carry that visible keyboard focus with them.
|
|
417
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "tab", .modifiers = .{ .shift = true } } });
|
|
418
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 11), view.canvas_widget_focused_id);
|
|
419
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 11), view.canvas_widget_focus_visible_id);
|
|
420
|
+
|
|
421
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
422
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 12), view.canvas_widget_focused_id);
|
|
423
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 12), view.canvas_widget_focus_visible_id);
|
|
424
|
+
}
|
|
425
|
+
|
|
375
426
|
test "flat tree levels resolve logical parents and children" {
|
|
376
427
|
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
377
428
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -537,6 +588,183 @@ test "a virtual list declaring the tree role scopes the tree keymap over its row
|
|
|
537
588
|
try std.testing.expectEqual(@as(canvas.ObjectId, 23), view.canvas_widget_focused_id);
|
|
538
589
|
}
|
|
539
590
|
|
|
591
|
+
test "tree arrow navigation reveals and focuses rows below a scroll viewport" {
|
|
592
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
593
|
+
defer harness.destroy(std.testing.allocator);
|
|
594
|
+
harness.null_platform.gpu_surfaces = true;
|
|
595
|
+
var app_state: ObservingApp = .{};
|
|
596
|
+
const app = app_state.app();
|
|
597
|
+
try harness.start(app);
|
|
598
|
+
|
|
599
|
+
_ = try harness.runtime.createView(.{
|
|
600
|
+
.window_id = 1,
|
|
601
|
+
.label = "canvas",
|
|
602
|
+
.kind = .gpu_surface,
|
|
603
|
+
.frame = geometry.RectF.init(0, 0, 240, 64),
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
const rows = [_]canvas.Widget{
|
|
607
|
+
treeRowPanel(21, 0, 28, null, &.{}),
|
|
608
|
+
treeRowPanel(22, 0, 28, null, &.{}),
|
|
609
|
+
treeRowPanel(23, 0, 28, null, &.{}),
|
|
610
|
+
treeRowPanel(24, 0, 28, null, &.{}),
|
|
611
|
+
};
|
|
612
|
+
const tree = canvas.Widget{
|
|
613
|
+
.id = 20,
|
|
614
|
+
.kind = .tree,
|
|
615
|
+
.frame = geometry.RectF.init(0, 0, 0, 118),
|
|
616
|
+
.layout = .{ .gap = 2 },
|
|
617
|
+
.children = &rows,
|
|
618
|
+
};
|
|
619
|
+
const root = canvas.Widget{
|
|
620
|
+
.id = 10,
|
|
621
|
+
.kind = .scroll_view,
|
|
622
|
+
.children = &.{tree},
|
|
623
|
+
};
|
|
624
|
+
var nodes: [8]canvas.WidgetLayoutNode = undefined;
|
|
625
|
+
const layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 64), &nodes);
|
|
626
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
627
|
+
const view = &harness.runtime.views[0];
|
|
628
|
+
|
|
629
|
+
// Row 2 is fully visible and row 3 has only its leading 4pt inside
|
|
630
|
+
// the viewport. Focus row 2 by pointer, then walk onto row 3.
|
|
631
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_down, .x = 10, .y = 40, .button = 0 } });
|
|
632
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_up, .x = 10, .y = 40, .button = 0 } });
|
|
633
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 22), view.canvas_widget_focused_id);
|
|
634
|
+
|
|
635
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
636
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 23), view.canvas_widget_focused_id);
|
|
637
|
+
|
|
638
|
+
// The next logical row starts fully below the clip. ArrowDown must
|
|
639
|
+
// minimally scroll it into view, move focus, and route the keyboard
|
|
640
|
+
// selection arrival to that newly visible row.
|
|
641
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
642
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 24), view.canvas_widget_focused_id);
|
|
643
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 24), app_state.last_keyboard_target_id);
|
|
644
|
+
try std.testing.expect(app_state.last_keyboard_focus_moved);
|
|
645
|
+
|
|
646
|
+
const scrolled = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
647
|
+
const viewport = scrolled.findById(10).?.frame.normalized();
|
|
648
|
+
const focused = scrolled.findById(24).?.frame.normalized();
|
|
649
|
+
try std.testing.expect(focused.y >= viewport.y);
|
|
650
|
+
try std.testing.expect(focused.maxY() <= viewport.maxY());
|
|
651
|
+
try std.testing.expect(scrolled.findById(10).?.widget.value > 0);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
test "list arrow navigation reveals and focuses rows below a scroll viewport" {
|
|
655
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
656
|
+
defer harness.destroy(std.testing.allocator);
|
|
657
|
+
harness.null_platform.gpu_surfaces = true;
|
|
658
|
+
var app_state: ObservingApp = .{};
|
|
659
|
+
const app = app_state.app();
|
|
660
|
+
try harness.start(app);
|
|
661
|
+
|
|
662
|
+
_ = try harness.runtime.createView(.{
|
|
663
|
+
.window_id = 1,
|
|
664
|
+
.label = "canvas",
|
|
665
|
+
.kind = .gpu_surface,
|
|
666
|
+
.frame = geometry.RectF.init(0, 0, 240, 64),
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
const rows = [_]canvas.Widget{
|
|
670
|
+
.{ .id = 31, .kind = .list_item, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "One" },
|
|
671
|
+
.{ .id = 32, .kind = .list_item, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Two" },
|
|
672
|
+
.{ .id = 33, .kind = .list_item, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Three" },
|
|
673
|
+
.{ .id = 34, .kind = .list_item, .frame = geometry.RectF.init(0, 0, 0, 28), .text = "Four" },
|
|
674
|
+
};
|
|
675
|
+
const list = canvas.Widget{
|
|
676
|
+
.id = 30,
|
|
677
|
+
.kind = .list,
|
|
678
|
+
.frame = geometry.RectF.init(0, 0, 0, 118),
|
|
679
|
+
.layout = .{ .gap = 2 },
|
|
680
|
+
.children = &rows,
|
|
681
|
+
};
|
|
682
|
+
const root = canvas.Widget{
|
|
683
|
+
.id = 10,
|
|
684
|
+
.kind = .scroll_view,
|
|
685
|
+
.children = &.{list},
|
|
686
|
+
};
|
|
687
|
+
var nodes: [8]canvas.WidgetLayoutNode = undefined;
|
|
688
|
+
const layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 64), &nodes);
|
|
689
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
690
|
+
try harness.runtime.focusView(1, "canvas");
|
|
691
|
+
const view = &harness.runtime.views[0];
|
|
692
|
+
|
|
693
|
+
// Keyboard entry grants the list-row roving contract (pointer focus
|
|
694
|
+
// stays intentionally quiet). The first Tab focuses the scroll view,
|
|
695
|
+
// the second reaches row 1.
|
|
696
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "tab" } });
|
|
697
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "tab" } });
|
|
698
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 31), view.canvas_widget_focused_id);
|
|
699
|
+
|
|
700
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
701
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
702
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 33), view.canvas_widget_focused_id);
|
|
703
|
+
|
|
704
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
705
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 34), view.canvas_widget_focused_id);
|
|
706
|
+
|
|
707
|
+
const scrolled = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
708
|
+
const viewport = scrolled.findById(10).?.frame.normalized();
|
|
709
|
+
const focused = scrolled.findById(34).?.frame.normalized();
|
|
710
|
+
try std.testing.expect(focused.y >= viewport.y);
|
|
711
|
+
try std.testing.expect(focused.maxY() <= viewport.maxY());
|
|
712
|
+
try std.testing.expect(scrolled.findById(10).?.widget.value > 0);
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
test "tree arrow navigation refuses rows clipped without a scroll ancestor" {
|
|
716
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
717
|
+
defer harness.destroy(std.testing.allocator);
|
|
718
|
+
harness.null_platform.gpu_surfaces = true;
|
|
719
|
+
var app_state: ObservingApp = .{};
|
|
720
|
+
const app = app_state.app();
|
|
721
|
+
try harness.start(app);
|
|
722
|
+
|
|
723
|
+
_ = try harness.runtime.createView(.{
|
|
724
|
+
.window_id = 1,
|
|
725
|
+
.label = "canvas",
|
|
726
|
+
.kind = .gpu_surface,
|
|
727
|
+
.frame = geometry.RectF.init(0, 0, 240, 64),
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
const rows = [_]canvas.Widget{
|
|
731
|
+
treeRowPanel(21, 0, 28, null, &.{}),
|
|
732
|
+
treeRowPanel(22, 0, 28, null, &.{}),
|
|
733
|
+
treeRowPanel(23, 0, 28, null, &.{}),
|
|
734
|
+
treeRowPanel(24, 0, 28, null, &.{}),
|
|
735
|
+
};
|
|
736
|
+
const tree = canvas.Widget{
|
|
737
|
+
.id = 20,
|
|
738
|
+
.kind = .tree,
|
|
739
|
+
.frame = geometry.RectF.init(0, 0, 0, 118),
|
|
740
|
+
.layout = .{ .gap = 2 },
|
|
741
|
+
.children = &rows,
|
|
742
|
+
};
|
|
743
|
+
const root = canvas.Widget{
|
|
744
|
+
.id = 10,
|
|
745
|
+
.kind = .stack,
|
|
746
|
+
.layout = .{ .clip_content = true },
|
|
747
|
+
.children = &.{tree},
|
|
748
|
+
};
|
|
749
|
+
var nodes: [8]canvas.WidgetLayoutNode = undefined;
|
|
750
|
+
const layout = try canvas.layoutWidgetTree(root, geometry.RectF.init(0, 0, 240, 64), &nodes);
|
|
751
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
752
|
+
const view = &harness.runtime.views[0];
|
|
753
|
+
|
|
754
|
+
// Row 3 intersects the fixed clip, but row 4 is completely outside it.
|
|
755
|
+
// Without a scroll ancestor the logical successor cannot be revealed,
|
|
756
|
+
// so the final ArrowDown must leave focus on the last visible row.
|
|
757
|
+
try std.testing.expect(layout.focusTargetById(24) == null);
|
|
758
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_down, .x = 10, .y = 40, .button = 0 } });
|
|
759
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .pointer_up, .x = 10, .y = 40, .button = 0 } });
|
|
760
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 22), view.canvas_widget_focused_id);
|
|
761
|
+
|
|
762
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
763
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 23), view.canvas_widget_focused_id);
|
|
764
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{ .window_id = 1, .label = "canvas", .kind = .key_down, .key = "arrowdown" } });
|
|
765
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 23), view.canvas_widget_focused_id);
|
|
766
|
+
}
|
|
767
|
+
|
|
540
768
|
// ------------------------------------------------------- layout tweens
|
|
541
769
|
|
|
542
770
|
/// Install the standard 0.5 split on a fresh gpu-surface view and
|
|
@@ -32,7 +32,7 @@ fn canvasWidgetLayoutNeedsLargeTextStorage(layout: canvas.WidgetLayoutTree) bool
|
|
|
32
32
|
var text_len: usize = 0;
|
|
33
33
|
for (layout.nodes) |node| {
|
|
34
34
|
const widget = node.widget;
|
|
35
|
-
if (widget.code_editor) return true;
|
|
35
|
+
if (widget.runtime_flags.code_editor) return true;
|
|
36
36
|
text_len +|= widget.text.len +| widget.icon.len +| widget.command.len +| widget.semantics.label.len;
|
|
37
37
|
for (widget.spans) |span| text_len +|= span.text.len +| span.link.len;
|
|
38
38
|
for (widget.context_menu) |item| text_len +|= item.label.len;
|
|
@@ -185,6 +185,11 @@ pub fn RuntimeCanvasWidgetState(comptime Runtime: type) type {
|
|
|
185
185
|
try self.views[index].copyCanvasWidgetSourceText(layout);
|
|
186
186
|
self.views[index].copyCanvasWidgetSourceScroll(layout);
|
|
187
187
|
self.views[index].copyCanvasWidgetSourceControls(layout);
|
|
188
|
+
// A controlled text replacement (the common submit-and-clear
|
|
189
|
+
// composer flow) drops stale selection state while retaining
|
|
190
|
+
// logical focus. Re-establish the insertion point before this
|
|
191
|
+
// rebuild emits so the caret never disappears until typing.
|
|
192
|
+
_ = try self.views[index].ensureCanvasWidgetFocusedTextCaret();
|
|
188
193
|
// Push the reconciled regions (frames, content extents,
|
|
189
194
|
// diverged offsets) to the native scroll drivers.
|
|
190
195
|
ScrollDriverMethods(Runtime).syncCanvasWidgetScrollDriversForView(self, index);
|
|
@@ -109,7 +109,7 @@ test "closing an earlier view transfers a later view's expanded text storage" {
|
|
|
109
109
|
.kind = .textarea,
|
|
110
110
|
.text = "expanded",
|
|
111
111
|
.text_no_wrap = true,
|
|
112
|
-
.code_editor = true,
|
|
112
|
+
.runtime_flags = .{ .code_editor = true },
|
|
113
113
|
};
|
|
114
114
|
var editor_nodes: [1]canvas.WidgetLayoutNode = undefined;
|
|
115
115
|
const editor_layout = try canvas.layoutWidgetTree(editor, geometry.RectF.init(0, 0, 240, 160), &editor_nodes);
|
|
@@ -2298,6 +2298,115 @@ test "plain Enter inserts a newline in a canvas textarea; chorded Enter never ed
|
|
|
2298
2298
|
} });
|
|
2299
2299
|
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
2300
2300
|
try std.testing.expectEqualStrings("First\n", retained.nodes[1].widget.text);
|
|
2301
|
+
|
|
2302
|
+
// The chat-composer policy leaves plain Enter for the UI submit
|
|
2303
|
+
// handler, so retained text does not receive a newline. Shift+Enter
|
|
2304
|
+
// remains an edit and inserts one exactly as the default textarea
|
|
2305
|
+
// does.
|
|
2306
|
+
const prompt = canvas.Widget{
|
|
2307
|
+
.id = 2,
|
|
2308
|
+
.kind = .textarea,
|
|
2309
|
+
.frame = geometry.RectF.init(12, 16, 180, 84),
|
|
2310
|
+
.text = "Prompt",
|
|
2311
|
+
.submit_on_enter = true,
|
|
2312
|
+
.semantics = .{ .label = "Message" },
|
|
2313
|
+
};
|
|
2314
|
+
var prompt_nodes: [2]canvas.WidgetLayoutNode = undefined;
|
|
2315
|
+
const prompt_layout = try canvas.layoutWidgetTree(.{ .kind = .stack, .children = &.{prompt} }, geometry.RectF.init(0, 0, 260, 160), &prompt_nodes);
|
|
2316
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", prompt_layout);
|
|
2317
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
2318
|
+
.window_id = 1,
|
|
2319
|
+
.label = "canvas",
|
|
2320
|
+
.kind = .key_down,
|
|
2321
|
+
.key = "enter",
|
|
2322
|
+
} });
|
|
2323
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
2324
|
+
try std.testing.expectEqualStrings("Prompt", retained.nodes[1].widget.text);
|
|
2325
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
2326
|
+
.window_id = 1,
|
|
2327
|
+
.label = "canvas",
|
|
2328
|
+
.kind = .key_down,
|
|
2329
|
+
.key = "enter",
|
|
2330
|
+
.modifiers = .{ .shift = true },
|
|
2331
|
+
} });
|
|
2332
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
2333
|
+
try std.testing.expectEqualStrings("Prompt\n", retained.nodes[1].widget.text);
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
test "focused textarea keeps a visible caret when controlled source clears after submit" {
|
|
2337
|
+
const TestApp = struct {
|
|
2338
|
+
fn app(self: *@This()) App {
|
|
2339
|
+
return .{ .context = self, .name = "gpu-widget-textarea-submit-clear", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
|
|
2340
|
+
}
|
|
2341
|
+
};
|
|
2342
|
+
|
|
2343
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
2344
|
+
defer harness.destroy(std.testing.allocator);
|
|
2345
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2346
|
+
var app_state: TestApp = .{};
|
|
2347
|
+
const app = app_state.app();
|
|
2348
|
+
try harness.start(app);
|
|
2349
|
+
|
|
2350
|
+
_ = try harness.runtime.createView(.{
|
|
2351
|
+
.window_id = 1,
|
|
2352
|
+
.label = "canvas",
|
|
2353
|
+
.kind = .gpu_surface,
|
|
2354
|
+
.frame = geometry.RectF.init(0, 0, 260, 160),
|
|
2355
|
+
});
|
|
2356
|
+
|
|
2357
|
+
const prompt = canvas.Widget{
|
|
2358
|
+
.id = 2,
|
|
2359
|
+
.kind = .textarea,
|
|
2360
|
+
.frame = geometry.RectF.init(12, 16, 180, 84),
|
|
2361
|
+
.text = "Prompt",
|
|
2362
|
+
.submit_on_enter = true,
|
|
2363
|
+
.semantics = .{ .label = "Message" },
|
|
2364
|
+
};
|
|
2365
|
+
var prompt_nodes: [2]canvas.WidgetLayoutNode = undefined;
|
|
2366
|
+
const prompt_layout = try canvas.layoutWidgetTree(.{ .kind = .stack, .children = &.{prompt} }, geometry.RectF.init(0, 0, 260, 160), &prompt_nodes);
|
|
2367
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", prompt_layout);
|
|
2368
|
+
_ = try harness.runtime.emitCanvasWidgetDisplayList(1, "canvas", .{});
|
|
2369
|
+
|
|
2370
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
2371
|
+
.window_id = 1,
|
|
2372
|
+
.label = "canvas",
|
|
2373
|
+
.kind = .pointer_down,
|
|
2374
|
+
.x = 100,
|
|
2375
|
+
.y = 30,
|
|
2376
|
+
} });
|
|
2377
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
2378
|
+
.window_id = 1,
|
|
2379
|
+
.label = "canvas",
|
|
2380
|
+
.kind = .key_down,
|
|
2381
|
+
.key = "enter",
|
|
2382
|
+
} });
|
|
2383
|
+
|
|
2384
|
+
var cleared_prompt = prompt;
|
|
2385
|
+
cleared_prompt.text = "";
|
|
2386
|
+
var cleared_nodes: [2]canvas.WidgetLayoutNode = undefined;
|
|
2387
|
+
const cleared_layout = try canvas.layoutWidgetTree(.{ .kind = .stack, .children = &.{cleared_prompt} }, geometry.RectF.init(0, 0, 260, 160), &cleared_nodes);
|
|
2388
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", cleared_layout);
|
|
2389
|
+
|
|
2390
|
+
const retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
2391
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), harness.runtime.views[0].canvas_widget_focused_id);
|
|
2392
|
+
try std.testing.expectEqual(@as(canvas.ObjectId, 2), harness.runtime.views[0].canvas_widget_focus_visible_id);
|
|
2393
|
+
try std.testing.expectEqualStrings("", retained.nodes[1].widget.text);
|
|
2394
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), retained.nodes[1].widget.text_selection.?);
|
|
2395
|
+
try std.testing.expectEqualDeep(canvas.TextRange.init(0, 0), runtimeViewWidgetSemantics(&harness.runtime.views[0])[0].text_selection.?);
|
|
2396
|
+
|
|
2397
|
+
_ = try harness.runtime.emitCanvasWidgetDisplayList(1, "canvas", .{});
|
|
2398
|
+
const display_list = try harness.runtime.canvasDisplayList(1, "canvas");
|
|
2399
|
+
var saw_caret = false;
|
|
2400
|
+
for (display_list.commands) |command| {
|
|
2401
|
+
switch (command) {
|
|
2402
|
+
.fill_rect => |fill| {
|
|
2403
|
+
if (fill.id == testCanvasWidgetPartId(2, 6)) saw_caret = true;
|
|
2404
|
+
},
|
|
2405
|
+
else => {},
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
try std.testing.expect(saw_caret);
|
|
2409
|
+
try std.testing.expectEqual(testCanvasWidgetPartId(2, 6), harness.runtime.views[0].canvas_widget_caret_blink_id);
|
|
2301
2410
|
}
|
|
2302
2411
|
|
|
2303
2412
|
test "Enter in a single-line input never inserts, even when the host stuffs a newline into the key event" {
|
|
@@ -3906,7 +4015,7 @@ test "editable code owns plain Tab and stamps its inferred indentation edit" {
|
|
|
3906
4015
|
.{
|
|
3907
4016
|
.id = 2,
|
|
3908
4017
|
.kind = .textarea,
|
|
3909
|
-
.code_editor = true,
|
|
4018
|
+
.runtime_flags = .{ .code_editor = true },
|
|
3910
4019
|
.text_no_wrap = true,
|
|
3911
4020
|
.frame = geometry.RectF.init(12, 16, 220, 100),
|
|
3912
4021
|
.text = source,
|
|
@@ -4620,7 +4729,7 @@ test "runtime scrolls editable no-wrap code horizontally and retains both axes"
|
|
|
4620
4729
|
const editor = canvas.Widget{
|
|
4621
4730
|
.id = 2,
|
|
4622
4731
|
.kind = .textarea,
|
|
4623
|
-
.code_editor = true,
|
|
4732
|
+
.runtime_flags = .{ .code_editor = true },
|
|
4624
4733
|
.code_line_number_digits = 2,
|
|
4625
4734
|
.text_no_wrap = true,
|
|
4626
4735
|
.frame = geometry.RectF.init(12, 16, 120, 72),
|
package/src/runtime/clock.zig
CHANGED
|
@@ -187,7 +187,11 @@ pub fn timestampToU64(value: i128) u64 {
|
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
pub fn automationInputTimestampNs() u64 {
|
|
190
|
-
|
|
190
|
+
// Automation input participates in the same duration math as native
|
|
191
|
+
// host input and presented-frame timestamps. Keep it in the monotonic
|
|
192
|
+
// domain: wall time can jump, and on Windows/Linux the hosts already
|
|
193
|
+
// stamp GPU events from QPC/CLOCK_MONOTONIC.
|
|
194
|
+
return monotonicNanoseconds();
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
test "the real clocks read plausible, ordered values" {
|
|
@@ -205,6 +209,14 @@ test "the real clocks read plausible, ordered values" {
|
|
|
205
209
|
try std.testing.expect(second >= first);
|
|
206
210
|
}
|
|
207
211
|
|
|
212
|
+
test "automation input timestamps share the monotonic clock domain" {
|
|
213
|
+
const before = monotonicNanoseconds();
|
|
214
|
+
const timestamp = automationInputTimestampNs();
|
|
215
|
+
const after = monotonicNanoseconds();
|
|
216
|
+
try std.testing.expect(timestamp >= before);
|
|
217
|
+
try std.testing.expect(timestamp <= after);
|
|
218
|
+
}
|
|
219
|
+
|
|
208
220
|
test "Clock.system reads the real clocks and Clock{} is the same seam" {
|
|
209
221
|
const clock: Clock = .system;
|
|
210
222
|
try std.testing.expect(clock.wallMs() > 1_577_836_800_000);
|