@native-sdk/cli 0.9.2 → 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 +141 -9
- 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 +10 -0
- package/packages/core/sdk/events.ts +30 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +61 -3
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +5 -2
- package/skill-data/ts-core/SKILL.md +10 -4
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/src/app_runner/root.zig +208 -6
- package/src/app_runner/ts_core_main.zig +14 -4
- package/src/app_runner/ts_core_mobile.zig +6 -2
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/platform/macos/appkit_host.m +79 -12
- package/src/platform/macos/root.zig +68 -5
- package/src/primitives/canvas/events.zig +79 -1
- package/src/primitives/canvas/root.zig +1 -0
- package/src/primitives/canvas/text_interaction.zig +23 -0
- package/src/primitives/canvas/text_tests.zig +45 -0
- package/src/primitives/canvas/ui.zig +11 -8
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +3 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- package/src/primitives/canvas/ui_markup_view_tests.zig +18 -2
- package/src/primitives/canvas/ui_tests.zig +37 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +13 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/canvas_widget_control_tests.zig +2 -0
- package/src/runtime/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/ts_ui_app.zig +184 -7
- package/src/runtime/ui_app.zig +98 -18
- package/src/runtime/ui_app_tests.zig +232 -13
- package/src/runtime/ui_app_window_tests.zig +23 -0
- package/src/runtime/view_widget_text.zig +1 -1
- package/src/tooling/templates.zig +6 -2
- package/src/tooling/ts_core.zig +1 -1
- package/src/tooling/verbs.zig +228 -0
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/emit_profile.zig +20 -7
- package/tools/corewire/emit_service.zig +49 -24
- package/tools/corewire/main.zig +21 -2
- package/tools/corewire/shim_rt.zig +20 -0
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,
|
|
@@ -209,6 +216,24 @@ pub fn build(b: *std.Build) void {
|
|
|
209
216
|
const app_runner_window_placement_mod = module(b, target, optimize, "src/app_runner/window_placement.zig");
|
|
210
217
|
app_runner_window_placement_mod.addImport("native_sdk", desktop_mod);
|
|
211
218
|
const app_runner_window_placement_tests = testArtifact(b, app_runner_window_placement_mod);
|
|
219
|
+
const app_runner_options = b.addOptions();
|
|
220
|
+
app_runner_options.addOption([]const u8, "platform", "null");
|
|
221
|
+
app_runner_options.addOption([]const u8, "trace", "off");
|
|
222
|
+
app_runner_options.addOption([]const u8, "web_engine", "system");
|
|
223
|
+
app_runner_options.addOption(bool, "debug_overlay", false);
|
|
224
|
+
app_runner_options.addOption(bool, "automation", false);
|
|
225
|
+
app_runner_options.addOption(bool, "web_layer", false);
|
|
226
|
+
const app_runner_mod = module(b, target, optimize, "src/app_runner/root.zig");
|
|
227
|
+
app_runner_mod.addImport("native_sdk", desktop_mod);
|
|
228
|
+
app_runner_mod.addImport("build_options", app_runner_options.createModule());
|
|
229
|
+
app_runner_mod.addImport("app_manifest_zon", b.createModule(.{ .root_source_file = b.path("tests/app-runner/menu_commands_fixture.zon") }));
|
|
230
|
+
const app_runner_migrations_mod = module(b, target, optimize, "src/app_runner/no_migrations.zig");
|
|
231
|
+
app_runner_migrations_mod.addImport("native_sdk", desktop_mod);
|
|
232
|
+
app_runner_mod.addImport("relational_migrations", app_runner_migrations_mod);
|
|
233
|
+
const app_runner_tests = testArtifact(b, app_runner_mod);
|
|
234
|
+
const app_runner_test_run = b.addRunArtifact(app_runner_tests);
|
|
235
|
+
const app_runner_test_step = b.step("test-app-runner", "Run framework app-runner manifest fallback tests");
|
|
236
|
+
app_runner_test_step.dependOn(&app_runner_test_run.step);
|
|
212
237
|
desktop_mod.link_libc = true;
|
|
213
238
|
if (target.result.os.tag == .macos) {
|
|
214
239
|
const flags: []const []const u8 = if (b.sysroot) |sysroot|
|
|
@@ -607,6 +632,7 @@ pub fn build(b: *std.Build) void {
|
|
|
607
632
|
test_step.dependOn(&b.addRunArtifact(json_tests).step);
|
|
608
633
|
test_step.dependOn(&b.addRunArtifact(app_runner_assets_tests).step);
|
|
609
634
|
test_step.dependOn(&b.addRunArtifact(app_runner_window_placement_tests).step);
|
|
635
|
+
test_step.dependOn(&app_runner_test_run.step);
|
|
610
636
|
test_step.dependOn(&b.addRunArtifact(canvas_tests).step);
|
|
611
637
|
test_step.dependOn(&b.addRunArtifact(record_store_tests).step);
|
|
612
638
|
test_step.dependOn(&file_crash_run.step);
|
|
@@ -813,6 +839,40 @@ pub fn build(b: *std.Build) void {
|
|
|
813
839
|
.{ .path = "build.zig", .pattern = "if (spec.emit_services) check.addFileInput(b.path(\"packages/core/package.json\"));" },
|
|
814
840
|
.{ .path = "build/app.zig", .pattern = "if (has_services) check.addFileInput(dep.path(\"packages/core/package.json\"));" },
|
|
815
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
|
+
});
|
|
816
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", &.{
|
|
817
877
|
.{ .path = "build/app.zig", .pattern = ".linux => !cross or target.result.cpu.arch == .x86_64 or target.result.cpu.arch == .aarch64" },
|
|
818
878
|
.{ .path = "build/app.zig", .pattern = ".windows => !cross or target.result.abi == .gnu" },
|
|
@@ -2158,6 +2218,52 @@ pub fn build(b: *std.Build) void {
|
|
|
2158
2218
|
native_shell_smoke_run.step.dependOn(&cli_exe.step);
|
|
2159
2219
|
native_shell_smoke_step.dependOn(&native_shell_smoke_run.step);
|
|
2160
2220
|
|
|
2221
|
+
const menu_bar_smoke_step = b.step("test-menu-bar-smoke", "Run zero-config TypeScript app-menu automation smoke test");
|
|
2222
|
+
const menu_bar_smoke_build = managedExampleRun(b, cli_exe, &.{ "build", "-Dplatform=macos", "-Dweb-engine=system", "-Dautomation=true", "-Doptimize=Debug" });
|
|
2223
|
+
menu_bar_smoke_build.setCwd(b.path("examples/menu-bar"));
|
|
2224
|
+
const menu_bar_smoke_run = b.addSystemCommand(&.{
|
|
2225
|
+
"sh", "-c",
|
|
2226
|
+
\\set -eu
|
|
2227
|
+
\\cd examples/menu-bar
|
|
2228
|
+
\\app="zig-out/bin/menu-bar"
|
|
2229
|
+
\\cli="$1"
|
|
2230
|
+
\\case "$cli" in /*) ;; *) cli="../../$cli" ;; esac
|
|
2231
|
+
\\automation_dir=".zig-cache/native-sdk-automation"
|
|
2232
|
+
\\mkdir -p "$automation_dir"
|
|
2233
|
+
\\rm -f "$automation_dir/snapshot.txt" "$automation_dir/accessibility.txt" "$automation_dir/windows.txt" "$automation_dir"/command*.txt
|
|
2234
|
+
\\"$app" > .zig-cache/native-sdk-menu-bar-smoke.log 2>&1 &
|
|
2235
|
+
\\pid=$!
|
|
2236
|
+
\\trap 'status=$?; kill "$pid" >/dev/null 2>&1 || true; wait "$pid" >/dev/null 2>&1 || true; if [ "$status" -ne 0 ]; then echo "---- app log (.zig-cache/native-sdk-menu-bar-smoke.log) ----" >&2; cat .zig-cache/native-sdk-menu-bar-smoke.log >&2 2>/dev/null || true; fi' EXIT
|
|
2237
|
+
\\ready="$("$cli" automate wait 2>&1)"
|
|
2238
|
+
\\case "$ready" in *"ready=true"*) ;; *) echo "menu-bar automation snapshot was not ready" >&2; exit 1 ;; esac
|
|
2239
|
+
\\before="$(cat "$automation_dir/snapshot.txt" 2>/dev/null || true)"
|
|
2240
|
+
\\case "$before" in *'command id="player.next" title="Next Track" enabled=true checked=false'*) ;; *) echo "app.zon command catalog was not loaded by the zero-config runner" >&2; exit 1 ;; esac
|
|
2241
|
+
\\case "$before" in *'app-menu title="Player" items=6'*) ;; *) echo "app.zon Player menu was not loaded by the zero-config runner" >&2; exit 1 ;; esac
|
|
2242
|
+
\\case "$before" in *'app-menu-item label="Next Track" command="player.next" enabled=true checked=false key="n" modifiers=(primary=true,command=false,control=false,option=false,shift=false)'*) ;; *) echo "app.zon player.next menu item was not loaded by the zero-config runner" >&2; exit 1 ;; esac
|
|
2243
|
+
\\case "$before" in
|
|
2244
|
+
\\ *'Ambient Coast'*) expected='Night Drive' ;;
|
|
2245
|
+
\\ *'Night Drive'*) expected='Paper Planes' ;;
|
|
2246
|
+
\\ *'Paper Planes'*) expected='Ambient Coast' ;;
|
|
2247
|
+
\\ *) echo "menu-bar snapshot did not expose the current TypeScript model track" >&2; exit 1 ;;
|
|
2248
|
+
\\esac
|
|
2249
|
+
\\"$cli" automate menu-command player.next >/dev/null 2>&1
|
|
2250
|
+
\\attempts=0
|
|
2251
|
+
\\while [ "$attempts" -lt 50 ]; do
|
|
2252
|
+
\\ snapshot="$(cat "$automation_dir/snapshot.txt" 2>/dev/null || true)"
|
|
2253
|
+
\\ case "$snapshot" in *"$expected"*) break ;; esac
|
|
2254
|
+
\\ attempts=$((attempts + 1))
|
|
2255
|
+
\\ sleep 0.1
|
|
2256
|
+
\\done
|
|
2257
|
+
\\case "$snapshot" in *"$expected"*) ;; *) echo "app.zon menu command did not reach the zero-config TypeScript commandMsg mapper" >&2; exit 1 ;; esac
|
|
2258
|
+
\\echo "menu-bar smoke ok"
|
|
2259
|
+
,
|
|
2260
|
+
"sh",
|
|
2261
|
+
});
|
|
2262
|
+
menu_bar_smoke_run.addFileArg(cli_exe.getEmittedBin());
|
|
2263
|
+
menu_bar_smoke_run.step.dependOn(&menu_bar_smoke_build.step);
|
|
2264
|
+
menu_bar_smoke_run.step.dependOn(&cli_exe.step);
|
|
2265
|
+
menu_bar_smoke_step.dependOn(&menu_bar_smoke_run.step);
|
|
2266
|
+
|
|
2161
2267
|
const gpu_surface_smoke_step = b.step("test-gpu-surface-smoke", "Run macOS GPU surface automation smoke test");
|
|
2162
2268
|
// The GPU smoke apps are managed examples (no build.zig of their own),
|
|
2163
2269
|
// so their binaries come from the CLI verb. -Doptimize=Debug keeps the
|
|
@@ -2648,7 +2754,7 @@ pub fn build(b: *std.Build) void {
|
|
|
2648
2754
|
\\case "$ready_snapshot" in *'view @w1/components-canvas kind=gpu_surface'*'gpu_nonblank=true'*'canvas_frame_gpu_packet_representable=true'*) ;; *) echo "component gallery GPU surface was not ready" >&2; exit 1 ;; esac
|
|
2649
2755
|
\\case "$ready_snapshot" in *'view @w1/main kind=webview'*) echo "component gallery created an implicit WebView" >&2; exit 1 ;; *) ;; esac
|
|
2650
2756
|
\\"$cli" automate assert 'role=tree name="Components"' 'role=treeitem name="Components".*state=\[expanded\]' 'role=treeitem name="Accordion".*state=\[selected\]' 'role=group name="Details".*state=\[selected,expanded\]' 'name="Accordion details are visible. The model owns this expanded state."'
|
|
2651
|
-
\\"$cli" automate assert 'role=group name="Theme"' 'role=button name="Default".*state=\[selected\]' 'role=button name="Geist"'
|
|
2757
|
+
\\"$cli" automate assert 'role=group name="Theme pack"' 'role=group name="Color scheme"' 'role=group name="Theme accent"' 'role=button name="Default".*state=\[selected\]' 'role=button name="Geist"' 'role=button name="System".*state=\[selected\]' 'role=button name="Pink"' 'role=button name="Teal"'
|
|
2652
2758
|
\\"$cli" automate screenshot components-canvas >/dev/null 2>&1
|
|
2653
2759
|
\\cp "$automation_dir/screenshot-components-canvas.png" "$automation_dir/screenshot-components-house.png"
|
|
2654
2760
|
\\rm -f "$automation_dir/screenshot-components-canvas.png"
|
|
@@ -3170,7 +3276,7 @@ fn tsCoreE2eArtifact(
|
|
|
3170
3276
|
if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER") == null) {
|
|
3171
3277
|
b.build_root.handle.access(
|
|
3172
3278
|
b.graph.io,
|
|
3173
|
-
|
|
3279
|
+
repositoryScriptcBin(b),
|
|
3174
3280
|
.{},
|
|
3175
3281
|
) catch return null;
|
|
3176
3282
|
}
|
|
@@ -3515,6 +3621,9 @@ fn tsCoreE2eArtifact(
|
|
|
3515
3621
|
// against (the same module the generated shims stage).
|
|
3516
3622
|
conformance_mod.addImport("corewire_rt", module(b, target, optimize, "tools/corewire/shim_rt.zig"));
|
|
3517
3623
|
conformance_mod.addImport("shim_markup_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/markup_fixture.contract.json")));
|
|
3624
|
+
// Compile-cost guard: this generated mirror carries 160 realistically
|
|
3625
|
+
// named Msg arms and must need no quota setting in app or test code.
|
|
3626
|
+
conformance_mod.addImport("shim_wide_core", sidecarShimModule(b, target, optimize, corewire_exe, b.path("tests/sidecar/wide_msg_fixture.contract.json")));
|
|
3518
3627
|
// The integer-class fixture: a hand-written sidecar attesting mixed
|
|
3519
3628
|
// i64/u64 slot classes, so the suite drives boundary and full-range
|
|
3520
3629
|
// integer values through a generated mirror's decode paths.
|
|
@@ -3691,6 +3800,7 @@ fn externalServiceFixture(
|
|
|
3691
3800
|
|
|
3692
3801
|
const compile = b.addSystemCommand(&.{node});
|
|
3693
3802
|
compile.addFileArg(b.path("packages/core/scripts/run_external_service_compiler.mjs"));
|
|
3803
|
+
compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
|
|
3694
3804
|
compile.addArg("--stage");
|
|
3695
3805
|
compile.addDirectoryArg(stage_dir);
|
|
3696
3806
|
compile.addArg("--manifest");
|
|
@@ -3719,8 +3829,7 @@ fn externalServiceFixture(
|
|
|
3719
3829
|
if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
|
|
3720
3830
|
compile.addArgs(&.{ "--compiler", override });
|
|
3721
3831
|
} else {
|
|
3722
|
-
compile.
|
|
3723
|
-
compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
|
|
3832
|
+
compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
|
|
3724
3833
|
}
|
|
3725
3834
|
|
|
3726
3835
|
return .{
|
|
@@ -3867,12 +3976,14 @@ fn externalCoreFixtureModule(
|
|
|
3867
3976
|
check.addFileArg(b.path("packages/core/src/cli.ts"));
|
|
3868
3977
|
check.addFileArg(b.path(spec.entry));
|
|
3869
3978
|
check.addArg("--contract");
|
|
3870
|
-
const
|
|
3979
|
+
const contract_raw = check.addOutputFileArg("core.contract.json");
|
|
3980
|
+
const contract = app_build.stabilizeGeneratedFile(b, contract_raw, "core.contract.json", false);
|
|
3871
3981
|
check.addArg("--contract-entry");
|
|
3872
3982
|
check.addArg(spec.entry);
|
|
3873
3983
|
const services_contract: ?std.Build.LazyPath = if (spec.emit_services) services: {
|
|
3874
3984
|
check.addArg("--services-contract");
|
|
3875
|
-
|
|
3985
|
+
const raw = check.addOutputFileArg("services.contract.json");
|
|
3986
|
+
break :services app_build.stabilizeGeneratedFile(b, raw, "services.contract.json", false);
|
|
3876
3987
|
} else null;
|
|
3877
3988
|
for (spec.service_packages) |package_entry| check.addArgs(&.{ "--service-package", package_entry });
|
|
3878
3989
|
const services_client: ?std.Build.LazyPath = if (services_contract) |service_contract| client: {
|
|
@@ -3880,7 +3991,8 @@ fn externalCoreFixtureModule(
|
|
|
3880
3991
|
service_project.addArg("--services-sidecar");
|
|
3881
3992
|
service_project.addFileArg(service_contract);
|
|
3882
3993
|
service_project.addArg("--service-client");
|
|
3883
|
-
|
|
3994
|
+
const client_raw = service_project.addOutputFileArg("services.gen.ts");
|
|
3995
|
+
break :client app_build.stabilizeGeneratedFile(b, client_raw, "services.gen.ts", false);
|
|
3884
3996
|
} else null;
|
|
3885
3997
|
if (spec.persist_capability) check.addArgs(&.{ "--capability", "persist" });
|
|
3886
3998
|
if (spec.store_capability) check.addArgs(&.{ "--capability", "store" });
|
|
@@ -3933,6 +4045,8 @@ fn externalCoreFixtureModule(
|
|
|
3933
4045
|
stage_run.addArg("--services-client");
|
|
3934
4046
|
stage_run.addFileArg(client);
|
|
3935
4047
|
}
|
|
4048
|
+
tsCoreAddCoreDirInputs(b, stage_run, std.fs.path.dirname(spec.entry) orelse ".");
|
|
4049
|
+
app_build.addStagedCoreSdkInputs(b, b, stage_run);
|
|
3936
4050
|
stage_run.addArg("--out");
|
|
3937
4051
|
const stage_dir = stage_run.addOutputDirectoryArg("stage");
|
|
3938
4052
|
|
|
@@ -3940,6 +4054,7 @@ fn externalCoreFixtureModule(
|
|
|
3940
4054
|
// pin, archive normalized, the co-emitted sidecar captured.
|
|
3941
4055
|
const compile = b.addSystemCommand(&.{node});
|
|
3942
4056
|
compile.addFileArg(b.path("packages/core/scripts/run_external_core_compiler.mjs"));
|
|
4057
|
+
compile.addFileInput(b.path("packages/core/scripts/compiler_command.mjs"));
|
|
3943
4058
|
compile.addArg("--stage");
|
|
3944
4059
|
compile.addDirectoryArg(stage_dir);
|
|
3945
4060
|
compile.addArgs(&.{ "--name", spec.name });
|
|
@@ -3966,8 +4081,7 @@ fn externalCoreFixtureModule(
|
|
|
3966
4081
|
// driver still refuses a release other than the SDK's pin.
|
|
3967
4082
|
compile.addArgs(&.{ "--compiler", override });
|
|
3968
4083
|
} else {
|
|
3969
|
-
compile.
|
|
3970
|
-
compile.addFileArg(b.path("packages/core/node_modules/scriptc/dist/main.js"));
|
|
4084
|
+
compile.addArgs(&.{ "--compiler", repositoryScriptcBin(b) });
|
|
3971
4085
|
}
|
|
3972
4086
|
|
|
3973
4087
|
// The mirror, generated from the archive's OWN co-emitted contract,
|
|
@@ -4015,6 +4129,24 @@ fn tsCoreAddDirInputs(b: *std.Build, transpile: *std.Build.Step.Run, dir_path: [
|
|
|
4015
4129
|
}
|
|
4016
4130
|
}
|
|
4017
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
|
+
|
|
4018
4150
|
fn filteredTestArtifact(b: *std.Build, mod: *std.Build.Module, name: []const u8, filters: []const []const u8) *std.Build.Step.Compile {
|
|
4019
4151
|
// use_llvm: Zig 0.16.0's self-hosted x86_64 backend miscompiles the
|
|
4020
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`);
|