@native-sdk/cli 0.9.0 → 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 +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- 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 +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- 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 +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- 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 +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- 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 +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -55,13 +55,14 @@ pub fn hitTestWidgetLayout(layout: anytype, point: geometry.PointF, tokens: Desi
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
pub fn hitTestWidgetLayoutWithPolicy(layout: anytype, point: geometry.PointF, tokens: DesignTokens, comptime policy: HitTestPolicy) ?WidgetHit {
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
// Window-level surfaces paint in the late z-pass — topmost — so they
|
|
59
|
+
// hit-test FIRST, in reverse window-surface paint order.
|
|
60
|
+
const surface_count = widget_tree.widgetLayoutWindowSurfaceCount(layout);
|
|
61
|
+
var tested: usize = 0;
|
|
62
|
+
var previous: ?widget_tree.WidgetPaintOrder = null;
|
|
63
|
+
while (tested < surface_count) : (tested += 1) {
|
|
64
|
+
const index = widget_tree.previousWidgetLayoutWindowSurface(layout, tokens, previous) orelse break;
|
|
65
|
+
previous = widget_tree.widgetLayoutWindowSurfaceOrder(layout, index, tokens);
|
|
65
66
|
if (isWidgetHiddenInAncestors(layout, index)) continue;
|
|
66
67
|
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) continue;
|
|
67
68
|
if (hitTestWidgetLayoutNode(layout, index, point, tokens, policy)) |hit| return hit;
|
|
@@ -75,9 +76,9 @@ fn hitTestWidgetLayoutChildren(layout: anytype, parent_index: ?usize, point: geo
|
|
|
75
76
|
var previous: ?widget_tree.WidgetPaintOrder = null;
|
|
76
77
|
while (tested < child_count) : (tested += 1) {
|
|
77
78
|
const child_index = widget_tree.previousWidgetLayoutPaintChild(layout, parent_index, tokens, previous) orelse return null;
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
if (!widget_tree.
|
|
79
|
+
// Window-level surfaces live in the hoisted pre-pass above, never
|
|
80
|
+
// at their tree position.
|
|
81
|
+
if (!widget_tree.widgetEscapesAncestorClips(layout.nodes[child_index].widget)) {
|
|
81
82
|
if (hitTestWidgetLayoutNode(layout, child_index, point, tokens, policy)) |hit| return hit;
|
|
82
83
|
}
|
|
83
84
|
previous = .{ .layer = widget_tree.widgetPaintLayer(layout.nodes[child_index].widget, tokens), .index = child_index };
|
|
@@ -131,7 +132,7 @@ fn widgetHitFromNode(node: WidgetLayoutNode, index: usize) WidgetHit {
|
|
|
131
132
|
/// claims presses (`widgetClaimsPress`). Plain text, icons, decorations,
|
|
132
133
|
/// and layout containers let the press fall through; interactive kinds,
|
|
133
134
|
/// editable text, scroll containers, overlay surfaces, and any widget
|
|
134
|
-
/// with a bound press/toggle handler stop the walk. Returns null when
|
|
135
|
+
/// with a bound press/toggle/drag handler stop the walk. Returns null when
|
|
135
136
|
/// nothing on the path claims — the press dispatches to no one, exactly
|
|
136
137
|
/// like a click on dead space.
|
|
137
138
|
pub fn widgetPressTargetIndexFromNode(layout: anytype, node_index: usize) ?usize {
|
|
@@ -234,9 +235,9 @@ pub fn widgetWindowDragTargetIndexFromNode(layout: anytype, node_index: usize) ?
|
|
|
234
235
|
fn isPointVisibleInWidgetAncestors(layout: anytype, node_index: usize, point: geometry.PointF) bool {
|
|
235
236
|
var current: usize = node_index;
|
|
236
237
|
while (true) {
|
|
237
|
-
//
|
|
238
|
-
//
|
|
239
|
-
if (widget_tree.
|
|
238
|
+
// A window-level surface escapes its ancestors' clip regions, so
|
|
239
|
+
// the walk stops here.
|
|
240
|
+
if (widget_tree.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
|
|
240
241
|
const parent_index = layout.nodes[current].parent_index orelse return true;
|
|
241
242
|
if (parent_index >= layout.nodes.len) return true;
|
|
242
243
|
const parent = layout.nodes[parent_index];
|
|
@@ -251,10 +252,9 @@ fn isWidgetFrameVisibleInWidgetAncestors(layout: anytype, node_index: usize) boo
|
|
|
251
252
|
if (frame.isEmpty()) return false;
|
|
252
253
|
var current: usize = node_index;
|
|
253
254
|
while (true) {
|
|
254
|
-
//
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
if (widget_tree.widgetIsAnchored(layout.nodes[current].widget)) return true;
|
|
255
|
+
// Window-level surfaces escape ancestor clips, keeping their focus
|
|
256
|
+
// targets live outside the authored container's bounds.
|
|
257
|
+
if (widget_tree.widgetEscapesAncestorClips(layout.nodes[current].widget)) return true;
|
|
258
258
|
const parent_index = layout.nodes[current].parent_index orelse return true;
|
|
259
259
|
if (parent_index >= layout.nodes.len) return true;
|
|
260
260
|
const parent = layout.nodes[parent_index];
|
|
@@ -413,6 +413,26 @@ pub fn focusWidgetTargetById(layout: anytype, id: ObjectId, scroll_semantics_fn:
|
|
|
413
413
|
return focusTargetFromLayoutNode(layout, index, scroll_semantics_fn);
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
/// Resolve every ordinary focus gate except ancestor geometry. Runtime
|
|
417
|
+
/// reveal paths use this to name a clipped target before scrolling it, while
|
|
418
|
+
/// keeping the exact same hidden, disclosure, disabled, and scroll-semantic
|
|
419
|
+
/// eligibility as `focusWidgetTargetById`.
|
|
420
|
+
pub fn logicalFocusWidgetTargetAtIndex(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
421
|
+
if (index >= layout.nodes.len) return null;
|
|
422
|
+
if (isWidgetHiddenInAncestors(layout, index)) return null;
|
|
423
|
+
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return null;
|
|
424
|
+
const node = layout.nodes[index];
|
|
425
|
+
if (node.widget.id == 0) return null;
|
|
426
|
+
if (!widget_access.isFocusable(node.widget) and (node.widget.state.disabled or !scroll_semantics_fn(layout, index).scrollable)) return null;
|
|
427
|
+
return .{
|
|
428
|
+
.id = node.widget.id,
|
|
429
|
+
.kind = node.widget.kind,
|
|
430
|
+
.bounds = node.frame,
|
|
431
|
+
.index = index,
|
|
432
|
+
.state = node.widget.state,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
416
436
|
fn focusForward(layout: anytype, current_index: ?usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
417
437
|
var index: usize = if (current_index) |value| value + 1 else 0;
|
|
418
438
|
while (index < layout.nodes.len) : (index += 1) {
|
|
@@ -466,23 +486,9 @@ fn focusSpatial(layout: anytype, current_index: usize, direction: WidgetFocusDir
|
|
|
466
486
|
}
|
|
467
487
|
|
|
468
488
|
fn focusTargetFromLayoutNode(layout: anytype, index: usize, scroll_semantics_fn: anytype) ?WidgetFocusTarget {
|
|
469
|
-
|
|
470
|
-
if (isWidgetHiddenInAncestors(layout, index)) return null;
|
|
471
|
-
// Concealed disclosure content never joins the focus order: a
|
|
472
|
-
// closed section's controls are unreachable by tab or arrows, and
|
|
473
|
-
// mid-reveal content stays unreachable until the reveal settles.
|
|
474
|
-
if (widget_tree.isWidgetConcealedByDisclosure(layout, index)) return null;
|
|
489
|
+
const target = logicalFocusWidgetTargetAtIndex(layout, index, scroll_semantics_fn) orelse return null;
|
|
475
490
|
if (!isWidgetFrameVisibleInWidgetAncestors(layout, index)) return null;
|
|
476
|
-
|
|
477
|
-
if (node.widget.id == 0) return null;
|
|
478
|
-
if (!widget_access.isFocusable(node.widget) and (node.widget.state.disabled or !scroll_semantics_fn(layout, index).scrollable)) return null;
|
|
479
|
-
return .{
|
|
480
|
-
.id = node.widget.id,
|
|
481
|
-
.kind = node.widget.kind,
|
|
482
|
-
.bounds = node.frame,
|
|
483
|
-
.index = index,
|
|
484
|
-
.state = node.widget.state,
|
|
485
|
-
};
|
|
491
|
+
return target;
|
|
486
492
|
}
|
|
487
493
|
|
|
488
494
|
fn spatialFocusCandidate(
|
|
@@ -60,6 +60,10 @@ pub const textGeometryForWidget = widget_text_input.textGeometryForWidget;
|
|
|
60
60
|
|
|
61
61
|
pub const WidgetLayoutTree = struct {
|
|
62
62
|
nodes: []const WidgetLayoutNode = &.{},
|
|
63
|
+
/// Viewport bounds that produced the layout. Kept on the tree instead
|
|
64
|
+
/// of every node so root-authored modals retain their window-space
|
|
65
|
+
/// contract without widening the hot node array.
|
|
66
|
+
root_bounds: ?geometry.RectF = null,
|
|
63
67
|
|
|
64
68
|
pub fn nodeCount(self: WidgetLayoutTree) usize {
|
|
65
69
|
return self.nodes.len;
|
|
@@ -158,6 +162,10 @@ pub const WidgetLayoutTree = struct {
|
|
|
158
162
|
return widget_routing.focusWidgetTargetById(self, id, widgetScrollSemantics);
|
|
159
163
|
}
|
|
160
164
|
|
|
165
|
+
pub fn logicalFocusTargetAtIndex(self: WidgetLayoutTree, index: usize) ?WidgetFocusTarget {
|
|
166
|
+
return widget_routing.logicalFocusWidgetTargetAtIndex(self, index, widgetScrollSemantics);
|
|
167
|
+
}
|
|
168
|
+
|
|
161
169
|
pub fn collectSemantics(self: WidgetLayoutTree, output: []WidgetSemanticsNode) Error![]const WidgetSemanticsNode {
|
|
162
170
|
return collectWidgetSemantics(self, output);
|
|
163
171
|
}
|
|
@@ -201,9 +209,10 @@ pub fn layoutWidgetTree(widget: Widget, bounds: geometry.RectF, output: []Widget
|
|
|
201
209
|
}
|
|
202
210
|
|
|
203
211
|
pub fn layoutWidgetTreeWithTokens(widget: Widget, bounds: geometry.RectF, tokens: DesignTokens, output: []WidgetLayoutNode) Error!WidgetLayoutTree {
|
|
212
|
+
const root_bounds = bounds.normalized();
|
|
204
213
|
var len: usize = 0;
|
|
205
|
-
_ = try widget_layout.layoutWidgetDepth(widget,
|
|
206
|
-
return .{ .nodes = output[0..len] };
|
|
214
|
+
_ = try widget_layout.layoutWidgetDepth(widget, root_bounds, null, 0, output, &len, tokens);
|
|
215
|
+
return .{ .nodes = output[0..len], .root_bounds = root_bounds };
|
|
207
216
|
}
|
|
208
217
|
|
|
209
218
|
pub fn intrinsicWidgetSize(widget: Widget, tokens: DesignTokens) geometry.SizeF {
|
|
@@ -1750,11 +1750,13 @@ test "widget emitter applies button variants" {
|
|
|
1750
1750
|
try emitWidgetTree(&builder, .{ .id = 23, .kind = .button, .frame = geometry.RectF.init(0, 120, 120, 32), .text = "Ghost", .variant = .ghost }, tokens);
|
|
1751
1751
|
try emitWidgetTree(&builder, .{ .id = 24, .kind = .button, .frame = geometry.RectF.init(0, 160, 120, 32), .text = "Delete", .variant = .destructive }, tokens);
|
|
1752
1752
|
|
|
1753
|
-
// Every variant is FLAT (no shadow command):
|
|
1754
|
-
//
|
|
1755
|
-
//
|
|
1753
|
+
// Every variant is FLAT (no shadow command): primary, secondary, and
|
|
1754
|
+
// outline each emit fill + border + label; borderless ghost and
|
|
1755
|
+
// destructive each emit only fill + label. Destructive is the quiet
|
|
1756
|
+
// red chip — the destructive hue as a 10% wash under destructive-red
|
|
1757
|
+
// text. No dead zero-width stroke commands enter the list.
|
|
1756
1758
|
const display_list = builder.displayList();
|
|
1757
|
-
try std.testing.expectEqual(@as(usize,
|
|
1759
|
+
try std.testing.expectEqual(@as(usize, 13), display_list.commandCount());
|
|
1758
1760
|
switch (display_list.commands[0]) {
|
|
1759
1761
|
.fill_rounded_rect => |fill| try expectFillColor(tokens.colors.accent, fill.fill),
|
|
1760
1762
|
else => return error.TestUnexpectedResult,
|
|
@@ -1775,19 +1777,13 @@ test "widget emitter applies button variants" {
|
|
|
1775
1777
|
.fill_rounded_rect => |fill| try expectFillColor(transparentColor(), fill.fill),
|
|
1776
1778
|
else => return error.TestUnexpectedResult,
|
|
1777
1779
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
else => return error.TestUnexpectedResult,
|
|
1781
|
-
}
|
|
1782
|
-
switch (display_list.commands[12]) {
|
|
1780
|
+
try std.testing.expect(display_list.findCommandById(widgetPartId(23, 2)) == null);
|
|
1781
|
+
switch (display_list.commands[11]) {
|
|
1783
1782
|
.fill_rounded_rect => |fill| try expectFillColor(colorWithAlpha(tokens.colors.destructive, 0.10), fill.fill),
|
|
1784
1783
|
else => return error.TestUnexpectedResult,
|
|
1785
1784
|
}
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
else => return error.TestUnexpectedResult,
|
|
1789
|
-
}
|
|
1790
|
-
switch (display_list.commands[14]) {
|
|
1785
|
+
try std.testing.expect(display_list.findCommandById(widgetPartId(24, 2)) == null);
|
|
1786
|
+
switch (display_list.commands[12]) {
|
|
1791
1787
|
.draw_text => |text| try std.testing.expectEqualDeep(tokens.colors.destructive, text.color),
|
|
1792
1788
|
else => return error.TestUnexpectedResult,
|
|
1793
1789
|
}
|
|
@@ -114,7 +114,8 @@ fn nearestSemanticParent(stack: []const ?usize) ?usize {
|
|
|
114
114
|
pub fn semanticRole(widget: Widget) WidgetRole {
|
|
115
115
|
if (widget.semantics.role != .none) return widget.semantics.role;
|
|
116
116
|
return switch (widget.kind) {
|
|
117
|
-
.stack, .row, .column, .grid, .scroll_view, .breadcrumb, .button_group, .pagination, .
|
|
117
|
+
.stack, .row, .column, .grid, .scroll_view, .breadcrumb, .button_group, .pagination, .tabs, .toggle_group, .accordion, .bubble, .resizable, .alert, .card, .panel => .group,
|
|
118
|
+
.radio_group => .radiogroup,
|
|
118
119
|
.data_grid, .table => .grid,
|
|
119
120
|
.data_row => .row,
|
|
120
121
|
.dialog, .drawer, .sheet, .popover => .dialog,
|
|
@@ -519,6 +520,10 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
|
|
|
519
520
|
var index = scroll_index + 1;
|
|
520
521
|
while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
|
|
521
522
|
const node = layout.nodes[index];
|
|
523
|
+
if (widget_tree.widgetIsRootRelativeModal(node.widget)) {
|
|
524
|
+
index = skipSubtree(layout, index);
|
|
525
|
+
continue;
|
|
526
|
+
}
|
|
522
527
|
// A subtree anchored DIRECTLY to the scroll region stays
|
|
523
528
|
// stationary under scrolling (its anchor base never moves), so
|
|
524
529
|
// `frame + offset` is not a content-space position for it —
|
|
@@ -551,7 +556,7 @@ fn widgetScrollContentExtent(layout: anytype, scroll_index: usize, viewport: geo
|
|
|
551
556
|
/// The horizontal content reach for a horizontal scroll view's
|
|
552
557
|
/// semantics — the sideways mirror of `widgetScrollContentExtent`, with
|
|
553
558
|
/// the honest-range exclusions the engine's clamp/driver walker applies
|
|
554
|
-
/// (`canvasWidgetLayoutScrollContentExtentX`):
|
|
559
|
+
/// (`canvasWidgetLayoutScrollContentExtentX`): window-level floating
|
|
555
560
|
/// subtrees are out of flow, a nested clip scope bounds its own
|
|
556
561
|
/// children, and disclosure content counts only while settled open.
|
|
557
562
|
fn widgetScrollContentExtentX(layout: anytype, scroll_index: usize, viewport: geometry.RectF) f32 {
|
|
@@ -562,7 +567,7 @@ fn widgetScrollContentExtentX(layout: anytype, scroll_index: usize, viewport: ge
|
|
|
562
567
|
var index = scroll_index + 1;
|
|
563
568
|
while (index < layout.nodes.len and layout.nodes[index].depth > scroll_depth) {
|
|
564
569
|
const node = layout.nodes[index];
|
|
565
|
-
if (node.widget
|
|
570
|
+
if (widget_tree.widgetEscapesAncestorClips(node.widget)) {
|
|
566
571
|
index = skipSubtree(layout, index);
|
|
567
572
|
continue;
|
|
568
573
|
}
|
|
@@ -2083,10 +2083,14 @@ test "text editing affordance colors resolve tokens and per-widget overrides" {
|
|
|
2083
2083
|
try std.testing.expectEqual(Color.rgb8(4, 5, 6).r, styled_wash.r);
|
|
2084
2084
|
try std.testing.expectApproxEqAbs(@as(f32, 0.3), styled_wash.a, 0.001);
|
|
2085
2085
|
|
|
2086
|
-
// A disabled field
|
|
2086
|
+
// A disabled field keeps its resolved text identity at the shared
|
|
2087
|
+
// disabled-wash strength instead of swapping to a flat gray.
|
|
2087
2088
|
var disabled = field;
|
|
2088
2089
|
disabled.state.disabled = true;
|
|
2089
|
-
try std.testing.expectEqualDeep(
|
|
2090
|
+
try std.testing.expectEqualDeep(
|
|
2091
|
+
Color.rgba(tokens.colors.text.r, tokens.colors.text.g, tokens.colors.text.b, tokens.states.disabled_alpha),
|
|
2092
|
+
textEditingInkColor(disabled, tokens),
|
|
2093
|
+
);
|
|
2090
2094
|
}
|
|
2091
2095
|
|
|
2092
2096
|
test "widget text fields render wrapped selection geometry" {
|
|
@@ -17,12 +17,70 @@ pub const WidgetPaintOrder = struct {
|
|
|
17
17
|
pub fn widgetPaintLayer(widget: Widget, tokens: DesignTokens) i32 {
|
|
18
18
|
if (widget.layer) |layer| return layer;
|
|
19
19
|
return switch (widget.kind) {
|
|
20
|
+
.dialog, .drawer, .sheet => tokens.layer.modal,
|
|
20
21
|
.popover, .menu_surface, .dropdown_menu => tokens.layer.overlay,
|
|
21
22
|
.tooltip => tokens.layer.floating,
|
|
22
23
|
else => tokens.layer.base,
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
/// Window-surface ordering keeps anchored siblings in their established
|
|
28
|
+
/// mount-order stack while lifting root-relative modals into the modal token
|
|
29
|
+
/// stratum. An explicit widget layer always wins. Anchored tooltip/menu
|
|
30
|
+
/// coexistence deliberately shares the overlay stratum here: their late-pass
|
|
31
|
+
/// contract is last-mounted-on-top even though their ordinary in-tree token
|
|
32
|
+
/// defaults differ.
|
|
33
|
+
pub fn widgetWindowSurfaceLayer(widget: Widget, tokens: DesignTokens) i32 {
|
|
34
|
+
if (widget.layer) |layer| return layer;
|
|
35
|
+
if (widgetIsRootRelativeModal(widget)) return tokens.layer.modal;
|
|
36
|
+
if (widgetIsAnchored(widget)) return tokens.layer.overlay;
|
|
37
|
+
return widgetPaintLayer(widget, tokens);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// Effective layer of a hoisted window surface in a laid tree. A surface
|
|
41
|
+
/// without an explicit layer cannot fall beneath the window surface that
|
|
42
|
+
/// contains it: a default dropdown/tooltip opened inside a modal therefore
|
|
43
|
+
/// stays in the modal stratum, while an explicitly authored layer remains an
|
|
44
|
+
/// intentional escape hatch.
|
|
45
|
+
pub fn widgetLayoutWindowSurfaceLayer(layout: anytype, node_index: usize, tokens: DesignTokens) i32 {
|
|
46
|
+
const node = layout.nodes[node_index];
|
|
47
|
+
if (node.widget.layer) |layer| return layer;
|
|
48
|
+
|
|
49
|
+
var layer = widgetWindowSurfaceLayer(node.widget, tokens);
|
|
50
|
+
var current = node.parent_index;
|
|
51
|
+
while (current) |index| {
|
|
52
|
+
if (index >= layout.nodes.len) break;
|
|
53
|
+
const ancestor = layout.nodes[index];
|
|
54
|
+
if (widgetEscapesAncestorClips(ancestor.widget)) {
|
|
55
|
+
layer = @max(layer, widgetWindowSurfaceLayer(ancestor.widget, tokens));
|
|
56
|
+
}
|
|
57
|
+
current = ancestor.parent_index;
|
|
58
|
+
}
|
|
59
|
+
return layer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
pub fn widgetLayoutWindowSurfaceOrder(layout: anytype, node_index: usize, tokens: DesignTokens) WidgetPaintOrder {
|
|
63
|
+
return .{
|
|
64
|
+
.layer = widgetLayoutWindowSurfaceLayer(layout, node_index, tokens),
|
|
65
|
+
.index = node_index,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Modal surfaces are placed in layout-root coordinates and never ride an
|
|
70
|
+
/// ancestor scroll region's content translation.
|
|
71
|
+
pub fn widgetIsRootRelativeModal(widget: Widget) bool {
|
|
72
|
+
return switch (widget.kind) {
|
|
73
|
+
.dialog, .drawer, .sheet => true,
|
|
74
|
+
else => false,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/// Surfaces whose layout, paint, routing, and visibility are resolved at
|
|
79
|
+
/// the window level rather than through their authored ancestor clips.
|
|
80
|
+
pub fn widgetEscapesAncestorClips(widget: Widget) bool {
|
|
81
|
+
return widgetIsAnchored(widget) or widgetIsRootRelativeModal(widget);
|
|
82
|
+
}
|
|
83
|
+
|
|
26
84
|
pub fn nextWidgetPaintChild(children: []const Widget, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
|
|
27
85
|
var best: ?WidgetPaintOrder = null;
|
|
28
86
|
for (children, 0..) |child, index| {
|
|
@@ -63,6 +121,36 @@ pub fn previousWidgetLayoutPaintChild(layout: anytype, parent_index: ?usize, tok
|
|
|
63
121
|
return if (best) |order| order.index else null;
|
|
64
122
|
}
|
|
65
123
|
|
|
124
|
+
pub inline fn widgetLayoutWindowSurfaceCount(layout: anytype) usize {
|
|
125
|
+
var count: usize = 0;
|
|
126
|
+
for (layout.nodes) |node| {
|
|
127
|
+
if (widgetEscapesAncestorClips(node.widget)) count += 1;
|
|
128
|
+
}
|
|
129
|
+
return count;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pub fn nextWidgetLayoutWindowSurface(layout: anytype, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
|
|
133
|
+
var best: ?WidgetPaintOrder = null;
|
|
134
|
+
for (layout.nodes, 0..) |node, index| {
|
|
135
|
+
if (!widgetEscapesAncestorClips(node.widget)) continue;
|
|
136
|
+
const order = widgetLayoutWindowSurfaceOrder(layout, index, tokens);
|
|
137
|
+
if (!widgetPaintOrderAfter(order, previous)) continue;
|
|
138
|
+
if (best == null or widgetPaintOrderLess(order, best.?)) best = order;
|
|
139
|
+
}
|
|
140
|
+
return if (best) |order| order.index else null;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pub fn previousWidgetLayoutWindowSurface(layout: anytype, tokens: DesignTokens, previous: ?WidgetPaintOrder) ?usize {
|
|
144
|
+
var best: ?WidgetPaintOrder = null;
|
|
145
|
+
for (layout.nodes, 0..) |node, index| {
|
|
146
|
+
if (!widgetEscapesAncestorClips(node.widget)) continue;
|
|
147
|
+
const order = widgetLayoutWindowSurfaceOrder(layout, index, tokens);
|
|
148
|
+
if (!widgetPaintOrderBefore(order, previous)) continue;
|
|
149
|
+
if (best == null or widgetPaintOrderLess(best.?, order)) best = order;
|
|
150
|
+
}
|
|
151
|
+
return if (best) |order| order.index else null;
|
|
152
|
+
}
|
|
153
|
+
|
|
66
154
|
fn widgetPaintOrderAfter(order: WidgetPaintOrder, previous: ?WidgetPaintOrder) bool {
|
|
67
155
|
const value = previous orelse return true;
|
|
68
156
|
return order.layer > value.layer or (order.layer == value.layer and order.index > value.index);
|
|
@@ -73,7 +161,7 @@ fn widgetPaintOrderBefore(order: WidgetPaintOrder, previous: ?WidgetPaintOrder)
|
|
|
73
161
|
return order.layer < value.layer or (order.layer == value.layer and order.index < value.index);
|
|
74
162
|
}
|
|
75
163
|
|
|
76
|
-
fn widgetPaintOrderLess(a: WidgetPaintOrder, b: WidgetPaintOrder) bool {
|
|
164
|
+
pub fn widgetPaintOrderLess(a: WidgetPaintOrder, b: WidgetPaintOrder) bool {
|
|
77
165
|
return a.layer < b.layer or (a.layer == b.layer and a.index < b.index);
|
|
78
166
|
}
|
|
79
167
|
|
|
@@ -186,16 +274,22 @@ pub fn widgetKindDisclosureAnimated(kind: widget_model.WidgetKind) bool {
|
|
|
186
274
|
const disclosure_settle_slack: f32 = 0.5;
|
|
187
275
|
|
|
188
276
|
/// The bottom edge the disclosure widget's content REACHES: the deepest
|
|
189
|
-
/// maxY among its in-flow children's subtrees.
|
|
190
|
-
/// outside the flow
|
|
277
|
+
/// maxY among its in-flow children's subtrees. Window-level surfaces float
|
|
278
|
+
/// outside the flow and never count.
|
|
191
279
|
pub fn disclosureContentBottom(layout: anytype, node_index: usize) f32 {
|
|
192
280
|
const node = layout.nodes[node_index];
|
|
193
281
|
var bottom = -std.math.inf(f32);
|
|
194
282
|
var index = node_index + 1;
|
|
195
|
-
while (index < layout.nodes.len and layout.nodes[index].depth > node.depth)
|
|
283
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > node.depth) {
|
|
196
284
|
const child = layout.nodes[index];
|
|
197
|
-
if (
|
|
285
|
+
if (widgetEscapesAncestorClips(child.widget)) {
|
|
286
|
+
const subtree_depth = child.depth;
|
|
287
|
+
index += 1;
|
|
288
|
+
while (index < layout.nodes.len and layout.nodes[index].depth > subtree_depth) : (index += 1) {}
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
198
291
|
bottom = @max(bottom, child.frame.normalized().maxY());
|
|
292
|
+
index += 1;
|
|
199
293
|
}
|
|
200
294
|
return bottom;
|
|
201
295
|
}
|
|
@@ -577,6 +577,8 @@ pub const WidgetRole = enum {
|
|
|
577
577
|
tab,
|
|
578
578
|
checkbox,
|
|
579
579
|
radio,
|
|
580
|
+
/// A single-choice group containing descendant radio controls.
|
|
581
|
+
radiogroup,
|
|
580
582
|
switch_control,
|
|
581
583
|
slider,
|
|
582
584
|
progressbar,
|
|
@@ -743,7 +745,7 @@ pub fn builtinComponentDescriptor(kind: BuiltinComponentKind) BuiltinComponentDe
|
|
|
743
745
|
.input => builtinComponent(.input, .input, .textbox, false),
|
|
744
746
|
.pagination => builtinComponent(.pagination, .pagination, .group, true),
|
|
745
747
|
.progress => builtinComponent(.progress, .progress, .progressbar, false),
|
|
746
|
-
.radio_group => builtinComponent(.radio_group, .radio_group, .
|
|
748
|
+
.radio_group => builtinComponent(.radio_group, .radio_group, .radiogroup, true),
|
|
747
749
|
.resizable => builtinComponent(.resizable, .resizable, .group, true),
|
|
748
750
|
.select => builtinComponent(.select, .select, .button, true),
|
|
749
751
|
.separator => builtinComponent(.separator, .separator, .none, false),
|
|
@@ -1040,9 +1042,8 @@ pub const Widget = struct {
|
|
|
1040
1042
|
layer: ?i32 = null,
|
|
1041
1043
|
/// Modal surfaces (dialog/drawer/sheet) paint a token-driven scrim
|
|
1042
1044
|
/// (dim + backdrop blur) across the whole tree behind them. False
|
|
1043
|
-
/// opts
|
|
1044
|
-
///
|
|
1045
|
-
/// actually modal. Ignored on every other kind.
|
|
1045
|
+
/// opts out of the scrim for a non-modal specimen; placement remains
|
|
1046
|
+
/// root-relative. Ignored on every other kind.
|
|
1046
1047
|
scrim: bool = true,
|
|
1047
1048
|
state: WidgetState = .{},
|
|
1048
1049
|
layout: WidgetLayoutStyle = .{},
|
|
@@ -1210,8 +1211,8 @@ pub const BuiltinComponentOptions = struct {
|
|
|
1210
1211
|
text_composition: ?TextRange = null,
|
|
1211
1212
|
value: f32 = 0,
|
|
1212
1213
|
layer: ?i32 = null,
|
|
1213
|
-
/// See `Widget.scrim`: false
|
|
1214
|
-
///
|
|
1214
|
+
/// See `Widget.scrim`: false keeps root-relative placement but omits
|
|
1215
|
+
/// the behind-it dim + blur.
|
|
1215
1216
|
scrim: bool = true,
|
|
1216
1217
|
state: WidgetState = .{},
|
|
1217
1218
|
layout: WidgetLayoutStyle = .{},
|
|
@@ -1509,6 +1510,18 @@ fn builtinComponentSemantics(descriptor: BuiltinComponentDescriptor, semantics:
|
|
|
1509
1510
|
/// concentric with the container's at every position.
|
|
1510
1511
|
pub const tabs_list_inset: f32 = 3;
|
|
1511
1512
|
|
|
1513
|
+
/// Additive control-size step shared by token-backed chrome metrics and
|
|
1514
|
+
/// token-independent kind defaults. The default alert inset uses the
|
|
1515
|
+
/// house 16px base / 2px step here; runtime token packs feed their own
|
|
1516
|
+
/// base and step through `widget_metrics.widgetSizedTokenValue`.
|
|
1517
|
+
pub fn widgetSizeSteppedValue(size: WidgetSize, value: f32, step: f32) f32 {
|
|
1518
|
+
return switch (size) {
|
|
1519
|
+
.sm => @max(0, value - step),
|
|
1520
|
+
.default, .icon, .heading, .display => value,
|
|
1521
|
+
.lg => value + step,
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1512
1525
|
/// Ergonomic per-kind layout defaults for the composite surfaces whose
|
|
1513
1526
|
/// house reference carries built-in content spacing, shared by EVERY
|
|
1514
1527
|
/// authoring path — `builtinComponentWidget` and (via the ui builder,
|
|
@@ -1525,7 +1538,7 @@ pub fn widgetKindDefaultLayout(kind: WidgetKind, size: WidgetSize) ?WidgetLayout
|
|
|
1525
1538
|
.clip_content = true,
|
|
1526
1539
|
},
|
|
1527
1540
|
.alert => .{
|
|
1528
|
-
.padding = geometry.InsetsF.all(16),
|
|
1541
|
+
.padding = geometry.InsetsF.all(widgetSizeSteppedValue(size, 16, 2)),
|
|
1529
1542
|
.gap = 12,
|
|
1530
1543
|
.clip_content = true,
|
|
1531
1544
|
},
|
package/src/root.zig
CHANGED
|
@@ -44,8 +44,12 @@ pub const FetchResponseMode = runtime.FetchResponseMode;
|
|
|
44
44
|
pub const EffectResponse = runtime.EffectResponse;
|
|
45
45
|
pub const EffectFetchOutcome = runtime.EffectFetchOutcome;
|
|
46
46
|
pub const EffectFileOp = runtime.EffectFileOp;
|
|
47
|
+
pub const EffectFileEvent = runtime.EffectFileEvent;
|
|
47
48
|
pub const EffectFileOutcome = runtime.EffectFileOutcome;
|
|
48
49
|
pub const EffectFileResult = runtime.EffectFileResult;
|
|
50
|
+
pub const FileAccessBinding = runtime.FileAccessBinding;
|
|
51
|
+
pub const effect_file_stream_chunk_bytes = runtime.effect_file_stream_chunk_bytes;
|
|
52
|
+
pub const max_effect_file_streams = runtime.max_effect_file_streams;
|
|
49
53
|
pub const EffectCredentialsOperation = runtime.EffectCredentialsOperation;
|
|
50
54
|
pub const EffectCredentialsOutcome = runtime.EffectCredentialsOutcome;
|
|
51
55
|
pub const EffectCredentialsResult = runtime.EffectCredentialsResult;
|
|
@@ -129,6 +133,7 @@ pub const EffectImageOutcome = runtime.EffectImageOutcome;
|
|
|
129
133
|
pub const imageCachePath = runtime.imageCachePath;
|
|
130
134
|
pub const max_effect_image_path_bytes = runtime.max_effect_image_path_bytes;
|
|
131
135
|
pub const max_effect_image_bytes = runtime.max_effect_image_bytes;
|
|
136
|
+
pub const max_effect_image_source_bytes = runtime.max_effect_image_source_bytes;
|
|
132
137
|
pub const effect_image_blob_hash_len = runtime.effect_image_blob_hash_len;
|
|
133
138
|
pub const EffectChannelEvent = runtime.EffectChannelEvent;
|
|
134
139
|
pub const EffectChannelEventKind = runtime.EffectChannelEventKind;
|
|
@@ -164,6 +169,7 @@ pub const setFreestandingMonotonicNanoseconds = runtime.setFreestandingMonotonic
|
|
|
164
169
|
pub const RegisteredImage = runtime.RegisteredImage;
|
|
165
170
|
pub const max_registered_canvas_images = runtime.max_registered_canvas_images;
|
|
166
171
|
pub const max_registered_canvas_image_pixel_bytes = runtime.max_registered_canvas_image_pixel_bytes;
|
|
172
|
+
pub const max_registered_canvas_image_pixel_bytes_ceiling = runtime.max_registered_canvas_image_pixel_bytes_ceiling;
|
|
167
173
|
pub const MediaSurfaceProducer = runtime.MediaSurfaceProducer;
|
|
168
174
|
pub const max_media_surface_channels = runtime.max_media_surface_channels;
|
|
169
175
|
pub const max_media_surface_pixel_bytes = runtime.max_media_surface_pixel_bytes;
|
|
@@ -210,6 +216,7 @@ pub const WindowCreateOptions = platform.WindowCreateOptions;
|
|
|
210
216
|
pub const WindowInfo = platform.WindowInfo;
|
|
211
217
|
pub const WindowState = platform.WindowState;
|
|
212
218
|
pub const WindowRestorePolicy = platform.WindowRestorePolicy;
|
|
219
|
+
pub const WindowInitialPlacement = platform.WindowInitialPlacement;
|
|
213
220
|
pub const WindowTitlebarStyle = platform.WindowTitlebarStyle;
|
|
214
221
|
pub const WindowChrome = platform.WindowChrome;
|
|
215
222
|
pub const FormFactor = platform.FormFactor;
|
|
@@ -240,8 +247,11 @@ pub const MessageDialogStyle = platform.MessageDialogStyle;
|
|
|
240
247
|
pub const MessageDialogResult = platform.MessageDialogResult;
|
|
241
248
|
pub const MessageDialogOptions = platform.MessageDialogOptions;
|
|
242
249
|
pub const NotificationOptions = platform.NotificationOptions;
|
|
250
|
+
pub const StatusItemId = platform.StatusItemId;
|
|
251
|
+
pub const primary_status_item_id = platform.primary_status_item_id;
|
|
243
252
|
pub const TrayItemId = platform.TrayItemId;
|
|
244
253
|
pub const TrayOptions = platform.TrayOptions;
|
|
254
|
+
pub const TrayShell = platform.TrayShell;
|
|
245
255
|
pub const TrayMenuItem = platform.TrayMenuItem;
|
|
246
256
|
pub const BridgeDispatcher = bridge.Dispatcher;
|
|
247
257
|
pub const BridgePolicy = bridge.Policy;
|
package/src/runtime/api.zig
CHANGED
|
@@ -8,6 +8,7 @@ const extensions = @import("../extensions/root.zig");
|
|
|
8
8
|
const app_manifest = @import("app_manifest");
|
|
9
9
|
const platform = @import("../platform/root.zig");
|
|
10
10
|
const runtime_effects = @import("effects.zig");
|
|
11
|
+
const canvas_limits = @import("canvas_limits.zig");
|
|
11
12
|
const runtime_session_record = @import("session_record.zig");
|
|
12
13
|
const runtime_view = @import("view.zig");
|
|
13
14
|
const security = @import("../security/root.zig");
|
|
@@ -27,6 +28,7 @@ pub const CommandEvent = struct {
|
|
|
27
28
|
source: CommandSource = .runtime,
|
|
28
29
|
window_id: platform.WindowId = 0,
|
|
29
30
|
view_label: []const u8 = "",
|
|
31
|
+
status_item_id: platform.StatusItemId = 0,
|
|
30
32
|
tray_item_id: platform.TrayItemId = 0,
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -38,6 +40,7 @@ pub const CommandSource = enum {
|
|
|
38
40
|
shortcut,
|
|
39
41
|
toolbar,
|
|
40
42
|
tray,
|
|
43
|
+
notification,
|
|
41
44
|
native_view,
|
|
42
45
|
bridge,
|
|
43
46
|
};
|
|
@@ -478,6 +481,11 @@ pub const Options = struct {
|
|
|
478
481
|
/// mutating `options.allocator` on a live runtime retargets
|
|
479
482
|
/// nothing — pick the owning allocator here, before init.
|
|
480
483
|
allocator: std.mem.Allocator = std.heap.page_allocator,
|
|
484
|
+
/// Runtime-frozen registered-image pixel budget. The standard app
|
|
485
|
+
/// runner reads this from app.zon's `.images.max_image_pixel_bytes`;
|
|
486
|
+
/// custom runners may set it directly. Storage remains lazy per used
|
|
487
|
+
/// slot, so raising the budget reserves nothing by itself.
|
|
488
|
+
max_image_pixel_bytes: usize = canvas_limits.max_registered_canvas_image_pixel_bytes,
|
|
481
489
|
trace_sink: ?trace.Sink = null,
|
|
482
490
|
log_path: ?[]const u8 = null,
|
|
483
491
|
extensions: ?extensions.ModuleRegistry = null,
|
|
@@ -500,6 +508,12 @@ pub const Options = struct {
|
|
|
500
508
|
/// checked separately; both gates must be open before core effects may
|
|
501
509
|
/// reach the platform keychain.
|
|
502
510
|
credentials_enabled: bool = false,
|
|
511
|
+
/// Raw-file policy resolved by the app runner. Six app-owned roots are
|
|
512
|
+
/// allowed without a grant; `filesystem` opens arbitrary paths.
|
|
513
|
+
/// Standard runners install the six resolved app-owned roots here. If a
|
|
514
|
+
/// custom runner omits the binding, UiApp fails closed with no exempt roots
|
|
515
|
+
/// while still honoring an explicit `filesystem` permission.
|
|
516
|
+
file_access: ?runtime_effects.FileAccessBinding = null,
|
|
503
517
|
js_window_api: bool = false,
|
|
504
518
|
/// Whether this build ships the embedded web layer. The app runner
|
|
505
519
|
/// sets it from the build graph's app.zon inference (declare-to-use:
|
|
@@ -153,8 +153,8 @@ pub fn parseAutomationCommandName(value: []const u8) ![]const u8 {
|
|
|
153
153
|
return trimmed[0..separator];
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
/// `tray-action <item-id
|
|
157
|
-
///
|
|
156
|
+
/// Parses the one-id `tray-action <item-id>` compatibility form: the
|
|
157
|
+
/// numeric dropdown row id printed by a primary item's `tray-item #N` line.
|
|
158
158
|
pub fn parseAutomationTrayItemId(value: []const u8) !platform.TrayItemId {
|
|
159
159
|
const trimmed = std.mem.trim(u8, value, " \n\r\t");
|
|
160
160
|
if (trimmed.len == 0) return error.InvalidCommand;
|
|
@@ -164,6 +164,27 @@ pub fn parseAutomationTrayItemId(value: []const u8) !platform.TrayItemId {
|
|
|
164
164
|
return id;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
pub const AutomationTrayTarget = struct {
|
|
168
|
+
status_item_id: platform.StatusItemId = platform.primary_status_item_id,
|
|
169
|
+
item_id: platform.TrayItemId,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/// `tray-action <item-id>` targets the reserved primary status item;
|
|
173
|
+
/// `tray-action <status-item-id> <item-id>` addresses any live item.
|
|
174
|
+
pub fn parseAutomationTrayTarget(value: []const u8) !AutomationTrayTarget {
|
|
175
|
+
var tokens = std.mem.tokenizeAny(u8, value, " \t\r\n");
|
|
176
|
+
const first = tokens.next() orelse return error.InvalidCommand;
|
|
177
|
+
const second = tokens.next();
|
|
178
|
+
if (tokens.next() != null) return error.InvalidCommand;
|
|
179
|
+
if (second) |item_text| {
|
|
180
|
+
const status_item_id = std.fmt.parseUnsigned(platform.StatusItemId, first, 10) catch return error.InvalidCommand;
|
|
181
|
+
const item_id = std.fmt.parseUnsigned(platform.TrayItemId, item_text, 10) catch return error.InvalidCommand;
|
|
182
|
+
if (status_item_id == 0 or item_id == 0) return error.InvalidCommand;
|
|
183
|
+
return .{ .status_item_id = status_item_id, .item_id = item_id };
|
|
184
|
+
}
|
|
185
|
+
return .{ .item_id = try parseAutomationTrayItemId(first) };
|
|
186
|
+
}
|
|
187
|
+
|
|
167
188
|
pub fn parseAutomationViewLabel(value: []const u8) ![]const u8 {
|
|
168
189
|
const trimmed = std.mem.trim(u8, value, " \n\r\t");
|
|
169
190
|
if (trimmed.len == 0) return error.InvalidCommand;
|
|
@@ -601,6 +622,18 @@ test "runtime parses automation tray item ids" {
|
|
|
601
622
|
try std.testing.expectError(error.InvalidCommand, parseAutomationTrayItemId("4 5"));
|
|
602
623
|
}
|
|
603
624
|
|
|
625
|
+
test "runtime parses primary and explicit automation tray targets" {
|
|
626
|
+
const primary = try parseAutomationTrayTarget("4");
|
|
627
|
+
try std.testing.expectEqual(platform.primary_status_item_id, primary.status_item_id);
|
|
628
|
+
try std.testing.expectEqual(@as(platform.TrayItemId, 4), primary.item_id);
|
|
629
|
+
const explicit = try parseAutomationTrayTarget("23 12");
|
|
630
|
+
try std.testing.expectEqual(@as(platform.StatusItemId, 23), explicit.status_item_id);
|
|
631
|
+
try std.testing.expectEqual(@as(platform.TrayItemId, 12), explicit.item_id);
|
|
632
|
+
try std.testing.expectError(error.InvalidCommand, parseAutomationTrayTarget("0 2"));
|
|
633
|
+
try std.testing.expectError(error.InvalidCommand, parseAutomationTrayTarget("2 0"));
|
|
634
|
+
try std.testing.expectError(error.InvalidCommand, parseAutomationTrayTarget("1 2 3"));
|
|
635
|
+
}
|
|
636
|
+
|
|
604
637
|
test "runtime parses automation widget click targets" {
|
|
605
638
|
const target = try parseAutomationWidgetTarget("canvas 42");
|
|
606
639
|
try std.testing.expectEqualStrings("canvas", target.view_label);
|