@native-sdk/cli 0.9.4 → 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.
Files changed (70) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +68 -57
  3. package/build.zig +12 -1
  4. package/package.json +10 -9
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
  8. package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
  9. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  10. package/packages/core/sdk/events.d.ts +33 -4
  11. package/packages/core/sdk/events.ts +45 -6
  12. package/packages/core/src/checker.ts +103 -8
  13. package/packages/core/src/modules.ts +6 -2
  14. package/packages/core/src/sqlite_cli.ts +22 -2
  15. package/packages/core/src/typed_ast.ts +4 -2
  16. package/packages/core/src/types.ts +8 -8
  17. package/schemas/app.schema.json +435 -0
  18. package/skill-data/core/SKILL.md +53 -15
  19. package/skill-data/core/references/project-anatomy.md +6 -6
  20. package/skill-data/native-ui/SKILL.md +26 -5
  21. package/skill-data/ts-core/SKILL.md +6 -6
  22. package/skills/native-sdk/SKILL.md +2 -2
  23. package/src/automation/snapshot.zig +91 -3
  24. package/src/platform/macos/appkit_host.h +41 -2
  25. package/src/platform/macos/appkit_host.m +198 -9
  26. package/src/platform/macos/cef_host.mm +191 -9
  27. package/src/platform/macos/root.zig +110 -3
  28. package/src/platform/null_platform.zig +50 -1
  29. package/src/platform/null_platform_tests.zig +53 -0
  30. package/src/platform/root.zig +9 -0
  31. package/src/platform/types.zig +58 -0
  32. package/src/platform/windows/root.zig +88 -15
  33. package/src/primitives/canvas/reference.zig +37 -15
  34. package/src/primitives/canvas/reference_tests.zig +63 -0
  35. package/src/primitives/canvas/ui.zig +9 -0
  36. package/src/primitives/canvas/ui_markup.zig +29 -0
  37. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  38. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  39. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  40. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  41. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  42. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  43. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  44. package/src/primitives/canvas/ui_schema.zig +9 -0
  45. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  46. package/src/primitives/canvas/ui_tests.zig +4 -2
  47. package/src/primitives/canvas/widget_render.zig +7 -2
  48. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  49. package/src/root.zig +4 -0
  50. package/src/runtime/automation_snapshot.zig +3 -0
  51. package/src/runtime/flow.zig +1 -1
  52. package/src/runtime/state.zig +14 -0
  53. package/src/runtime/system_services.zig +62 -0
  54. package/src/runtime/ts_ui_app.zig +161 -33
  55. package/src/runtime/ui_app.zig +33 -1
  56. package/src/runtime/ui_app_tests.zig +63 -0
  57. package/src/runtime/validation.zig +87 -1
  58. package/src/tooling/android.zig +5 -4
  59. package/src/tooling/buildgraph.zig +24 -8
  60. package/src/tooling/db.zig +1 -1
  61. package/src/tooling/doctor.zig +1 -1
  62. package/src/tooling/ios.zig +5 -4
  63. package/src/tooling/json_to_zon.zig +136 -0
  64. package/src/tooling/manifest.zig +120 -33
  65. package/src/tooling/raw_manifest.zig +4 -0
  66. package/src/tooling/root.zig +1 -0
  67. package/src/tooling/templates.zig +165 -116
  68. package/src/tooling/ts_core.zig +11 -7
  69. package/src/tooling/verbs.zig +7 -6
  70. package/src/tooling/web_engine.zig +17 -1
@@ -414,15 +414,50 @@ const widget_action_drop_files: u32 = 1 << 9;
414
414
  const widget_action_dismiss: u32 = 1 << 10;
415
415
 
