@native-sdk/cli 0.9.3 → 0.9.5
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/README.md +3 -3
- package/build/app.zig +323 -76
- package/build/ts_run.mjs +15 -18
- package/build.zig +83 -8
- package/package.json +14 -10
- package/packages/core/compile-surface/core.ts +1 -0
- package/packages/core/package-lock.json +16 -13
- package/packages/core/package.json +5 -2
- package/packages/core/scripts/compiler_command.mjs +71 -0
- package/packages/core/scripts/compiler_typecheck.mjs +4 -4
- package/packages/core/scripts/embed_markup_c.mjs +25 -0
- package/packages/core/scripts/npm_static_spike.mjs +3 -3
- package/packages/core/scripts/run_external_core_compiler.mjs +21 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +17 -7
- package/packages/core/scripts/vendor_service_packages.mjs +121 -8
- package/packages/core/sdk/core.ts +1 -0
- package/packages/core/sdk/events.d.ts +36 -4
- package/packages/core/sdk/events.ts +49 -6
- package/packages/core/src/checker.ts +106 -10
- package/packages/core/src/modules.ts +6 -2
- package/packages/core/src/sqlite_cli.ts +22 -2
- package/packages/core/src/typed_ast.ts +4 -2
- package/packages/core/src/types.ts +8 -8
- package/schemas/app.schema.json +435 -0
- package/skill-data/core/SKILL.md +53 -15
- package/skill-data/core/references/project-anatomy.md +6 -6
- package/skill-data/native-ui/SKILL.md +28 -6
- package/skill-data/ts-core/SKILL.md +9 -6
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/skills/native-sdk/SKILL.md +2 -2
- package/src/app_runner/ts_core_main.zig +12 -4
- package/src/app_runner/ts_core_mobile.zig +6 -2
- package/src/automation/snapshot.zig +91 -3
- package/src/platform/macos/appkit_host.h +41 -2
- package/src/platform/macos/appkit_host.m +198 -9
- package/src/platform/macos/cef_host.mm +191 -9
- package/src/platform/macos/root.zig +110 -3
- package/src/platform/null_platform.zig +50 -1
- package/src/platform/null_platform_tests.zig +53 -0
- package/src/platform/root.zig +9 -0
- package/src/platform/types.zig +58 -0
- package/src/platform/windows/root.zig +88 -15
- package/src/primitives/canvas/reference.zig +37 -15
- package/src/primitives/canvas/reference_tests.zig +63 -0
- package/src/primitives/canvas/ui.zig +9 -0
- package/src/primitives/canvas/ui_markup.zig +29 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
- package/src/primitives/canvas/ui_markup_contract.zig +7 -0
- package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
- package/src/primitives/canvas/ui_markup_tests.zig +6 -0
- package/src/primitives/canvas/ui_markup_view.zig +28 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
- package/src/primitives/canvas/ui_schema.zig +9 -0
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +4 -2
- package/src/primitives/canvas/widget_render.zig +7 -2
- package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
- package/src/root.zig +4 -0
- package/src/runtime/automation_snapshot.zig +3 -0
- package/src/runtime/flow.zig +1 -1
- package/src/runtime/state.zig +14 -0
- package/src/runtime/system_services.zig +62 -0
- package/src/runtime/ts_ui_app.zig +181 -39
- package/src/runtime/ui_app.zig +40 -1
- package/src/runtime/ui_app_tests.zig +63 -0
- package/src/runtime/ui_app_window_tests.zig +23 -0
- package/src/runtime/validation.zig +87 -1
- package/src/tooling/android.zig +5 -4
- package/src/tooling/buildgraph.zig +24 -8
- package/src/tooling/db.zig +1 -1
- package/src/tooling/doctor.zig +1 -1
- package/src/tooling/ios.zig +5 -4
- package/src/tooling/json_to_zon.zig +136 -0
- package/src/tooling/manifest.zig +120 -33
- package/src/tooling/raw_manifest.zig +4 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +171 -118
- package/src/tooling/ts_core.zig +12 -8
- package/src/tooling/verbs.zig +233 -5
- package/src/tooling/web_engine.zig +17 -1
- package/tools/corewire/emit_profile.zig +20 -7
- package/tools/corewire/emit_service.zig +49 -24
- package/tools/corewire/main.zig +21 -2
|
@@ -1714,6 +1714,7 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1714
1714
|
// ---------------------------------------------------- attributes
|
|
1715
1715
|
|
|
1716
1716
|
fn applyAttrs(self: *Self, scope: *Scope, node: markup.MarkupNode, options: *Ui.ElementOptions) BuildError!void {
|
|
1717
|
+
try self.applyImageSourceAttrs(scope, node, options);
|
|
1717
1718
|
for (node.attrs) |attribute| {
|
|
1718
1719
|
if (std.mem.eql(u8, attribute.name, "kind")) continue;
|
|
1719
1720
|
if (std.mem.startsWith(u8, attribute.name, "on-")) {
|
|
@@ -1751,6 +1752,7 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1751
1752
|
try self.applyImageAttr(scope, node, options, attribute);
|
|
1752
1753
|
continue;
|
|
1753
1754
|
}
|
|
1755
|
+
if (markup.imageSourceAttrName(attribute.name)) continue;
|
|
1754
1756
|
if (std.mem.eql(u8, attribute.name, "surface")) {
|
|
1755
1757
|
try self.applySurfaceAttr(scope, node, options, attribute);
|
|
1756
1758
|
continue;
|
|
@@ -1868,6 +1870,32 @@ pub fn MarkupView(comptime ModelT: type, comptime MsgT: type) type {
|
|
|
1868
1870
|
};
|
|
1869
1871
|
}
|
|
1870
1872
|
|
|
1873
|
+
/// The four `source-*` attributes form one optional source
|
|
1874
|
+
/// rectangle in decoded-image pixel coordinates. Build it before
|
|
1875
|
+
/// the scalar attribute walk so declaration order carries no
|
|
1876
|
+
/// meaning; repeat the validator's shape checks for hot-reloaded
|
|
1877
|
+
/// documents that reached the interpreter without validation.
|
|
1878
|
+
fn applyImageSourceAttrs(self: *Self, scope: *Scope, node: markup.MarkupNode, options: *Ui.ElementOptions) BuildError!void {
|
|
1879
|
+
var any = false;
|
|
1880
|
+
for (markup.image_source_attr_names) |name| {
|
|
1881
|
+
if (node.attr(name) != null) any = true;
|
|
1882
|
+
}
|
|
1883
|
+
if (!any) return;
|
|
1884
|
+
if (!std.mem.eql(u8, node.name, "avatar") and !std.mem.eql(u8, node.name, "image")) {
|
|
1885
|
+
return self.failVoid(node, markup.image_source_element_message);
|
|
1886
|
+
}
|
|
1887
|
+
if (node.attr("image") == null) return self.failVoid(node, markup.image_source_binding_message);
|
|
1888
|
+
for (markup.image_source_attr_names) |name| {
|
|
1889
|
+
if (node.attr(name) == null) return self.failVoid(node, markup.image_source_complete_message);
|
|
1890
|
+
}
|
|
1891
|
+
options.image_src = .{
|
|
1892
|
+
.x = try self.floatAttr(scope, node, node.attrEntry("source-x").?),
|
|
1893
|
+
.y = try self.floatAttr(scope, node, node.attrEntry("source-y").?),
|
|
1894
|
+
.width = try self.floatAttr(scope, node, node.attrEntry("source-width").?),
|
|
1895
|
+
.height = try self.floatAttr(scope, node, node.attrEntry("source-height").?),
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1871
1899
|
/// `surface="{binding}"` on media-surface: the model-owned u64
|
|
1872
1900
|
/// surface id a producer targets — media-surface-only,
|
|
1873
1901
|
/// binding-only, integer-valued (the runtime-image-id grammar
|
|
@@ -2846,6 +2846,9 @@ pub const ImageLeafModel = struct {
|
|
|
2846
2846
|
/// A signed id field: bindings evaluate as i64, so a negative must
|
|
2847
2847
|
/// reach the image seam as a value, never trap in the u64 cast.
|
|
2848
2848
|
stale_image: i64 = -2,
|
|
2849
|
+
source_x: f32 = 4,
|
|
2850
|
+
source_width: f32 = 32,
|
|
2851
|
+
invalid_source: []const u8 = "wide",
|
|
2849
2852
|
|
|
2850
2853
|
/// A pub fn producing an ImageId binds like a field.
|
|
2851
2854
|
pub fn thumbnail(model: *const ImageLeafModel) canvas.ImageId {
|
|
@@ -2855,7 +2858,7 @@ pub const ImageLeafModel = struct {
|
|
|
2855
2858
|
|
|
2856
2859
|
pub const image_markup_source =
|
|
2857
2860
|
\\<row gap="8">
|
|
2858
|
-
\\ <image image="{cover}" width="120" height="80" label="Cover art" />
|
|
2861
|
+
\\ <image image="{cover}" source-x="{source_x}" source-y="8" source-width="{source_width}" source-height="24" width="120" height="80" label="Cover art" />
|
|
2859
2862
|
\\ <image image="{thumbnail}" width="48" height="48" label="" />
|
|
2860
2863
|
\\</row>
|
|
2861
2864
|
;
|
|
@@ -2875,7 +2878,7 @@ pub const ImageLeafUi = canvas.Ui(ImageLeafMsg);
|
|
|
2875
2878
|
/// shares.
|
|
2876
2879
|
pub fn handImageLeafView(ui: *ImageLeafUi, model: *const ImageLeafModel) ImageLeafUi.Node {
|
|
2877
2880
|
return ui.row(.{ .gap = 8 }, .{
|
|
2878
|
-
ui.image(.{ .image = model.cover, .width = 120, .height = 80, .semantics = .{ .label = "Cover art" } }),
|
|
2881
|
+
ui.image(.{ .image = model.cover, .image_src = geometry.RectF.init(model.source_x, 8, model.source_width, 24), .width = 120, .height = 80, .semantics = .{ .label = "Cover art" } }),
|
|
2879
2882
|
ui.image(.{ .image = model.thumbnail(), .width = 48, .height = 48, .semantics = .{ .label = "" } }),
|
|
2880
2883
|
});
|
|
2881
2884
|
}
|
|
@@ -2902,13 +2905,16 @@ test "the image leaf binds a dynamic ImageId from model fields and fns" {
|
|
|
2902
2905
|
try collectIds(hand_tree.root, &hand_ids, testing.allocator);
|
|
2903
2906
|
try testing.expectEqualSlices(canvas.ObjectId, hand_ids.items, markup_ids.items);
|
|
2904
2907
|
|
|
2905
|
-
// The
|
|
2908
|
+
// The id and source-coordinate bindings land on the widget. The
|
|
2909
|
+
// second image omits a crop and draws the whole registered image.
|
|
2906
2910
|
const cover = markup_tree.root.children[0];
|
|
2907
2911
|
try testing.expectEqual(canvas.WidgetKind.image, cover.kind);
|
|
2908
2912
|
try testing.expectEqual(@as(canvas.ImageId, 42), cover.image_id);
|
|
2913
|
+
try testing.expectEqualDeep(@as(?geometry.RectF, geometry.RectF.init(4, 8, 32, 24)), cover.image_src);
|
|
2909
2914
|
try testing.expectEqualStrings("Cover art", cover.semantics.label);
|
|
2910
2915
|
const thumbnail = markup_tree.root.children[1];
|
|
2911
2916
|
try testing.expectEqual(@as(canvas.ImageId, 43), thumbnail.image_id);
|
|
2917
|
+
try testing.expectEqual(@as(?geometry.RectF, null), thumbnail.image_src);
|
|
2912
2918
|
|
|
2913
2919
|
// 0 is the "no image" sentinel: the leaf renders nothing (the
|
|
2914
2920
|
// model simply has not loaded the image yet).
|
|
@@ -2945,6 +2951,29 @@ test "image leaf misuse fails the build with the teaching messages" {
|
|
|
2945
2951
|
.source = "<row>\n <image image=\"{cover}\" label=\"Art\"><text>Caption</text></image>\n</row>",
|
|
2946
2952
|
.message = canvas.ui_markup.image_children_message,
|
|
2947
2953
|
},
|
|
2954
|
+
.{
|
|
2955
|
+
// A source rectangle is atomic: omitting one coordinate is
|
|
2956
|
+
// a typo, not an implicit zero/default.
|
|
2957
|
+
.source = "<row>\n <image image=\"{cover}\" source-x=\"0\" source-y=\"0\" source-width=\"16\" label=\"Art\" />\n</row>",
|
|
2958
|
+
.message = canvas.ui_markup.image_source_complete_message,
|
|
2959
|
+
},
|
|
2960
|
+
.{
|
|
2961
|
+
// Cropping without an image would be inert (avatar may omit
|
|
2962
|
+
// image normally for its initials fallback).
|
|
2963
|
+
.source = "<row>\n <avatar source-x=\"0\" source-y=\"0\" source-width=\"16\" source-height=\"16\">CT</avatar>\n</row>",
|
|
2964
|
+
.message = canvas.ui_markup.image_source_binding_message,
|
|
2965
|
+
},
|
|
2966
|
+
.{
|
|
2967
|
+
// Only registered-image widgets consume source rectangles.
|
|
2968
|
+
.source = "<row>\n <badge source-x=\"0\" source-y=\"0\" source-width=\"16\" source-height=\"16\">3</badge>\n</row>",
|
|
2969
|
+
.message = canvas.ui_markup.image_source_element_message,
|
|
2970
|
+
},
|
|
2971
|
+
.{
|
|
2972
|
+
// Runtime model values still pass the numeric conversion
|
|
2973
|
+
// gate; a string cannot become a source coordinate.
|
|
2974
|
+
.source = "<row>\n <image image=\"{cover}\" source-x=\"{invalid_source}\" source-y=\"0\" source-width=\"16\" source-height=\"16\" label=\"Art\" />\n</row>",
|
|
2975
|
+
.message = "expected a number",
|
|
2976
|
+
},
|
|
2948
2977
|
.{
|
|
2949
2978
|
// Markup that skipped validation (hot reload) can reach the
|
|
2950
2979
|
// engine without the binding: the leaf could only ever
|
|
@@ -591,6 +591,15 @@ pub const attrs = [_]AttrInfo{
|
|
|
591
591
|
// minimum unconstrained so a capped element still shrinks with a
|
|
592
592
|
// narrow parent.
|
|
593
593
|
.{ .code = 98, .name = "max-width", .class = .number, .group = .option, .field = "max_width" },
|
|
594
|
+
// Registered-image source rectangle, in decoded-image pixel
|
|
595
|
+
// coordinates. The four values are one atomic declaration: the
|
|
596
|
+
// validator scopes them to avatar/image and requires all four beside
|
|
597
|
+
// the image binding. They lower together into ElementOptions.image_src,
|
|
598
|
+
// so no individual attribute names a flat field.
|
|
599
|
+
.{ .code = 99, .name = "source-x", .class = .number, .group = .element },
|
|
600
|
+
.{ .code = 100, .name = "source-y", .class = .number, .group = .element },
|
|
601
|
+
.{ .code = 101, .name = "source-width", .class = .number, .group = .element },
|
|
602
|
+
.{ .code = 102, .name = "source-height", .class = .number, .group = .element },
|
|
594
603
|
};
|
|
595
604
|
|
|
596
605
|
// ----------------------------------------------------------------- events
|
|
@@ -22,7 +22,7 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
22
22
|
// the new fingerprint ONLY for additions; renames/renumbers are
|
|
23
23
|
// schema-version-bump events, not silent edits.
|
|
24
24
|
try testing.expectEqual(@as(usize, 70), schema.elements.len);
|
|
25
|
-
try testing.expectEqual(@as(usize,
|
|
25
|
+
try testing.expectEqual(@as(usize, 102), schema.attrs.len);
|
|
26
26
|
try testing.expectEqual(@as(usize, 15), schema.events.len);
|
|
27
27
|
// The element table runs through the span composite (64), the
|
|
28
28
|
// bubble-reactions composite (65), the media surface (66), the
|
|
@@ -48,9 +48,11 @@ test "registry codes are stable: assigned at birth, never renumbered or renamed"
|
|
|
48
48
|
// code-diff line sets added-lines (94) and removed-lines (95), and
|
|
49
49
|
// Markdown's registered-image iterable binding images (96), and the
|
|
50
50
|
// textarea Enter policy submit-on-enter (97), and the responsive
|
|
51
|
-
// layout ceiling max-width (98)
|
|
51
|
+
// layout ceiling max-width (98), and the registered-image source
|
|
52
|
+
// rectangle source-x (99), source-y (100), source-width (101), and
|
|
53
|
+
// source-height (102).
|
|
52
54
|
try testing.expectEqual(
|
|
53
|
-
@as(u64,
|
|
55
|
+
@as(u64, 0x3614b1510b48dcf4),
|
|
54
56
|
tableFingerprint(schema.AttrInfo, &schema.attrs),
|
|
55
57
|
);
|
|
56
58
|
// The event table runs through the pointer-hover containment pair
|
|
@@ -562,9 +562,9 @@ test "avatar and image sugar carry registered image ids" {
|
|
|
562
562
|
|
|
563
563
|
var ui = InboxUi.init(arena_state.allocator());
|
|
564
564
|
const tree = try ui.finalize(ui.column(.{}, .{
|
|
565
|
-
ui.avatar(.{ .image = 77, .semantics = .{ .label = "Native SDK" } }, "NS"),
|
|
565
|
+
ui.avatar(.{ .image = 77, .image_src = geometry.RectF.init(32, 0, 32, 32), .semantics = .{ .label = "Native SDK" } }, "NS"),
|
|
566
566
|
ui.avatar(.{}, "NS"),
|
|
567
|
-
ui.image(.{ .image = 42, .semantics = .{ .label = "Chart" } }),
|
|
567
|
+
ui.image(.{ .image = 42, .image_src = geometry.RectF.init(4, 8, 24, 16), .semantics = .{ .label = "Chart" } }),
|
|
568
568
|
}));
|
|
569
569
|
|
|
570
570
|
// With an image id the avatar clips it to the circle (cover fit);
|
|
@@ -572,6 +572,7 @@ test "avatar and image sugar carry registered image ids" {
|
|
|
572
572
|
const with_image = tree.root.children[0];
|
|
573
573
|
try testing.expectEqual(canvas.WidgetKind.avatar, with_image.kind);
|
|
574
574
|
try testing.expectEqual(@as(canvas.ImageId, 77), with_image.image_id);
|
|
575
|
+
try testing.expectEqualDeep(@as(?geometry.RectF, geometry.RectF.init(32, 0, 32, 32)), with_image.image_src);
|
|
575
576
|
try testing.expectEqual(canvas.ImageFit.cover, with_image.image_fit);
|
|
576
577
|
try testing.expectEqualStrings("NS", with_image.text);
|
|
577
578
|
|
|
@@ -582,6 +583,7 @@ test "avatar and image sugar carry registered image ids" {
|
|
|
582
583
|
const image_leaf = tree.root.children[2];
|
|
583
584
|
try testing.expectEqual(canvas.WidgetKind.image, image_leaf.kind);
|
|
584
585
|
try testing.expectEqual(@as(canvas.ImageId, 42), image_leaf.image_id);
|
|
586
|
+
try testing.expectEqualDeep(@as(?geometry.RectF, geometry.RectF.init(4, 8, 24, 16)), image_leaf.image_src);
|
|
585
587
|
}
|
|
586
588
|
|
|
587
589
|
test "payload-carrying handlers build messages from edits and values" {
|
|
@@ -2697,7 +2697,10 @@ fn emitImageWidget(builder: *Builder, widget: Widget) Error!void {
|
|
|
2697
2697
|
.dst = widget.frame,
|
|
2698
2698
|
.opacity = widget.image_opacity,
|
|
2699
2699
|
.fit = widget.image_fit,
|
|
2700
|
-
|
|
2700
|
+
// Packet hosts expose filtering but no per-draw sampler-address
|
|
2701
|
+
// mode. Nearest sampling keeps an atlas crop from filtering
|
|
2702
|
+
// across its source boundary; whole-image draws stay linear.
|
|
2703
|
+
.sampling = if (widget.image_src != null) .nearest else widget.image_sampling,
|
|
2701
2704
|
});
|
|
2702
2705
|
if (clips_image) try builder.popClip();
|
|
2703
2706
|
}
|
|
@@ -2987,7 +2990,9 @@ fn emitAvatarWidget(builder: *Builder, widget: Widget, tokens: DesignTokens) Err
|
|
|
2987
2990
|
.dst = widget.frame,
|
|
2988
2991
|
.opacity = widget.image_opacity,
|
|
2989
2992
|
.fit = widget.image_fit,
|
|
2990
|
-
|
|
2993
|
+
// See emitImageWidget: a cropped avatar is an atlas draw and
|
|
2994
|
+
// must not sample neighboring regions on packet hosts.
|
|
2995
|
+
.sampling = if (widget.image_src != null) .nearest else widget.image_sampling,
|
|
2991
2996
|
// The render plan flattens the clip stack to rects, so the
|
|
2992
2997
|
// pill clip above only crops the bounds; the draw's own
|
|
2993
2998
|
// radius mask is what actually rounds the image.
|
|
@@ -829,7 +829,7 @@ test "widget image emits draw image and exposes image semantics" {
|
|
|
829
829
|
.image_id = 42,
|
|
830
830
|
.image_src = geometry.RectF.init(0, 0, 320, 192),
|
|
831
831
|
.image_fit = .cover,
|
|
832
|
-
.image_sampling = .
|
|
832
|
+
.image_sampling = .linear,
|
|
833
833
|
.image_opacity = 0.75,
|
|
834
834
|
.semantics = .{ .label = "Deployment preview" },
|
|
835
835
|
};
|
|
@@ -864,6 +864,8 @@ test "widget image emits draw image and exposes image semantics" {
|
|
|
864
864
|
try expectRect(geometry.RectF.init(0, 0, 320, 192), draw.src);
|
|
865
865
|
try expectRect(geometry.RectF.init(12, 14, 80, 48), draw.dst);
|
|
866
866
|
try std.testing.expectEqual(ImageFit.cover, draw.fit);
|
|
867
|
+
// Atlas crops force nearest sampling at the widget seam so
|
|
868
|
+
// packet hosts cannot filter outside the source rectangle.
|
|
867
869
|
try std.testing.expectEqual(ImageSampling.nearest, draw.sampling);
|
|
868
870
|
try std.testing.expectEqual(@as(f32, 0.75), draw.opacity);
|
|
869
871
|
},
|
package/src/root.zig
CHANGED
|
@@ -253,6 +253,10 @@ pub const TrayItemId = platform.TrayItemId;
|
|
|
253
253
|
pub const TrayOptions = platform.TrayOptions;
|
|
254
254
|
pub const TrayShell = platform.TrayShell;
|
|
255
255
|
pub const TrayMenuItem = platform.TrayMenuItem;
|
|
256
|
+
pub const TraySegmentOption = platform.TraySegmentOption;
|
|
257
|
+
pub const TraySegmentedRow = platform.TraySegmentedRow;
|
|
258
|
+
pub const TrayMetricRow = platform.TrayMetricRow;
|
|
259
|
+
pub const TrayChartRow = platform.TrayChartRow;
|
|
256
260
|
pub const BridgeDispatcher = bridge.Dispatcher;
|
|
257
261
|
pub const BridgePolicy = bridge.Policy;
|
|
258
262
|
pub const BridgeCommandPolicy = bridge.CommandPolicy;
|
|
@@ -103,6 +103,9 @@ pub fn RuntimeAutomationSnapshot(comptime Runtime: type) type {
|
|
|
103
103
|
.role = item.role,
|
|
104
104
|
.key = item.key,
|
|
105
105
|
.modifiers = item.modifiers,
|
|
106
|
+
.segmented = item.segmented,
|
|
107
|
+
.metric = item.metric,
|
|
108
|
+
.chart = item.chart,
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
self.automation_trays[tray_count] = .{
|
package/src/runtime/flow.zig
CHANGED
|
@@ -1012,7 +1012,7 @@ pub fn RuntimeFlow(comptime Runtime: type) type {
|
|
|
1012
1012
|
// stale or unknown item id is loud driver misuse,
|
|
1013
1013
|
// like widget-click on an unmounted widget.
|
|
1014
1014
|
const target = try parseAutomationTrayTarget(command.value);
|
|
1015
|
-
if (!SystemServiceMethods().
|
|
1015
|
+
if (!SystemServiceMethods().statusItemMenuItemActionable(self, target.status_item_id, target.item_id)) return error.InvalidCommand;
|
|
1016
1016
|
try dispatchPlatformEvent(self, app, .{ .tray_action = .{
|
|
1017
1017
|
.status_item_id = target.status_item_id,
|
|
1018
1018
|
.item_id = target.item_id,
|
package/src/runtime/state.zig
CHANGED
|
@@ -86,6 +86,20 @@ pub const RuntimeTrayItem = struct {
|
|
|
86
86
|
label_storage: [platform.max_tray_item_label_bytes]u8 = undefined,
|
|
87
87
|
detail_storage: [platform.max_tray_item_detail_bytes]u8 = undefined,
|
|
88
88
|
key_storage: [platform.max_menu_key_bytes]u8 = undefined,
|
|
89
|
+
segment_options: [platform.max_tray_segment_options]platform.TraySegmentOption = undefined,
|
|
90
|
+
segment_option_label_storage: [platform.max_tray_segment_options][platform.max_tray_segment_label_bytes]u8 = undefined,
|
|
91
|
+
segment_option_command_storage: [platform.max_tray_segment_options][platform.max_tray_item_command_bytes]u8 = undefined,
|
|
92
|
+
segment_option_count: usize = 0,
|
|
93
|
+
segmented: ?platform.TraySegmentedRow = null,
|
|
94
|
+
metric_primary_storage: [platform.max_tray_item_label_bytes]u8 = undefined,
|
|
95
|
+
metric_secondary_storage: [platform.max_tray_item_detail_bytes]u8 = undefined,
|
|
96
|
+
metric_accessibility_storage: [platform.max_tray_chart_text_bytes]u8 = undefined,
|
|
97
|
+
metric: ?platform.TrayMetricRow = null,
|
|
98
|
+
chart_values: [platform.max_tray_chart_values]f32 = undefined,
|
|
99
|
+
chart_leading_caption_storage: [platform.max_tray_chart_text_bytes]u8 = undefined,
|
|
100
|
+
chart_trailing_summary_storage: [platform.max_tray_chart_text_bytes]u8 = undefined,
|
|
101
|
+
chart_accessibility_label_storage: [platform.max_tray_chart_text_bytes]u8 = undefined,
|
|
102
|
+
chart: ?platform.TrayChartRow = null,
|
|
89
103
|
};
|
|
90
104
|
|
|
91
105
|
pub const RuntimeStatusItem = struct {
|
|
@@ -229,6 +229,25 @@ pub fn RuntimeSystemServices(comptime Runtime: type) type {
|
|
|
229
229
|
const status_item = findStatusItemConst(self, status_item_id) orelse return false;
|
|
230
230
|
for (status_item.items[0..status_item.item_count]) |item| {
|
|
231
231
|
if (item.id == item_id) return true;
|
|
232
|
+
if (item.segmented) |segmented| {
|
|
233
|
+
for (segmented.options) |option| if (option.id == item_id) return true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/// Whether automation may invoke this row exactly as a user can.
|
|
240
|
+
/// Disabled native menu items and segmented choices cannot emit a
|
|
241
|
+
/// platform action, so the automation seam must reject them too.
|
|
242
|
+
pub fn statusItemMenuItemActionable(self: *const Runtime, status_item_id: platform.StatusItemId, item_id: platform.TrayItemId) bool {
|
|
243
|
+
const status_item = findStatusItemConst(self, status_item_id) orelse return false;
|
|
244
|
+
for (status_item.items[0..status_item.item_count]) |item| {
|
|
245
|
+
if (item.id == item_id) return !item.separator and item.enabled and (item.role == .command or item.role == .agent);
|
|
246
|
+
if (item.segmented) |segmented| {
|
|
247
|
+
for (segmented.options) |option| {
|
|
248
|
+
if (option.id == item_id) return option.enabled;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
232
251
|
}
|
|
233
252
|
return false;
|
|
234
253
|
}
|
|
@@ -241,6 +260,11 @@ pub fn RuntimeSystemServices(comptime Runtime: type) type {
|
|
|
241
260
|
const status_item = findStatusItemConst(self, status_item_id) orelse return "tray.action";
|
|
242
261
|
for (status_item.items[0..status_item.item_count]) |item| {
|
|
243
262
|
if (item.id == item_id and item.command.len > 0) return item.command;
|
|
263
|
+
if (item.segmented) |segmented| {
|
|
264
|
+
for (segmented.options) |option| {
|
|
265
|
+
if (option.id == item_id) return option.command;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
244
268
|
}
|
|
245
269
|
return "tray.action";
|
|
246
270
|
}
|
|
@@ -480,6 +504,44 @@ fn storeTrayItems(status_item: anytype, items: []const platform.TrayMenuItem) !v
|
|
|
480
504
|
status_item.items[index].role = item.role;
|
|
481
505
|
status_item.items[index].key = try copyInto(&status_item.items[index].key_storage, item.key);
|
|
482
506
|
status_item.items[index].modifiers = item.modifiers;
|
|
507
|
+
status_item.items[index].segmented = null;
|
|
508
|
+
status_item.items[index].segment_option_count = 0;
|
|
509
|
+
if (item.segmented) |segmented| {
|
|
510
|
+
for (segmented.options, 0..) |option, option_index| {
|
|
511
|
+
const stored = &status_item.items[index].segment_options[option_index];
|
|
512
|
+
stored.id = option.id;
|
|
513
|
+
stored.label = try copyInto(&status_item.items[index].segment_option_label_storage[option_index], option.label);
|
|
514
|
+
stored.command = try copyInto(&status_item.items[index].segment_option_command_storage[option_index], option.command);
|
|
515
|
+
stored.selected = option.selected;
|
|
516
|
+
stored.enabled = option.enabled;
|
|
517
|
+
}
|
|
518
|
+
status_item.items[index].segment_option_count = segmented.options.len;
|
|
519
|
+
const stored = &status_item.items[index];
|
|
520
|
+
stored.segmented = .{ .options = stored.segment_options[0..stored.segment_option_count] };
|
|
521
|
+
}
|
|
522
|
+
status_item.items[index].metric = null;
|
|
523
|
+
if (item.metric) |metric| {
|
|
524
|
+
status_item.items[index].metric = .{
|
|
525
|
+
.primary_text = try copyInto(&status_item.items[index].metric_primary_storage, metric.primary_text),
|
|
526
|
+
.secondary_text = try copyInto(&status_item.items[index].metric_secondary_storage, metric.secondary_text),
|
|
527
|
+
.accessibility_label = try copyInto(&status_item.items[index].metric_accessibility_storage, metric.accessibility_label),
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
status_item.items[index].chart = null;
|
|
531
|
+
if (item.chart) |chart| {
|
|
532
|
+
@memcpy(status_item.items[index].chart_values[0..chart.values.len], chart.values);
|
|
533
|
+
const leading_caption = try copyInto(&status_item.items[index].chart_leading_caption_storage, chart.leading_caption);
|
|
534
|
+
const trailing_summary = try copyInto(&status_item.items[index].chart_trailing_summary_storage, chart.trailing_summary);
|
|
535
|
+
const accessibility_label = try copyInto(&status_item.items[index].chart_accessibility_label_storage, chart.accessibility_label);
|
|
536
|
+
status_item.items[index].chart = .{
|
|
537
|
+
.values = status_item.items[index].chart_values[0..chart.values.len],
|
|
538
|
+
.min_value = chart.min_value,
|
|
539
|
+
.max_value = chart.max_value,
|
|
540
|
+
.leading_caption = leading_caption,
|
|
541
|
+
.trailing_summary = trailing_summary,
|
|
542
|
+
.accessibility_label = accessibility_label,
|
|
543
|
+
};
|
|
544
|
+
}
|
|
483
545
|
}
|
|
484
546
|
status_item.item_count = items.len;
|
|
485
547
|
}
|