@native-sdk/cli 0.8.3 → 0.8.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 +50 -3
- package/build.zig +131 -360
- package/native-sdk.d.ts +4 -0
- package/package.json +9 -9
- package/packages/core/compile-surface/core.ts +90 -1
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.d.ts +65 -2
- package/packages/core/sdk/core.ts +189 -33
- package/packages/core/sdk/events.d.ts +14 -0
- package/packages/core/sdk/events.ts +18 -0
- package/packages/core/src/checker.ts +61 -1
- package/packages/core/src/devhost.ts +3 -3
- package/packages/core/src/diagnostics.ts +4 -4
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +2 -1
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +8 -8
- package/skill-data/ts-core/SKILL.md +16 -13
- package/src/app_runner/ts_core_main.zig +25 -2
- package/src/embed/host.zig +6 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/linux/root.zig +1 -0
- package/src/platform/macos/appkit_host.h +10 -0
- package/src/platform/macos/appkit_host.m +515 -93
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +22 -0
- package/src/platform/macos/root.zig +68 -0
- package/src/platform/null_platform.zig +58 -0
- package/src/platform/root.zig +7 -0
- package/src/platform/types.zig +100 -0
- package/src/platform/windows/root.zig +56 -0
- package/src/platform/windows/webview2_host.cpp +171 -0
- package/src/primitives/app_manifest/types.zig +2 -0
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +296 -114
- package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +29 -5
- package/src/root.zig +10 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/canvas_frame.zig +13 -2
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/effects.zig +313 -2
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/root.zig +3 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_core_host.zig +401 -32
- package/src/runtime/ts_core_host_tests.zig +407 -0
- package/src/runtime/ts_ui_app.zig +39 -1
- package/src/runtime/ui_app.zig +18 -3
- package/src/runtime/ui_app_tests.zig +48 -0
- package/src/runtime/view.zig +2 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/tooling/manifest.zig +1034 -0
- package/src/tooling/package.zig +837 -6
- package/src/tooling/raw_manifest.zig +35 -0
- package/src/tooling/templates.zig +55 -0
- package/tools/corewire/emit_facade.zig +36 -0
|
@@ -30,6 +30,7 @@ pub const RawManifest = struct {
|
|
|
30
30
|
shortcuts: []const RawShortcut = &.{},
|
|
31
31
|
file_associations: []const RawFileAssociation = &.{},
|
|
32
32
|
url_schemes: []const RawUrlScheme = &.{},
|
|
33
|
+
dmg: RawDmg = .{},
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
pub const RawCef = struct {
|
|
@@ -221,3 +222,37 @@ pub const RawUrlScheme = struct {
|
|
|
221
222
|
scheme: []const u8,
|
|
222
223
|
role: []const u8 = "viewer",
|
|
223
224
|
};
|
|
225
|
+
|
|
226
|
+
pub const RawDmgPosition = struct {
|
|
227
|
+
x: u16,
|
|
228
|
+
y: u16,
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
/// One visible Finder item in an explicitly art-directed DMG. `app` names
|
|
232
|
+
/// the packaged bundle (and may override its DMG-only display name),
|
|
233
|
+
/// `applications` creates the conventional alias,
|
|
234
|
+
/// `file` copies a project-relative file or directory, and `link` creates a
|
|
235
|
+
/// symlink to an absolute path. An explicit list replaces the legacy fixed
|
|
236
|
+
/// app/Applications pair.
|
|
237
|
+
pub const RawDmgItem = struct {
|
|
238
|
+
kind: []const u8,
|
|
239
|
+
path: ?[]const u8 = null,
|
|
240
|
+
name: ?[]const u8 = null,
|
|
241
|
+
position: RawDmgPosition,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/// Finder presentation for the macOS archive produced by
|
|
245
|
+
/// `native package --target macos --archive`. The defaults are a complete
|
|
246
|
+
/// drag-to-Applications layout; apps only declare this block when they want
|
|
247
|
+
/// to art-direct it.
|
|
248
|
+
pub const RawDmg = struct {
|
|
249
|
+
volume_name: ?[]const u8 = null,
|
|
250
|
+
background: ?[]const u8 = null,
|
|
251
|
+
window_width: u16 = 660,
|
|
252
|
+
window_height: u16 = 400,
|
|
253
|
+
icon_size: u16 = 128,
|
|
254
|
+
app_position: RawDmgPosition = .{ .x = 166, .y = 182 },
|
|
255
|
+
applications_position: RawDmgPosition = .{ .x = 486, .y = 182 },
|
|
256
|
+
applications_link: bool = true,
|
|
257
|
+
items: []const RawDmgItem = &.{},
|
|
258
|
+
};
|
|
@@ -1468,6 +1468,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1468
1468
|
\\ const app_mod = localModule(b, target, optimize, "src/main.zig");
|
|
1469
1469
|
\\ app_mod.addImport("native_sdk", native_sdk_mod);
|
|
1470
1470
|
\\ app_mod.addImport("runner", runner_mod);
|
|
1471
|
+
\\ addMacosPrivacyInfoPlist(b, app_mod, target, app_config);
|
|
1471
1472
|
\\ const exe = b.addExecutable(.{
|
|
1472
1473
|
\\ .name = app_exe_name,
|
|
1473
1474
|
\\ .root_module = app_mod,
|
|
@@ -1529,6 +1530,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1529
1530
|
\\ const package_app_mod = localModule(b, target, package_optimize, "src/main.zig");
|
|
1530
1531
|
\\ package_app_mod.addImport("native_sdk", package_sdk_mod);
|
|
1531
1532
|
\\ package_app_mod.addImport("runner", package_runner_mod);
|
|
1533
|
+
\\ addMacosPrivacyInfoPlist(b, package_app_mod, target, app_config);
|
|
1532
1534
|
\\ const built = b.addExecutable(.{
|
|
1533
1535
|
\\ .name = app_exe_name,
|
|
1534
1536
|
\\ .root_module = package_app_mod,
|
|
@@ -1600,6 +1602,33 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1600
1602
|
\\ return if (target.result.cpu.arch == .x86_64) true else null;
|
|
1601
1603
|
\\}
|
|
1602
1604
|
\\
|
|
1605
|
+
\\/// Bare Mach-O dev executables have no bundle Info.plist. Embed the
|
|
1606
|
+
\\/// capture usage strings derived from app.zon so macOS can present
|
|
1607
|
+
\\/// consent instead of terminating the process. Packaged apps also
|
|
1608
|
+
\\/// receive the richer external plist from the package command.
|
|
1609
|
+
\\fn addMacosPrivacyInfoPlist(b: *std.Build, app_mod: *std.Build.Module, target: std.Build.ResolvedTarget, config: AppManifestBuildConfig) void {
|
|
1610
|
+
\\ if (target.result.os.tag != .macos) return;
|
|
1611
|
+
\\ if (!config.microphone_permission and !config.system_audio_permission) return;
|
|
1612
|
+
\\
|
|
1613
|
+
\\ const microphone = if (config.microphone_permission)
|
|
1614
|
+
\\ " <key>NSMicrophoneUsageDescription</key>\\n <string>This app captures microphone audio when you start recording.</string>\\n"
|
|
1615
|
+
\\ else
|
|
1616
|
+
\\ "";
|
|
1617
|
+
\\ const system_audio = if (config.system_audio_permission)
|
|
1618
|
+
\\ " <key>NSAudioCaptureUsageDescription</key>\\n <string>This app captures system audio when you start recording.</string>\\n" ++
|
|
1619
|
+
\\ " <key>NSScreenCaptureUsageDescription</key>\\n <string>This app captures system audio when you start recording.</string>\\n"
|
|
1620
|
+
\\ else
|
|
1621
|
+
\\ "";
|
|
1622
|
+
\\ const source = b.fmt(
|
|
1623
|
+
\\ \\#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"
|
|
1624
|
+
\\ \\__attribute__((used, section("__TEXT,__info_plist")))
|
|
1625
|
+
\\ \\static const unsigned char native_sdk_info_plist[sizeof(NATIVE_SDK_INFO_PLIST) - 1] = NATIVE_SDK_INFO_PLIST;
|
|
1626
|
+
\\ \\
|
|
1627
|
+
\\ , .{ microphone, system_audio });
|
|
1628
|
+
\\ const generated = b.addWriteFiles().add("native_sdk_macos_info_plist.c", source);
|
|
1629
|
+
\\ app_mod.addCSourceFile(.{ .file = generated, .flags = &.{} });
|
|
1630
|
+
\\}
|
|
1631
|
+
\\
|
|
1603
1632
|
\\// Resolve the optimize mode for one exe role (mirrors the Native SDK
|
|
1604
1633
|
\\// build graph): an explicit -Doptimize wins for every role, --release
|
|
1605
1634
|
\\// resolves through zig's release_mode, and only when neither was
|
|
@@ -1731,6 +1760,8 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1731
1760
|
\\ }
|
|
1732
1761
|
\\ app_mod.linkFramework("AppKit", .{});
|
|
1733
1762
|
\\ app_mod.linkFramework("AVFoundation", .{});
|
|
1763
|
+
\\ app_mod.linkFramework("CoreMedia", .{});
|
|
1764
|
+
\\ app_mod.linkFramework("ScreenCaptureKit", .{ .weak = true });
|
|
1734
1765
|
\\ app_mod.linkFramework("CoreVideo", .{});
|
|
1735
1766
|
\\ app_mod.linkFramework("MediaToolbox", .{});
|
|
1736
1767
|
\\ app_mod.linkFramework("Accelerate", .{});
|
|
@@ -1846,6 +1877,10 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1846
1877
|
\\ app_mod.linkSystemLibrary("ole32", .{});
|
|
1847
1878
|
\\ app_mod.linkSystemLibrary("oleacc", .{});
|
|
1848
1879
|
\\ app_mod.linkSystemLibrary("shell32", .{});
|
|
1880
|
+
\\ // TypeScript cores link ScriptC's host runtime, whose network-interface
|
|
1881
|
+
\\ // helpers use GetAdaptersAddresses and Winsock address conversion.
|
|
1882
|
+
\\ app_mod.linkSystemLibrary("iphlpapi", .{});
|
|
1883
|
+
\\ app_mod.linkSystemLibrary("ws2_32", .{});
|
|
1849
1884
|
\\ // The audio backend: Media Foundation (session + source resolver
|
|
1850
1885
|
\\ // + streaming audio renderer) and WinHTTP (the cache fill).
|
|
1851
1886
|
\\ app_mod.linkSystemLibrary("mf", .{});
|
|
@@ -1955,6 +1990,8 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1955
1990
|
\\ cef_dir: []const u8 = "third_party/cef/macos",
|
|
1956
1991
|
\\ cef_auto_install: bool = false,
|
|
1957
1992
|
\\ webview_layer: WebLayerOption = .auto,
|
|
1993
|
+
\\ microphone_permission: bool = false,
|
|
1994
|
+
\\ system_audio_permission: bool = false,
|
|
1958
1995
|
\\ /// The first web declaration found (for teaching messages), or
|
|
1959
1996
|
\\ /// null when app.zon declares no web use. `web_engine = "system"`
|
|
1960
1997
|
\\ /// alone is NOT web intent — it is the default in many canvas
|
|
@@ -1967,6 +2004,7 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
1967
2004
|
\\/// ignored. Full schema validation stays with `native validate`.
|
|
1968
2005
|
\\const InferenceManifest = struct {
|
|
1969
2006
|
\\ capabilities: []const []const u8 = &.{},
|
|
2007
|
+
\\ permissions: []const []const u8 = &.{},
|
|
1970
2008
|
\\ web_engine: []const u8 = "system",
|
|
1971
2009
|
\\ webview_layer: []const u8 = "auto",
|
|
1972
2010
|
\\ cef: struct {
|
|
@@ -2005,6 +2043,8 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2005
2043
|
\\ .cef_dir = raw.cef.dir,
|
|
2006
2044
|
\\ .cef_auto_install = raw.cef.auto_install,
|
|
2007
2045
|
\\ .webview_layer = parseWebLayer(raw.webview_layer) orelse @panic("app.zon .webview_layer must be \"auto\", \"include\", or \"exclude\""),
|
|
2046
|
+
\\ .microphone_permission = hasManifestPermission(raw.permissions, "microphone"),
|
|
2047
|
+
\\ .system_audio_permission = hasManifestPermission(raw.permissions, "system_audio"),
|
|
2008
2048
|
\\ };
|
|
2009
2049
|
\\ config.web_declaration = blk: {
|
|
2010
2050
|
\\ if (raw.frontend != null) break :blk "a .frontend block";
|
|
@@ -2021,6 +2061,13 @@ fn buildZig(allocator: std.mem.Allocator, names: TemplateNames, framework_path:
|
|
|
2021
2061
|
\\ return config;
|
|
2022
2062
|
\\}
|
|
2023
2063
|
\\
|
|
2064
|
+
\\fn hasManifestPermission(permissions: []const []const u8, name: []const u8) bool {
|
|
2065
|
+
\\ for (permissions) |permission| {
|
|
2066
|
+
\\ if (std.mem.eql(u8, permission, name)) return true;
|
|
2067
|
+
\\ }
|
|
2068
|
+
\\ return false;
|
|
2069
|
+
\\}
|
|
2070
|
+
\\
|
|
2024
2071
|
\\/// The web-layer decision for this build — the same declare-to-use
|
|
2025
2072
|
\\/// contract the Native SDK's standard build graph, CLI, and runner
|
|
2026
2073
|
\\/// apply: an app is WEB when app.zon declares web use (a .frontend
|
|
@@ -3820,6 +3867,14 @@ test "writeDefaultApp emits Vite project files" {
|
|
|
3820
3867
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "src/platform/macos/cef_host.mm") != null);
|
|
3821
3868
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "src/platform/linux/gtk_host.c") != null);
|
|
3822
3869
|
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "app_manifest_zon") != null);
|
|
3870
|
+
// Standalone frontend builds launch a bare Mach-O during development,
|
|
3871
|
+
// so capture permissions must produce the same embedded usage strings
|
|
3872
|
+
// as the managed graph (for both dev and the separately optimized exe).
|
|
3873
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "permissions: []const []const u8") != null);
|
|
3874
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "hasManifestPermission(raw.permissions, \"microphone\")") != null);
|
|
3875
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSMicrophoneUsageDescription") != null);
|
|
3876
|
+
try std.testing.expect(std.mem.indexOf(u8, build_zig_text, "NSAudioCaptureUsageDescription") != null);
|
|
3877
|
+
try std.testing.expect(std.mem.count(u8, build_zig_text, "addMacosPrivacyInfoPlist(b, ") == 2);
|
|
3823
3878
|
// The generated graph carries the whole web-layer feature: the
|
|
3824
3879
|
// override option, the app.zon inference with its conflict panic,
|
|
3825
3880
|
// the option handed to the runner, and the conditional WebView2
|
|
@@ -2499,6 +2499,7 @@ const FacadeEmitter = struct {
|
|
|
2499
2499
|
\\
|
|
2500
2500
|
\\const nscfFetchMethods = ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD"];
|
|
2501
2501
|
\\const nscfAudioVerbs = ["pause", "resume", "stop", "seek", "volume"];
|
|
2502
|
+
\\const nscfAudioCaptureSources = ["microphone", "system"];
|
|
2502
2503
|
\\const nscfVideoVerbs = ["play", "pause", "stop", "seek", "volume", "muted", "loop"];
|
|
2503
2504
|
\\
|
|
2504
2505
|
\\function nscfEncodeCmd(sink: nscfSink, cmd: nscfCmd<{s}>): void {{
|
|
@@ -2719,6 +2720,41 @@ const FacadeEmitter = struct {
|
|
|
2719
2720
|
\\ nscfWBytes(sink, cmd.subtitle);
|
|
2720
2721
|
\\ nscfWBytes(sink, cmd.body);
|
|
2721
2722
|
\\ return;
|
|
2723
|
+
\\ case "audio_capture_start":
|
|
2724
|
+
\\ nscfWU8(sink, 0x1e);
|
|
2725
|
+
\\ nscfWF64(sink, cmd.key);
|
|
2726
|
+
\\ nscfWU8(sink, nscfMemberIndex(nscfAudioCaptureSources, cmd.source, "audio capture source"));
|
|
2727
|
+
\\ nscfWU32(sink, cmd.sampleRate);
|
|
2728
|
+
\\ nscfWU8(sink, cmd.channels);
|
|
2729
|
+
\\ nscfWU8(sink, nscfTagOf(cmd.eventKind));
|
|
2730
|
+
\\ return;
|
|
2731
|
+
\\ case "audio_capture_stop":
|
|
2732
|
+
\\ nscfWU8(sink, 0x1f);
|
|
2733
|
+
\\ nscfWF64(sink, cmd.key);
|
|
2734
|
+
\\ return;
|
|
2735
|
+
\\ case "fetch_stream": {
|
|
2736
|
+
\\ nscfWU8(sink, 0x20);
|
|
2737
|
+
\\ nscfWShortText(sink, cmd.key);
|
|
2738
|
+
\\ nscfWU8(sink, nscfTagOf(cmd.lineKind));
|
|
2739
|
+
\\ nscfWU8(sink, nscfTagOf(cmd.okKind));
|
|
2740
|
+
\\ nscfWU8(sink, nscfTagOf(cmd.errKind));
|
|
2741
|
+
\\ nscfWU8(sink, nscfMemberIndex(nscfFetchMethods, cmd.method, "fetch method"));
|
|
2742
|
+
\\ nscfWU32(sink, cmd.timeoutMs);
|
|
2743
|
+
\\ nscfWU32(sink, cmd.maxLineBytes);
|
|
2744
|
+
\\ nscfWBytes(sink, cmd.url);
|
|
2745
|
+
\\ if (cmd.headers.length > 255) {
|
|
2746
|
+
\\ nscfTrap("a fetch carries over 255 headers — the wire's header block cannot carry it");
|
|
2747
|
+
\\ }
|
|
2748
|
+
\\ nscfWU8(sink, cmd.headers.length);
|
|
2749
|
+
\\ for (let i = 0; i < cmd.headers.length; i++) {
|
|
2750
|
+
\\ const header = cmd.headers[i]!;
|
|
2751
|
+
\\ nscfWShortText(sink, header.name);
|
|
2752
|
+
\\ const value = header.value;
|
|
2753
|
+
\\ nscfWBytes(sink, typeof value === "string" ? nscfTextBytes(value) : value);
|
|
2754
|
+
\\ }
|
|
2755
|
+
\\ nscfWBytes(sink, cmd.body);
|
|
2756
|
+
\\ return;
|
|
2757
|
+
\\ }
|
|
2722
2758
|
\\ case "batch":
|
|
2723
2759
|
\\ for (let i = 0; i < cmd.cmds.length; i++) {
|
|
2724
2760
|
\\ nscfEncodeCmd(sink, cmd.cmds[i]!);
|