@native-sdk/cli 0.9.3 → 0.9.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 +273 -37
- package/build/ts_run.mjs +15 -18
- package/build.zig +72 -8
- package/package.json +13 -10
- package/packages/core/compile-surface/core.ts +1 -0
- package/packages/core/package-lock.json +16 -13
- package/packages/core/package.json +5 -2
- package/packages/core/scripts/compiler_command.mjs +71 -0
- package/packages/core/scripts/compiler_typecheck.mjs +4 -4
- package/packages/core/scripts/embed_markup_c.mjs +25 -0
- package/packages/core/scripts/npm_static_spike.mjs +3 -3
- package/packages/core/scripts/run_external_core_compiler.mjs +4 -3
- package/packages/core/scripts/run_external_service_compiler.mjs +2 -1
- package/packages/core/sdk/core.ts +1 -0
- package/packages/core/sdk/events.d.ts +3 -0
- package/packages/core/sdk/events.ts +4 -0
- package/packages/core/src/checker.ts +3 -2
- package/skill-data/native-ui/SKILL.md +2 -1
- package/skill-data/ts-core/SKILL.md +3 -0
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/src/app_runner/ts_core_main.zig +12 -4
- package/src/app_runner/ts_core_mobile.zig +6 -2
- package/src/runtime/ts_ui_app.zig +20 -6
- package/src/runtime/ui_app.zig +7 -0
- package/src/runtime/ui_app_window_tests.zig +23 -0
- package/src/tooling/templates.zig +6 -2
- package/src/tooling/ts_core.zig +1 -1
- package/src/tooling/verbs.zig +227 -0
- package/tools/corewire/emit_profile.zig +20 -7
- package/tools/corewire/emit_service.zig +49 -24
- 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
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
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
|
-
//
|
|
23
|
-
// the
|
|
24
|
-
//
|
|
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
|
-
//
|
|
48
|
-
//
|
|
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
|
|
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,40 @@ 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 = "node_modules\", \".bin\", if (builtin.os.tag == .windows) \"scriptc.cmd\" else \"scriptc\"" },
|
|
863
|
+
.{ .path = "build/app.zig", .pattern = "addFileInput(dep.path(\"packages/core/scripts/compiler_command.mjs\"))" },
|
|
864
|
+
.{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
|
|
865
|
+
.{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "compilerArgv(args.compiler)" },
|
|
866
|
+
.{ .path = "packages/core/scripts/compiler_command.mjs", .pattern = "npmTarget !== null" },
|
|
867
|
+
.{ .path = "build.zig", .pattern = "fn repositoryScriptcBin" },
|
|
868
|
+
.{ .path = "build.zig", .pattern = "packages/core/node_modules/.bin/scriptc.cmd" },
|
|
869
|
+
.{ .path = "build.zig", .pattern = "compile.addArgs(&.{ \"--compiler\", repositoryScriptcBin(b) });" },
|
|
870
|
+
.{ .path = "src/tooling/verbs.zig", .pattern = "Zig's full summary reports each named build step's duration" },
|
|
871
|
+
.{ .path = "src/tooling/verbs.zig", .pattern = "fn rebuildPathIgnored" },
|
|
872
|
+
.{ .path = "src/tooling/verbs.zig", .pattern = "var walker = try root.walkSelectively(allocator);" },
|
|
873
|
+
.{ .path = "src/tooling/verbs.zig", .pattern = "if (!rebuildPathIgnored(path)) try walker.enter(io, entry);" },
|
|
874
|
+
.{ .path = "tools/native-sdk/main.zig", .pattern = "--explain-rebuild" },
|
|
875
|
+
});
|
|
835
876
|
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
877
|
.{ .path = "build/app.zig", .pattern = ".linux => !cross or target.result.cpu.arch == .x86_64 or target.result.cpu.arch == .aarch64" },
|
|
837
878
|
.{ .path = "build/app.zig", .pattern = ".windows => !cross or target.result.abi == .gnu" },
|
|
@@ -3235,7 +3276,7 @@ fn tsCoreE2eArtifact(
|
|
|
3235
3276
|
if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER") == null) {
|
|
3236
3277
|
b.build_root.handle.access(
|
|
3237
3278
|
b.graph.io,
|
|
3238
|
-
|
|
3279
|
+
repositoryScriptcBin(b),
|
|
3239
3280
|
.{},
|
|
3240
3281
|
) catch return null;
|
|
3241
3282
|
}
|
|
@@ -3759,6 +3800,7 @@ fn externalServiceFixture(
|
|
|
3759
3800
|
|
|
3760
3801
|
const compile = b.addSystemCommand(&.{node});
|
|
3761
3802
|
compile.addFileArg(b.path("packages/core/scripts/run_external_service_compiler.mjs"));
|
|
3803
|
+
compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
|
|
3762
3804
|
compile.addArg("--stage");
|
|
3763
3805
|
compile.addDirectoryArg(stage_dir);
|
|
3764
3806
|
compile.addArg("--manifest");
|
|
@@ -3787,8 +3829,7 @@ fn externalServiceFixture(
|
|
|
3787
3829
|
if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
|
|
3788
3830
|
compile.addArgs(&.{ "--compiler", override });
|
|
3789
3831
|
} else {
|
|
3790
|
-
compile.
|
|
3791
|
-
compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
|
|
3832
|
+
compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
|
|
3792
3833
|
}
|
|
3793
3834
|
|
|
3794
3835
|
return .{
|
|
@@ -3935,12 +3976,14 @@ fn externalCoreFixtureModule(
|
|
|
3935
3976
|
check.addFileArg(b.path("packages/core/src/cli.ts"));
|
|
3936
3977
|
check.addFileArg(b.path(spec.entry));
|
|
3937
3978
|
check.addArg("--contract");
|
|
3938
|
-
const
|
|
3979
|
+
const contract_raw = check.addOutputFileArg("core.contract.json");
|
|
3980
|
+
const contract = app_build.stabilizeGeneratedFile(b, contract_raw, "core.contract.json", false);
|
|
3939
3981
|
check.addArg("--contract-entry");
|
|
3940
3982
|
check.addArg(spec.entry);
|
|
3941
3983
|
const services_contract: ?std.Build.LazyPath = if (spec.emit_services) services: {
|
|
3942
3984
|
check.addArg("--services-contract");
|
|
3943
|
-
|
|
3985
|
+
const raw = check.addOutputFileArg("services.contract.json");
|
|
3986
|
+
break :services app_build.stabilizeGeneratedFile(b, raw, "services.contract.json", false);
|
|
3944
3987
|
} else null;
|
|
3945
3988
|
for (spec.service_packages) |package_entry| check.addArgs(&.{ "--service-package", package_entry });
|
|
3946
3989
|
const services_client: ?std.Build.LazyPath = if (services_contract) |service_contract| client: {
|
|
@@ -3948,7 +3991,8 @@ fn externalCoreFixtureModule(
|
|
|
3948
3991
|
service_project.addArg("--services-sidecar");
|
|
3949
3992
|
service_project.addFileArg(service_contract);
|
|
3950
3993
|
service_project.addArg("--service-client");
|
|
3951
|
-
|
|
3994
|
+
const client_raw = service_project.addOutputFileArg("services.gen.ts");
|
|
3995
|
+
break :client app_build.stabilizeGeneratedFile(b, client_raw, "services.gen.ts", false);
|
|
3952
3996
|
} else null;
|
|
3953
3997
|
if (spec.persist_capability) check.addArgs(&.{ "--capability", "persist" });
|
|
3954
3998
|
if (spec.store_capability) check.addArgs(&.{ "--capability", "store" });
|
|
@@ -4001,6 +4045,8 @@ fn externalCoreFixtureModule(
|
|
|
4001
4045
|
stage_run.addArg("--services-client");
|
|
4002
4046
|
stage_run.addFileArg(client);
|
|
4003
4047
|
}
|
|
4048
|
+
tsCoreAddCoreDirInputs(b, stage_run, std.fs.path.dirname(spec.entry) orelse ".");
|
|
4049
|
+
app_build.addStagedCoreSdkInputs(b, b, stage_run);
|
|
4004
4050
|
stage_run.addArg("--out");
|
|
4005
4051
|
const stage_dir = stage_run.addOutputDirectoryArg("stage");
|
|
4006
4052
|
|
|
@@ -4008,6 +4054,7 @@ fn externalCoreFixtureModule(
|
|
|
4008
4054
|
// pin, archive normalized, the co-emitted sidecar captured.
|
|
4009
4055
|
const compile = b.addSystemCommand(&.{node});
|
|
4010
4056
|
compile.addFileArg(b.path("packages/core/scripts/run_external_core_compiler.mjs"));
|
|
4057
|
+
compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
|
|
4011
4058
|
compile.addArg("--stage");
|
|
4012
4059
|
compile.addDirectoryArg(stage_dir);
|
|
4013
4060
|
compile.addArgs(&.{ "--name", spec.name });
|
|
@@ -4034,8 +4081,7 @@ fn externalCoreFixtureModule(
|
|
|
4034
4081
|
// driver still refuses a release other than the SDK's pin.
|
|
4035
4082
|
compile.addArgs(&.{ "--compiler", override });
|
|
4036
4083
|
} else {
|
|
4037
|
-
compile.
|
|
4038
|
-
compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
|
|
4084
|
+
compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
|
|
4039
4085
|
}
|
|
4040
4086
|
|
|
4041
4087
|
// The mirror, generated from the archive's OWN co-emitted contract,
|
|
@@ -4083,6 +4129,24 @@ fn tsCoreAddDirInputs(b: *std.Build, transpile: *std.Build.Step.Run, dir_path: [
|
|
|
4083
4129
|
}
|
|
4084
4130
|
}
|
|
4085
4131
|
|
|
4132
|
+
/// The source set stage_external_core.mjs copies: every ordinary `.ts` file,
|
|
4133
|
+
/// excluding the independent services compiler class and declaration files.
|
|
4134
|
+
fn tsCoreAddCoreDirInputs(b: *std.Build, stage: *std.Build.Step.Run, dir_path: []const u8) void {
|
|
4135
|
+
var dir = b.build_root.handle.openDir(b.graph.io, dir_path, .{ .iterate = true }) catch return;
|
|
4136
|
+
defer dir.close(b.graph.io);
|
|
4137
|
+
var walker = dir.walk(b.allocator) catch return;
|
|
4138
|
+
defer walker.deinit();
|
|
4139
|
+
while (walker.next(b.graph.io) catch null) |entry| {
|
|
4140
|
+
if (entry.kind != .file or !std.mem.endsWith(u8, entry.basename, ".ts") or std.mem.endsWith(u8, entry.basename, ".d.ts")) continue;
|
|
4141
|
+
const normalized = b.dupe(entry.path);
|
|
4142
|
+
for (normalized) |*char| if (char.* == '\\') {
|
|
4143
|
+
char.* = '/';
|
|
4144
|
+
};
|
|
4145
|
+
if (std.mem.startsWith(u8, normalized, "services/")) continue;
|
|
4146
|
+
stage.addFileInput(b.path(b.fmt("{s}/{s}", .{ dir_path, entry.path })));
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
|
|
4086
4150
|
fn filteredTestArtifact(b: *std.Build, mod: *std.Build.Module, name: []const u8, filters: []const []const u8) *std.Build.Step.Compile {
|
|
4087
4151
|
// use_llvm: Zig 0.16.0's self-hosted x86_64 backend miscompiles the
|
|
4088
4152
|
// 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
|
+
"version": "0.9.4",
|
|
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
|
},
|
|
@@ -32,17 +35,17 @@
|
|
|
32
35
|
],
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"@typescript/old": "npm:typescript@6.0.3",
|
|
35
|
-
"scriptc": "0.0.
|
|
38
|
+
"scriptc": "0.0.33"
|
|
36
39
|
},
|
|
37
40
|
"optionalDependencies": {
|
|
38
|
-
"@native-sdk/cli-darwin-arm64": "0.9.
|
|
39
|
-
"@native-sdk/cli-darwin-x64": "0.9.
|
|
40
|
-
"@native-sdk/cli-linux-arm64-gnu": "0.9.
|
|
41
|
-
"@native-sdk/cli-linux-arm64-musl": "0.9.
|
|
42
|
-
"@native-sdk/cli-linux-x64-gnu": "0.9.
|
|
43
|
-
"@native-sdk/cli-linux-x64-musl": "0.9.
|
|
44
|
-
"@native-sdk/cli-win32-arm64": "0.9.
|
|
45
|
-
"@native-sdk/cli-win32-x64": "0.9.
|
|
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"
|
|
46
49
|
},
|
|
47
50
|
"repository": {
|
|
48
51
|
"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
|
+
"version": "0.9.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@native-sdk/core",
|
|
9
|
-
"version": "0.9.
|
|
9
|
+
"version": "0.9.4",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"scriptc": "0.0.
|
|
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.
|
|
19
|
-
"integrity": "sha512-
|
|
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.
|
|
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.
|
|
29
|
-
"integrity": "sha512-
|
|
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.
|
|
348
|
-
"integrity": "sha512-
|
|
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.
|
|
354
|
+
"@scriptc/compiler": "0.0.33"
|
|
352
355
|
},
|
|
353
356
|
"bin": {
|
|
354
|
-
"scriptc": "dist/
|
|
357
|
+
"scriptc": "dist/bootstrap.js"
|
|
355
358
|
},
|
|
356
359
|
"engines": {
|
|
357
|
-
"node": ">=
|
|
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
|
+
"version": "0.9.4",
|
|
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.
|
|
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
|
|
31
|
+
let compilerArgv;
|
|
32
32
|
try {
|
|
33
|
-
|
|
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(
|
|
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
|
|
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(
|
|
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`);
|
|
@@ -20,6 +20,7 @@ import { spawnSync } from "node:child_process";
|
|
|
20
20
|
import fs from "node:fs";
|
|
21
21
|
import os from "node:os";
|
|
22
22
|
import path from "node:path";
|
|
23
|
+
import { compilerArgv } from "./compiler_command.mjs";
|
|
23
24
|
|
|
24
25
|
function parseArgs(argv) {
|
|
25
26
|
const args = {};
|
|
@@ -56,10 +57,10 @@ for (const key of ["stage", "manifest", "frontend-sidecar", "out-archive", "out-
|
|
|
56
57
|
if (key in args) args[key] = path.resolve(args[key]);
|
|
57
58
|
}
|
|
58
59
|
// --compiler is a COMMAND: a bare executable path (possibly containing
|
|
59
|
-
// spaces) or an interpreter plus script ("node .../main.js").
|
|
60
|
-
//
|
|
60
|
+
// spaces) or an interpreter plus script ("node .../main.js"). The shared
|
|
61
|
+
// resolver also unwraps npm's Windows .cmd shim to its declared JS bin.
|
|
61
62
|
const argv0 = args.compiler
|
|
62
|
-
? (
|
|
63
|
+
? compilerArgv(args.compiler)
|
|
63
64
|
: [process.execPath, args["compiler-js"]];
|
|
64
65
|
|
|
65
66
|
// App and fixture build graphs state the host and target explicitly. A
|
|
@@ -17,6 +17,7 @@ import { spawnSync } from "node:child_process";
|
|
|
17
17
|
import fs from "node:fs";
|
|
18
18
|
import os from "node:os";
|
|
19
19
|
import path from "node:path";
|
|
20
|
+
import { compilerArgv } from "./compiler_command.mjs";
|
|
20
21
|
|
|
21
22
|
function parseArgs(argv) {
|
|
22
23
|
const args = {};
|
|
@@ -143,7 +144,7 @@ for (const key of ["stage", "manifest", "contract", "out-exe", "out-archive", "c
|
|
|
143
144
|
if (args[key]) args[key] = path.resolve(args[key]);
|
|
144
145
|
}
|
|
145
146
|
const argv0 = args.compiler
|
|
146
|
-
? (
|
|
147
|
+
? compilerArgv(args.compiler)
|
|
147
148
|
: [process.execPath, args["compiler-js"]];
|
|
148
149
|
|
|
149
150
|
// Cross compiles hand the compiler its zig-cc lane: the target triple as
|
|
@@ -388,6 +388,7 @@ export function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor {
|
|
|
388
388
|
x: spec.x ?? null,
|
|
389
389
|
y: spec.y ?? null,
|
|
390
390
|
resizable: spec.resizable ?? true,
|
|
391
|
+
restorePolicy: spec.restorePolicy ?? "clamp_to_visible_screen",
|
|
391
392
|
minWidth: spec.minWidth ?? 0,
|
|
392
393
|
minHeight: spec.minHeight ?? 0,
|
|
393
394
|
titlebar: spec.titlebar ?? "standard",
|
|
@@ -55,6 +55,7 @@ export interface StatusItemDescriptor {
|
|
|
55
55
|
}
|
|
56
56
|
export type WindowClosePolicy = "quit" | "hide";
|
|
57
57
|
export type WindowTitlebarStyle = "standard" | "hidden_inset" | "hidden_inset_tall" | "chromeless";
|
|
58
|
+
export type WindowRestorePolicy = "clamp_to_visible_screen" | "center_on_primary";
|
|
58
59
|
export interface WindowDescriptorSpec {
|
|
59
60
|
readonly label: Uint8Array;
|
|
60
61
|
readonly canvasLabel: Uint8Array;
|
|
@@ -64,6 +65,7 @@ export interface WindowDescriptorSpec {
|
|
|
64
65
|
readonly x?: number | null;
|
|
65
66
|
readonly y?: number | null;
|
|
66
67
|
readonly resizable?: boolean;
|
|
68
|
+
readonly restorePolicy?: WindowRestorePolicy;
|
|
67
69
|
readonly minWidth?: number;
|
|
68
70
|
readonly minHeight?: number;
|
|
69
71
|
readonly titlebar?: WindowTitlebarStyle;
|
|
@@ -84,6 +86,7 @@ export interface WindowDescriptor {
|
|
|
84
86
|
readonly x: number | null;
|
|
85
87
|
readonly y: number | null;
|
|
86
88
|
readonly resizable: boolean;
|
|
89
|
+
readonly restorePolicy: WindowRestorePolicy;
|
|
87
90
|
readonly minWidth: number;
|
|
88
91
|
readonly minHeight: number;
|
|
89
92
|
readonly titlebar: WindowTitlebarStyle;
|
|
@@ -135,6 +135,8 @@ export type WindowClosePolicy = "quit" | "hide";
|
|
|
135
135
|
|
|
136
136
|
export type WindowTitlebarStyle = "standard" | "hidden_inset" | "hidden_inset_tall" | "chromeless";
|
|
137
137
|
|
|
138
|
+
export type WindowRestorePolicy = "clamp_to_visible_screen" | "center_on_primary";
|
|
139
|
+
|
|
138
140
|
/// Author-facing input to `windowDescriptor`; omitted fields receive the
|
|
139
141
|
/// same defaults as UiApp.WindowDescriptor.
|
|
140
142
|
export interface WindowDescriptorSpec {
|
|
@@ -146,6 +148,7 @@ export interface WindowDescriptorSpec {
|
|
|
146
148
|
readonly x?: number | null;
|
|
147
149
|
readonly y?: number | null;
|
|
148
150
|
readonly resizable?: boolean;
|
|
151
|
+
readonly restorePolicy?: WindowRestorePolicy;
|
|
149
152
|
readonly minWidth?: number;
|
|
150
153
|
readonly minHeight?: number;
|
|
151
154
|
readonly titlebar?: WindowTitlebarStyle;
|
|
@@ -172,6 +175,7 @@ export interface WindowDescriptor {
|
|
|
172
175
|
readonly x: number | null;
|
|
173
176
|
readonly y: number | null;
|
|
174
177
|
readonly resizable: boolean;
|
|
178
|
+
readonly restorePolicy: WindowRestorePolicy;
|
|
175
179
|
readonly minWidth: number;
|
|
176
180
|
readonly minHeight: number;
|
|
177
181
|
readonly titlebar: WindowTitlebarStyle;
|
|
@@ -1467,12 +1467,13 @@ export class SubsetChecker {
|
|
|
1467
1467
|
return candidate?.type.k === "optional" && ["number", "i64", "f64", "numAlias"].includes(candidate.type.inner.k);
|
|
1468
1468
|
};
|
|
1469
1469
|
const valid =
|
|
1470
|
-
names.join(",") === "activateOnShow,allowsFullscreen,alwaysOnTop,canvasLabel,clickThrough,closePolicy,height,label,minHeight,minWidth,onCloseCommand,resizable,title,titlebar,transparent,width,x,y" &&
|
|
1470
|
+
names.join(",") === "activateOnShow,allowsFullscreen,alwaysOnTop,canvasLabel,clickThrough,closePolicy,height,label,minHeight,minWidth,onCloseCommand,resizable,restorePolicy,title,titlebar,transparent,width,x,y" &&
|
|
1471
1471
|
field("label")?.type.k === "bytes" &&
|
|
1472
1472
|
field("canvasLabel")?.type.k === "bytes" &&
|
|
1473
1473
|
field("title")?.type.k === "bytes" &&
|
|
1474
1474
|
numeric("width") && numeric("height") && optionalNumeric("x") && optionalNumeric("y") &&
|
|
1475
|
-
field("resizable")?.type.k === "bool" &&
|
|
1475
|
+
field("resizable")?.type.k === "bool" && enumMembersAre("restorePolicy", ["clamp_to_visible_screen", "center_on_primary"]) &&
|
|
1476
|
+
numeric("minWidth") && numeric("minHeight") &&
|
|
1476
1477
|
enumMembersAre("titlebar", ["standard", "hidden_inset", "hidden_inset_tall", "chromeless"]) &&
|
|
1477
1478
|
field("transparent")?.type.k === "bool" && field("alwaysOnTop")?.type.k === "bool" &&
|
|
1478
1479
|
field("clickThrough")?.type.k === "bool" && field("activateOnShow")?.type.k === "bool" &&
|