@native-sdk/cli 0.9.0 → 0.9.1
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 +331 -24
- package/build.zig +179 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +167 -12
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +11 -5
- package/skill-data/ts-core/SKILL.md +53 -20
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +29 -0
- package/src/app_runner/ts_core_main.zig +5 -0
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +1 -0
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +28 -0
- package/src/embed/ui_host.zig +68 -2
- package/src/platform/linux/cef_host.cpp +7 -1
- package/src/platform/linux/gtk_host.c +200 -5
- package/src/platform/linux/gtk_host.h +2 -1
- package/src/platform/linux/root.zig +69 -4
- package/src/platform/macos/appkit_host.h +11 -7
- package/src/platform/macos/appkit_host.m +210 -88
- package/src/platform/macos/cef_host.mm +210 -88
- package/src/platform/macos/root.zig +77 -30
- package/src/platform/null_platform.zig +234 -51
- package/src/platform/null_platform_tests.zig +39 -0
- package/src/platform/root.zig +10 -0
- package/src/platform/types.zig +105 -16
- package/src/platform/windows/root.zig +20 -6
- package/src/platform/windows/webview2_host.cpp +41 -5
- package/src/root.zig +7 -0
- package/src/runtime/api.zig +8 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +11 -1
- package/src/runtime/core.zig +12 -6
- package/src/runtime/effects.zig +1323 -35
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +5 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +97 -7
- package/src/runtime/session_tests.zig +81 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +95 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +321 -109
- package/src/runtime/ui_app_tests.zig +132 -6
- package/src/runtime/ui_app_window_tests.zig +61 -7
- package/src/runtime/validation.zig +20 -0
- package/src/tooling/templates.zig +28 -0
- package/src/tooling/ts_core.zig +83 -0
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Flatten a static archive whose members include nested archives into one
|
|
3
|
+
// plain object archive.
|
|
4
|
+
//
|
|
5
|
+
// Zig's ELF static-library emission stores `.a` link inputs as archive
|
|
6
|
+
// MEMBERS instead of merging their objects (Mach-O emission merges), so an
|
|
7
|
+
// Android embed library carrying compiled TypeScript core/service archives
|
|
8
|
+
// would hand the NDK linker nested blobs it skips with a warning. This
|
|
9
|
+
// driver extracts every member with the supplied zig's llvm-ar (GNU
|
|
10
|
+
// long-name members included — the reason system `ar` on macOS is not an
|
|
11
|
+
// option), recurses into nested archives, and re-archives the objects with
|
|
12
|
+
// a fresh symbol index.
|
|
13
|
+
//
|
|
14
|
+
// node merge_static_archives.mjs --zig <zig-exe> --format <gnu|darwin>
|
|
15
|
+
// --out <file.a> --in <file.a> [--in <file.a> ...]
|
|
16
|
+
|
|
17
|
+
import { spawnSync } from "node:child_process";
|
|
18
|
+
import fs from "node:fs";
|
|
19
|
+
import os from "node:os";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
|
|
22
|
+
const args = { in: [] };
|
|
23
|
+
for (let i = 2; i < process.argv.length; i += 2) {
|
|
24
|
+
const key = process.argv[i];
|
|
25
|
+
const value = process.argv[i + 1];
|
|
26
|
+
if (!key?.startsWith("--") || value === undefined) {
|
|
27
|
+
console.error("usage: merge_static_archives.mjs --zig <zig-exe> --format <gnu|darwin> --out <file.a> --in <file.a> [--in ...]");
|
|
28
|
+
process.exit(2);
|
|
29
|
+
}
|
|
30
|
+
if (key === "--in") args.in.push(path.resolve(value));
|
|
31
|
+
else args[key.slice(2)] = value;
|
|
32
|
+
}
|
|
33
|
+
for (const required of ["zig", "format", "out"]) {
|
|
34
|
+
if (!args[required]) {
|
|
35
|
+
console.error(`merge_static_archives.mjs: missing --${required}`);
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (args.in.length === 0) {
|
|
40
|
+
console.error("merge_static_archives.mjs: supply at least one --in archive");
|
|
41
|
+
process.exit(2);
|
|
42
|
+
}
|
|
43
|
+
args.out = path.resolve(args.out);
|
|
44
|
+
|
|
45
|
+
function ar(arArgs) {
|
|
46
|
+
const result = spawnSync(args.zig, ["ar", ...arArgs], { encoding: "utf8" });
|
|
47
|
+
if (result.status !== 0) {
|
|
48
|
+
console.error(`merge_static_archives.mjs: zig ar ${arArgs[0]} failed:\n${result.stderr ?? ""}`);
|
|
49
|
+
process.exit(result.status ?? 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const work = fs.mkdtempSync(path.join(os.tmpdir(), "native-merge-archives-"));
|
|
54
|
+
try {
|
|
55
|
+
const objects = [];
|
|
56
|
+
let extraction = 0;
|
|
57
|
+
const extract = (archive) => {
|
|
58
|
+
const dir = path.join(work, String(extraction));
|
|
59
|
+
extraction += 1;
|
|
60
|
+
fs.mkdirSync(dir);
|
|
61
|
+
ar(["x", `--output=${dir}`, archive]);
|
|
62
|
+
for (const name of fs.readdirSync(dir)) {
|
|
63
|
+
const member = path.join(dir, name);
|
|
64
|
+
if (name.endsWith(".a")) extract(member);
|
|
65
|
+
else objects.push(member);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
for (const input of args.in) extract(input);
|
|
69
|
+
if (objects.length === 0) {
|
|
70
|
+
console.error("merge_static_archives.mjs: the input archives contain no objects");
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
fs.mkdirSync(path.dirname(args.out), { recursive: true });
|
|
74
|
+
fs.rmSync(args.out, { force: true });
|
|
75
|
+
ar(["rcs", `--format=${args.format}`, args.out, ...objects]);
|
|
76
|
+
} finally {
|
|
77
|
+
fs.rmSync(work, { recursive: true, force: true });
|
|
78
|
+
}
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// --out-archive <file>
|
|
14
14
|
// --out-sidecar <file>
|
|
15
15
|
// [--host-platform <arch-os-abi> --target-platform <arch-os-abi>
|
|
16
|
-
// --zig-exe <path>]
|
|
16
|
+
// --zig-exe <path>] [--android-ndk <dir>]
|
|
17
|
+
// (--compiler <cmd> | --compiler-js <main.js>)
|
|
17
18
|
|
|
18
19
|
import { spawnSync } from "node:child_process";
|
|
19
20
|
import fs from "node:fs";
|
|
@@ -51,7 +52,7 @@ function parseArgs(argv) {
|
|
|
51
52
|
const args = parseArgs(process.argv);
|
|
52
53
|
// Every path argument resolves against the INVOCATION's cwd up front:
|
|
53
54
|
// the compile itself runs from a scratch directory.
|
|
54
|
-
for (const key of ["stage", "manifest", "frontend-sidecar", "out-archive", "out-sidecar", "compiler-js", "zig-exe"]) {
|
|
55
|
+
for (const key of ["stage", "manifest", "frontend-sidecar", "out-archive", "out-sidecar", "compiler-js", "zig-exe", "android-ndk"]) {
|
|
55
56
|
if (key in args) args[key] = path.resolve(args[key]);
|
|
56
57
|
}
|
|
57
58
|
// --compiler is a COMMAND: a bare executable path (possibly containing
|
|
@@ -78,13 +79,37 @@ const hostAbi = (hostParts[2] ?? "").split(".")[0];
|
|
|
78
79
|
const targetArch = targetParts[0] ?? "";
|
|
79
80
|
const targetOs = (targetParts[1] ?? "").split(".")[0];
|
|
80
81
|
const targetAbi = (targetParts[2] ?? "").split(".")[0];
|
|
82
|
+
// The two mobile families, from the build graph's Zig triple spelling:
|
|
83
|
+
// `aarch64-ios[-simulator]` and `aarch64-linux-android`. The pinned compiler
|
|
84
|
+
// admits exactly aarch64 for both — library archives, which is the only
|
|
85
|
+
// output this driver produces.
|
|
86
|
+
const iosTarget = targetOs === "ios";
|
|
87
|
+
const androidTarget = targetOs === "linux" && targetAbi === "android";
|
|
88
|
+
const mobileTarget = iosTarget || androidTarget;
|
|
89
|
+
// The canonical SCRIPTC_TARGET spelling for a mobile compile: the compiler
|
|
90
|
+
// names iOS targets with the vendor (`aarch64-apple-ios[-simulator]`) and
|
|
91
|
+
// Android with the Zig triple itself.
|
|
92
|
+
const scriptcTarget = iosTarget
|
|
93
|
+
? `aarch64-apple-ios${targetAbi === "simulator" ? "-simulator" : ""}`
|
|
94
|
+
: args["target-platform"];
|
|
81
95
|
// A Windows host's Zig triple defaults to GNU, but an explicit same-arch MSVC
|
|
82
96
|
// target still compiles through native clang and the installed Windows SDK.
|
|
83
97
|
const nativeWindows = hostOs === "windows" && targetOs === "windows" && hostArch === targetArch &&
|
|
84
98
|
(targetAbi === hostAbi || targetAbi === "msvc");
|
|
85
99
|
const cross = args["host-platform"] !== undefined &&
|
|
86
100
|
args["target-platform"] !== args["host-platform"] && !nativeWindows;
|
|
87
|
-
if (
|
|
101
|
+
if (mobileTarget) {
|
|
102
|
+
const desktopHost = ["macos", "linux", "windows"].includes(hostOs);
|
|
103
|
+
const admitted = desktopHost && targetArch === "aarch64" && (!iosTarget || hostOs === "macos");
|
|
104
|
+
if (!admitted) {
|
|
105
|
+
console.error(
|
|
106
|
+
iosTarget && hostOs !== "macos"
|
|
107
|
+
? `TypeScript cores for an iOS target (${args["target-platform"]}) compile on a macOS build host only — the Apple SDK sysroot and Mach-O localization live there — but this build host is ${args["host-platform"]}. Build iOS apps on a Mac.`
|
|
108
|
+
: `TypeScript cores compile for the mobile targets the pinned compiler covers — aarch64 iOS/iOS-simulator (macOS host) and aarch64 Android — but this build pairs host ${args["host-platform"]} with target ${args["target-platform"]}.`,
|
|
109
|
+
);
|
|
110
|
+
process.exit(2);
|
|
111
|
+
}
|
|
112
|
+
} else if (cross) {
|
|
88
113
|
const desktopHost = ["macos", "linux", "windows"].includes(hostOs);
|
|
89
114
|
const admitted = desktopHost &&
|
|
90
115
|
(targetOs === "linux" ||
|
|
@@ -101,14 +126,19 @@ if (cross) {
|
|
|
101
126
|
process.exit(2);
|
|
102
127
|
}
|
|
103
128
|
}
|
|
129
|
+
// Cross compiles ride the compiler's zig-cc lane: SCRIPTC_TARGET carries the
|
|
130
|
+
// compiler's own mobile spellings for iOS/Android, --zig-exe's directory
|
|
131
|
+
// fronts PATH, and an Android build threads the NDK location the same way
|
|
132
|
+
// (--android-ndk becomes ANDROID_NDK_ROOT for the sysroot discovery).
|
|
104
133
|
const compileEnv = cross
|
|
105
134
|
? {
|
|
106
135
|
...process.env,
|
|
107
136
|
SCRIPTC_CC: "zigcc",
|
|
108
|
-
SCRIPTC_TARGET:
|
|
137
|
+
SCRIPTC_TARGET: scriptcTarget,
|
|
109
138
|
...(args["zig-exe"]
|
|
110
139
|
? { PATH: `${path.dirname(args["zig-exe"])}${path.delimiter}${process.env.PATH ?? ""}` }
|
|
111
140
|
: {}),
|
|
141
|
+
...(args["android-ndk"] && androidTarget ? { ANDROID_NDK_ROOT: args["android-ndk"] } : {}),
|
|
112
142
|
}
|
|
113
143
|
: process.env;
|
|
114
144
|
|
|
@@ -164,15 +194,30 @@ try {
|
|
|
164
194
|
|
|
165
195
|
// The pinned compiler owns the archive contract (including its build id),
|
|
166
196
|
// while the SDK frontend owns facts the compiler release predates. Carry
|
|
167
|
-
// exactly
|
|
197
|
+
// exactly that checked source metadata across the compile boundary.
|
|
168
198
|
const compiledContract = JSON.parse(fs.readFileSync(sidecar, "utf8"));
|
|
169
199
|
const frontendContract = JSON.parse(fs.readFileSync(args["frontend-sidecar"], "utf8"));
|
|
170
|
-
|
|
171
|
-
|
|
200
|
+
const modelUnbound = frontendContract.model_unbound;
|
|
201
|
+
const msgUnbound = frontendContract.msg?.unbound;
|
|
202
|
+
const stringList = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
203
|
+
if (
|
|
204
|
+
!/^[0-9a-f]{16}$/.test(frontendContract.model_fingerprint ?? "") ||
|
|
205
|
+
typeof frontendContract.has_migrate !== "boolean" ||
|
|
206
|
+
!stringList(modelUnbound) ||
|
|
207
|
+
!stringList(msgUnbound)
|
|
208
|
+
) {
|
|
209
|
+
console.error("the frontend contract is missing its checked persistence or unbound-view metadata — the SDK frontend and build driver are out of sync");
|
|
172
210
|
process.exit(1);
|
|
173
211
|
}
|
|
174
212
|
compiledContract.model_fingerprint = frontendContract.model_fingerprint;
|
|
175
213
|
compiledContract.has_migrate = frontendContract.has_migrate;
|
|
214
|
+
// Model and Msg are re-exported into the generated facade, so the pinned
|
|
215
|
+
// compiler cannot resolve that entry module's viewUnbound list against an
|
|
216
|
+
// entry-owned root declaration. These lists are lint-only source facts:
|
|
217
|
+
// restore the frontend's checked names without replacing any ABI fact the
|
|
218
|
+
// compiler co-emitted for the archive.
|
|
219
|
+
compiledContract.model_unbound = modelUnbound;
|
|
220
|
+
compiledContract.msg = { ...(compiledContract.msg ?? {}), unbound: msgUnbound };
|
|
176
221
|
fs.writeFileSync(args["out-sidecar"], `${JSON.stringify(compiledContract, null, 2)}\n`);
|
|
177
222
|
} finally {
|
|
178
223
|
fs.rmSync(work, { recursive: true, force: true });
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
// pairings follow the pinned compiler's build matrix: same-triple compiles run
|
|
10
10
|
// natively; Linux and Windows GNU targets cross-compile from any desktop host
|
|
11
11
|
// over the compiler's zig-cc lane; macOS targets need a macOS build host.
|
|
12
|
+
// Mobile targets (aarch64 iOS, iOS simulator, and Android) are archive-only:
|
|
13
|
+
// --out-archive is admitted (iOS from a macOS host, Android from any desktop
|
|
14
|
+
// host with an NDK), --out-exe refuses with the in-process pointer.
|
|
12
15
|
|
|
13
16
|
import { spawnSync } from "node:child_process";
|
|
14
17
|
import fs from "node:fs";
|
|
@@ -21,7 +24,7 @@ function parseArgs(argv) {
|
|
|
21
24
|
const key = argv[i];
|
|
22
25
|
const value = argv[i + 1];
|
|
23
26
|
if (!key?.startsWith("--") || value === undefined) {
|
|
24
|
-
console.error("usage: run_external_service_compiler.mjs --stage <dir> --manifest <package.json> --contract <services.contract.json> (--out-exe <file> | --out-archive <file>) --host-platform <arch-os-abi> --target-platform <arch-os-abi> [--zig-exe <path>] (--compiler <cmd> | --compiler-js <main.js>)");
|
|
27
|
+
console.error("usage: run_external_service_compiler.mjs --stage <dir> --manifest <package.json> --contract <services.contract.json> (--out-exe <file> | --out-archive <file>) --host-platform <arch-os-abi> --target-platform <arch-os-abi> [--zig-exe <path>] [--android-ndk <dir>] (--compiler <cmd> | --compiler-js <main.js>)");
|
|
25
28
|
process.exit(2);
|
|
26
29
|
}
|
|
27
30
|
args[key.slice(2)] = value;
|
|
@@ -60,13 +63,45 @@ const hostAbi = platformAbi(args["host-platform"]);
|
|
|
60
63
|
const targetOs = platformOs(args["target-platform"]);
|
|
61
64
|
const targetArch = platformArch(args["target-platform"]);
|
|
62
65
|
const targetAbi = platformAbi(args["target-platform"]);
|
|
66
|
+
// The two mobile families, from the build graph's Zig triple spelling:
|
|
67
|
+
// `aarch64-ios[-simulator]` and `aarch64-linux-android`. The pinned compiler
|
|
68
|
+
// admits exactly aarch64 for both, library archives only.
|
|
69
|
+
const iosTarget = targetOs === "ios";
|
|
70
|
+
const androidTarget = targetOs === "linux" && targetAbi === "android";
|
|
71
|
+
const mobileTarget = iosTarget || androidTarget;
|
|
72
|
+
// The canonical SCRIPTC_TARGET spelling for a mobile compile: the compiler
|
|
73
|
+
// names iOS targets with the vendor (`aarch64-apple-ios[-simulator]`) and
|
|
74
|
+
// Android with the Zig triple itself.
|
|
75
|
+
const scriptcTarget = iosTarget
|
|
76
|
+
? `aarch64-apple-ios${targetAbi === "simulator" ? "-simulator" : ""}`
|
|
77
|
+
: args["target-platform"];
|
|
63
78
|
// Zig names a native Windows host with the GNU ABI by default, while a user
|
|
64
79
|
// may explicitly target MSVC on that same machine. That remains native
|
|
65
80
|
// compiler work; an exact native GNU triple does too.
|
|
66
81
|
const nativeWindows = hostOs === "windows" && targetOs === "windows" && hostArch === targetArch &&
|
|
67
82
|
(targetAbi === hostAbi || targetAbi === "msvc");
|
|
68
83
|
const cross = args["target-platform"] !== args["host-platform"] && !nativeWindows;
|
|
69
|
-
if (
|
|
84
|
+
if (mobileTarget) {
|
|
85
|
+
// Mobile services are archive-only: there is no child process to spawn on
|
|
86
|
+
// iOS or Android, so the plain-scriptc executable lane refuses here.
|
|
87
|
+
if (args["out-exe"]) {
|
|
88
|
+
console.error(
|
|
89
|
+
`TypeScript services for ${args["target-platform"]} build library archives only: mobile apps cannot spawn a sibling service process. ` +
|
|
90
|
+
"Use the in-process carrier (--out-archive) — the mobile default.",
|
|
91
|
+
);
|
|
92
|
+
process.exit(2);
|
|
93
|
+
}
|
|
94
|
+
const desktopHost = ["macos", "linux", "windows"].includes(hostOs);
|
|
95
|
+
const admitted = desktopHost && targetArch === "aarch64" && (!iosTarget || hostOs === "macos");
|
|
96
|
+
if (!admitted) {
|
|
97
|
+
console.error(
|
|
98
|
+
iosTarget && hostOs !== "macos"
|
|
99
|
+
? `TypeScript services for an iOS target (${args["target-platform"]}) compile on a macOS build host only — the Apple SDK sysroot and Mach-O localization live there — but this build host is ${args["host-platform"]}. Build iOS service apps on a Mac.`
|
|
100
|
+
: `TypeScript services compile for the mobile targets the pinned compiler covers — aarch64 iOS/iOS-simulator (macOS host) and aarch64 Android — but this build pairs host ${args["host-platform"]} with target ${args["target-platform"]}.`,
|
|
101
|
+
);
|
|
102
|
+
process.exit(2);
|
|
103
|
+
}
|
|
104
|
+
} else if (cross) {
|
|
70
105
|
const desktopHost = ["macos", "linux", "windows"].includes(hostOs);
|
|
71
106
|
const admitted = desktopHost &&
|
|
72
107
|
(targetOs === "linux" ||
|
|
@@ -86,24 +121,25 @@ if (cross) {
|
|
|
86
121
|
|
|
87
122
|
// Runtime localization is narrower than executable cross-compilation. The
|
|
88
123
|
// in-process archive's object merger supports native Linux through host
|
|
89
|
-
// binutils, cross-ELF for x86_64/aarch64, COFF for
|
|
90
|
-
//
|
|
91
|
-
//
|
|
124
|
+
// binutils, cross-ELF for x86_64/aarch64 (Android included), COFF for
|
|
125
|
+
// x86_64, and Mach-O — iOS device and simulator included — on a macOS host.
|
|
126
|
+
// Keep this preflight in lockstep with the pinned compiler's compileLibrary guard
|
|
127
|
+
// so `in_process` refusals teach before compiler work.
|
|
92
128
|
if (args["out-archive"]) {
|
|
93
129
|
const archiveSupported =
|
|
94
130
|
(targetOs === "linux" && (!cross || ["x86_64", "aarch64"].includes(targetArch))) ||
|
|
95
131
|
(targetOs === "windows" && targetArch === "x86_64" && (!cross || targetAbi === "gnu")) ||
|
|
96
|
-
(targetOs === "macos" && hostOs === "macos");
|
|
132
|
+
((targetOs === "macos" || iosTarget) && hostOs === "macos");
|
|
97
133
|
if (!archiveSupported) {
|
|
98
134
|
console.error(
|
|
99
135
|
`TypeScript in-process services cannot build a runtime-localized archive for ${args["target-platform"]} from ${args["host-platform"]}. ` +
|
|
100
|
-
"The pinned compiler supports native Linux, cross-Linux x86_64/aarch64, native Windows x86_64, cross-Windows x86_64 GNU, and macOS targets on a macOS host. " +
|
|
101
|
-
"Use the child carrier (the default), or choose a supported in-process target.",
|
|
136
|
+
"The pinned compiler supports native Linux, cross-Linux x86_64/aarch64 (Android included), native Windows x86_64, cross-Windows x86_64 GNU, and macOS/iOS targets on a macOS host. " +
|
|
137
|
+
"Use the child carrier (the desktop default), or choose a supported in-process target.",
|
|
102
138
|
);
|
|
103
139
|
process.exit(2);
|
|
104
140
|
}
|
|
105
141
|
}
|
|
106
|
-
for (const key of ["stage", "manifest", "contract", "out-exe", "out-archive", "compiler-js", "zig-exe"]) {
|
|
142
|
+
for (const key of ["stage", "manifest", "contract", "out-exe", "out-archive", "compiler-js", "zig-exe", "android-ndk"]) {
|
|
107
143
|
if (args[key]) args[key] = path.resolve(args[key]);
|
|
108
144
|
}
|
|
109
145
|
const argv0 = args.compiler
|
|
@@ -111,17 +147,21 @@ const argv0 = args.compiler
|
|
|
111
147
|
: [process.execPath, args["compiler-js"]];
|
|
112
148
|
|
|
113
149
|
// Cross compiles hand the compiler its zig-cc lane: the target triple as
|
|
114
|
-
// SCRIPTC_TARGET
|
|
115
|
-
//
|
|
116
|
-
//
|
|
150
|
+
// SCRIPTC_TARGET (the compiler's own mobile spellings for iOS/Android), and
|
|
151
|
+
// (when the build graph supplied its own zig) that zig's directory at the
|
|
152
|
+
// front of PATH so the lane never depends on an ambient install. An Android
|
|
153
|
+
// build threads the NDK location the same way (--android-ndk becomes
|
|
154
|
+
// ANDROID_NDK_ROOT for the compiler's sysroot discovery). Native compiles
|
|
155
|
+
// keep the process environment untouched.
|
|
117
156
|
const compileEnv = cross
|
|
118
157
|
? {
|
|
119
158
|
...process.env,
|
|
120
159
|
SCRIPTC_CC: "zigcc",
|
|
121
|
-
SCRIPTC_TARGET:
|
|
160
|
+
SCRIPTC_TARGET: scriptcTarget,
|
|
122
161
|
...(args["zig-exe"]
|
|
123
162
|
? { PATH: `${path.dirname(args["zig-exe"])}${path.delimiter}${process.env.PATH ?? ""}` }
|
|
124
163
|
: {}),
|
|
164
|
+
...(args["android-ndk"] && androidTarget ? { ANDROID_NDK_ROOT: args["android-ndk"] } : {}),
|
|
125
165
|
}
|
|
126
166
|
: process.env;
|
|
127
167
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Stage the typed service executable: ordinary service TypeScript plus
|
|
3
3
|
// corewire's generated service_host_main.ts. One narrow mechanical lowering
|
|
4
|
-
// is required by
|
|
4
|
+
// is required by the pinned compiler: an escaping `throw { kind, message }` becomes
|
|
5
5
|
// an Error subclass carrying kind in `.name`, the object form its reachable
|
|
6
6
|
// static catch tier cannot inspect yet. NS1067 rejects locally caught tagged
|
|
7
7
|
// records; shared core-class modules receive the same transform in this
|
|
@@ -3,6 +3,8 @@ export declare function utf8Bytes(s: string): Uint8Array;
|
|
|
3
3
|
export type Msgish = {
|
|
4
4
|
readonly kind: string;
|
|
5
5
|
};
|
|
6
|
+
import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.js";
|
|
7
|
+
export declare function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor;
|
|
6
8
|
/** Cooperative cancellation capability supplied by generated service hosts. */
|
|
7
9
|
export interface ServiceCancellation {
|
|
8
10
|
/** True after Cmd.cancel or the operation deadline requests cancellation. */
|
|
@@ -136,6 +138,23 @@ export interface WriteRoute<M extends Msgish> {
|
|
|
136
138
|
readonly ok: EmptyKind<M>;
|
|
137
139
|
readonly err: BytesKind<M>;
|
|
138
140
|
}
|
|
141
|
+
export interface FileReadStreamRoute<M extends Msgish> {
|
|
142
|
+
readonly key?: string;
|
|
143
|
+
readonly chunk: BytesKind<M>;
|
|
144
|
+
readonly done: TimestampKind<M>;
|
|
145
|
+
readonly err: BytesKind<M>;
|
|
146
|
+
}
|
|
147
|
+
export interface FileStatArm {
|
|
148
|
+
readonly exists: boolean;
|
|
149
|
+
readonly size: number;
|
|
150
|
+
readonly mtimeMs: number;
|
|
151
|
+
}
|
|
152
|
+
export type FileStatKind<M extends Msgish> = M extends Msgish ? [Exclude<keyof M, "kind">] extends [keyof FileStatArm] ? [keyof FileStatArm] extends [Exclude<keyof M, "kind">] ? M extends Msgish & FileStatArm ? M["kind"] : never : never : never : never;
|
|
153
|
+
export interface FileStatRoute<M extends Msgish> {
|
|
154
|
+
readonly key?: string;
|
|
155
|
+
readonly ok: FileStatKind<M>;
|
|
156
|
+
readonly err: BytesKind<M>;
|
|
157
|
+
}
|
|
139
158
|
export interface StoreScanOptions {
|
|
140
159
|
readonly limit?: number;
|
|
141
160
|
readonly after?: string | Uint8Array;
|
|
@@ -229,9 +248,12 @@ export interface FetchStreamSpec extends FetchSpec {
|
|
|
229
248
|
readonly maxLineBytes?: number;
|
|
230
249
|
}
|
|
231
250
|
export interface NotificationSpec {
|
|
251
|
+
readonly id?: Uint8Array;
|
|
232
252
|
readonly title: Uint8Array;
|
|
233
253
|
readonly subtitle?: Uint8Array;
|
|
234
254
|
readonly body?: Uint8Array;
|
|
255
|
+
readonly actionLabel?: Uint8Array;
|
|
256
|
+
readonly actionCommand?: Uint8Array;
|
|
235
257
|
}
|
|
236
258
|
export type LocalTimeStyle = "date" | "time" | "datetime";
|
|
237
259
|
export type Cmd<M extends Msgish> = {
|
|
@@ -284,6 +306,49 @@ export type Cmd<M extends Msgish> = {
|
|
|
284
306
|
readonly errKind: string;
|
|
285
307
|
readonly path: Uint8Array;
|
|
286
308
|
readonly bytes: Uint8Array;
|
|
309
|
+
} | {
|
|
310
|
+
readonly op: "append_file";
|
|
311
|
+
readonly key: string;
|
|
312
|
+
readonly okKind: string;
|
|
313
|
+
readonly errKind: string;
|
|
314
|
+
readonly path: Uint8Array;
|
|
315
|
+
readonly bytes: Uint8Array;
|
|
316
|
+
} | {
|
|
317
|
+
readonly op: "stat_file";
|
|
318
|
+
readonly key: string;
|
|
319
|
+
readonly okKind: string;
|
|
320
|
+
readonly errKind: string;
|
|
321
|
+
readonly path: Uint8Array;
|
|
322
|
+
} | {
|
|
323
|
+
readonly op: "delete_file";
|
|
324
|
+
readonly key: string;
|
|
325
|
+
readonly okKind: string;
|
|
326
|
+
readonly errKind: string;
|
|
327
|
+
readonly path: Uint8Array;
|
|
328
|
+
} | {
|
|
329
|
+
readonly op: "read_file_stream";
|
|
330
|
+
readonly key: string;
|
|
331
|
+
readonly chunkKind: string;
|
|
332
|
+
readonly doneKind: string;
|
|
333
|
+
readonly errKind: string;
|
|
334
|
+
readonly path: Uint8Array;
|
|
335
|
+
} | {
|
|
336
|
+
readonly op: "write_file_stream";
|
|
337
|
+
readonly key: string;
|
|
338
|
+
readonly okKind: string;
|
|
339
|
+
readonly errKind: string;
|
|
340
|
+
readonly path: Uint8Array;
|
|
341
|
+
} | {
|
|
342
|
+
readonly op: "write_file_chunk";
|
|
343
|
+
readonly key: string;
|
|
344
|
+
readonly okKind: string;
|
|
345
|
+
readonly errKind: string;
|
|
346
|
+
readonly bytes: Uint8Array;
|
|
347
|
+
} | {
|
|
348
|
+
readonly op: "write_file_close";
|
|
349
|
+
readonly key: string;
|
|
350
|
+
readonly okKind: string;
|
|
351
|
+
readonly errKind: string;
|
|
287
352
|
} | {
|
|
288
353
|
readonly op: "store_set";
|
|
289
354
|
readonly key: string;
|
|
@@ -363,9 +428,12 @@ export type Cmd<M extends Msgish> = {
|
|
|
363
428
|
readonly errKind: string;
|
|
364
429
|
} | {
|
|
365
430
|
readonly op: "show_notification";
|
|
431
|
+
readonly id: Uint8Array;
|
|
366
432
|
readonly title: Uint8Array;
|
|
367
433
|
readonly subtitle: Uint8Array;
|
|
368
434
|
readonly body: Uint8Array;
|
|
435
|
+
readonly actionLabel: Uint8Array;
|
|
436
|
+
readonly actionCommand: Uint8Array;
|
|
369
437
|
} | {
|
|
370
438
|
readonly op: "delay";
|
|
371
439
|
readonly key: string;
|
|
@@ -500,6 +568,13 @@ export declare const Cmd: {
|
|
|
500
568
|
cancel(key: string): Cmd<never>;
|
|
501
569
|
readFile<M extends Msgish>(path: Uint8Array, route: RequestRoute<M>): Cmd<M>;
|
|
502
570
|
writeFile<M extends Msgish>(path: Uint8Array, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
571
|
+
appendFile<M extends Msgish>(path: Uint8Array, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
572
|
+
statFile<M extends Msgish>(path: Uint8Array, route: FileStatRoute<M>): Cmd<M>;
|
|
573
|
+
deleteFile<M extends Msgish>(path: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
574
|
+
readFileStream<M extends Msgish>(path: Uint8Array, route: FileReadStreamRoute<M>): Cmd<M>;
|
|
575
|
+
writeFileStream<M extends Msgish>(key: string, path: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
576
|
+
writeFileChunk<M extends Msgish>(key: string, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
577
|
+
writeFileClose<M extends Msgish>(key: string, route: WriteRoute<M>): Cmd<M>;
|
|
503
578
|
store: {
|
|
504
579
|
set<M extends Msgish>(storeKey: string, bytes: Uint8Array, route: WriteRoute<M>): Cmd<M>;
|
|
505
580
|
get<M extends Msgish>(storeKey: string, route: RequestRoute<M>): Cmd<M>;
|