@native-sdk/cli 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +273 -37
- package/build/ts_run.mjs +15 -18
- package/build.zig +141 -9
- package/package.json +13 -10
- package/packages/core/compile-surface/core.ts +1 -0
- package/packages/core/package-lock.json +16 -13
- package/packages/core/package.json +5 -2
- package/packages/core/scripts/compiler_command.mjs +71 -0
- package/packages/core/scripts/compiler_typecheck.mjs +4 -4
- package/packages/core/scripts/embed_markup_c.mjs +25 -0
- package/packages/core/scripts/npm_static_spike.mjs +3 -3
- package/packages/core/scripts/run_external_core_compiler.mjs +4 -3
- package/packages/core/scripts/run_external_service_compiler.mjs +2 -1
- package/packages/core/sdk/core.ts +1 -0
- package/packages/core/sdk/events.d.ts +10 -0
- package/packages/core/sdk/events.ts +30 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +61 -3
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +5 -2
- package/skill-data/ts-core/SKILL.md +10 -4
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/src/app_runner/root.zig +208 -6
- package/src/app_runner/ts_core_main.zig +14 -4
- package/src/app_runner/ts_core_mobile.zig +6 -2
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/platform/macos/appkit_host.m +79 -12
- package/src/platform/macos/root.zig +68 -5
- package/src/primitives/canvas/events.zig +79 -1
- package/src/primitives/canvas/root.zig +1 -0
- package/src/primitives/canvas/text_interaction.zig +23 -0
- package/src/primitives/canvas/text_tests.zig +45 -0
- package/src/primitives/canvas/ui.zig +11 -8
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +3 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- package/src/primitives/canvas/ui_markup_view_tests.zig +18 -2
- package/src/primitives/canvas/ui_tests.zig +37 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +13 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/canvas_widget_control_tests.zig +2 -0
- package/src/runtime/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/ts_ui_app.zig +184 -7
- package/src/runtime/ui_app.zig +98 -18
- package/src/runtime/ui_app_tests.zig +232 -13
- package/src/runtime/ui_app_window_tests.zig +23 -0
- package/src/runtime/view_widget_text.zig +1 -1
- package/src/tooling/templates.zig +6 -2
- package/src/tooling/ts_core.zig +1 -1
- package/src/tooling/verbs.zig +228 -0
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/emit_profile.zig +20 -7
- package/tools/corewire/emit_service.zig +49 -24
- package/tools/corewire/main.zig +21 -2
- package/tools/corewire/shim_rt.zig +20 -0
|
@@ -2214,7 +2214,7 @@ pub const catalog_markup_source =
|
|
|
2214
2214
|
\\ </row>
|
|
2215
2215
|
\\ <row gap="8">
|
|
2216
2216
|
\\ <input text="{query}" placeholder="Name" autofocus="true" on-input="query_edit" on-submit="submit_query" grow="1" />
|
|
2217
|
-
\\ <combobox text="{query}" placeholder="Search fruit" on-input="query_edit" />
|
|
2217
|
+
\\ <combobox text="{query}" placeholder="Search fruit" on-input="query_edit" on-press="open_picker" on-submit="submit_query" />
|
|
2218
2218
|
\\ </row>
|
|
2219
2219
|
\\ <radio-group gap="4" label="Formatting">
|
|
2220
2220
|
\\ <radio checked="{bold}" on-change="toggle_bold" label="Bold" />
|
|
@@ -2344,7 +2344,7 @@ pub fn handCatalogView(ui: *CatalogUi, model: *const CatalogModel) CatalogUi.Nod
|
|
|
2344
2344
|
}),
|
|
2345
2345
|
ui.row(.{ .gap = 8 }, .{
|
|
2346
2346
|
ui.el(.input, .{ .text = model.query, .placeholder = "Name", .autofocus = true, .on_input = CatalogUi.inputMsg(.query_edit), .on_submit = .submit_query, .grow = 1 }, .{}),
|
|
2347
|
-
ui.el(.combobox, .{ .text = model.query, .placeholder = "Search fruit", .on_input = CatalogUi.inputMsg(.query_edit) }, .{}),
|
|
2347
|
+
ui.el(.combobox, .{ .text = model.query, .placeholder = "Search fruit", .on_input = CatalogUi.inputMsg(.query_edit), .on_press = .open_picker, .on_submit = .submit_query }, .{}),
|
|
2348
2348
|
}),
|
|
2349
2349
|
ui.el(.radio_group, .{ .gap = 4, .semantics = .{ .label = "Formatting" } }, .{
|
|
2350
2350
|
ui.el(.radio, .{ .checked = model.bold, .on_change = .toggle_bold }, .{}),
|
|
@@ -2489,6 +2489,10 @@ test "catalog elements build the hand-written tree and dispatch typed messages"
|
|
|
2489
2489
|
try testing.expectEqualStrings("q", markup_tree.msgForKeyboard(input.id, typed).?.query_edit.insert_text);
|
|
2490
2490
|
const submit = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "enter" };
|
|
2491
2491
|
try testing.expectEqual(CatalogMsg.submit_query, markup_tree.msgForKeyboard(input.id, submit).?);
|
|
2492
|
+
const combobox = findByKind(markup_tree.root, .combobox).?;
|
|
2493
|
+
try testing.expectEqual(CatalogMsg.submit_query, markup_tree.msgForKeyboard(combobox.id, submit).?);
|
|
2494
|
+
try testing.expectEqual(CatalogMsg.open_picker, markup_tree.msgForKeyboard(combobox.id, .{ .phase = .key_down, .key = "space" }).?);
|
|
2495
|
+
try testing.expectEqual(CatalogMsg.open_picker, markup_tree.msgForKeyboard(combobox.id, .{ .phase = .key_down, .key = "arrowdown" }).?);
|
|
2492
2496
|
|
|
2493
2497
|
// The whole catalog lays out through the canvas engine.
|
|
2494
2498
|
var nodes: [256]canvas.WidgetLayoutNode = undefined;
|
|
@@ -4660,6 +4664,8 @@ pub const MirrorTextInputEvent = union(enum) {
|
|
|
4660
4664
|
delete_forward,
|
|
4661
4665
|
delete_word_backward,
|
|
4662
4666
|
delete_word_forward,
|
|
4667
|
+
delete_to_start,
|
|
4668
|
+
delete_to_line_start,
|
|
4663
4669
|
clear,
|
|
4664
4670
|
move_caret: MirrorCaretMove,
|
|
4665
4671
|
set_selection: MirrorSelection,
|
|
@@ -4687,6 +4693,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4687
4693
|
delete_forward,
|
|
4688
4694
|
delete_word_backward,
|
|
4689
4695
|
delete_word_forward,
|
|
4696
|
+
delete_to_start,
|
|
4697
|
+
delete_to_line_start,
|
|
4690
4698
|
clear,
|
|
4691
4699
|
move_caret: MirrorCaretMove,
|
|
4692
4700
|
set_selection: MirrorSelectionWithAffinity,
|
|
@@ -4703,6 +4711,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4703
4711
|
delete_forward,
|
|
4704
4712
|
delete_word_backward,
|
|
4705
4713
|
delete_word_forward,
|
|
4714
|
+
delete_to_start,
|
|
4715
|
+
delete_to_line_start,
|
|
4706
4716
|
clear,
|
|
4707
4717
|
move_caret: MirrorCaretMove,
|
|
4708
4718
|
set_selection: MirrorSelection,
|
|
@@ -4716,6 +4726,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4716
4726
|
delete_forward,
|
|
4717
4727
|
delete_word_backward,
|
|
4718
4728
|
delete_word_forward,
|
|
4729
|
+
delete_to_start,
|
|
4730
|
+
delete_to_line_start,
|
|
4719
4731
|
clear,
|
|
4720
4732
|
move_caret: MirrorCaretMove,
|
|
4721
4733
|
set_selection: MirrorSelection,
|
|
@@ -4731,6 +4743,8 @@ test "declaredTextInputUnion accepts the emitted mirror shape and rejects near-m
|
|
|
4731
4743
|
delete_forward,
|
|
4732
4744
|
delete_word_backward,
|
|
4733
4745
|
delete_word_forward,
|
|
4746
|
+
delete_to_start,
|
|
4747
|
+
delete_to_line_start,
|
|
4734
4748
|
clear,
|
|
4735
4749
|
move_caret: struct { direction: WrongDirection, extend: bool },
|
|
4736
4750
|
set_selection: MirrorSelection,
|
|
@@ -4984,6 +4998,8 @@ test "the interpreter binds on-input to a declared mirror union and translates e
|
|
|
4984
4998
|
try testing.expectEqualStrings("abc", inserted.edit.insert_text);
|
|
4985
4999
|
// Void verbs map by tag.
|
|
4986
5000
|
try testing.expectEqual(MirrorTextInputEvent.delete_backward, tree.msgForTextEdit(field.id, .delete_backward).?.edit);
|
|
5001
|
+
try testing.expectEqual(MirrorTextInputEvent.delete_to_start, tree.msgForTextEdit(field.id, .delete_to_start).?.edit);
|
|
5002
|
+
try testing.expectEqual(MirrorTextInputEvent.delete_to_line_start, tree.msgForTextEdit(field.id, .delete_to_line_start).?.edit);
|
|
4987
5003
|
// Caret moves translate the direction enum by member name.
|
|
4988
5004
|
const moved = tree.msgForTextEdit(field.id, .{ .move_caret = .{ .direction = .previous_word, .extend = true } }).?;
|
|
4989
5005
|
try testing.expectEqual(MirrorCaretDirection.previous_word, moved.edit.move_caret.direction);
|
|
@@ -349,6 +349,43 @@ test "keyboard events resolve activation and submit messages" {
|
|
|
349
349
|
try testing.expectEqual(@as(?Msg, null), tree.msgForKeyboard(checkbox.id, letter));
|
|
350
350
|
}
|
|
351
351
|
|
|
352
|
+
test "combobox Enter prefers submit while its other open keys still press" {
|
|
353
|
+
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
354
|
+
defer arena_state.deinit();
|
|
355
|
+
|
|
356
|
+
var ui = InboxUi.init(arena_state.allocator());
|
|
357
|
+
const tree = try ui.finalize(ui.column(.{}, .{
|
|
358
|
+
ui.el(.combobox, .{
|
|
359
|
+
.text = "both handlers",
|
|
360
|
+
.on_press = .load_more,
|
|
361
|
+
.on_submit = .add,
|
|
362
|
+
}, .{}),
|
|
363
|
+
ui.el(.combobox, .{
|
|
364
|
+
.text = "press only",
|
|
365
|
+
.on_press = .load_more,
|
|
366
|
+
}, .{}),
|
|
367
|
+
ui.el(.combobox, .{
|
|
368
|
+
.text = "submit only",
|
|
369
|
+
.on_submit = .add,
|
|
370
|
+
}, .{}),
|
|
371
|
+
}));
|
|
372
|
+
|
|
373
|
+
const both = tree.root.children[0];
|
|
374
|
+
const press_only = tree.root.children[1];
|
|
375
|
+
const submit_only = tree.root.children[2];
|
|
376
|
+
const enter = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "enter" };
|
|
377
|
+
const space = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "space" };
|
|
378
|
+
const arrow_down = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "arrowdown" };
|
|
379
|
+
const arrow_up = canvas.WidgetKeyboardEvent{ .phase = .key_down, .key = "arrowup" };
|
|
380
|
+
|
|
381
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(both.id, enter).?);
|
|
382
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, space).?);
|
|
383
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, arrow_down).?);
|
|
384
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(both.id, arrow_up).?);
|
|
385
|
+
try testing.expectEqual(Msg.load_more, tree.msgForKeyboard(press_only.id, enter).?);
|
|
386
|
+
try testing.expectEqual(Msg.add, tree.msgForKeyboard(submit_only.id, enter).?);
|
|
387
|
+
}
|
|
388
|
+
|
|
352
389
|
test "tree keyboard navigation can select without dispatching pointer activation" {
|
|
353
390
|
var arena_state = std.heap.ArenaAllocator.init(testing.allocator);
|
|
354
391
|
defer arena_state.deinit();
|
|
@@ -2403,6 +2403,19 @@ test "the accent override desaturates its dark-scheme focus ring" {
|
|
|
2403
2403
|
try std.testing.expectEqualDeep(gray, canvas.accentFocusRing(gray, .dark));
|
|
2404
2404
|
}
|
|
2405
2405
|
|
|
2406
|
+
test "accent overrides compose over either built-in pack without moving unrelated tokens" {
|
|
2407
|
+
const accent = Color.rgb8(0, 120, 111);
|
|
2408
|
+
for ([_]canvas.ThemePack{ .house, .geist }) |pack| {
|
|
2409
|
+
const base = DesignTokens.theme(.{ .pack = pack, .color_scheme = .dark });
|
|
2410
|
+
const branded = base.withOverrides(canvas.accentOverrides(accent, .dark));
|
|
2411
|
+
try std.testing.expectEqualDeep(accent, branded.colors.accent);
|
|
2412
|
+
try std.testing.expectEqualDeep(canvas.accentFocusRing(accent, .dark), branded.colors.focus_ring);
|
|
2413
|
+
try std.testing.expectEqualDeep(accent, branded.controls.slider.active_background);
|
|
2414
|
+
try std.testing.expectEqual(base.metrics.control_height, branded.metrics.control_height);
|
|
2415
|
+
try std.testing.expectEqualDeep(base.colors.background, branded.colors.background);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2406
2419
|
test "the dark accent focus ring holds the non-text contrast floor across hues" {
|
|
2407
2420
|
// Rings draw OUTSIDE controls, so the tones that matter are the
|
|
2408
2421
|
// dark containers controls commonly sit on, across BOTH shipped
|
|
@@ -30,6 +30,8 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
30
30
|
.windows = self.automation_windows[0..1],
|
|
31
31
|
.views = &.{},
|
|
32
32
|
.widgets = &.{},
|
|
33
|
+
.commands = self.options.commands,
|
|
34
|
+
.menus = self.options.menus,
|
|
33
35
|
.diagnostics = automationDiagnostics(self),
|
|
34
36
|
.frame_profile = automationFrameProfile(self),
|
|
35
37
|
.trays = automationTrays(self),
|
|
@@ -64,6 +66,8 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
64
66
|
.windows = self.automation_windows[0..count],
|
|
65
67
|
.views = self.automation_views[0..view_count],
|
|
66
68
|
.widgets = self.automation_widgets[0..widget_count],
|
|
69
|
+
.commands = self.options.commands,
|
|
70
|
+
.menus = self.options.menus,
|
|
67
71
|
.diagnostics = automationDiagnostics(self),
|
|
68
72
|
.frame_profile = automationFrameProfile(self),
|
|
69
73
|
.trays = automationTrays(self),
|
|
@@ -2182,6 +2182,8 @@ test "runtime dispatches canvas widget commands from pointer and keyboard activa
|
|
|
2182
2182
|
try std.testing.expectEqual(@as(u32, 6), app_state.command_count);
|
|
2183
2183
|
|
|
2184
2184
|
harness.runtime.views[0].canvas_widget_focused_id = 6;
|
|
2185
|
+
// Command-string widgets have no typed on-submit channel, so their
|
|
2186
|
+
// combobox Enter behavior intentionally remains trigger activation.
|
|
2185
2187
|
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
2186
2188
|
.window_id = 1,
|
|
2187
2189
|
.label = "canvas",
|
|
@@ -1401,6 +1401,57 @@ test "single-line history replay restores exact retained bytes" {
|
|
|
1401
1401
|
try std.testing.expect(harness.runtime.views[0].canvasWidgetTextHistoryAvailability(2).can_redo);
|
|
1402
1402
|
}
|
|
1403
1403
|
|
|
1404
|
+
test "macOS Command Backspace treats model-provided newlines as single-line presentation bytes" {
|
|
1405
|
+
if (comptime builtin.os.tag != .macos) return error.SkipZigTest;
|
|
1406
|
+
|
|
1407
|
+
const TestApp = struct {
|
|
1408
|
+
fn app(self: *@This()) App {
|
|
1409
|
+
return .{ .context = self, .name = "gpu-widget-input-command-backspace-raw-newline", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
1414
|
+
defer harness.destroy(std.testing.allocator);
|
|
1415
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1416
|
+
var app_state: TestApp = .{};
|
|
1417
|
+
const app = app_state.app();
|
|
1418
|
+
try harness.start(app);
|
|
1419
|
+
_ = try harness.runtime.createView(.{
|
|
1420
|
+
.window_id = 1,
|
|
1421
|
+
.label = "canvas",
|
|
1422
|
+
.kind = .gpu_surface,
|
|
1423
|
+
.frame = geometry.RectF.init(0, 0, 240, 100),
|
|
1424
|
+
});
|
|
1425
|
+
|
|
1426
|
+
var nodes: [2]canvas.WidgetLayoutNode = undefined;
|
|
1427
|
+
const layout = try canvas.layoutWidgetTree(.{ .kind = .stack, .children = &.{canvas.Widget{
|
|
1428
|
+
.id = 2,
|
|
1429
|
+
.kind = .input,
|
|
1430
|
+
.frame = geometry.RectF.init(12, 16, 180, 32),
|
|
1431
|
+
.text = "one\ntwo",
|
|
1432
|
+
.text_selection = canvas.TextSelection.collapsed(7),
|
|
1433
|
+
}} }, geometry.RectF.init(0, 0, 240, 100), &nodes);
|
|
1434
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
1435
|
+
harness.runtime.views[0].focused = true;
|
|
1436
|
+
harness.runtime.views[0].canvas_widget_focused_id = 2;
|
|
1437
|
+
|
|
1438
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
1439
|
+
.window_id = 1,
|
|
1440
|
+
.label = "canvas",
|
|
1441
|
+
.kind = .key_down,
|
|
1442
|
+
.key = "backspace",
|
|
1443
|
+
.modifiers = .{ .command = true, .shift = true },
|
|
1444
|
+
} });
|
|
1445
|
+
|
|
1446
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
1447
|
+
try std.testing.expectEqualStrings("", retained.nodes[1].widget.text);
|
|
1448
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), retained.nodes[1].widget.text_selection.?);
|
|
1449
|
+
try dispatchTextareaHistoryShortcut(harness, app, false);
|
|
1450
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
1451
|
+
try std.testing.expectEqualStrings("one\ntwo", retained.nodes[1].widget.text);
|
|
1452
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(7), retained.nodes[1].widget.text_selection.?);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1404
1455
|
test "textarea history replays newly completed CRLF atomically" {
|
|
1405
1456
|
const TestApp = struct {
|
|
1406
1457
|
fn app(self: *@This()) App {
|
|
@@ -1838,6 +1889,79 @@ test "canvas textareas undo and redo keyboard edits" {
|
|
|
1838
1889
|
try std.testing.expectEqualStrings("external!", retained.nodes[1].widget.text);
|
|
1839
1890
|
}
|
|
1840
1891
|
|
|
1892
|
+
test "macOS Command Backspace deletes to line start in every editable text kind and undoes as one step" {
|
|
1893
|
+
if (comptime builtin.os.tag != .macos) return error.SkipZigTest;
|
|
1894
|
+
|
|
1895
|
+
const TestApp = struct {
|
|
1896
|
+
fn app(self: *@This()) App {
|
|
1897
|
+
return .{ .context = self, .name = "gpu-widget-command-backspace", .source = platform.WebViewSource.html("<h1>Hello</h1>") };
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
1902
|
+
defer harness.destroy(std.testing.allocator);
|
|
1903
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1904
|
+
var app_state: TestApp = .{};
|
|
1905
|
+
const app = app_state.app();
|
|
1906
|
+
try harness.start(app);
|
|
1907
|
+
_ = try harness.runtime.createView(.{
|
|
1908
|
+
.window_id = 1,
|
|
1909
|
+
.label = "canvas",
|
|
1910
|
+
.kind = .gpu_surface,
|
|
1911
|
+
.frame = geometry.RectF.init(0, 0, 520, 280),
|
|
1912
|
+
});
|
|
1913
|
+
|
|
1914
|
+
const kinds = [_]canvas.WidgetKind{ .input, .text_field, .search_field, .combobox, .textarea };
|
|
1915
|
+
var children: [kinds.len]canvas.Widget = undefined;
|
|
1916
|
+
for (&children, kinds, 0..) |*child, kind, index| {
|
|
1917
|
+
child.* = .{
|
|
1918
|
+
.id = @intCast(index + 2),
|
|
1919
|
+
.kind = kind,
|
|
1920
|
+
.frame = geometry.RectF.init(12, @floatFromInt(12 + index * 46), 260, 36),
|
|
1921
|
+
.text = if (kind == .textarea) "first\nsecond line" else "second line",
|
|
1922
|
+
.text_selection = canvas.TextSelection.collapsed(if (kind == .textarea) 12 else 6),
|
|
1923
|
+
.semantics = .{ .label = "Editor" },
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
var nodes: [kinds.len + 1]canvas.WidgetLayoutNode = undefined;
|
|
1927
|
+
const layout = try canvas.layoutWidgetTree(
|
|
1928
|
+
.{ .kind = .stack, .children = &children },
|
|
1929
|
+
geometry.RectF.init(0, 0, 520, 280),
|
|
1930
|
+
&nodes,
|
|
1931
|
+
);
|
|
1932
|
+
_ = try harness.runtime.setCanvasWidgetLayout(1, "canvas", layout);
|
|
1933
|
+
|
|
1934
|
+
for (kinds, 0..) |kind, index| {
|
|
1935
|
+
const id: canvas.ObjectId = @intCast(index + 2);
|
|
1936
|
+
harness.runtime.views[0].focused = true;
|
|
1937
|
+
harness.runtime.views[0].canvas_widget_focused_id = id;
|
|
1938
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
1939
|
+
.window_id = 1,
|
|
1940
|
+
.label = "canvas",
|
|
1941
|
+
.kind = .key_down,
|
|
1942
|
+
.key = "backspace",
|
|
1943
|
+
.modifiers = .{ .command = true },
|
|
1944
|
+
} });
|
|
1945
|
+
|
|
1946
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
1947
|
+
const edited = retained.findById(id).?.widget;
|
|
1948
|
+
try std.testing.expectEqualStrings(if (kind == .textarea) "first\n line" else " line", edited.text);
|
|
1949
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(if (kind == .textarea) 6 else 0), edited.text_selection.?);
|
|
1950
|
+
|
|
1951
|
+
try dispatchTextareaHistoryShortcut(harness, app, false);
|
|
1952
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
1953
|
+
const undone = retained.findById(id).?.widget;
|
|
1954
|
+
try std.testing.expectEqualStrings(if (kind == .textarea) "first\nsecond line" else "second line", undone.text);
|
|
1955
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(if (kind == .textarea) 12 else 6), undone.text_selection.?);
|
|
1956
|
+
|
|
1957
|
+
try dispatchTextareaHistoryShortcut(harness, app, true);
|
|
1958
|
+
retained = try harness.runtime.canvasWidgetLayout(1, "canvas");
|
|
1959
|
+
const redone = retained.findById(id).?.widget;
|
|
1960
|
+
try std.testing.expectEqualStrings(if (kind == .textarea) "first\n line" else " line", redone.text);
|
|
1961
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(if (kind == .textarea) 6 else 0), redone.text_selection.?);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1841
1965
|
test "compound editor history reroutes every continuation after controlled rebuilds" {
|
|
1842
1966
|
const TestApp = struct {
|
|
1843
1967
|
replay_count: usize = 0,
|
|
@@ -253,6 +253,35 @@ test "runtime dispatches menu command events" {
|
|
|
253
253
|
try std.testing.expectEqual(@as(platform.WindowId, 1), app_state.last_window_id);
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
test "automation snapshot exposes configured app menus" {
|
|
257
|
+
const items = [_]platform.MenuItem{
|
|
258
|
+
.{ .label = "Refresh", .command = "app.refresh" },
|
|
259
|
+
.{ .label = "Disabled", .command = "app.disabled", .enabled = false },
|
|
260
|
+
.{ .separator = true },
|
|
261
|
+
};
|
|
262
|
+
const menus = [_]platform.Menu{
|
|
263
|
+
.{ .title = "View", .items = &items },
|
|
264
|
+
};
|
|
265
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
266
|
+
defer harness.destroy(std.testing.allocator);
|
|
267
|
+
harness.runtime.options.menus = &menus;
|
|
268
|
+
const snapshot = harness.runtime.automationSnapshot("Menus");
|
|
269
|
+
try std.testing.expectEqual(@as(usize, 1), snapshot.menus.len);
|
|
270
|
+
try std.testing.expectEqualStrings("View", snapshot.menus[0].title);
|
|
271
|
+
try std.testing.expectEqual(@as(usize, 3), snapshot.menus[0].items.len);
|
|
272
|
+
try std.testing.expectEqualStrings("app.refresh", snapshot.menus[0].items[0].command);
|
|
273
|
+
try std.testing.expect(!snapshot.menus[0].items[1].enabled);
|
|
274
|
+
try std.testing.expect(snapshot.menus[0].items[2].separator);
|
|
275
|
+
|
|
276
|
+
var buffer: [2048]u8 = undefined;
|
|
277
|
+
var writer = std.Io.Writer.fixed(&buffer);
|
|
278
|
+
try automation.snapshot.writeText(snapshot, &writer);
|
|
279
|
+
const text = writer.buffered();
|
|
280
|
+
try std.testing.expect(std.mem.indexOf(u8, text, "app-menu title=\"View\" items=3\n") != null);
|
|
281
|
+
try std.testing.expect(std.mem.indexOf(u8, text, " app-menu-item label=\"Refresh\" command=\"app.refresh\" enabled=true checked=false key=\"\"") != null);
|
|
282
|
+
try std.testing.expect(std.mem.indexOf(u8, text, " app-menu-item separator\n") != null);
|
|
283
|
+
}
|
|
284
|
+
|
|
256
285
|
test "runtime dispatches tray item commands" {
|
|
257
286
|
const TestApp = struct {
|
|
258
287
|
command_count: u32 = 0,
|
|
@@ -133,8 +133,12 @@ pub const format_fingerprint: u64 = layout_fingerprint.hash(formatLayoutDescript
|
|
|
133
133
|
/// out-of-window audio record as journal damage — an older recording
|
|
134
134
|
/// could journal a wider value the old feed paths accepted, which
|
|
135
135
|
/// would now be misreported as damage instead of refusing as a
|
|
136
|
-
/// different generation.
|
|
137
|
-
|
|
136
|
+
/// different generation. Epoch 6: macOS Command+Backspace gained its
|
|
137
|
+
/// platform text-editor meaning (delete to field start in single-line
|
|
138
|
+
/// editors, or hard line start in textareas). The raw gpu-surface key record
|
|
139
|
+
/// is byte-identical, but replay now derives a text edit where older builds
|
|
140
|
+
/// derived none.
|
|
141
|
+
pub const format_semantic_epoch: u32 = 6;
|
|
138
142
|
|
|
139
143
|
/// The canonical description `format_fingerprint` hashes: everything
|
|
140
144
|
/// that defines the on-disk record layout. Reflection covers the record
|
|
@@ -1611,6 +1615,21 @@ test "event codec round-trips every payload variant" {
|
|
|
1611
1615
|
try testing.expect(decoded.gpu_surface_input.modifiers.control);
|
|
1612
1616
|
try testing.expectEqual(@as(f32, 0), decoded.gpu_surface_input.scale);
|
|
1613
1617
|
}
|
|
1618
|
+
{
|
|
1619
|
+
// Command+Backspace journals as the raw platform key chord; replay
|
|
1620
|
+
// re-derives the semantic delete_to_start/delete_to_line_start edit
|
|
1621
|
+
// from the focused widget kind.
|
|
1622
|
+
const decoded = try roundTripEvent(.{ .gpu_surface_input = .{
|
|
1623
|
+
.label = "editor-canvas",
|
|
1624
|
+
.kind = .key_down,
|
|
1625
|
+
.key = "backspace",
|
|
1626
|
+
.modifiers = .{ .primary = true, .command = true },
|
|
1627
|
+
} });
|
|
1628
|
+
try testing.expectEqualStrings("backspace", decoded.gpu_surface_input.key);
|
|
1629
|
+
try testing.expect(decoded.gpu_surface_input.modifiers.primary);
|
|
1630
|
+
try testing.expect(decoded.gpu_surface_input.modifiers.command);
|
|
1631
|
+
try testing.expect(!decoded.gpu_surface_input.modifiers.control);
|
|
1632
|
+
}
|
|
1614
1633
|
{
|
|
1615
1634
|
// v5: pinch records carry the magnification delta and the
|
|
1616
1635
|
// gesture kinds appended at codes 12-14.
|