@native-sdk/cli 0.4.2 → 0.4.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.
Files changed (46) hide show
  1. package/build/app.zig +121 -66
  2. package/build.zig +123 -6
  3. package/package.json +9 -9
  4. package/skill-data/core/SKILL.md +3 -0
  5. package/skill-data/native-ui/SKILL.md +16 -0
  6. package/skill-data/zig/SKILL.md +198 -0
  7. package/skills/native-sdk/SKILL.md +1 -1
  8. package/src/app_runner/root.zig +51 -9
  9. package/src/platform/linux/gtk_host.c +226 -21
  10. package/src/platform/windows/webview2_host.cpp +16 -10
  11. package/src/primitives/app_manifest/root.zig +8 -0
  12. package/src/primitives/app_manifest/types.zig +14 -0
  13. package/src/primitives/app_manifest/validation.zig +18 -0
  14. package/src/primitives/app_manifest/web_layer.zig +366 -0
  15. package/src/primitives/canvas/chart_tests.zig +2 -2
  16. package/src/primitives/canvas/markdown_tests.zig +1 -1
  17. package/src/primitives/canvas/reference.zig +135 -6
  18. package/src/primitives/canvas/reference_tests.zig +171 -6
  19. package/src/primitives/canvas/root.zig +3 -0
  20. package/src/primitives/canvas/test_support.zig +3 -0
  21. package/src/primitives/canvas/widget_builtin_tests.zig +249 -4
  22. package/src/primitives/canvas/widget_render_controls.zig +18 -1
  23. package/src/primitives/canvas/widget_runtime.zig +3 -0
  24. package/src/primitives/canvas/widget_text_input.zig +104 -1
  25. package/src/runtime/api.zig +7 -0
  26. package/src/runtime/bridge_responses.zig +2 -0
  27. package/src/runtime/builtin_bridge.zig +6 -0
  28. package/src/runtime/canvas_widget_runtime.zig +23 -3
  29. package/src/runtime/canvas_widget_text_tests.zig +101 -0
  30. package/src/runtime/flow.zig +8 -0
  31. package/src/runtime/platform_bridge_tests.zig +1 -0
  32. package/src/runtime/session_tests.zig +35 -8
  33. package/src/runtime/view.zig +1 -1
  34. package/src/runtime/view_widget_scroll.zig +12 -1
  35. package/src/runtime/view_widget_text.zig +6 -2
  36. package/src/runtime/web_layer_gate_tests.zig +242 -0
  37. package/src/runtime/window_storage.zig +5 -0
  38. package/src/runtime/window_view_runtime.zig +1 -0
  39. package/src/tooling/buildgraph.zig +119 -3
  40. package/src/tooling/junction.zig +247 -0
  41. package/src/tooling/manifest.zig +267 -1
  42. package/src/tooling/package.zig +598 -6
  43. package/src/tooling/raw_manifest.zig +1 -0
  44. package/src/tooling/root.zig +1 -0
  45. package/src/tooling/templates.zig +288 -61
  46. package/src/tooling/verbs.zig +5 -0
