@native-sdk/cli 0.9.4 → 0.10.0

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.
Files changed (97) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +75 -57
  3. package/build/ts_run.mjs +1 -1
  4. package/build.zig +20 -2
  5. package/package.json +11 -10
  6. package/packages/core/package-lock.json +12 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/compiler_command.mjs +1 -1
  9. package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
  10. package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
  11. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  12. package/packages/core/sdk/events.d.ts +33 -4
  13. package/packages/core/sdk/events.ts +45 -6
  14. package/packages/core/src/checker.ts +103 -8
  15. package/packages/core/src/modules.ts +6 -2
  16. package/packages/core/src/sqlite_cli.ts +22 -2
  17. package/packages/core/src/typed_ast.ts +4 -2
  18. package/packages/core/src/types.ts +8 -8
  19. package/schemas/app.schema.json +446 -0
  20. package/skill-data/core/SKILL.md +53 -15
  21. package/skill-data/core/references/project-anatomy.md +6 -6
  22. package/skill-data/native-ui/SKILL.md +26 -5
  23. package/skill-data/ts-core/SKILL.md +6 -6
  24. package/skill-data/ts-services/references/service-surface.md +1 -1
  25. package/skills/native-sdk/SKILL.md +2 -2
  26. package/src/app_runner/root.zig +25 -0
  27. package/src/automation/snapshot.zig +91 -3
  28. package/src/platform/macos/appkit_host.h +66 -2
  29. package/src/platform/macos/appkit_host.m +735 -24
  30. package/src/platform/macos/cef_host.mm +208 -9
  31. package/src/platform/macos/root.zig +205 -3
  32. package/src/platform/null_platform.zig +50 -1
  33. package/src/platform/null_platform_tests.zig +53 -0
  34. package/src/platform/root.zig +12 -0
  35. package/src/platform/types.zig +73 -0
  36. package/src/platform/windows/root.zig +88 -15
  37. package/src/primitives/app_manifest/tests.zig +19 -0
  38. package/src/primitives/app_manifest/validation.zig +14 -2
  39. package/src/primitives/canvas/font_ttf.zig +24 -0
  40. package/src/primitives/canvas/gpu.zig +5 -0
  41. package/src/primitives/canvas/reference.zig +41 -16
  42. package/src/primitives/canvas/reference_tests.zig +63 -0
  43. package/src/primitives/canvas/render_tests.zig +1 -1
  44. package/src/primitives/canvas/root.zig +1 -0
  45. package/src/primitives/canvas/serialization.zig +1 -0
  46. package/src/primitives/canvas/test_support.zig +1 -0
  47. package/src/primitives/canvas/text.zig +1 -0
  48. package/src/primitives/canvas/text_layout.zig +84 -15
  49. package/src/primitives/canvas/text_layout_hash.zig +3 -1
  50. package/src/primitives/canvas/text_layout_types.zig +3 -0
  51. package/src/primitives/canvas/text_metrics.zig +28 -1
  52. package/src/primitives/canvas/text_tests.zig +61 -6
  53. package/src/primitives/canvas/ui.zig +9 -0
  54. package/src/primitives/canvas/ui_markup.zig +29 -0
  55. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  56. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  57. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  58. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  59. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  60. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  61. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  62. package/src/primitives/canvas/ui_schema.zig +9 -0
  63. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  64. package/src/primitives/canvas/ui_tests.zig +4 -2
  65. package/src/primitives/canvas/widget_render.zig +13 -2
  66. package/src/primitives/canvas/widget_render_controls.zig +1 -0
  67. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  68. package/src/root.zig +6 -0
  69. package/src/runtime/automation_snapshot.zig +3 -0
  70. package/src/runtime/canvas_fonts.zig +87 -0
  71. package/src/runtime/core.zig +1 -0
  72. package/src/runtime/flow.zig +8 -1
  73. package/src/runtime/native_command_event_tests.zig +58 -0
  74. package/src/runtime/state.zig +14 -0
  75. package/src/runtime/system_services.zig +62 -0
  76. package/src/runtime/ts_ui_app.zig +161 -33
  77. package/src/runtime/ui_app.zig +33 -1
  78. package/src/runtime/ui_app_tests.zig +63 -0
  79. package/src/runtime/validation.zig +87 -1
  80. package/src/tooling/android.zig +5 -4
  81. package/src/tooling/buildgraph.zig +24 -8
  82. package/src/tooling/db.zig +1 -1
  83. package/src/tooling/doctor.zig +1 -1
  84. package/src/tooling/ios.zig +5 -4
  85. package/src/tooling/json_to_zon.zig +136 -0
  86. package/src/tooling/manifest.zig +199 -35
  87. package/src/tooling/package.zig +33 -0
  88. package/src/tooling/raw_manifest.zig +11 -0
  89. package/src/tooling/root.zig +2 -0
  90. package/src/tooling/templates.zig +210 -116
  91. package/src/tooling/ts_core.zig +11 -7
  92. package/src/tooling/update.zig +576 -0
  93. package/src/tooling/verbs.zig +7 -6
  94. package/src/tooling/web_engine.zig +17 -1
  95. package/src/updater/c_api.zig +123 -0
  96. package/src/updater/feed.zig +215 -0
  97. package/src/updater/root.zig +10 -0
package/README.md CHANGED
@@ -20,7 +20,7 @@ cd my_app
20
20
  native dev
