@native-sdk/cli 0.9.3 → 0.9.5

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 (84) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +323 -76
  3. package/build/ts_run.mjs +15 -18
  4. package/build.zig +83 -8
  5. package/package.json +14 -10
  6. package/packages/core/compile-surface/core.ts +1 -0
  7. package/packages/core/package-lock.json +16 -13
  8. package/packages/core/package.json +5 -2
  9. package/packages/core/scripts/compiler_command.mjs +71 -0
  10. package/packages/core/scripts/compiler_typecheck.mjs +4 -4
  11. package/packages/core/scripts/embed_markup_c.mjs +25 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +3 -3
  13. package/packages/core/scripts/run_external_core_compiler.mjs +21 -10
  14. package/packages/core/scripts/run_external_service_compiler.mjs +17 -7
  15. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  16. package/packages/core/sdk/core.ts +1 -0
  17. package/packages/core/sdk/events.d.ts +36 -4
  18. package/packages/core/sdk/events.ts +49 -6
  19. package/packages/core/src/checker.ts +106 -10
  20. package/packages/core/src/modules.ts +6 -2
  21. package/packages/core/src/sqlite_cli.ts +22 -2
  22. package/packages/core/src/typed_ast.ts +4 -2
  23. package/packages/core/src/types.ts +8 -8
  24. package/schemas/app.schema.json +435 -0
  25. package/skill-data/core/SKILL.md +53 -15
  26. package/skill-data/core/references/project-anatomy.md +6 -6
  27. package/skill-data/native-ui/SKILL.md +28 -6
  28. package/skill-data/ts-core/SKILL.md +9 -6
  29. package/skill-data/ts-services/references/service-surface.md +1 -1
  30. package/skills/native-sdk/SKILL.md +2 -2
  31. package/src/app_runner/ts_core_main.zig +12 -4
  32. package/src/app_runner/ts_core_mobile.zig +6 -2
  33. package/src/automation/snapshot.zig +91 -3
  34. package/src/platform/macos/appkit_host.h +41 -2
  35. package/src/platform/macos/appkit_host.m +198 -9
  36. package/src/platform/macos/cef_host.mm +191 -9
  37. package/src/platform/macos/root.zig +110 -3
  38. package/src/platform/null_platform.zig +50 -1
  39. package/src/platform/null_platform_tests.zig +53 -0
  40. package/src/platform/root.zig +9 -0
  41. package/src/platform/types.zig +58 -0
  42. package/src/platform/windows/root.zig +88 -15
  43. package/src/primitives/canvas/reference.zig +37 -15
  44. package/src/primitives/canvas/reference_tests.zig +63 -0
  45. package/src/primitives/canvas/ui.zig +9 -0
  46. package/src/primitives/canvas/ui_markup.zig +29 -0
  47. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  48. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  49. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  50. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  51. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  52. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  53. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  54. package/src/primitives/canvas/ui_schema.zig +9 -0
  55. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  56. package/src/primitives/canvas/ui_tests.zig +4 -2
  57. package/src/primitives/canvas/widget_render.zig +7 -2
  58. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  59. package/src/root.zig +4 -0
  60. package/src/runtime/automation_snapshot.zig +3 -0
  61. package/src/runtime/flow.zig +1 -1
  62. package/src/runtime/state.zig +14 -0
  63. package/src/runtime/system_services.zig +62 -0
  64. package/src/runtime/ts_ui_app.zig +181 -39
  65. package/src/runtime/ui_app.zig +40 -1
  66. package/src/runtime/ui_app_tests.zig +63 -0
  67. package/src/runtime/ui_app_window_tests.zig +23 -0
  68. package/src/runtime/validation.zig +87 -1
  69. package/src/tooling/android.zig +5 -4
  70. package/src/tooling/buildgraph.zig +24 -8
  71. package/src/tooling/db.zig +1 -1
  72. package/src/tooling/doctor.zig +1 -1
  73. package/src/tooling/ios.zig +5 -4
  74. package/src/tooling/json_to_zon.zig +136 -0
  75. package/src/tooling/manifest.zig +120 -33
  76. package/src/tooling/raw_manifest.zig +4 -0
  77. package/src/tooling/root.zig +1 -0
  78. package/src/tooling/templates.zig +171 -118
  79. package/src/tooling/ts_core.zig +12 -8
  80. package/src/tooling/verbs.zig +233 -5
  81. package/src/tooling/web_engine.zig +17 -1
  82. package/tools/corewire/emit_profile.zig +20 -7
  83. package/tools/corewire/emit_service.zig +49 -24
  84. package/tools/corewire/main.zig +21 -2
package/build/ts_run.mjs CHANGED
@@ -12,21 +12,16 @@
12
12
  // node's ancestor node_modules walk). Node's own type stripping is never
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
- // it only became DEFAULT in node 22.18 — so a checkout target on
16
- // 22.15-22.17 would die with ERR_UNKNOWN_FILE_EXTENSION if the hook let it
17
- // "fall through". Hooking everything makes the 22.15 floor true for both
18
- // layouts. Then the runner imports the requested module with argv
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
17
+ // bootstrap, so this shared runner enforces the same floor before importing
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],
20
20
  // its arguments from argv[2]).