@@ -0,0 +1,242 @@
1
+ //! The runtime half of the native-only-host contract: a build whose
2
+ //! app.zon declared no web use ships without the embedded web layer
3
+ //! (`Options.web_layer = false`), and every path that would create a
4
+ //! webview fails fast with `error.WebViewLayerNotBuilt` and its teaching
5
+ //! message — never a platform call into a host whose web layer was
6
+ //! compiled out, and never a misleading not-found.
7
+
8
+ const support = @import("test_support.zig");
9
+ const std = support.std;
10
+ const geometry = support.geometry;
11
+ const app_manifest = support.app_manifest;
12
+ const automation = support.automation;
13
+ const platform = support.platform;
14
+ const App = support.App;
15
+ const Event = support.Event;
16
+ const Runtime = support.Runtime;
17
+ const TestHarness = support.TestHarness;
18
+
19
+ const teaching_needle = "built without the web layer";
20
+
21
+ /// A native-only app shape: default empty source, one canvas scene.
22
+ const canvas_scene_views = [_]app_manifest.ShellView{
23
+ .{ .label = "canvas", .kind = .gpu_surface, .fill = true },
24
+ };
25
+ const canvas_scene_windows = [_]app_manifest.ShellWindow{
26
+ .{ .label = "main", .views = &canvas_scene_views },
27
+ };
28
+
29
+ const CanvasApp = struct {
30
+ fn app(self: *@This()) App {
31
+ return .{ .context = self, .name = "native-only", .scene_fn = scene };
32
+ }
33
+
34
+ fn scene(context: *anyopaque) anyerror!app_manifest.ShellConfig {
35
+ _ = context;
36
+ return .{ .windows = &canvas_scene_windows };
37
+ }
38
+ };
39
+
40
+ test "native-only runtime starts a canvas scene and refuses webview creation with the teaching error" {
41
+ const harness = try TestHarness().create(std.testing.allocator, .{});
42
+ defer harness.destroy(std.testing.allocator);
43
+ // The null platform's gpu_surface support is opt-in; the fixture
44
+ // scene is a canvas window, so switch it on like a real host.
45
+ harness.null_platform.gpu_surfaces = true;
46
+ harness.runtime.options.web_layer = false;
47
+ var app_state: CanvasApp = .{};
48
+ try harness.start(app_state.app());
49
+
50
+ // The canvas scene booted without touching the web layer.
51
+ try std.testing.expectEqual(@as(usize, 0), harness.null_platform.webview_count);
52
+
53
+ // Direct webview view creation (the shell/bridge choke point).
54
+ try std.testing.expectError(error.WebViewLayerNotBuilt, harness.runtime.createView(.{
55
+ .window_id = 1,
56
+ .label = "preview",
57
+ .kind = .webview,
58
+ .frame = geometry.RectF.init(0, 0, 320, 240),
59
+ .url = "https://example.com",
60
+ }));
61
+
62
+ // A window whose source would materialize a main webview.
63
+ try std.testing.expectError(error.WebViewLayerNotBuilt, harness.runtime.createWindow(.{
64
+ .label = "second",
65
+ .title = "Second",
66
+ .default_frame = geometry.RectF.init(0, 0, 400, 300),
67
+ .source = platform.WebViewSource.url("https://example.com"),
68
+ }));
69
+ try std.testing.expectEqual(@as(usize, 0), harness.null_platform.webview_count);
70
+ }
71
+
72
+ test "native-only runtime answers webview bridge verbs with the teaching error" {
73
+ const harness = try TestHarness().create(std.testing.allocator, .{});
74
+ defer harness.destroy(std.testing.allocator);
75
+ harness.null_platform.gpu_surfaces = true;
76
+ harness.runtime.options.web_layer = false;
77
+ harness.runtime.options.js_window_api = true;
78
+ const origins = [_][]const u8{"zero://inline"};
79
+ harness.runtime.options.security.navigation.allowed_origins = &origins;
80
+ var app_state: CanvasApp = .{};
81
+ try harness.start(app_state.app());
82
+
83
+ try harness.runtime.dispatchPlatformEvent(app_state.app(), .{ .bridge_message = .{
84
+ .bytes = "{\"id\":\"1\",\"command\":\"native-sdk.webview.create\",\"payload\":{\"label\":\"preview\",\"url\":\"https://example.com\",\"frame\":{\"width\":300,\"height\":200}}}",
85
+ .origin = "zero://inline",
86
+ .window_id = 1,
87
+ } });
88
+ const response = harness.null_platform.lastBridgeResponse();
89
+ try std.testing.expect(std.mem.indexOf(u8, response, "\"ok\":false") != null);
90
+ try std.testing.expect(std.mem.indexOf(u8, response, teaching_needle) != null);
91
+ try std.testing.expectEqual(@as(usize, 0), harness.null_platform.webview_count);
92
+ }
93
+
94
+ test "native-only runtime fails fast when a source app reaches webview startup" {
95
+ const SourceApp = struct {
96
+ fn app(self: *@This()) App {
97
+ return .{ .context = self, .name = "source-app", .source = platform.WebViewSource.html("<p>web</p>") };
98
+ }
99
+ };
100
+
101
+ const harness = try TestHarness().create(std.testing.allocator, .{});
102
+ defer harness.destroy(std.testing.allocator);
103
+ harness.runtime.options.web_layer = false;
104
+ var app_state: SourceApp = .{};
105
+ try std.testing.expectError(error.WebViewLayerNotBuilt, harness.start(app_state.app()));
106
+ }
107
+
108
+ /// The scripted platform loop for the automation-driven session below:
109
+ /// startup, one frame, then two dropbox commands written from the loop's
110
+ /// own thread (like a driver writing while the app runs) and drained by
111
+ /// the following frames — deterministic, no watcher timing involved.
112
+ const NativeOnlyAutomationLoop = struct {
113
+ null_platform: *platform.NullPlatform,
114
+ automation_dir: []const u8,
115
+
116
+ fn run(context: *anyopaque, handler: platform.EventHandler, handler_context: *anyopaque) anyerror!void {
117
+ const self: *NativeOnlyAutomationLoop = @ptrCast(@alignCast(context));
118
+ try handler(handler_context, .app_start);
119
+ try handler(handler_context, .{ .surface_resized = self.null_platform.surface_value });
120
+ try handler(handler_context, .frame_requested);
121
+
122
+ var path_buffer: [160]u8 = undefined;
123
+ try std.Io.Dir.cwd().writeFile(std.testing.io, .{
124
+ .sub_path = try std.fmt.bufPrint(&path_buffer, "{s}/command-1.txt", .{self.automation_dir}),
125
+ .data = "menu-command probe.normal\n",
126
+ });
127
+ try std.Io.Dir.cwd().writeFile(std.testing.io, .{
128
+ .sub_path = try std.fmt.bufPrint(&path_buffer, "{s}/command-2.txt", .{self.automation_dir}),
129
+ .data = "menu-command probe.webview\n",
130
+ });
131
+ try handler(handler_context, .frame_requested);
132
+ try handler(handler_context, .frame_requested);
133
+ try handler(handler_context, .app_shutdown);
134
+ }
135
+ };
136
+
137
+ /// A native-only canvas app driven entirely through automation: a
138
+ /// normal command mutates state, and a command that tries to create a
139
+ /// webview records the gate's answer.
140
+ const NativeOnlyAutomationApp = struct {
141
+ normal_commands: usize = 0,
142
+ webview_error: ?anyerror = null,
143
+
144
+ fn scene(context: *anyopaque) anyerror!app_manifest.ShellConfig {
145
+ _ = context;
146
+ return .{ .windows = &canvas_scene_windows };
147
+ }
148
+
149
+ fn event(context: *anyopaque, runtime: *Runtime, event_value: Event) anyerror!void {
150
+ const self: *NativeOnlyAutomationApp = @ptrCast(@alignCast(context));
151
+ if (event_value != .command) return;
152
+ if (std.mem.eql(u8, event_value.command.name, "probe.normal")) {
153
+ self.normal_commands += 1;
154
+ return;
155
+ }
156
+ if (std.mem.eql(u8, event_value.command.name, "probe.webview")) {
157
+ _ = runtime.createView(.{
158
+ .window_id = 1,
159
+ .label = "preview",
160
+ .kind = .webview,
161
+ .frame = geometry.RectF.init(0, 0, 320, 240),
162
+ .url = "https://example.com",
163
+ }) catch |err| {
164
+ self.webview_error = err;
165
+ return;
166
+ };
167
+ self.webview_error = null;
168
+ }
169
+ }
170
+
171
+ fn app(self: *NativeOnlyAutomationApp) App {
172
+ return .{
173
+ .context = self,
174
+ .name = "native-only-automation",
175
+ .scene_fn = scene,
176
+ .event_fn = event,
177
+ };
178
+ }
179
+ };
180
+
181
+ test "automation drives a native-only session: commands work, webview creation teaches" {
182
+ // Pid-suffixed dropbox (this test compiles into more than one test
183
+ // binary; parallel copies must not share a directory).
184
+ var dir_buffer: [64]u8 = undefined;
185
+ const automation_dir = try automation.watcher.testDirectory(&dir_buffer, ".zig-cache/test-automation-web-layer");
186
+ var cwd = std.Io.Dir.cwd();
187
+ cwd.deleteTree(std.testing.io, automation_dir) catch {};
188
+ try cwd.createDirPath(std.testing.io, automation_dir);
189
+ defer cwd.deleteTree(std.testing.io, automation_dir) catch {};
190
+
191
+ // Heap-hosted: NullPlatform and Runtime are both multi-megabyte.
192
+ const null_platform = try std.heap.page_allocator.create(platform.NullPlatform);
193
+ defer std.heap.page_allocator.destroy(null_platform);
194
+ null_platform.* = platform.NullPlatform.init(.{});
195
+ null_platform.gpu_surfaces = true;
196
+ var loop: NativeOnlyAutomationLoop = .{ .null_platform = null_platform, .automation_dir = automation_dir };
197
+
198
+ var platform_value = null_platform.platform();
199
+ platform_value.run_fn = NativeOnlyAutomationLoop.run;
200
+ platform_value.context = &loop;
201
+
202
+ const runtime = try std.heap.page_allocator.create(Runtime);
203
+ defer std.heap.page_allocator.destroy(runtime);
204
+ Runtime.initAt(runtime, .{
205
+ .platform = platform_value,
206
+ .automation = automation.Server.init(std.testing.io, automation_dir, "WebLayerGate"),
207
+ .web_layer = false,
208
+ });
209
+
210
+ var app_state: NativeOnlyAutomationApp = .{};
211
+ try runtime.run(app_state.app());
212
+
213
+ // Normal operation: the automation-driven command reached the app.
214
+ try std.testing.expectEqual(@as(usize, 1), app_state.normal_commands);
215
+ // The automation-driven webview attempt got the teaching error, and
216
+ // no webview ever reached the platform host.
217
+ try std.testing.expectEqual(@as(?anyerror, error.WebViewLayerNotBuilt), app_state.webview_error);
218
+ try std.testing.expectEqual(@as(usize, 0), null_platform.webview_count);
219
+ }
220
+
221
+ test "web-layer builds keep every webview path working (control)" {
222
+ const SourceApp = struct {
223
+ fn app(self: *@This()) App {
224
+ return .{ .context = self, .name = "source-app", .source = platform.WebViewSource.html("<p>web</p>") };
225
+ }
226
+ };
227
+
228
+ const harness = try TestHarness().create(std.testing.allocator, .{});
229
+ defer harness.destroy(std.testing.allocator);
230
+ var app_state: SourceApp = .{};
231
+ try harness.start(app_state.app());
232
+ const webview_origins = [_][]const u8{"https://example.com"};
233
+ harness.runtime.options.security.navigation.allowed_origins = &webview_origins;
234
+ _ = try harness.runtime.createView(.{
235
+ .window_id = 1,
236
+ .label = "preview",
237
+ .kind = .webview,
238
+ .frame = geometry.RectF.init(0, 0, 320, 240),
239
+ .url = "https://example.com",
240
+ });
241
+ try std.testing.expectEqual(@as(usize, 1), harness.null_platform.webview_count);
242
+ }
@@ -70,6 +70,11 @@ pub fn RuntimeWindowStorage(comptime Runtime: type) type {
70
70
  errdefer Self.removeWindowAt(self, index);
71
71
  errdefer if (native_created) self.options.platform.services.closeWindow(id) catch {};
72
72
 
73
+ // Materializing a window source means creating its main
74
+ // webview — refused before the native window exists when the
75
+ // build has no web layer, so the error names the real cause.
76
+ if (self.windows[index].source != null and !self.options.web_layer) return error.WebViewLayerNotBuilt;
77
+
73
78
  const window_options = options.windowOptions(id, self.windows[index].info.label);
74
79
  const native_info = try self.options.platform.services.createWindow(window_options);
75
80
  native_created = true;
@@ -321,6 +321,7 @@ pub fn RuntimeWindowViewRuntime(comptime Runtime: type) type {
321
321
  }
322
322
 
323
323
  pub fn createWebViewView(self: *Runtime, options: platform.ViewOptions) !platform.ViewInfo {
324
+ if (!self.options.web_layer) return error.WebViewLayerNotBuilt;
324
325
  try validateChildWebViewLabel(options.label);
325
326
  try Self.validateWebViewUrl(self, options.url);
326
327
  if (!isValidWebViewFrame(options.frame)) return error.InvalidWebViewOptions;
@@ -17,14 +17,46 @@
17
17
 
18
18
  const std = @import("std");
19
19
  const templates = @import("templates.zig");
20
+ const junction = @import("junction.zig");
20
21
 
21
22
  pub const generated_dir = ".native/build";
22
23
 
24
+ /// Where the cross-volume junction lives, relative to the app dir: a
25
+ /// directory junction `.native/sdk` -> framework root lets the generated
26
+ /// build graph reference an SDK on another Windows volume through a
27
+ /// relative zon path (`../sdk` from the `.native/build` build root), since
28
+ /// build.zig.zon rejects absolute paths and no `..` chain crosses volumes.
29
+ pub const sdk_junction_dir = ".native/sdk";
30
+ const junction_dependency_path = "../sdk";
31
+
23
32
  pub const Error = error{
24
33
  MissingFramework,
25
34
  AlreadyEjected,
35
+ CrossVolumeFramework,
36
+ };
37
+
38
+ /// How the framework path dependency reaches the zon file. Pure decision
39
+ /// over the `std.fs.path.relative` result, so the cross-volume case is
40
+ /// testable with fabricated drive-letter paths on every host.
41
+ pub const DependencyRoute = union(enum) {
42
+ /// Same volume (or any non-Windows host): the computed relative path
43
+ /// goes into the zon verbatim, exactly as before.
44
+ relative: []const u8,
45
+ /// The framework sits on another Windows volume, where no relative
46
+ /// path exists: the zon gets `../sdk` and the caller must create or
47
+ /// refresh the `.native/sdk` junction.
48
+ junction,
26
49
  };
27
50
 
51
+ pub fn routeDependencyPath(dependency_path: []const u8) DependencyRoute {
52
+ if (junction.crossesVolumes(dependency_path)) return .junction;
53
+ return .{ .relative = if (dependency_path.len == 0) "." else dependency_path };
54
+ }
55
+
56
+ /// The two user-level ways out when the junction bridge is unavailable
57
+ /// (appended to every cross-volume teaching error).
58
+ pub const cross_volume_ways_out = junction.cross_volume_ways_out;
59
+
28
60
  /// Where the `native_sdk` framework checkout lives, for wiring the path
29
61
  /// dependency of a generated or ejected build graph. Resolution order:
30
62
  /// 1. NATIVE_SDK_PATH environment variable (explicit override; the npm
@@ -35,7 +67,13 @@ pub fn resolveFrameworkRoot(allocator: std.mem.Allocator, io: std.Io, env_map: *
35
67
  if (env_map.get("NATIVE_SDK_PATH")) |path| {
36
68
  if (path.len > 0 and hasFrameworkRoot(allocator, io, path)) {
37
69
  if (std.fs.path.isAbsolute(path)) return try allocator.dupe(u8, path);
38
- return try std.Io.Dir.cwd().realPathFileAlloc(io, path, allocator);
70
+ // realPathFileAlloc returns a sentinel-terminated allocation
71
+ // (length + 1 bytes); this function's contract is a plain
72
+ // slice the caller frees, so re-dupe without the sentinel or
73
+ // that free is off by one byte.
74
+ const real_path = try std.Io.Dir.cwd().realPathFileAlloc(io, path, allocator);
75
+ defer allocator.free(real_path);
76
+ return try allocator.dupe(u8, real_path);
39
77
  }
40
78
  }
41
79
 
@@ -112,9 +150,40 @@ pub fn ensureGeneratedBuild(allocator: std.mem.Allocator, io: std.Io, app_dir: [
112
150
  const dependency_path = try std.fs.path.relative(allocator, cwd, null, gen_real, framework_real);
113
151
  defer allocator.free(dependency_path);
114
152
 
153
+ const zon_dependency_path: []const u8 = switch (routeDependencyPath(dependency_path)) {
154
+ .relative => |path| path,
155
+ .junction => bridge: {
156
+ // Cross-volume (drive letters or UNC shares): wire the zon
157
+ // through a `.native/sdk` junction instead of the absolute
158
+ // path Zig rejects. Refreshed on every generation, so an SDK
159
+ // that moved or was reinstalled elsewhere is retargeted here.
160
+ const native_dir_real = std.fs.path.dirname(gen_real).?;
161
+ const app_real = std.fs.path.dirname(native_dir_real) orelse native_dir_real;
162
+ const junction_path = try std.fs.path.join(allocator, &.{ native_dir_real, "sdk" });
163
+ defer allocator.free(junction_path);
164
+ junction.ensure(allocator, io, junction_path, framework_real) catch |err| switch (err) {
165
+ error.OutOfMemory, error.Canceled => |e| return e,
166
+ else => {
167
+ std.debug.print(
168
+ \\cannot wire this app to the Native SDK: the app ({s})
169
+ \\and the SDK ({s})
170
+ \\sit on different Windows volumes, and build.zig.zon path
171
+ \\dependencies must be relative — no relative path crosses
172
+ \\volumes. The CLI bridges that with a directory junction at
173
+ \\{s}, but creating it failed ({t}).
174
+ \\
175
+ , .{ app_real, framework_real, sdk_junction_dir, err });
176
+ std.debug.print(cross_volume_ways_out, .{});
177
+ return error.CrossVolumeFramework;
178
+ },
179
+ };
180
+ break :bridge junction_dependency_path;
181
+ },
182
+ };
183
+
115
184
  const build_zig = try renderBuildZig(allocator, options.app_name, .generated);
116
185
  defer allocator.free(build_zig);
117
- const build_zon = try renderBuildZon(allocator, options.app_name, if (dependency_path.len == 0) "." else dependency_path, .generated);
186
+ const build_zon = try renderBuildZon(allocator, options.app_name, zon_dependency_path, .generated);
118
187
  defer allocator.free(build_zon);
119
188
 
120
189
  var dir = try std.Io.Dir.cwd().openDir(io, gen_path, .{});
@@ -149,9 +218,30 @@ pub fn eject(allocator: std.mem.Allocator, io: std.Io, app_dir: []const u8, opti
149
218
  const dependency_path = try std.fs.path.relative(allocator, cwd, null, app_real, framework_real);
150
219
  defer allocator.free(dependency_path);
151
220
 
221
+ const zon_dependency_path: []const u8 = switch (routeDependencyPath(dependency_path)) {
222
+ .relative => |path| path,
223
+ // No junction bridge for eject: the ejected build belongs to the
224
+ // user and is driven by plain `zig build`, so the CLI would never
225
+ // refresh a `.native/sdk` junction again — it would silently rot
226
+ // the first time the SDK moves. Teach the constraint instead.
227
+ .junction => {
228
+ std.debug.print(
229
+ \\cannot eject: the app ({s})
230
+ \\and the Native SDK ({s})
231
+ \\sit on different Windows volumes, and the ejected
232
+ \\build.zig.zon needs a relative SDK path — no relative path
233
+ \\crosses volumes, and an ejected build is user-owned, so the
234
+ \\CLI cannot keep a junction bridge fresh for it.
235
+ \\
236
+ , .{ app_real, framework_real });
237
+ std.debug.print(cross_volume_ways_out, .{});
238
+ return error.CrossVolumeFramework;
239
+ },
240
+ };
241
+
152
242
  const build_zig = try renderBuildZig(allocator, options.app_name, .ejected);
153
243
  defer allocator.free(build_zig);
154
- const build_zon = try renderBuildZon(allocator, options.app_name, if (dependency_path.len == 0) "." else dependency_path, .ejected);
244
+ const build_zon = try renderBuildZon(allocator, options.app_name, zon_dependency_path, .ejected);
155
245
  defer allocator.free(build_zon);
156
246
 
157
247
  try dir.writeFile(io, .{ .sub_path = "build.zig", .data = build_zig });
@@ -283,6 +373,32 @@ test "generated build.zig.zon wires the framework path dependency" {
283
373
  try std.testing.expect(std.mem.indexOf(u8, text, ".paths = .{ \"build.zig\", \"build.zig.zon\" }") != null);
284
374
  }
285
375
 
376
+ test "dependency routing keeps relative paths and bridges cross-volume ones" {
377
+ // Same volume (and every non-Windows host): verbatim, zero change.
378
+ try std.testing.expectEqualStrings("../../../framework", routeDependencyPath("../../../framework").relative);
379
+ try std.testing.expectEqualStrings("..\\..\\sdk", routeDependencyPath("..\\..\\sdk").relative);
380
+ // Build root == framework root: relative() returns "", the zon gets ".".
381
+ try std.testing.expectEqualStrings(".", routeDependencyPath("").relative);
382
+ // Cross-volume: std.fs.path.relative degrades to the absolute target
383
+ // (drive letters or UNC shares), which must route through the junction.
384
+ try std.testing.expect(routeDependencyPath("C:\\Users\\alpha\\AppData\\Roaming\\npm\\node_modules\\@native-sdk\\cli") == .junction);
385
+ try std.testing.expect(routeDependencyPath("\\\\server\\share\\native-sdk") == .junction);
386
+ }
387
+
388
+ test "the junction route renders a relative zon path through .native/sdk" {
389
+ const text = try renderBuildZon(std.testing.allocator, "my-app", junction_dependency_path, .generated);
390
+ defer std.testing.allocator.free(text);
391
+ try std.testing.expect(std.mem.indexOf(u8, text, ".native_sdk = .{ .path = \"../sdk\" }") != null);
392
+ // Never an absolute path in the zon, junction route included.
393
+ try std.testing.expect(std.mem.indexOf(u8, text, ".path = \"C:") == null);
394
+ try std.testing.expect(std.mem.indexOf(u8, text, ".path = \"\\\\") == null);
395
+ }
396
+
397
+ test "the cross-volume teaching text names both user-level ways out" {
398
+ try std.testing.expect(std.mem.indexOf(u8, cross_volume_ways_out, "same volume") != null);
399
+ try std.testing.expect(std.mem.indexOf(u8, cross_volume_ways_out, "npm config set prefix") != null);
400
+ }
401
+
286
402
  /// Path equality where '/' in the expected value also matches the
287
403
  /// platform separator, so tests written with forward slashes hold on
288
404
  /// Windows (where std.fs.path.join emits backslashes).