@native-sdk/cli 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +26 -9
- package/build.zig +55 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/skill-data/native-ui/SKILL.md +7 -7
- package/skill-data/ts-core/SKILL.md +1 -1
- package/src/app_runner/root.zig +93 -6
- package/src/app_runner/ts_core_main.zig +4 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +192 -40
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +154 -9
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ui_app.zig +9 -3
- package/src/runtime/ui_app_tests.zig +119 -19
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/web_engine.zig +1 -1
package/build/app.zig
CHANGED
|
@@ -1254,6 +1254,9 @@ pub const MobileLibOptions = struct {
|
|
|
1254
1254
|
filesystem_permission: bool = false,
|
|
1255
1255
|
/// Stable app identity used as the Keychain/Keystore service namespace.
|
|
1256
1256
|
credentials_service: []const u8 = "dev.native_sdk.app",
|
|
1257
|
+
/// Frozen registered-image pixel budget. Standard app builds infer it
|
|
1258
|
+
/// from app.zon; low-level embedders default to the SDK's 1 MiB tier.
|
|
1259
|
+
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
1257
1260
|
/// A TypeScript core's staged mobile wiring: set by `addAppArtifacts`
|
|
1258
1261
|
/// when the tree carries src/core.ts. The `app` module roots at the
|
|
1259
1262
|
/// staged mobile entry instead of `main`, and the compiled core (and
|
|
@@ -1318,6 +1321,7 @@ fn addMobileLibWithTarget(b: *std.Build, dep: *std.Build.Dependency, target: std
|
|
|
1318
1321
|
mobile_options.addOption(bool, "credentials_permission", options.credentials_permission);
|
|
1319
1322
|
mobile_options.addOption(bool, "filesystem_permission", options.filesystem_permission);
|
|
1320
1323
|
mobile_options.addOption([]const u8, "credentials_service", options.credentials_service);
|
|
1324
|
+
mobile_options.addOption(usize, "max_image_pixel_bytes", options.max_image_pixel_bytes);
|
|
1321
1325
|
exports_mod.addImport("mobile_build_options", mobile_options.createModule());
|
|
1322
1326
|
const migration_path = options.relational_migrations orelse dep.path("src/app_runner/no_migrations.zig");
|
|
1323
1327
|
const migration_mod = b.createModule(.{ .root_source_file = migration_path, .target = target, .optimize = optimize });
|
|
@@ -1515,6 +1519,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
|
|
|
1515
1519
|
.credentials_permission = app_config.credentials_permission,
|
|
1516
1520
|
.filesystem_permission = app_config.filesystem_permission,
|
|
1517
1521
|
.credentials_service = app_config.app_id,
|
|
1522
|
+
.max_image_pixel_bytes = app_config.max_image_pixel_bytes,
|
|
1518
1523
|
.ts_core = if (ts_stage) |stage| .{
|
|
1519
1524
|
.main_root = stage.mobile_root,
|
|
1520
1525
|
.archive = stage.archive,
|
|
@@ -1850,19 +1855,23 @@ fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.Resolv
|
|
|
1850
1855
|
});
|
|
1851
1856
|
app_mod.link_libc = true;
|
|
1852
1857
|
}
|
|
1853
|
-
|
|
1858
|
+
addMacosInfoPlist(b, app_mod, target, app_config);
|
|
1854
1859
|
return app_mod;
|
|
1855
1860
|
}
|
|
1856
1861
|
|
|
1857
1862
|
/// Bare Mach-O executables launched by the dev loop do not have an app
|
|
1858
|
-
/// bundle's external Info.plist.
|
|
1859
|
-
///
|
|
1860
|
-
///
|
|
1861
|
-
/// their richer external plist generated by package.zig.
|
|
1862
|
-
fn
|
|
1863
|
+
/// bundle's external Info.plist. Embed launch policy plus capture usage
|
|
1864
|
+
/// strings in the conventional section so LaunchServices starts accessory
|
|
1865
|
+
/// apps without a transient Dock tile and capture consent can be presented.
|
|
1866
|
+
/// Packaged apps retain their richer external plist generated by package.zig.
|
|
1867
|
+
fn addMacosInfoPlist(b: *std.Build, app_mod: *std.Build.Module, target: std.Build.ResolvedTarget, config: AppManifestBuildConfig) void {
|
|
1863
1868
|
if (target.result.os.tag != .macos) return;
|
|
1864
|
-
if (!config.microphone_permission and !config.system_audio_permission) return;
|
|
1869
|
+
if (config.dock_visible and !config.microphone_permission and !config.system_audio_permission) return;
|
|
1865
1870
|
|
|
1871
|
+
const launch_policy = if (!config.dock_visible)
|
|
1872
|
+
" <key>LSUIElement</key>\\n <true/>\\n"
|
|
1873
|
+
else
|
|
1874
|
+
"";
|
|
1866
1875
|
const microphone = if (config.microphone_permission)
|
|
1867
1876
|
" <key>NSMicrophoneUsageDescription</key>\\n <string>This app captures microphone audio when you start recording.</string>\\n"
|
|
1868
1877
|
else
|
|
@@ -1873,11 +1882,11 @@ fn addMacosPrivacyInfoPlist(b: *std.Build, app_mod: *std.Build.Module, target: s
|
|
|
1873
1882
|
else
|
|
1874
1883
|
"";
|
|
1875
1884
|
const source = b.fmt(
|
|
1876
|
-
\\#define NATIVE_SDK_INFO_PLIST "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n<dict>\n{s}{s}</dict>\n</plist>\n"
|
|
1885
|
+
\\#define NATIVE_SDK_INFO_PLIST "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" "<plist version=\"1.0\">\n<dict>\n{s}{s}{s}</dict>\n</plist>\n"
|
|
1877
1886
|
\\__attribute__((used, section("__TEXT,__info_plist")))
|
|
1878
1887
|
\\static const unsigned char native_sdk_info_plist[sizeof(NATIVE_SDK_INFO_PLIST) - 1] = NATIVE_SDK_INFO_PLIST;
|
|
1879
1888
|
\\
|
|
1880
|
-
, .{ microphone, system_audio });
|
|
1889
|
+
, .{ launch_policy, microphone, system_audio });
|
|
1881
1890
|
const generated = b.addWriteFiles().add("native_sdk_macos_info_plist.c", source);
|
|
1882
1891
|
app_mod.addCSourceFile(.{ .file = generated, .flags = &.{} });
|
|
1883
1892
|
}
|
|
@@ -2481,6 +2490,7 @@ const AppManifestBuildConfig = struct {
|
|
|
2481
2490
|
cef_dir: []const u8 = "third_party/cef/macos",
|
|
2482
2491
|
cef_auto_install: bool = false,
|
|
2483
2492
|
webview_layer: WebLayerOption = .auto,
|
|
2493
|
+
dock_visible: bool = true,
|
|
2484
2494
|
microphone_permission: bool = false,
|
|
2485
2495
|
system_audio_permission: bool = false,
|
|
2486
2496
|
persist_capability: bool = false,
|
|
@@ -2493,6 +2503,7 @@ const AppManifestBuildConfig = struct {
|
|
|
2493
2503
|
credentials_capability: bool = false,
|
|
2494
2504
|
credentials_permission: bool = false,
|
|
2495
2505
|
filesystem_permission: bool = false,
|
|
2506
|
+
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
2496
2507
|
sqlite_capability: bool = false,
|
|
2497
2508
|
/// The first web declaration found (for teaching messages), or null
|
|
2498
2509
|
/// when app.zon declares no web use. `web_engine = "system"` alone is
|
|
@@ -2514,6 +2525,7 @@ const InferenceManifest = struct {
|
|
|
2514
2525
|
id: []const u8 = "dev.native_sdk.app",
|
|
2515
2526
|
capabilities: []const []const u8 = &.{},
|
|
2516
2527
|
permissions: []const []const u8 = &.{},
|
|
2528
|
+
dock_visible: bool = true,
|
|
2517
2529
|
web_engine: []const u8 = "system",
|
|
2518
2530
|
webview_layer: []const u8 = "auto",
|
|
2519
2531
|
core_compiler: []const u8 = "external",
|
|
@@ -2525,6 +2537,9 @@ const InferenceManifest = struct {
|
|
|
2525
2537
|
persist: ?struct {
|
|
2526
2538
|
version: u64,
|
|
2527
2539
|
} = null,
|
|
2540
|
+
images: struct {
|
|
2541
|
+
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
2542
|
+
} = .{},
|
|
2528
2543
|
service_packages: []const ServicePackageConfig = &.{},
|
|
2529
2544
|
service_carrier: []const u8 = "auto",
|
|
2530
2545
|
service_pool_size: u8 = 0,
|
|
@@ -2575,6 +2590,7 @@ fn appManifestBuildConfig(b: *std.Build, app_root: []const u8) AppManifestBuildC
|
|
|
2575
2590
|
.cef_dir = raw.cef.dir,
|
|
2576
2591
|
.cef_auto_install = raw.cef.auto_install,
|
|
2577
2592
|
.webview_layer = web_layer_contract.parseWebViewLayer(raw.webview_layer) orelse @panic("app.zon .webview_layer must be \"auto\", \"include\", or \"exclude\""),
|
|
2593
|
+
.dock_visible = raw.dock_visible,
|
|
2578
2594
|
.microphone_permission = hasManifestPermission(raw.permissions, "microphone"),
|
|
2579
2595
|
.system_audio_permission = hasManifestPermission(raw.permissions, "system_audio"),
|
|
2580
2596
|
.persist_capability = hasManifestCapability(raw.capabilities, "persist"),
|
|
@@ -2587,6 +2603,7 @@ fn appManifestBuildConfig(b: *std.Build, app_root: []const u8) AppManifestBuildC
|
|
|
2587
2603
|
.credentials_capability = hasManifestCapability(raw.capabilities, "credentials"),
|
|
2588
2604
|
.credentials_permission = hasManifestPermission(raw.permissions, "credentials"),
|
|
2589
2605
|
.filesystem_permission = hasManifestPermission(raw.permissions, "filesystem"),
|
|
2606
|
+
.max_image_pixel_bytes = raw.images.max_image_pixel_bytes,
|
|
2590
2607
|
.sqlite_capability = hasManifestCapability(raw.capabilities, "store") or hasManifestCapability(raw.capabilities, "sqlite"),
|
|
2591
2608
|
.web_declaration = web_layer_contract.manifestDeclaration(raw),
|
|
2592
2609
|
};
|
package/build.zig
CHANGED
|
@@ -206,7 +206,20 @@ pub fn build(b: *std.Build) void {
|
|
|
206
206
|
else
|
|
207
207
|
sqliteCompileFlags(),
|
|
208
208
|
});
|
|
209
|
+
const app_runner_window_placement_mod = module(b, target, optimize, "src/app_runner/window_placement.zig");
|
|
210
|
+
app_runner_window_placement_mod.addImport("native_sdk", desktop_mod);
|
|
211
|
+
const app_runner_window_placement_tests = testArtifact(b, app_runner_window_placement_mod);
|
|
209
212
|
desktop_mod.link_libc = true;
|
|
213
|
+
if (target.result.os.tag == .macos) {
|
|
214
|
+
const flags: []const []const u8 = if (b.sysroot) |sysroot|
|
|
215
|
+
&.{ "-fobjc-arc", "-fno-sanitize=builtin", "-ObjC", "-mmacosx-version-min=11.0", "-isysroot", sysroot, b.fmt("-I{s}/usr/include", .{sysroot}) }
|
|
216
|
+
else
|
|
217
|
+
&.{ "-fobjc-arc", "-fno-sanitize=builtin", "-ObjC", "-mmacosx-version-min=11.0" };
|
|
218
|
+
desktop_mod.addCSourceFile(.{ .file = b.path("src/platform/macos/image_fit_test.m"), .flags = flags });
|
|
219
|
+
desktop_mod.linkFramework("Foundation", .{});
|
|
220
|
+
desktop_mod.linkFramework("ImageIO", .{});
|
|
221
|
+
desktop_mod.linkSystemLibrary("objc", .{});
|
|
222
|
+
}
|
|
210
223
|
const desktop_tests = testArtifact(b, desktop_mod);
|
|
211
224
|
const desktop_test_shards = desktopTestShardArtifacts(b, desktop_mod);
|
|
212
225
|
// Tier-5 crash battery: a child uses the public streamed sink, signals
|
|
@@ -593,6 +606,7 @@ pub fn build(b: *std.Build) void {
|
|
|
593
606
|
test_step.dependOn(&b.addRunArtifact(platform_info_tests).step);
|
|
594
607
|
test_step.dependOn(&b.addRunArtifact(json_tests).step);
|
|
595
608
|
test_step.dependOn(&b.addRunArtifact(app_runner_assets_tests).step);
|
|
609
|
+
test_step.dependOn(&b.addRunArtifact(app_runner_window_placement_tests).step);
|
|
596
610
|
test_step.dependOn(&b.addRunArtifact(canvas_tests).step);
|
|
597
611
|
test_step.dependOn(&b.addRunArtifact(record_store_tests).step);
|
|
598
612
|
test_step.dependOn(&file_crash_run.step);
|
|
@@ -824,6 +838,31 @@ pub fn build(b: *std.Build) void {
|
|
|
824
838
|
.{ .path = "build/app.zig", .pattern = "test_step.dependOn(&analysis_obj.step);" },
|
|
825
839
|
.{ .path = "src/runtime/ui_app.zig", .pattern = "has no default value - give every Model field a default" },
|
|
826
840
|
});
|
|
841
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-owned-runner-window-placement", "Verify owned example runners preserve explicit origins and distinguish successful state restoration", &.{
|
|
842
|
+
.{ .path = "examples/hello/src/runner.zig", .pattern = ".initial_placement = if (@hasField(@TypeOf(window), \"x\") or @hasField(@TypeOf(window), \"y\")) .explicit else .default" },
|
|
843
|
+
.{ .path = "examples/hello/src/runner.zig", .pattern = "window.initial_placement = .restored;" },
|
|
844
|
+
.{ .path = "examples/hello/src/runner.zig", .pattern = "app_info.main_window.initial_placement = .restored;" },
|
|
845
|
+
.{ .path = "examples/capabilities/src/runner.zig", .pattern = "info.main_window.default_frame = manifestShellStartupFrame(info.main_window.default_frame);" },
|
|
846
|
+
.{ .path = "examples/capabilities/src/runner.zig", .pattern = "info.main_window.restore_state = manifestShellStartupRestoreState(info.main_window.restore_state);" },
|
|
847
|
+
.{ .path = "examples/capabilities/src/runner.zig", .pattern = "info.main_window.restore_policy = manifestShellStartupRestorePolicy(info.main_window.restore_policy);" },
|
|
848
|
+
.{ .path = "examples/capabilities/src/runner.zig", .pattern = "info.main_window.initial_placement = manifestShellStartupInitialPlacement(info.main_window.initial_placement);" },
|
|
849
|
+
});
|
|
850
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-macos-window-placement-contracts", "Verify both macOS hosts use the primary display and restore persisted content frames without titlebar growth", &.{
|
|
851
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "return [NSScreen screens].firstObject ?: [NSScreen mainScreen];" },
|
|
852
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "return [NSScreen screens].firstObject ?: [NSScreen mainScreen];" },
|
|
853
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "[window frameRectForContentRect:restoredContentFrame]" },
|
|
854
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "[window frameRectForContentRect:restoredContentFrame]" },
|
|
855
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "[window setFrame:restoredWindowFrame display:NO];" },
|
|
856
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "[window setFrame:restoredWindowFrame display:NO];" },
|
|
857
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "[window setFrame:NativeSdkCenterFrameOnScreen(window.frame, primaryScreen) display:NO];" },
|
|
858
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "[window setFrame:NativeSdkCenterFrameOnScreen(window.frame, primaryScreen) display:NO];" },
|
|
859
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "else if (initialPlacement == 1) {\n // Fresh authored dimensions are content size" },
|
|
860
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "else if (initialPlacement == 1) {\n // AppKit adds titlebar chrome" },
|
|
861
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "[window setFrame:NativeSdkConstrainFrame(window.frame) display:NO];" },
|
|
862
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "[window setFrame:NativeSdkConstrainFrame(window.frame) display:NO];" },
|
|
863
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "initWithFrame:window.contentView.bounds" },
|
|
864
|
+
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "initWithFrame:window.contentView.bounds" },
|
|
865
|
+
});
|
|
827
866
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-bridge-view-selector-helpers", "Verify injected view helpers accept string selectors", &.{
|
|
828
867
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "viewSelectorPayload(options)" },
|
|
829
868
|
.{ .path = "src/platform/macos/cef_host.mm", .pattern = "viewSelectorPayload(options)" },
|
|
@@ -1458,6 +1497,13 @@ pub fn build(b: *std.Build) void {
|
|
|
1458
1497
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkTextNavigationNeedsRawKeyEvent(event)" },
|
|
1459
1498
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "NSEventModifierFlagCommand | NSEventModifierFlagOption" },
|
|
1460
1499
|
});
|
|
1500
|
+
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-widget-accessibility-hierarchy", "Verify AppKit preserves retained-widget accessibility parentage", &.{
|
|
1501
|
+
.{ .path = "src/platform/macos/appkit_host.h", .pattern = "uint64_t parent_id;" },
|
|
1502
|
+
.{ .path = "src/platform/macos/root.zig", .pattern = ".parent_id = node.parent_id orelse 0" },
|
|
1503
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "element.accessibilityParent = parent;" },
|
|
1504
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "parent.accessibilityChildren = [childrenByParentId objectForKey:parentId];" },
|
|
1505
|
+
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "return self.widgetAccessibilityRootElements ?: @[];" },
|
|
1506
|
+
});
|
|
1461
1507
|
addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-appearance-bridge", "Verify AppKit reports system light and dark appearance changes", &.{
|
|
1462
1508
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "effectiveAppearance" },
|
|
1463
1509
|
.{ .path = "src/platform/macos/appkit_host.m", .pattern = "accessibilityDisplayShouldReduceMotion" },
|
|
@@ -1480,6 +1526,7 @@ pub fn build(b: *std.Build) void {
|
|
|
1480
1526
|
addTestStep(b, "test-diagnostics", "Run diagnostics module tests", diagnostics_tests);
|
|
1481
1527
|
addTestStep(b, "test-platform-info", "Run platform info module tests", platform_info_tests);
|
|
1482
1528
|
addTestStep(b, "test-json", "Run JSON primitive tests", json_tests);
|
|
1529
|
+
addTestStep(b, "test-app-runner-window-placement", "Run app-runner window placement decision tests", app_runner_window_placement_tests);
|
|
1483
1530
|
addTestStep(b, "test-canvas", "Run canvas display list tests", canvas_tests);
|
|
1484
1531
|
addTestStep(b, "test-desktop", "Run Native SDK framework tests", desktop_tests);
|
|
1485
1532
|
for (desktop_test_shard_specs, desktop_test_shards) |spec, shard_tests| {
|
|
@@ -1713,6 +1760,7 @@ pub fn build(b: *std.Build) void {
|
|
|
1713
1760
|
"examples/calculator/zig-out/package/test-ios-layout/calculator.xcodeproj/xcshareddata/xcschemes/calculator.xcscheme",
|
|
1714
1761
|
"examples/calculator/zig-out/package/test-ios-layout/Host/uikit_host.m",
|
|
1715
1762
|
"examples/calculator/zig-out/package/test-ios-layout/Host/native_sdk_app.h",
|
|
1763
|
+
"examples/calculator/zig-out/package/test-ios-layout/Host/apple_image_fit.h",
|
|
1716
1764
|
"examples/calculator/zig-out/package/test-ios-layout/Host/Info.plist",
|
|
1717
1765
|
"examples/calculator/zig-out/package/test-ios-layout/Assets.xcassets/AppIcon.appiconset/AppIcon.png",
|
|
1718
1766
|
"examples/calculator/zig-out/package/test-ios-layout/Assets.xcassets/AppIcon.appiconset/Contents.json",
|
|
@@ -1813,13 +1861,20 @@ pub fn build(b: *std.Build) void {
|
|
|
1813
1861
|
});
|
|
1814
1862
|
addFileContainsCheckStep(b, file_contains_checker, mobile_examples_step, "test-example-mobile-widget-abi", "Verify mobile examples use stable widget ABI lookups", &.{
|
|
1815
1863
|
.{ .path = "examples/ios/NativeSdkIOSExample/native_sdk.h", .pattern = "native_sdk_viewport_state_t" },
|
|
1864
|
+
.{ .path = "examples/ios/NativeSdkIOSExample/native_sdk.h", .pattern = "NATIVE_SDK_WIDGET_ROLE_RADIOGROUP = 21" },
|
|
1816
1865
|
.{ .path = "examples/ios/NativeSdkIOSExample/native_sdk.h", .pattern = "native_sdk_app_scroll" },
|
|
1817
1866
|
.{ .path = "examples/ios/NativeSdkIOSExample/native_sdk.h", .pattern = "native_sdk_app_set_text_measure" },
|
|
1867
|
+
.{ .path = "examples/android/app/src/main/cpp/native_sdk.h", .pattern = "NATIVE_SDK_WIDGET_ROLE_RADIOGROUP = 21" },
|
|
1818
1868
|
.{ .path = "examples/android/app/src/main/cpp/native_sdk.h", .pattern = "native_sdk_app_set_text_measure" },
|
|
1819
1869
|
.{ .path = "examples/mobile-canvas/ios/native_sdk_app.h", .pattern = "native_sdk_app_set_text_measure" },
|
|
1820
1870
|
.{ .path = "examples/ios/NativeSdkIOSExample/NativeSdkHostViewController.swift", .pattern = "native_sdk_app_widget_semantics_by_id" },
|
|
1871
|
+
.{ .path = "examples/ios/NativeSdkIOSExample/NativeSdkHostViewController.swift", .pattern = "NATIVE_SDK_WIDGET_ROLE_RADIO" },
|
|
1872
|
+
.{ .path = "examples/ios/NativeSdkIOSExample/NativeSdkHostViewController.swift", .pattern = "childrenByParentId[node.parentId, default: []].append(element)" },
|
|
1873
|
+
.{ .path = "examples/ios/NativeSdkIOSExample/NativeSdkHostViewController.swift", .pattern = "parent.accessibilityContainerType = .semanticGroup" },
|
|
1874
|
+
.{ .path = "examples/ios/NativeSdkIOSExample/NativeSdkHostViewController.swift", .pattern = "parent.isAccessibilityElement = false" },
|
|
1821
1875
|
.{ .path = "examples/android/app/src/main/cpp/native_sdk.h", .pattern = "native_sdk_app_widget_semantics_by_id" },
|
|
1822
1876
|
.{ .path = "examples/android/app/src/main/java/dev/native_sdk/examples/android/MainActivity.kt", .pattern = "nativeScroll(nativeApp" },
|
|
1877
|
+
.{ .path = "examples/android/app/src/main/java/dev/native_sdk/examples/android/MainActivity.kt", .pattern = "WIDGET_ROLE_RADIOGROUP -> \"android.widget.RadioGroup\"" },
|
|
1823
1878
|
.{ .path = "examples/android/app/src/main/java/dev/native_sdk/examples/android/MainActivity.kt", .pattern = "nativeWidgetSemanticsByIdFields" },
|
|
1824
1879
|
.{ .path = "examples/android/app/src/main/cpp/native_sdk_jni.c", .pattern = "native_sdk_app_widget_semantics_by_id" },
|
|
1825
1880
|
.{ .path = "examples/android/app/src/main/cpp/native_sdk_jni.c", .pattern = "native_sdk_app_scroll" },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"scriptc": "0.0.31"
|
|
36
36
|
},
|
|
37
37
|
"optionalDependencies": {
|
|
38
|
-
"@native-sdk/cli-darwin-arm64": "0.9.
|
|
39
|
-
"@native-sdk/cli-darwin-x64": "0.9.
|
|
40
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.9.
|
|
41
|
-
"@native-sdk/cli-linux-arm64-musl": "0.9.
|
|
42
|
-
"@native-sdk/cli-linux-x64-gnu": "0.9.
|
|
43
|
-
"@native-sdk/cli-linux-x64-musl": "0.9.
|
|
44
|
-
"@native-sdk/cli-win32-arm64": "0.9.
|
|
45
|
-
"@native-sdk/cli-win32-x64": "0.9.
|
|
38
|
+
"@native-sdk/cli-darwin-arm64": "0.9.2",
|
|
39
|
+
"@native-sdk/cli-darwin-x64": "0.9.2",
|
|
40
|
+
"@native-sdk/cli-linux-arm64-gnu": "0.9.2",
|
|
41
|
+
"@native-sdk/cli-linux-arm64-musl": "0.9.2",
|
|
42
|
+
"@native-sdk/cli-linux-x64-gnu": "0.9.2",
|
|
43
|
+
"@native-sdk/cli-linux-x64-musl": "0.9.2",
|
|
44
|
+
"@native-sdk/cli-win32-arm64": "0.9.2",
|
|
45
|
+
"@native-sdk/cli-win32-x64": "0.9.2"
|
|
46
46
|
},
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@native-sdk/core",
|
|
9
|
-
"version": "0.9.
|
|
9
|
+
"version": "0.9.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"scriptc": "0.0.31"
|
|
12
12
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@native-sdk/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -614,7 +614,9 @@ export type VideoEventKind<M extends Msgish> = M extends Msgish
|
|
|
614
614
|
/// live id), "not_found" (missing local file, no url), "io_failed" (a local
|
|
615
615
|
/// read failure), "connect_failed"/"tls_failed"/"protocol_failed"/"timed_out"
|
|
616
616
|
/// (the fetch taxonomy), "http_status" (a non-2xx answer; `status` carries
|
|
617
|
-
/// it), "cancelled", "too_large" (
|
|
617
|
+
/// it), "cancelled", "too_large" (the encoded source exceeds the fixed
|
|
618
|
+
/// source bound; conforming codecs decode photo-scale pixels down to the
|
|
619
|
+
/// app's registered-image budget),
|
|
618
620
|
/// "unsupported" (no platform codec), "decode_failed", "registry_full", and
|
|
619
621
|
/// "alloc_failed" (the host refused the memory the registration needed —
|
|
620
622
|
/// resource exhaustion, not corrupt bytes: the same source may load once
|
|
@@ -153,7 +153,7 @@ Zero app code: on macOS every non-virtualized `scroll` region — and every wind
|
|
|
153
153
|
|
|
154
154
|
Authors write ONE menu; the platform decides how it presents. The default is the real OS context menu at the pointer — `NSMenu` on macOS, `TrackPopupMenu` on Windows, `GtkPopoverMenu` on Linux — and the selection dispatches the item's typed `Msg`. On hosts without a native menu presenter (the mobile toolkit hosts and embed hosts today), the SAME declared items present automatically as an anchored canvas surface at the click point, with the standard anchored-surface behavior (Escape and outside-click dismiss, late z-pass, window clipping). Never two authored menus, never a canvas imitation where the OS menu exists.
|
|
155
155
|
|
|
156
|
-
Markup declares the menu as a `<context-menu>` element — a DIRECT child of the
|
|
156
|
+
Markup declares the menu as a `<context-menu>` element — a DIRECT child of the interactive element whose right-click it answers (a hit-target kind, or an element made interactive by `on-press`/`on-double-press`/`on-toggle`/`on-hold`/`on-drag`). It is metadata, not content: it renders nothing in the row's flow. Children are `menu-item`s (`on-press` required, `disabled` optional, the text content is the label) and bare `<separator/>`s, with `if`/`else`/`for` around them to swap or repeat items — a menu whose items all evaporate at runtime simply declares no menu (the All Notes row pattern). Conditional MENUS are spelled as conditional ITEMS: the `<context-menu>` itself takes no attributes and cannot sit behind a structure tag. No submenus: the platform channel carries flat items (label, enabled, separator) only.
|
|
157
157
|
|
|
158
158
|
```html
|
|
159
159
|
<list-item on-press="open_note:{n.id}" label="{n.title}">
|
|
@@ -196,19 +196,19 @@ Automation drives the native path honestly: snapshots list every widget's declar
|
|
|
196
196
|
| `stack`, `panel`, `card` | overlay containers | children stack on top of each other — `gap` can never space them and is a validation error (put a `column`/`row` inside for flow) |
|
|
197
197
|
| `scroll` | scroll_view | wrap multiple children in a `column` inside it |
|
|
198
198
|
| `list`, `grid` | list, grid | vertical stack / cell grid |
|
|
199
|
-
| `tabs`, `toggle-group`, `button-group`, `radio-group`, `breadcrumb`, `pagination` | row containers | children flow horizontally
|
|
199
|
+
| `tabs`, `toggle-group`, `button-group`, `radio-group`, `breadcrumb`, `pagination` | row containers | children flow horizontally. Give every `radio-group` an accessible `label`; it is one logical `radiogroup`: descendant radios at any nesting depth share one Tab stop; arrows wrap while Home/End move to the edges, focus and selection move together, and selecting one clears the rest of the nearest group scope |
|
|
200
200
|
| `table` > `table-row` > `table-cell` | table, data_row, data_cell | rows only inside a table, cells only inside a row (for/if wrappers are fine); cells are text leaves, dispatch with `on-press` |
|
|
201
201
|
| `dropdown-menu` | dropdown_menu | vertical menu surface; children are `menu-item`s. `anchor="below\|above"` floats it against its PARENT's frame (see Pickers): late z-pass above the whole tree, window-clipped, auto-flipping at the window edges, zero flow space. Pair with `on-dismiss` |
|
|
202
202
|
| `accordion` | accordion | header via `text` attr; children show while `selected`, dispatch `on-toggle` |
|
|
203
203
|
| `alert`, `bubble` | surfaces | `alert` title via `text` attr; children stack inside. `bubble` hugs its message up to 80% of the thread (`ghost` exempt; explicit `width` wins) and takes one `<reactions>` child — the reaction pill straddling its bottom edge, one text run, dock via `text-alignment` (default `end`); `text=` on bubble itself is a teaching error (that channel belongs to the pill). Grouped runs are spacing, not vocabulary: 8 gap within a sender's run, 32 between turns |
|
|
204
|
-
| `dialog`, `drawer`, `sheet` | modal surfaces |
|
|
204
|
+
| `dialog`, `drawer`, `sheet` | modal surfaces | root-relative and unaffected by ancestor scroll or clipping: dialogs center in the viewport, drawers span its width and dock to the bottom, and sheets span its height and dock to the right — title via `text` attr, wrap in `<if>` to show conditionally |
|
|
205
205
|
| `resizable` | resizable | engine-managed drag handle; `width` sets the initial width |
|
|
206
206
|
| `split` | split | two-pane horizontal splitter: exactly two element children (nest splits for more panes), the engine synthesizes the draggable divider between them. `value` binds the model-owned first-pane fraction (0 lays out at 0.5), `on-resize` names an f32 Msg variant dispatched with every applied fraction (echo it back through `value` — see Splitters), `min-width` on the panes bounds the drag, `gap` sets the divider band thickness. The divider is focusable: Left/Right (Shift for bigger steps) adjust, Home/End jump to the clamp edges |
|
|
207
207
|
| `tree` | tree | disclosure-tree container (vertical flow): descendant rows carrying `role="treeitem"` — at ANY nesting depth — form one roving keyboard focus set with the ARIA tree keymap. Up/Down walk visible rows (selection follows focus through each row's `on-press`), Left collapses an expanded row or moves to the parent row, Right expands a collapsed row or moves to the first child row, Home/End jump to the edges, Enter/Space activate. Expandable rows bind `expanded` and `on-toggle`; the model owns selection and expansion (collapsed children are simply not rendered) |
|
|
208
208
|
| `text`, `badge`, `tooltip` | text leaves | text content, `{}` interpolation allowed; `text` line policy via `wrap` (`"true"` word-wraps; `"false"`/unset paint one honest line, overflow eliding by default — `overflow="clip"` opts out), and `text` alone takes the typography rungs `size="heading"`/`size="display"` (themable token steps above title — section headings, hero stats, timer numerals). `tooltip` with `anchor="above\|below"` floats against its parent (the stack wrapping trigger + tooltip, the dropdown pattern) and the RUNTIME owns its visibility — hover intent on the trigger: shows after `tooltip-delay` ms (default 600; `"0"` = instant) and immediately on keyboard focus; hides on leave, focus departure, Escape, or a press of the trigger (a press also closes the warm window), and a shared 400ms warm window after a pointer-hovered tooltip hides on leave (the only hide that warms) shows the next trigger's tooltip instantly; the model never hears hover. These are shadcn/ui's defaults (Base UI). Without `anchor` it stays a static leaf that paints whenever the view renders it |
|
|
209
209
|
| `text` > `span` | inline styled runs | mixed-style text in ONE wrapped paragraph: span children style runs with `weight="regular\|medium\|bold"`, `mono`, `italic`, `scale` (a positive multiplier on the paragraph's base size — inline headings, hero stats), `underline`, `foreground` (token name); `{bindings}` interpolate inside spans; whitespace between runs collapses to a single space (none = the runs abut); spans do not nest, take no events, and the paragraph announces as one text run — see "Rich text" |
|
|
210
210
|
| `button`, `toggle-button`, `list-item`, `menu-item`, `toggle`, `switch`, `select`, `avatar` | text-bearing controls | label is the text content; `button`, `toggle-button`, `list-item`, and `menu-item` also take `icon="save"` — a vector icon drawn inline (buttons/toggle-buttons before the label, icon-only when the content is empty: add a `label`; list/menu items as a leading slot), ONE hit target whose icon follows the element's enabled/disabled tint (no overlay stacking, no duplicated `on-press`); tab strips are `toggle-button` children, so tabs get icons this way; `select` shows `placeholder` while empty and dispatches `on-press`; `avatar` renders initials, or a runtime image via `image="{binding}"` (see the Images section) |
|
|
211
|
-
| `checkbox`, `radio`, `slider`, `progress` | value controls | `checked`, `value` (a 0..1 fraction on slider and progress; progress clamps out-of-range values at render, never an error);
|
|
211
|
+
| `checkbox`, `radio`, `slider`, `progress` | value controls | `checked`, `value` (a 0..1 fraction on slider and progress; progress clamps out-of-range values at render, never an error); checkbox/radio visible labels are text content (`<checkbox>Done</checkbox>`), with `text="..."` as the equivalent binding-friendly form and `label=` alone naming one for accessibility without drawing a label; a radio selection TRANSITION (pointer, Space/Enter, grouped navigation, or accessibility selection) dispatches `on-change` when bound, then `on-toggle`, then `on-press` for compatibility — reactivating the already-checked radio has no new `on-change` edge, though a legacy fallback still receives the activation; a slider's `value` follows the source when it MOVES (model-driven progress renders every rebuild) and keeps the user's drag while the source replays the same value — use `slider` for seek bars, `progress` for display-only; a markup slider's `on-change` dispatches a PLAIN Msg with no value payload — mirror the applied value into the model with `Options.sync` (the Zig builder's `on_value = Ui.valueMsg(.tag)` does deliver the applied f32) |
|
|
212
212
|
| `text-field`, `input`, `search-field`, `combobox`, `textarea` | text entry | `placeholder`; edits via `on-input`, enter via `on-submit` on single-line kinds; in a default `textarea`, Enter (and Shift+Enter) inserts a newline and `on-submit` dispatches on primary+Enter (cmd on macOS, ctrl elsewhere). A chat composer opts into `submit-on-enter="true"`: plain Enter submits, Shift+Enter remains a newline, and the primary chord still submits. `search-field` carries a built-in trailing clear affordance whenever it holds text (press the x, or Escape while focused — both clear through the text-edit path, so `on-input` hears it; no attribute, no external Clear button needed) |
|
|
213
213
|
| `status-bar` | status bar | text leaf: content only, no children |
|
|
214
214
|
| `separator`, `spacer` | separator, flexible space | `separator` is axis-aware: a horizontal rule in a `column`, a thin vertical divider in a `row`; give `spacer` a `grow` |
|
|
@@ -221,7 +221,7 @@ Automation drives the native path honestly: snapshots list every widget's declar
|
|
|
221
221
|
| `stepper` > `step` | composite stage track | `active="{index}"` (required) derives each step's completed/active/pending state; steps are text leaves (no attributes) joined by connectors; stepper also takes `key`, `global-key`, `label` |
|
|
222
222
|
| `timeline` > `timeline-item` | composite ledger list | items only inside a timeline (for/if fine); items are leaves — `title` (required), `description`, `meta`, `indicator`, `variant`, `connector="false"` on the last item, `selected`; `on-press` makes the whole item pressable with a trailing chevron |
|
|
223
223
|
| `chart` > `series` | composite data chart | series only inside a chart, and only series (the set is static — data varies through bindings); each series is a leaf — `values="{binding}"` (required) names a model `[]const f32` iterable, `kind` is `line`/`area`/`bar` (literal), `color` a token name, `label` the semantics name; chart takes `y-min`, `y-max`, `grid-lines`, `baseline`, `x-labels`, `y-labels`, `hover-details`, `stroke-width`, box options, `label` — see "Charts" |
|
|
224
|
-
| `context-menu` | consumed by its parent | right-click menu on its DIRECT parent (a hit
|
|
224
|
+
| `context-menu` | consumed by its parent | right-click menu on its DIRECT parent (a hit-target kind or an element with `on-press`/`on-double-press`/`on-toggle`/`on-hold`/`on-drag`); metadata, never a flow child. Children: `menu-item`s (`on-press` required, `disabled` optional, no `icon`) and bare `separator`s, with `if`/`else`/`for` around them. Attribute-less; presents natively where the host has a menu presenter, as an anchored surface elsewhere — see "Context menus" |
|
|
225
225
|
| `input-group` > `textarea` + `input-group-actions` | composite grouped input | the composer shape: ONE bordered field wrapping exactly one `textarea` (first — document order is focus order) plus an optional `input-group-actions` row of controls inside the same border. The group wears the focus ring for its focused descendant and the textarea's own chrome dissolves automatically, so the whole group reads as one field; the textarea keeps its full behavior (`text`, `placeholder`, `on-input`, `on-submit`, `autofocus`, and optional `submit-on-enter`). Group takes `label`, `width`, `height`, `min-width`, `grow`, `key`, `global-key`; the actions row takes `gap` and holds ordinary elements (`if`/`else`/`for` work — swap send for stop while streaming) — put a `<spacer grow="1"/>` between leading and trailing controls (`Ui.inputGroup`/`Ui.inputGroupActions` are the Zig-view equivalents) |
|
|
226
226
|
|
|
227
227
|
Not markup-expressible (deliberately — write these as Zig view functions with `canvas.Ui`): `icon_button` (`<button icon="...">` with empty content is the declarative icon button), `data_grid` (per-column cell templates), `popover`/`menu_surface` (anchored to runtime geometry), `segmented_control` (use `tabs`/`toggle-group`: `<button>` children of `<tabs>` lower to segmented triggers automatically, so the active tab lifts per the house treatment). Charts ARE expressible: `<chart>` with `<series values="{binding}">` children binding model f32 iterables — see the Charts section (`.band` series and dynamic series composition stay with `ui.chart`). Built-in vector icons ARE expressible: `<icon name="search"/>` (closed, compile-checked name set; `Ui.icon` is the Zig-view equivalent). App-authored icons: `canvas.svg_icon.parseComptime(@embedFile("icons/logo.svg"))` parses any SVG in the common 24x24 stroke-icon dialect at comptime; register the parsed table once at boot with `canvas.icons.registerAppIcons(&table)` and draw by name via `ui.appIcon(.{...}, "logo")` or `ElementOptions.icon` — registered names render exactly like built-ins on every draw path. Markup `<icon>`/`<button icon>` stay built-in-only (the compiled engine validates names at comptime, where runtime registrations cannot exist — engine parity). Runtime images ARE expressible: `<image image="{cover}" width="120" height="80" label="Cover art"/>` and `<avatar image="{user_image}">CT</avatar>` bind a `u64` ImageId model field/fn (the id is just model data; 0 draws nothing / keeps the initials fallback) — see the Images section; the `image` binding is required on the leaf (an unbound `<image>` is dead markup) and stays avatar+image scoped.
|
|
@@ -521,7 +521,7 @@ Scroll offsets follow the same mirror discipline as text: the Msg carries the of
|
|
|
521
521
|
|
|
522
522
|
A handler or update error DEGRADES, it does not exit the app: dispatch catches it, records it in a bounded ring (`runtime.dispatchErrors()`, the `error event=... name=...` lines and `dispatch_errors=` count in automation snapshots, and a `dispatch.error` trace record at error level), and the app keeps running. Trace-sink capacity failures likewise never fail dispatch — dropped records are counted (`dropped_trace_records=`), not fatal. Design for it: an arm that can fail should still surface its own status in the model; the error ring is the safety net, not the UX.
|
|
523
523
|
|
|
524
|
-
Presses follow ONE rule: a click lands on the nearest
|
|
524
|
+
Presses follow ONE rule: a click lands on the nearest press-claiming widget under the pointer — plain text, icons, images, badges, and layout containers let it fall through to their closest interactive ancestor, and dragging still selects text. An interactive element is a control kind (button, checkbox, list-item, ...) or ANY element with a bound `on-press`/`on-double-press`/`on-toggle`/`on-hold`/`on-drag`; these handlers make the element a hit target and press claimer. Thus a row can bind `on-press` for clicks or `on-drag` for spatial dragging, and child text still resolves to that row without overlays or duplicated handlers. Nested claimers resolve to the deepest one; editable text fields, scroll containers, and modal surfaces (dialog, drawer, sheet, popover, menus) always claim their own presses. The value/text handlers (`on-change`, `on-submit`, `on-input`) still only belong on controls — both engines and `markup check` reject them on layout/decoration elements with a teaching error.
|
|
525
525
|
|
|
526
526
|
### Keys: quiet list rows and the app-level fallback
|
|
527
527
|
|
|
@@ -1003,7 +1003,7 @@ Rules:
|
|
|
1003
1003
|
|
|
1004
1004
|
- `fx.registerImage(id, w, h, rgba8)` takes already-decoded straight-alpha RGBA8 (exactly `w*h*4` bytes; the runtime copies — your buffer is free on return). `fx.registerImageBytes(id, bytes)` decodes first. `fx.unregisterImage(id)` frees the slot. Outside UiApp: `Runtime.registerCanvasImage` / `registerCanvasImageBytes` / `unregisterCanvasImage`.
|
|
1005
1005
|
- Re-registering an id replaces the pixels; every view repaints and GPU caches re-upload off the changed content fingerprint — no invalidation calls. For caches, mint fresh ids (effect-key style, monotonically increasing) and `unregisterImage` the evictee — never re-key different content onto a live id.
|
|
1006
|
-
- Bounded and loud (`canvas_limits`): 16 slots
|
|
1006
|
+
- Bounded and loud (`canvas_limits`): 16 slots, a 1 MiB decoded-pixel TARGET by default. Encoded images decode aspect-preservingly to fit, so real photos load and the reported dimensions are the registered geometry; raw-pixel `registerImage` remains strict. Image-centric apps may declare app.zon `.images = .{ .max_image_pixel_bytes = 8388608 }` (accepted range 1–8 MiB). Allocation is lazy per used slot, but 16 fully used 8 MiB slots are a declared 128 MiB high-water. Every encoded entry point, including direct `fx.registerImageBytes`, shares the separate flat 8 MiB source bound. Editors needing source-resolution pixels, 1:1 zoom, or tiles own that pipeline through a `gpu_surface` or media-surface producer, not this registry. Errors: `error.ImageRegistryFull`, `error.ImageTooLarge` (encoded source, raw pixels, or a codec-contract violation), `error.ImageDecodeFailed`, `error.InvalidImageId`/`InvalidImageDimensions`, `error.UnsupportedService`.
|
|
1007
1007
|
- A draw referencing an unregistered id skips — a transient loading state can never fail presentation. `ui.avatar` clips a set image to the circle (`cover` fit) and renders the initials argument otherwise.
|
|
1008
1008
|
- Registered images render in live presentation AND `renderCanvasScreenshot`/automation screenshots, so goldens can assert on them.
|
|
1009
1009
|
- Deterministic tests: `harness.null_platform.image_decode = true` enables a strict decoder for the exact PNG subset `canvas.png.writeRgba8` emits — encode a raw RGBA fixture with the canvas PNG writer and drive the full decode→register→draw path with no bundled codec (`src/runtime/canvas_image_tests.zig` is the reference).
|
|
@@ -169,7 +169,7 @@ Four effect families deliver MANY results from one command — a keyed stream th
|
|
|
169
169
|
- `Cmd.channelClose(key)` — close the open channel under the key, if any: staged posts flush, exactly one `"closed"` event (final drop totals aboard) dispatches the event arm, and the key frees. A key with no open channel no-ops.
|
|
170
170
|
- `Cmd.audioCaptureStart(key, { source, sampleRate?, channels? }, { event })` — start a native `"microphone"` or `"system"` audio stream. The host converts into interleaved signed-16 little-endian PCM at 16/24/48 kHz and mono/stereo (default 48 kHz mono), in chunks no larger than 20 ms. The ten-field event arm is matched by NAME: `key`, `state` (exactly `"started" | "data" | "failed" | "stopped" | "rejected"`), `source` (exactly `"microphone" | "system"`), `sampleRate`, `channels`, `timestampMs`, `frames`, `pcm`, `droppedPending`, and `droppedTotal`. PCM is dispatch-lifetime bytes; the commit walker copies it when stored in the model. The bounded queue, wake behavior, drop accounting, journaling, and offline replay are the channel transport's. Microphone and system may run concurrently; a second start for one source replaces that source's prior key.
|
|
171
171
|
- `Cmd.audioCaptureStop(key)` — synchronously quiesce native callbacks, flush already accepted chunks, deliver exactly one `"stopped"` terminal, and free the key. The key remains occupied until that terminal is delivered, so wait for `"stopped"` before reusing it; an earlier restart is rejected. A missing key no-ops. Declare `"microphone"` and/or `"system_audio"` in `app.zon` permissions so macOS dev executables and packaged apps carry the required usage descriptions.
|
|
172
|
-
- `Cmd.imageLoad(id, { path?, url?, cachePath?, expectedBytes? }, { event })` — load an image at runtime under the model-owned NUMERIC ImageId your markup binds (`<image image="{cover}"/>`, `<avatar image="{avatar}"/>`); `id` may be any number expression (ids are model data), a positive integer below 2^53 (a certain-to-be-refused literal like 0 stops the build, NS1030). The source cascade is `audioPlay`'s exactly: local `path` first, a missing file falls through to `url` (fetched whole, installed at the cache path and integrity-gated by `expectedBytes`); at least one of `path`/`url` (NS1029), and prefer OMITTING `cachePath` — the wiring's caches directory (`TsUiApp`'s `image_cache_dir`) derives the content-addressed path from the URL. Exactly ONE `event` arm dispatches per load — a five-field record matched by NAME: `id` (the requested ImageId echoed verbatim, so concurrent loads sharing one arm stay distinguishable; an id the wire cannot carry exactly echoes 0), `state` (the `ImageState` union — exactly the fifteen members `"loaded" | "rejected" | "not_found" | "io_failed" | "connect_failed" | "tls_failed" | "protocol_failed" | "timed_out" | "http_status" | "cancelled" | "too_large" | "unsupported" | "decode_failed" | "registry_full" | "alloc_failed"`, any order; `"alloc_failed"` is resource exhaustion at registration — the host refused the memory, the bytes may be fine, retry when memory frees), `width`/`height` (the
|
|
172
|
+
- `Cmd.imageLoad(id, { path?, url?, cachePath?, expectedBytes? }, { event })` — load an image at runtime under the model-owned NUMERIC ImageId your markup binds (`<image image="{cover}"/>`, `<avatar image="{avatar}"/>`); `id` may be any number expression (ids are model data), a positive integer below 2^53 (a certain-to-be-refused literal like 0 stops the build, NS1030). The source cascade is `audioPlay`'s exactly: local `path` first, a missing file falls through to `url` (fetched whole, installed at the cache path and integrity-gated by `expectedBytes`); at least one of `path`/`url` (NS1029), and prefer OMITTING `cachePath` — the wiring's caches directory (`TsUiApp`'s `image_cache_dir`) derives the content-addressed path from the URL. Exactly ONE `event` arm dispatches per load — a five-field record matched by NAME: `id` (the requested ImageId echoed verbatim, so concurrent loads sharing one arm stay distinguishable; an id the wire cannot carry exactly echoes 0), `state` (the `ImageState` union — exactly the fifteen members `"loaded" | "rejected" | "not_found" | "io_failed" | "connect_failed" | "tls_failed" | "protocol_failed" | "timed_out" | "http_status" | "cancelled" | "too_large" | "unsupported" | "decode_failed" | "registry_full" | "alloc_failed"`, any order; `"alloc_failed"` is resource exhaustion at registration — the host refused the memory, the bytes may be fine, retry when memory frees), `width`/`height` (the actual registered dimensions on `"loaded"`, 0 otherwise), and `status` (the HTTP status for url loads that performed an exchange; 0 when none occurred — local paths, cache hits — so a cached `"loaded"` is distinguishable from a network one). On `"loaded"` the pixels are already registered under the id — store the id in the model then (the store-on-success discipline keeps a fallback rendering until the load lands). One load per id at a time: a duplicate live id dispatches `"rejected"` (the spawn discipline — a load in flight is never replaced implicitly), and image loads are not the string-keyed `Cmd.cancel`'s to end — `Cmd.imageCancel(id)` is their cancel, LOUD like spawn's: the one terminal still arrives as the event arm's `"cancelled"`, and the id frees for a fresh load once it lands (an id with no live load no-ops; the same NS1030 literal gate as `imageLoad`). The default registry has 16 slots and a 1 MiB decoded-pixel target per slot: platform codecs downscale photo-size sources at decode time, preserving aspect, instead of rejecting them. Image-centric apps may declare `.images = .{ .max_image_pixel_bytes = 8388608 }` in app.zon (1–8 MiB accepted); allocation stays lazy per used slot, but filling 16 ceiling-sized slots is a declared 128 MiB high-water. Encoded sources have their own flat 8 MiB bound; only over-bound source bytes report `"too_large"` in normal operation, never a cut decode. `Cmd.imageUnregister(id)` releases a loaded image's registry slot — the gallery eviction move when the 17th distinct image would answer `"registry_full"`: views bound to the id fall back, and the slot accepts the next load. Unregister is synchronous registry surgery, NOT an effect — no result Msg, an unregistered id no-ops (the same NS1030 literal gate) — and it frees only the CURRENT registration: a load in flight under the id still registers at its terminal, so cancel the load first (`Cmd.imageCancel`) to keep the slot free.
|
|
173
173
|
|
|
174
174
|
### The window verbs
|
|
175
175
|
|