416
416
  const AppKitTrayCallback = *const fn (context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void;
417
+ const AppKitTraySegmentOption = extern struct {
418
+ item_id: u32,
419
+ label: [*]const u8,
420
+ label_len: usize,
421
+ selected: c_int,
422
+ enabled: c_int,
423
+ };
424
+ const AppKitTraySegmentedRow = extern struct {
425
+ row_index: usize,
426
+ options: [*]const AppKitTraySegmentOption,
427
+ option_count: usize,
428
+ };
429
+ const AppKitTrayMetricRow = extern struct {
430
+ row_index: usize,
431
+ primary_text: [*]const u8,
432
+ primary_text_len: usize,
433
+ secondary_text: [*]const u8,
434
+ secondary_text_len: usize,
435
+ accessibility_label: [*]const u8,
436
+ accessibility_label_len: usize,
437
+ };
438
+ const AppKitTrayChartRow = extern struct {
439
+ row_index: usize,
440
+ values: [*]const f32,
441
+ value_count: usize,
442
+ min_value: f64,
443
+ max_value: f64,
444
+ leading_caption: [*]const u8,
445
+ leading_caption_len: usize,
446
+ trailing_summary: [*]const u8,
447
+ trailing_summary_len: usize,
448
+ accessibility_label: [*]const u8,
449
+ accessibility_label_len: usize,
450
+ };
417
451
 
418
452
  extern fn native_sdk_appkit_show_open_dialog(host: *AppKitHost, opts: *const AppKitOpenDialogOpts, buffer: [*]u8, buffer_len: usize) AppKitOpenDialogResult;
419
453
  extern fn native_sdk_appkit_show_save_dialog(host: *AppKitHost, opts: *const AppKitSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
420
454
  extern fn native_sdk_appkit_show_message_dialog(host: *AppKitHost, opts: *const AppKitMessageDialogOpts) c_int;
421
- extern fn native_sdk_appkit_create_tray(host: *AppKitHost, status_item_id: u32, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize, visible: c_int, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int, activation_command: [*]const u8, activation_command_len: usize, alternate_activation_command: [*]const u8, alternate_activation_command_len: usize, open_command: [*]const u8, open_command_len: usize) void;
455
+ extern fn native_sdk_appkit_create_tray(host: *AppKitHost, status_item_id: u32, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize, visible: c_int, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int, font_size: f64, font_weight: c_int, activation_command: [*]const u8, activation_command_len: usize, alternate_activation_command: [*]const u8, alternate_activation_command_len: usize, open_command: [*]const u8, open_command_len: usize) void;
422
456
  extern fn native_sdk_appkit_update_tray_shell(host: *AppKitHost, status_item_id: u32, icon_path: [*]const u8, icon_path_len: usize, tooltip: [*]const u8, tooltip_len: usize, visible: c_int, activation_command: [*]const u8, activation_command_len: usize, alternate_activation_command: [*]const u8, alternate_activation_command_len: usize, open_command: [*]const u8, open_command_len: usize) void;
423
457
  extern fn native_sdk_appkit_update_tray_menu(host: *AppKitHost, status_item_id: u32, item_ids: [*]const u32, labels: [*]const [*]const u8, label_lens: [*]const usize, separators: [*]const c_int, enabled_flags: [*]const c_int, details: [*]const [*]const u8, detail_lens: [*]const usize, roles: [*]const c_int, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
458
+ extern fn native_sdk_appkit_update_tray_rich_rows(host: *AppKitHost, status_item_id: u32, segmented_rows: [*]const AppKitTraySegmentedRow, segmented_count: usize, metric_rows: [*]const AppKitTrayMetricRow, metric_count: usize, chart_rows: [*]const AppKitTrayChartRow, chart_count: usize) void;
424
459
  extern fn native_sdk_appkit_update_tray_title(host: *AppKitHost, status_item_id: u32, title: [*]const u8, title_len: usize) void;
425
- extern fn native_sdk_appkit_update_tray_presentation(host: *AppKitHost, status_item_id: u32, title: [*]const u8, title_len: usize, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int) void;
460
+ extern fn native_sdk_appkit_update_tray_presentation(host: *AppKitHost, status_item_id: u32, title: [*]const u8, title_len: usize, width: f64, tone: c_int, icon_opacity: f64, monospaced: c_int, font_size: f64, font_weight: c_int) void;
426
461
  extern fn native_sdk_appkit_remove_tray(host: *AppKitHost, status_item_id: u32) void;
427
462
  extern fn native_sdk_appkit_set_tray_callback(host: *AppKitHost, callback: AppKitTrayCallback, context: ?*anyopaque) void;
428
463
 
@@ -2690,6 +2725,8 @@ fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, o
2690
2725
  @intFromEnum(presentation.tone),
2691
2726
  presentation.icon_opacity,
2692
2727
  if (presentation.monospaced) 1 else 0,
2728
+ presentation.font_size,
2729
+ @intFromEnum(presentation.font_weight),
2693
2730
  options.activation_command.ptr,
2694
2731
  options.activation_command.len,
2695
2732
  options.alternate_activation_command.ptr,
@@ -2739,6 +2776,65 @@ fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemI
2739
2776
  (@as(u32, @intFromBool(item.modifiers.shift)) << 4);
2740
2777
  }
2741
2778
  native_sdk_appkit_update_tray_menu(self.host, status_item_id, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count);
2779
+
2780
+ var segment_options: [max_tray_items * platform_mod.max_tray_segment_options]AppKitTraySegmentOption = undefined;
2781
+ var segmented_rows: [max_tray_items]AppKitTraySegmentedRow = undefined;
2782
+ var metric_rows: [max_tray_items]AppKitTrayMetricRow = undefined;
2783
+ var chart_rows: [max_tray_items]AppKitTrayChartRow = undefined;
2784
+ var option_count: usize = 0;
2785
+ var segmented_count: usize = 0;
2786
+ var metric_count: usize = 0;
2787
+ var chart_count: usize = 0;
2788
+ for (items[0..count], 0..) |item, row_index| {
2789
+ if (item.segmented) |segmented| {
2790
+ const start = option_count;
2791
+ for (segmented.options) |option| {
2792
+ segment_options[option_count] = .{
2793
+ .item_id = option.id,
2794
+ .label = option.label.ptr,
2795
+ .label_len = option.label.len,
2796
+ .selected = if (option.selected) 1 else 0,
2797
+ .enabled = if (option.enabled) 1 else 0,
2798
+ };
2799
+ option_count += 1;
2800
+ }
2801
+ segmented_rows[segmented_count] = .{
2802
+ .row_index = row_index,
2803
+ .options = segment_options[start..option_count].ptr,
2804
+ .option_count = option_count - start,
2805
+ };
2806
+ segmented_count += 1;
2807
+ }
2808
+ if (item.metric) |metric| {
2809
+ metric_rows[metric_count] = .{
2810
+ .row_index = row_index,
2811
+ .primary_text = metric.primary_text.ptr,
2812
+ .primary_text_len = metric.primary_text.len,
2813
+ .secondary_text = metric.secondary_text.ptr,
2814
+ .secondary_text_len = metric.secondary_text.len,
2815
+ .accessibility_label = metric.accessibility_label.ptr,
2816
+ .accessibility_label_len = metric.accessibility_label.len,
2817
+ };
2818
+ metric_count += 1;
2819
+ }
2820
+ if (item.chart) |chart| {
2821
+ chart_rows[chart_count] = .{
2822
+ .row_index = row_index,
2823
+ .values = chart.values.ptr,
2824
+ .value_count = chart.values.len,
2825
+ .min_value = chart.min_value,
2826
+ .max_value = chart.max_value,
2827
+ .leading_caption = chart.leading_caption.ptr,
2828
+ .leading_caption_len = chart.leading_caption.len,
2829
+ .trailing_summary = chart.trailing_summary.ptr,
2830
+ .trailing_summary_len = chart.trailing_summary.len,
2831
+ .accessibility_label = chart.accessibility_label.ptr,
2832
+ .accessibility_label_len = chart.accessibility_label.len,
2833
+ };
2834
+ chart_count += 1;
2835
+ }
2836
+ }
2837
+ native_sdk_appkit_update_tray_rich_rows(self.host, status_item_id, &segmented_rows, segmented_count, &metric_rows, metric_count, &chart_rows, chart_count);
2742
2838
  }
2743
2839
 
2744
2840
  fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, title: []const u8) anyerror!void {
@@ -2748,7 +2844,7 @@ fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItem
2748
2844
 
2749
2845
  fn updateTrayPresentation(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, presentation: platform_mod.TrayPresentation) anyerror!void {
2750
2846
  const self: *MacPlatform = @ptrCast(@alignCast(context.?));
2751
- native_sdk_appkit_update_tray_presentation(self.host, status_item_id, presentation.title.ptr, presentation.title.len, presentation.width, @intFromEnum(presentation.tone), presentation.icon_opacity, if (presentation.monospaced) 1 else 0);
2847
+ native_sdk_appkit_update_tray_presentation(self.host, status_item_id, presentation.title.ptr, presentation.title.len, presentation.width, @intFromEnum(presentation.tone), presentation.icon_opacity, if (presentation.monospaced) 1 else 0, presentation.font_size, @intFromEnum(presentation.font_weight));
2752
2848
  }
2753
2849
 
2754
2850
  fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
@@ -2821,6 +2917,17 @@ test "mac status lifecycle hooks emit tray commands" {
2821
2917
  }
2822
2918
  }