21
21
  //
22
- // On node builds without module.registerHooks (pre-22.15, or 23.0-23.4 —
23
- // the hook landed in 22.15 and 23.5, so ">=22.15" alone is not the
24
- // capability line) NO .ts target can run — node_modules-resident
25
- // stripping is refused by design and default stripping outside
26
- // node_modules only landed in 22.18, which is above this tier anyway —
27
- // so the runner fails fast with one teaching line (upgrade to Node.js
28
- // 22.15+, on the 23 line 23.5+) before importing it, instead of
29
- // surfacing node's raw extension/stripping error.
22
+ // A Node 24 build without module.registerHooks is incomplete for this tier,
23
+ // so the runner gives the same Node 24 teaching instead of surfacing a raw
24
+ // extension/stripping error.
30
25
 
31
26
  import module, { createRequire } from 'node:module';
32
27
  import { readFileSync } from 'node:fs';
@@ -39,19 +34,21 @@ if (!target) {
39
34
  process.exit(2);
40
35
  }
41
36
  const targetPath = resolve(target);
37
+ const nodeMajor = Number(process.versions.node.split('.')[0]);
38
+ if (!Number.isInteger(nodeMajor) || nodeMajor < 24) {
39
+ console.error(`TypeScript apps need Node.js 24+; you're running ${process.version} - upgrade node and re-run.`);
40
+ process.exit(1);
41
+ }
42
42
  // Drop the runner from argv so the target module parses its own argv
43
43
  // exactly as when node runs it directly.
44
44
  process.argv.splice(1, 1);
45
45
 