21
21
  ```
22
22
 
23
- A native window opens with a working counter. The primary scaffold is three files of truth and no build config: `src/core.ts` (`Model`, `Msg`, `update`), `src/app.native` (the UI), and `app.zon` (the manifest). `native dev|build|test` own the generated build; `src/app.native` hot-reloads while the app runs, keeping your state; `native dev --core` runs the TypeScript logic loop under node; and `native check` validates the core and every view in milliseconds without building. Prefer a Zig core? Use `native init my_app --template zig-core`.
23
+ A native window opens with a working counter. The primary scaffold is three files of truth and no build config: `src/core.ts` (`Model`, `Msg`, `update`), `src/app.native` (the UI), and `app.json` (the manifest, with JSON Schema completion). Existing `app.zon` manifests remain supported. `native dev|build|test` own the generated build; `src/app.native` hot-reloads while the app runs, keeping your state; `native dev --core` runs the TypeScript logic loop under node; and `native check` validates the core and every view in milliseconds without building. Prefer a Zig core? Use `native init my_app --template zig-core`.
24
24
 
25
25
  When part of your product is the web, WebView surfaces coexist with the native canvas; web-frontend scaffolds (`--frontend next`, `--frontend vite`, and more) install their generated frontend dependencies automatically on first run.
26
26
 
@@ -34,11 +34,11 @@ Read the full guide at [native-sdk.dev/quick-start](https://native-sdk.dev/quick
34
34
  | `native dev [dir]` | Build and run the app (markup hot reload; managed frontend dev server when configured) |
35
35
  | `native build [dir]` | Build a ReleaseFast binary into `zig-out/bin/` |
36
36
  | `native test [dir]` | Run the app's test suite |
37
- | `native check [dir]` | Validate `src/**.native` markup and `app.zon` against the model contract |
37
+ | `native check [dir]` | Validate `src/**.native` markup and `app.json`/`app.zon` against the model contract |
38
38
  | `native markup check\|lsp` | Check individual markup files, or serve diagnostics, completion, and hover to your editor |
39
39
  | `native eject [dir]` | Write an owned build.zig/build.zig.zon into the app |
40
40
  | `native doctor` | Check host environment, WebView, manifest, and CEF |
41
- | `native validate` | Validate `app.zon` against the manifest schema |
41
+ | `native validate` | Validate `app.json` (or `app.zon`) against the manifest schema |
42
42
  | `native package` | Package the app for distribution |
43
43
  | `native bundle-assets` | Copy frontend assets into the build output |
44
44
  | `native automate` | Drive a running app: snapshots, widgets, assertions, screenshots, record/replay |
package/build/app.zig CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  const std = @import("std");
7
7
  const builtin = @import("builtin");
8
+ const json_to_zon = @import("../src/tooling/json_to_zon.zig");
8
9
 
9
10
  /// Canonicalize a generated file by its CONTENT before another build step
10
11
  /// consumes it. `std.Build.Step.Run` normally places outputs under a cache
@@ -121,6 +122,9 @@ const WebLayerOption = web_layer_contract.WebViewLayer;
121
122
 
122
123
  pub const AppOptions = struct {
123
124
  name: []const u8,
125
+ /// Explicit manifest path. Null auto-detects app.json first, then app.zon,
126
+ /// so older owned build.zig files can adopt JSON without a build edit.
127
+ manifest: ?[]const u8 = null,
124
128
  /// App entry point; defaults to src/main.zig (relative to `app_root`).
125
129
  main: []const u8 = "src/main.zig",
126
130
  /// Root of the app source tree, relative to the build root. "." for a
@@ -163,6 +167,34 @@ fn appFileExists(b: *std.Build, app_root: []const u8, sub_path: []const u8) bool
163
167
  return true;
164
168
  }
165
169
 
170
+ fn appManifestName(b: *std.Build, app_root: []const u8, requested: ?[]const u8) []const u8 {
171
+ if (requested) |name| return name;
172
+ if (appFileExists(b, app_root, "app.json")) return "app.json";
173
+ return "app.zon";
174
+ }
175
+
176
+ fn appManifestPath(b: *std.Build, app_root: []const u8, manifest_name: []const u8) []const u8 {
177
+ return appPath(b, app_root, manifest_name);
178
+ }
179
+
180
+ /// Produce the Zig module consumed by the existing comptime manifest wiring.
181
+ /// ZON manifests are already modules; JSON manifests are converted losslessly
182
+ /// into a generated module, keeping one runtime feature path for both formats.
183
+ fn appManifestModule(b: *std.Build, app_root: []const u8, manifest_name: []const u8) *std.Build.Module {
184
+ const path = appManifestPath(b, app_root, manifest_name);
185
+ if (!json_to_zon.isJsonPath(path)) {
186
+ return b.createModule(.{ .root_source_file = b.path(path) });
187
+ }
188
+ const source = b.build_root.handle.readFileAlloc(b.graph.io, path, b.allocator, .limited(1024 * 1024)) catch
189
+ @panic("cannot read app.json");
190
+ const zon = json_to_zon.convertAlloc(b.allocator, source) catch |err| switch (err) {
191
+ error.NullNotAllowed => @panic("app.json cannot contain null values; omit optional fields instead"),
192
+ else => @panic("cannot convert app.json into the build-time manifest module; run `native check` for a precise diagnostic"),
193
+ };
194
+ const generated = b.addWriteFiles().add("app_manifest.zon", zon);
195
+ return b.createModule(.{ .root_source_file = generated });
196
+ }
197
+
166
198
  const TsWindowView = struct {
167
199
  label: []const u8,
168
200
  source_path: []const u8,
@@ -676,48 +708,6 @@ fn tsParseQuotedManifestValue(manifest_json: []const u8, comptime key: []const u
676
708
  return suffix;
677
709
  }
678
710
 
679
- /// The external compiler's published `scriptc` binary entrypoint,
680
- /// resolved by node's ancestor node_modules walk from the SDK's
681
- /// packages/core — the same origin the frontend toolchain resolves from
682
- /// (tsAliasedCompilerVersion's walk, kept in lockstep). Repo checkouts
683
- /// install it there with `npm ci`; the npm-installed CLI carries the
684
- /// compiler as a regular dependency, nested under the package on global
685
- /// prefixes and hoisted to the project root on local ones.
686
- fn tsExternalCompilerBin(b: *std.Build, dep: *std.Build.Dependency) ?[]const u8 {
687
- const io = b.graph.io;
688
- const sdk_root = tsSdkRoot(b.allocator, io, dep);
689
- var dir: []const u8 = b.pathJoin(&.{ sdk_root, "packages", "core" });
690
- while (true) {
691
- if (!std.mem.eql(u8, std.fs.path.basename(dir), "node_modules")) {
692
- const candidate = b.pathJoin(&.{ dir, "node_modules", ".bin", if (builtin.os.tag == .windows) "scriptc.cmd" else "scriptc" });
693
- found: {
694
- std.Io.Dir.cwd().access(io, candidate, .{}) catch break :found;
695
- return candidate;
696
- }
697
- }
698
- dir = std.fs.path.dirname(dir) orelse return null;
699
- }
700
- }
701
-
702
- fn requireTsExternalCompilerBin(b: *std.Build, dep: *std.Build.Dependency) []const u8 {
703
- return tsExternalCompilerBin(b, dep) orelse {
704
- const sdk_root = tsSdkRoot(dep.builder.allocator, dep.builder.graph.io, dep);
705
- std.debug.print(
706
- \\
707
- \\error: the external TypeScript compiler is not installed (cores and services
708
- \\compile through it). It ships as an exact-pinned dependency of the SDK's
709
- \\packages/core — install it once with:
710
- \\ cd {s}/packages/core && npm ci
711
- \\(or point NATIVE_SDK_CORE_COMPILER at the pinned release's command; an
712
- \\npm-installed @native-sdk/cli carries the compiler automatically — if it is
713
- \\missing there, the install is broken: reinstall @native-sdk/cli).
714
- \\
715
- \\
716
- , .{sdk_root});
717
- std.process.exit(1);
718
- };
719
- }
720
-
721
711
  /// PR 166 adds both the published compile-cache bootstrap and the optional
722
712
  /// library-profile optimization field. The installed bootstrap is therefore
723
713
  /// the capability marker: keep older exact pins byte-for-byte compatible;
@@ -902,6 +892,16 @@ fn tsCoreStage(
902
892
  sqlite_check.addFileArg(dep.path("packages/core/compile-surface/core.ts"));
903
893
  sqlite_check.addArg("--sdk-out");
904
894
  checked_sdk_core = sqlite_check.addOutputFileArg("core.ts");
895
+ sqlite_check.addArg("--sdk-events-out");
896
+ _ = sqlite_check.addOutputFileArg("events.ts");
897
+ sqlite_check.addArg("--sdk-text-out");
898
+ _ = sqlite_check.addOutputFileArg("text.ts");
899
+ sqlite_check.addArg("--sdk-bytes-text-methods-out");
900
+ _ = sqlite_check.addOutputFileArg("bytes_text_methods.d.ts");
901
+ sqlite_check.addArg("--sdk-events-dts-out");
902
+ _ = sqlite_check.addOutputFileArg("events.d.ts");
903
+ sqlite_check.addArg("--sdk-text-dts-out");
904
+ _ = sqlite_check.addOutputFileArg("text.d.ts");
905
905
  sqlite_check.addArg("--static-out");
906
906
  checked_static_core = sqlite_check.addOutputFileArg("core_static.ts");
907
907
  sqlite_check.addArg("--zig-out");
@@ -914,6 +914,9 @@ fn tsCoreStage(
914
914
  }
915
915
  sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_codegen.ts"));
916
916
  sqlite_check.addFileInput(dep.path("packages/core/src/sqlite_runtime_policy.ts"));
917
+ for ([_][]const u8{ "events.ts", "text.ts", "bytes_text_methods.d.ts", "events.d.ts", "text.d.ts" }) |source| {
918
+ sqlite_check.addFileInput(dep.path(b.fmt("packages/core/sdk/{s}", .{source})));
919
+ }
917
920
  addAppSqlDirInputs(b, sqlite_check, appPath(b, app_root, "src"));
918
921
  }
919
922
 
@@ -1087,8 +1090,11 @@ fn tsCoreStage(
1087
1090
  if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
1088
1091
  service_compile.addArgs(&.{ "--compiler", override });
1089
1092
  } else {
1090
- const compiler_bin = requireTsExternalCompilerBin(b, dep);
1091
- service_compile.addArgs(&.{ "--compiler", compiler_bin });
1093
+ // Let Node resolve the dependency from the SDK package origin:
1094
+ // this is npm's own nested/hoisted/global-sibling walk, and the
1095
+ // driver follows scriptc's published `bin` declaration.
1096
+ service_compile.addArg("--compiler-package-origin");
1097
+ service_compile.addFileArg(dep.path("packages/core/package.json"));
1092
1098
  }
1093
1099
  }
1094
1100
 
@@ -1158,8 +1164,8 @@ fn tsCoreStage(
1158
1164
  // driver still refuses a release other than the SDK's pin.
1159
1165
  compile.addArgs(&.{ "--compiler", override });
1160
1166
  } else {
1161
- const compiler_bin = requireTsExternalCompilerBin(b, dep);
1162
- compile.addArgs(&.{ "--compiler", compiler_bin });
1167
+ compile.addArg("--compiler-package-origin");
1168
+ compile.addFileArg(dep.path("packages/core/package.json"));
1163
1169
  }
1164
1170
 
1165
1171
  // The mirror, generated from the archive's OWN co-emitted contract.
@@ -1627,7 +1633,8 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1627
1633
  " src/main.zig,\nor keep src/main.zig and delete src/core.ts. (Other Zig files under" ++
1628
1634
  " src/ are fine either way.)\n");
1629
1635
  }
1630
- const app_config = appManifestBuildConfig(b, app_options.app_root);
1636
+ const manifest_name = appManifestName(b, app_options.app_root, app_options.manifest);
1637
+ const app_config = appManifestBuildConfig(b, app_options.app_root, manifest_name);
1631
1638
  // The core-compiler setting names the one lane there is; the flag
1632
1639
  // overrides app.zon's `.core_compiler` and both exist so a stated
1633
1640
  // choice stays stateable (and so the removed lane's spelling teaches
@@ -1708,7 +1715,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1708
1715
  .archive = stage.archive,
1709
1716
  .service_archive = stage.service_archive,
1710
1717
  .markup_c = stage.markup_c,
1711
- .manifest_mod = b.createModule(.{ .root_source_file = b.path(appPath(b, app_options.app_root, "app.zon")) }),
1718
+ .manifest_mod = appManifestModule(b, app_options.app_root, manifest_name),
1712
1719
  } else null,
1713
1720
  });
1714
1721
  }
@@ -1735,6 +1742,9 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1735
1742
  @panic("-Dplatform=windows requires a Windows target");
1736
1743
  }
1737
1744
  const web_engine = web_engine_override orelse app_config.web_engine;
1745
+ if (app_config.updates_enabled and selected_platform == .macos and web_engine == .chromium) {
1746
+ @panic("\nnative updates currently require the system macOS host; use web_engine = \"system\" or remove the updates block\n");
1747
+ }
1738
1748
  const cef_dir = cef_dir_override orelse defaultCefDir(selected_platform, app_config.cef_dir);
1739
1749
  const cef_auto_install = cef_auto_install_override orelse app_config.cef_auto_install;
1740
1750
  if (web_engine == .chromium and selected_platform != .macos) {
@@ -1758,7 +1768,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1758
1768
  options.addOption(bool, "web_layer", web_layer);
1759
1769
  const options_mod = options.createModule();
1760
1770
 
1761
- const app_mod = appModule(b, dep, target, app_optimize, app_options, options_mod, ts_stage, relational_migrations, app_config);
1771
+ const app_mod = appModule(b, dep, target, app_optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config);
1762
1772
  // TypeScript app code and platform hosts are expensive Zig/Clang semantic
1763
1773
  // work but do not depend on primary markup bytes. Compile them once into
1764
1774
  // an object, then make the executable a link-only artifact over that
@@ -1839,7 +1849,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1839
1849
  // the production app module feeds the cached app-code object and must not
1840
1850
  // absorb the separately linked markup data object.
1841
1851
  const test_app_mod = if (ts_stage != null or app_optimize != optimize)
1842
- appModule(b, dep, target, optimize, app_options, options_mod, ts_stage, relational_migrations, app_config)
1852
+ appModule(b, dep, target, optimize, app_options, manifest_name, options_mod, ts_stage, relational_migrations, app_config)
1843
1853
  else
1844
1854
  app_mod;
1845
1855
  if (ts_stage) |stage| test_app_mod.addObject(markupDataObject(b, target, optimize, stage.markup_c));
@@ -1938,7 +1948,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1938
1948
  // WebView2 loader) from the framework root; the cached artifact's
1939
1949
  // own location cannot derive it, so hand it over explicitly.
1940
1950
  package_run.setEnvironmentVariable("NATIVE_SDK_PATH", dep.builder.pathFromRoot("."));
1941
- package_run.addArgs(&.{ "package", "--target", package_target_name, "--manifest", "app.zon", "--output" });
1951
+ package_run.addArgs(&.{ "package", "--target", package_target_name, "--manifest", manifest_name, "--output" });
1942
1952
  package_run.addArg(if (host_os == .macos)
1943
1953
  b.fmt("zig-out/package/{s}.app", .{app_options.name})
1944
1954
  else
@@ -1966,6 +1976,7 @@ pub fn addAppArtifacts(b: *std.Build, dep: *std.Build.Dependency, app_options: A
1966
1976
  // runtime (the generated build graph already forwards them).
1967
1977
  package_run.addArgs(&.{ "--web-engine", @tagName(web_engine), "--cef-dir", cef_dir });
1968
1978
  if (cef_auto_install) package_run.addArg("--cef-auto-install");
1979
+ if (app_config.updates_enabled and host_os == .macos) package_run.addArg("--update-archive");
1969
1980
  package_run.has_side_effects = true;
1970
1981
  const package_step = b.step("package", "Create a distributable package via the native CLI");
1971
1982
  package_step.dependOn(&package_run.step);
@@ -2015,14 +2026,14 @@ fn exampleOptimizeMode(b: *std.Build, requested: ?std.builtin.OptimizeMode, defa
2015
2026
  };
2016
2027
  }
2017
2028
 
2018
- fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig) *std.Build.Module {
2029
+ fn appModule(b: *std.Build, dep: *std.Build.Dependency, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, app_options: AppOptions, manifest_name: []const u8, options_mod: *std.Build.Module, ts_stage: ?TsCoreStage, relational_migrations: std.Build.LazyPath, app_config: AppManifestBuildConfig) *std.Build.Module {
2019
2030
  const native_sdk_mod = nativeSdkModuleWithTerminal(b, dep, target, optimize, app_options.terminal_sessions);
2020
2031
  const runner_mod = b.createModule(.{
2021
2032
  .root_source_file = dep.path("src/app_runner/root.zig"),
2022
2033
  .target = target,
2023
2034
  .optimize = optimize,
2024
2035
  });
2025
- const manifest_mod = b.createModule(.{ .root_source_file = b.path(appPath(b, app_options.app_root, "app.zon")) });
2036
+ const manifest_mod = appManifestModule(b, app_options.app_root, manifest_name);
2026
2037
  runner_mod.addImport("native_sdk", native_sdk_mod);
2027
2038
  runner_mod.addImport("build_options", options_mod);
2028
2039
  runner_mod.addImport("app_manifest_zon", manifest_mod);
@@ -2740,6 +2751,7 @@ const AppManifestBuildConfig = struct {
2740
2751
  credentials_permission: bool = false,
2741
2752
  filesystem_permission: bool = false,
2742
2753
  max_image_pixel_bytes: usize = 1024 * 1024,
2754
+ updates_enabled: bool = false,
2743
2755
  sqlite_capability: bool = false,
2744
2756
  /// The first web declaration found (for teaching messages), or null
2745
2757
  /// when app.zon declares no web use. `web_engine = "system"` alone is
@@ -2779,6 +2791,7 @@ const InferenceManifest = struct {
2779
2791
  service_packages: []const ServicePackageConfig = &.{},
2780
2792
  service_carrier: []const u8 = "auto",
2781
2793
  service_pool_size: u8 = 0,
2794
+ updates: ?struct {} = null,
2782
2795
  shell: struct {
2783
2796
  windows: []const struct {
2784
2797
  views: []const struct {
@@ -2805,15 +2818,19 @@ fn appPath(b: *std.Build, app_root: []const u8, sub_path: []const u8) []const u8
2805
2818
  return b.pathJoin(&.{ app_root, sub_path });
2806
2819
  }
2807
2820
 
2808
- fn appManifestBuildConfig(b: *std.Build, app_root: []const u8) AppManifestBuildConfig {
2821
+ fn appManifestBuildConfig(b: *std.Build, app_root: []const u8, manifest_name: []const u8) AppManifestBuildConfig {
2809
2822
  // The fallback for a manifest this lenient parse cannot read keeps
2810
2823
  // the web layer (see AppManifestBuildConfig): a shape mismatch here
2811
2824
  // is not proof the app declares no web use.
2812
2825
  const fallback: AppManifestBuildConfig = .{ .web_declaration = .unreadable_manifest };
2813
- const source = b.build_root.handle.readFileAlloc(b.graph.io, appPath(b, app_root, "app.zon"), b.allocator, .limited(1024 * 1024)) catch return fallback;
2814
- const source_z = b.allocator.dupeZ(u8, source) catch return fallback;
2826
+ const source = b.build_root.handle.readFileAlloc(b.graph.io, appPath(b, app_root, manifest_name), b.allocator, .limited(1024 * 1024)) catch return fallback;
2815
2827
  @setEvalBranchQuota(2000);
2816
- const raw = std.zon.parse.fromSliceAlloc(InferenceManifest, b.allocator, source_z, null, .{ .ignore_unknown_fields = true }) catch return fallback;
2828
+ const raw = if (std.ascii.eqlIgnoreCase(std.fs.path.extension(manifest_name), ".json"))
2829
+ std.json.parseFromSliceLeaky(InferenceManifest, b.allocator, source, .{ .ignore_unknown_fields = true }) catch return fallback
2830
+ else zon: {
2831
+ const source_z = b.allocator.dupeZ(u8, source) catch return fallback;
2832
+ break :zon std.zon.parse.fromSliceAlloc(InferenceManifest, b.allocator, source_z, null, .{ .ignore_unknown_fields = true }) catch return fallback;
2833
+ };
2817
2834
  // `.core_compiler` names the one lane there is; validated here so
2818
2835
  // the removed transpiled lane's spelling teaches at configure time.
2819
2836
  if (!std.mem.eql(u8, raw.core_compiler, "external")) {
@@ -2840,6 +2857,7 @@ fn appManifestBuildConfig(b: *std.Build, app_root: []const u8) AppManifestBuildC
2840
2857
  .credentials_permission = hasManifestPermission(raw.permissions, "credentials"),
2841
2858
  .filesystem_permission = hasManifestPermission(raw.permissions, "filesystem"),
2842
2859
  .max_image_pixel_bytes = raw.images.max_image_pixel_bytes,
2860
+ .updates_enabled = raw.updates != null,
2843
2861
  .sqlite_capability = hasManifestCapability(raw.capabilities, "store") or hasManifestCapability(raw.capabilities, "sqlite"),
2844
2862
  .web_declaration = web_layer_contract.manifestDeclaration(raw),
2845
2863
  };
package/build/ts_run.mjs CHANGED
@@ -13,7 +13,7 @@
13
13
  // relied on: it refuses node_modules-resident .ts by design
14
14
  // (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING), and outside node_modules
15
15
  // it only became DEFAULT in node 22.18. Hooking everything keeps both layouts
16
- // identical. scriptc 0.0.33 requires Node 24 for its published compile-cache
16
+ // identical. scriptc 0.0.35 requires Node 24 for its published compile-cache
17
17
  // bootstrap, so this shared runner enforces the same floor before importing
18
18
  // any frontend module. Then it imports the requested module with argv
19
19
  // respliced so the target sees its usual shape (its own path at argv[1],
package/build.zig CHANGED
@@ -320,6 +320,7 @@ pub fn build(b: *std.Build) void {
320
320
  const ios_host_mod = module(b, target, optimize, "src/platform/ios/files.zig");
321
321
  const android_host_mod = module(b, target, optimize, "src/platform/android/files.zig");
322
322
  const tooling_mod = module(b, target, optimize, "src/tooling/root.zig");
323
+ const update_feed_mod = module(b, target, optimize, "src/updater/feed.zig");
323
324
  tooling_mod.addImport("assets", assets_mod);
324
325
  tooling_mod.addImport("app_dirs", app_dirs_mod);
325
326
  tooling_mod.addImport("app_manifest", app_manifest_mod);
@@ -331,6 +332,7 @@ pub fn build(b: *std.Build) void {
331
332
  tooling_mod.addImport("ios_host", ios_host_mod);
332
333
  tooling_mod.addImport("android_host", android_host_mod);
333
334
  tooling_mod.addImport("sqlite_engine", module(b, target, optimize, "src/runtime/sqlite_engine.zig"));
335
+ tooling_mod.addImport("update_feed", update_feed_mod);
334
336
  tooling_mod.addIncludePath(b.path("third_party/sqlite"));
335
337
  tooling_mod.addCSourceFile(.{
336
338
  .file = b.path("third_party/sqlite/sqlite3.c"),
@@ -440,6 +442,7 @@ pub fn build(b: *std.Build) void {
440
442
  const host_ios_host_mod = module(b, host_target, optimize, "src/platform/ios/files.zig");
441
443
  const host_android_host_mod = module(b, host_target, optimize, "src/platform/android/files.zig");
442
444
  const host_tooling_mod = module(b, host_target, optimize, "src/tooling/root.zig");
445
+ const host_update_feed_mod = module(b, host_target, optimize, "src/updater/feed.zig");
443
446
  host_tooling_mod.addImport("assets", host_assets_mod);
444
447
  host_tooling_mod.addImport("app_dirs", host_app_dirs_mod);
445
448
  host_tooling_mod.addImport("app_manifest", host_app_manifest_mod);
@@ -451,6 +454,7 @@ pub fn build(b: *std.Build) void {
451
454
  host_tooling_mod.addImport("ios_host", host_ios_host_mod);
452
455
  host_tooling_mod.addImport("android_host", host_android_host_mod);
453
456
  host_tooling_mod.addImport("sqlite_engine", module(b, host_target, optimize, "src/runtime/sqlite_engine.zig"));
457
+ host_tooling_mod.addImport("update_feed", host_update_feed_mod);
454
458
  host_tooling_mod.addIncludePath(b.path("third_party/sqlite"));
455
459
  host_tooling_mod.addCSourceFile(.{
456
460
  .file = b.path("third_party/sqlite/sqlite3.c"),
@@ -859,7 +863,10 @@ pub fn build(b: *std.Build) void {
859
863
  .{ .path = "packages/core/scripts/embed_markup_c.mjs", .pattern = "const unsigned char native_sdk_app_markup[]" },
860
864
  .{ .path = "build/app.zig", .pattern = "node_modules\", \"scriptc\", \"dist\", \"bootstrap.js\"" },
861
865
  .{ .path = "build/app.zig", .pattern = "setEnvironmentVariable(\"SCRIPTC_TIMING\", \"1\")" },
862
- .{ .path = "build/app.zig", .pattern = "node_modules\", \".bin\", if (builtin.os.tag == .windows) \"scriptc.cmd\" else \"scriptc\"" },
866
+ .{ .path = "build/app.zig", .pattern = "service_compile.addArg(\"--compiler-package-origin\")" },
867
+ .{ .path = "build/app.zig", .pattern = "compile.addArg(\"--compiler-package-origin\")" },
868
+ .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "publishedScriptcArgv(args[\"compiler-package-origin\"])" },
869
+ .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "publishedScriptcArgv(args[\"compiler-package-origin\"])" },
863
870
  .{ .path = "build/app.zig", .pattern = "addFileInput(dep.path(\"packages/core/scripts/compiler_command.mjs\"))" },
864
871
  .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
865
872
  .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
@@ -1344,8 +1351,11 @@ pub fn build(b: *std.Build) void {
1344
1351
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NSMutableParagraphStyle" },
1345
1352
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketTextLineBreakMode" },
1346
1353
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketTextAlignment" },
1354
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "static BOOL NativeSdkPacketDrawAttributedText(" },
1355
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "drawGlyphsForGlyphRange:glyphRange atPoint:" },
1356
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "glyphRangeForTextContainer:container" },
1347
1357
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "NativeSdkPacketNumber(layout[@\"maxWidth\"], 0)" },
1348
- .{ .path = "src/platform/macos/appkit_host.m", .pattern = "[value drawWithRect:NSMakeRect(origin.x, origin.y - size, textWidth, textHeight)" },
1358
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "native_sdk_appkit_measure_text_ink(" },
1349
1359
  });
1350
1360
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-gpu-packet-font-assets", "Verify AppKit GPU packet text registers bundled font assets", &.{
1351
1361
  .{ .path = "src/platform/macos/appkit_host.m", .pattern = "#import <CoreText/CoreText.h>" },
@@ -1573,6 +1583,14 @@ pub fn build(b: *std.Build) void {
1573
1583
  .{ .path = "src/platform/macos/root.zig", .pattern = ".high_contrast = event.high_contrast != 0" },
1574
1584
  .{ .path = "src/platform/macos/root.zig", .pattern = ".appearance_changed => state.emit" },
1575
1585
  });
1586
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-tray-segment-source-selection", "Verify both macOS tray hosts keep segmented selection model-owned", &.{
1587
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "@property(nonatomic, assign) NSInteger sourceSelectedSegment;" },
1588
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;" },
1589
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "for (NSInteger index = 0; index < control.segmentCount; index++) {\n [control setSelected:index == sourceSelected forSegment:index];\n }\n self.trayCallback" },
1590
+ .{ .path = "src/platform/macos/cef_host.mm", .pattern = "@property(nonatomic, assign) NSInteger sourceSelectedSegment;" },
1591
+ .{ .path = "src/platform/macos/cef_host.mm", .pattern = "if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;" },
1592
+ .{ .path = "src/platform/macos/cef_host.mm", .pattern = "for (NSInteger index = 0; index < control.segmentCount; index++) {\n [control setSelected:index == sourceSelected forSegment:index];\n }\n self.trayCallback" },
1593
+ });
1576
1594
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-builtin-bridge-policy", "Verify bridge policy docs include guarded dialog commands", &.{
1577
1595
  .{ .path = "docs/src/app/docs/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1578
1596
  .{ .path = "docs/src/app/docs/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
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
  "engines": {
@@ -14,6 +14,7 @@
14
14
  "bin/native.js",
15
15
  "assets",
16
16
  "skill-data",
17
+ "schemas",
17
18
  "skills",
18
19
  "src",
19
20
  "build",
@@ -35,17 +36,17 @@
35
36
  ],
36
37
  "dependencies": {
37
38
  "@typescript/old": "npm:typescript@6.0.3",
38
- "scriptc": "0.0.33"
39
+ "scriptc": "0.0.35"
39
40
  },
40
41
  "optionalDependencies": {
41
- "@native-sdk/cli-darwin-arm64": "0.9.4",
42
- "@native-sdk/cli-darwin-x64": "0.9.4",
43
- "@native-sdk/cli-linux-arm64-gnu": "0.9.4",
44
- "@native-sdk/cli-linux-arm64-musl": "0.9.4",
45
- "@native-sdk/cli-linux-x64-gnu": "0.9.4",
46
- "@native-sdk/cli-linux-x64-musl": "0.9.4",
47
- "@native-sdk/cli-win32-arm64": "0.9.4",
48
- "@native-sdk/cli-win32-x64": "0.9.4"
42
+ "@native-sdk/cli-darwin-arm64": "0.10.0",
43
+ "@native-sdk/cli-darwin-x64": "0.10.0",
44
+ "@native-sdk/cli-linux-arm64-gnu": "0.10.0",
45
+ "@native-sdk/cli-linux-arm64-musl": "0.10.0",
46
+ "@native-sdk/cli-linux-x64-gnu": "0.10.0",
47
+ "@native-sdk/cli-linux-x64-musl": "0.10.0",
48
+ "@native-sdk/cli-win32-arm64": "0.10.0",
49
+ "@native-sdk/cli-win32-x64": "0.10.0"
49
50
  },
50
51
  "repository": {
51
52
  "type": "git",
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.9.4",
9
+ "version": "0.10.0",
10
10
  "dependencies": {
11
- "scriptc": "0.0.33"
11
+ "scriptc": "0.0.35"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@typescript/old": "npm:typescript@6.0.3"
@@ -18,18 +18,18 @@
18
18
  }
19
19
  },
20
20
  "node_modules/@scriptc/compiler": {
21
- "version": "0.0.33",
22
- "integrity": "sha512-Hkxo+Z0WwY/c/X9jR/EXVqQv4uHxRuVoE7THIdfYOgTbnshqVvW2z8k5womnSu33j4pAV8MCo4vDImgOpoAeUw==",
21
+ "version": "0.0.35",
22
+ "integrity": "sha512-OLTmyGpFPJAAVn0RfRBoXuCjpaTfpBC1wt6XdO/SzqMab/DaRjCIJY9vv5b1VspP6zLZP2WEYWZPgP8vHKAJPg==",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@scriptc/runtime": "0.0.33",
25
+ "@scriptc/runtime": "0.0.35",
26
26
  "typescript": "7.0.2",
27
27
  "typescript5": "npm:typescript@5.9.3"
28
28
  }
29
29
  },
30
30
  "node_modules/@scriptc/runtime": {
31
- "version": "0.0.33",
32
- "integrity": "sha512-dvmfPdS/Jz4l7rmvnHk76yC469il+zk317RTnTDzP3iW4PHjOhd+W8ZCDgQZEp1VSsNSBy2EQnh2+8Eyv+uVKA==",
31
+ "version": "0.0.35",
32
+ "integrity": "sha512-kjtKfneGr9YGxx631jOPJ1XVh0X6h5LM+rwQmhF6loI9oA+zW7rlYmoF+VkTXLdkre+bu9LptIIgdxKPdAquPA==",
33
33
  "license": "Apache-2.0"
34
34
  },
35
35
  "node_modules/@typescript/old": {
@@ -347,11 +347,12 @@
347
347
  }
348
348
  },
349
349
  "node_modules/scriptc": {
350
- "version": "0.0.33",
351
- "integrity": "sha512-GzNvPRl41xzPA+E9hifmhACoIWPHxx2gU0BT++2T1CatrkQLvt5QKrjPw+OZzRLQBtOD/xGr3Tt4lT5gV/ganA==",
350
+ "version": "0.0.35",
351
+ "integrity": "sha512-46Td/02HJZNLuosdYDiUSQ+auKwGmQ03+odD6Pg+J7D+eAV7sOYQvjZu9M+3ePyYfL3hFQa6wWiGexV/Bd0r+w==",
352
+ "hasInstallScript": true,
352
353
  "license": "Apache-2.0",
353
354
  "dependencies": {
354
- "@scriptc/compiler": "0.0.33"
355
+ "@scriptc/compiler": "0.0.35"
355
356
  },
356
357
  "bin": {
357
358
  "scriptc": "dist/bootstrap.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.4",
3
+ "version": "0.10.0",
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",
@@ -39,6 +39,6 @@
39
39
  "@typescript/old": "npm:typescript@6.0.3"
40
40
  },
41
41
  "dependencies": {
42
- "scriptc": "0.0.33"
42
+ "scriptc": "0.0.35"
43
43
  }
44
44
  }
@@ -49,7 +49,7 @@ export function compilerArgv(command, options = {}) {
49
49
  }
50
50
 
51
51
  /// Resolve scriptc through its published package `bin` declaration. This is
52
- /// intentionally not `scriptc/dist/main.js`: 0.0.33's bin points at the Node
52
+ /// intentionally not `scriptc/dist/main.js`: 0.0.35's bin points at the Node
53
53
  /// 24 compile-cache bootstrap, and future package entrypoint changes should
54
54
  /// reach every Native check/build invocation automatically.
55
55
  export function publishedScriptcArgv(origin, options = {}) {
@@ -14,13 +14,14 @@
14
14
  // --out-sidecar <file>
15
15
  // [--host-platform <arch-os-abi> --target-platform <arch-os-abi>
16
16
  // --zig-exe <path>] [--android-ndk <dir>]
17
- // (--compiler <cmd> | --compiler-js <main.js>)
17
+ // (--compiler <cmd> | --compiler-js <main.js> |
18
+ // --compiler-package-origin <packages/core/package.json>)
18
19
 
19
20
  import { spawnSync } from "node:child_process";
20
21
  import fs from "node:fs";
21
22
  import os from "node:os";
22
23
  import path from "node:path";
23
- import { compilerArgv } from "./compiler_command.mjs";
24
+ import { compilerArgv, publishedScriptcArgv } from "./compiler_command.mjs";
24
25
 
25
26
  function parseArgs(argv) {
26
27
  const args = {};
@@ -28,7 +29,7 @@ function parseArgs(argv) {
28
29
  const key = argv[i];
29
30
  const value = argv[i + 1];
30
31
  if (!key.startsWith("--") || value === undefined) {
31
- console.error("usage: run_external_core_compiler.mjs --stage <dir> --name <n> --manifest <package.json> --frontend-sidecar <file> --out-archive <file> --out-sidecar <file> [--host-platform <arch-os-abi> --target-platform <arch-os-abi> --zig-exe <path>] (--compiler <cmd> | --compiler-js <main.js>)");
32
+ console.error("usage: run_external_core_compiler.mjs --stage <dir> --name <n> --manifest <package.json> --frontend-sidecar <file> --out-archive <file> --out-sidecar <file> [--host-platform <arch-os-abi> --target-platform <arch-os-abi> --zig-exe <path>] (--compiler <cmd> | --compiler-js <main.js> | --compiler-package-origin <package.json>)");
32
33
  process.exit(2);
33
34
  }
34
35
  args[key.slice(2)] = value;
@@ -39,8 +40,9 @@ function parseArgs(argv) {
39
40
  process.exit(2);
40
41
  }
41
42
  }
42
- if (!args.compiler && !args["compiler-js"]) {
43
- console.error("run_external_core_compiler.mjs: supply --compiler <cmd> or --compiler-js <main.js>");
43
+ const compilerModes = [args.compiler, args["compiler-js"], args["compiler-package-origin"]].filter(Boolean);
44
+ if (compilerModes.length !== 1) {
45
+ console.error("run_external_core_compiler.mjs: supply exactly one of --compiler <cmd>, --compiler-js <main.js>, or --compiler-package-origin <package.json>");
44
46
  process.exit(2);
45
47
  }
46
48
  if (Boolean(args["host-platform"]) !== Boolean(args["target-platform"])) {
@@ -53,15 +55,23 @@ function parseArgs(argv) {
53
55
  const args = parseArgs(process.argv);
54
56
  // Every path argument resolves against the INVOCATION's cwd up front:
55
57
  // the compile itself runs from a scratch directory.
56
- for (const key of ["stage", "manifest", "frontend-sidecar", "out-archive", "out-sidecar", "compiler-js", "zig-exe", "android-ndk"]) {
58
+ for (const key of ["stage", "manifest", "frontend-sidecar", "out-archive", "out-sidecar", "compiler-js", "compiler-package-origin", "zig-exe", "android-ndk"]) {
57
59
  if (key in args) args[key] = path.resolve(args[key]);
58
60
  }
59
61
  // --compiler is a COMMAND: a bare executable path (possibly containing
60
62
  // spaces) or an interpreter plus script ("node .../main.js"). The shared
61
63
  // resolver also unwraps npm's Windows .cmd shim to its declared JS bin.
62
- const argv0 = args.compiler
63
- ? compilerArgv(args.compiler)
64
- : [process.execPath, args["compiler-js"]];
64
+ let argv0;
65
+ try {
66
+ argv0 = args.compiler
67
+ ? compilerArgv(args.compiler)
68
+ : args["compiler-js"]
69
+ ? [process.execPath, args["compiler-js"]]
70
+ : publishedScriptcArgv(args["compiler-package-origin"]);
71
+ } catch (error) {
72
+ console.error(`the external TypeScript compiler is not installed or has no valid published bin: ${error instanceof Error ? error.message : String(error)} — reinstall @native-sdk/cli, or point NATIVE_SDK_CORE_COMPILER at the pinned release's command`);
73
+ process.exit(2);
74
+ }
65
75
 
66
76
  // App and fixture build graphs state the host and target explicitly. A
67
77
  // differing target must compile the core archive through the same ScriptC