@native-sdk/cli 0.9.1 → 0.9.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 +26 -9
- package/build.zig +55 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/skill-data/native-ui/SKILL.md +7 -7
- package/skill-data/ts-core/SKILL.md +1 -1
- package/src/app_runner/root.zig +93 -6
- package/src/app_runner/ts_core_main.zig +4 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +192 -40
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +154 -9
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ui_app.zig +9 -3
- package/src/runtime/ui_app_tests.zig +119 -19
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/web_engine.zig +1 -1
|
@@ -95,7 +95,10 @@ fn validateWidgetLayoutPoolBudgets(
|
|
|
95
95
|
pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
96
96
|
return struct {
|
|
97
97
|
pub fn widgetLayoutTree(self: *const RuntimeView) canvas.WidgetLayoutTree {
|
|
98
|
-
return .{
|
|
98
|
+
return .{
|
|
99
|
+
.nodes = self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
100
|
+
.root_bounds = self.widget_layout_root_bounds,
|
|
101
|
+
};
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
pub fn widgetSemantics(self: *const RuntimeView) []const canvas.WidgetSemanticsNode {
|
|
@@ -194,6 +197,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
194
197
|
}
|
|
195
198
|
if (anchored_count > canvas_limits.max_canvas_widget_anchored_per_view) return error.WidgetAnchoredSurfaceLimitReached;
|
|
196
199
|
if (layout.nodes.len > 0 and layout.nodes.ptr == self.widget_layout_nodes[0..].ptr) {
|
|
200
|
+
self.widget_layout_root_bounds = layout.root_bounds;
|
|
197
201
|
self.widget_revision += 1;
|
|
198
202
|
self.canvas_widget_layout_adoptions +%= 1;
|
|
199
203
|
return;
|
|
@@ -285,6 +289,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
285
289
|
self.canvas_widget_layout_adoptions +%= 1;
|
|
286
290
|
errdefer self.pruneCanvasWidgetHoverMsgChain();
|
|
287
291
|
self.widget_layout_node_count = 0;
|
|
292
|
+
self.widget_layout_root_bounds = layout.root_bounds;
|
|
288
293
|
self.widget_semantics_node_count = 0;
|
|
289
294
|
self.widget_text_len = 0;
|
|
290
295
|
self.widget_span_len = 0;
|
|
@@ -302,9 +307,11 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
302
307
|
self.widget_layout_node_count += 1;
|
|
303
308
|
}
|
|
304
309
|
|
|
305
|
-
clampCanvasWidgetLayoutScrollOffsets(
|
|
310
|
+
try clampCanvasWidgetLayoutScrollOffsets(
|
|
306
311
|
self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
307
312
|
self.widget_scroll_states[0..self.widget_layout_node_count],
|
|
313
|
+
self.widget_layout_root_bounds,
|
|
314
|
+
self.widget_tokens,
|
|
308
315
|
);
|
|
309
316
|
clampCanvasWidgetLayoutTextOffsets(
|
|
310
317
|
self.widget_layout_nodes[0..self.widget_layout_node_count],
|
|
@@ -495,7 +502,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
495
502
|
|
|
496
503
|
/// Escape's dismissal resolution: the nearest dismissible surface
|
|
497
504
|
/// up the focused widget's chain when something is focused, and
|
|
498
|
-
/// otherwise — or when the chain finds none — the topmost
|
|
505
|
+
/// otherwise — or when the chain finds none — the topmost painted
|
|
499
506
|
/// anchored surface in the view. The fallback is what makes
|
|
500
507
|
/// surfaces opened from NON-focusable triggers dismissible: a
|
|
501
508
|
/// text-crumb trigger takes no focus on click, so nothing is
|
|
@@ -505,7 +512,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
505
512
|
/// never dismisses a surface, not even through the fallback.
|
|
506
513
|
/// With SEVERAL surfaces anchored on one stack (the select
|
|
507
514
|
/// trigger's focus-shown tooltip floating over its open menu),
|
|
508
|
-
/// each Escape peels exactly one, topmost
|
|
515
|
+
/// each Escape peels exactly one, topmost by effective layer first —
|
|
509
516
|
/// the tooltip goes, then the menu.
|
|
510
517
|
pub fn dismissCanvasWidgetSurfaceFromEscape(self: *RuntimeView, focused_id: canvas.ObjectId) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
511
518
|
if (focused_id != 0) {
|
|
@@ -553,8 +560,20 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
553
560
|
/// double-cover those and leave the menu beneath it floating
|
|
554
561
|
/// after the user clicked away.
|
|
555
562
|
pub fn dismissCanvasWidgetSurfaceForPointerOutsideFocusedTarget(self: *RuntimeView, focused_id: canvas.ObjectId, route: []const canvas.WidgetEventRouteEntry) anyerror!?CanvasWidgetSurfaceDismissal {
|
|
556
|
-
const
|
|
557
|
-
|
|
563
|
+
const focused_surface_index = if (focused_id != 0)
|
|
564
|
+
if (self.canvasWidgetNodeIndexById(focused_id)) |focused_index|
|
|
565
|
+
canvasWidgetSurfaceIndexForTargetInScope(self, focused_index, .interactive)
|
|
566
|
+
else
|
|
567
|
+
null
|
|
568
|
+
else
|
|
569
|
+
null;
|
|
570
|
+
// A non-focusable trigger (text/icon/stack) can open an
|
|
571
|
+
// anchored menu while leaving no focus behind, and focus may
|
|
572
|
+
// also live in an unrelated branch. Match Escape's deliberate
|
|
573
|
+
// whole-view fallback, scoped to interactive surfaces so the
|
|
574
|
+
// tooltip intent machine keeps owning tooltip dismissal.
|
|
575
|
+
const surface_index = focused_surface_index orelse
|
|
576
|
+
canvasWidgetTopmostAnchoredSurfaceIndexInScope(self, .interactive) orelse return null;
|
|
558
577
|
if (self.canvasWidgetRouteDescendsFromIndex(route, surface_index)) return null;
|
|
559
578
|
// Clicking the ANCHOR region of an anchored surface (the
|
|
560
579
|
// trigger, or the stack that wraps trigger + surface) is the
|
|
@@ -713,7 +732,7 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
713
732
|
return null;
|
|
714
733
|
}
|
|
715
734
|
|
|
716
|
-
/// The topmost
|
|
735
|
+
/// The topmost visible anchored dismissible surface
|
|
717
736
|
/// whose anchor is `anchor_index`, or null.
|
|
718
737
|
pub fn canvasWidgetAnchoredDismissibleChildIndex(self: *const RuntimeView, anchor_index: usize) ?usize {
|
|
719
738
|
return canvasWidgetAnchoredChildIndexInScope(self, anchor_index, .any);
|
|
@@ -725,12 +744,17 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
725
744
|
/// menu) never masks the surface the caller asked for.
|
|
726
745
|
fn canvasWidgetAnchoredChildIndexInScope(self: *const RuntimeView, anchor_index: usize, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
727
746
|
var found: ?usize = null;
|
|
747
|
+
var found_order: ?canvas.WidgetPaintOrder = null;
|
|
728
748
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
729
749
|
if (node.parent_index != anchor_index) continue;
|
|
730
750
|
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
731
751
|
if (!canvasWidgetAnchoredSurfaceKindInScope(node.widget.kind, scope)) continue;
|
|
732
752
|
if (node.widget.semantics.hidden) continue;
|
|
733
|
-
|
|
753
|
+
const order = canvas.widgetLayoutWindowSurfaceOrder(self.widgetLayoutTree(), index, self.widget_tokens);
|
|
754
|
+
if (found_order == null or canvas.widgetPaintOrderLess(found_order.?, order)) {
|
|
755
|
+
found = index;
|
|
756
|
+
found_order = order;
|
|
757
|
+
}
|
|
734
758
|
}
|
|
735
759
|
return found;
|
|
736
760
|
}
|
|
@@ -944,18 +968,27 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
944
968
|
}
|
|
945
969
|
|
|
946
970
|
/// The topmost visible anchored dismissible surface in the whole
|
|
947
|
-
/// view — highest node index
|
|
948
|
-
/// z-pass
|
|
949
|
-
/// here is the surface the user sees on top. Ancestor-hidden
|
|
971
|
+
/// view — highest effective `(layer, node index)`, matching both
|
|
972
|
+
/// the anchored late z-pass and reverse-order hit-testing, so
|
|
973
|
+
/// "topmost" here is the surface the user sees on top. Ancestor-hidden
|
|
950
974
|
/// subtrees are skipped: a surface inside a hidden branch is not
|
|
951
975
|
/// on screen and must not swallow Escape.
|
|
952
976
|
pub fn canvasWidgetTopmostAnchoredDismissibleIndex(self: *const RuntimeView) ?usize {
|
|
977
|
+
return canvasWidgetTopmostAnchoredSurfaceIndexInScope(self, .any);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
fn canvasWidgetTopmostAnchoredSurfaceIndexInScope(self: *const RuntimeView, comptime scope: CanvasWidgetAnchoredSurfaceScope) ?usize {
|
|
953
981
|
var found: ?usize = null;
|
|
982
|
+
var found_order: ?canvas.WidgetPaintOrder = null;
|
|
954
983
|
for (self.widget_layout_nodes[0..self.widget_layout_node_count], 0..) |node, index| {
|
|
955
984
|
if (!canvas.widgetIsAnchored(node.widget)) continue;
|
|
956
|
-
if (!
|
|
985
|
+
if (!canvasWidgetAnchoredSurfaceKindInScope(node.widget.kind, scope)) continue;
|
|
957
986
|
if (canvasWidgetNodeHiddenInTree(self, index)) continue;
|
|
958
|
-
|
|
987
|
+
const order = canvas.widgetLayoutWindowSurfaceOrder(self.widgetLayoutTree(), index, self.widget_tokens);
|
|
988
|
+
if (found_order == null or canvas.widgetPaintOrderLess(found_order.?, order)) {
|
|
989
|
+
found = index;
|
|
990
|
+
found_order = order;
|
|
991
|
+
}
|
|
959
992
|
}
|
|
960
993
|
return found;
|
|
961
994
|
}
|
|
@@ -991,6 +1024,70 @@ pub fn RuntimeViewCanvasWidgetTree(comptime RuntimeView: type) type {
|
|
|
991
1024
|
return self.canvasWidgetFocusTargetInScope(surface_index, current_index, direction);
|
|
992
1025
|
}
|
|
993
1026
|
|
|
1027
|
+
/// Radio groups contribute one stop to the flat Tab order. The
|
|
1028
|
+
/// first currently reachable radio fixes that stop's authored
|
|
1029
|
+
/// position; entering retargets to the selected radio (or first
|
|
1030
|
+
/// focusable radio), while leaving resumes from the fixed stop.
|
|
1031
|
+
/// That distinction keeps nested/interleaved scopes ordered even
|
|
1032
|
+
/// when an outer group's selected radio appears after an inner
|
|
1033
|
+
/// group. Existing anchored-surface focus traps remain authoritative.
|
|
1034
|
+
pub fn canvasWidgetRovingTabTarget(
|
|
1035
|
+
self: *const RuntimeView,
|
|
1036
|
+
current_id: ?canvas.ObjectId,
|
|
1037
|
+
direction: canvas.WidgetFocusDirection,
|
|
1038
|
+
) ?canvas.WidgetFocusTarget {
|
|
1039
|
+
const layout = self.widgetLayoutTree();
|
|
1040
|
+
const current_scope = if (current_id) |id|
|
|
1041
|
+
if (self.canvasWidgetNodeIndexById(id)) |index|
|
|
1042
|
+
canvas_widget_runtime.canvasWidgetRovingTabScope(layout, index)
|
|
1043
|
+
else
|
|
1044
|
+
null
|
|
1045
|
+
else
|
|
1046
|
+
null;
|
|
1047
|
+
|
|
1048
|
+
var walk_id = current_id;
|
|
1049
|
+
if (current_scope) |scope| {
|
|
1050
|
+
if (canvas_widget_runtime.canvasWidgetRovingTabStopTarget(layout, scope)) |stop| {
|
|
1051
|
+
walk_id = stop.id;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
var attempts: usize = 0;
|
|
1055
|
+
while (attempts <= self.widget_layout_node_count) : (attempts += 1) {
|
|
1056
|
+
const target = if (walk_id) |id|
|
|
1057
|
+
self.canvasWidgetScopedFocusTarget(id, direction) orelse layout.focusTarget(walk_id, direction) orelse return null
|
|
1058
|
+
else
|
|
1059
|
+
layout.focusTarget(null, direction) orelse return null;
|
|
1060
|
+
|
|
1061
|
+
if (canvas_widget_runtime.canvasWidgetRovingTabScope(layout, target.index)) |target_scope| {
|
|
1062
|
+
// Radios after the first visible member do not create
|
|
1063
|
+
// extra flat-order stops. This also prevents a later
|
|
1064
|
+
// outer-group radio from retargeting backward across a
|
|
1065
|
+
// nested group's stop and forming a Tab cycle.
|
|
1066
|
+
const target_stop = canvas_widget_runtime.canvasWidgetRovingTabStopTarget(layout, target_scope) orelse {
|
|
1067
|
+
walk_id = target.id;
|
|
1068
|
+
continue;
|
|
1069
|
+
};
|
|
1070
|
+
if (target.id != target_stop.id) {
|
|
1071
|
+
walk_id = target.id;
|
|
1072
|
+
continue;
|
|
1073
|
+
}
|
|
1074
|
+
if (current_scope) |scope| {
|
|
1075
|
+
if (target_scope.kind == scope.kind and target_scope.index == scope.index) {
|
|
1076
|
+
walk_id = target.id;
|
|
1077
|
+
continue;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return canvas_widget_runtime.canvasWidgetRovingTabEntryTarget(layout, target_scope) orelse target;
|
|
1081
|
+
}
|
|
1082
|
+
return target;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// A trapped surface whose only focusable composite is this
|
|
1086
|
+
// radio group wraps onto the group's one entry stop.
|
|
1087
|
+
if (current_scope) |scope| return canvas_widget_runtime.canvasWidgetRovingTabEntryTarget(layout, scope);
|
|
1088
|
+
return null;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
994
1091
|
pub fn canvasWidgetFocusTargetInScope(
|
|
995
1092
|
self: *const RuntimeView,
|
|
996
1093
|
surface_index: usize,
|
|
@@ -57,6 +57,7 @@ pub fn widgetRoleName(role: canvas.WidgetRole) []const u8 {
|
|
|
57
57
|
.tab => "tab",
|
|
58
58
|
.checkbox => "checkbox",
|
|
59
59
|
.radio => "radio",
|
|
60
|
+
.radiogroup => "radiogroup",
|
|
60
61
|
.switch_control => "switch",
|
|
61
62
|
.slider => "slider",
|
|
62
63
|
.progressbar => "progressbar",
|
|
@@ -91,6 +92,7 @@ pub fn platformWidgetAccessibilityRole(role: canvas.WidgetRole) platform.WidgetA
|
|
|
91
92
|
.tab => .tab,
|
|
92
93
|
.checkbox => .checkbox,
|
|
93
94
|
.radio => .radio,
|
|
95
|
+
.radiogroup => .radiogroup,
|
|
94
96
|
.switch_control => .switch_control,
|
|
95
97
|
.slider => .slider,
|
|
96
98
|
.progressbar => .progressbar,
|
|
@@ -96,6 +96,92 @@ test "runtime creates lists focuses and closes windows" {
|
|
|
96
96
|
try std.testing.expect(!harness.runtime.windows[1].info.open);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
test "runtime-created windows restore saved frames by label" {
|
|
100
|
+
const TestApp = struct {
|
|
101
|
+
fn app(self: *@This()) App {
|
|
102
|
+
return .{ .context = self, .name = "window-restore", .source = platform.WebViewSource.html("<p>Windows</p>") };
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var tmp = std.testing.tmpDir(.{});
|
|
107
|
+
defer tmp.cleanup();
|
|
108
|
+
var state_dir_buffer: [128]u8 = undefined;
|
|
109
|
+
var state_file_buffer: [160]u8 = undefined;
|
|
110
|
+
const state_dir = try std.fmt.bufPrint(&state_dir_buffer, ".zig-cache/tmp/{s}", .{tmp.sub_path});
|
|
111
|
+
const state_file = try std.fmt.bufPrint(&state_file_buffer, "{s}/windows.zon", .{state_dir});
|
|
112
|
+
const store = window_state.Store.init(std.testing.io, state_dir, state_file);
|
|
113
|
+
const saved_frame = geometry.RectF.init(240, 180, 860, 620);
|
|
114
|
+
try store.saveWindow(.{
|
|
115
|
+
.id = 77,
|
|
116
|
+
.label = "tools",
|
|
117
|
+
.title = "Stale persisted title",
|
|
118
|
+
.frame = saved_frame,
|
|
119
|
+
});
|
|
120
|
+
try store.saveWindow(.{
|
|
121
|
+
.id = 78,
|
|
122
|
+
.label = "opted-out",
|
|
123
|
+
.frame = geometry.RectF.init(320, 240, 940, 700),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
127
|
+
defer harness.destroy(std.testing.allocator);
|
|
128
|
+
var app_state: TestApp = .{};
|
|
129
|
+
try harness.start(app_state.app());
|
|
130
|
+
harness.runtime.options.window_state_store = store;
|
|
131
|
+
|
|
132
|
+
const info = try harness.runtime.createWindow(.{
|
|
133
|
+
.label = "tools",
|
|
134
|
+
.title = "Current title",
|
|
135
|
+
.default_frame = geometry.RectF.init(40, 60, 420, 320),
|
|
136
|
+
});
|
|
137
|
+
try std.testing.expectEqual(saved_frame, info.frame);
|
|
138
|
+
try std.testing.expectEqualStrings("Current title", info.title);
|
|
139
|
+
try std.testing.expectEqual(platform.WindowInitialPlacement.restored, harness.null_platform.window_placement[1]);
|
|
140
|
+
|
|
141
|
+
const opted_out_frame = geometry.RectF.init(24, 36, 400, 300);
|
|
142
|
+
const opted_out = try harness.runtime.createWindow(.{
|
|
143
|
+
.label = "opted-out",
|
|
144
|
+
.default_frame = opted_out_frame,
|
|
145
|
+
.restore_state = false,
|
|
146
|
+
});
|
|
147
|
+
try std.testing.expectEqual(opted_out_frame, opted_out.frame);
|
|
148
|
+
try std.testing.expectEqual(platform.WindowInitialPlacement.explicit, harness.null_platform.window_placement[2]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
test "runtime-created window store miss preserves authored placement" {
|
|
152
|
+
const TestApp = struct {
|
|
153
|
+
fn app(self: *@This()) App {
|
|
154
|
+
return .{ .context = self, .name = "window-restore-miss", .source = platform.WebViewSource.html("<p>Windows</p>") };
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
var tmp = std.testing.tmpDir(.{});
|
|
159
|
+
defer tmp.cleanup();
|
|
160
|
+
var state_dir_buffer: [128]u8 = undefined;
|
|
161
|
+
var state_file_buffer: [160]u8 = undefined;
|
|
162
|
+
const state_dir = try std.fmt.bufPrint(&state_dir_buffer, ".zig-cache/tmp/{s}", .{tmp.sub_path});
|
|
163
|
+
const state_file = try std.fmt.bufPrint(&state_file_buffer, "{s}/windows.zon", .{state_dir});
|
|
164
|
+
const store = window_state.Store.init(std.testing.io, state_dir, state_file);
|
|
165
|
+
try store.saveWindow(.{
|
|
166
|
+
.label = "other-window",
|
|
167
|
+
.frame = geometry.RectF.init(300, 220, 900, 700),
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const harness = try TestHarness().create(std.testing.allocator, .{});
|
|
171
|
+
defer harness.destroy(std.testing.allocator);
|
|
172
|
+
var app_state: TestApp = .{};
|
|
173
|
+
try harness.start(app_state.app());
|
|
174
|
+
harness.runtime.options.window_state_store = store;
|
|
175
|
+
|
|
176
|
+
const authored_frame = geometry.RectF.init(80, 120, 480, 360);
|
|
177
|
+
const info = try harness.runtime.createWindow(.{
|
|
178
|
+
.label = "tools",
|
|
179
|
+
.default_frame = authored_frame,
|
|
180
|
+
});
|
|
181
|
+
try std.testing.expectEqual(authored_frame, info.frame);
|
|
182
|
+
try std.testing.expectEqual(platform.WindowInitialPlacement.explicit, harness.null_platform.window_placement[1]);
|
|
183
|
+
}
|
|
184
|
+
|
|
99
185
|
test "transparent imperative window without explicit source stays canvas-only" {
|
|
100
186
|
const TestApp = struct {
|
|
101
187
|
fn app(self: *@This()) App {
|
|
@@ -117,7 +117,22 @@ pub fn RuntimeWindowStorage(comptime Runtime: type) type {
|
|
|
117
117
|
// build has no web layer, so the error names the real cause.
|
|
118
118
|
if (self.windows[index].source != null and !self.options.web_layer) return error.WebViewLayerNotBuilt;
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
var window_options = options.windowOptions(id, self.windows[index].info.label);
|
|
121
|
+
// Startup windows are restored by the app runner before the
|
|
122
|
+
// platform exists. Windows materialized later (scene secondary
|
|
123
|
+
// windows, model-declared windows, imperative calls, and the JS
|
|
124
|
+
// bridge) first exist here, so this is the one layer that can
|
|
125
|
+
// perform their label-keyed lookup. A miss or read failure keeps
|
|
126
|
+
// the authored explicit/default placement unchanged; only an
|
|
127
|
+
// actual record can claim the `.restored` reason.
|
|
128
|
+
if (window_options.restore_state) {
|
|
129
|
+
if (self.options.window_state_store) |store| {
|
|
130
|
+
if (store.loadWindow(window_options.label, &self.window_state_read_scratch) catch null) |saved| {
|
|
131
|
+
window_options.default_frame = saved.frame;
|
|
132
|
+
window_options.initial_placement = .restored;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
121
136
|
const native_info = try self.options.platform.services.createWindow(window_options);
|
|
122
137
|
native_created = true;
|
|
123
138
|
try Self.applyNativeInfo(self, index, native_info);
|
|
@@ -244,6 +244,7 @@ pub fn RuntimeWindowViews(comptime Runtime: type) type {
|
|
|
244
244
|
.resizable = shell_window.resizable,
|
|
245
245
|
.restore_state = shell_window.restore_state,
|
|
246
246
|
.restore_policy = shellRestorePolicy(shell_window.restore_policy),
|
|
247
|
+
.initial_placement = if (shell_window.x != null or shell_window.y != null) .explicit else .default,
|
|
247
248
|
.titlebar = shell_layout.shellTitlebarStyle(shell_window.titlebar),
|
|
248
249
|
.show = shell_layout.shellWindowShowMode(shell_window),
|
|
249
250
|
.transparent = shell_window.transparent,
|
package/src/tooling/ios.zig
CHANGED
|
@@ -31,9 +31,11 @@ const toolchain = @import("toolchain.zig");
|
|
|
31
31
|
/// `ios_host` module (src/platform/ios/files.zig).
|
|
32
32
|
pub const host_source = @import("ios_host").uikit_host_m;
|
|
33
33
|
pub const host_header = @import("ios_host").native_sdk_app_h;
|
|
34
|
+
pub const host_image_fit_header = @import("ios_host").apple_image_fit_h;
|
|
34
35
|
|
|
35
36
|
pub const host_source_name = "uikit_host.m";
|
|
36
37
|
pub const host_header_name = "native_sdk_app.h";
|
|
38
|
+
pub const host_image_fit_header_name = "apple_image_fit.h";
|
|
37
39
|
|
|
38
40
|
pub const deployment_target = "15.0";
|
|
39
41
|
|
|
@@ -54,6 +56,7 @@ pub fn writeHostSources(io: std.Io, dir_path: []const u8) !void {
|
|
|
54
56
|
defer dir.close(io);
|
|
55
57
|
try dir.writeFile(io, .{ .sub_path = host_source_name, .data = host_source });
|
|
56
58
|
try dir.writeFile(io, .{ .sub_path = host_header_name, .data = host_header });
|
|
59
|
+
try dir.writeFile(io, .{ .sub_path = host_image_fit_header_name, .data = host_image_fit_header });
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
/// The iOS bundle identifier for an app.zon `id`: underscores map to
|
package/src/tooling/manifest.zig
CHANGED
|
@@ -22,7 +22,9 @@ pub const Metadata = struct {
|
|
|
22
22
|
platforms: []const []const u8 = &.{},
|
|
23
23
|
permissions: []const []const u8 = &.{},
|
|
24
24
|
capabilities: []const []const u8 = &.{},
|
|
25
|
+
dock_visible: bool = true,
|
|
25
26
|
persist: ?PersistMetadata = null,
|
|
27
|
+
images: ImagesMetadata = .{},
|
|
26
28
|
service_packages: []const ServicePackageMetadata = &.{},
|
|
27
29
|
/// Which carrier runs src/services operations: "auto", "in_process",
|
|
28
30
|
/// or "child". Validated so a typo teaches at check time.
|
|
@@ -228,6 +230,10 @@ pub const PersistMetadata = struct {
|
|
|
228
230
|
restore: PersistRestoreMetadata,
|
|
229
231
|
};
|
|
230
232
|
|
|
233
|
+
pub const ImagesMetadata = struct {
|
|
234
|
+
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
235
|
+
};
|
|
236
|
+
|
|
231
237
|
pub const PersistRestoreMetadata = struct {
|
|
232
238
|
ok: []const u8,
|
|
233
239
|
none: []const u8,
|
|
@@ -495,6 +501,10 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
495
501
|
const capabilities = parseCapabilities(allocator, metadata.capabilities) catch return .{ .ok = false, .message = "app.zon capabilities are invalid" };
|
|
496
502
|
defer allocator.free(capabilities);
|
|
497
503
|
const persist = convertPersist(metadata.persist);
|
|
504
|
+
app_manifest.validateImages(.{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes }) catch return .{
|
|
505
|
+
.ok = false,
|
|
506
|
+
.message = "app.zon images.max_image_pixel_bytes must be between 1048576 (the default) and 8388608 bytes; allocation is lazy once per used slot, up to 16 slots",
|
|
507
|
+
};
|
|
498
508
|
if (!validServicePackages(metadata.service_packages)) return .{
|
|
499
509
|
.ok = false,
|
|
500
510
|
.message = "app.zon service_packages must use safe npm names, exact X.Y.Z versions, unique names, and lowercase SHA-256 content hashes",
|
|
@@ -554,7 +564,9 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
554
564
|
.version = parseVersion(metadata.version) catch return .{ .ok = false, .message = "app.zon version is invalid" },
|
|
555
565
|
.permissions = permissions,
|
|
556
566
|
.capabilities = capabilities,
|
|
567
|
+
.dock_visible = metadata.dock_visible,
|
|
557
568
|
.persist = persist,
|
|
569
|
+
.images = .{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes },
|
|
558
570
|
.bridge = .{ .commands = bridge_commands },
|
|
559
571
|
.frontend = frontend,
|
|
560
572
|
.security = security,
|
|
@@ -573,6 +585,7 @@ pub fn validateFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8)
|
|
|
573
585
|
app_manifest.validateManifest(manifest) catch |err| return .{
|
|
574
586
|
.ok = false,
|
|
575
587
|
.message = switch (err) {
|
|
588
|
+
error.MissingTrayCapability => "app.zon dock_visible = false requires the \"tray\" capability: an accessory app has no Dock/app-switcher route back to hidden windows - add \"tray\" to .capabilities and install a status item, or keep dock_visible = true (the default)",
|
|
576
589
|
error.WebViewLayerConflict => web_layer_conflict_message,
|
|
577
590
|
else => "manifest fields failed semantic validation",
|
|
578
591
|
},
|
|
@@ -591,7 +604,7 @@ fn zonParseFailureMessage(allocator: std.mem.Allocator, source: []const u8) ?[]c
|
|
|
591
604
|
const source_z = scratch.dupeZ(u8, source) catch return null;
|
|
592
605
|
var diag: std.zon.parse.Diagnostics = .{};
|
|
593
606
|
defer diag.deinit(scratch);
|
|
594
|
-
@setEvalBranchQuota(
|
|
607
|
+
@setEvalBranchQuota(4000);
|
|
595
608
|
if (std.zon.parse.fromSliceAlloc(RawManifest, scratch, source_z, &diag, .{})) |_| {
|
|
596
609
|
return null;
|
|
597
610
|
} else |_| {
|
|
@@ -614,7 +627,7 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
|
|
|
614
627
|
defer arena.deinit();
|
|
615
628
|
const scratch = arena.allocator();
|
|
616
629
|
const source_z = try scratch.dupeZ(u8, source);
|
|
617
|
-
@setEvalBranchQuota(
|
|
630
|
+
@setEvalBranchQuota(4000);
|
|
618
631
|
const raw = try std.zon.parse.fromSliceAlloc(RawManifest, scratch, source_z, null, .{});
|
|
619
632
|
return .{
|
|
620
633
|
.id = try allocator.dupe(u8, raw.id),
|
|
@@ -628,7 +641,9 @@ pub fn parseText(allocator: std.mem.Allocator, source: []const u8) !Metadata {
|
|
|
628
641
|
.platforms = try duplicateStringList(allocator, raw.platforms),
|
|
629
642
|
.permissions = try duplicateStringList(allocator, raw.permissions),
|
|
630
643
|
.capabilities = try duplicateStringList(allocator, raw.capabilities),
|
|
644
|
+
.dock_visible = raw.dock_visible,
|
|
631
645
|
.persist = try duplicateRawPersist(allocator, raw.persist),
|
|
646
|
+
.images = .{ .max_image_pixel_bytes = raw.images.max_image_pixel_bytes },
|
|
632
647
|
.service_packages = try duplicateRawServicePackages(allocator, raw.service_packages),
|
|
633
648
|
.service_carrier = try allocator.dupe(u8, raw.service_carrier),
|
|
634
649
|
.service_pool_size = if (raw.service_pool_size == 0) null else raw.service_pool_size,
|
|
@@ -2507,6 +2522,47 @@ test "manifest metadata parser reads identity version and lists" {
|
|
|
2507
2522
|
});
|
|
2508
2523
|
}
|
|
2509
2524
|
|
|
2525
|
+
test "manifest parser reads dock visibility and defaults it to visible" {
|
|
2526
|
+
const accessory = try parseText(std.testing.allocator,
|
|
2527
|
+
\\.{
|
|
2528
|
+
\\ .id = "com.example.menu",
|
|
2529
|
+
\\ .name = "menu",
|
|
2530
|
+
\\ .version = "1.0.0",
|
|
2531
|
+
\\ .capabilities = .{"tray"},
|
|
2532
|
+
\\ .dock_visible = false,
|
|
2533
|
+
\\}
|
|
2534
|
+
);
|
|
2535
|
+
defer accessory.deinit(std.testing.allocator);
|
|
2536
|
+
try std.testing.expect(!accessory.dock_visible);
|
|
2537
|
+
|
|
2538
|
+
const regular = try parseText(std.testing.allocator,
|
|
2539
|
+
\\.{
|
|
2540
|
+
\\ .id = "com.example.regular",
|
|
2541
|
+
\\ .name = "regular",
|
|
2542
|
+
\\ .version = "1.0.0",
|
|
2543
|
+
\\}
|
|
2544
|
+
);
|
|
2545
|
+
defer regular.deinit(std.testing.allocator);
|
|
2546
|
+
try std.testing.expect(regular.dock_visible);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
test "manifest parser carries and validates registered-image budgets" {
|
|
2550
|
+
const metadata = try parseText(std.testing.allocator,
|
|
2551
|
+
\\.{
|
|
2552
|
+
\\ .id = "com.example.photos",
|
|
2553
|
+
\\ .name = "photos",
|
|
2554
|
+
\\ .version = "1.0.0",
|
|
2555
|
+
\\ .images = .{ .max_image_pixel_bytes = 8388608 },
|
|
2556
|
+
\\}
|
|
2557
|
+
);
|
|
2558
|
+
defer metadata.deinit(std.testing.allocator);
|
|
2559
|
+
try std.testing.expectEqual(@as(usize, 8 * 1024 * 1024), metadata.images.max_image_pixel_bytes);
|
|
2560
|
+
try app_manifest.validateImages(.{ .max_image_pixel_bytes = metadata.images.max_image_pixel_bytes });
|
|
2561
|
+
|
|
2562
|
+
try std.testing.expectError(error.InvalidDimension, app_manifest.validateImages(.{ .max_image_pixel_bytes = 1048575 }));
|
|
2563
|
+
try std.testing.expectError(error.InvalidDimension, app_manifest.validateImages(.{ .max_image_pixel_bytes = 8388609 }));
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2510
2566
|
test "manifest metadata parser carries model persistence configuration" {
|
|
2511
2567
|
const metadata = try parseText(std.testing.allocator,
|
|
2512
2568
|
\\.{
|
|
@@ -3270,6 +3326,38 @@ test "validate rejects a web-declaring manifest that excludes the web layer" {
|
|
|
3270
3326
|
try std.testing.expect(std.mem.indexOf(u8, invalid.message, "webview_layer is invalid") != null);
|
|
3271
3327
|
}
|
|
3272
3328
|
|
|
3329
|
+
test "validate rejects accessory startup without a tray capability" {
|
|
3330
|
+
var cwd = std.Io.Dir.cwd();
|
|
3331
|
+
const root = ".zig-cache/test-validate-accessory-tray";
|
|
3332
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
3333
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
3334
|
+
try cwd.createDirPath(std.testing.io, root);
|
|
3335
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/app.zon", .data =
|
|
3336
|
+
\\.{
|
|
3337
|
+
\\ .id = "dev.example.accessory",
|
|
3338
|
+
\\ .name = "accessory",
|
|
3339
|
+
\\ .version = "1.0.0",
|
|
3340
|
+
\\ .dock_visible = false,
|
|
3341
|
+
\\}
|
|
3342
|
+
});
|
|
3343
|
+
|
|
3344
|
+
const invalid = try validateFile(std.testing.allocator, std.testing.io, root ++ "/app.zon");
|
|
3345
|
+
try std.testing.expect(!invalid.ok);
|
|
3346
|
+
try std.testing.expect(std.mem.indexOf(u8, invalid.message, "dock_visible = false requires the \"tray\" capability") != null);
|
|
3347
|
+
|
|
3348
|
+
try cwd.writeFile(std.testing.io, .{ .sub_path = root ++ "/app.zon", .data =
|
|
3349
|
+
\\.{
|
|
3350
|
+
\\ .id = "dev.example.accessory",
|
|
3351
|
+
\\ .name = "accessory",
|
|
3352
|
+
\\ .version = "1.0.0",
|
|
3353
|
+
\\ .capabilities = .{"tray"},
|
|
3354
|
+
\\ .dock_visible = false,
|
|
3355
|
+
\\}
|
|
3356
|
+
});
|
|
3357
|
+
const valid = try validateFile(std.testing.allocator, std.testing.io, root ++ "/app.zon");
|
|
3358
|
+
try std.testing.expect(valid.ok);
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3273
3361
|
test "manifest validates the theme pack name" {
|
|
3274
3362
|
const metadata = try parseText(std.testing.allocator,
|
|
3275
3363
|
\\.{
|
package/src/tooling/package.zig
CHANGED
|
@@ -197,6 +197,15 @@ pub fn artifactName(buffer: []u8, metadata: manifest_tool.Metadata, target: Pack
|
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageOptions) !PackageStats {
|
|
200
|
+
// Keep the manifest's accessory-app safety invariant at the artifact
|
|
201
|
+
// boundary too. CLI package verbs and direct callers receive Metadata,
|
|
202
|
+
// not the typed manifest that `native validate` checks, so without this
|
|
203
|
+
// guard they could emit LSUIElement=true for an app with no status-item
|
|
204
|
+
// route back to its hidden windows.
|
|
205
|
+
if (!options.metadata.dock_visible and !metadataHasCapability(options.metadata, "tray")) {
|
|
206
|
+
std.debug.print("error: app.zon dock_visible = false requires the \"tray\" capability: an accessory app has no Dock/app-switcher route back to hidden windows - add \"tray\" to .capabilities and install a status item, or keep dock_visible = true (the default)\n", .{});
|
|
207
|
+
return error.MissingTrayCapability;
|
|
208
|
+
}
|
|
200
209
|
// The package boundary of the reject-conflicts contract: an exclude
|
|
201
210
|
// (from `--web-layer` or app.zon) against declared web content — or
|
|
202
211
|
// against a resolved Chromium engine — never becomes an artifact.
|
|
@@ -233,6 +242,13 @@ pub fn createPackage(allocator: std.mem.Allocator, io: std.Io, options: PackageO
|
|
|
233
242
|
return stats;
|
|
234
243
|
}
|
|
235
244
|
|
|
245
|
+
fn metadataHasCapability(metadata: manifest_tool.Metadata, name: []const u8) bool {
|
|
246
|
+
for (metadata.capabilities) |capability| {
|
|
247
|
+
if (std.mem.eql(u8, capability, name)) return true;
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
|
|
236
252
|
fn validateWebEngineTarget(target: PackageTarget, web_engine: WebEngine) !void {
|
|
237
253
|
if (web_engine != .chromium) return;
|
|
238
254
|
switch (target) {
|
|
@@ -503,6 +519,7 @@ fn createIosArtifact(allocator: std.mem.Allocator, io: std.Io, options: PackageO
|
|
|
503
519
|
try dir.createDirPath(io, "Host");
|
|
504
520
|
try writeFile(dir, io, "Host/" ++ ios_tool.host_source_name, ios_tool.host_source);
|
|
505
521
|
try writeFile(dir, io, "Host/" ++ ios_tool.host_header_name, ios_tool.host_header);
|
|
522
|
+
try writeFile(dir, io, "Host/" ++ ios_tool.host_image_fit_header_name, ios_tool.host_image_fit_header);
|
|
506
523
|
const info_plist = try ios_tool.infoPlistAlloc(allocator, options.metadata);
|
|
507
524
|
defer allocator.free(info_plist);
|
|
508
525
|
try writeFile(dir, io, "Host/Info.plist", info_plist);
|
|
@@ -737,6 +754,10 @@ fn macosInfoPlist(allocator: std.mem.Allocator, metadata: manifest_tool.Metadata
|
|
|
737
754
|
defer allocator.free(url_types);
|
|
738
755
|
const privacy_descriptions = try macosPrivacyUsageDescriptions(allocator, metadata);
|
|
739
756
|
defer allocator.free(privacy_descriptions);
|
|
757
|
+
const launch_policy = if (!metadata.dock_visible)
|
|
758
|
+
" <key>LSUIElement</key>\n <true/>\n"
|
|
759
|
+
else
|
|
760
|
+
"";
|
|
740
761
|
// The About panel's bottom line in packaged bundles: the manifest
|
|
741
762
|
// description rides NSHumanReadableCopyright, the plist key the
|
|
742
763
|
// standard About panel renders as its footer text — the same line
|
|
@@ -773,11 +794,11 @@ fn macosInfoPlist(allocator: std.mem.Allocator, metadata: manifest_tool.Metadata
|
|
|
773
794
|
\\ <string>{s}</string>
|
|
774
795
|
\\ <key>CFBundleVersion</key>
|
|
775
796
|
\\ <string>{s}</string>
|
|
776
|
-
\\{s}{s}{s}{s}
|
|
797
|
+
\\{s}{s}{s}{s}{s}
|
|
777
798
|
\\</dict>
|
|
778
799
|
\\</plist>
|
|
779
800
|
\\
|
|
780
|
-
, .{ bundle_id, display_name, display_name, executable, icon, version, version, about_line, privacy_descriptions, document_types, url_types });
|
|
801
|
+
, .{ bundle_id, display_name, display_name, executable, icon, version, version, launch_policy, about_line, privacy_descriptions, document_types, url_types });
|
|
781
802
|
}
|
|
782
803
|
|
|
783
804
|
fn metadataHasPermission(metadata: manifest_tool.Metadata, name: []const u8) bool {
|
|
@@ -3022,6 +3043,14 @@ test "mobile package artifacts use manifest identity metadata" {
|
|
|
3022
3043
|
const packaged_activity = try readPath(std.testing.allocator, std.testing.io, ".zig-cache/test-package-mobile-identity/android/Host/NativeSdkActivity.java");
|
|
3023
3044
|
defer std.testing.allocator.free(packaged_activity);
|
|
3024
3045
|
try std.testing.expectEqualStrings(android_tool.host_activity_source, packaged_activity);
|
|
3046
|
+
// Decode-to-fit must use ceiling-rounded power-of-two samples for
|
|
3047
|
+
// one-pixel panoramas, then enforce the axis cap only after the exact
|
|
3048
|
+
// resize. Checking the emitted host pins both the source asset and the
|
|
3049
|
+
// ordering that keeps an 8193x1 source loadable as 8192x1.
|
|
3050
|
+
try std.testing.expect(std.mem.indexOf(u8, packaged_activity, "int sampledHeight = (sourceHeight - 1) / nextSampleSize + 1;") != null);
|
|
3051
|
+
const exact_fit_index = std.mem.indexOf(u8, packaged_activity, "Bitmap fitted = Bitmap.createScaledBitmap") orelse return error.TestUnexpectedResult;
|
|
3052
|
+
const final_cap_index = std.mem.indexOf(u8, packaged_activity, "if (width > MAX_DECODED_IMAGE_DIMENSION || height > MAX_DECODED_IMAGE_DIMENSION || width > maxPixels / height)") orelse return error.TestUnexpectedResult;
|
|
3053
|
+
try std.testing.expect(exact_fit_index < final_cap_index);
|
|
3025
3054
|
const packaged_bridge = try readPath(std.testing.allocator, std.testing.io, ".zig-cache/test-package-mobile-identity/android/Host/android_host.c");
|
|
3026
3055
|
defer std.testing.allocator.free(packaged_bridge);
|
|
3027
3056
|
try std.testing.expectEqualStrings(android_tool.host_bridge_source, packaged_bridge);
|
|
@@ -3186,6 +3215,42 @@ test "plist capture usage descriptions follow manifest permissions" {
|
|
|
3186
3215
|
try std.testing.expect(std.mem.indexOf(u8, bare_plist, "NSScreenCaptureUsageDescription") == null);
|
|
3187
3216
|
}
|
|
3188
3217
|
|
|
3218
|
+
test "plist launch policy follows dock visibility" {
|
|
3219
|
+
const accessory: manifest_tool.Metadata = .{
|
|
3220
|
+
.id = "dev.example.menu",
|
|
3221
|
+
.name = "menu",
|
|
3222
|
+
.version = "1.0.0",
|
|
3223
|
+
.dock_visible = false,
|
|
3224
|
+
};
|
|
3225
|
+
const accessory_plist = try macosInfoPlist(std.testing.allocator, accessory, "menu");
|
|
3226
|
+
defer std.testing.allocator.free(accessory_plist);
|
|
3227
|
+
try std.testing.expect(std.mem.indexOf(u8, accessory_plist, "<key>LSUIElement</key>\n <true/>") != null);
|
|
3228
|
+
|
|
3229
|
+
const regular: manifest_tool.Metadata = .{ .id = "dev.example.app", .name = "demo", .version = "1.0.0" };
|
|
3230
|
+
const regular_plist = try macosInfoPlist(std.testing.allocator, regular, "demo");
|
|
3231
|
+
defer std.testing.allocator.free(regular_plist);
|
|
3232
|
+
try std.testing.expect(std.mem.indexOf(u8, regular_plist, "LSUIElement") == null);
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
test "package rejects accessory startup without a tray before staging an artifact" {
|
|
3236
|
+
var cwd = std.Io.Dir.cwd();
|
|
3237
|
+
const root = ".zig-cache/test-package-accessory-tray";
|
|
3238
|
+
try cwd.deleteTree(std.testing.io, root);
|
|
3239
|
+
defer cwd.deleteTree(std.testing.io, root) catch {};
|
|
3240
|
+
|
|
3241
|
+
try std.testing.expectError(error.MissingTrayCapability, createPackage(std.testing.allocator, std.testing.io, .{
|
|
3242
|
+
.metadata = .{
|
|
3243
|
+
.id = "dev.example.stranded",
|
|
3244
|
+
.name = "stranded",
|
|
3245
|
+
.version = "1.0.0",
|
|
3246
|
+
.dock_visible = false,
|
|
3247
|
+
},
|
|
3248
|
+
.target = .macos,
|
|
3249
|
+
.output_path = root ++ "/Stranded.app",
|
|
3250
|
+
}));
|
|
3251
|
+
try std.testing.expectError(error.FileNotFound, cwd.openDir(std.testing.io, root ++ "/Stranded.app", .{}));
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3189
3254
|
test "plist template includes document and URL registrations" {
|
|
3190
3255
|
const extensions = [_][]const u8{ "md", ".markdown" };
|
|
3191
3256
|
const mime_types = [_][]const u8{"text/markdown"};
|