@hewel/zgui-build 0.1.3 → 0.1.6

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.
@@ -6,7 +6,7 @@ prebuilt `zgui-host` binaries, and packaged desktop applications.
6
6
 
7
7
  ## 1. Upstream `zgui` (`zortax/zgui`)
8
8
 
9
- - **Source:** https://github.com/zortax/zgui (pinned revision `ee29c7dc66206eb04ba7bcf514058a278c9070ba`)
9
+ - **Source:** https://github.com/zortax/zgui (pinned revision `b985e19296b625f6f9ee1b66d6a5ff09d9de7ff6`)
10
10
  - **License:** Apache License, Version 2.0
11
11
  - **Scope:** Vendored native crates under `vendor/` (linked into `zgui-host`) and adapted UI
12
12
  stylesheet/theme/icon resources under `@hewel/zgui` (`packages/ui/upstream/{LICENSE,NOTICE,ORIGIN}`).
package/sdk/bun.lock CHANGED
@@ -161,7 +161,7 @@
161
161
  },
162
162
  "packages/build": {
163
163
  "name": "@hewel/zgui-build",
164
- "version": "0.1.3",
164
+ "version": "0.1.6",
165
165
  "dependencies": {
166
166
  "@solidjs/compiler": "2.0.1",
167
167
  "lightningcss": "1.33.0",
@@ -176,7 +176,7 @@
176
176
  },
177
177
  "packages/cli": {
178
178
  "name": "@hewel/zgui-cli",
179
- "version": "0.1.3",
179
+ "version": "0.1.6",
180
180
  "bin": {
181
181
  "zgui-js": "./src/cli.ts",
182
182
  },
@@ -192,7 +192,7 @@
192
192
  },
193
193
  "packages/create-zgui-js": {
194
194
  "name": "create-zgui-js",
195
- "version": "0.1.3",
195
+ "version": "0.1.6",
196
196
  "bin": {
197
197
  "create-zgui-js": "./src/cli.ts",
198
198
  },
@@ -205,22 +205,23 @@
205
205
  },
206
206
  "packages/host-linux-arm64": {
207
207
  "name": "@hewel/zgui-host-linux-arm64",
208
- "version": "0.1.3",
208
+ "version": "0.1.6",
209
209
  },
210
210
  "packages/host-linux-x64": {
211
211
  "name": "@hewel/zgui-host-linux-x64",
212
- "version": "0.1.3",
212
+ "version": "0.1.6",
213
213
  },
214
214
  "packages/services": {
215
215
  "name": "@hewel/zgui-services",
216
- "version": "0.1.3",
216
+ "version": "0.1.6",
217
217
  "dependencies": {
218
+ "@hewel/zgui": "workspace:*",
218
219
  "solid-js": "2.0.1",
219
220
  },
220
221
  },
221
222
  "packages/ui": {
222
223
  "name": "@hewel/zgui",
223
- "version": "0.1.3",
224
+ "version": "0.1.6",
224
225
  "dependencies": {
225
226
  "@solidjs/signals": "2.0.1",
226
227
  "@solidjs/universal": "2.0.1",
package/sdk/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zgui-js",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "scripts": {
23
23
  "prepare": "git config core.hooksPath .githooks 2>/dev/null || true; bun tools/build-packages.ts --quiet",
24
24
  "build:packages": "bun tools/build-packages.ts",
25
+ "build:downstream": "bun run build:packages && cargo build --release -j 4 -p zgui-host -p zgui-static-render --locked --offline",
25
26
  "release:check": "bun tools/release.ts check",
26
27
  "release:version": "bun tools/release.ts version",
27
28
  "release:pack": "bun tools/release.ts pack",
package/src/build.ts CHANGED
@@ -15,7 +15,12 @@ import path from "node:path";
15
15
  import { compileBundle, compileWorkerBundle, type CompilationResult } from "./compiler.ts";
16
16
  import { typecheckProject } from "./typecheck.ts";
17
17
  import { canonicalJson, sha256, moduleIdentity } from "./identity.ts";
18
- import { compileModuleBytecode, resolveNativeHost } from "./host.ts";
18
+ import {
19
+ compileModuleBytecode,
20
+ NativeHostUnavailableError,
21
+ preflightBundle,
22
+ resolveNativeHost,
23
+ } from "./host.ts";
19
24
  import { publishGeneration, resourcePath } from "./publication.ts";
20
25
  import { readManifestPolicy } from "./manifest-policy.ts";
21
26
  import { syncCssModuleTypes, validateStylesheet } from "./css.ts";
@@ -275,6 +280,7 @@ export async function buildApplication(
275
280
  appDirectory = path.join(root, "apps/examples", app),
276
281
  development = false,
277
282
  bytecode = false,
283
+ preflight,
278
284
  hostRoot,
279
285
  hostExecutable,
280
286
  hostSearchFrom,
@@ -285,7 +291,14 @@ export async function buildApplication(
285
291
  {
286
292
  signal,
287
293
  nativeHost,
288
- }: { signal?: AbortSignal | undefined; nativeHost?: ResolvedNativeHost | undefined } = {},
294
+ resolveHost,
295
+ onPreflightPassed,
296
+ }: {
297
+ signal?: AbortSignal | undefined;
298
+ nativeHost?: ResolvedNativeHost | undefined;
299
+ resolveHost?: ((allowCargoBuild: boolean) => Promise<ResolvedNativeHost>) | undefined;
300
+ onPreflightPassed?: ((packageDirectory: string) => void) | undefined;
301
+ } = {},
289
302
  ): Promise<PublishedApplication> {
290
303
  signal?.throwIfAborted();
291
304
  if (!/^[a-z][a-z0-9-]*$/.test(app)) throw new Error(`Invalid application name: ${app}`);
@@ -307,10 +320,13 @@ export async function buildApplication(
307
320
  appDirectory,
308
321
  development,
309
322
  bytecode,
323
+ preflight,
310
324
  hostRoot,
311
325
  hostExecutable,
312
326
  hostSearchFrom,
313
327
  nativeHost,
328
+ resolveHost,
329
+ onPreflightPassed,
314
330
  signal,
315
331
  extraCapabilities,
316
332
  capabilitiesFile,
@@ -326,22 +342,32 @@ export async function buildWithResolvedHost(
326
342
  signal,
327
343
  }: Pick<ResolveNativeHostOptions, "hostRoot" | "hostExecutable" | "signal">,
328
344
  ) {
329
- let host: Promise<ResolvedNativeHost> | undefined;
330
- const resolveHost = () =>
331
- (host ??= resolveNativeHost({
345
+ let host: ResolvedNativeHost | undefined;
346
+ const resolveHost = async (allowCargoBuild = true) =>
347
+ (host ??= await resolveNativeHost({
332
348
  hostExecutable,
333
349
  hostRoot,
334
350
  root: options.root,
335
351
  cwd: options.appDirectory,
336
352
  searchFrom: options.hostSearchFrom,
353
+ allowCargoBuild,
337
354
  signal,
338
355
  }));
356
+ let preflightedDirectory: string | undefined;
339
357
  // Bytecode needs the compiler early; packaging validates the manifest before resolving a runtime-only host.
340
- const application = await buildApplication(app, options, {
341
- signal,
342
- nativeHost: options.bytecode ? await resolveHost() : undefined,
343
- });
344
- return { application, resolveHost };
358
+ const application = await buildApplication(
359
+ app,
360
+ { ...options, hostRoot, hostExecutable },
361
+ {
362
+ signal,
363
+ nativeHost: options.bytecode ? await resolveHost() : undefined,
364
+ resolveHost,
365
+ onPreflightPassed: packageDirectory => {
366
+ preflightedDirectory = packageDirectory;
367
+ },
368
+ },
369
+ );
370
+ return { application, resolveHost, preflightedDirectory };
345
371
  }
346
372
 
347
373
  export async function publishApplication(
@@ -353,10 +379,13 @@ export async function publishApplication(
353
379
  signal,
354
380
  development = false,
355
381
  bytecode = false,
382
+ preflight = false,
356
383
  hostRoot,
357
384
  hostExecutable,
358
385
  hostSearchFrom,
359
386
  nativeHost,
387
+ resolveHost: resolveProvidedHost,
388
+ onPreflightPassed,
360
389
  extraCapabilities,
361
390
  capabilitiesFile,
362
391
  }: BuildApplicationOptions & {
@@ -364,6 +393,8 @@ export async function publishApplication(
364
393
  appDirectory: string;
365
394
  signal?: AbortSignal | undefined;
366
395
  nativeHost?: ResolvedNativeHost | undefined;
396
+ resolveHost?: ((allowCargoBuild: boolean) => Promise<ResolvedNativeHost>) | undefined;
397
+ onPreflightPassed?: ((packageDirectory: string) => void) | undefined;
367
398
  },
368
399
  ): Promise<PublishedApplication> {
369
400
  signal?.throwIfAborted();
@@ -389,6 +420,7 @@ export async function publishApplication(
389
420
  const {
390
421
  id,
391
422
  window: windowConfig,
423
+ resourceProfile,
392
424
  capabilities,
393
425
  workerEntries,
394
426
  fonts,
@@ -407,32 +439,60 @@ export async function publishApplication(
407
439
  }
408
440
  workers.push({ name: compiled.name, path: compiled.path, sourceMap: compiled.sourceMap });
409
441
  }
442
+ const chunks = result.graph.chunks
443
+ .map(chunk => chunk.fileName)
444
+ .filter(fileName => fileName !== "app.mjs")
445
+ .sort()
446
+ .map(chunkPath => ({ path: chunkPath, sourceMap: `${chunkPath}.map` }));
447
+ const modulePaths = [
448
+ "app.mjs",
449
+ ...chunks.map(chunk => chunk.path),
450
+ ...workers.map(worker => worker.path),
451
+ ];
452
+ const profile = resourceProfile ?? "standard";
453
+ const warningMiB = profile === "extended" ? 6 : 2;
454
+ const limitMiB = profile === "extended" ? 16 : 6;
455
+ const mib = 1024 * 1024;
456
+ for (const modulePath of modulePaths) {
457
+ const module = files.get(modulePath);
458
+ if (!module) throw new Error(`Missing compiled JS module: ${modulePath}`);
459
+ const bytes = module.byteLength;
460
+ if (bytes > limitMiB * mib) {
461
+ const profileAdvice =
462
+ profile === "standard" ? ' or select "resourceProfile": "extended"' : "";
463
+ throw new Error(
464
+ `${modulePath} (${bytes} bytes) exceeds the ${profile} resource profile limit of ${limitMiB} MiB. QuickJS parse/AST memory can be several times the module source size. Split the code, move static data to assets/${profileAdvice}.`,
465
+ );
466
+ }
467
+ if (bytes > warningMiB * mib) {
468
+ const message = `${modulePath} (${bytes} bytes) exceeds the ${profile} resource profile warning threshold of ${warningMiB} MiB. QuickJS parse/AST memory can be several times the module source size.`;
469
+ console.warn(message);
470
+ }
471
+ }
410
472
  files.set(
411
473
  "build-info.json",
412
474
  Buffer.from(
413
475
  JSON.stringify(await buildInfo(root, result, { appDirectory, development }), null, 2) + "\n",
414
476
  ),
415
477
  );
416
- const chunks = result.graph.chunks
417
- .map(chunk => chunk.fileName)
418
- .filter(fileName => fileName !== "app.mjs")
419
- .sort()
420
- .map(chunkPath => ({ path: chunkPath, sourceMap: `${chunkPath}.map` }));
421
478
  let entryPath = "app.mjs";
422
479
  let bytecodeMeta: { bytecodeFormat: "qjs-bytecode-v1"; quickjsAbi: string } | undefined;
423
480
  let finalChunks = chunks;
424
481
  let finalWorkers = workers;
482
+ let resolvedHost = nativeHost;
483
+ const resolveHost = (allowCargoBuild: boolean) =>
484
+ resolveProvidedHost?.(allowCargoBuild) ??
485
+ resolveNativeHost({
486
+ hostExecutable,
487
+ hostRoot,
488
+ root,
489
+ cwd: appDirectory,
490
+ searchFrom: hostSearchFrom,
491
+ allowCargoBuild,
492
+ signal,
493
+ });
425
494
  if (bytecode) {
426
- const host =
427
- nativeHost ??
428
- (await resolveNativeHost({
429
- hostExecutable,
430
- hostRoot,
431
- root,
432
- cwd: appDirectory,
433
- searchFrom: hostSearchFrom,
434
- signal,
435
- }));
495
+ const host = (resolvedHost ??= await resolveHost(true));
436
496
  const bytecodeFormat = host.abi?.bytecodeFormat;
437
497
  const quickjsAbi = host.abi?.quickjsAbi;
438
498
  if (bytecodeFormat !== "qjs-bytecode-v1" || !quickjsAbi) {
@@ -450,11 +510,6 @@ export async function publishApplication(
450
510
  };
451
511
  const sourceDir = path.join(tempDir, "src");
452
512
  const outDir = path.join(tempDir, "out");
453
- const modulePaths = [
454
- "app.mjs",
455
- ...chunks.map(chunk => chunk.path),
456
- ...workers.map(worker => worker.path),
457
- ];
458
513
  for (const jsPath of modulePaths) {
459
514
  const jsBytes = files.get(jsPath);
460
515
  if (!jsBytes) throw new Error(`Missing compiled JS module for bytecode: ${jsPath}`);
@@ -511,6 +566,7 @@ export async function publishApplication(
511
566
  assets: [...assets.keys()].sort(),
512
567
  fonts,
513
568
  ...(windowConfig ? { window: windowConfig } : {}),
569
+ ...(resourceProfile ? { resourceProfile } : {}),
514
570
  ...(capabilities ? { capabilities } : {}),
515
571
  styleSystem: result.styleSystem,
516
572
  artifactDigests: Object.fromEntries(
@@ -523,6 +579,27 @@ export async function publishApplication(
523
579
  signal?.throwIfAborted();
524
580
  files.set("manifest.json", Buffer.from(JSON.stringify(manifest, null, 2) + "\n"));
525
581
  signal?.throwIfAborted();
526
- const dist = await publishGeneration(appDirectory, files);
582
+ const dist = await publishGeneration(
583
+ appDirectory,
584
+ files,
585
+ preflight === false
586
+ ? undefined
587
+ : {
588
+ async verify(packageDirectory) {
589
+ if (!resolvedHost) {
590
+ try {
591
+ resolvedHost = await resolveHost(preflight === true);
592
+ } catch (error) {
593
+ if (preflight === true || !(error instanceof NativeHostUnavailableError))
594
+ throw error;
595
+ }
596
+ }
597
+ if (resolvedHost && (preflight === true || resolvedHost.abi?.preflight === true)) {
598
+ await preflightBundle(resolvedHost, packageDirectory, { signal });
599
+ onPreflightPassed?.(packageDirectory);
600
+ }
601
+ },
602
+ },
603
+ );
527
604
  return { dist, manifest };
528
605
  }
package/src/compiler.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { realpathSync } from "node:fs";
3
- import { realpath } from "node:fs/promises";
3
+ import { realpath, stat } from "node:fs/promises";
4
4
  import {
5
5
  transform as solidTransform,
6
6
  type TransformOptions as SolidTransformOptions,
@@ -82,6 +82,25 @@ const GENERATED_STYLE_FILE =
82
82
 
83
83
  const JSX_SOURCE_FILE = /\.[cm]?[jt]sx$/i;
84
84
 
85
+ const MAX_JSON_BYTES = 128 * 1024;
86
+ const jsonBudgetPlugin: Plugin = {
87
+ name: "zgui-json-size-budget",
88
+ load: {
89
+ filter: { id: /\.json$/i },
90
+ async handler(id) {
91
+ if (!path.isAbsolute(id)) return null;
92
+ const { size } = await stat(id);
93
+ if (size > MAX_JSON_BYTES) {
94
+ this.addWatchFile(id);
95
+ throw new Error(
96
+ `JSON module ${id} is ${size} bytes and exceeds 128 KiB. Move large JSON data to assets/ and read or stream it via @hewel/zgui-services.`,
97
+ );
98
+ }
99
+ return null;
100
+ },
101
+ },
102
+ };
103
+
85
104
  function computeLineStarts(source: string): number[] {
86
105
  const starts = [0];
87
106
  for (let i = 0; i < source.length; i++) {
@@ -277,6 +296,7 @@ function compilerOptions(
277
296
  warn(warning);
278
297
  },
279
298
  plugins: [
299
+ jsonBudgetPlugin,
280
300
  {
281
301
  name: "lightningcss-solid-universal-typescript",
282
302
  resolveId(source) {
@@ -575,6 +595,7 @@ export async function compileWorkerBundle(
575
595
  warn(warning);
576
596
  },
577
597
  plugins: [
598
+ jsonBudgetPlugin,
578
599
  {
579
600
  name: "zgui-compute-worker",
580
601
  resolveId(source) {
package/src/dev.ts CHANGED
@@ -30,10 +30,13 @@ export async function devApplication(
30
30
  root = workspaceRoot,
31
31
  appDirectory = path.join(root, "apps/examples", app),
32
32
  hostArgs = [],
33
+ hostCwd,
33
34
  hostRoot,
34
35
  hostExecutable,
35
36
  hostSearchFrom,
37
+ preflight,
36
38
  strictTypecheck = false,
39
+ headless = false,
37
40
  mode = "desktop",
38
41
  extraCapabilities,
39
42
  capabilitiesFile,
@@ -86,11 +89,17 @@ export async function devApplication(
86
89
  if (controller.signal.aborted) return exitCode ?? 143;
87
90
  if (mode !== "desktop" && mode !== "preview")
88
91
  throw new Error(`Unknown development mode: ${String(mode)}`);
92
+ if (headless && mode !== "desktop")
93
+ throw new Error("--headless cannot be combined with preview development mode");
89
94
  watcher = watch(app, {
90
95
  root,
91
96
  appDirectory,
92
97
  development: mode === "desktop",
93
98
  strictTypecheck,
99
+ preflight,
100
+ hostRoot,
101
+ hostExecutable,
102
+ hostSearchFrom,
94
103
  extraCapabilities,
95
104
  capabilitiesFile,
96
105
  cssModuleInclude,
@@ -133,11 +142,13 @@ export async function devApplication(
133
142
  const dist = await Promise.race([published.promise, stopped.promise]);
134
143
  if (controller.signal.aborted) return;
135
144
  // Launch from this single startup path, never from a rebuild callback.
145
+ const extraHostArgs =
146
+ headless && !hostArgs.includes("--headless") ? ["--headless", ...hostArgs] : hostArgs;
136
147
  const args =
137
148
  mode === "preview"
138
- ? ["preview", "watch", "--bundle", dist!, ...hostArgs]
139
- : ["--bundle", dist!, "--watch", ...hostArgs];
140
- stop(await run(executable, args, { root: runRoot, signal: controller.signal }));
149
+ ? ["preview", "watch", "--bundle", dist!, ...extraHostArgs]
150
+ : ["--bundle", dist!, "--watch", ...extraHostArgs];
151
+ stop(await run(executable, args, { root: hostCwd ?? runRoot, signal: controller.signal }));
141
152
  } catch (error) {
142
153
  fail(error);
143
154
  }
package/src/host.ts CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  realpathSync,
16
16
  statSync,
17
17
  } from "node:fs";
18
- import { chmod, copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
18
+ import { chmod, copyFile, lstat, mkdir, readFile, stat, writeFile } from "node:fs/promises";
19
19
  import { createRequire } from "node:module";
20
20
  import { constants } from "node:os";
21
21
  import path from "node:path";
@@ -47,6 +47,10 @@ function hostFailure(message: string, exitCode = 1): Error & { exitCode: number
47
47
  return Object.assign(new Error(message), { exitCode });
48
48
  }
49
49
 
50
+ export class NativeHostUnavailableError extends Error {
51
+ readonly exitCode = 1;
52
+ }
53
+
50
54
  interface ProcessOptions {
51
55
  spawnProcess?: (
52
56
  executable: string,
@@ -225,6 +229,33 @@ export async function runNativeHost(
225
229
  return ownedProcess(executable, args, { root: path.resolve(root), signal }, processOptions);
226
230
  }
227
231
 
232
+ export async function preflightBundle(
233
+ host: ResolvedNativeHost,
234
+ bundleDir: string,
235
+ { signal }: { signal?: AbortSignal | undefined } = {},
236
+ ): Promise<void> {
237
+ signal?.throwIfAborted();
238
+ if (host.abi?.preflight !== true) {
239
+ throw new Error(
240
+ `Resolved zgui-host (${host.executable}) does not advertise "preflight": true; install or build a host with preflight support.`,
241
+ );
242
+ }
243
+ const capture = { stdout: [] as string[], stderr: [] as string[] };
244
+ const code = await ownedProcess(host.executable, ["preflight", "--bundle", bundleDir], {
245
+ root: host.runRoot,
246
+ signal,
247
+ capture,
248
+ });
249
+ signal?.throwIfAborted();
250
+ if (code !== 0) {
251
+ const detail = capture.stderr.join("").trim() || capture.stdout.join("").trim();
252
+ throw hostFailure(
253
+ `zgui-host preflight failed for ${bundleDir} (exit ${code})${detail ? `: ${detail}` : ""}`,
254
+ code,
255
+ );
256
+ }
257
+ }
258
+
228
259
  export function platformId(
229
260
  platform: string = process.platform,
230
261
  arch: string = process.arch,
@@ -286,6 +317,7 @@ function parseVersionText(text: string): NativeHostAbi | null {
286
317
  : {}),
287
318
  ...(typeof parsed.quickjsAbi === "string" ? { quickjsAbi: parsed.quickjsAbi } : {}),
288
319
  ...(typeof parsed.styleProfile === "string" ? { styleProfile: parsed.styleProfile } : {}),
320
+ preflight: typeof parsed.preflight === "boolean" ? parsed.preflight : undefined,
289
321
  };
290
322
  } catch {
291
323
  return null;
@@ -486,7 +518,7 @@ async function resolveCargoExecutable(
486
518
  `Explicit --host-root is not a zgui-js Cargo checkout (missing crates/zgui-host/Cargo.toml): ${cargoRoot}`,
487
519
  );
488
520
  }
489
- throw hostFailure(
521
+ throw new NativeHostUnavailableError(
490
522
  `Local Cargo checkout detected at ${cargoRoot}, but zgui-host has not been built yet. Run \`cargo build -p zgui-host\` or invoke \`zgui-js dev\`.`,
491
523
  );
492
524
  }
@@ -580,7 +612,7 @@ export async function resolveNativeHost({
580
612
  const installHint = packageName
581
613
  ? `Install the prebuilt host package (${packageName})`
582
614
  : `No prebuilt host package is published for ${currentPlatform}`;
583
- throw hostFailure(
615
+ throw new NativeHostUnavailableError(
584
616
  `Cannot locate a zgui-js zgui-host binary for ${currentPlatform}.\n` +
585
617
  ` 1. ${installHint} (included in @hewel/zgui-cli optionalDependencies on supported platforms), or\n` +
586
618
  ` 2. Pass --host-executable <PATH> or set ZGUI_JS_HOST_EXECUTABLE=<PATH>, or\n` +
@@ -616,6 +648,13 @@ export async function stageHostPackage({
616
648
  if (!existsSync(sourceBinary)) {
617
649
  throw hostFailure(`Source zgui-host binary not found: ${sourceBinary}`);
618
650
  }
651
+ const staticRenderSource =
652
+ platform === "linux-x64"
653
+ ? path.join(path.dirname(sourceBinary), "zgui-static-render")
654
+ : undefined;
655
+ if (staticRenderSource && !statSync(staticRenderSource, { throwIfNoEntry: false })?.isFile()) {
656
+ throw hostFailure(`Source zgui-static-render binary not found: ${staticRenderSource}`);
657
+ }
619
658
  const targetDir = path.resolve(
620
659
  packageDir ?? path.join(workspaceRoot, `packages/host-${platform}`),
621
660
  );
@@ -653,6 +692,11 @@ export async function stageHostPackage({
653
692
  await mkdir(binDir, { recursive: true });
654
693
  await copyFile(sourceBinary, destBinary);
655
694
  await chmod(destBinary, 0o755);
695
+ if (staticRenderSource) {
696
+ const destination = path.join(binDir, "zgui-static-render");
697
+ await copyFile(staticRenderSource, destination);
698
+ await chmod(destination, 0o755);
699
+ }
656
700
 
657
701
  const info = await stat(destBinary);
658
702
  const manifest: StagedHostManifest = {
@@ -692,6 +736,13 @@ export async function verifyHostPackage(
692
736
  const expectedPlatform = Object.entries(SUPPORTED_HOST_PACKAGES).find(
693
737
  ([, name]) => name === pkgJson.name,
694
738
  )?.[0];
739
+ if (expectedPlatform === "linux-x64") {
740
+ const renderer = path.join(dir, "bin", "zgui-static-render");
741
+ const info = await lstat(renderer).catch(() => undefined);
742
+ if (!info?.isFile() || (info.mode & 0o111) === 0) {
743
+ throw hostFailure(`Missing or non-executable staged binary: ${renderer}`);
744
+ }
745
+ }
695
746
  validateStagedManifest({
696
747
  manifest,
697
748
  binaryPath,
package/src/identity.ts CHANGED
@@ -6,15 +6,17 @@ export type JsonValue =
6
6
  | boolean
7
7
  | number
8
8
  | string
9
- | JsonValue[]
9
+ | readonly JsonValue[]
10
10
  | { [key: string]: JsonValue };
11
11
 
12
+ const isJsonArray: (value: JsonValue) => value is readonly JsonValue[] = Array.isArray;
13
+
12
14
  export function sha256(bytes: string | Uint8Array): string {
13
15
  return `sha256:${new Bun.CryptoHasher("sha256").update(bytes).digest("hex")}`;
14
16
  }
15
17
 
16
18
  export function canonicalJson(value: JsonValue): string {
17
- if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
19
+ if (isJsonArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
18
20
  if (value !== null && typeof value === "object") {
19
21
  return `{${Object.keys(value)
20
22
  .sort()
package/src/internal.ts CHANGED
@@ -5,6 +5,7 @@ export {
5
5
  buildSdkPackages,
6
6
  ensureSdkPackagesBuilt,
7
7
  hasCheckoutSdkSources,
8
+ listOxlintOutputFiles,
8
9
  type SdkPackageName,
9
10
  } from "./sdk-packages.ts";
10
11
  export { extractStaticComponentSheet, type StaticComponentSheet } from "./compiler.ts";