2823
2919
 
2920
+ test "mac typed tray rows cross the AppKit ABI without text conventions" {
2921
+ for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |source| {
2922
+ try std.testing.expect(std.mem.indexOf(u8, source, "TraySegmentedView") != null);
2923
+ try std.testing.expect(std.mem.indexOf(u8, source, "NSSegmentedControl") != null);
2924
+ try std.testing.expect(std.mem.indexOf(u8, source, "TrayChartView") != null);
2925
+ try std.testing.expect(std.mem.indexOf(u8, source, "native_sdk_appkit_update_tray_rich_rows") != null);
2926
+ try std.testing.expect(std.mem.indexOf(u8, source, "range_selected") == null);
2927
+ try std.testing.expect(std.mem.indexOf(u8, source, "chart|") == null);
2928
+ }
2929
+ }
2930
+
2824
2931
  test "mac status menu updates preserve the menu being opened" {
2825
2932
  for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
2826
2933
  try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu = entry.menu;") != null);
@@ -45,6 +45,10 @@ const max_tray_title_bytes = types.max_tray_title_bytes;
45
45
  const max_tray_tooltip_bytes = types.max_tray_tooltip_bytes;
46
46
  const max_tray_item_label_bytes = types.max_tray_item_label_bytes;
47
47
  const max_tray_item_command_bytes = types.max_tray_item_command_bytes;
48
+ const max_tray_segment_options = types.max_tray_segment_options;
49
+ const max_tray_segment_label_bytes = types.max_tray_segment_label_bytes;
50
+ const max_tray_chart_values = types.max_tray_chart_values;
51
+ const max_tray_chart_text_bytes = types.max_tray_chart_text_bytes;
48
52
  const max_drop_paths_bytes = types.max_drop_paths_bytes;
49
53
  const max_drop_paths = types.max_drop_paths;
50
54
  const max_window_event_name_bytes = types.max_window_event_name_bytes;
@@ -319,6 +323,16 @@ const NullStatusItem = struct {
319
323
  open_command_len: usize = 0,
320
324
  presentation: TrayPresentation = .{},
321
325
  items: [max_tray_items]TrayMenuItem = undefined,
326
+ segment_options: [max_tray_items * max_tray_segment_options]types.TraySegmentOption = undefined,
327
+ segment_option_label_storage: [max_tray_items * max_tray_segment_options][max_tray_segment_label_bytes]u8 = undefined,
328
+ segment_option_command_storage: [max_tray_items * max_tray_segment_options][max_tray_item_command_bytes]u8 = undefined,
329
+ metric_primary_storage: [max_tray_items][max_tray_item_label_bytes]u8 = undefined,
330
+ metric_secondary_storage: [max_tray_items][types.max_tray_item_detail_bytes]u8 = undefined,
331
+ metric_accessibility_storage: [max_tray_items][max_tray_chart_text_bytes]u8 = undefined,
332
+ chart_values: [max_tray_items * max_tray_chart_values]f32 = undefined,
333
+ chart_leading_caption_storage: [max_tray_items][max_tray_chart_text_bytes]u8 = undefined,
334
+ chart_trailing_summary_storage: [max_tray_items][max_tray_chart_text_bytes]u8 = undefined,
335
+ chart_accessibility_storage: [max_tray_items][max_tray_chart_text_bytes]u8 = undefined,
322
336
  item_count: usize = 0,
323
337
  };
324
338
 
@@ -1789,7 +1803,42 @@ pub const NullPlatform = struct {
1789
1803
  const self: *NullPlatform = @ptrCast(@alignCast(context.?));
1790
1804
  const status_item = self.findStatusItem(status_item_id) orelse return error.InvalidTrayOptions;
1791
1805
  if (items.len > status_item.items.len) return error.InvalidTrayOptions;
1792
- for (items, 0..) |item, index| status_item.items[index] = item;
1806
+ for (items, 0..) |item, index| {
1807
+ status_item.items[index] = item;
1808
+ if (item.segmented) |segmented| {
1809
+ const start = index * max_tray_segment_options;
1810
+ for (segmented.options, 0..) |option, option_index| {
1811
+ const flat_index = start + option_index;
1812
+ status_item.segment_options[flat_index] = .{
1813
+ .id = option.id,
1814
+ .label = try copyInto(&status_item.segment_option_label_storage[flat_index], option.label),
1815
+ .command = try copyInto(&status_item.segment_option_command_storage[flat_index], option.command),
1816
+ .selected = option.selected,
1817
+ .enabled = option.enabled,
1818
+ };
1819
+ }
1820
+ status_item.items[index].segmented = .{ .options = status_item.segment_options[start .. start + segmented.options.len] };
1821
+ }
1822
+ if (item.metric) |metric| {
1823
+ status_item.items[index].metric = .{
1824
+ .primary_text = try copyInto(&status_item.metric_primary_storage[index], metric.primary_text),
1825
+ .secondary_text = try copyInto(&status_item.metric_secondary_storage[index], metric.secondary_text),
1826
+ .accessibility_label = try copyInto(&status_item.metric_accessibility_storage[index], metric.accessibility_label),
1827
+ };
1828
+ }
1829
+ if (item.chart) |chart| {
1830
+ const start = index * max_tray_chart_values;
1831
+ @memcpy(status_item.chart_values[start .. start + chart.values.len], chart.values);
1832
+ status_item.items[index].chart = .{
1833
+ .values = status_item.chart_values[start .. start + chart.values.len],
1834
+ .min_value = chart.min_value,
1835
+ .max_value = chart.max_value,
1836
+ .leading_caption = try copyInto(&status_item.chart_leading_caption_storage[index], chart.leading_caption),
1837
+ .trailing_summary = try copyInto(&status_item.chart_trailing_summary_storage[index], chart.trailing_summary),
1838
+ .accessibility_label = try copyInto(&status_item.chart_accessibility_storage[index], chart.accessibility_label),
1839
+ };
1840
+ }
1841
+ }
1793
1842
  status_item.item_count = items.len;
1794
1843
  self.tray_update_count += 1;
1795
1844
  }
@@ -330,6 +330,59 @@ test "null platform preserves the tray title when presentation styles are set" {
330
330
  try std.testing.expectEqual(types.TrayTone.warning, retitled.tone);
331
331
  }
332
332
 
333
+ test "null platform owns retained rich tray row bytes" {
334
+ var null_platform = NullPlatform.init(.{});
335
+ defer null_platform.deinit();
336
+
337
+ var segment_label = [_]u8{ 'D', 'a', 'y' };
338
+ var segment_command = [_]u8{ 'r', 'a', 'n', 'g', 'e' };
339
+ var metric_primary = [_]u8{ '2', '4', '9', '4' };
340
+ var metric_secondary = [_]u8{ 'T', 'o', 'd', 'a', 'y' };
341
+ var metric_accessibility = [_]u8{ 'M', 'e', 't', 'r', 'i', 'c' };
342
+ var chart_caption = [_]u8{ 'C', 'P', 'U' };
343
+ var chart_summary = [_]u8{ '5', '0', '%' };
344
+ var chart_accessibility = [_]u8{ 'C', 'P', 'U', ' ', '5', '0' };
345
+ const chart_values = [_]f32{0.5};
346
+
347
+ try null_platform.platform().services.createTray(.{ .items = &.{
348
+ .{ .role = .segmented, .segmented = .{ .options = &.{.{
349
+ .id = 20,
350
+ .label = &segment_label,
351
+ .command = &segment_command,
352
+ }} } },
353
+ .{ .role = .hero, .metric = .{
354
+ .primary_text = &metric_primary,
355
+ .secondary_text = &metric_secondary,
356
+ .accessibility_label = &metric_accessibility,
357
+ } },
358
+ .{ .role = .chart, .chart = .{
359
+ .values = &chart_values,
360
+ .leading_caption = &chart_caption,
361
+ .trailing_summary = &chart_summary,
362
+ .accessibility_label = &chart_accessibility,
363
+ } },
364
+ } });
365
+
366
+ @memset(&segment_label, 'X');
367
+ @memset(&segment_command, 'Y');
368
+ @memset(&metric_primary, 'P');
369
+ @memset(&metric_secondary, 'S');
370
+ @memset(&metric_accessibility, 'A');
371
+ @memset(&chart_caption, 'Z');
372
+ @memset(&chart_summary, 'W');
373
+ @memset(&chart_accessibility, 'Q');
374
+
375
+ const items = null_platform.trayItems();
376
+ try std.testing.expectEqualStrings("Day", items[0].segmented.?.options[0].label);
377
+ try std.testing.expectEqualStrings("range", items[0].segmented.?.options[0].command);
378
+ try std.testing.expectEqualStrings("2494", items[1].metric.?.primary_text);
379
+ try std.testing.expectEqualStrings("Today", items[1].metric.?.secondary_text);
380
+ try std.testing.expectEqualStrings("Metric", items[1].metric.?.accessibility_label);
381
+ try std.testing.expectEqualStrings("CPU", items[2].chart.?.leading_caption);
382
+ try std.testing.expectEqualStrings("50%", items[2].chart.?.trailing_summary);
383
+ try std.testing.expectEqualStrings("CPU 50", items[2].chart.?.accessibility_label);
384
+ }
385
+
333
386
  test "null platform records OS actions" {
334
387
  var null_platform = NullPlatform.init(.{});
335
388
  defer null_platform.deinit();
@@ -43,6 +43,10 @@ pub const max_tray_tooltip_bytes = types.max_tray_tooltip_bytes;
43
43
  pub const max_tray_item_label_bytes = types.max_tray_item_label_bytes;
44
44
  pub const max_tray_item_command_bytes = types.max_tray_item_command_bytes;
45
45
  pub const max_tray_item_detail_bytes = types.max_tray_item_detail_bytes;
46
+ pub const max_tray_segment_options = types.max_tray_segment_options;
47
+ pub const max_tray_segment_label_bytes = types.max_tray_segment_label_bytes;
48
+ pub const max_tray_chart_values = types.max_tray_chart_values;
49
+ pub const max_tray_chart_text_bytes = types.max_tray_chart_text_bytes;
46
50
  pub const max_drop_paths_bytes = types.max_drop_paths_bytes;
47
51
  pub const max_drop_paths = types.max_drop_paths;
48
52
  pub const max_window_event_name_bytes = types.max_window_event_name_bytes;
@@ -142,8 +146,13 @@ pub const TrayShell = types.TrayShell;
142
146
  pub const trayShell = types.trayShell;
143
147
  pub const TrayTone = types.TrayTone;
144
148
  pub const TrayPresentation = types.TrayPresentation;
149
+ pub const TrayFontWeight = types.TrayFontWeight;
145
150
  pub const TrayMenuItem = types.TrayMenuItem;
146
151
  pub const TrayItemRole = types.TrayItemRole;
152
+ pub const TraySegmentOption = types.TraySegmentOption;
153
+ pub const TraySegmentedRow = types.TraySegmentedRow;
154
+ pub const TrayMetricRow = types.TrayMetricRow;
155
+ pub const TrayChartRow = types.TrayChartRow;
147
156
  pub const NativeCommandEvent = types.NativeCommandEvent;
148
157
  pub const MenuCommandEvent = types.MenuCommandEvent;
149
158
  pub const TrayCommandEvent = types.TrayCommandEvent;
@@ -266,6 +266,10 @@ pub const max_tray_tooltip_bytes: usize = 256;
266
266
  pub const max_tray_item_label_bytes: usize = 256;
267
267
  pub const max_tray_item_command_bytes: usize = 128;
268
268
  pub const max_tray_item_detail_bytes: usize = 256;
269
+ pub const max_tray_segment_options: usize = 8;
270
+ pub const max_tray_segment_label_bytes: usize = 64;
271
+ pub const max_tray_chart_values: usize = 32;
272
+ pub const max_tray_chart_text_bytes: usize = 128;
269
273
  pub const max_drop_paths_bytes: usize = 8192;
270
274
  pub const max_drop_paths: usize = max_drop_paths_bytes / 2 + 1;
271
275
  pub const max_window_event_name_bytes: usize = 64;
@@ -1466,6 +1470,13 @@ pub const TrayTone = enum(u8) {
1466
1470
  critical,
1467
1471
  };
1468
1472
 
1473
+ pub const TrayFontWeight = enum(u8) {
1474
+ regular,
1475
+ medium,
1476
+ semibold,
1477
+ bold,
1478
+ };
1479
+
1469
1480
  /// The model-derived part of a status item. Keeping this separate from
1470
1481
  /// icon/tooltip/activation options lets UiApp patch presentation without
1471
1482
  /// recreating the native item.
@@ -1477,6 +1488,9 @@ pub const TrayPresentation = struct {
1477
1488
  tone: TrayTone = .normal,
1478
1489
  icon_opacity: f32 = 1,
1479
1490
  monospaced: bool = false,
1491
+ /// Explicit title size in points; zero keeps the host's menu-bar default.
1492
+ font_size: f32 = 0,
1493
+ font_weight: TrayFontWeight = .regular,
1480
1494
  };
1481
1495
 
1482
1496
  pub const TrayOptions = struct {
@@ -1531,6 +1545,45 @@ pub const TrayItemRole = enum(u8) {
1531
1545
  hero,
1532
1546
  agent,
1533
1547
  context,
1548
+ segmented,
1549
+ chart,
1550
+ };
1551
+
1552
+ /// One choice inside a typed segmented tray row. Its stable id and command
1553
+ /// participate in the same namespace and dispatch route as an ordinary tray
1554
+ /// command row; the containing row itself is display structure, not an
1555
+ /// action. At most one option in a row may be selected.
1556
+ pub const TraySegmentOption = struct {
1557
+ id: TrayItemId,
1558
+ label: []const u8,
1559
+ command: []const u8,
1560
+ selected: bool = false,
1561
+ enabled: bool = true,
1562
+ };
1563
+
1564
+ pub const TraySegmentedRow = struct {
1565
+ options: []const TraySegmentOption = &.{},
1566
+ };
1567
+
1568
+ /// A prominent two-line metric block inside a tray menu. This is semantic
1569
+ /// dropdown content, distinct from the persistent menu-bar title.
1570
+ pub const TrayMetricRow = struct {
1571
+ primary_text: []const u8,
1572
+ secondary_text: []const u8 = "",
1573
+ accessibility_label: []const u8,
1574
+ };
1575
+
1576
+ /// A bounded bar-chart/sparkline readout. Values are finite and must fall in
1577
+ /// the explicit `min_value...max_value` domain. The text fields remain
1578
+ /// semantic data on every host; capable macOS hosts place them around a
1579
+ /// native AppKit-drawn bar chart.
1580
+ pub const TrayChartRow = struct {
1581
+ values: []const f32 = &.{},
1582
+ min_value: f32 = 0,
1583
+ max_value: f32 = 1,
1584
+ leading_caption: []const u8 = "",
1585
+ trailing_summary: []const u8 = "",
1586
+ accessibility_label: []const u8 = "",
1534
1587
  };
1535
1588
 
1536
1589
  pub const TrayMenuItem = struct {
@@ -1543,6 +1596,11 @@ pub const TrayMenuItem = struct {
1543
1596
  role: TrayItemRole = .command,
1544
1597
  key: []const u8 = "",
1545
1598
  modifiers: ShortcutModifiers = .{},
1599
+ /// Typed rich-row payloads. Exactly one is present for its matching role;
1600
+ /// both stay null for every existing command/readout row.
1601
+ segmented: ?TraySegmentedRow = null,
1602
+ metric: ?TrayMetricRow = null,
1603
+ chart: ?TrayChartRow = null,
1546
1604
  };
1547
1605
 
1548
1606
  pub const NativeCommandEvent = struct {
@@ -1519,6 +1519,34 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
1519
1519
 
1520
1520
  const max_tray_items: usize = 32;
1521
1521
 
1522
+ const TrayFallbackText = struct {
1523
+ label: []const u8,
1524
+ detail: []const u8,
1525
+ };
1526
+
1527
+ /// Project a rich row onto Win32's plain label/detail menu surface. Chart
1528
+ /// captions are optional, but the accessibility label is required, so a
1529
+ /// captionless chart must still remain visible instead of becoming a blank
1530
+ /// disabled row.
1531
+ fn trayFallbackText(item: platform_mod.TrayMenuItem) TrayFallbackText {
1532
+ if (item.metric) |metric| return .{
1533
+ .label = metric.primary_text,
1534
+ .detail = metric.secondary_text,
1535
+ };
1536
+ if (item.chart) |chart| {
1537
+ if (chart.leading_caption.len > 0) return .{
1538
+ .label = chart.leading_caption,
1539
+ .detail = chart.trailing_summary,
1540
+ };
1541
+ if (chart.trailing_summary.len > 0) return .{
1542
+ .label = chart.trailing_summary,
1543
+ .detail = "",
1544
+ };
1545
+ return .{ .label = chart.accessibility_label, .detail = "" };
1546
+ }
1547
+ return .{ .label = item.label, .detail = item.detail };
1548
+ }
1549
+
1522
1550
  fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
1523
1551
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1524
1552
  if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
@@ -1545,7 +1573,7 @@ fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemI
1545
1573
  const self: *WindowsPlatform = @ptrCast(@alignCast(context.?));
1546
1574
  if (status_item_id != platform_mod.primary_status_item_id) return error.UnsupportedService;
1547
1575
  if (self.web_engine != .system) return error.UnsupportedService;
1548
- const count = @min(items.len, max_tray_items);
1576
+ var count: usize = 0;
1549
1577
  var ids: [max_tray_items]u32 = undefined;
1550
1578
  var labels: [max_tray_items][*]const u8 = undefined;
1551
1579
  var label_lens: [max_tray_items]usize = undefined;
@@ -1563,23 +1591,44 @@ fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemI
1563
1591
  // returning). Doubling covers the all-ampersands worst case.
1564
1592
  var label_pool: [max_tray_items * (platform_mod.max_tray_item_label_bytes + platform_mod.max_tray_item_detail_bytes) * 2]u8 = undefined;
1565
1593
  var pool_used: usize = 0;
1566
- for (items[0..count], 0..) |item, index| {
1567
- const label = escapeMenuLabelAmpersands(item.label, &label_pool, &pool_used);
1568
- const detail = escapeMenuLabelAmpersands(item.detail, &label_pool, &pool_used);
1569
- ids[index] = item.id;
1570
- labels[index] = label.ptr;
1571
- label_lens[index] = label.len;
1572
- separators[index] = if (item.separator) 1 else 0;
1594
+ for (items) |item| {
1595
+ if (item.segmented) |segmented| {
1596
+ for (segmented.options) |option| {
1597
+ const label = escapeMenuLabelAmpersands(option.label, &label_pool, &pool_used);
1598
+ ids[count] = option.id;
1599
+ labels[count] = label.ptr;
1600
+ label_lens[count] = label.len;
1601
+ separators[count] = 0;
1602
+ enabled_flags[count] = if (option.enabled) 1 else 0;
1603
+ const selected_detail = if (option.selected) "Selected" else "";
1604
+ details[count] = selected_detail.ptr;
1605
+ detail_lens[count] = selected_detail.len;
1606
+ roles[count] = @intFromEnum(platform_mod.TrayItemRole.command);
1607
+ keys[count] = "".ptr;
1608
+ key_lens[count] = 0;
1609
+ modifiers[count] = 0;
1610
+ count += 1;
1611
+ }
1612
+ continue;
1613
+ }
1614
+ const fallback = trayFallbackText(item);
1615
+ const label = escapeMenuLabelAmpersands(fallback.label, &label_pool, &pool_used);
1616
+ const detail = escapeMenuLabelAmpersands(fallback.detail, &label_pool, &pool_used);
1617
+ ids[count] = item.id;
1618
+ labels[count] = label.ptr;
1619
+ label_lens[count] = label.len;
1620
+ separators[count] = if (item.separator) 1 else 0;
1573
1621
  // Windows has no custom status-menu row seam. Preserve semantic
1574
1622
  // readouts as visible detail text, while only command/agent rows can
1575
1623
  // become actions.
1576
- enabled_flags[index] = if (item.enabled and (item.role == .command or item.role == .agent)) 1 else 0;
1577
- details[index] = detail.ptr;
1578
- detail_lens[index] = detail.len;
1579
- roles[index] = @intFromEnum(item.role);
1580
- keys[index] = item.key.ptr;
1581
- key_lens[index] = item.key.len;
1582
- modifiers[index] = shortcutModifierFlags(item.modifiers);
1624
+ enabled_flags[count] = if (item.enabled and (item.role == .command or item.role == .agent)) 1 else 0;
1625
+ details[count] = detail.ptr;
1626
+ detail_lens[count] = detail.len;
1627
+ roles[count] = @intFromEnum(item.role);
1628
+ keys[count] = item.key.ptr;
1629
+ key_lens[count] = item.key.len;
1630
+ modifiers[count] = shortcutModifierFlags(item.modifiers);
1631
+ count += 1;
1583
1632
  }
1584
1633
  if (native_sdk_windows_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count) == 0) return error.UnsupportedService;
1585
1634
  }
@@ -2183,6 +2232,30 @@ test "windows tray carries lifecycle commands rich rows and key equivalents into
2183
2232
  try std.testing.expect(std.mem.indexOf(u8, host_source, "tray_event == NIN_SELECT || tray_event == NIN_KEYSELECT || tray_event == WM_LBUTTONUP") != null);
2184
2233
  }
2185
2234
 
2235
+ test "windows chart fallback uses accessibility text when captions are absent" {
2236
+ const values = [_]f32{0.5};
2237
+ const fallback = trayFallbackText(.{
2238
+ .role = .chart,
2239
+ .chart = .{
2240
+ .values = &values,
2241
+ .accessibility_label = "CPU history, 50 percent",
2242
+ },
2243
+ });
2244
+ try std.testing.expectEqualStrings("CPU history, 50 percent", fallback.label);
2245
+ try std.testing.expectEqualStrings("", fallback.detail);
2246
+
2247
+ const summarized = trayFallbackText(.{
2248
+ .role = .chart,
2249
+ .chart = .{
2250
+ .values = &values,
2251
+ .trailing_summary = "50%",
2252
+ .accessibility_label = "CPU history, 50 percent",
2253
+ },
2254
+ });
2255
+ try std.testing.expectEqualStrings("50%", summarized.label);
2256
+ try std.testing.expectEqualStrings("", summarized.detail);
2257
+ }
2258
+
2186
2259
  test "windows refuses a tray-less .hide main window at platform init instead of stranding it hidden" {
2187
2260
  // The pre-created MAIN window never passes through the runtime's
2188
2261
  // create gate, so the platform's init gate must hold the same line
@@ -486,6 +486,7 @@ pub const ReferenceRenderSurface = struct {
486
486
  } else return error.ReferenceRenderUnsupportedCommand;
487
487
 
488
488
  const src_rect = referenceImageSourceRect(image, value.src) orelse return;
489
+ const sample_bounds = referenceImageSampleBounds(image, src_rect);
489
490
  const local_dst = referenceImageDestinationRect(value.dst, src_rect, value.fit) orelse return;
490
491
  const dst_rect = command.transform.transformRect(local_dst).normalized();
491
492
  // The rounded mask applies over the REQUESTED destination (the
@@ -510,7 +511,7 @@ pub const ReferenceRenderSurface = struct {
510
511
  // once per (image content, size, phase) and every later repaint
511
512
  // — the cover-loading cascade, a re-opened view, a whole-pixel
512
513
  // move — blends from the panel.
513
- if (self.imageScalePanel(image, value, src_rect, dst_rect, pixel_rect)) |panel| {
514
+ if (self.imageScalePanel(image, value, src_rect, sample_bounds, dst_rect, pixel_rect)) |panel| {
514
515
  const dst_x0: i64 = @intFromFloat(@floor(dst_rect.x));
515
516
  const dst_y0: i64 = @intFromFloat(@floor(dst_rect.y));
516
517
  var y = pixel_rect.y;
@@ -549,7 +550,7 @@ pub const ReferenceRenderSurface = struct {
549
550
  if (has_mask and !referencePointInRoundedRect(point, mask_rect, mask_radius)) continue;
550
551
  const u = std.math.clamp((point.x - dst_rect.x) / dst_rect.width, 0, 1);
551
552
  const v = std.math.clamp((point.y - dst_rect.y) / dst_rect.height, 0, 1);
552
- const sample = referenceSampleImage(image, src_rect, u, v, value.sampling);
553
+ const sample = referenceSampleImage(image, src_rect, sample_bounds, u, v, value.sampling);
553
554
  const index = (y * self.width + x) * 4;
554
555
  const dst = [4]u8{
555
556
  self.pixels[index + 0],
@@ -575,7 +576,7 @@ pub const ReferenceRenderSurface = struct {
575
576
  width: usize,
576
577
  };
577
578
 
578
- fn imageScalePanel(self: ReferenceRenderSurface, image: ReferenceImage, value: DrawImage, src_rect: geometry.RectF, dst_rect: geometry.RectF, pixel_rect: ReferencePixelRect) ?ImageScalePanel {
579
+ fn imageScalePanel(self: ReferenceRenderSurface, image: ReferenceImage, value: DrawImage, src_rect: geometry.RectF, sample_bounds: ReferenceImageSampleBounds, dst_rect: geometry.RectF, pixel_rect: ReferencePixelRect) ?ImageScalePanel {
579
580
  const memo = self.render_memo orelse return null;
580
581
  // Exact-arithmetic bounds: pixel offsets and phases must stay in
581
582
  // f32's exact-integer range for the phase-relative identity
@@ -630,7 +631,7 @@ pub const ReferenceRenderSurface = struct {
630
631
  var column: usize = 0;
631
632
  while (column < panel_width) : (column += 1) {
632
633
  const u = std.math.clamp(((@as(f32, @floatFromInt(column)) + 0.5) - phase_x) / dst_rect.width, 0, 1);
633
- const sample = referenceSampleImage(image, src_rect, u, v, value.sampling);
634
+ const sample = referenceSampleImage(image, src_rect, sample_bounds, u, v, value.sampling);
634
635
  const offset = (row * panel_width + column) * 4;
635
636
  buffer[offset] = sample[0];
636
637
  buffer[offset + 1] = sample[1];
@@ -1372,22 +1373,43 @@ const ReferencePremultipliedLinearColor = struct {
1372
1373
  a: f32 = 0,
1373
1374
  };
1374
1375
 
1375
- fn referenceSampleImage(image: ReferenceImage, src: geometry.RectF, u: f32, v: f32, sampling: ImageSampling) [4]u8 {
1376
+ fn referenceSampleImage(image: ReferenceImage, src: geometry.RectF, bounds: ReferenceImageSampleBounds, u: f32, v: f32, sampling: ImageSampling) [4]u8 {
1376
1377
  return switch (sampling) {
1377
- .nearest => referenceSampleImageNearest(image, src, u, v),
1378
- .linear => referenceSampleImageLinear(image, src, u, v),
1378
+ .nearest => referenceSampleImageNearest(image, src, bounds, u, v),
1379
+ .linear => referenceSampleImageLinear(image, src, bounds, u, v),
1379
1380
  };
1380
1381
  }
1381
1382
 
1382
- fn referenceSampleImageNearest(image: ReferenceImage, src: geometry.RectF, u: f32, v: f32) [4]u8 {
1383
+ const ReferenceImageSampleBounds = struct {
1384
+ min_x: i32,
1385
+ min_y: i32,
1386
+ max_x: i32,
1387
+ max_y: i32,
1388
+ };
1389
+
1390
+ /// Inclusive texel bounds touched by a clipped source rectangle. Native
1391
+ /// image APIs constrain filtering to their source portion; mirror that
1392
+ /// here so scaling a texture-atlas tile never samples an adjacent tile.
1393
+ fn referenceImageSampleBounds(image: ReferenceImage, src: geometry.RectF) ReferenceImageSampleBounds {
1394
+ const image_max_x: i32 = @intCast(image.width - 1);
1395
+ const image_max_y: i32 = @intCast(image.height - 1);
1396
+ return .{
1397
+ .min_x = clampI32(referenceFloor(src.minX()), 0, image_max_x),
1398
+ .min_y = clampI32(referenceFloor(src.minY()), 0, image_max_y),
1399
+ .max_x = clampI32(referenceCeil(src.maxX()) - 1, 0, image_max_x),
1400
+ .max_y = clampI32(referenceCeil(src.maxY()) - 1, 0, image_max_y),
1401
+ };
1402
+ }
1403
+
1404
+ fn referenceSampleImageNearest(image: ReferenceImage, src: geometry.RectF, bounds: ReferenceImageSampleBounds, u: f32, v: f32) [4]u8 {
1383
1405
  const sample_x_f = src.x + std.math.clamp(u, 0, 1) * src.width;
1384
1406
  const sample_y_f = src.y + std.math.clamp(v, 0, 1) * src.height;
1385
- const x = clampI32(referenceFloor(sample_x_f), 0, @intCast(image.width - 1));
1386
- const y = clampI32(referenceFloor(sample_y_f), 0, @intCast(image.height - 1));
1407
+ const x = clampI32(referenceFloor(sample_x_f), bounds.min_x, bounds.max_x);
1408
+ const y = clampI32(referenceFloor(sample_y_f), bounds.min_y, bounds.max_y);
1387
1409
  return referenceImagePixel(image, x, y);
1388
1410
  }
1389
1411
 
1390
- fn referenceSampleImageLinear(image: ReferenceImage, src: geometry.RectF, u: f32, v: f32) [4]u8 {
1412
+ fn referenceSampleImageLinear(image: ReferenceImage, src: geometry.RectF, bounds: ReferenceImageSampleBounds, u: f32, v: f32) [4]u8 {
1391
1413
  // Belt over the renderPass-level fill: direct sampler callers (unit
1392
1414
  // tests, future paths) stay correct. One predictable branch per
1393
1415
  // output pixel — noise next to the twelve pows the table replaces.
@@ -1396,10 +1418,10 @@ fn referenceSampleImageLinear(image: ReferenceImage, src: geometry.RectF, u: f32
1396
1418
  const sample_y_f = src.y + std.math.clamp(v, 0, 1) * src.height - 0.5;
1397
1419
  const x_floor = referenceFloor(sample_x_f);
1398
1420
  const y_floor = referenceFloor(sample_y_f);
1399
- const x0 = clampI32(x_floor, 0, @intCast(image.width - 1));
1400
- const y0 = clampI32(y_floor, 0, @intCast(image.height - 1));
1401
- const x1 = clampI32(x_floor + 1, 0, @intCast(image.width - 1));
1402
- const y1 = clampI32(y_floor + 1, 0, @intCast(image.height - 1));
1421
+ const x0 = clampI32(x_floor, bounds.min_x, bounds.max_x);
1422
+ const y0 = clampI32(y_floor, bounds.min_y, bounds.max_y);
1423
+ const x1 = clampI32(x_floor + 1, bounds.min_x, bounds.max_x);
1424
+ const y1 = clampI32(y_floor + 1, bounds.min_y, bounds.max_y);
1403
1425
  const tx = std.math.clamp(sample_x_f - @as(f32, @floatFromInt(x_floor)), 0, 1);
1404
1426
  const ty = std.math.clamp(sample_y_f - @as(f32, @floatFromInt(y_floor)), 0, 1);
1405
1427