@native-sdk/cli 0.5.3 → 0.5.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 +41 -1
- package/build.zig +223 -3
- package/native-sdk.d.ts +17 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/rt/rt.zig +138 -3
- package/packages/core/sdk/core.ts +225 -3
- package/packages/core/src/emitter.ts +2586 -259
- package/skill-data/native-ui/SKILL.md +3 -2
- package/skill-data/ts-core/SKILL.md +9 -1
- package/src/app_runner/root.zig +81 -1
- package/src/app_runner/ts_core_main.zig +4 -0
- package/src/embed/tests.zig +119 -1
- package/src/platform/linux/gtk_host.c +112 -3
- package/src/platform/linux/root.zig +71 -0
- package/src/platform/macos/appkit_host.h +48 -2
- package/src/platform/macos/appkit_host.m +533 -34
- package/src/platform/macos/cef_host.mm +262 -10
- package/src/platform/macos/root.zig +92 -4
- package/src/platform/null_platform.zig +298 -5
- package/src/platform/root.zig +33 -0
- package/src/platform/types.zig +138 -4
- package/src/platform/windows/root.zig +134 -0
- package/src/platform/windows/webview2_host.cpp +152 -40
- package/src/primitives/app_manifest/comptime_scene.zig +5 -0
- package/src/primitives/app_manifest/root.zig +1 -0
- package/src/primitives/app_manifest/types.zig +32 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/ui.zig +11 -7
- package/src/primitives/canvas/ui_markup.zig +58 -34
- package/src/primitives/canvas/ui_markup_binary.zig +4 -1
- package/src/primitives/canvas/ui_markup_compiled.zig +23 -8
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
- package/src/primitives/canvas/ui_markup_contract.zig +1 -1
- package/src/primitives/canvas/ui_markup_contract_tests.zig +26 -0
- package/src/primitives/canvas/ui_markup_huge_document_tests.zig +154 -0
- package/src/primitives/canvas/ui_markup_tests.zig +29 -9
- package/src/primitives/canvas/ui_markup_view.zig +29 -11
- package/src/primitives/canvas/ui_markup_view_tests.zig +150 -9
- package/src/primitives/canvas/ui_schema.zig +13 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/root.zig +7 -0
- package/src/runtime/api.zig +6 -4
- package/src/runtime/bridge_payload.zig +7 -0
- package/src/runtime/bridge_responses.zig +5 -0
- package/src/runtime/builtin_bridge.zig +9 -4
- package/src/runtime/canvas_font_tests.zig +439 -2
- package/src/runtime/canvas_fonts.zig +61 -6
- package/src/runtime/canvas_image_tests.zig +195 -0
- package/src/runtime/canvas_images.zig +45 -12
- package/src/runtime/core.zig +58 -11
- package/src/runtime/effects.zig +1664 -43
- package/src/runtime/effects_fetch_tests.zig +89 -1
- package/src/runtime/effects_file_tests.zig +41 -1
- package/src/runtime/effects_image_tests.zig +1304 -0
- package/src/runtime/effects_tests.zig +153 -0
- package/src/runtime/flow.zig +17 -0
- package/src/runtime/root.zig +11 -0
- package/src/runtime/session_blobs.zig +689 -0
- package/src/runtime/session_journal.zig +85 -21
- package/src/runtime/session_record.zig +27 -2
- package/src/runtime/session_replay.zig +168 -16
- package/src/runtime/session_tests.zig +1992 -0
- package/src/runtime/shell_layout.zig +7 -0
- package/src/runtime/testdata/fonts/NotoSansSC-Receipt.ttf +0 -0
- package/src/runtime/testdata/fonts/OFL.txt +93 -0
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +439 -4
- package/src/runtime/ts_core_host_tests.zig +41 -0
- package/src/runtime/ts_ui_app.zig +7 -0
- package/src/runtime/ui_app.zig +111 -6
- package/src/runtime/ui_app_window_tests.zig +468 -0
- package/src/runtime/window_command_bridge_tests.zig +117 -0
- package/src/runtime/window_storage.zig +32 -0
- package/src/runtime/window_views.zig +61 -1
- package/src/tooling/manifest.zig +75 -0
- package/src/tooling/raw_manifest.zig +2 -0
- package/src/tooling/templates.zig +219 -1
|
@@ -1466,6 +1466,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1466
1466
|
\\ const exe = b.addExecutable(.{
|
|
1467
1467
|
\\ .name = app_exe_name,
|
|
1468
1468
|
\\ .root_module = app_mod,
|
|
1469
|
+
\\ // Zig 0.16.0's self-hosted x86_64 backend (the Debug default)
|
|
1470
|
+
\\ // miscompiles the SysV C calling convention for the long
|
|
1471
|
+
\\ // mixed-argument signatures the platform hosts use, shifting
|
|
1472
|
+
\\ // stack-passed pointers by one slot (a Debug dev run on
|
|
1473
|
+
\\ // x86_64 Linux crashes creating its first shell view). Force
|
|
1474
|
+
\\ // LLVM there, mirroring the Native SDK build graph; Release
|
|
1475
|
+
\\ // modes already use LLVM, so only Debug changes.
|
|
1476
|
+
\\ .use_llvm = useLlvmWorkaround(target),
|
|
1469
1477
|
\\ });
|
|
1470
1478
|
\\ // Windows subsystem posture (mirrors the Native SDK build graph):
|
|
1471
1479
|
\\ // release-shaped exes are GUI-subsystem so the app never flashes a
|
|
@@ -1519,6 +1527,9 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1519
1527
|
\\ const built = b.addExecutable(.{
|
|
1520
1528
|
\\ .name = app_exe_name,
|
|
1521
1529
|
\\ .root_module = package_app_mod,
|
|
1530
|
+
\\ // Same self-hosted x86_64 workaround as the dev exe above
|
|
1531
|
+
\\ // (only reachable when -Doptimize pins Debug for both roles).
|
|
1532
|
+
\\ .use_llvm = useLlvmWorkaround(target),
|
|
1522
1533
|
\\ });
|
|
1523
1534
|
\\ // Same subsystem posture as the dev exe above, keyed on this
|
|
1524
1535
|
\\ // exe's own mode: release-shaped Windows exes are GUI-subsystem.
|
|
@@ -1572,6 +1583,18 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1572
1583
|
\\ test_step.dependOn(&b.addRunArtifact(tests).step);
|
|
1573
1584
|
\\}
|
|
1574
1585
|
\\
|
|
1586
|
+
\\// Zig 0.16.0's self-hosted x86_64 backend miscompiles the SysV C
|
|
1587
|
+
\\// calling convention for long mixed int/pointer/double signatures
|
|
1588
|
+
\\// (the platform hosts' view-create calls) and f32-heavy ones (the
|
|
1589
|
+
\\// embed viewport ABI): stack-passed arguments arrive shifted, so a
|
|
1590
|
+
\\// Debug x86_64 build crashes at the first platform call that passes
|
|
1591
|
+
\\// strings on the stack. Force the LLVM backend on x86_64 until the
|
|
1592
|
+
\\// upstream backend is fixed; Release modes already default to LLVM,
|
|
1593
|
+
\\// so this only changes Debug builds.
|
|
1594
|
+
\\fn useLlvmWorkaround(target: std.Build.ResolvedTarget) ?bool {
|
|
1595
|
+
\\ return if (target.result.cpu.arch == .x86_64) true else null;
|
|
1596
|
+
\\}
|
|
1597
|
+
\\
|
|
1575
1598
|
\\// Resolve the optimize mode for one exe role (mirrors the Native SDK
|
|
1576
1599
|
\\// build graph): an explicit -Doptimize wins for every role, --release
|
|
1577
1600
|
\\// resolves through zig's release_mode, and only when neither was
|
|
@@ -1728,7 +1751,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1728
1751
|
\\ // the layer stays out even on machines where the
|
|
1729
1752
|
\\ // development package is installed — libwebkitgtk is
|
|
1730
1753
|
\\ // neither linked nor required at runtime, and the
|
|
1731
|
-
\\ // executable carries no WebKit reference at all.
|
|
1754
|
+
\\ // executable carries no WebKit reference at all. This
|
|
1755
|
+
\\ // is the expected, configured state of every canvas
|
|
1756
|
+
\\ // app on Linux, so the stub compile is deliberately
|
|
1757
|
+
\\ // silent — no build note, no compiler diagnostic (the
|
|
1758
|
+
\\ // host's seam comment explains why even an
|
|
1759
|
+
\\ // informational pragma is dangerous); a stubbed host
|
|
1760
|
+
\\ // teaches at runtime by reporting WebViewNotFound the
|
|
1761
|
+
\\ // moment an app actually uses a WebView.
|
|
1732
1762
|
\\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/linux/gtk_host.c"), .flags = &.{"-DNATIVE_SDK_ALLOW_WEBKITGTK_STUB"} });
|
|
1733
1763
|
\\ app_mod.linkSystemLibrary("gtk4", .{});
|
|
1734
1764
|
\\ app_mod.linkSystemLibrary("dl", .{});
|
|
@@ -1774,6 +1804,14 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1774
1804
|
\\ // headers are reachable through the system include paths
|
|
1775
1805
|
\\ // — no WebView2Loader.dll is installed or path-wired,
|
|
1776
1806
|
\\ // and the executable carries no reference to it at all.
|
|
1807
|
+
\\ // This is the expected, configured state of every
|
|
1808
|
+
\\ // canvas app on Windows, so the stub compile is
|
|
1809
|
+
\\ // deliberately silent — no build note, no compiler
|
|
1810
|
+
\\ // diagnostic (the host's seam comment explains why
|
|
1811
|
+
\\ // even an informational pragma is dangerous); a
|
|
1812
|
+
\\ // stubbed host teaches at runtime by reporting
|
|
1813
|
+
\\ // WebViewNotFound the moment an app actually uses a
|
|
1814
|
+
\\ // WebView.
|
|
1777
1815
|
\\ app_mod.addCSourceFile(.{ .file = nativeSdkPath(b, native_sdk_path, "src/platform/windows/webview2_host.cpp"), .flags = &.{ "-std=c++17", "-DNATIVE_SDK_ALLOW_WEBVIEW2_STUB" } });
|
|
1778
1816
|
\\ },
|
|
1779
1817
|
\\ .chromium => {
|
|
@@ -2183,6 +2221,7 @@ fn runnerZig() []const u8 {
|
|
|
2183
2221
|
\\ var info: native_sdk.AppInfo = .{
|
|
2184
2222
|
\\ .app_name = self.app_name,
|
|
2185
2223
|
\\ .has_web_content = manifestHasWebContent(),
|
|
2224
|
+
\\ .declares_tray = manifestDeclaresTrayCapability(),
|
|
2186
2225
|
\\ .window_title = self.window_title,
|
|
2187
2226
|
\\ .bundle_id = self.bundle_id,
|
|
2188
2227
|
\\ .icon_path = self.icon_path,
|
|
@@ -2191,6 +2230,26 @@ fn runnerZig() []const u8 {
|
|
|
2191
2230
|
\\ if (windows.len > 0) {
|
|
2192
2231
|
\\ info.main_window = windows[0];
|
|
2193
2232
|
\\ info.windows = windows;
|
|
2233
|
+
\\ } else {
|
|
2234
|
+
\\ // Scene-first apps declare their one window under
|
|
2235
|
+
\\ // `.shell.windows` — the startup window the host creates
|
|
2236
|
+
\\ // adopts that declaration when the scene loads, but its
|
|
2237
|
+
\\ // CHROME is fixed at create time, so the manifest's
|
|
2238
|
+
\\ // titlebar style threads through here. Same for visibility:
|
|
2239
|
+
\\ // a canvas-first startup window is created ordered-out and
|
|
2240
|
+
\\ // shown after its first canvas frame presents, so launch
|
|
2241
|
+
\\ // never flashes a blank window.
|
|
2242
|
+
\\ info.main_window.titlebar = manifestShellStartupTitlebar();
|
|
2243
|
+
\\ info.main_window.resizable = manifestShellStartupResizable();
|
|
2244
|
+
\\ info.main_window.show = manifestShellStartupShowMode();
|
|
2245
|
+
\\ // Min-size floors ride the create call like the titlebar:
|
|
2246
|
+
\\ // the scene re-applies size/title later, but the window's
|
|
2247
|
+
\\ // enforced floor is host state from the first frame on.
|
|
2248
|
+
\\ info.main_window.min_width = manifestShellStartupMinSize("min_width");
|
|
2249
|
+
\\ info.main_window.min_height = manifestShellStartupMinSize("min_height");
|
|
2250
|
+
\\ // Close handling is host window state like the titlebar:
|
|
2251
|
+
\\ // the manifest's declaration rides the host create.
|
|
2252
|
+
\\ info.main_window.close_policy = manifestShellStartupClosePolicy();
|
|
2194
2253
|
\\ }
|
|
2195
2254
|
\\ return info;
|
|
2196
2255
|
\\ }
|
|
@@ -2314,6 +2373,10 @@ fn runnerZig() []const u8 {
|
|
|
2314
2373
|
\\ .resizable = windowBool(window, "resizable", true),
|
|
2315
2374
|
\\ .restore_state = windowBool(window, "restore_state", true),
|
|
2316
2375
|
\\ .restore_policy = windowRestorePolicy(window),
|
|
2376
|
+
\\ .titlebar = windowTitlebarStyle(window),
|
|
2377
|
+
\\ .min_width = windowMinSize(window, "min_width"),
|
|
2378
|
+
\\ .min_height = windowMinSize(window, "min_height"),
|
|
2379
|
+
\\ .close_policy = windowClosePolicy(window),
|
|
2317
2380
|
\\ };
|
|
2318
2381
|
\\}
|
|
2319
2382
|
\\
|
|
@@ -2347,6 +2410,125 @@ fn runnerZig() []const u8 {
|
|
|
2347
2410
|
\\ @compileError("unknown app.zon window restore_policy");
|
|
2348
2411
|
\\}
|
|
2349
2412
|
\\
|
|
2413
|
+
\\/// Window-enforced content min-size floor from app.zon. Validated at
|
|
2414
|
+
\\/// comptime like the titlebar style: a negative floor is an authoring
|
|
2415
|
+
\\/// error, not a silent clamp.
|
|
2416
|
+
\\fn windowMinSize(comptime window: anytype, comptime field: []const u8) f32 {
|
|
2417
|
+
\\ const value: f32 = comptime windowFloat(window, field, 0);
|
|
2418
|
+
\\ comptime {
|
|
2419
|
+
\\ if (!(value >= 0)) @compileError("app.zon window " ++ field ++ " must be non-negative");
|
|
2420
|
+
\\ }
|
|
2421
|
+
\\ return value;
|
|
2422
|
+
\\}
|
|
2423
|
+
\\
|
|
2424
|
+
\\fn windowTitlebarStyle(comptime window: anytype) native_sdk.WindowTitlebarStyle {
|
|
2425
|
+
\\ if (comptime !@hasField(@TypeOf(window), "titlebar")) return .standard;
|
|
2426
|
+
\\ const value = window.titlebar;
|
|
2427
|
+
\\ if (comptime std.mem.eql(u8, value, "standard")) return .standard;
|
|
2428
|
+
\\ if (comptime std.mem.eql(u8, value, "hidden_inset")) return .hidden_inset;
|
|
2429
|
+
\\ if (comptime std.mem.eql(u8, value, "hidden_inset_tall")) return .hidden_inset_tall;
|
|
2430
|
+
\\ if (comptime std.mem.eql(u8, value, "chromeless")) return .chromeless;
|
|
2431
|
+
\\ @compileError("unknown app.zon window titlebar style");
|
|
2432
|
+
\\}
|
|
2433
|
+
\\
|
|
2434
|
+
\\/// The startup window's titlebar style for scene-first apps: app.zon's
|
|
2435
|
+
\\/// `.shell.windows[0].titlebar`. Chrome cannot change after the host
|
|
2436
|
+
\\/// creates the window, so it must ride the create call — unlike
|
|
2437
|
+
\\/// size/title, which the loading scene re-applies.
|
|
2438
|
+
\\fn manifestShellStartupTitlebar() native_sdk.WindowTitlebarStyle {
|
|
2439
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return .standard;
|
|
2440
|
+
\\ const shell = app_manifest.shell;
|
|
2441
|
+
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return .standard;
|
|
2442
|
+
\\ if (comptime shell.windows.len == 0) return .standard;
|
|
2443
|
+
\\ return windowTitlebarStyle(shell.windows[0]);
|
|
2444
|
+
\\}
|
|
2445
|
+
\\
|
|
2446
|
+
\\/// The startup window's resizability for scene-first apps: like the
|
|
2447
|
+
\\/// titlebar style, resizable is window chrome fixed at create time.
|
|
2448
|
+
\\fn manifestShellStartupResizable() bool {
|
|
2449
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return true;
|
|
2450
|
+
\\ const shell = app_manifest.shell;
|
|
2451
|
+
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return true;
|
|
2452
|
+
\\ if (comptime shell.windows.len == 0) return true;
|
|
2453
|
+
\\ return windowBool(shell.windows[0], "resizable", true);
|
|
2454
|
+
\\}
|
|
2455
|
+
\\
|
|
2456
|
+
\\/// The startup window's close policy for scene-first apps: app.zon's
|
|
2457
|
+
\\/// `.shell.windows[0].close_policy`. Like the titlebar, close handling
|
|
2458
|
+
\\/// is host window state fixed at create time.
|
|
2459
|
+
\\fn manifestShellStartupClosePolicy() native_sdk.WindowClosePolicy {
|
|
2460
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return .quit;
|
|
2461
|
+
\\ const shell = app_manifest.shell;
|
|
2462
|
+
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return .quit;
|
|
2463
|
+
\\ if (comptime shell.windows.len == 0) return .quit;
|
|
2464
|
+
\\ return windowClosePolicy(shell.windows[0]);
|
|
2465
|
+
\\}
|
|
2466
|
+
\\
|
|
2467
|
+
\\/// The startup window's content min-size floor for scene-first apps:
|
|
2468
|
+
\\/// app.zon's `.shell.windows[0].min_width`/`.min_height` (0 = none).
|
|
2469
|
+
\\fn manifestShellStartupMinSize(comptime field: []const u8) f32 {
|
|
2470
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return 0;
|
|
2471
|
+
\\ const shell = app_manifest.shell;
|
|
2472
|
+
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return 0;
|
|
2473
|
+
\\ if (comptime shell.windows.len == 0) return 0;
|
|
2474
|
+
\\ return windowMinSize(shell.windows[0], field);
|
|
2475
|
+
\\}
|
|
2476
|
+
\\
|
|
2477
|
+
\\/// Present-before-show for the STARTUP window: when app.zon's first
|
|
2478
|
+
\\/// shell window hosts a canvas (`gpu_surface` view), the host creates
|
|
2479
|
+
\\/// it ordered-out and it becomes visible after the first canvas frame
|
|
2480
|
+
\\/// presents. Webview-first startup windows keep immediate visibility.
|
|
2481
|
+
\\fn manifestShellStartupShowMode() native_sdk.WindowShowMode {
|
|
2482
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "shell")) return .immediate;
|
|
2483
|
+
\\ const shell = app_manifest.shell;
|
|
2484
|
+
\\ if (comptime !@hasField(@TypeOf(shell), "windows")) return .immediate;
|
|
2485
|
+
\\ if (comptime shell.windows.len == 0) return .immediate;
|
|
2486
|
+
\\ const window = shell.windows[0];
|
|
2487
|
+
\\ if (comptime !@hasField(@TypeOf(window), "views")) return .immediate;
|
|
2488
|
+
\\ inline for (window.views) |view| {
|
|
2489
|
+
\\ if (comptime @hasField(@TypeOf(view), "kind")) {
|
|
2490
|
+
\\ if (comptime std.mem.eql(u8, view.kind, "gpu_surface")) return .on_first_present;
|
|
2491
|
+
\\ }
|
|
2492
|
+
\\ }
|
|
2493
|
+
\\ return .immediate;
|
|
2494
|
+
\\}
|
|
2495
|
+
\\
|
|
2496
|
+
\\/// What the window's close affordance does, from app.zon. `.hide` is
|
|
2497
|
+
\\/// validated against the TARGET platform at comptime: a host with no
|
|
2498
|
+
\\/// affordance to bring a hidden window back (GTK has no status item;
|
|
2499
|
+
\\/// windows without a declared tray, since hiding removes the taskbar
|
|
2500
|
+
\\/// entry and windows has no dock) refuses the declaration here, at
|
|
2501
|
+
\\/// build time, instead of stranding a hidden window at runtime.
|
|
2502
|
+
\\fn windowClosePolicy(comptime window: anytype) native_sdk.WindowClosePolicy {
|
|
2503
|
+
\\ if (comptime !@hasField(@TypeOf(window), "close_policy")) return .quit;
|
|
2504
|
+
\\ const value = window.close_policy;
|
|
2505
|
+
\\ if (comptime std.mem.eql(u8, value, "quit")) return .quit;
|
|
2506
|
+
\\ if (comptime std.mem.eql(u8, value, "hide")) {
|
|
2507
|
+
\\ if (comptime std.mem.eql(u8, build_options.platform, "linux")) {
|
|
2508
|
+
\\ @compileError("app.zon window close_policy \"hide\" is not supported on linux: the GTK host has no status item (tray), so nothing could bring the hidden window back - declare \"quit\" (the default), or scope the .hide declaration to macos/windows builds");
|
|
2509
|
+
\\ }
|
|
2510
|
+
\\ if (comptime std.mem.eql(u8, build_options.platform, "windows")) {
|
|
2511
|
+
\\ if (comptime !manifestDeclaresTrayCapability()) {
|
|
2512
|
+
\\ @compileError("app.zon window close_policy \"hide\" on windows requires the \"tray\" capability: hiding removes the taskbar entry and windows has no dock-reopen path, so only a status item (tray) could bring the hidden window back - add \"tray\" to .capabilities and install a status item, or declare \"quit\" (the default); macos needs no capability because the dock reopen path always exists");
|
|
2513
|
+
\\ }
|
|
2514
|
+
\\ }
|
|
2515
|
+
\\ return .hide;
|
|
2516
|
+
\\ }
|
|
2517
|
+
\\ @compileError("unknown app.zon window close_policy - supported values: \"quit\" (close really closes; the default) and \"hide\" (the menu-bar-app shape: close hides the window and the app keeps running)");
|
|
2518
|
+
\\}
|
|
2519
|
+
\\
|
|
2520
|
+
\\/// Whether app.zon declares the "tray" capability — the status item
|
|
2521
|
+
\\/// `.hide` leans on where the OS has no built-in re-show affordance.
|
|
2522
|
+
\\/// Evaluated at comptime over the manifest import, like the web scan.
|
|
2523
|
+
\\fn manifestDeclaresTrayCapability() bool {
|
|
2524
|
+
\\ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
|
|
2525
|
+
\\ inline for (app_manifest.capabilities) |capability| {
|
|
2526
|
+
\\ const name: []const u8 = capability;
|
|
2527
|
+
\\ if (comptime std.mem.eql(u8, name, "tray")) return true;
|
|
2528
|
+
\\ }
|
|
2529
|
+
\\ return false;
|
|
2530
|
+
\\}
|
|
2531
|
+
\\
|
|
2350
2532
|
\\fn menuItem(comptime item: anytype) native_sdk.MenuItem {
|
|
2351
2533
|
\\ return .{
|
|
2352
2534
|
\\ .label = if (@hasField(@TypeOf(item), "label")) item.label else "",
|
|
@@ -3651,6 +3833,42 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3651
3833
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestWindowOptions") != null);
|
|
3652
3834
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.windows = windows") != null);
|
|
3653
3835
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "for (restored_windows, 0..)") != null);
|
|
3836
|
+
// The generated manifestWindow must thread every declarable window
|
|
3837
|
+
// option into WindowOptions — a dropped field is a silent no-op for
|
|
3838
|
+
// every `native create` app (the manifest accepts the declaration,
|
|
3839
|
+
// the window ignores it). close_policy shipped with exactly that gap
|
|
3840
|
+
// once; these pins hold the field AND the Linux comptime refusal (a
|
|
3841
|
+
// .hide window with no tray to bring it back must fail the build,
|
|
3842
|
+
// not strand a hidden window at runtime).
|
|
3843
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".restore_policy = windowRestorePolicy(window)") != null);
|
|
3844
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".titlebar = windowTitlebarStyle(window)") != null);
|
|
3845
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_width = windowMinSize(window, \"min_width\")") != null);
|
|
3846
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".min_height = windowMinSize(window, \"min_height\")") != null);
|
|
3847
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".close_policy = windowClosePolicy(window)") != null);
|
|
3848
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "close_policy \\\"hide\\\" is not supported on linux") != null);
|
|
3849
|
+
// The windows-conditional twin: `.hide` hides the taskbar entry and
|
|
3850
|
+
// windows has no dock-reopen path, so the declaration requires the
|
|
3851
|
+
// "tray" capability (the status item IS the re-show affordance).
|
|
3852
|
+
// macOS stays exempt — the Dock reopen path always exists.
|
|
3853
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "close_policy \\\"hide\\\" on windows requires the \\\"tray\\\" capability") != null);
|
|
3854
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "fn manifestDeclaresTrayCapability()") != null);
|
|
3855
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, ".declares_tray = manifestDeclaresTrayCapability()") != null);
|
|
3856
|
+
// The scene-first twin: an app.zon that declares its one window under
|
|
3857
|
+
// `.shell.windows` (the default `native init` shape) hits the
|
|
3858
|
+
// windows.len == 0 branch, and the startup window's host-create state
|
|
3859
|
+
// (chrome, resizability, show mode, min-size floor, close policy)
|
|
3860
|
+
// must thread from the shell declaration exactly like the SDK runner
|
|
3861
|
+
// — a generated runner without this threading silently keeps
|
|
3862
|
+
// quit-on-close (and standard chrome) for every scene-first
|
|
3863
|
+
// manifest. The close-policy helper reuses windowClosePolicy, so the
|
|
3864
|
+
// shell path carries the same Linux comptime refusal pinned above.
|
|
3865
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.titlebar = manifestShellStartupTitlebar()") != null);
|
|
3866
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.resizable = manifestShellStartupResizable()") != null);
|
|
3867
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.show = manifestShellStartupShowMode()") != null);
|
|
3868
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_width = manifestShellStartupMinSize(\"min_width\")") != null);
|
|
3869
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.min_height = manifestShellStartupMinSize(\"min_height\")") != null);
|
|
3870
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "info.main_window.close_policy = manifestShellStartupClosePolicy()") != null);
|
|
3871
|
+
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "return windowClosePolicy(shell.windows[0])") != null);
|
|
3654
3872
|
// The Runtime is multi-megabyte; the generated runner must heap-allocate
|
|
3655
3873
|
// it and construct in place, never build it by value on the stack.
|
|
3656
3874
|
try std.testing.expect(std.mem.indexOf(u8, runner_zig_text, "std.heap.page_allocator.create(native_sdk.Runtime)") != null);
|