@skathi-native/cli 0.1.0-beta.2 → 0.1.0-beta.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/aot/host-globals.json +105 -0
- package/aot/native.ts +142 -0
- package/aot/pin.ts +67 -0
- package/aot/toolchain.lock.json +17 -0
- package/aot/transform.ts +69 -0
- package/check/codes.ts +19 -0
- package/check/command.ts +5 -3
- package/check/index.ts +44 -1
- package/cli/aot-build.ts +192 -0
- package/cli/build-app.ts +102 -31
- package/cli/config.ts +45 -102
- package/cli/create.ts +12 -54
- package/cli/dev.ts +109 -19
- package/cli/effects.ts +162 -0
- package/cli/elf.ts +3 -2
- package/cli/help.ts +56 -148
- package/cli/host-fetch.ts +116 -54
- package/cli/host.ts +59 -39
- package/cli/sk.ts +440 -246
- package/cli/skpk.ts +6 -0
- package/cli/stamp.ts +2 -2
- package/cli/term.ts +169 -38
- package/cli/workload-cache.ts +258 -0
- package/effects/compile.ts +952 -0
- package/effects/redslangc.json +23 -0
- package/effects/redslangc.ts +220 -0
- package/effects/sk.slang +558 -0
- package/package.json +6 -2
- package/templates/icon.png +0 -0
- package/templates/minimal/.vscode/settings.json +3 -0
- package/templates/minimal/src/App.vue +2 -2
- package/templates/showcase/.vscode/settings.json +3 -0
- package/templates/showcase/shaders/sheen.slang +23 -0
- package/templates/showcase/src/components/Titlebar.vue +7 -3
- package/templates/showcase/src/engine.ts +3 -26
- package/templates/showcase/src/pages/AudioPage.vue +6 -9
- package/templates/showcase/src/pages/FilesPage.vue +11 -15
- package/templates/showcase/src/pages/FormsPage.vue +2 -3
- package/templates/showcase/src/pages/GraphicsPage.vue +13 -15
- package/templates/showcase/src/pages/HomePage.vue +1 -2
- package/templates/showcase/src/pages/LocalePage.vue +2 -2
- package/templates/showcase/src/pages/MediaPage.vue +1 -1
- package/templates/showcase/src/pages/MotionPage.vue +1 -1
- package/templates/showcase/src/pages/NetworkPage.vue +6 -5
- package/templates/showcase/src/pages/PermissionsPage.vue +2 -2
- package/templates/showcase/src/pages/StoragePage.vue +23 -36
- package/templates/showcase/src/pages/StylesPage.vue +9 -1
- package/templates/showcase/src/pages/SystemPage.vue +3 -3
- package/templates/showcase/src/styles.css +2 -2
- package/templates/showcase/src/components/Missing.vue +0 -26
package/cli/host.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// Where `sk build` gets the prebuilt bare host it stamps: `cargo build --release -p sk-app
|
|
2
|
-
// --features prod` (the whole engine, no app), built once per Skathi version and variant
|
|
3
|
-
//
|
|
2
|
+
// --features prod` (the whole engine, no app), built once per Skathi version and variant: `standard`, or
|
|
3
|
+
// `no-devtools` with the devtools compiled out.
|
|
4
4
|
//
|
|
5
|
-
// Resolution, first hit wins: 1. `--
|
|
5
|
+
// Resolution, first hit wins: 1. `--workload <exe>` or `SK_HOST`; 2. in-repo
|
|
6
6
|
// target/x86_64-pc-windows-msvc/release/sk-app.exe, when that is a prod host of this variant and
|
|
7
|
-
// version; 3. the local cache (`sk
|
|
7
|
+
// version; 3. the local cache (`sk workload add <exe>`, `sk workload build`, or a download from this
|
|
8
8
|
// version's GitHub release: host-fetch.ts); 4. an error naming them. Paths per OS are in platform.ts.
|
|
9
9
|
//
|
|
10
|
-
// A host for another OS cannot be run to ask what it is: only `--
|
|
10
|
+
// A host for another OS cannot be run to ask what it is: only `--workload` / `SK_HOST` names one, its
|
|
11
11
|
// format is sniffed, and what it is comes from a `host.json` beside it or is taken on trust, with a warning.
|
|
12
12
|
//
|
|
13
13
|
// A host and a bundle must come from the same Skathi version (the bundle carries the JS half of
|
|
14
14
|
// the `__sk_*` protocol): the CLI refuses a host whose `--sk-host-info` disagrees
|
|
15
|
-
// (`--allow-
|
|
15
|
+
// (`--allow-workload-mismatch` is for maintainers).
|
|
16
16
|
|
|
17
17
|
import { spawnSync } from "node:child_process";
|
|
18
18
|
import {
|
|
@@ -29,7 +29,8 @@ import {
|
|
|
29
29
|
} from "node:fs";
|
|
30
30
|
import { homedir } from "node:os";
|
|
31
31
|
import { dirname, join, resolve } from "node:path";
|
|
32
|
-
import {
|
|
32
|
+
import type { CompilerInfo } from "../aot/pin";
|
|
33
|
+
import { cargoFeatureArgs, ENGINE_FEATURES, VARIANTS, type Variant } from "./config";
|
|
33
34
|
import { appendedPayloadOf, elfMachineOf } from "./elf";
|
|
34
35
|
import { bundlePayloadPath, machOArchs } from "./macos-bundle";
|
|
35
36
|
import { readPe, RT } from "./pe";
|
|
@@ -56,12 +57,21 @@ export interface HostInfo {
|
|
|
56
57
|
jscPin: string;
|
|
57
58
|
payloadFormat: number;
|
|
58
59
|
profile: string;
|
|
60
|
+
/** What a dev host reloads in place from `sk dev` besides JS modules; absent on older hosts. */
|
|
61
|
+
devReload?: string[];
|
|
62
|
+
/** A host built with the native AOT loader: what an app image must be compiled against. */
|
|
63
|
+
aot?: HostAot | null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface HostAot extends CompilerInfo {
|
|
67
|
+
transform: string;
|
|
68
|
+
preludeSha256: string;
|
|
59
69
|
}
|
|
60
70
|
|
|
61
71
|
export interface ResolvedHost {
|
|
62
72
|
exe: string;
|
|
63
73
|
info: HostInfo;
|
|
64
|
-
source: "--
|
|
74
|
+
source: "--workload" | "SK_HOST" | "repo" | "cache";
|
|
65
75
|
unverified?: string;
|
|
66
76
|
}
|
|
67
77
|
|
|
@@ -83,12 +93,12 @@ function formatProblem(exe: string, platform: Platform): string | null {
|
|
|
83
93
|
if (platform === "windows") return null;
|
|
84
94
|
if (platform === "linux") {
|
|
85
95
|
const machine = elfMachineOf(exe);
|
|
86
|
-
if (!machine) return `${exe} is not an ELF executable — a Linux build needs a Linux sk-app`;
|
|
96
|
+
if (!machine) return `${exe} is not an ELF executable — a Linux build needs a Linux workload (sk-app)`;
|
|
87
97
|
if (machine !== "x86_64" && machine !== "aarch64") return `${exe} is an ELF for ${machine}, not x86_64 or aarch64`;
|
|
88
98
|
return null;
|
|
89
99
|
}
|
|
90
100
|
const archs = machOArchs(exe);
|
|
91
|
-
if (!archs) return `${exe} is not a Mach-O executable — a macOS bundle needs a macOS sk-app`;
|
|
101
|
+
if (!archs) return `${exe} is not a Mach-O executable — a macOS bundle needs a macOS workload (sk-app)`;
|
|
92
102
|
if (!archs.some((a) => a === "arm64" || a === "x86_64"))
|
|
93
103
|
return `${exe} is a Mach-O for ${archs.join(", ")}, not arm64 or x86_64`;
|
|
94
104
|
return null;
|
|
@@ -106,18 +116,21 @@ export function crossHostInfo(
|
|
|
106
116
|
try {
|
|
107
117
|
const info = JSON.parse(readFileSync(sidecar, "utf8")) as HostInfo;
|
|
108
118
|
if (info.mode && info.skathi && info.variant) {
|
|
109
|
-
return {
|
|
119
|
+
return {
|
|
120
|
+
info,
|
|
121
|
+
unverified: `${platform} workload described by ${sidecar}, not run (this is ${process.platform})`,
|
|
122
|
+
};
|
|
110
123
|
}
|
|
111
124
|
} catch {}
|
|
112
125
|
}
|
|
113
|
-
const
|
|
126
|
+
const devtools = variant !== "no-devtools";
|
|
114
127
|
const info: HostInfo = {
|
|
115
128
|
mode: "prod",
|
|
116
129
|
skathi: CLI_VERSION,
|
|
117
130
|
crate: "unknown",
|
|
118
131
|
variant,
|
|
119
|
-
devtools
|
|
120
|
-
features: ["prod", ...
|
|
132
|
+
devtools,
|
|
133
|
+
features: ["prod", ...(devtools ? [] : ["no-devtools"]), ...ENGINE_FEATURES],
|
|
121
134
|
jscPin: "unknown",
|
|
122
135
|
payloadFormat: 1,
|
|
123
136
|
profile: "unknown",
|
|
@@ -125,7 +138,7 @@ export function crossHostInfo(
|
|
|
125
138
|
return {
|
|
126
139
|
info,
|
|
127
140
|
unverified:
|
|
128
|
-
`a ${platform}
|
|
141
|
+
`a ${platform} workload cannot be run on ${process.platform} to check it — ${exe} is taken to be a prod ${variant} workload ` +
|
|
129
142
|
`of Skathi ${CLI_VERSION}. Put its \`--sk-host-info\` output in ${sidecar} to have it checked.`,
|
|
130
143
|
};
|
|
131
144
|
}
|
|
@@ -133,7 +146,7 @@ export function crossHostInfo(
|
|
|
133
146
|
export function hostInfo(exe: string): HostInfo {
|
|
134
147
|
if (!existsSync(exe)) throw new HostError(`${exe} does not exist`);
|
|
135
148
|
if (isStamped(exe)) {
|
|
136
|
-
throw new HostError(`${exe} is a packaged app, not a bare
|
|
149
|
+
throw new HostError(`${exe} is a packaged app, not a bare workload (it already carries a SKPAYLOAD)`);
|
|
137
150
|
}
|
|
138
151
|
const r = spawnSync(exe, ["--sk-host-info"], { encoding: "utf8", timeout: 30_000, windowsHide: true });
|
|
139
152
|
if (r.error) throw new HostError(`${exe} could not be run: ${r.error.message}`);
|
|
@@ -144,7 +157,7 @@ export function hostInfo(exe: string): HostInfo {
|
|
|
144
157
|
return info;
|
|
145
158
|
} catch {
|
|
146
159
|
throw new HostError(
|
|
147
|
-
`${exe} did not answer --sk-host-info (exit ${r.status}).
|
|
160
|
+
`${exe} did not answer --sk-host-info (exit ${r.status}). Workloads older than this CLI do not know the flag — ` +
|
|
148
161
|
`rebuild it.\n${(r.stderr ?? "").trim().split(/\r?\n/).slice(-5).join("\n")}`,
|
|
149
162
|
);
|
|
150
163
|
}
|
|
@@ -164,18 +177,20 @@ export function checkHost(exe: string, info: HostInfo, variant: Variant | null,
|
|
|
164
177
|
const mismatch =
|
|
165
178
|
info.skathi !== CLI_VERSION && !allowMismatch
|
|
166
179
|
? `${exe} is Skathi ${info.skathi}, this CLI is ${CLI_VERSION} — the bundle carries the JS half of the ` +
|
|
167
|
-
`
|
|
180
|
+
`workload protocol, so the two must match (--allow-workload-mismatch overrides, for maintainers)`
|
|
168
181
|
: null;
|
|
169
182
|
if (variant === DEV_HOST) {
|
|
170
183
|
return info.mode === "dev"
|
|
171
184
|
? mismatch
|
|
172
|
-
: `${exe} is a ${info.mode}
|
|
185
|
+
: `${exe} is a ${info.mode} workload — sk dev needs one built without --features prod`;
|
|
173
186
|
}
|
|
174
|
-
if (info.mode !== "prod") return `${exe} is a ${info.mode}
|
|
187
|
+
if (info.mode !== "prod") return `${exe} is a ${info.mode} workload — sk build needs one built with --features prod`;
|
|
175
188
|
if (variant && info.variant !== variant) return `${exe} is the ${info.variant} variant, not ${variant}`;
|
|
176
|
-
if (!
|
|
177
|
-
return `${exe}
|
|
189
|
+
if (!VARIANTS.includes(info.variant)) {
|
|
190
|
+
return `${exe} is the ${info.variant} variant, which leaves engine parts out — sk build stamps only ${VARIANTS.join(" or ")} workloads`;
|
|
178
191
|
}
|
|
192
|
+
const missing = ENGINE_FEATURES.filter((f) => !info.features?.includes(f));
|
|
193
|
+
if (missing.length) return `${exe} lacks ${missing.join(", ")} — rebuild or replace the cached workload`;
|
|
179
194
|
return mismatch;
|
|
180
195
|
}
|
|
181
196
|
|
|
@@ -219,6 +234,7 @@ export interface ResolveOptions {
|
|
|
219
234
|
allowMismatch?: boolean | undefined;
|
|
220
235
|
platform?: Platform | undefined;
|
|
221
236
|
log?: (line: string) => void;
|
|
237
|
+
onBytes?: ((done: number, total: number) => void) | undefined;
|
|
222
238
|
}
|
|
223
239
|
|
|
224
240
|
export function resolveHost(options: ResolveOptions): ResolvedHost {
|
|
@@ -229,11 +245,11 @@ export function resolveHost(options: ResolveOptions): ResolvedHost {
|
|
|
229
245
|
const explicit = options.host ?? process.env.SK_HOST;
|
|
230
246
|
if (explicit) {
|
|
231
247
|
const exe = resolve(explicit);
|
|
232
|
-
const source = options.host ? "--
|
|
248
|
+
const source = options.host ? "--workload" : "SK_HOST";
|
|
233
249
|
if (cross) {
|
|
234
250
|
if (!existsSync(exe)) throw new HostError(`${exe} does not exist`);
|
|
235
251
|
if (isStamped(exe))
|
|
236
|
-
throw new HostError(`${exe} is a packaged app, not a bare
|
|
252
|
+
throw new HostError(`${exe} is a packaged app, not a bare workload (it already carries an app payload)`);
|
|
237
253
|
const { info, unverified } = crossHostInfo(exe, options.variant, platform);
|
|
238
254
|
const problem = checkHost(exe, info, options.variant, allow);
|
|
239
255
|
if (problem) throw new HostError(problem);
|
|
@@ -248,8 +264,8 @@ export function resolveHost(options: ResolveOptions): ResolvedHost {
|
|
|
248
264
|
}
|
|
249
265
|
if (cross) {
|
|
250
266
|
throw new HostError(
|
|
251
|
-
`a ${platform} build on ${process.platform} needs the
|
|
252
|
-
`(or SK_HOST). This machine's checkout and cache hold ${currentPlatform()}
|
|
267
|
+
`a ${platform} build on ${process.platform} needs the workload named: --workload <path to a ${platform} sk-app> ` +
|
|
268
|
+
`(or SK_HOST). This machine's checkout and cache hold ${currentPlatform()} workloads.`,
|
|
253
269
|
);
|
|
254
270
|
}
|
|
255
271
|
|
|
@@ -262,7 +278,7 @@ export function resolveHost(options: ResolveOptions): ResolvedHost {
|
|
|
262
278
|
if (statSync(REPO_RELEASE_EXE).mtimeMs < newestHostSource()) {
|
|
263
279
|
log(
|
|
264
280
|
`warning: ${REPO_RELEASE_EXE} is older than the sources it is built from — ` +
|
|
265
|
-
"`bun packages/cli/cli/sk.ts
|
|
281
|
+
"`bun packages/cli/cli/sk.ts workload build` rebuilds it",
|
|
266
282
|
);
|
|
267
283
|
}
|
|
268
284
|
return { exe: REPO_RELEASE_EXE, info, source: "repo" };
|
|
@@ -285,18 +301,20 @@ export function resolveHost(options: ResolveOptions): ResolvedHost {
|
|
|
285
301
|
tried.push(`cache: ${cached} does not exist`);
|
|
286
302
|
}
|
|
287
303
|
|
|
304
|
+
const remedies: [string, string][] = [
|
|
305
|
+
[`--workload <${hostsFor(platform).exeFile}>`, "(or SK_HOST=<exe>) a prod workload built from this version"],
|
|
306
|
+
[`sk workload install ${options.variant}`, `download it from the Skathi ${CLI_VERSION} release`],
|
|
307
|
+
["sk workload add <exe>", "import one into the local cache"],
|
|
308
|
+
...(REPO_ROOT
|
|
309
|
+
? [[`sk workload build ${options.variant}`, "build it from this checkout (cargo)"] as [string, string]]
|
|
310
|
+
: []),
|
|
311
|
+
];
|
|
312
|
+
const width = Math.max(...remedies.map(([how]) => how.length));
|
|
288
313
|
throw new HostError(
|
|
289
|
-
`no ${options.variant} Skathi ${CLI_VERSION}
|
|
314
|
+
`no ${options.variant} Skathi ${CLI_VERSION} workload found.\n` +
|
|
290
315
|
tried.map((t) => ` - ${t}`).join("\n") +
|
|
291
316
|
"\nSupply one of:\n" +
|
|
292
|
-
` ${
|
|
293
|
-
` sk host fetch download it from the Skathi ${CLI_VERSION} release\n` +
|
|
294
|
-
" sk host add <exe> import one into the local cache\n" +
|
|
295
|
-
(REPO_ROOT
|
|
296
|
-
? options.variant === "standard" || options.variant === "no-devtools"
|
|
297
|
-
? " sk host build build both variants from this checkout (cargo)\n"
|
|
298
|
-
: ` sk host build --variant ${options.variant} build this one from this checkout (cargo)\n`
|
|
299
|
-
: ""),
|
|
317
|
+
remedies.map(([how, what]) => ` ${how.padEnd(width)} ${what}\n`).join(""),
|
|
300
318
|
);
|
|
301
319
|
}
|
|
302
320
|
|
|
@@ -314,7 +332,7 @@ export function addHost(exe: string, log: (line: string) => void = () => {}): {
|
|
|
314
332
|
rmSync(dest, { force: true });
|
|
315
333
|
renameSync(tmp, dest);
|
|
316
334
|
writeFileSync(join(dirname(dest), "host.json"), JSON.stringify(info, null, 2) + "\n");
|
|
317
|
-
log(`cached ${info.variant}
|
|
335
|
+
log(`cached ${info.variant} workload ${info.skathi} (${info.profile}) → ${dest}`);
|
|
318
336
|
return { path: dest, info };
|
|
319
337
|
}
|
|
320
338
|
|
|
@@ -324,7 +342,7 @@ function cargo(): string {
|
|
|
324
342
|
const home = process.env.CARGO_HOME ?? join(process.env.USERPROFILE ?? homedir(), ".cargo");
|
|
325
343
|
const exe = join(home, "bin", process.platform === "win32" ? "cargo.exe" : "cargo");
|
|
326
344
|
if (existsSync(exe)) return exe;
|
|
327
|
-
throw new HostError("cargo is not on PATH — building a
|
|
345
|
+
throw new HostError("cargo is not on PATH — building a workload needs the Rust toolchain (sk build does not)");
|
|
328
346
|
}
|
|
329
347
|
|
|
330
348
|
/** The cargo command line for `variant`, plus `extra` features (`native-inspector` for a release host). */
|
|
@@ -350,7 +368,9 @@ export function cargoBuildHost(
|
|
|
350
368
|
extras: CargoExtras = {},
|
|
351
369
|
): { exe: string; ms: number } {
|
|
352
370
|
if (!REPO_ROOT || !REPO_RELEASE_EXE) {
|
|
353
|
-
throw new HostError(
|
|
371
|
+
throw new HostError(
|
|
372
|
+
"sk workload build runs from a Skathi checkout; elsewhere, use sk workload install or sk workload add <exe>",
|
|
373
|
+
);
|
|
354
374
|
}
|
|
355
375
|
const args = hostCargoArgs(variant, extras.features);
|
|
356
376
|
log(`cargo ${args.join(" ")}`);
|