@native-sdk/cli 0.5.0 → 0.5.2
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 +198 -13
- package/build/ts_run.mjs +58 -19
- package/build.zig +42 -0
- package/package.json +13 -9
- package/packages/core/package-lock.json +4 -3
- package/packages/core/package.json +3 -2
- package/packages/core/src/typed_ast.ts +11 -1
- package/skill-data/native-ui/SKILL.md +2 -2
- package/src/platform/types.zig +9 -0
- package/src/platform/windows/webview2_host.cpp +24 -0
- package/src/primitives/canvas/layout_audit.zig +5 -5
- package/src/primitives/canvas/root.zig +6 -0
- package/src/primitives/canvas/tokens.zig +185 -7
- package/src/primitives/canvas/ui.zig +27 -5
- package/src/primitives/canvas/ui_markup.zig +27 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +127 -0
- package/src/primitives/canvas/ui_markup_tests.zig +47 -0
- package/src/primitives/canvas/ui_markup_view.zig +10 -1
- package/src/primitives/canvas/ui_markup_view_tests.zig +78 -0
- package/src/primitives/canvas/ui_schema.zig +15 -1
- package/src/primitives/canvas/ui_schema_tests.zig +5 -4
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -5
- package/src/primitives/canvas/widget_layout.zig +142 -3
- package/src/primitives/canvas/widget_layout_tests.zig +82 -0
- package/src/primitives/canvas/widget_metrics.zig +16 -8
- package/src/primitives/canvas/widget_tree.zig +14 -2
- package/src/primitives/canvas/widgets.zig +12 -0
- package/src/runtime/automation_widget_dispatch.zig +95 -28
- package/src/runtime/canvas_frame.zig +15 -0
- package/src/runtime/canvas_widget_anchored_tests.zig +253 -65
- package/src/runtime/canvas_widget_context_menu.zig +3 -2
- package/src/runtime/canvas_widget_events.zig +1271 -3
- package/src/runtime/canvas_widget_floating_tests.zig +2801 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +1 -1
- package/src/runtime/canvas_widget_state.zig +82 -5
- package/src/runtime/core.zig +30 -0
- package/src/runtime/effects.zig +1037 -133
- package/src/runtime/effects_fetch_tests.zig +42 -0
- package/src/runtime/effects_file_tests.zig +220 -0
- package/src/runtime/effects_tests.zig +287 -0
- package/src/runtime/flow.zig +24 -1
- package/src/runtime/gpu_surface_events.zig +44 -5
- package/src/runtime/session_journal.zig +25 -13
- package/src/runtime/session_record.zig +166 -0
- package/src/runtime/session_tests.zig +453 -0
- package/src/runtime/ui_app.zig +137 -39
- package/src/runtime/ui_app_tests.zig +681 -0
- package/src/runtime/ui_app_window_tests.zig +182 -0
- package/src/runtime/view.zig +86 -0
- package/src/runtime/view_widget_text.zig +18 -1
- package/src/runtime/view_widget_tree.zig +339 -20
- package/src/runtime/widget_bridge.zig +26 -0
- package/src/runtime/window_storage.zig +61 -15
- package/src/runtime/window_view_runtime.zig +13 -0
- package/src/runtime/window_views.zig +6 -0
- package/src/tooling/package.zig +311 -8
- package/src/tooling/templates.zig +97 -9
- package/src/tooling/ts_core.zig +626 -13
- package/src/tooling/verbs.zig +88 -2
package/src/tooling/verbs.zig
CHANGED
|
@@ -64,6 +64,11 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
64
64
|
if (buildgraph.resolveFrameworkRoot(allocator, io, options.base_env) catch null) |framework_root| {
|
|
65
65
|
defer allocator.free(framework_root);
|
|
66
66
|
ts_core.selfHealEditorPackage(allocator, io, framework_root);
|
|
67
|
+
// The build graph runs the transpiler inside `zig build`; gate
|
|
68
|
+
// its toolchain resolution before any zig spawns — but ONLY
|
|
69
|
+
// for graphs the CLI itself generates (see the preflight's own
|
|
70
|
+
// doc for why ejected apps must flow past it).
|
|
71
|
+
try tsToolchainPreflight(allocator, io, ".", framework_root);
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -74,7 +79,7 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
74
79
|
defer argv.deinit(allocator);
|
|
75
80
|
try argv.appendSlice(allocator, &.{ zig_exe, "build" });
|
|
76
81
|
|
|
77
|
-
const ejected =
|
|
82
|
+
const ejected = isEjectedAt(io, ".");
|
|
78
83
|
var build_file: ?[]const u8 = null;
|
|
79
84
|
defer if (build_file) |path| allocator.free(path);
|
|
80
85
|
var prefix: ?[]const u8 = null;
|
|
@@ -123,7 +128,7 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
123
128
|
.build => {
|
|
124
129
|
if (!hasOptimizeFlag(options.forwarded_args)) {
|
|
125
130
|
// Both build shapes register -Doptimize (addApp and the
|
|
126
|
-
// expanded template
|
|
131
|
+
// expanded template each b.option it by hand).
|
|
127
132
|
try argv.append(allocator, "-Doptimize=ReleaseFast");
|
|
128
133
|
release_fast = true;
|
|
129
134
|
}
|
|
@@ -172,6 +177,33 @@ pub fn run(allocator: std.mem.Allocator, io: std.Io, verb: Verb, options: Option
|
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
179
|
|
|
180
|
+
/// The one generated-vs-ejected decision the verbs make: an app that owns
|
|
181
|
+
/// a build.zig at its root is EJECTED and the verbs drive it through plain
|
|
182
|
+
/// `zig build`; otherwise the CLI synthesizes the graph into .native/build/
|
|
183
|
+
/// (the module doc above). Named so the toolchain preflight and the argv
|
|
184
|
+
/// assembly cannot drift onto different predicates.
|
|
185
|
+
fn isEjectedAt(io: std.Io, app_root: []const u8) bool {
|
|
186
|
+
var buffer: [1024]u8 = undefined;
|
|
187
|
+
const path = std.fmt.bufPrint(&buffer, "{s}/build.zig", .{app_root}) catch return false;
|
|
188
|
+
return buildgraph.fileExists(io, path);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/// The pre-spawn TS toolchain gate, scoped to graphs the CLI generates.
|
|
192
|
+
/// Generated graphs wire `framework_root` — the CLI's own SDK — as the
|
|
193
|
+
/// app's dependency, so an unresolvable toolchain there fails HERE with
|
|
194
|
+
/// the CLI's teaching (the checkout's one `npm ci --include=dev`, or the
|
|
195
|
+
/// reinstall on an npm layout) instead of a configure-time error inside
|
|
196
|
+
/// the graph. npm-installed CLIs always resolve — the toolchain ships as
|
|
197
|
+
/// a CLI dependency. EJECTED apps own their build.zig.zon and may pin a
|
|
198
|
+
/// DIFFERENT SDK checkout than the CLI resolves, so gating the CLI's SDK
|
|
199
|
+
/// would false-fail a healthy app (direct `zig build` works); they flow
|
|
200
|
+
/// straight to the zig spawn, where build/app.zig's tsCoreStage safety
|
|
201
|
+
/// net teaches against the app's ACTUAL dependency SDK.
|
|
202
|
+
fn tsToolchainPreflight(allocator: std.mem.Allocator, io: std.Io, app_root: []const u8, framework_root: []const u8) !void {
|
|
203
|
+
if (isEjectedAt(io, app_root)) return;
|
|
204
|
+
try ts_core.ensureResolvedTranspiler(allocator, io, framework_root);
|
|
205
|
+
}
|
|
206
|
+
|
|
175
207
|
fn hasOptimizeFlag(args: []const []const u8) bool {
|
|
176
208
|
for (args) |arg| {
|
|
177
209
|
if (std.mem.startsWith(u8, arg, "-Doptimize")) return true;
|
|
@@ -218,6 +250,60 @@ fn runZig(io: std.Io, verb: Verb, argv: []const []const u8) !void {
|
|
|
218
250
|
return error.ZigBuildFailed;
|
|
219
251
|
}
|
|
220
252
|
|
|
253
|
+
test "toolchain preflight: ejected TS apps skip the CLI-SDK gate, generated ones keep it" {
|
|
254
|
+
const allocator = std.testing.allocator;
|
|
255
|
+
const io = std.testing.io;
|
|
256
|
+
var cwd = std.Io.Dir.cwd();
|
|
257
|
+
const root = ".zig-cache/test-verbs-ts-preflight";
|
|
258
|
+
const sdk = root ++ "/sdk-checkout";
|
|
259
|
+
const ejected_app = root ++ "/ejected-app";
|
|
260
|
+
const generated_app = root ++ "/generated-app";
|
|
261
|
+
cwd.deleteTree(io, root) catch {};
|
|
262
|
+
defer cwd.deleteTree(io, root) catch {};
|
|
263
|
+
|
|
264
|
+
// A CLI framework root whose toolchain is ABSENT: packages/core/test
|
|
265
|
+
// marks the checkout layout, and no node_modules ever lands — the gate
|
|
266
|
+
// teaches `npm ci --include=dev` whenever it actually runs. The pin
|
|
267
|
+
// manifest rides along: the gate reads its exact compiler pin from
|
|
268
|
+
// packages/core/package.json, which every real layout carries.
|
|
269
|
+
try cwd.createDirPath(io, sdk ++ "/packages/core/test");
|
|
270
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/package.json", .data = "{ \"name\": \"@native-sdk/core\", \"version\": \"0.0.9\", \"devDependencies\": { \"@typescript/old\": \"npm:typescript@9.9.9\" } }" });
|
|
271
|
+
|
|
272
|
+
// The ejected-shaped TS layout: an app-owned build.zig (+ build.zig.zon)
|
|
273
|
+
// at the root, src/core.ts present. Its zon may pin a DIFFERENT SDK
|
|
274
|
+
// than the CLI's, so the preflight must NOT fail on the CLI SDK's
|
|
275
|
+
// missing toolchain — the verb reaches the spawn decision, where
|
|
276
|
+
// build/app.zig's in-graph teaching names the app's actual dependency.
|
|
277
|
+
try cwd.createDirPath(io, ejected_app ++ "/src");
|
|
278
|
+
try cwd.writeFile(io, .{ .sub_path = ejected_app ++ "/build.zig", .data = "// app-owned graph" });
|
|
279
|
+
try cwd.writeFile(io, .{ .sub_path = ejected_app ++ "/build.zig.zon", .data = ".{ .dependencies = .{ .native_sdk = .{ .path = \"../elsewhere\" } } }" });
|
|
280
|
+
try cwd.writeFile(io, .{ .sub_path = ejected_app ++ "/src/core.ts", .data = "// ts core" });
|
|
281
|
+
try std.testing.expectEqual(ts_core.CoreTree.ts, ts_core.detectAt(io, ejected_app));
|
|
282
|
+
try std.testing.expect(isEjectedAt(io, ejected_app));
|
|
283
|
+
try tsToolchainPreflight(allocator, io, ejected_app, sdk);
|
|
284
|
+
|
|
285
|
+
// The generated-shaped layout (no build.zig: the CLI synthesizes the
|
|
286
|
+
// graph against ITS OWN SDK) keeps the friendly pre-spawn gate: the
|
|
287
|
+
// absent toolchain still teaches before any zig spawn.
|
|
288
|
+
try cwd.createDirPath(io, generated_app ++ "/src");
|
|
289
|
+
try cwd.writeFile(io, .{ .sub_path = generated_app ++ "/src/core.ts", .data = "// ts core" });
|
|
290
|
+
try std.testing.expect(!isEjectedAt(io, generated_app));
|
|
291
|
+
try std.testing.expectError(error.MissingTranspiler, tsToolchainPreflight(allocator, io, generated_app, sdk));
|
|
292
|
+
|
|
293
|
+
// And a resolvable CLI SDK passes the generated gate silently: land the
|
|
294
|
+
// wrapper AND the aliased real compiler it re-exports, as npm does —
|
|
295
|
+
// the compiler at the version the staged pin manifest names.
|
|
296
|
+
const toolchain_manifest = "{ \"name\": \"@typescript/typescript6\", \"version\": \"0.0.2\", \"main\": \"./lib/typescript.js\" }";
|
|
297
|
+
const compiler_manifest = "{ \"name\": \"typescript\", \"version\": \"9.9.9\", \"main\": \"./lib/typescript.js\" }";
|
|
298
|
+
try cwd.createDirPath(io, sdk ++ "/packages/core/node_modules/@typescript/typescript6/lib");
|
|
299
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/node_modules/@typescript/typescript6/package.json", .data = toolchain_manifest });
|
|
300
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/node_modules/@typescript/typescript6/lib/typescript.js", .data = "// fake wrapper" });
|
|
301
|
+
try cwd.createDirPath(io, sdk ++ "/packages/core/node_modules/@typescript/old/lib");
|
|
302
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/node_modules/@typescript/old/package.json", .data = compiler_manifest });
|
|
303
|
+
try cwd.writeFile(io, .{ .sub_path = sdk ++ "/packages/core/node_modules/@typescript/old/lib/typescript.js", .data = "// fake compiler" });
|
|
304
|
+
try tsToolchainPreflight(allocator, io, generated_app, sdk);
|
|
305
|
+
}
|
|
306
|
+
|
|
221
307
|
test "optimize flags are detected among forwarded args" {
|
|
222
308
|
try std.testing.expect(hasOptimizeFlag(&.{"-Doptimize=Debug"}));
|
|
223
309
|
try std.testing.expect(hasOptimizeFlag(&.{ "-Dautomation=true", "--release=safe" }));
|