46
46
  if (typeof module.registerHooks !== 'function') {
47
- // No load hooks on this node (pre-22.15, or a 23.0-23.4 build). Every
48
- // .ts target needs the hook — node_modules-resident stripping is
49
- // refused by design, and native default stripping outside node_modules
50
- // is 22.18+ — so any .ts target would fail deep inside node with a raw
51
- // extension/stripping error. Teach the fix instead.
47
+ // Every .ts target needs the hook. A supported Node build without it is
48
+ // incomplete for this tier, so teach the supported installation instead.
52
49
  if (targetPath.endsWith('.ts')) {
53
50
  console.error(
54
- `TypeScript apps need Node.js 22.15+ (on the 23 line: 23.5+); you're running ${process.version} - upgrade node and re-run.`,
51
+ `TypeScript apps need Node.js 24+ with module.registerHooks; you're running ${process.version} - upgrade or reinstall node and re-run.`,
55
52
  );
56
53
  process.exit(1);
57
54
  }
package/build.zig CHANGED
@@ -1,6 +1,13 @@
1
1
  const std = @import("std");
2
2
  const web_engine_tool = @import("src/tooling/web_engine.zig");
3
3
 
4
+ fn repositoryScriptcBin(b: *std.Build) []const u8 {
5
+ return b.pathFromRoot(if (b.graph.host.result.os.tag == .windows)
6
+ "packages/core/node_modules/.bin/scriptc.cmd"
7
+ else
8
+ "packages/core/node_modules/.bin/scriptc");
9
+ }
10
+
4
11
  const PlatformOption = enum {
5
12
  auto,
6
13
  null,
@@ -832,6 +839,43 @@ pub fn build(b: *std.Build) void {
832
839
  .{ .path = "build.zig", .pattern = "if (spec.emit_services) check.addFileInput(b.path(\"packages/core/package.json\"));" },
833
840
  .{ .path = "build/app.zig", .pattern = "if (has_services) check.addFileInput(dep.path(\"packages/core/package.json\"));" },
834
841
  });
842
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-ts-build-invalidation-boundaries", "Verify generated TypeScript contracts stabilize by content and service implementation inputs cannot dirty the core compiler lane", &.{
843
+ .{ .path = "build/app.zig", .pattern = "pub fn stabilizeGeneratedFile" },
844
+ .{ .path = "build/app.zig", .pattern = "const contract = stabilizeGeneratedFile(b, contract_raw, \"core.contract.json\", build_trace);" },
845
+ .{ .path = "build/app.zig", .pattern = "break :services_contract stabilizeGeneratedFile(b, raw, \"services.contract.json\", build_trace);" },
846
+ .{ .path = "build/app.zig", .pattern = "addAppCoreTsDirInputs(b, stage_run, appPath(b, app_root, \"src\"));" },
847
+ .{ .path = "build/app.zig", .pattern = "addStagedCoreSdkInputs(b, dep.builder, stage_run);" },
848
+ .{ .path = "build/app.zig", .pattern = "for ([_][]const u8{ \"text.ts\", \"events.ts\" }) |source|" },
849
+ .{ .path = "build.zig", .pattern = "app_build.addStagedCoreSdkInputs(b, b, stage_run);" },
850
+ .{ .path = "packages/core/scripts/stage_external_core.mjs", .pattern = "for (const sdkFile of [\"text.ts\", \"events.ts\"])" },
851
+ .{ .path = "build/app.zig", .pattern = "if (std.mem.startsWith(u8, normalized, \"services/\")) continue;" },
852
+ .{ .path = "tools/corewire/emit_service.zig", .pattern = "native-sdk.services.abi.v3" },
853
+ .{ .path = "tools/corewire/emit_service.zig", .pattern = "implementation-only fingerprint" },
854
+ .{ .path = "build/app.zig", .pattern = "link_mod.addObject(markupDataObject(b, target, app_optimize, stage.markup_c));" },
855
+ .{ .path = "build/app.zig", .pattern = "addPlatformLinkSearchPaths(b, selected_platform, web_engine, cef_dir, link_mod);" },
856
+ .{ .path = "build/app.zig", .pattern = "mod.addFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sysroot, \"System/Library/Frameworks\" }) });" },
857
+ .{ .path = "build/app.zig", .pattern = "b.fmt(\"{s}-app-code\", .{app_options.name})" },
858
+ .{ .path = "src/app_runner/ts_core_main.zig", .pattern = "extern const native_sdk_app_markup: u8;" },
859
+ .{ .path = "packages/core/scripts/embed_markup_c.mjs", .pattern = "const unsigned char native_sdk_app_markup[]" },
860
+ .{ .path = "build/app.zig", .pattern = "node_modules\", \"scriptc\", \"dist\", \"bootstrap.js\"" },
861
+ .{ .path = "build/app.zig", .pattern = "setEnvironmentVariable(\"SCRIPTC_TIMING\", \"1\")" },
862
+ .{ .path = "build/app.zig", .pattern = "service_compile.addArg(\"--compiler-package-origin\")" },
863
+ .{ .path = "build/app.zig", .pattern = "compile.addArg(\"--compiler-package-origin\")" },
864
+ .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "publishedScriptcArgv(args[\"compiler-package-origin\"])" },
865
+ .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "publishedScriptcArgv(args[\"compiler-package-origin\"])" },
866
+ .{ .path = "build/app.zig", .pattern = "addFileInput(dep.path(\"packages/core/scripts/compiler_command.mjs\"))" },
867
+ .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
868
+ .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
869
+ .{ .path = "packages/core/scripts/compiler_command.mjs", .pattern = "npmTarget !== null" },
870
+ .{ .path = "build.zig", .pattern = "fn repositoryScriptcBin" },
871
+ .{ .path = "build.zig", .pattern = "packages/core/node_modules/.bin/scriptc.cmd" },
872
+ .{ .path = "build.zig", .pattern = "compile.addArgs(&.{ \"--compiler\", repositoryScriptcBin(b) });" },
873
+ .{ .path = "src/tooling/verbs.zig", .pattern = "Zig's full summary reports each named build step's duration" },
874
+ .{ .path = "src/tooling/verbs.zig", .pattern = "fn rebuildPathIgnored" },
875
+ .{ .path = "src/tooling/verbs.zig", .pattern = "var walker = try root.walkSelectively(allocator);" },
876
+ .{ .path = "src/tooling/verbs.zig", .pattern = "if (!rebuildPathIgnored(path)) try walker.enter(io, entry);" },
877
+ .{ .path = "tools/native-sdk/main.zig", .pattern = "--explain-rebuild" },
878
+ });
835
879
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-scriptc-cross-target-plumbing", "Verify core and service archives share the target-aware ScriptC lane, and every direct Windows archive consumer links its runtime import libraries", &.{
836
880
  .{ .path = "build/app.zig", .pattern = ".linux => !cross or target.result.cpu.arch == .x86_64 or target.result.cpu.arch == .aarch64" },
837
881
  .{ .path = "build/app.zig", .pattern = ".windows => !cross or target.result.abi == .gnu" },
@@ -1532,6 +1576,14 @@ pub fn build(b: *std.Build) void {
1532
1576
  .{ .path = "src/platform/macos/root.zig", .pattern = ".high_contrast = event.high_contrast != 0" },
1533
1577
  .{ .path = "src/platform/macos/root.zig", .pattern = ".appearance_changed => state.emit" },
1534
1578
  });
