@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
|
@@ -47,6 +47,18 @@ fn counterThemePack(model: *const CounterModel) canvas.ThemePack {
|
|
|
47
47
|
return if (model.count == 0) .house else .geist;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
fn counterThemeState(model: *const CounterModel) CounterApp.ThemeState {
|
|
51
|
+
return switch (model.count) {
|
|
52
|
+
0 => .{ .color_scheme = .dark },
|
|
53
|
+
1 => .{ .pack = .geist, .color_scheme = .system, .accent = canvas.Color.rgb8(0, 0x78, 0x6f) },
|
|
54
|
+
else => .{ .pack = .house, .color_scheme = .light, .accent = canvas.Color.rgb8(0xdf, 0x26, 0x70) },
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fn invalidCounterThemeState(_: *const CounterModel) CounterApp.ThemeState {
|
|
59
|
+
return .{ .invalid_accent = "pink" };
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
const counter_views = [_]app_manifest.ShellView{
|
|
51
63
|
.{ .label = canvas_label, .kind = .gpu_surface, .fill = true, .gpu_backend = .metal },
|
|
52
64
|
};
|
|
@@ -1920,6 +1932,117 @@ test "model-derived theme packs retain live appearance, accent, and surface scal
|
|
|
1920
1932
|
try std.testing.expectEqual(@as(f32, 2), actual.pixel_snap.scale);
|
|
1921
1933
|
}
|
|
1922
1934
|
|
|
1935
|
+
test "model-derived theme state composes forced/system schemes and model accent over manifest defaults" {
|
|
1936
|
+
var options = counterOptions();
|
|
1937
|
+
options.theme = .house;
|
|
1938
|
+
options.theme_accent = canvas.Color.rgb8(0x12, 0x34, 0x56);
|
|
1939
|
+
options.theme_state_fn = counterThemeState;
|
|
1940
|
+
|
|
1941
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1942
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1943
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1944
|
+
defer app_state.deinit();
|
|
1945
|
+
app_state.system_appearance = .{ .color_scheme = .light };
|
|
1946
|
+
app_state.pixel_snap_scale = 2;
|
|
1947
|
+
|
|
1948
|
+
// Model-forced dark wins over an OS-light appearance; omitted pack and
|
|
1949
|
+
// accent inherit the manifest-backed options.
|
|
1950
|
+
var expected = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .pack = .house });
|
|
1951
|
+
expected = expected.withOverrides(canvas.accentOverrides(options.theme_accent.?, .dark));
|
|
1952
|
+
var actual = app_state.effectiveTokens();
|
|
1953
|
+
try std.testing.expectEqualDeep(expected.colors.background, actual.colors.background);
|
|
1954
|
+
try std.testing.expectEqualDeep(expected.colors.accent, actual.colors.accent);
|
|
1955
|
+
try std.testing.expectEqual(@as(f32, 2), actual.pixel_snap.scale);
|
|
1956
|
+
|
|
1957
|
+
// `system` resumes live OS following while model pack/accent override the
|
|
1958
|
+
// manifest values.
|
|
1959
|
+
app_state.model.count = 1;
|
|
1960
|
+
app_state.theme_state_known = false;
|
|
1961
|
+
app_state.system_appearance = .{ .color_scheme = .dark };
|
|
1962
|
+
const teal = canvas.Color.rgb8(0, 0x78, 0x6f);
|
|
1963
|
+
expected = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .pack = .geist });
|
|
1964
|
+
expected = expected.withOverrides(canvas.accentOverrides(teal, .dark));
|
|
1965
|
+
actual = app_state.effectiveTokens();
|
|
1966
|
+
try std.testing.expectEqualDeep(expected.colors.background, actual.colors.background);
|
|
1967
|
+
try std.testing.expectEqualDeep(teal, actual.colors.accent);
|
|
1968
|
+
try std.testing.expectEqualDeep(canvas.accentFocusRing(teal, .dark), actual.colors.focus_ring);
|
|
1969
|
+
|
|
1970
|
+
// High contrast keeps the existing accessibility rule: neither the
|
|
1971
|
+
// model nor manifest accent layers over the pack's loud register.
|
|
1972
|
+
app_state.system_appearance.high_contrast = true;
|
|
1973
|
+
actual = app_state.effectiveTokens();
|
|
1974
|
+
const loud = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .contrast = .high, .pack = .geist });
|
|
1975
|
+
try std.testing.expectEqualDeep(loud.colors.accent, actual.colors.accent);
|
|
1976
|
+
try std.testing.expect(!std.meta.eql(teal, actual.colors.accent));
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
test "malformed adapter theme accents reject the rebuild instead of inheriting silently" {
|
|
1980
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1981
|
+
defer harness.destroy(std.testing.allocator);
|
|
1982
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1983
|
+
var options = counterOptions();
|
|
1984
|
+
options.theme_state_fn = invalidCounterThemeState;
|
|
1985
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1986
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1987
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1988
|
+
defer app_state.deinit();
|
|
1989
|
+
const app = app_state.app();
|
|
1990
|
+
try harness.start(app);
|
|
1991
|
+
try std.testing.expectError(error.InvalidThemeAccent, harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1992
|
+
.label = canvas_label,
|
|
1993
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1994
|
+
.scale_factor = 1,
|
|
1995
|
+
.frame_index = 1,
|
|
1996
|
+
.timestamp_ns = 1_000_000,
|
|
1997
|
+
.nonblank = true,
|
|
1998
|
+
} }));
|
|
1999
|
+
try std.testing.expect(!app_state.installed);
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
test "forced theme state still follows accessibility axes while scheme-only OS flips do not restyle" {
|
|
2003
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
2004
|
+
defer harness.destroy(std.testing.allocator);
|
|
2005
|
+
harness.null_platform.gpu_surfaces = true;
|
|
2006
|
+
|
|
2007
|
+
var options = counterOptions();
|
|
2008
|
+
options.theme_state_fn = counterThemeState; // count 0 forces dark.
|
|
2009
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
2010
|
+
defer std.testing.allocator.destroy(app_state);
|
|
2011
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
2012
|
+
defer app_state.deinit();
|
|
2013
|
+
const app = app_state.app();
|
|
2014
|
+
try harness.start(app);
|
|
2015
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .light } });
|
|
2016
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
2017
|
+
.label = canvas_label,
|
|
2018
|
+
.size = geometry.SizeF.init(400, 300),
|
|
2019
|
+
.scale_factor = 1,
|
|
2020
|
+
.frame_index = 1,
|
|
2021
|
+
.timestamp_ns = 1_000_000,
|
|
2022
|
+
.nonblank = true,
|
|
2023
|
+
} });
|
|
2024
|
+
var stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2025
|
+
const dark = canvas.DesignTokens.theme(.{ .color_scheme = .dark });
|
|
2026
|
+
try std.testing.expectEqualDeep(dark.colors.background, stored.colors.background);
|
|
2027
|
+
|
|
2028
|
+
// A scheme-only flip cannot override the forced state.
|
|
2029
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{ .color_scheme = .dark } });
|
|
2030
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2031
|
+
try std.testing.expectEqualDeep(dark.colors.background, stored.colors.background);
|
|
2032
|
+
|
|
2033
|
+
// Accessibility axes remain live even under a forced color scheme.
|
|
2034
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .appearance_changed = .{
|
|
2035
|
+
.color_scheme = .light,
|
|
2036
|
+
.high_contrast = true,
|
|
2037
|
+
.reduce_motion = true,
|
|
2038
|
+
} });
|
|
2039
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
2040
|
+
const dark_loud = canvas.DesignTokens.theme(.{ .color_scheme = .dark, .contrast = .high, .reduce_motion = true });
|
|
2041
|
+
try std.testing.expectEqualDeep(dark_loud.colors.background, stored.colors.background);
|
|
2042
|
+
try std.testing.expectEqualDeep(dark_loud.colors.focus_ring, stored.colors.focus_ring);
|
|
2043
|
+
try std.testing.expectEqual(@as(u32, 0), stored.motion.normal_ms);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
1923
2046
|
test "static tokens carry the surface scale and re-snap on a scale change" {
|
|
1924
2047
|
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1925
2048
|
defer harness.destroy(std.testing.allocator);
|
|
@@ -3142,6 +3265,73 @@ test "automation composition and selection verbs keep the model mirror consisten
|
|
|
3142
3265
|
try std.testing.expectEqualStrings("", canceled_layout.findById(field_id).?.widget.text);
|
|
3143
3266
|
}
|
|
3144
3267
|
|
|
3268
|
+
test "macOS Command Backspace keeps the controlled TextBuffer mirror and history in lockstep" {
|
|
3269
|
+
if (comptime @import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
3270
|
+
|
|
3271
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
3272
|
+
defer harness.destroy(std.testing.allocator);
|
|
3273
|
+
harness.null_platform.gpu_surfaces = true;
|
|
3274
|
+
|
|
3275
|
+
const app_state = try std.testing.allocator.create(SearchMirrorApp);
|
|
3276
|
+
defer std.testing.allocator.destroy(app_state);
|
|
3277
|
+
try startSearchMirror(harness, app_state);
|
|
3278
|
+
defer app_state.deinit();
|
|
3279
|
+
const app = app_state.app();
|
|
3280
|
+
const field_id = findWidgetIdByKind(app_state.tree.?.root, .search_field).?;
|
|
3281
|
+
|
|
3282
|
+
try core.testing.dispatchAutomationWidgetAction(&harness.runtime, app, .{
|
|
3283
|
+
.view_label = search_mirror_canvas_label,
|
|
3284
|
+
.id = field_id,
|
|
3285
|
+
.action = .set_text,
|
|
3286
|
+
.value = "second line",
|
|
3287
|
+
});
|
|
3288
|
+
for (0..5) |_| {
|
|
3289
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3290
|
+
.window_id = 1,
|
|
3291
|
+
.label = search_mirror_canvas_label,
|
|
3292
|
+
.kind = .key_down,
|
|
3293
|
+
.key = "arrowleft",
|
|
3294
|
+
} });
|
|
3295
|
+
}
|
|
3296
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(6), app_state.model.query.selection);
|
|
3297
|
+
|
|
3298
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3299
|
+
.window_id = 1,
|
|
3300
|
+
.label = search_mirror_canvas_label,
|
|
3301
|
+
.kind = .key_down,
|
|
3302
|
+
.key = "backspace",
|
|
3303
|
+
.modifiers = .{ .primary = true, .command = true },
|
|
3304
|
+
} });
|
|
3305
|
+
try std.testing.expectEqualStrings(" line", app_state.model.query.text());
|
|
3306
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), app_state.model.query.selection);
|
|
3307
|
+
var retained = try harness.runtime.canvasWidgetLayout(1, search_mirror_canvas_label);
|
|
3308
|
+
try std.testing.expectEqualStrings(app_state.model.query.text(), retained.findById(field_id).?.widget.text);
|
|
3309
|
+
try std.testing.expectEqualDeep(app_state.model.query.selection, retained.findById(field_id).?.widget.text_selection.?);
|
|
3310
|
+
|
|
3311
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3312
|
+
.window_id = 1,
|
|
3313
|
+
.label = search_mirror_canvas_label,
|
|
3314
|
+
.kind = .key_down,
|
|
3315
|
+
.key = "z",
|
|
3316
|
+
.modifiers = .{ .primary = true, .command = true },
|
|
3317
|
+
} });
|
|
3318
|
+
try std.testing.expectEqualStrings("second line", app_state.model.query.text());
|
|
3319
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(6), app_state.model.query.selection);
|
|
3320
|
+
|
|
3321
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_input = .{
|
|
3322
|
+
.window_id = 1,
|
|
3323
|
+
.label = search_mirror_canvas_label,
|
|
3324
|
+
.kind = .key_down,
|
|
3325
|
+
.key = "z",
|
|
3326
|
+
.modifiers = .{ .primary = true, .command = true, .shift = true },
|
|
3327
|
+
} });
|
|
3328
|
+
try std.testing.expectEqualStrings(" line", app_state.model.query.text());
|
|
3329
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(0), app_state.model.query.selection);
|
|
3330
|
+
retained = try harness.runtime.canvasWidgetLayout(1, search_mirror_canvas_label);
|
|
3331
|
+
try std.testing.expectEqualStrings(app_state.model.query.text(), retained.findById(field_id).?.widget.text);
|
|
3332
|
+
try std.testing.expectEqualDeep(app_state.model.query.selection, retained.findById(field_id).?.widget.text_selection.?);
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3145
3335
|
// --------------------------------- combobox open-arrow (mirror invariant)
|
|
3146
3336
|
|
|
3147
3337
|
const combo_mirror_canvas_label = "combo-mirror-canvas";
|
|
@@ -3151,12 +3341,16 @@ const ComboMirrorModel = struct {
|
|
|
3151
3341
|
note: canvas.TextBuffer(64) = .{},
|
|
3152
3342
|
open: bool = false,
|
|
3153
3343
|
opens: u32 = 0,
|
|
3344
|
+
submits: u32 = 0,
|
|
3345
|
+
picks: u32 = 0,
|
|
3154
3346
|
query_edits: u32 = 0,
|
|
3155
3347
|
};
|
|
3156
3348
|
|
|
3157
3349
|
const ComboMirrorMsg = union(enum) {
|
|
3158
3350
|
open_picker,
|
|
3159
3351
|
close_picker,
|
|
3352
|
+
submit_query,
|
|
3353
|
+
pick_query: []const u8,
|
|
3160
3354
|
query_edit: canvas.TextInputEvent,
|
|
3161
3355
|
note_edit: canvas.TextInputEvent,
|
|
3162
3356
|
};
|
|
@@ -3170,6 +3364,16 @@ fn comboMirrorUpdate(model: *ComboMirrorModel, msg: ComboMirrorMsg) void {
|
|
|
3170
3364
|
model.opens += 1;
|
|
3171
3365
|
},
|
|
3172
3366
|
.close_picker => model.open = false,
|
|
3367
|
+
.submit_query => {
|
|
3368
|
+
model.open = false;
|
|
3369
|
+
model.submits += 1;
|
|
3370
|
+
},
|
|
3371
|
+
.pick_query => |query| {
|
|
3372
|
+
model.query.clear();
|
|
3373
|
+
model.query.apply(.{ .insert_text = query });
|
|
3374
|
+
model.open = false;
|
|
3375
|
+
model.picks += 1;
|
|
3376
|
+
},
|
|
3173
3377
|
.query_edit => |edit| {
|
|
3174
3378
|
model.query.apply(edit);
|
|
3175
3379
|
model.query_edits += 1;
|
|
@@ -3185,6 +3389,7 @@ fn comboMirrorView(ui: *ComboMirrorApp.Ui, model: *const ComboMirrorModel) Combo
|
|
|
3185
3389
|
.width = 200,
|
|
3186
3390
|
.expanded = model.open,
|
|
3187
3391
|
.on_press = .open_picker,
|
|
3392
|
+
.on_submit = .submit_query,
|
|
3188
3393
|
.on_input = ComboMirrorApp.Ui.inputMsg(.query_edit),
|
|
3189
3394
|
}, .{});
|
|
3190
3395
|
const picker = if (model.open) ui.stack(.{ .height = 28 }, .{
|
|
@@ -3196,8 +3401,8 @@ fn comboMirrorView(ui: *ComboMirrorApp.Ui, model: *const ComboMirrorModel) Combo
|
|
|
3196
3401
|
.height = 60,
|
|
3197
3402
|
.on_dismiss = .close_picker,
|
|
3198
3403
|
}, .{
|
|
3199
|
-
ui.el(.menu_item, .{ .key = .{ .int = 0 }, .text = "glass bead", .height = 26, .on_press = .
|
|
3200
|
-
ui.el(.menu_item, .{ .key = .{ .int = 1 }, .text = "glass jar", .height = 26, .on_press = .
|
|
3404
|
+
ui.el(.menu_item, .{ .key = .{ .int = 0 }, .text = "glass bead", .height = 26, .on_press = ComboMirrorMsg{ .pick_query = "glass bead" } }, .{}),
|
|
3405
|
+
ui.el(.menu_item, .{ .key = .{ .int = 1 }, .text = "glass jar", .height = 26, .on_press = ComboMirrorMsg{ .pick_query = "glass jar" } }, .{}),
|
|
3201
3406
|
}),
|
|
3202
3407
|
}) else ui.stack(.{ .height = 28 }, .{trigger});
|
|
3203
3408
|
return ui.column(.{ .gap = 8, .padding = 12 }, .{
|
|
@@ -3237,7 +3442,7 @@ fn comboMirrorRetainedSelection(harness: *core.TestHarness(), id: canvas.ObjectI
|
|
|
3237
3442
|
return layout.findById(id).?.widget.text_selection;
|
|
3238
3443
|
}
|
|
3239
3444
|
|
|
3240
|
-
test "
|
|
3445
|
+
test "combobox submit precedence and open-menu selection keep the text mirror consistent" {
|
|
3241
3446
|
// The split-brain escapee: a CLOSED combobox maps ArrowUp/Down to
|
|
3242
3447
|
// BOTH its open press (`widgetKeyboardControlIntent`'s menu-open
|
|
3243
3448
|
// keys) and — through the single-line caret derivation — a stamped
|
|
@@ -3292,6 +3497,19 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3292
3497
|
try std.testing.expectEqualStrings("glass", app_state.model.query.text());
|
|
3293
3498
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3294
3499
|
|
|
3500
|
+
// Enter resolves through on_submit BEFORE the trigger's open press.
|
|
3501
|
+
// The closed picker stays closed and neither side of the text mirror
|
|
3502
|
+
// changes while the submit message commits.
|
|
3503
|
+
const edits_before_submit = app_state.model.query_edits;
|
|
3504
|
+
try comboMirrorKey(harness, app, "enter");
|
|
3505
|
+
try std.testing.expect(!app_state.model.open);
|
|
3506
|
+
try std.testing.expectEqual(@as(u32, 0), app_state.model.opens);
|
|
3507
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.submits);
|
|
3508
|
+
try std.testing.expectEqual(edits_before_submit, app_state.model.query_edits);
|
|
3509
|
+
try std.testing.expectEqualStrings("glass", app_state.model.query.text());
|
|
3510
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3511
|
+
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3512
|
+
|
|
3295
3513
|
// THE pin: ArrowDown on the closed trigger opens the picker and
|
|
3296
3514
|
// both carets stay at 3 — no query edit is heard or applied.
|
|
3297
3515
|
const edits_before_open = app_state.model.query_edits;
|
|
@@ -3302,9 +3520,10 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3302
3520
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3303
3521
|
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3304
3522
|
|
|
3305
|
-
// The OPEN-picker truth
|
|
3306
|
-
//
|
|
3307
|
-
//
|
|
3523
|
+
// The OPEN-picker truth: the next arrow walks the keyboard INTO the
|
|
3524
|
+
// mounted menu (the focus step consumes it before routing reaches
|
|
3525
|
+
// the trigger), so Enter selects that menu item instead of reaching
|
|
3526
|
+
// the combobox submit handler again.
|
|
3308
3527
|
const first_item_id = findWidgetIdByText(app_state.tree.?, .menu_item, "glass bead").?;
|
|
3309
3528
|
try comboMirrorKey(harness, app, "arrowdown");
|
|
3310
3529
|
try std.testing.expectEqual(first_item_id, harness.runtime.views[0].canvas_widget_focused_id);
|
|
@@ -3312,12 +3531,12 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3312
3531
|
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(3), app_state.model.query.selection);
|
|
3313
3532
|
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(3)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3314
3533
|
|
|
3315
|
-
|
|
3316
|
-
// the picker closes through `on_dismiss` and the combobox's
|
|
3317
|
-
// Escape-clear never runs — the query survives.
|
|
3318
|
-
try comboMirrorKey(harness, app, "escape");
|
|
3534
|
+
try comboMirrorKey(harness, app, "enter");
|
|
3319
3535
|
try std.testing.expect(!app_state.model.open);
|
|
3320
|
-
try std.testing.
|
|
3536
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.submits);
|
|
3537
|
+
try std.testing.expectEqual(@as(u32, 1), app_state.model.picks);
|
|
3538
|
+
try std.testing.expectEqualStrings("glass bead", app_state.model.query.text());
|
|
3539
|
+
try std.testing.expectEqualStrings("glass bead", (try harness.runtime.canvasWidgetLayout(1, combo_mirror_canvas_label)).findById(combo_id).?.widget.text);
|
|
3321
3540
|
try std.testing.expectEqual(combo_id, harness.runtime.views[0].canvas_widget_focused_id);
|
|
3322
3541
|
|
|
3323
3542
|
// ArrowUp on the closed trigger is the same open key: opens, and
|
|
@@ -3326,8 +3545,8 @@ test "a closed combobox's open arrows move neither the retained caret nor the mo
|
|
|
3326
3545
|
try std.testing.expect(app_state.model.open);
|
|
3327
3546
|
try std.testing.expectEqual(@as(u32, 2), app_state.model.opens);
|
|
3328
3547
|
try std.testing.expectEqual(edits_before_open, app_state.model.query_edits);
|
|
3329
|
-
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed(
|
|
3330
|
-
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed(
|
|
3548
|
+
try std.testing.expectEqualDeep(canvas.TextSelection.collapsed("glass bead".len), app_state.model.query.selection);
|
|
3549
|
+
try std.testing.expectEqualDeep(@as(?canvas.TextSelection, canvas.TextSelection.collapsed("glass bead".len)), try comboMirrorRetainedSelection(harness, combo_id));
|
|
3331
3550
|
try comboMirrorKey(harness, app, "escape");
|
|
3332
3551
|
try std.testing.expect(!app_state.model.open);
|
|
3333
3552
|
|
|
@@ -21,6 +21,7 @@ const settings_window_label = "settings";
|
|
|
21
21
|
const PanelModel = struct {
|
|
22
22
|
settings_open: bool = false,
|
|
23
23
|
position_settings: bool = true,
|
|
24
|
+
center_settings: bool = false,
|
|
24
25
|
transparent_settings: bool = false,
|
|
25
26
|
bumps: u32 = 0,
|
|
26
27
|
user_closes: u32 = 0,
|
|
@@ -63,6 +64,7 @@ fn panelWindows(model: *const PanelModel, scratch: *PanelApp.WindowsScratch) []c
|
|
|
63
64
|
.height = 240,
|
|
64
65
|
.x = if (model.position_settings) 84 else null,
|
|
65
66
|
.y = if (model.position_settings) 126 else null,
|
|
67
|
+
.restore_policy = if (model.center_settings) .center_on_primary else .clamp_to_visible_screen,
|
|
66
68
|
.min_width = 280,
|
|
67
69
|
.min_height = 200,
|
|
68
70
|
.titlebar = if (model.transparent_settings) .chromeless else .standard,
|
|
@@ -245,6 +247,27 @@ test "a Msg declares the settings window, its canvas installs, and automation dr
|
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
|
|
250
|
+
test "a windows_fn restore policy reaches fresh WindowOptions" {
|
|
251
|
+
const fixture = try Fixture.create();
|
|
252
|
+
defer fixture.destroy();
|
|
253
|
+
|
|
254
|
+
fixture.app_state.model.position_settings = false;
|
|
255
|
+
fixture.app_state.model.center_settings = true;
|
|
256
|
+
try fixture.clickSettingsButton();
|
|
257
|
+
const info = fixture.settingsWindowInfo() orelse return error.TestUnexpectedResult;
|
|
258
|
+
|
|
259
|
+
for (fixture.harness.null_platform.windows[0..fixture.harness.null_platform.window_count], 0..) |window, index| {
|
|
260
|
+
if (window.id != info.id) continue;
|
|
261
|
+
// Model-declared windows deliberately set restore_state=false. With
|
|
262
|
+
// no authored origin this remains a fresh/default placement while
|
|
263
|
+
// preserving the descriptor's policy at WindowOptions.
|
|
264
|
+
try std.testing.expectEqual(support.platform.WindowInitialPlacement.default, fixture.harness.null_platform.window_placement[index]);
|
|
265
|
+
try std.testing.expectEqual(support.platform.WindowRestorePolicy.center_on_primary, fixture.harness.null_platform.window_restore_policy[index]);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
return error.WindowNotFound;
|
|
269
|
+
}
|
|
270
|
+
|
|
248
271
|
test "a transparent descriptor selects premultiplied canvas alpha and an alpha-zero clear" {
|
|
249
272
|
const fixture = try Fixture.create();
|
|
250
273
|
defer fixture.destroy();
|
|
@@ -412,7 +412,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
412
412
|
if (std.ascii.eqlIgnoreCase(keyboard.key, "arrowdown")) return .{ .move_caret = .{ .direction = .end, .extend = keyboard.modifiers.shift } };
|
|
413
413
|
}
|
|
414
414
|
|
|
415
|
-
return
|
|
415
|
+
return canvas.widgetKeyboardTextEditEventForWidget(widget, keyboard);
|
|
416
416
|
}
|
|
417
417
|
|
|
418
418
|
/// Resolve Command/Ctrl+Z against the focused editor's delta
|
|
@@ -503,7 +503,7 @@ fn tsSlimReadme(allocator: std.mem.Allocator, names: TemplateNames) ![]const u8
|
|
|
503
503
|
\\
|
|
504
504
|
\\## Requirements
|
|
505
505
|
\\
|
|
506
|
-
\\Node.js
|
|
506
|
+
\\Node.js 24+ on PATH (the TypeScript frontend
|
|
507
507
|
\\and the core compiler run at build time; your shipped binary carries
|
|
508
508
|
\\none of it).
|
|
509
509
|
\\
|
|
@@ -1158,7 +1158,7 @@ fn nativeCiYaml(allocator: std.mem.Allocator, names: TemplateNames, framework_pa
|
|
|
1158
1158
|
const node_setup =
|
|
1159
1159
|
\\ - uses: actions/setup-node@v4
|
|
1160
1160
|
\\ with:
|
|
1161
|
-
\\ node-version:
|
|
1161
|
+
\\ node-version: 24
|
|
1162
1162
|
\\
|
|
1163
1163
|
;
|
|
1164
1164
|
const compiler_install =
|
|
@@ -4531,6 +4531,10 @@ test "writeDefaultApp --full ts-core emits a CI workflow with the node tier" {
|
|
|
4531
4531
|
// frontend + compiler install inside the fetched SDK's packages/core,
|
|
4532
4532
|
// in BOTH jobs (each builds the app, so each compiles the core).
|
|
4533
4533
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "actions/setup-node@v4") != null);
|
|
4534
|
+
const node_24 = "node-version: 24";
|
|
4535
|
+
const first_node = std.mem.indexOf(u8, ci_yaml_text, node_24).?;
|
|
4536
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text[first_node + node_24.len ..], node_24) != null);
|
|
4537
|
+
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text, "node-version: 22") == null);
|
|
4534
4538
|
const npm_ci = "npm ci --prefix \"$NATIVE_SDK_PATH/packages/core\"";
|
|
4535
4539
|
const first = std.mem.indexOf(u8, ci_yaml_text, npm_ci).?;
|
|
4536
4540
|
try std.testing.expect(std.mem.indexOf(u8, ci_yaml_text[first + npm_ci.len ..], npm_ci) != null);
|
package/src/tooling/ts_core.zig
CHANGED
|
@@ -74,7 +74,7 @@ fn nodeMissing() Error {
|
|
|
74
74
|
std.debug.print(
|
|
75
75
|
\\TypeScript app cores need node on PATH (the @native-sdk/core frontend and the
|
|
76
76
|
\\core dev-harness run under it; the binary you ship carries no JS runtime).
|
|
77
|
-
\\Install Node.js
|
|
77
|
+
\\Install Node.js 24+ - https://nodejs.org or
|
|
78
78
|
\\`brew install node` - and re-run.
|
|
79
79
|
\\
|
|
80
80
|
, .{});
|