@native-sdk/cli 0.4.1 → 0.4.3
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/assets/native-sdk.manifest +17 -1
- package/build/app.zig +40 -1
- package/build.zig +49 -3
- package/package.json +10 -9
- package/src/platform/macos/appkit_host.m +21 -6
- package/src/platform/windows/webview2_host.cpp +377 -72
- package/src/primitives/canvas/chart.zig +8 -7
- package/src/primitives/canvas/chart_tests.zig +2 -2
- package/src/primitives/canvas/commands.zig +27 -0
- package/src/primitives/canvas/gpu.zig +8 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -1
- package/src/primitives/canvas/reference.zig +215 -7
- package/src/primitives/canvas/reference_tests.zig +326 -7
- package/src/primitives/canvas/root.zig +3 -0
- package/src/primitives/canvas/serialization.zig +16 -3
- package/src/primitives/canvas/test_support.zig +3 -0
- package/src/primitives/canvas/themes/geist.zig +6 -0
- package/src/primitives/canvas/tokens.zig +7 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +439 -3
- package/src/primitives/canvas/widget_render.zig +29 -41
- package/src/primitives/canvas/widget_render_controls.zig +73 -43
- package/src/primitives/canvas/widget_render_style.zig +53 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +19 -18
- package/src/primitives/canvas/widget_runtime.zig +3 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +20 -21
- package/src/primitives/canvas/widget_text_input.zig +104 -1
- package/src/runtime/canvas_frame_packet_tests.zig +9 -1
- package/src/runtime/canvas_frame_patch_tests.zig +39 -1
- package/src/runtime/canvas_widget_control_tests.zig +4 -4
- package/src/runtime/canvas_widget_runtime.zig +23 -3
- package/src/runtime/canvas_widget_text_tests.zig +101 -0
- package/src/runtime/ui_app.zig +78 -10
- package/src/runtime/ui_app_tests.zig +109 -0
- package/src/runtime/ui_app_window_tests.zig +93 -0
- package/src/runtime/view.zig +1 -1
- package/src/runtime/view_widget_scroll.zig +12 -1
- package/src/runtime/view_widget_text.zig +6 -2
- package/src/tooling/buildgraph.zig +112 -2
- package/src/tooling/junction.zig +247 -0
- package/src/tooling/package.zig +45 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +102 -2
- package/third_party/webview2/LICENSE.txt +27 -0
- package/third_party/webview2/README.md +19 -0
- package/third_party/webview2/arm64/WebView2Loader.dll +0 -0
- package/third_party/webview2/include/EventToken.h +12 -0
- package/third_party/webview2/include/WebView2.h +60636 -0
- package/third_party/webview2/x64/WebView2Loader.dll +0 -0
package/src/runtime/ui_app.zig
CHANGED
|
@@ -659,6 +659,15 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
659
659
|
on_close: ?MsgT = null,
|
|
660
660
|
installed: bool = false,
|
|
661
661
|
canvas_size: geometry.SizeF = .{ .width = 1, .height = 1 },
|
|
662
|
+
/// The device scale of THIS window's surface, adopted from
|
|
663
|
+
/// its own frame and resize events. Secondary windows can sit
|
|
664
|
+
/// on a different-density monitor than the main canvas, so
|
|
665
|
+
/// the scale is per-window state: the app owns ONE appearance,
|
|
666
|
+
/// but each slot's rebuild stamps its own scale into
|
|
667
|
+
/// `pixel_snap.scale` (`slotEffectiveTokens`) so this window's
|
|
668
|
+
/// hairlines snap against the grid it actually renders on.
|
|
669
|
+
/// The main canvas keeps its scale in `Self.pixel_snap_scale`.
|
|
670
|
+
pixel_snap_scale: f32 = 1,
|
|
662
671
|
tree: ?Ui.Tree = null,
|
|
663
672
|
arena_index: usize = 0,
|
|
664
673
|
arenas: [2]std.heap.ArenaAllocator,
|
|
@@ -1131,15 +1140,21 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1131
1140
|
/// `tokens_fn`, explicit static `tokens`, or — the default — the
|
|
1132
1141
|
/// stock theme derived from the SYSTEM appearance the runtime
|
|
1133
1142
|
/// tracks (scheme, contrast, reduced motion), so an unthemed app
|
|
1134
|
-
/// honors the OS light/dark setting live.
|
|
1135
|
-
///
|
|
1143
|
+
/// honors the OS light/dark setting live. Every path carries the
|
|
1144
|
+
/// surface scale in `pixel_snap.scale` — the app owns the
|
|
1145
|
+
/// appearance, the runtime owns the device scale — so static
|
|
1146
|
+
/// tokens snap hairlines against the real surface density too.
|
|
1136
1147
|
pub fn effectiveTokens(self: *const Self) canvas.DesignTokens {
|
|
1137
1148
|
if (self.options.tokens_fn) |tokens_fn| {
|
|
1138
1149
|
var tokens = tokens_fn(&self.model);
|
|
1139
1150
|
tokens.pixel_snap.scale = self.pixel_snap_scale;
|
|
1140
1151
|
return tokens;
|
|
1141
1152
|
}
|
|
1142
|
-
if (self.options.tokens) |static_tokens|
|
|
1153
|
+
if (self.options.tokens) |static_tokens| {
|
|
1154
|
+
var tokens = static_tokens;
|
|
1155
|
+
tokens.pixel_snap.scale = self.pixel_snap_scale;
|
|
1156
|
+
return tokens;
|
|
1157
|
+
}
|
|
1143
1158
|
var tokens = canvas.DesignTokens.theme(.{
|
|
1144
1159
|
.color_scheme = switch (self.system_appearance.color_scheme) {
|
|
1145
1160
|
.light => .light,
|
|
@@ -1153,10 +1168,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1153
1168
|
return tokens;
|
|
1154
1169
|
}
|
|
1155
1170
|
|
|
1171
|
+
/// The design tokens for a secondary window's rebuild: the same
|
|
1172
|
+
/// app-owned appearance as `effectiveTokens`, restamped with the
|
|
1173
|
+
/// SLOT's device scale. Each window snaps hairlines against its
|
|
1174
|
+
/// own monitor's grid — only the scale differs per window, never
|
|
1175
|
+
/// the appearance.
|
|
1176
|
+
fn slotEffectiveTokens(self: *const Self, slot: *const WindowSlot) canvas.DesignTokens {
|
|
1177
|
+
var tokens = self.effectiveTokens();
|
|
1178
|
+
tokens.pixel_snap.scale = slot.pixel_snap_scale;
|
|
1179
|
+
return tokens;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1156
1182
|
/// Whether the stock tokens derive from the system appearance:
|
|
1157
1183
|
/// true only when the app claims neither token override, so an
|
|
1158
|
-
/// appearance flip
|
|
1159
|
-
/// and re-render.
|
|
1184
|
+
/// appearance flip must re-derive and re-render.
|
|
1160
1185
|
fn followsSystemAppearance(self: *const Self) bool {
|
|
1161
1186
|
return self.options.tokens_fn == null and self.options.tokens == null;
|
|
1162
1187
|
}
|
|
@@ -1167,6 +1192,20 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1167
1192
|
return self.options.tokens_fn != null or self.followsSystemAppearance();
|
|
1168
1193
|
}
|
|
1169
1194
|
|
|
1195
|
+
/// Whether a rebuild must push its tokens into the runtime's
|
|
1196
|
+
/// stored copy. Derived tokens can change with any model or
|
|
1197
|
+
/// appearance input, so they always re-emit. Static tokens are
|
|
1198
|
+
/// fixed by the app, but the runtime stamps the surface scale
|
|
1199
|
+
/// onto them (`effectiveTokens`), so a stored copy holding a
|
|
1200
|
+
/// stale scale re-emits too — hairlines re-snap after a move
|
|
1201
|
+
/// between monitors — while ordinary rebuilds keep skipping the
|
|
1202
|
+
/// redundant emission.
|
|
1203
|
+
fn rebuildEmitsTokens(self: *const Self, runtime: *Runtime, window_id: platform.WindowId, canvas_label: []const u8, tokens: canvas.DesignTokens) bool {
|
|
1204
|
+
if (self.derivesTokens()) return true;
|
|
1205
|
+
const stored = runtime.canvasWidgetDesignTokens(window_id, canvas_label) catch return true;
|
|
1206
|
+
return stored.pixel_snap.scale != tokens.pixel_snap.scale;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1170
1209
|
/// Read runtime-owned widget state back into the model through the
|
|
1171
1210
|
/// optional `sync` hook.
|
|
1172
1211
|
fn syncModel(self: *Self, runtime: *Runtime, window_id: platform.WindowId) void {
|
|
@@ -1279,7 +1318,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1279
1318
|
try self.installChromeDisplayList(runtime, window_id, chrome, layout, tokens);
|
|
1280
1319
|
} else {
|
|
1281
1320
|
_ = try runtime.setCanvasWidgetLayout(window_id, self.options.canvas_label, layout);
|
|
1282
|
-
if (self.installed and self.
|
|
1321
|
+
if (self.installed and self.rebuildEmitsTokens(runtime, window_id, self.options.canvas_label, tokens)) {
|
|
1283
1322
|
_ = try runtime.emitCanvasWidgetDisplayList(window_id, self.options.canvas_label, tokens);
|
|
1284
1323
|
}
|
|
1285
1324
|
}
|
|
@@ -1732,6 +1771,10 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1732
1771
|
slot.on_close = descriptor.on_close;
|
|
1733
1772
|
slot.installed = false;
|
|
1734
1773
|
slot.canvas_size = .{ .width = descriptor.width, .height = descriptor.height };
|
|
1774
|
+
// Until this window's first frame reports its real density,
|
|
1775
|
+
// assume the main canvas's — new windows usually open on the
|
|
1776
|
+
// same monitor, and the installing frame corrects the guess.
|
|
1777
|
+
slot.pixel_snap_scale = self.pixel_snap_scale;
|
|
1735
1778
|
slot.tree = null;
|
|
1736
1779
|
slot.arena_index = 0;
|
|
1737
1780
|
self.window_slot_count += 1;
|
|
@@ -1808,7 +1851,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1808
1851
|
|
|
1809
1852
|
fn rebuildWindowSlot(self: *Self, runtime: *Runtime, slot: *WindowSlot) anyerror!void {
|
|
1810
1853
|
const window_view = self.options.window_view orelse return;
|
|
1811
|
-
const tokens = runtime.tokensWithTextMeasure(self.
|
|
1854
|
+
const tokens = runtime.tokensWithTextMeasure(self.slotEffectiveTokens(slot));
|
|
1812
1855
|
const next_index = slot.arena_index ^ 1;
|
|
1813
1856
|
_ = slot.arenas[next_index].reset(.retain_capacity);
|
|
1814
1857
|
var ui = Ui.init(slot.arenas[next_index].allocator());
|
|
@@ -1827,7 +1870,7 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
1827
1870
|
return err;
|
|
1828
1871
|
};
|
|
1829
1872
|
_ = try runtime.setCanvasWidgetLayout(slot.window_id, slot.canvasLabel(), layout);
|
|
1830
|
-
if (slot.installed and self.
|
|
1873
|
+
if (slot.installed and self.rebuildEmitsTokens(runtime, slot.window_id, slot.canvasLabel(), tokens)) {
|
|
1831
1874
|
_ = try runtime.emitCanvasWidgetDisplayList(slot.window_id, slot.canvasLabel(), tokens);
|
|
1832
1875
|
}
|
|
1833
1876
|
slot.tree = tree;
|
|
@@ -2749,7 +2792,12 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2749
2792
|
self.installed = true;
|
|
2750
2793
|
self.startMarkupWatch(runtime);
|
|
2751
2794
|
self.installStatusItem(runtime);
|
|
2752
|
-
} else if (
|
|
2795
|
+
} else if (@abs(self.pixel_snap_scale - scale) > 0.001) {
|
|
2796
|
+
// The surface moved to a different density (a drag between
|
|
2797
|
+
// monitors): EVERY token path carries the scale in
|
|
2798
|
+
// `pixel_snap.scale`, so static-token apps rebuild here
|
|
2799
|
+
// too — the re-emit inside `rebuild` re-snaps hairlines
|
|
2800
|
+
// against the new grid.
|
|
2753
2801
|
self.pixel_snap_scale = scale;
|
|
2754
2802
|
try self.rebuild(runtime, frame_event.window_id);
|
|
2755
2803
|
} else if (self.options.web_panes != null) {
|
|
@@ -2778,13 +2826,24 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2778
2826
|
fn handleWindowSlotFrame(self: *Self, runtime: *Runtime, frame_event: platform.GpuSurfaceFrameEvent) anyerror!void {
|
|
2779
2827
|
const slot = self.windowSlotByCanvasLabel(frame_event.label) orelse return;
|
|
2780
2828
|
slot.window_id = frame_event.window_id;
|
|
2829
|
+
const scale = normalizedSurfaceScale(frame_event.scale_factor);
|
|
2781
2830
|
var installing = false;
|
|
2782
2831
|
if (!slot.installed) {
|
|
2783
2832
|
installing = true;
|
|
2784
2833
|
slot.canvas_size = frame_event.size;
|
|
2834
|
+
slot.pixel_snap_scale = scale;
|
|
2785
2835
|
try self.rebuildWindowSlot(runtime, slot);
|
|
2786
|
-
_ = try runtime.emitCanvasWidgetDisplayList(slot.window_id, slot.canvasLabel(), runtime.tokensWithTextMeasure(self.
|
|
2836
|
+
_ = try runtime.emitCanvasWidgetDisplayList(slot.window_id, slot.canvasLabel(), runtime.tokensWithTextMeasure(self.slotEffectiveTokens(slot)));
|
|
2787
2837
|
slot.installed = true;
|
|
2838
|
+
} else if (@abs(slot.pixel_snap_scale - scale) > 0.001) {
|
|
2839
|
+
// THIS window moved to a different density (the main
|
|
2840
|
+
// canvas may still be on its old monitor): adopt the
|
|
2841
|
+
// slot's scale and rebuild so the re-emit inside
|
|
2842
|
+
// `rebuildWindowSlot` re-snaps this window's hairlines —
|
|
2843
|
+
// static-token apps included, because the stored copy
|
|
2844
|
+
// holds the stale scale (`rebuildEmitsTokens`).
|
|
2845
|
+
slot.pixel_snap_scale = scale;
|
|
2846
|
+
try self.rebuildWindowSlot(runtime, slot);
|
|
2788
2847
|
}
|
|
2789
2848
|
try self.presentFrame(runtime, frame_event, slot.canvasLabel(), installing);
|
|
2790
2849
|
}
|
|
@@ -2897,13 +2956,22 @@ pub fn UiAppWithFeatures(comptime ModelT: type, comptime MsgT: type, comptime fe
|
|
|
2897
2956
|
}
|
|
2898
2957
|
|
|
2899
2958
|
fn handleResize(self: *Self, runtime: *Runtime, resize_event: platform.GpuSurfaceResizeEvent) anyerror!void {
|
|
2959
|
+
// Resize events carry the surface density alongside the frame:
|
|
2960
|
+
// a move to a different-DPI monitor can arrive as a resize
|
|
2961
|
+
// whose LOGICAL size is unchanged (the OS rescales the frame),
|
|
2962
|
+
// so the scale must be adopted BEFORE the rebuild below — the
|
|
2963
|
+
// rebuild's re-emit then stamps freshly-snapped tokens, and
|
|
2964
|
+
// `rebuildEmitsTokens` sees the stored copy's stale scale and
|
|
2965
|
+
// forces the emission even when nothing else changed.
|
|
2900
2966
|
if (!std.mem.eql(u8, resize_event.label, self.options.canvas_label)) {
|
|
2901
2967
|
const slot = self.windowSlotByCanvasLabel(resize_event.label) orelse return;
|
|
2902
2968
|
slot.canvas_size = .{ .width = resize_event.frame.width, .height = resize_event.frame.height };
|
|
2969
|
+
slot.pixel_snap_scale = normalizedSurfaceScale(resize_event.scale_factor);
|
|
2903
2970
|
if (slot.installed) try self.rebuildWindowSlot(runtime, slot);
|
|
2904
2971
|
return;
|
|
2905
2972
|
}
|
|
2906
2973
|
self.canvas_size = .{ .width = resize_event.frame.width, .height = resize_event.frame.height };
|
|
2974
|
+
self.pixel_snap_scale = normalizedSurfaceScale(resize_event.scale_factor);
|
|
2907
2975
|
if (!self.installed) return;
|
|
2908
2976
|
// Fullscreen transitions resize the canvas AND flip the
|
|
2909
2977
|
// chrome overlay insets (macOS hides the titlebar band and
|
|
@@ -1044,6 +1044,115 @@ test "unthemed apps follow the system appearance live; explicit tokens opt out"
|
|
|
1044
1044
|
try std.testing.expectEqualDeep(light.colors.background, fixed_state.effectiveTokens().colors.background);
|
|
1045
1045
|
}
|
|
1046
1046
|
|
|
1047
|
+
test "static tokens carry the surface scale and re-snap on a scale change" {
|
|
1048
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1049
|
+
defer harness.destroy(std.testing.allocator);
|
|
1050
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1051
|
+
|
|
1052
|
+
// The app pins its look with static tokens (geometry snapping on,
|
|
1053
|
+
// scale 1 inside — the app never knows the monitor).
|
|
1054
|
+
var options = counterOptions();
|
|
1055
|
+
var static_tokens = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
1056
|
+
static_tokens.pixel_snap = .{ .geometry = true, .text = true };
|
|
1057
|
+
options.tokens = static_tokens;
|
|
1058
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1059
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1060
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1061
|
+
defer app_state.deinit();
|
|
1062
|
+
const app = app_state.app();
|
|
1063
|
+
try harness.start(app);
|
|
1064
|
+
|
|
1065
|
+
// Install on a 2x surface: the effective tokens are a stamped COPY —
|
|
1066
|
+
// the app owns the appearance, the runtime owns the device scale —
|
|
1067
|
+
// and the stored tokens carry the real density, so hairlines snap
|
|
1068
|
+
// against the physical grid instead of scale 1.
|
|
1069
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1070
|
+
.label = canvas_label,
|
|
1071
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1072
|
+
.scale_factor = 2,
|
|
1073
|
+
.frame_index = 1,
|
|
1074
|
+
.timestamp_ns = 1_000_000,
|
|
1075
|
+
.nonblank = true,
|
|
1076
|
+
} });
|
|
1077
|
+
try std.testing.expect(app_state.installed);
|
|
1078
|
+
try std.testing.expectEqual(@as(f32, 2), app_state.effectiveTokens().pixel_snap.scale);
|
|
1079
|
+
var stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
1080
|
+
try std.testing.expectEqual(@as(f32, 2), stored.pixel_snap.scale);
|
|
1081
|
+
try std.testing.expectEqualDeep(static_tokens.colors.background, stored.colors.background);
|
|
1082
|
+
|
|
1083
|
+
// A frame at a new density (the window dragged to a 1x monitor)
|
|
1084
|
+
// rebuilds and re-emits for a static-token app too: the stored
|
|
1085
|
+
// tokens re-snap to the new grid without any app involvement. The
|
|
1086
|
+
// model is poked directly (no dispatch) so the refreshed retained
|
|
1087
|
+
// text proves the FRAME triggered the rebuild.
|
|
1088
|
+
app_state.model.count = 5;
|
|
1089
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1090
|
+
.label = canvas_label,
|
|
1091
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1092
|
+
.scale_factor = 1,
|
|
1093
|
+
.frame_index = 2,
|
|
1094
|
+
.timestamp_ns = 2_000_000,
|
|
1095
|
+
.nonblank = true,
|
|
1096
|
+
} });
|
|
1097
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 5"));
|
|
1098
|
+
try std.testing.expectEqual(@as(f32, 1), app_state.effectiveTokens().pixel_snap.scale);
|
|
1099
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
1100
|
+
try std.testing.expectEqual(@as(f32, 1), stored.pixel_snap.scale);
|
|
1101
|
+
try std.testing.expectEqualDeep(static_tokens.colors.background, stored.colors.background);
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
test "a resize carrying a new density re-stamps and re-emits at the unchanged logical size" {
|
|
1105
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
1106
|
+
defer harness.destroy(std.testing.allocator);
|
|
1107
|
+
harness.null_platform.gpu_surfaces = true;
|
|
1108
|
+
|
|
1109
|
+
// Static tokens make this the strict case: ordinary rebuilds skip
|
|
1110
|
+
// the redundant emission, so a re-stamped stored copy below proves
|
|
1111
|
+
// the stale-scale re-emit fired.
|
|
1112
|
+
var options = counterOptions();
|
|
1113
|
+
var static_tokens = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
1114
|
+
static_tokens.pixel_snap = .{ .geometry = true, .text = true };
|
|
1115
|
+
options.tokens = static_tokens;
|
|
1116
|
+
const app_state = try std.testing.allocator.create(CounterApp);
|
|
1117
|
+
defer std.testing.allocator.destroy(app_state);
|
|
1118
|
+
app_state.* = CounterApp.init(std.heap.page_allocator, .{}, options);
|
|
1119
|
+
defer app_state.deinit();
|
|
1120
|
+
const app = app_state.app();
|
|
1121
|
+
try harness.start(app);
|
|
1122
|
+
|
|
1123
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
1124
|
+
.label = canvas_label,
|
|
1125
|
+
.size = geometry.SizeF.init(400, 300),
|
|
1126
|
+
.scale_factor = 2,
|
|
1127
|
+
.frame_index = 1,
|
|
1128
|
+
.timestamp_ns = 1_000_000,
|
|
1129
|
+
.nonblank = true,
|
|
1130
|
+
} });
|
|
1131
|
+
try std.testing.expect(app_state.installed);
|
|
1132
|
+
var stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
1133
|
+
try std.testing.expectEqual(@as(f32, 2), stored.pixel_snap.scale);
|
|
1134
|
+
|
|
1135
|
+
// A DPI-only monitor move arrives as a resize whose LOGICAL size is
|
|
1136
|
+
// unchanged — only the event's scale differs. The resize path must
|
|
1137
|
+
// adopt the density before rebuilding, and the rebuild must re-emit
|
|
1138
|
+
// even though the layout inputs are identical: without both, the
|
|
1139
|
+
// stored tokens keep snapping against the old grid until the next
|
|
1140
|
+
// input. The model is poked directly (no dispatch) so the refreshed
|
|
1141
|
+
// retained text proves the RESIZE triggered the rebuild.
|
|
1142
|
+
app_state.model.count = 7;
|
|
1143
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_resized = .{
|
|
1144
|
+
.window_id = 1,
|
|
1145
|
+
.label = canvas_label,
|
|
1146
|
+
.frame = geometry.RectF.init(0, 0, 400, 300),
|
|
1147
|
+
.scale_factor = 1,
|
|
1148
|
+
} });
|
|
1149
|
+
try std.testing.expect(try retainedTextExists(&harness.runtime, "Count 7"));
|
|
1150
|
+
try std.testing.expectEqual(@as(f32, 1), app_state.effectiveTokens().pixel_snap.scale);
|
|
1151
|
+
stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
1152
|
+
try std.testing.expectEqual(@as(f32, 1), stored.pixel_snap.scale);
|
|
1153
|
+
try std.testing.expectEqualDeep(static_tokens.colors.background, stored.colors.background);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1047
1156
|
test "markup watch polls from the reserved runtime timer" {
|
|
1048
1157
|
const io = std.testing.io;
|
|
1049
1158
|
const watch_path = ".zig-cache/ui-app-markup-watch-test.native";
|
|
@@ -309,6 +309,99 @@ test "input from the secondary window dispatches through its own tree with its w
|
|
|
309
309
|
try std.testing.expectEqual(@as(u32, 1), fixture.app_state.model.bumps);
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
+
test "each window's tokens carry its own surface density, not the main canvas's" {
|
|
313
|
+
const harness = try core.TestHarness().create(std.testing.allocator, .{ .size = geometry.SizeF.init(400, 300) });
|
|
314
|
+
defer harness.destroy(std.testing.allocator);
|
|
315
|
+
harness.null_platform.gpu_surfaces = true;
|
|
316
|
+
|
|
317
|
+
// Static tokens make this the strict case: ordinary slot rebuilds
|
|
318
|
+
// skip the redundant emission, so every re-stamped stored copy below
|
|
319
|
+
// proves the stale-scale re-emit fired for THAT window.
|
|
320
|
+
var static_tokens = canvas.DesignTokens.theme(.{ .color_scheme = .light });
|
|
321
|
+
static_tokens.pixel_snap = .{ .geometry = true, .text = true };
|
|
322
|
+
const app_state = try PanelApp.create(std.heap.page_allocator, .{
|
|
323
|
+
.name = "ui-app-panel-density",
|
|
324
|
+
.scene = panel_scene,
|
|
325
|
+
.canvas_label = canvas_label,
|
|
326
|
+
.tokens = static_tokens,
|
|
327
|
+
.update = panelUpdate,
|
|
328
|
+
.view = panelView,
|
|
329
|
+
.windows_fn = panelWindows,
|
|
330
|
+
.window_view = panelWindowView,
|
|
331
|
+
});
|
|
332
|
+
defer app_state.destroy();
|
|
333
|
+
const app = app_state.app();
|
|
334
|
+
try harness.start(app);
|
|
335
|
+
|
|
336
|
+
// Main canvas installs on a 1x monitor; the model already declares
|
|
337
|
+
// the settings window, so the installing rebuild creates it.
|
|
338
|
+
app_state.model.settings_open = true;
|
|
339
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
340
|
+
.label = canvas_label,
|
|
341
|
+
.size = geometry.SizeF.init(400, 300),
|
|
342
|
+
.scale_factor = 1,
|
|
343
|
+
.frame_index = 1,
|
|
344
|
+
.timestamp_ns = 1_000_000,
|
|
345
|
+
.nonblank = true,
|
|
346
|
+
} });
|
|
347
|
+
var buffer: [support.platform.max_windows]support.platform.WindowInfo = undefined;
|
|
348
|
+
var settings_id: support.platform.WindowId = 0;
|
|
349
|
+
for (harness.runtime.listWindows(&buffer)) |info| {
|
|
350
|
+
if (std.mem.eql(u8, info.label, settings_window_label)) settings_id = info.id;
|
|
351
|
+
}
|
|
352
|
+
try std.testing.expect(settings_id != 0);
|
|
353
|
+
|
|
354
|
+
// The settings window installs on a 2x monitor: ITS stored tokens
|
|
355
|
+
// carry 2 while the main canvas keeps 1 — the scale is per-window
|
|
356
|
+
// state, the appearance is still the app's single set.
|
|
357
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
358
|
+
.window_id = settings_id,
|
|
359
|
+
.label = settings_canvas_label,
|
|
360
|
+
.size = geometry.SizeF.init(320, 240),
|
|
361
|
+
.scale_factor = 2,
|
|
362
|
+
.frame_index = 1,
|
|
363
|
+
.timestamp_ns = 2_000_000,
|
|
364
|
+
.nonblank = true,
|
|
365
|
+
} });
|
|
366
|
+
const main_stored = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
367
|
+
try std.testing.expectEqual(@as(f32, 1), main_stored.pixel_snap.scale);
|
|
368
|
+
var slot_stored = try harness.runtime.canvasWidgetDesignTokens(settings_id, settings_canvas_label);
|
|
369
|
+
try std.testing.expectEqual(@as(f32, 2), slot_stored.pixel_snap.scale);
|
|
370
|
+
try std.testing.expectEqualDeep(static_tokens.colors.background, slot_stored.colors.background);
|
|
371
|
+
|
|
372
|
+
// Dragging the SECONDARY window to a 1x monitor re-stamps only its
|
|
373
|
+
// own tokens. The model is poked directly (no dispatch) so the
|
|
374
|
+
// refreshed slot text proves the frame triggered the slot rebuild.
|
|
375
|
+
app_state.model.bumps = 3;
|
|
376
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_frame = .{
|
|
377
|
+
.window_id = settings_id,
|
|
378
|
+
.label = settings_canvas_label,
|
|
379
|
+
.size = geometry.SizeF.init(320, 240),
|
|
380
|
+
.scale_factor = 1,
|
|
381
|
+
.frame_index = 2,
|
|
382
|
+
.timestamp_ns = 3_000_000,
|
|
383
|
+
.nonblank = true,
|
|
384
|
+
} });
|
|
385
|
+
const rebuilt = try harness.runtime.canvasWidgetLayout(settings_id, settings_canvas_label);
|
|
386
|
+
try std.testing.expect(widgetIdByText(rebuilt, .text, "bumped 3") != null);
|
|
387
|
+
slot_stored = try harness.runtime.canvasWidgetDesignTokens(settings_id, settings_canvas_label);
|
|
388
|
+
try std.testing.expectEqual(@as(f32, 1), slot_stored.pixel_snap.scale);
|
|
389
|
+
|
|
390
|
+
// A density-carrying RESIZE (the DPI-change channel on hosts that
|
|
391
|
+
// rescale the frame in place) re-stamps the slot's tokens too, even
|
|
392
|
+
// at an unchanged logical size.
|
|
393
|
+
try harness.runtime.dispatchPlatformEvent(app, .{ .gpu_surface_resized = .{
|
|
394
|
+
.window_id = settings_id,
|
|
395
|
+
.label = settings_canvas_label,
|
|
396
|
+
.frame = geometry.RectF.init(0, 0, 320, 240),
|
|
397
|
+
.scale_factor = 2,
|
|
398
|
+
} });
|
|
399
|
+
slot_stored = try harness.runtime.canvasWidgetDesignTokens(settings_id, settings_canvas_label);
|
|
400
|
+
try std.testing.expectEqual(@as(f32, 2), slot_stored.pixel_snap.scale);
|
|
401
|
+
const main_after = try harness.runtime.canvasWidgetDesignTokens(1, canvas_label);
|
|
402
|
+
try std.testing.expectEqual(@as(f32, 1), main_after.pixel_snap.scale);
|
|
403
|
+
}
|
|
404
|
+
|
|
312
405
|
// ------------------------------------------------- window-action effects
|
|
313
406
|
|
|
314
407
|
const VerbModel = struct {
|
package/src/runtime/view.zig
CHANGED
|
@@ -516,7 +516,7 @@ pub const RuntimeView = struct {
|
|
|
516
516
|
pub const stepCanvasWidgetKineticScroll = CanvasWidgetScrollMethods.stepCanvasWidgetKineticScroll;
|
|
517
517
|
pub const canvasWidgetScrollContentExtent = CanvasWidgetScrollMethods.canvasWidgetScrollContentExtent;
|
|
518
518
|
pub const translateCanvasWidgetScrollDescendants = CanvasWidgetScrollMethods.translateCanvasWidgetScrollDescendants;
|
|
519
|
-
pub const
|
|
519
|
+
pub const scrollCanvasTextInputCaretIntoView = CanvasWidgetScrollMethods.scrollCanvasTextInputCaretIntoView;
|
|
520
520
|
|
|
521
521
|
const CanvasWidgetControlMethods = view_widget_control.RuntimeViewCanvasWidgetControl(RuntimeView);
|
|
522
522
|
pub const canvasWidgetToggleAnimation = CanvasWidgetControlMethods.canvasWidgetToggleAnimation;
|
|
@@ -7,6 +7,7 @@ const canvas_widget_runtime = @import("canvas_widget_runtime.zig");
|
|
|
7
7
|
const unionRects = canvas_frame_helpers.unionRects;
|
|
8
8
|
const CanvasWidgetScrollKeyboardTarget = canvas_widget_runtime.CanvasWidgetScrollKeyboardTarget;
|
|
9
9
|
const canvasWidgetScrollableKind = canvas_widget_runtime.canvasWidgetScrollableKind;
|
|
10
|
+
const canvasWidgetSingleLineTextKind = canvas_widget_runtime.canvasWidgetSingleLineTextKind;
|
|
10
11
|
|
|
11
12
|
pub const CanvasWidgetScrollSource = enum {
|
|
12
13
|
discrete,
|
|
@@ -335,9 +336,19 @@ pub fn RuntimeViewCanvasWidgetScroll(comptime RuntimeView: type) type {
|
|
|
335
336
|
}
|
|
336
337
|
}
|
|
337
338
|
|
|
338
|
-
|
|
339
|
+
/// Keep the editable field's caret inside its visible span after
|
|
340
|
+
/// a text or caret change: textareas scroll vertically, single-
|
|
341
|
+
/// line fields horizontally — both through the widget's retained
|
|
342
|
+
/// `value` offset channel.
|
|
343
|
+
pub fn scrollCanvasTextInputCaretIntoView(self: *RuntimeView, index: usize) void {
|
|
339
344
|
if (index >= self.widget_layout_node_count) return;
|
|
340
345
|
var widget = self.widget_layout_nodes[index].widget;
|
|
346
|
+
if (canvasWidgetSingleLineTextKind(widget.kind)) {
|
|
347
|
+
const next_offset = canvas.textInputCaretVisibleScrollOffsetForWidget(widget, self.widget_tokens, widget.value);
|
|
348
|
+
if (next_offset == widget.value) return;
|
|
349
|
+
self.widget_layout_nodes[index].widget.value = next_offset;
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
341
352
|
if (widget.kind != .textarea) return;
|
|
342
353
|
|
|
343
354
|
const viewport = canvas.textInputViewportForWidget(widget, self.widget_tokens) orelse return;
|
|
@@ -37,7 +37,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
37
37
|
if (canvasWidgetTextEditUnchanged(current_state, next_state)) return null;
|
|
38
38
|
|
|
39
39
|
try self.rewriteCanvasWidgetTextStorage(index, next_state);
|
|
40
|
-
self.
|
|
40
|
+
self.scrollCanvasTextInputCaretIntoView(index);
|
|
41
41
|
const semantics = try self.widgetLayoutTree().collectSemantics(&self.widget_semantics_nodes);
|
|
42
42
|
self.widget_semantics_node_count = semantics.len;
|
|
43
43
|
self.widget_revision += 1;
|
|
@@ -98,6 +98,10 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
98
98
|
|
|
99
99
|
self.widget_layout_nodes[index].widget.text_selection = next_selection;
|
|
100
100
|
self.widget_layout_nodes[index].widget.text_composition = null;
|
|
101
|
+
// A pointer-placed caret is a caret change like any other: a
|
|
102
|
+
// drag past a scrolled single-line field's edge lands on an
|
|
103
|
+
// off-screen offset, and the field follows it.
|
|
104
|
+
if (canvasWidgetSingleLineTextKind(widget.kind)) self.scrollCanvasTextInputCaretIntoView(index);
|
|
101
105
|
try self.refreshCanvasWidgetSemantics();
|
|
102
106
|
self.widget_revision += 1;
|
|
103
107
|
return self.canvasWidgetDirtyBounds(index, widget.frame);
|
|
@@ -266,7 +270,7 @@ pub fn RuntimeViewCanvasWidgetText(comptime RuntimeView: type) type {
|
|
|
266
270
|
.selection = canvas.TextSelection.collapsed(text.len),
|
|
267
271
|
.composition = null,
|
|
268
272
|
});
|
|
269
|
-
self.
|
|
273
|
+
self.scrollCanvasTextInputCaretIntoView(index);
|
|
270
274
|
try self.refreshCanvasWidgetSemantics();
|
|
271
275
|
self.widget_revision += 1;
|
|
272
276
|
return self.canvasWidgetDirtyBounds(index, self.widget_layout_nodes[index].frame);
|
|
@@ -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
|
|
@@ -112,9 +144,40 @@ pub fn ensureGeneratedBuild(allocator: std.mem.Allocator, io: std.Io, app_dir: [
|
|
|
112
144
|
const dependency_path = try std.fs.path.relative(allocator, cwd, null, gen_real, framework_real);
|
|
113
145
|
defer allocator.free(dependency_path);
|
|
114
146
|
|
|
147
|
+
const zon_dependency_path: []const u8 = switch (routeDependencyPath(dependency_path)) {
|
|
148
|
+
.relative => |path| path,
|
|
149
|
+
.junction => bridge: {
|
|
150
|
+
// Cross-volume (drive letters or UNC shares): wire the zon
|
|
151
|
+
// through a `.native/sdk` junction instead of the absolute
|
|
152
|
+
// path Zig rejects. Refreshed on every generation, so an SDK
|
|
153
|
+
// that moved or was reinstalled elsewhere is retargeted here.
|
|
154
|
+
const native_dir_real = std.fs.path.dirname(gen_real).?;
|
|
155
|
+
const app_real = std.fs.path.dirname(native_dir_real) orelse native_dir_real;
|
|
156
|
+
const junction_path = try std.fs.path.join(allocator, &.{ native_dir_real, "sdk" });
|
|
157
|
+
defer allocator.free(junction_path);
|
|
158
|
+
junction.ensure(allocator, io, junction_path, framework_real) catch |err| switch (err) {
|
|
159
|
+
error.OutOfMemory, error.Canceled => |e| return e,
|
|
160
|
+
else => {
|
|
161
|
+
std.debug.print(
|
|
162
|
+
\\cannot wire this app to the Native SDK: the app ({s})
|
|
163
|
+
\\and the SDK ({s})
|
|
164
|
+
\\sit on different Windows volumes, and build.zig.zon path
|
|
165
|
+
\\dependencies must be relative — no relative path crosses
|
|
166
|
+
\\volumes. The CLI bridges that with a directory junction at
|
|
167
|
+
\\{s}, but creating it failed ({t}).
|
|
168
|
+
\\
|
|
169
|
+
, .{ app_real, framework_real, sdk_junction_dir, err });
|
|
170
|
+
std.debug.print(cross_volume_ways_out, .{});
|
|
171
|
+
return error.CrossVolumeFramework;
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
break :bridge junction_dependency_path;
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
115
178
|
const build_zig = try renderBuildZig(allocator, options.app_name, .generated);
|
|
116
179
|
defer allocator.free(build_zig);
|
|
117
|
-
const build_zon = try renderBuildZon(allocator, options.app_name,
|
|
180
|
+
const build_zon = try renderBuildZon(allocator, options.app_name, zon_dependency_path, .generated);
|
|
118
181
|
defer allocator.free(build_zon);
|
|
119
182
|
|
|
120
183
|
var dir = try std.Io.Dir.cwd().openDir(io, gen_path, .{});
|
|
@@ -149,9 +212,30 @@ pub fn eject(allocator: std.mem.Allocator, io: std.Io, app_dir: []const u8, opti
|
|
|
149
212
|
const dependency_path = try std.fs.path.relative(allocator, cwd, null, app_real, framework_real);
|
|
150
213
|
defer allocator.free(dependency_path);
|
|
151
214
|
|
|
215
|
+
const zon_dependency_path: []const u8 = switch (routeDependencyPath(dependency_path)) {
|
|
216
|
+
.relative => |path| path,
|
|
217
|
+
// No junction bridge for eject: the ejected build belongs to the
|
|
218
|
+
// user and is driven by plain `zig build`, so the CLI would never
|
|
219
|
+
// refresh a `.native/sdk` junction again — it would silently rot
|
|
220
|
+
// the first time the SDK moves. Teach the constraint instead.
|
|
221
|
+
.junction => {
|
|
222
|
+
std.debug.print(
|
|
223
|
+
\\cannot eject: the app ({s})
|
|
224
|
+
\\and the Native SDK ({s})
|
|
225
|
+
\\sit on different Windows volumes, and the ejected
|
|
226
|
+
\\build.zig.zon needs a relative SDK path — no relative path
|
|
227
|
+
\\crosses volumes, and an ejected build is user-owned, so the
|
|
228
|
+
\\CLI cannot keep a junction bridge fresh for it.
|
|
229
|
+
\\
|
|
230
|
+
, .{ app_real, framework_real });
|
|
231
|
+
std.debug.print(cross_volume_ways_out, .{});
|
|
232
|
+
return error.CrossVolumeFramework;
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
152
236
|
const build_zig = try renderBuildZig(allocator, options.app_name, .ejected);
|
|
153
237
|
defer allocator.free(build_zig);
|
|
154
|
-
const build_zon = try renderBuildZon(allocator, options.app_name,
|
|
238
|
+
const build_zon = try renderBuildZon(allocator, options.app_name, zon_dependency_path, .ejected);
|
|
155
239
|
defer allocator.free(build_zon);
|
|
156
240
|
|
|
157
241
|
try dir.writeFile(io, .{ .sub_path = "build.zig", .data = build_zig });
|
|
@@ -283,6 +367,32 @@ test "generated build.zig.zon wires the framework path dependency" {
|
|
|
283
367
|
try std.testing.expect(std.mem.indexOf(u8, text, ".paths = .{ \"build.zig\", \"build.zig.zon\" }") != null);
|
|
284
368
|
}
|
|
285
369
|
|
|
370
|
+
test "dependency routing keeps relative paths and bridges cross-volume ones" {
|
|
371
|
+
// Same volume (and every non-Windows host): verbatim, zero change.
|
|
372
|
+
try std.testing.expectEqualStrings("../../../framework", routeDependencyPath("../../../framework").relative);
|
|
373
|
+
try std.testing.expectEqualStrings("..\\..\\sdk", routeDependencyPath("..\\..\\sdk").relative);
|
|
374
|
+
// Build root == framework root: relative() returns "", the zon gets ".".
|
|
375
|
+
try std.testing.expectEqualStrings(".", routeDependencyPath("").relative);
|
|
376
|
+
// Cross-volume: std.fs.path.relative degrades to the absolute target
|
|
377
|
+
// (drive letters or UNC shares), which must route through the junction.
|
|
378
|
+
try std.testing.expect(routeDependencyPath("C:\\Users\\alpha\\AppData\\Roaming\\npm\\node_modules\\@native-sdk\\cli") == .junction);
|
|
379
|
+
try std.testing.expect(routeDependencyPath("\\\\server\\share\\native-sdk") == .junction);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
test "the junction route renders a relative zon path through .native/sdk" {
|
|
383
|
+
const text = try renderBuildZon(std.testing.allocator, "my-app", junction_dependency_path, .generated);
|
|
384
|
+
defer std.testing.allocator.free(text);
|
|
385
|
+
try std.testing.expect(std.mem.indexOf(u8, text, ".native_sdk = .{ .path = \"../sdk\" }") != null);
|
|
386
|
+
// Never an absolute path in the zon, junction route included.
|
|
387
|
+
try std.testing.expect(std.mem.indexOf(u8, text, ".path = \"C:") == null);
|
|
388
|
+
try std.testing.expect(std.mem.indexOf(u8, text, ".path = \"\\\\") == null);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
test "the cross-volume teaching text names both user-level ways out" {
|
|
392
|
+
try std.testing.expect(std.mem.indexOf(u8, cross_volume_ways_out, "same volume") != null);
|
|
393
|
+
try std.testing.expect(std.mem.indexOf(u8, cross_volume_ways_out, "npm config set prefix") != null);
|
|
394
|
+
}
|
|
395
|
+
|
|
286
396
|
/// Path equality where '/' in the expected value also matches the
|
|
287
397
|
/// platform separator, so tests written with forward slashes hold on
|
|
288
398
|
/// Windows (where std.fs.path.join emits backslashes).
|