1579
+ addFileContainsCheckStep(b, file_contains_checker, test_step, "test-appkit-tray-segment-source-selection", "Verify both macOS tray hosts keep segmented selection model-owned", &.{
1580
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "@property(nonatomic, assign) NSInteger sourceSelectedSegment;" },
1581
+ .{ .path = "src/platform/macos/appkit_host.m", .pattern = "if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;" },
1582
+ .{ .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" },
1583
+ .{ .path = "src/platform/macos/cef_host.mm", .pattern = "@property(nonatomic, assign) NSInteger sourceSelectedSegment;" },
1584
+ .{ .path = "src/platform/macos/cef_host.mm", .pattern = "if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;" },
1585
+ .{ .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" },
1586
+ });
1535
1587
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-docs-builtin-bridge-policy", "Verify bridge policy docs include guarded dialog commands", &.{
1536
1588
  .{ .path = "docs/src/app/docs/security/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
1537
1589
  .{ .path = "docs/src/app/docs/bridge/builtin-commands/page.mdx", .pattern = ".{ .name = \"native-sdk.dialog.saveFile\"" },
@@ -3235,7 +3287,7 @@ fn tsCoreE2eArtifact(
3235
3287
  if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER") == null) {
3236
3288
  b.build_root.handle.access(
3237
3289
  b.graph.io,
3238
- "packages/core/node_modules/scriptc/dist/main.js",
3290
+ repositoryScriptcBin(b),
3239
3291
  .{},
3240
3292
  ) catch return null;
3241
3293
  }
@@ -3759,6 +3811,7 @@ fn externalServiceFixture(
3759
3811
 
3760
3812
  const compile = b.addSystemCommand(&.{node});
3761
3813
  compile.addFileArg(b.path("packages/core/scripts/run_external_service_compiler.mjs"));
3814
+ compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
3762
3815
  compile.addArg("--stage");
3763
3816
  compile.addDirectoryArg(stage_dir);
3764
3817
  compile.addArg("--manifest");
@@ -3787,8 +3840,7 @@ fn externalServiceFixture(
3787
3840
  if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
3788
3841
  compile.addArgs(&.{ "--compiler", override });
3789
3842
  } else {
3790
- compile.addArg("--compiler-js");
3791
- compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
3843
+ compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
3792
3844
  }
3793
3845
 
3794
3846
  return .{
@@ -3935,12 +3987,14 @@ fn externalCoreFixtureModule(
3935
3987
  check.addFileArg(b.path("packages/core/src/cli.ts"));
3936
3988
  check.addFileArg(b.path(spec.entry));
3937
3989
  check.addArg("--contract");
3938
- const contract = check.addOutputFileArg("core.contract.json");
3990
+ const contract_raw = check.addOutputFileArg("core.contract.json");
3991
+ const contract = app_build.stabilizeGeneratedFile(b, contract_raw, "core.contract.json", false);
3939
3992
  check.addArg("--contract-entry");
3940
3993
  check.addArg(spec.entry);
3941
3994
  const services_contract: ?std.Build.LazyPath = if (spec.emit_services) services: {
3942
3995
  check.addArg("--services-contract");
3943
- break :services check.addOutputFileArg("services.contract.json");
3996
+ const raw = check.addOutputFileArg("services.contract.json");
3997
+ break :services app_build.stabilizeGeneratedFile(b, raw, "services.contract.json", false);
3944
3998
  } else null;
3945
3999
  for (spec.service_packages) |package_entry| check.addArgs(&.{ "--service-package", package_entry });
3946
4000
  const services_client: ?std.Build.LazyPath = if (services_contract) |service_contract| client: {
@@ -3948,7 +4002,8 @@ fn externalCoreFixtureModule(
3948
4002
  service_project.addArg("--services-sidecar");
3949
4003
  service_project.addFileArg(service_contract);
3950
4004
  service_project.addArg("--service-client");
3951
- break :client service_project.addOutputFileArg("services.gen.ts");
4005
+ const client_raw = service_project.addOutputFileArg("services.gen.ts");
4006
+ break :client app_build.stabilizeGeneratedFile(b, client_raw, "services.gen.ts", false);
3952
4007
  } else null;
3953
4008
  if (spec.persist_capability) check.addArgs(&.{ "--capability", "persist" });
3954
4009
  if (spec.store_capability) check.addArgs(&.{ "--capability", "store" });
@@ -4001,6 +4056,8 @@ fn externalCoreFixtureModule(
4001
4056
  stage_run.addArg("--services-client");
4002
4057
  stage_run.addFileArg(client);
4003
4058
  }
4059
+ tsCoreAddCoreDirInputs(b, stage_run, std.fs.path.dirname(spec.entry) orelse ".");
4060
+ app_build.addStagedCoreSdkInputs(b, b, stage_run);
4004
4061
  stage_run.addArg("--out");
4005
4062
  const stage_dir = stage_run.addOutputDirectoryArg("stage");
4006
4063
 
@@ -4008,6 +4065,7 @@ fn externalCoreFixtureModule(
4008
4065
  // pin, archive normalized, the co-emitted sidecar captured.
4009
4066
  const compile = b.addSystemCommand(&.{node});
4010
4067
  compile.addFileArg(b.path("packages/core/scripts/run_external_core_compiler.mjs"));
4068
+ compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
4011
4069
  compile.addArg("--stage");
4012
4070
  compile.addDirectoryArg(stage_dir);
4013
4071
  compile.addArgs(&.{ "--name", spec.name });
@@ -4034,8 +4092,7 @@ fn externalCoreFixtureModule(
4034
4092
  // driver still refuses a release other than the SDK's pin.
4035
4093
  compile.addArgs(&.{ "--compiler", override });
4036
4094
  } else {
4037
- compile.addArg("--compiler-js");
4038
- compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
4095
+ compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
4039
4096
  }
4040
4097
 
4041
4098
  // The mirror, generated from the archive's OWN co-emitted contract,
@@ -4083,6 +4140,24 @@ fn tsCoreAddDirInputs(b: *std.Build, transpile: *std.Build.Step.Run, dir_path: [
4083
4140
  }
4084
4141
  }
4085
4142
 
4143
+ /// The source set stage_external_core.mjs copies: every ordinary `.ts` file,
4144
+ /// excluding the independent services compiler class and declaration files.
4145
+ fn tsCoreAddCoreDirInputs(b: *std.Build, stage: *std.Build.Step.Run, dir_path: []const u8) void {
4146
+ var dir = b.build_root.handle.openDir(b.graph.io, dir_path, .{ .iterate = true }) catch return;
4147
+ defer dir.close(b.graph.io);
4148
+ var walker = dir.walk(b.allocator) catch return;
4149
+ defer walker.deinit();
4150
+ while (walker.next(b.graph.io) catch null) |entry| {
4151
+ if (entry.kind != .file or !std.mem.endsWith(u8, entry.basename, ".ts") or std.mem.endsWith(u8, entry.basename, ".d.ts")) continue;
4152
+ const normalized = b.dupe(entry.path);
4153
+ for (normalized) |*char| if (char.* == '\\') {
4154
+ char.* = '/';
4155
+ };
4156
+ if (std.mem.startsWith(u8, normalized, "services/")) continue;
4157
+ stage.addFileInput(b.path(b.fmt("{s}/{s}", .{ dir_path, entry.path })));
4158
+ }
4159
+ }
4160
+
4086
4161
  fn filteredTestArtifact(b: *std.Build, mod: *std.Build.Module, name: []const u8, filters: []const []const u8) *std.Build.Step.Compile {
4087
4162
  // use_llvm: Zig 0.16.0's self-hosted x86_64 backend miscompiles the
4088
4163
  // SysV C ABI for f32-heavy signatures (native_sdk_app_viewport); see
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
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
+ "engines": {
7
+ "node": ">=24"
8
+ },
6
9
  "bin": {
7
10
  "native": "bin/native.js"
8
11
  },
@@ -11,6 +14,7 @@
11
14
  "bin/native.js",
12
15
  "assets",
13
16
  "skill-data",
17
+ "schemas",
14
18
  "skills",
15
19
  "src",
16
20
  "build",
@@ -32,17 +36,17 @@
32
36
  ],
33
37
  "dependencies": {
34
38
  "@typescript/old": "npm:typescript@6.0.3",
35
- "scriptc": "0.0.31"
39
+ "scriptc": "0.0.33"
36
40
  },
37
41
  "optionalDependencies": {
38
- "@native-sdk/cli-darwin-arm64": "0.9.3",
39
- "@native-sdk/cli-darwin-x64": "0.9.3",
40
- "@native-sdk/cli-linux-arm64-gnu": "0.9.3",
41
- "@native-sdk/cli-linux-arm64-musl": "0.9.3",
42
- "@native-sdk/cli-linux-x64-gnu": "0.9.3",
43
- "@native-sdk/cli-linux-x64-musl": "0.9.3",
44
- "@native-sdk/cli-win32-arm64": "0.9.3",
45
- "@native-sdk/cli-win32-x64": "0.9.3"
42
+ "@native-sdk/cli-darwin-arm64": "0.9.5",
43
+ "@native-sdk/cli-darwin-x64": "0.9.5",
44
+ "@native-sdk/cli-linux-arm64-gnu": "0.9.5",
45
+ "@native-sdk/cli-linux-arm64-musl": "0.9.5",
46
+ "@native-sdk/cli-linux-x64-gnu": "0.9.5",
47
+ "@native-sdk/cli-linux-x64-musl": "0.9.5",
48
+ "@native-sdk/cli-win32-arm64": "0.9.5",
49
+ "@native-sdk/cli-win32-x64": "0.9.5"
46
50
  },
47
51
  "repository": {
48
52
  "type": "git",
@@ -96,6 +96,7 @@ export function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor {
96
96
  x: spec.x ?? null,
97
97
  y: spec.y ?? null,
98
98
  resizable: spec.resizable ?? true,
99
+ restorePolicy: spec.restorePolicy ?? "clamp_to_visible_screen",
99
100
  minWidth: spec.minWidth ?? 0,
100
101
  minHeight: spec.minHeight ?? 0,
101
102
  titlebar: spec.titlebar ?? "standard",
@@ -1,32 +1,35 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.9.3",
9
+ "version": "0.9.5",
10
10
  "dependencies": {
11
- "scriptc": "0.0.31"
11
+ "scriptc": "0.0.33"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@typescript/old": "npm:typescript@6.0.3"
15
+ },
16
+ "engines": {
17
+ "node": ">=24"
15
18
  }
16
19
  },
17
20
  "node_modules/@scriptc/compiler": {
18
- "version": "0.0.31",
19
- "integrity": "sha512-mx0GZXQdYR19jwahXQeo8dgZffi38v2F43n2zvofRsNozjPkh4cJ8qM7ir5xgc1otEfXKHIVMTBh0x/uKq6gbQ==",
21
+ "version": "0.0.33",
22
+ "integrity": "sha512-Hkxo+Z0WwY/c/X9jR/EXVqQv4uHxRuVoE7THIdfYOgTbnshqVvW2z8k5womnSu33j4pAV8MCo4vDImgOpoAeUw==",
20
23
  "license": "Apache-2.0",
21
24
  "dependencies": {
22
- "@scriptc/runtime": "0.0.31",
25
+ "@scriptc/runtime": "0.0.33",
23
26
  "typescript": "7.0.2",
24
27
  "typescript5": "npm:typescript@5.9.3"
25
28
  }
26
29
  },
27
30
  "node_modules/@scriptc/runtime": {
28
- "version": "0.0.31",
29
- "integrity": "sha512-NS37+H6blyQGmv24BN11vXmqOZ9igudWOqlkcL1MWvslOemy4vLWqxAe77Ca/51DJCfAu1xui2a3MPq8rQLfcQ==",
31
+ "version": "0.0.33",
32
+ "integrity": "sha512-dvmfPdS/Jz4l7rmvnHk76yC469il+zk317RTnTDzP3iW4PHjOhd+W8ZCDgQZEp1VSsNSBy2EQnh2+8Eyv+uVKA==",
30
33
  "license": "Apache-2.0"
31
34
  },
32
35
  "node_modules/@typescript/old": {
@@ -344,17 +347,17 @@
344
347
  }
345
348
  },
346
349
  "node_modules/scriptc": {
347
- "version": "0.0.31",
348
- "integrity": "sha512-V7cR6080/mqm1PlHeIIlGDHID4aL/Poq+w4U/03935nK0stIJkHaKGtmKZEk5GrOXrejqVEtMNCGjZvYk/ClUQ==",
350
+ "version": "0.0.33",
351
+ "integrity": "sha512-GzNvPRl41xzPA+E9hifmhACoIWPHxx2gU0BT++2T1CatrkQLvt5QKrjPw+OZzRLQBtOD/xGr3Tt4lT5gV/ganA==",
349
352
  "license": "Apache-2.0",
350
353
  "dependencies": {
351
- "@scriptc/compiler": "0.0.31"
354
+ "@scriptc/compiler": "0.0.33"
352
355
  },
353
356
  "bin": {
354
- "scriptc": "dist/main.js"
357
+ "scriptc": "dist/bootstrap.js"
355
358
  },
356
359
  "engines": {
357
- "node": ">=20"
360
+ "node": ">=24"
358
361
  }
359
362
  },
360
363
  "node_modules/typescript": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.3",
3
+ "version": "0.9.5",
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",
@@ -9,6 +9,9 @@
9
9
  },
10
10
  "homepage": "https://native-sdk.dev",
11
11
  "type": "module",
12
+ "engines": {
13
+ "node": ">=24"
14
+ },
12
15
  "types": "./sdk/core.ts",
13
16
  "files": [
14
17
  "sdk",
@@ -36,6 +39,6 @@
36
39
  "@typescript/old": "npm:typescript@6.0.3"
37
40
  },
38
41
  "dependencies": {
39
- "scriptc": "0.0.31"
42
+ "scriptc": "0.0.33"
40
43
  }
41
44
  }
@@ -0,0 +1,71 @@
1
+ // Resolve a compiler command into the argv prefix used by the core and
2
+ // service drivers. On Windows npm exposes package bins as .cmd shims, which
3
+ // Node's spawnSync cannot execute directly. For the installed scriptc bin,
4
+ // unwrap the shim through the package's own `bin` declaration and execute the
5
+ // declared JavaScript entry with Node. This preserves published-bin changes
6
+ // (for example dist/main.js -> dist/bootstrap.js) without a shell boundary.
7
+
8
+ import fs from "node:fs";
9
+ import { createRequire } from "node:module";
10
+ import path from "node:path";
11
+
12
+ function npmBinJavaScript(command) {
13
+ const binName = path.basename(command).replace(/\.(?:cmd|bat)$/i, "");
14
+ const nodeModules = path.dirname(path.dirname(command));
15
+ const packageJson = path.join(nodeModules, binName, "package.json");
16
+ let manifest;
17
+ try {
18
+ manifest = JSON.parse(fs.readFileSync(packageJson, "utf8"));
19
+ } catch {
20
+ return null;
21
+ }
22
+ const declared = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.[binName];
23
+ if (typeof declared !== "string" || declared.length === 0 || path.isAbsolute(declared)) return null;
24
+ const packageRoot = path.dirname(packageJson);
25
+ const target = path.resolve(packageRoot, declared);
26
+ const relative = path.relative(packageRoot, target);
27
+ if (relative === "" || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) return null;
28
+ try {
29
+ if (!fs.statSync(target).isFile()) return null;
30
+ } catch {
31
+ return null;
32
+ }
33
+ return target;
34
+ }
35
+
36
+ export function compilerArgv(command, options = {}) {
37
+ const platform = options.platform ?? process.platform;
38
+ const node = options.node ?? process.execPath;
39
+ const env = options.env ?? process.env;
40
+ const argv = fs.existsSync(command) ? [command] : command.split(/\s+/);
41
+ if (platform !== "win32" || argv.length !== 1 || !/\.(?:cmd|bat)$/i.test(argv[0])) return argv;
42
+
43
+ const npmTarget = npmBinJavaScript(argv[0]);
44
+ if (npmTarget !== null) return [node, npmTarget];
45
+
46
+ // Development overrides may name an arbitrary batch file rather than an
47
+ // npm bin. cmd.exe is the Windows executable format's required launcher.
48
+ return [env.ComSpec ?? env.COMSPEC ?? "cmd.exe", "/d", "/s", "/c", argv[0]];
49
+ }
50
+
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
53
+ /// 24 compile-cache bootstrap, and future package entrypoint changes should
54
+ /// reach every Native check/build invocation automatically.
55
+ export function publishedScriptcArgv(origin, options = {}) {
56
+ const node = options.node ?? process.execPath;
57
+ const packageJson = createRequire(origin).resolve("scriptc/package.json");
58
+ const manifest = JSON.parse(fs.readFileSync(packageJson, "utf8"));
59
+ const declared = typeof manifest.bin === "string" ? manifest.bin : manifest.bin?.scriptc;
60
+ if (typeof declared !== "string" || declared.length === 0 || path.isAbsolute(declared)) {
61
+ throw new Error("scriptc package has no safe published binary entrypoint");
62
+ }
63
+ const packageRoot = path.dirname(packageJson);
64
+ const target = path.resolve(packageRoot, declared);
65
+ const relative = path.relative(packageRoot, target);
66
+ if (relative === "" || relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
67
+ throw new Error("scriptc package's published binary entrypoint escapes its package");
68
+ }
69
+ if (!fs.statSync(target).isFile()) throw new Error("scriptc package's published binary entrypoint is missing");
70
+ return [node, target];
71
+ }
@@ -14,8 +14,8 @@ import { spawnSync } from "node:child_process";
14
14
  import fs from "node:fs";
15
15
  import os from "node:os";
16
16
  import path from "node:path";
17
- import { createRequire } from "node:module";
18
17
  import { fileURLToPath } from "node:url";
18
+ import { publishedScriptcArgv } from "./compiler_command.mjs";
19
19
 
20
20
  const entry = process.argv[2];
21
21
  if (!entry) {
@@ -28,9 +28,9 @@ for (let i = 3; i < process.argv.length; i++) {
28
28
  }
29
29
  const here = path.dirname(fileURLToPath(import.meta.url));
30
30
  const coreRoot = path.resolve(here, "..");
31
- let compilerJs;
31
+ let compilerArgv;
32
32
  try {
33
- compilerJs = createRequire(path.join(coreRoot, "package.json")).resolve("scriptc/dist/main.js");
33
+ compilerArgv = publishedScriptcArgv(path.join(coreRoot, "package.json"));
34
34
  } catch {
35
35
  console.error("the external core compiler is not installed — run `npm ci --include=dev` in the SDK's packages/core");
36
36
  process.exit(2);
@@ -124,7 +124,7 @@ try {
124
124
  const npmArgs = isService && vendoredPackages.length > 0
125
125
  ? ["--npm-static", vendoredPackages.map((pkg) => pkg.name).join(",")]
126
126
  : [];
127
- const probe = spawnSync(process.execPath, [compilerJs, "coverage", candidate, ...npmArgs, ...maps], { encoding: "utf8" });
127
+ const probe = spawnSync(compilerArgv[0], [...compilerArgv.slice(1), "coverage", candidate, ...npmArgs, ...maps], { encoding: "utf8" });
128
128
  const out = `${probe.stdout ?? ""}${probe.stderr ?? ""}`;
129
129
  // Coverage deliberately reports per-package fallback as a note even
130
130
  // when the rest of the source graph is analyzable. Native SDK's policy
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ // Turn Native markup into one tiny C translation unit. Keeping the authored
3
+ // bytes outside Zig's module graph means a markup edit recompiles this data
4
+ // object and relinks the app without re-analyzing the SDK/app Zig graph.
5
+
6
+ import fs from "node:fs";
7
+ import path from "node:path";
8
+
9
+ const [, , input, output] = process.argv;
10
+ if (!input || !output) {
11
+ console.error("usage: embed_markup_c.mjs <src/app.native> <out.c>");
12
+ process.exit(2);
13
+ }
14
+
15
+ const bytes = fs.readFileSync(input);
16
+ let source = "#include <stddef.h>\n";
17
+ source += "const unsigned char native_sdk_app_markup[] = {";
18
+ for (let i = 0; i < bytes.length; i++) {
19
+ if (i % 24 === 0) source += "\n ";
20
+ source += `${bytes[i]},`;
21
+ }
22
+ source += "\n};\n";
23
+ source += `const size_t native_sdk_app_markup_len = ${bytes.length};\n`;
24
+ fs.mkdirSync(path.dirname(output), { recursive: true });
25
+ fs.writeFileSync(output, source);
@@ -7,13 +7,13 @@ import { spawnSync } from "node:child_process";
7
7
  import fs from "node:fs";
8
8
  import os from "node:os";
9
9
  import path from "node:path";
10
- import { createRequire } from "node:module";
11
10
  import { fileURLToPath } from "node:url";
11
+ import { publishedScriptcArgv } from "./compiler_command.mjs";
12
12
 
13
13
  const here = path.dirname(fileURLToPath(import.meta.url));
14
14
  const coreRoot = path.resolve(here, "..");
15
15
  const repoRoot = path.resolve(coreRoot, "..", "..");
16
- const compilerJs = createRequire(path.join(coreRoot, "package.json")).resolve("scriptc/dist/main.js");
16
+ const compilerArgv = publishedScriptcArgv(path.join(coreRoot, "package.json"));
17
17
  const compilerVersion = JSON.parse(fs.readFileSync(path.join(coreRoot, "package.json"), "utf8")).dependencies.scriptc;
18
18
 
19
19
  const candidates = [
@@ -38,7 +38,7 @@ for (const candidate of candidates) {
38
38
  fs.symlinkSync(pnpmNodeModules(candidate), path.join(scratch, "node_modules"), "dir");
39
39
  const entry = path.join(scratch, "probe.ts");
40
40
  fs.writeFileSync(entry, candidate.source);
41
- const probe = spawnSync(process.execPath, [compilerJs, "coverage", entry, "--npm-static", candidate.name], { encoding: "utf8" });
41
+ const probe = spawnSync(compilerArgv[0], [...compilerArgv.slice(1), "coverage", entry, "--npm-static", candidate.name], { encoding: "utf8" });
42
42
  const output = `${probe.stdout ?? ""}${probe.stderr ?? ""}`;
43
43
  if (process.env.NATIVE_NPM_STATIC_SPIKE_VERBOSE === "1") {
44
44
  process.stderr.write(`\n===== ${candidate.name}@${candidate.version} =====\n${output}\n`);
@@ -14,12 +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";
24
+ import { compilerArgv, publishedScriptcArgv } from "./compiler_command.mjs";
23
25
 
24
26
  function parseArgs(argv) {
25
27
  const args = {};
@@ -27,7 +29,7 @@ function parseArgs(argv) {
27
29
  const key = argv[i];
28
30
  const value = argv[i + 1];
29
31
  if (!key.startsWith("--") || value === undefined) {
30
- 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>)");
31
33
  process.exit(2);
32
34
  }
33
35
  args[key.slice(2)] = value;
@@ -38,8 +40,9 @@ function parseArgs(argv) {
38
40
  process.exit(2);
39
41
  }
40
42
  }
41
- if (!args.compiler && !args["compiler-js"]) {
42
- 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>");
43
46
  process.exit(2);
44
47
  }
45
48
  if (Boolean(args["host-platform"]) !== Boolean(args["target-platform"])) {
@@ -52,15 +55,23 @@ function parseArgs(argv) {
52
55
  const args = parseArgs(process.argv);
53
56
  // Every path argument resolves against the INVOCATION's cwd up front:
54
57
  // the compile itself runs from a scratch directory.
55
- 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"]) {
56
59
  if (key in args) args[key] = path.resolve(args[key]);
57
60
  }
58
61
  // --compiler is a COMMAND: a bare executable path (possibly containing
59
- // spaces) or an interpreter plus script ("node .../main.js"). A path
60
- // that exists is taken whole; anything else splits on whitespace.
61
- const argv0 = args.compiler
62
- ? (fs.existsSync(args.compiler) ? [args.compiler] : args.compiler.split(/\s+/))
63
- : [process.execPath, args["compiler-js"]];
62
+ // spaces) or an interpreter plus script ("node .../main.js"). The shared
63
+ // resolver also unwraps npm's Windows .cmd shim to its declared JS bin.
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
+ }
64
75
 
65
76
  // App and fixture build graphs state the host and target explicitly. A
66
77
  // differing target must compile the core archive through the same ScriptC