@native-sdk/cli 0.4.4 → 0.5.0
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 +187 -6
- package/build/ts_run.mjs +63 -0
- package/build.zig +213 -1
- package/build.zig.zon +1 -0
- package/package.json +15 -10
- package/packages/core/package-lock.json +43 -0
- package/packages/core/package.json +37 -0
- package/packages/core/rt/rt.zig +1579 -0
- package/packages/core/sdk/bytes_text_methods.d.ts +88 -0
- package/packages/core/sdk/core.ts +694 -0
- package/packages/core/sdk/events.ts +137 -0
- package/packages/core/sdk/text.ts +519 -0
- package/packages/core/src/checker.ts +1869 -0
- package/packages/core/src/cli.ts +68 -0
- package/packages/core/src/devhost.ts +291 -0
- package/packages/core/src/devhost_resolver.mjs +22 -0
- package/packages/core/src/diagnostics.ts +417 -0
- package/packages/core/src/emitter.ts +8815 -0
- package/packages/core/src/infer.ts +1515 -0
- package/packages/core/src/modules.ts +173 -0
- package/packages/core/src/ownership.ts +740 -0
- package/packages/core/src/text_polyfill.ts +337 -0
- package/packages/core/src/text_tables.ts +408 -0
- package/packages/core/src/transpile.ts +146 -0
- package/packages/core/src/typed_ast.ts +536 -0
- package/packages/core/src/types.ts +815 -0
- package/skill-data/native-ui/SKILL.md +14 -0
- package/skill-data/ts-core/SKILL.md +493 -0
- package/skill-data/zig/SKILL.md +10 -0
- package/src/app_runner/root.zig +24 -0
- package/src/app_runner/ts_core_main.zig +231 -0
- package/src/primitives/app_manifest/comptime_scene.zig +341 -0
- package/src/primitives/app_manifest/root.zig +5 -0
- package/src/primitives/canvas/commands.zig +14 -7
- package/src/primitives/canvas/lazy_tls.zig +73 -0
- package/src/primitives/canvas/render_generic_resources.zig +22 -15
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tests.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +40 -32
- package/src/primitives/canvas/text_layout_cache.zig +29 -22
- package/src/primitives/canvas/text_measure_cache.zig +56 -41
- package/src/primitives/canvas/text_spans.zig +39 -26
- package/src/primitives/canvas/tokens.zig +54 -0
- package/src/primitives/canvas/ui.zig +125 -0
- package/src/primitives/canvas/ui_markup.zig +22 -3
- package/src/primitives/canvas/ui_markup_compiled.zig +97 -7
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +275 -0
- package/src/primitives/canvas/ui_markup_contract.zig +68 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +257 -2
- package/src/primitives/canvas/ui_markup_reflect.zig +214 -0
- package/src/primitives/canvas/ui_markup_view.zig +105 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +336 -0
- package/src/primitives/canvas/ui_schema.zig +8 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_invalidation.zig +14 -7
- package/src/primitives/canvas/widget_render.zig +25 -15
- package/src/primitives/canvas/widget_render_controls.zig +15 -9
- package/src/primitives/canvas/widget_runtime_tests.zig +44 -0
- package/src/root.zig +7 -0
- package/src/runtime/canvas_frame.zig +57 -36
- package/src/runtime/canvas_images.zig +9 -3
- package/src/runtime/canvas_widget_control_tests.zig +5 -6
- package/src/runtime/canvas_widget_runtime.zig +7 -4
- package/src/runtime/effects.zig +490 -2
- package/src/runtime/effects_host_tests.zig +594 -0
- package/src/runtime/root.zig +18 -0
- package/src/runtime/session_replay.zig +7 -1
- package/src/runtime/tests.zig +2 -0
- package/src/runtime/ts_core_host.zig +1505 -0
- package/src/runtime/ts_core_host_tests.zig +1408 -0
- package/src/runtime/ts_ui_app.zig +469 -0
- package/src/runtime/ui_app.zig +58 -0
- package/src/runtime/view_canvas.zig +24 -17
- package/src/runtime/view_widget_tree.zig +2 -2
- package/src/tooling/codesign.zig +212 -105
- package/src/tooling/doctor.zig +78 -0
- package/src/tooling/manifest.zig +47 -0
- package/src/tooling/package.zig +124 -12
- package/src/tooling/raw_manifest.zig +15 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +683 -28
- package/src/tooling/ts_core.zig +486 -0
- package/src/tooling/verbs.zig +17 -0
package/src/tooling/package.zig
CHANGED
|
@@ -89,6 +89,11 @@ pub const PackageStats = struct {
|
|
|
89
89
|
artifact_name: []const u8 = "",
|
|
90
90
|
target: PackageTarget = .macos,
|
|
91
91
|
signing_mode: SigningMode = .none,
|
|
92
|
+
/// True when a signing mode that claims to sign (adhoc or identity)
|
|
93
|
+
/// ran AND the result passed `codesign --verify --deep --strict`:
|
|
94
|
+
/// the proof behind the report's "signed, verified" line. A package
|
|
95
|
+
/// whose signing or verification fails never produces stats at all.
|
|
96
|
+
signing_verified: bool = false,
|
|
92
97
|
asset_count: usize = 0,
|
|
93
98
|
web_engine: WebEngine = .system,
|
|
94
99
|
web_layer: ?manifest_tool.WebLayer = null,
|
|
@@ -174,6 +179,9 @@ pub fn printDiagnostic(stats: PackageStats) void {
|
|
|
174
179
|
if (stats.web_layer) |layer| {
|
|
175
180
|
std.debug.print(" web layer: {s} ({s})\n", .{ webLayerEngineName(layer, stats.target, stats.web_engine), layer.sourceText() });
|
|
176
181
|
}
|
|
182
|
+
if (stats.signing_verified) {
|
|
183
|
+
std.debug.print(" signing: {s} (signed, verified)\n", .{@tagName(stats.signing_mode)});
|
|
184
|
+
}
|
|
177
185
|
if (stats.archive_path) |archive| {
|
|
178
186
|
std.debug.print(" archive: {s}\n", .{archive});
|
|
179
187
|
}
|
|
@@ -225,13 +233,14 @@ pub fn createMacosApp(allocator: std.mem.Allocator, io: std.Io, options: Package
|
|
|
225
233
|
try cef.ensureLayout(io, options.cef_dir);
|
|
226
234
|
try copyMacosCefRuntime(allocator, io, package_dir, options.cef_dir);
|
|
227
235
|
}
|
|
228
|
-
try runSigning(allocator, io, package_dir, options);
|
|
236
|
+
const signing_verified = try runSigning(allocator, io, package_dir, options);
|
|
229
237
|
|
|
230
238
|
return .{
|
|
231
239
|
.path = options.output_path,
|
|
232
240
|
.artifact_name = std.fs.path.basename(options.output_path),
|
|
233
241
|
.target = .macos,
|
|
234
242
|
.signing_mode = options.signing.mode,
|
|
243
|
+
.signing_verified = signing_verified,
|
|
235
244
|
.asset_count = bundle_stats.asset_count,
|
|
236
245
|
.web_engine = options.web_engine,
|
|
237
246
|
.web_layer = webLayerFor(options),
|
|
@@ -1359,33 +1368,65 @@ fn copyTree(allocator: std.mem.Allocator, io: std.Io, source_path: []const u8, d
|
|
|
1359
1368
|
/// the signature on the bundle is the proof it happened — and only a
|
|
1360
1369
|
/// FAILED signing rewrites it, which is safe because a failed codesign
|
|
1361
1370
|
/// leaves the bundle without a seal to break.
|
|
1362
|
-
|
|
1371
|
+
/// Returns true when the bundle was signed AND the signature verified —
|
|
1372
|
+
/// the value the report's "signed, verified" line states. A signing mode
|
|
1373
|
+
/// that claims to sign (adhoc or identity) either delivers a verified
|
|
1374
|
+
/// signature or fails the whole package with codesign's own reason:
|
|
1375
|
+
/// exiting 0 while shipping an unsigned bundle is the release-breaking
|
|
1376
|
+
/// failure this pipeline exists to prevent.
|
|
1377
|
+
fn runSigning(allocator: std.mem.Allocator, io: std.Io, dir: std.Io.Dir, options: PackageOptions) !bool {
|
|
1363
1378
|
const plan_path = "Contents/Resources/signing-plan.txt";
|
|
1364
1379
|
switch (options.signing.mode) {
|
|
1365
|
-
.none =>
|
|
1380
|
+
.none => {
|
|
1381
|
+
try writeFile(dir, io, plan_path, "signing=none\nunsigned local package\n");
|
|
1382
|
+
return false;
|
|
1383
|
+
},
|
|
1366
1384
|
.adhoc => {
|
|
1367
1385
|
try writeFile(dir, io, plan_path, "signing=adhoc\nad-hoc signed\n");
|
|
1368
|
-
const result = codesign.signAdHoc(io, options.output_path)
|
|
1386
|
+
const result = try codesign.signAdHoc(allocator, io, options.output_path);
|
|
1387
|
+
defer allocator.free(result.message);
|
|
1388
|
+
if (!result.ok) {
|
|
1369
1389
|
try writeFile(dir, io, plan_path, "signing=adhoc\ncodesign --sign - failed; bundle is unsigned\n");
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1390
|
+
std.debug.print("error: ad-hoc code signing failed for {s}, so this package would ship unsigned - codesign said:\n{s}\n fix what codesign reports above, or package with `--signing none` if an unsigned bundle is what you want\n", .{ options.output_path, trimmedToolOutput(result.message) });
|
|
1391
|
+
return error.SigningFailed;
|
|
1392
|
+
}
|
|
1373
1393
|
},
|
|
1374
1394
|
.identity => {
|
|
1375
1395
|
const identity = options.signing.identity orelse {
|
|
1376
1396
|
try writeFile(dir, io, plan_path, "signing=identity\nno identity provided; bundle is unsigned\n");
|
|
1377
|
-
|
|
1397
|
+
std.debug.print("error: --signing identity needs the identity to sign with, so this package would ship unsigned - pass --identity \"Developer ID Application: Your Name (TEAMID)\"\n `security find-identity -v -p codesigning` lists the identities this machine can sign with\n", .{});
|
|
1398
|
+
return error.SigningFailed;
|
|
1378
1399
|
};
|
|
1379
1400
|
const plan_text = try std.fmt.allocPrint(allocator, "signing=identity\nsigned with {s}\n", .{identity});
|
|
1380
1401
|
defer allocator.free(plan_text);
|
|
1381
1402
|
try writeFile(dir, io, plan_path, plan_text);
|
|
1382
|
-
const result = codesign.signIdentity(io, options.output_path, identity, options.signing.entitlements)
|
|
1403
|
+
const result = try codesign.signIdentity(allocator, io, options.output_path, identity, options.signing.entitlements);
|
|
1404
|
+
defer allocator.free(result.message);
|
|
1405
|
+
if (!result.ok) {
|
|
1383
1406
|
try writeFile(dir, io, plan_path, "signing=identity\ncodesign failed; bundle is unsigned\n");
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1407
|
+
std.debug.print("error: code signing with \"{s}\" failed for {s}, so this package would ship unsigned - codesign said:\n{s}\n `security find-identity -v -p codesigning` lists the identities this machine can sign with\n", .{ identity, options.output_path, trimmedToolOutput(result.message) });
|
|
1408
|
+
return error.SigningFailed;
|
|
1409
|
+
}
|
|
1387
1410
|
},
|
|
1388
1411
|
}
|
|
1412
|
+
// The signature just applied must actually hold — the same strict
|
|
1413
|
+
// deep check an Apple silicon launch effectively runs. A bundle that
|
|
1414
|
+
// signs but does not verify (a stale seal, unsigned nested code) is
|
|
1415
|
+
// a packaging failure, not a report footnote.
|
|
1416
|
+
const verified = try codesign.verify(allocator, io, options.output_path);
|
|
1417
|
+
defer allocator.free(verified.message);
|
|
1418
|
+
if (!verified.ok) {
|
|
1419
|
+
std.debug.print("error: {s} was signed but failed `codesign --verify --deep --strict`, so it would be rejected at launch - codesign said:\n{s}\n fix what codesign reports above and rerun `native package`\n", .{ options.output_path, trimmedToolOutput(verified.message) });
|
|
1420
|
+
return error.SignatureVerificationFailed;
|
|
1421
|
+
}
|
|
1422
|
+
return true;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/// codesign's output, trimmed of trailing newlines so the teaching
|
|
1426
|
+
/// message's fix line lands directly under it (the output itself stays
|
|
1427
|
+
/// verbatim).
|
|
1428
|
+
fn trimmedToolOutput(output: []const u8) []const u8 {
|
|
1429
|
+
return std.mem.trimEnd(u8, output, "\r\n");
|
|
1389
1430
|
}
|
|
1390
1431
|
|
|
1391
1432
|
fn hasRegistrationMetadata(metadata: manifest_tool.Metadata) bool {
|
|
@@ -2337,6 +2378,77 @@ test "package report records target signing and assets" {
|
|
|
2337
2378
|
try std.testing.expect(std.mem.indexOf(u8, buffer[0..len], ".asset_count = 2") != null);
|
|
2338
2379
|
}
|
|
2339
2380
|
|
|
2381
|
+
test "adhoc packaging into a spaced output path signs and verifies" {
|
|
2382
|
+
// The reported release-breaker: `--output "<path with spaces>.app"`
|
|
2383
|
+
// packaged, exited 0, and shipped an UNSIGNED bundle because the
|
|
2384
|
+
// codesign command was a shell string the spaces split apart. The
|
|
2385
|
+
// pipeline now execs argv arrays, so the spaced path must sign — and
|
|
2386
|
+
// the strict deep verify (real codesign, darwin hosts only) is the
|
|
2387
|
+
// proof.
|
|
2388
|
+
if (@import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
2389
|
+
const gpa = std.testing.allocator;
|
|
2390
|
+
var cwd = std.Io.Dir.cwd();
|
|
2391
|
+
const root = ".zig-cache/test-package signed spaced";
|
|
2392
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2393
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2394
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2395
|
+
|
|
2396
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.spaced-sign", .name = "spaced-demo", .version = "1.0.0" };
|
|
2397
|
+
const app_path = root ++ "/My Spaced Demo.app";
|
|
2398
|
+
const stats = try createMacosApp(gpa, std.testing.io, .{
|
|
2399
|
+
.metadata = metadata,
|
|
2400
|
+
.output_path = app_path,
|
|
2401
|
+
// A real Mach-O executable, so codesign has honest code to sign.
|
|
2402
|
+
.binary_path = "/bin/ls",
|
|
2403
|
+
.assets_dir = root ++ "/assets",
|
|
2404
|
+
.signing = .{ .mode = .adhoc },
|
|
2405
|
+
});
|
|
2406
|
+
try std.testing.expectEqual(SigningMode.adhoc, stats.signing_mode);
|
|
2407
|
+
try std.testing.expect(stats.signing_verified);
|
|
2408
|
+
|
|
2409
|
+
// Pin the claim with an independent codesign run, not just the flag.
|
|
2410
|
+
const verified = try codesign.verify(gpa, std.testing.io, app_path);
|
|
2411
|
+
defer gpa.free(verified.message);
|
|
2412
|
+
try std.testing.expect(verified.ok);
|
|
2413
|
+
}
|
|
2414
|
+
|
|
2415
|
+
test "a codesign failure fails packaging instead of shipping unsigned" {
|
|
2416
|
+
// An identity codesign cannot resolve exits nonzero; packaging must
|
|
2417
|
+
// surface that as an error (with codesign's reason printed), never
|
|
2418
|
+
// as a created artifact. Real codesign run: darwin hosts only.
|
|
2419
|
+
if (@import("builtin").os.tag != .macos) return error.SkipZigTest;
|
|
2420
|
+
var cwd = std.Io.Dir.cwd();
|
|
2421
|
+
const root = ".zig-cache/test-package-signing-failure";
|
|
2422
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2423
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2424
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2425
|
+
|
|
2426
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.sign-fail", .name = "sign-fail-demo", .version = "1.0.0" };
|
|
2427
|
+
try std.testing.expectError(error.SigningFailed, createMacosApp(std.testing.allocator, std.testing.io, .{
|
|
2428
|
+
.metadata = metadata,
|
|
2429
|
+
.output_path = root ++ "/Sign Fail Demo.app",
|
|
2430
|
+
.binary_path = "/bin/ls",
|
|
2431
|
+
.assets_dir = root ++ "/assets",
|
|
2432
|
+
.signing = .{ .mode = .identity, .identity = "native-sdk-no-such-identity" },
|
|
2433
|
+
}));
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
test "identity signing without an identity is a loud failure, not a silent unsigned bundle" {
|
|
2437
|
+
var cwd = std.Io.Dir.cwd();
|
|
2438
|
+
const root = ".zig-cache/test-package-signing-no-identity";
|
|
2439
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
2440
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
2441
|
+
try cwd.createDirPath(std.testing.io, root ++ "/assets");
|
|
2442
|
+
|
|
2443
|
+
const metadata: manifest_tool.Metadata = .{ .id = "dev.example.no-identity", .name = "no-identity-demo", .version = "1.0.0" };
|
|
2444
|
+
try std.testing.expectError(error.SigningFailed, createMacosApp(std.testing.allocator, std.testing.io, .{
|
|
2445
|
+
.metadata = metadata,
|
|
2446
|
+
.output_path = root ++ "/NoIdentity.app",
|
|
2447
|
+
.assets_dir = root ++ "/assets",
|
|
2448
|
+
.signing = .{ .mode = .identity },
|
|
2449
|
+
}));
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2340
2452
|
test "native-only windows package ships no WebView2 loader and reports web layer none" {
|
|
2341
2453
|
var cwd = std.Io.Dir.cwd();
|
|
2342
2454
|
const root = ".zig-cache/test-package-native-only-windows";
|
|
@@ -14,9 +14,11 @@ pub const RawManifest = struct {
|
|
|
14
14
|
web_engine: []const u8 = @tagName(web_engine.default_engine),
|
|
15
15
|
webview_layer: []const u8 = "auto",
|
|
16
16
|
theme: ?[]const u8 = null,
|
|
17
|
+
theme_accent: ?[]const u8 = null,
|
|
17
18
|
cef: RawCef = .{},
|
|
18
19
|
frontend: ?RawFrontend = null,
|
|
19
20
|
security: RawSecurity = .{},
|
|
21
|
+
assets: RawAssets = .{},
|
|
20
22
|
windows: []const RawWindow = &.{},
|
|
21
23
|
shell: RawShell = .{},
|
|
22
24
|
commands: []const RawCommand = &.{},
|
|
@@ -59,6 +61,19 @@ pub const RawSecurity = struct {
|
|
|
59
61
|
navigation: RawNavigation = .{},
|
|
60
62
|
};
|
|
61
63
|
|
|
64
|
+
/// Launch-registered assets (the TypeScript-core wiring's image channel):
|
|
65
|
+
/// each image is read once at launch and registered on the installing
|
|
66
|
+
/// frame under its declared `ImageId` — the id markup avatar bindings
|
|
67
|
+
/// reference.
|
|
68
|
+
pub const RawAssets = struct {
|
|
69
|
+
images: []const RawImageAsset = &.{},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
pub const RawImageAsset = struct {
|
|
73
|
+
id: u64,
|
|
74
|
+
path: []const u8,
|
|
75
|
+
};
|
|
76
|
+
|
|
62
77
|
pub const RawNavigation = struct {
|
|
63
78
|
allowed_origins: []const []const u8 = &.{},
|
|
64
79
|
external_links: RawExternalLinks = .{},
|
package/src/tooling/root.zig
CHANGED
|
@@ -14,6 +14,7 @@ pub const embedlib = @import("embedlib.zig");
|
|
|
14
14
|
pub const eject_components = @import("eject_components.zig");
|
|
15
15
|
pub const toolchain = @import("toolchain.zig");
|
|
16
16
|
pub const verbs = @import("verbs.zig");
|
|
17
|
+
pub const ts_core = @import("ts_core.zig");
|
|
17
18
|
pub const ios = @import("ios.zig");
|
|
18
19
|
pub const android = @import("android.zig");
|
|
19
20
|
pub const xcodeproj = @import("xcodeproj.zig");
|