@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
|
@@ -226,10 +226,10 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
226
226
|
);
|
|
227
227
|
|
|
228
228
|
// Per-pass probe-table indices over the collected entry lists
|
|
229
|
-
// (shared
|
|
229
|
+
// (shared per-thread scratch; see the reconcile-id-index note
|
|
230
230
|
// in canvas_widget_runtime.zig). Lookups return exactly what
|
|
231
231
|
// the linear scans returned; only the search cost changes.
|
|
232
|
-
const index_scratch =
|
|
232
|
+
const index_scratch = canvas_widget_runtime.canvas_widget_reconcile_index_scratch.get();
|
|
233
233
|
index_scratch.controls.build(previous_control_states);
|
|
234
234
|
index_scratch.source_controls.build(self.widgetSourceControlEntries());
|
|
235
235
|
index_scratch.texts.build(previous_text_states);
|
package/src/tooling/codesign.zig
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const std = @import("std");
|
|
2
2
|
|
|
3
|
+
/// The outcome of one signing-pipeline tool run. `message` is always
|
|
4
|
+
/// allocated (the tool's own stdout+stderr for failures — codesign says
|
|
5
|
+
/// exactly why it refused — or a short success note); the caller frees.
|
|
3
6
|
pub const SignResult = struct {
|
|
4
7
|
ok: bool,
|
|
5
|
-
message: []
|
|
8
|
+
message: []u8,
|
|
6
9
|
};
|
|
7
10
|
|
|
8
11
|
pub const CodesignArgs = struct {
|
|
@@ -20,62 +23,99 @@ pub const NotarizeArgs = struct {
|
|
|
20
23
|
password_keychain_item: ?[]const u8 = null,
|
|
21
24
|
};
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
// Every command in this pipeline is built as an ARGV ARRAY, never as a
|
|
27
|
+
// shell string: a bundle path (or identity) with spaces must reach
|
|
28
|
+
// codesign/ditto/notarytool as one argument. The shell-string shape this
|
|
29
|
+
// replaced split `My App.app` into two arguments, codesign signed
|
|
30
|
+
// nothing, and the failure never surfaced.
|
|
31
|
+
|
|
32
|
+
pub const sign_argv_capacity = 10;
|
|
33
|
+
|
|
34
|
+
pub fn signArgv(buffer: *[sign_argv_capacity][]const u8, args: CodesignArgs) []const []const u8 {
|
|
35
|
+
var len: usize = 0;
|
|
36
|
+
buffer[len] = "codesign";
|
|
37
|
+
len += 1;
|
|
38
|
+
buffer[len] = "--sign";
|
|
39
|
+
len += 1;
|
|
40
|
+
buffer[len] = args.identity;
|
|
41
|
+
len += 1;
|
|
42
|
+
buffer[len] = "--force";
|
|
43
|
+
len += 1;
|
|
44
|
+
if (args.deep) {
|
|
45
|
+
buffer[len] = "--deep";
|
|
46
|
+
len += 1;
|
|
47
|
+
}
|
|
48
|
+
if (args.hardened_runtime) {
|
|
49
|
+
buffer[len] = "--options";
|
|
50
|
+
len += 1;
|
|
51
|
+
buffer[len] = "runtime";
|
|
52
|
+
len += 1;
|
|
53
|
+
}
|
|
30
54
|
if (args.entitlements) |ent| {
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
buffer[len] = "--entitlements";
|
|
56
|
+
len += 1;
|
|
57
|
+
buffer[len] = ent;
|
|
58
|
+
len += 1;
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return
|
|
60
|
+
buffer[len] = args.app_path;
|
|
61
|
+
len += 1;
|
|
62
|
+
return buffer[0..len];
|
|
37
63
|
}
|
|
38
64
|
|
|
39
|
-
pub fn
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
try writer.writeAll(zip_path);
|
|
43
|
-
try writer.writeAll(" --team-id ");
|
|
44
|
-
try writer.writeAll(args.team_id);
|
|
45
|
-
if (args.apple_id) |apple_id| {
|
|
46
|
-
try writer.writeAll(" --apple-id ");
|
|
47
|
-
try writer.writeAll(apple_id);
|
|
48
|
-
}
|
|
49
|
-
if (args.password_keychain_item) |item| {
|
|
50
|
-
try writer.writeAll(" --password @keychain:");
|
|
51
|
-
try writer.writeAll(item);
|
|
52
|
-
}
|
|
53
|
-
try writer.writeAll(" --wait");
|
|
54
|
-
return writer.buffered();
|
|
65
|
+
pub fn verifyArgv(buffer: *[6][]const u8, app_path: []const u8) []const []const u8 {
|
|
66
|
+
buffer.* = .{ "codesign", "--verify", "--deep", "--strict", "--verbose=2", app_path };
|
|
67
|
+
return buffer;
|
|
55
68
|
}
|
|
56
69
|
|
|
57
|
-
pub fn
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
try writer.writeAll(app_path);
|
|
61
|
-
return writer.buffered();
|
|
70
|
+
pub fn zipArgv(buffer: *[6][]const u8, app_path: []const u8, zip_path: []const u8) []const []const u8 {
|
|
71
|
+
buffer.* = .{ "ditto", "-c", "-k", "--keepParent", app_path, zip_path };
|
|
72
|
+
return buffer;
|
|
62
73
|
}
|
|
63
74
|
|
|
64
|
-
pub fn
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
try writer.writeAll(app_path);
|
|
68
|
-
try writer.writeAll(" ");
|
|
69
|
-
try writer.writeAll(zip_path);
|
|
70
|
-
return writer.buffered();
|
|
75
|
+
pub fn stapleArgv(buffer: *[4][]const u8, app_path: []const u8) []const []const u8 {
|
|
76
|
+
buffer.* = .{ "xcrun", "stapler", "staple", app_path };
|
|
77
|
+
return buffer;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
|
-
pub
|
|
74
|
-
|
|
80
|
+
pub const notarize_submit_argv_capacity = 11;
|
|
81
|
+
|
|
82
|
+
pub fn notarizeSubmitArgv(buffer: *[notarize_submit_argv_capacity][]const u8, zip_path: []const u8, password_value: ?[]const u8, args: NotarizeArgs) []const []const u8 {
|
|
83
|
+
var len: usize = 0;
|
|
84
|
+
buffer[len] = "xcrun";
|
|
85
|
+
len += 1;
|
|
86
|
+
buffer[len] = "notarytool";
|
|
87
|
+
len += 1;
|
|
88
|
+
buffer[len] = "submit";
|
|
89
|
+
len += 1;
|
|
90
|
+
buffer[len] = zip_path;
|
|
91
|
+
len += 1;
|
|
92
|
+
buffer[len] = "--team-id";
|
|
93
|
+
len += 1;
|
|
94
|
+
buffer[len] = args.team_id;
|
|
95
|
+
len += 1;
|
|
96
|
+
if (args.apple_id) |apple_id| {
|
|
97
|
+
buffer[len] = "--apple-id";
|
|
98
|
+
len += 1;
|
|
99
|
+
buffer[len] = apple_id;
|
|
100
|
+
len += 1;
|
|
101
|
+
}
|
|
102
|
+
if (password_value) |value| {
|
|
103
|
+
buffer[len] = "--password";
|
|
104
|
+
len += 1;
|
|
105
|
+
buffer[len] = value;
|
|
106
|
+
len += 1;
|
|
107
|
+
}
|
|
108
|
+
buffer[len] = "--wait";
|
|
109
|
+
len += 1;
|
|
110
|
+
return buffer[0..len];
|
|
75
111
|
}
|
|
76
112
|
|
|
77
|
-
pub fn
|
|
78
|
-
return runSign(io, .{
|
|
113
|
+
pub fn signAdHoc(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !SignResult {
|
|
114
|
+
return runSign(allocator, io, .{ .app_path = app_path, .identity = "-", .deep = true });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
pub fn signIdentity(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8, identity: []const u8, entitlements: ?[]const u8) !SignResult {
|
|
118
|
+
return runSign(allocator, io, .{
|
|
79
119
|
.app_path = app_path,
|
|
80
120
|
.identity = identity,
|
|
81
121
|
.entitlements = entitlements,
|
|
@@ -84,89 +124,156 @@ pub fn signIdentity(io: std.Io, app_path: []const u8, identity: []const u8, enti
|
|
|
84
124
|
});
|
|
85
125
|
}
|
|
86
126
|
|
|
127
|
+
/// `codesign --verify --deep --strict` over the signed bundle: the same
|
|
128
|
+
/// check Gatekeeper and an Apple silicon launch effectively run, so a
|
|
129
|
+
/// signature that only LOOKS applied (stale seal, unsigned nested code)
|
|
130
|
+
/// fails here at package time instead of on the user's machine.
|
|
131
|
+
pub fn verify(allocator: std.mem.Allocator, io: std.Io, app_path: []const u8) !SignResult {
|
|
132
|
+
var buffer: [6][]const u8 = undefined;
|
|
133
|
+
return runTool(allocator, io, verifyArgv(&buffer, app_path));
|
|
134
|
+
}
|
|
135
|
+
|
|
87
136
|
pub fn notarize(allocator: std.mem.Allocator, io: std.Io, args: NotarizeArgs) !SignResult {
|
|
88
137
|
const zip_path = try std.fmt.allocPrint(allocator, "{s}.zip", .{args.app_path});
|
|
89
138
|
defer allocator.free(zip_path);
|
|
90
139
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
140
|
+
{
|
|
141
|
+
var zip_buffer: [6][]const u8 = undefined;
|
|
142
|
+
const zip_result = try runTool(allocator, io, zipArgv(&zip_buffer, args.app_path, zip_path));
|
|
143
|
+
if (!zip_result.ok) return failedStep(allocator, "ditto (zip for notarization)", zip_result);
|
|
144
|
+
allocator.free(zip_result.message);
|
|
145
|
+
}
|
|
95
146
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
147
|
+
{
|
|
148
|
+
const password_value: ?[]const u8 = if (args.password_keychain_item) |item|
|
|
149
|
+
try std.fmt.allocPrint(allocator, "@keychain:{s}", .{item})
|
|
150
|
+
else
|
|
151
|
+
null;
|
|
152
|
+
defer if (password_value) |value| allocator.free(value);
|
|
153
|
+
var submit_buffer: [notarize_submit_argv_capacity][]const u8 = undefined;
|
|
154
|
+
const submit_result = try runTool(allocator, io, notarizeSubmitArgv(&submit_buffer, zip_path, password_value, args));
|
|
155
|
+
if (!submit_result.ok) return failedStep(allocator, "notarytool submit", submit_result);
|
|
156
|
+
allocator.free(submit_result.message);
|
|
157
|
+
}
|
|
99
158
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
159
|
+
{
|
|
160
|
+
var staple_buffer: [4][]const u8 = undefined;
|
|
161
|
+
const staple_result = try runTool(allocator, io, stapleArgv(&staple_buffer, args.app_path));
|
|
162
|
+
if (!staple_result.ok) return failedStep(allocator, "stapler staple", staple_result);
|
|
163
|
+
allocator.free(staple_result.message);
|
|
164
|
+
}
|
|
103
165
|
|
|
104
|
-
return .{ .ok = true, .message = "notarization complete" };
|
|
166
|
+
return .{ .ok = true, .message = try allocator.dupe(u8, "notarization complete") };
|
|
105
167
|
}
|
|
106
168
|
|
|
107
|
-
fn
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
runShell(io, cmd) catch return .{ .ok = false, .message = "codesign failed" };
|
|
111
|
-
return .{ .ok = true, .message = "signed" };
|
|
169
|
+
fn failedStep(allocator: std.mem.Allocator, step: []const u8, result: SignResult) !SignResult {
|
|
170
|
+
defer allocator.free(result.message);
|
|
171
|
+
return .{ .ok = false, .message = try std.fmt.allocPrint(allocator, "{s} failed:\n{s}", .{ step, result.message }) };
|
|
112
172
|
}
|
|
113
173
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
174
|
+
fn runSign(allocator: std.mem.Allocator, io: std.Io, args: CodesignArgs) !SignResult {
|
|
175
|
+
var buffer: [sign_argv_capacity][]const u8 = undefined;
|
|
176
|
+
return runTool(allocator, io, signArgv(&buffer, args));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// Run one pipeline tool and report a non-zero exit as a failure that
|
|
180
|
+
/// carries the tool's own output: a codesign that exits 1 — or a host
|
|
181
|
+
/// without codesign at all — must surface with its reason so callers can
|
|
182
|
+
/// refuse to report a signature that does not exist.
|
|
183
|
+
fn runTool(allocator: std.mem.Allocator, io: std.Io, argv: []const []const u8) !SignResult {
|
|
184
|
+
const result = std.process.run(allocator, io, .{
|
|
185
|
+
.argv = argv,
|
|
186
|
+
.stdout_limit = .limited(256 * 1024),
|
|
187
|
+
.stderr_limit = .limited(256 * 1024),
|
|
188
|
+
}) catch |err| switch (err) {
|
|
189
|
+
error.OutOfMemory => return error.OutOfMemory,
|
|
190
|
+
else => return .{
|
|
191
|
+
.ok = false,
|
|
192
|
+
.message = try std.fmt.allocPrint(allocator, "could not run `{s}`: {t} (it ships with the Xcode Command Line Tools; signing macOS bundles needs a macOS host)", .{ argv[0], err }),
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
defer allocator.free(result.stdout);
|
|
196
|
+
defer allocator.free(result.stderr);
|
|
197
|
+
const ok = result.term == .exited and result.term.exited == 0;
|
|
198
|
+
// codesign explains failures on stderr; notarytool narrates on
|
|
199
|
+
// stdout. Keep both, stderr last so the refusal reads closest to
|
|
200
|
+
// the caller's teaching message.
|
|
201
|
+
return .{ .ok = ok, .message = try std.mem.concat(allocator, u8, &.{ result.stdout, result.stderr }) };
|
|
131
202
|
}
|
|
132
203
|
|
|
133
|
-
test "ad-hoc sign
|
|
134
|
-
var buffer: [
|
|
135
|
-
const
|
|
136
|
-
|
|
204
|
+
test "ad-hoc sign argv keeps a spaced bundle path as one argument" {
|
|
205
|
+
var buffer: [sign_argv_capacity][]const u8 = undefined;
|
|
206
|
+
const argv = signArgv(&buffer, .{ .app_path = "/tmp/My Demo App.app" });
|
|
207
|
+
const expected = [_][]const u8{ "codesign", "--sign", "-", "--force", "--deep", "/tmp/My Demo App.app" };
|
|
208
|
+
try expectArgv(&expected, argv);
|
|
137
209
|
}
|
|
138
210
|
|
|
139
|
-
test "identity sign
|
|
140
|
-
var buffer: [
|
|
141
|
-
const
|
|
142
|
-
.app_path = "/tmp/
|
|
143
|
-
.identity = "Developer ID Application: Test",
|
|
144
|
-
.entitlements = "assets/native-sdk.entitlements",
|
|
211
|
+
test "identity sign argv includes runtime and entitlements as single arguments" {
|
|
212
|
+
var buffer: [sign_argv_capacity][]const u8 = undefined;
|
|
213
|
+
const argv = signArgv(&buffer, .{
|
|
214
|
+
.app_path = "/tmp/My Demo App.app",
|
|
215
|
+
.identity = "Developer ID Application: Test Person (ABCD1234)",
|
|
216
|
+
.entitlements = "assets dir/native-sdk.entitlements",
|
|
145
217
|
.hardened_runtime = true,
|
|
146
218
|
});
|
|
147
|
-
|
|
148
|
-
"codesign
|
|
149
|
-
|
|
150
|
-
|
|
219
|
+
const expected = [_][]const u8{
|
|
220
|
+
"codesign", "--sign",
|
|
221
|
+
"Developer ID Application: Test Person (ABCD1234)", "--force",
|
|
222
|
+
"--deep", "--options",
|
|
223
|
+
"runtime", "--entitlements",
|
|
224
|
+
"assets dir/native-sdk.entitlements", "/tmp/My Demo App.app",
|
|
225
|
+
};
|
|
226
|
+
try expectArgv(&expected, argv);
|
|
151
227
|
}
|
|
152
228
|
|
|
153
|
-
test "
|
|
154
|
-
var buffer: [
|
|
155
|
-
const
|
|
156
|
-
|
|
229
|
+
test "verify argv runs the strict deep check on the bundle path" {
|
|
230
|
+
var buffer: [6][]const u8 = undefined;
|
|
231
|
+
const argv = verifyArgv(&buffer, "/tmp/My Demo App.app");
|
|
232
|
+
const expected = [_][]const u8{ "codesign", "--verify", "--deep", "--strict", "--verbose=2", "/tmp/My Demo App.app" };
|
|
233
|
+
try expectArgv(&expected, argv);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
test "notarize submit argv includes team id, keychain password, and wait" {
|
|
237
|
+
var buffer: [notarize_submit_argv_capacity][]const u8 = undefined;
|
|
238
|
+
const argv = notarizeSubmitArgv(&buffer, "/tmp/My Demo App.app.zip", "@keychain:AC_PASSWORD", .{
|
|
239
|
+
.app_path = "/tmp/My Demo App.app",
|
|
157
240
|
.team_id = "ABCD1234",
|
|
241
|
+
.apple_id = "dev@example.com",
|
|
158
242
|
});
|
|
159
|
-
|
|
243
|
+
const expected = [_][]const u8{ "xcrun", "notarytool", "submit", "/tmp/My Demo App.app.zip", "--team-id", "ABCD1234", "--apple-id", "dev@example.com", "--password", "@keychain:AC_PASSWORD", "--wait" };
|
|
244
|
+
try expectArgv(&expected, argv);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
test "staple and zip argv carry spaced paths as single arguments" {
|
|
248
|
+
var staple_buffer: [4][]const u8 = undefined;
|
|
249
|
+
const staple = stapleArgv(&staple_buffer, "/tmp/My Demo App.app");
|
|
250
|
+
const staple_expected = [_][]const u8{ "xcrun", "stapler", "staple", "/tmp/My Demo App.app" };
|
|
251
|
+
try expectArgv(&staple_expected, staple);
|
|
252
|
+
|
|
253
|
+
var zip_buffer: [6][]const u8 = undefined;
|
|
254
|
+
const zip = zipArgv(&zip_buffer, "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip");
|
|
255
|
+
const zip_expected = [_][]const u8{ "ditto", "-c", "-k", "--keepParent", "/tmp/My Demo App.app", "/tmp/My Demo App.app.zip" };
|
|
256
|
+
try expectArgv(&zip_expected, zip);
|
|
160
257
|
}
|
|
161
258
|
|
|
162
|
-
test "
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
try std.testing.
|
|
259
|
+
test "a failing tool surfaces its own output, not a silent success" {
|
|
260
|
+
if (@import("builtin").os.tag == .windows) return error.SkipZigTest;
|
|
261
|
+
// `false` exits 1 with no output: the result must be a failure.
|
|
262
|
+
const result = try runTool(std.testing.allocator, std.testing.io, &.{"false"});
|
|
263
|
+
defer std.testing.allocator.free(result.message);
|
|
264
|
+
try std.testing.expect(!result.ok);
|
|
166
265
|
}
|
|
167
266
|
|
|
168
|
-
test "
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
try std.testing.
|
|
267
|
+
test "a missing tool reports a failure that names it" {
|
|
268
|
+
const result = try runTool(std.testing.allocator, std.testing.io, &.{"native-sdk-no-such-tool-xyz"});
|
|
269
|
+
defer std.testing.allocator.free(result.message);
|
|
270
|
+
try std.testing.expect(!result.ok);
|
|
271
|
+
try std.testing.expect(std.mem.indexOf(u8, result.message, "native-sdk-no-such-tool-xyz") != null);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
fn expectArgv(expected: []const []const u8, actual: []const []const u8) !void {
|
|
275
|
+
try std.testing.expectEqual(expected.len, actual.len);
|
|
276
|
+
for (expected, actual) |want, got| {
|
|
277
|
+
try std.testing.expectEqualStrings(want, got);
|
|
278
|
+
}
|
|
172
279
|
}
|
package/src/tooling/doctor.zig
CHANGED
|
@@ -4,6 +4,8 @@ const cef = @import("cef.zig");
|
|
|
4
4
|
const debug = @import("debug");
|
|
5
5
|
const manifest_tool = @import("manifest.zig");
|
|
6
6
|
const web_engine = @import("web_engine.zig");
|
|
7
|
+
const buildgraph = @import("buildgraph.zig");
|
|
8
|
+
const ts_core = @import("ts_core.zig");
|
|
7
9
|
|
|
8
10
|
pub const Error = error{
|
|
9
11
|
DoctorProblems,
|
|
@@ -142,6 +144,7 @@ pub fn reportForCurrentHostWithProbe(
|
|
|
142
144
|
try buffers.add("null-backend", .available, "headless WebView shell platform is available", .{});
|
|
143
145
|
try addLogPathCheck(buffers, env_map);
|
|
144
146
|
try addManifestCheck(buffers, allocator, io, options);
|
|
147
|
+
try addTsEditorPackageCheck(buffers, allocator, io, env_map, probe);
|
|
145
148
|
if (target.os == .macos) {
|
|
146
149
|
try buffers.add("webview-system", .available, "WKWebView system WebView backend is available on macOS hosts", .{});
|
|
147
150
|
try addPathCheck(buffers, io, probe, "codesign", "/usr/bin/codesign", "codesign is available for macOS signing", "codesign was not found");
|
|
@@ -226,6 +229,30 @@ fn addLogPathCheck(buffers: *ReportBuffers, env_map: *std.process.Environ.Map) !
|
|
|
226
229
|
try buffers.add("log-path", .available, "runtime logs will be written to {s}", .{paths.log_file});
|
|
227
230
|
}
|
|
228
231
|
|
|
232
|
+
/// TypeScript apps only (cwd has src/core.ts): compare the app's editor
|
|
233
|
+
/// copy of @native-sdk/core (node_modules — the pre-publish surface stock
|
|
234
|
+
/// tsc resolves) against the SDK's bundled package. A mismatch never breaks
|
|
235
|
+
/// a build (builds don't read node_modules); it breaks IntelliSense, so the
|
|
236
|
+
/// teaching line names the fix.
|
|
237
|
+
fn addTsEditorPackageCheck(buffers: *ReportBuffers, allocator: std.mem.Allocator, io: std.Io, env_map: *std.process.Environ.Map, probe: Probe) !void {
|
|
238
|
+
if (!probe.pathExists(io, "src/core.ts")) return;
|
|
239
|
+
const framework_root = (buildgraph.resolveFrameworkRoot(allocator, io, env_map) catch null) orelse {
|
|
240
|
+
return buffers.add("ts-editor-package", .missing, "cannot locate the Native SDK framework to verify node_modules/@native-sdk/core; set NATIVE_SDK_PATH to your framework checkout", .{});
|
|
241
|
+
};
|
|
242
|
+
defer allocator.free(framework_root);
|
|
243
|
+
const status = ts_core.editorPackageStatus(allocator, io, framework_root, ".") catch {
|
|
244
|
+
return buffers.add("ts-editor-package", .missing, "the SDK at {s} is missing packages/core - cannot verify the editor package", .{framework_root});
|
|
245
|
+
};
|
|
246
|
+
defer status.deinit(allocator);
|
|
247
|
+
if (status.fresh()) {
|
|
248
|
+
try buffers.add("ts-editor-package", .available, "node_modules/@native-sdk/core matches the SDK (v{s}) - stock editor TypeScript resolves the SDK", .{status.bundled});
|
|
249
|
+
} else if (status.installed) |installed| {
|
|
250
|
+
try buffers.add("ts-editor-package", .missing, "node_modules/@native-sdk/core is v{s} but the SDK ships v{s} - `native check` refreshes it (after the npm publish: `npm install`); builds are unaffected", .{ installed, status.bundled });
|
|
251
|
+
} else {
|
|
252
|
+
try buffers.add("ts-editor-package", .missing, "node_modules/@native-sdk/core is missing - editor TypeScript cannot resolve the SDK; `native check` materializes it (builds are unaffected)", .{});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
229
256
|
fn addManifestCheck(buffers: *ReportBuffers, allocator: std.mem.Allocator, io: std.Io, options: Options) !void {
|
|
230
257
|
const path = options.manifest_path orelse return;
|
|
231
258
|
const result = manifest_tool.validateFile(allocator, io, path) catch |err| {
|
|
@@ -318,6 +345,57 @@ test "doctor options parse strict manifest and cef checks" {
|
|
|
318
345
|
try std.testing.expectEqualStrings("third_party/cef/macos", options.cef_dir_override.?);
|
|
319
346
|
}
|
|
320
347
|
|
|
348
|
+
test "doctor reports the TS editor package when the tree has a core.ts" {
|
|
349
|
+
const allocator = std.testing.allocator;
|
|
350
|
+
const io = std.testing.io;
|
|
351
|
+
// A fake SDK checkout (framework marker + bundled package) under the
|
|
352
|
+
// cache; the cwd (repo root) plays the app dir and has no
|
|
353
|
+
// node_modules/@native-sdk/core, so the check reports the missing copy.
|
|
354
|
+
const sdk = ".zig-cache/test-doctor-editor-package/sdk";
|
|
355
|
+
var cwd = std.Io.Dir.cwd();
|
|
356
|
+
cwd.deleteTree(io, ".zig-cache/test-doctor-editor-package") catch {};
|
|
357
|
+
defer cwd.deleteTree(io, ".zig-cache/test-doctor-editor-package") catch {};
|
|
358
|
+
try cwd.createDirPath(io, sdk ++ "/src");
|
|
359
|
+
try cwd.createDirPath(io, sdk ++ "/packages/core/sdk");
|
|
360
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/src/root.zig", .data = "// marker" });
|
|
361
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/package.json", .data = "{ \"version\": \"0.0.5\" }" });
|
|
362
|
+
|
|
363
|
+
const Fake = struct {
|
|
364
|
+
fn commandAvailable(context: ?*anyopaque, inner_allocator: std.mem.Allocator, inner_io: std.Io, argv: []const []const u8) bool {
|
|
365
|
+
_ = context;
|
|
366
|
+
_ = inner_allocator;
|
|
367
|
+
_ = inner_io;
|
|
368
|
+
_ = argv;
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
fn pathExists(context: ?*anyopaque, inner_io: std.Io, path: []const u8) bool {
|
|
373
|
+
_ = context;
|
|
374
|
+
_ = inner_io;
|
|
375
|
+
return std.mem.eql(u8, path, "src/core.ts");
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
var env_map = std.process.Environ.Map.init(allocator);
|
|
380
|
+
defer env_map.deinit();
|
|
381
|
+
try env_map.put("HOME", "/Users/alice");
|
|
382
|
+
try env_map.put("NATIVE_SDK_PATH", sdk);
|
|
383
|
+
var buffers: ReportBuffers = .{};
|
|
384
|
+
const report = try reportForCurrentHostWithProbe(allocator, io, &env_map, .{}, &buffers, .{
|
|
385
|
+
.command_fn = Fake.commandAvailable,
|
|
386
|
+
.path_fn = Fake.pathExists,
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
var found = false;
|
|
390
|
+
for (report.checks) |check| {
|
|
391
|
+
if (!std.mem.eql(u8, check.id, "ts-editor-package")) continue;
|
|
392
|
+
found = true;
|
|
393
|
+
try std.testing.expectEqual(platform_info.Status.missing, check.status);
|
|
394
|
+
try std.testing.expect(std.mem.indexOf(u8, check.message, "native check") != null);
|
|
395
|
+
}
|
|
396
|
+
try std.testing.expect(found);
|
|
397
|
+
}
|
|
398
|
+
|
|
321
399
|
test "doctor report uses injected probes" {
|
|
322
400
|
const Fake = struct {
|
|
323
401
|
fn commandAvailable(context: ?*anyopaque, allocator: std.mem.Allocator, io: std.Io, argv: []const []const u8) bool {
|
package/src/tooling/manifest.zig
CHANGED
|
@@ -33,6 +33,12 @@ pub const Metadata = struct {
|
|
|
33
33
|
/// the known pack names so a typo is a check error, never a silent
|
|
34
34
|
/// default-theme fallback.
|
|
35
35
|
theme: ?[]const u8 = null,
|
|
36
|
+
/// The manifest's one-accent brand override (`theme_accent =
|
|
37
|
+
/// "#df2670"`), layered over the resolved pack by the runtime
|
|
38
|
+
/// (`canvas.accentOverrides`; high contrast skips it). Optional —
|
|
39
|
+
/// absent keeps the pack's own accent. Validated as a #rrggbb hex
|
|
40
|
+
/// color so a typo is a check error, never a silent stock accent.
|
|
41
|
+
theme_accent: ?[]const u8 = null,
|
|
36
42
|
cef: web_engine_tool.CefConfig = .{},
|
|
37
43
|
frontend: ?FrontendMetadata = null,
|
|
38
44
|
security: SecurityMetadata = .{},
|
|
@@ -54,6 +60,7 @@ pub const Metadata = struct {
|
|
|
54
60
|
if (self.display_name) |value| allocator.free(value);
|
|
55
61
|
if (self.description) |value| allocator.free(value);
|
|
56
62
|
if (self.theme) |value| allocator.free(value);
|
|
63
|
+
if (self.theme_accent) |value| allocator.free(value);
|
|
57
64
|
allocator.free(self.version);
|
|
58
65
|
allocator.free(self.web_engine);
|
|
59
66
|
allocator.free(self.webview_layer);
|
|
@@ -374,6 +381,12 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
374
381
|
.message = "app.zon theme is invalid - expected one of: house, geist",
|
|
375
382
|
};
|
|
376
383
|
}
|
|
384
|
+
if (metadata.theme_accent) |accent| {
|
|
385
|
+
if (!isHexColor(accent)) return .{
|
|
386
|
+
.ok = false,
|
|
387
|
+
.message = "app.zon theme_accent is invalid - expected a #rrggbb hex color (e.g. \"#df2670\")",
|
|
388
|
+
};
|
|
389
|
+
}
|
|
377
390
|
validateIconPaths(metadata.icons) catch return .{ .ok = false, .message = "app.zon icons are invalid" };
|
|
378
391
|
if (try checkIconSources(allocator, io, std.fs.path.dirname(path) orelse ".", metadata.icons)) |icon_message| {
|
|
379
392
|
return .{ .ok = false, .message = icon_message };
|
|
@@ -480,6 +493,7 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
|
|
|
480
493
|
.display_name = if (raw.display_name) |value| try allocator.dupe(u8, value) else null,
|
|
481
494
|
.description = if (raw.description) |value| try allocator.dupe(u8, value) else null,
|
|
482
495
|
.theme = if (raw.theme) |value| try allocator.dupe(u8, value) else null,
|
|
496
|
+
.theme_accent = if (raw.theme_accent) |value| try allocator.dupe(u8, value) else null,
|
|
483
497
|
.version = try allocator.dupe(u8, raw.version),
|
|
484
498
|
.icons = try duplicateStringList(allocator, raw.icons),
|
|
485
499
|
.platforms = try duplicateStringList(allocator, raw.platforms),
|
|
@@ -960,6 +974,17 @@ fn isKnownThemePack(name: []const u8) bool {
|
|
|
960
974
|
return false;
|
|
961
975
|
}
|
|
962
976
|
|
|
977
|
+
/// One #rrggbb hex color — the `theme_accent` shape the runner's
|
|
978
|
+
/// comptime parse accepts (kept in step the same way as the pack names:
|
|
979
|
+
/// a drift is a build error in the app, never a shipped typo).
|
|
980
|
+
fn isHexColor(value: []const u8) bool {
|
|
981
|
+
if (value.len != 7 or value[0] != '#') return false;
|
|
982
|
+
for (value[1..]) |byte| {
|
|
983
|
+
_ = std.fmt.charToDigit(byte, 16) catch return false;
|
|
984
|
+
}
|
|
985
|
+
return true;
|
|
986
|
+
}
|
|
987
|
+
|
|
963
988
|
fn validateIconPaths(icons: []const []const u8) !void {
|
|
964
989
|
for (icons, 0..) |icon, index| {
|
|
965
990
|
try validateRelativePath(icon);
|
|
@@ -2203,3 +2228,25 @@ test "manifest validates the theme pack name" {
|
|
|
2203
2228
|
try std.testing.expect(isKnownThemePack("geist"));
|
|
2204
2229
|
try std.testing.expect(!isKnownThemePack("neon"));
|
|
2205
2230
|
}
|
|
2231
|
+
|
|
2232
|
+
test "manifest validates the theme accent hex color" {
|
|
2233
|
+
const metadata = try parseText(std.testing.allocator,
|
|
2234
|
+
\\.{
|
|
2235
|
+
\\ .id = "com.example.app",
|
|
2236
|
+
\\ .name = "example",
|
|
2237
|
+
\\ .version = "1.0.0",
|
|
2238
|
+
\\ .theme = "geist",
|
|
2239
|
+
\\ .theme_accent = "#df2670",
|
|
2240
|
+
\\}
|
|
2241
|
+
);
|
|
2242
|
+
defer metadata.deinit(std.testing.allocator);
|
|
2243
|
+
try std.testing.expectEqualStrings("#df2670", metadata.theme_accent.?);
|
|
2244
|
+
// The hex-shape check is the tooling half of the contract; the
|
|
2245
|
+
// runner re-parses the same shape at comptime in the app build.
|
|
2246
|
+
try std.testing.expect(isHexColor("#df2670"));
|
|
2247
|
+
try std.testing.expect(isHexColor("#000000"));
|
|
2248
|
+
try std.testing.expect(!isHexColor("df2670"));
|
|
2249
|
+
try std.testing.expect(!isHexColor("#df267"));
|
|
2250
|
+
try std.testing.expect(!isHexColor("#df26700"));
|
|
2251
|
+
try std.testing.expect(!isHexColor("#df267g"));
|
|
2252
|
+
}
|