@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
|
@@ -705,6 +705,44 @@ typedef struct {
|
|
|
705
705
|
|
|
706
706
|
typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t status_item_id, uint32_t item_id);
|
|
707
707
|
|
|
708
|
+
typedef struct {
|
|
709
|
+
uint32_t item_id;
|
|
710
|
+
const char *label;
|
|
711
|
+
size_t label_len;
|
|
712
|
+
int selected;
|
|
713
|
+
int enabled;
|
|
714
|
+
} native_sdk_appkit_tray_segment_option_t;
|
|
715
|
+
|
|
716
|
+
typedef struct {
|
|
717
|
+
size_t row_index;
|
|
718
|
+
const native_sdk_appkit_tray_segment_option_t *options;
|
|
719
|
+
size_t option_count;
|
|
720
|
+
} native_sdk_appkit_tray_segmented_row_t;
|
|
721
|
+
|
|
722
|
+
typedef struct {
|
|
723
|
+
size_t row_index;
|
|
724
|
+
const char *primary_text;
|
|
725
|
+
size_t primary_text_len;
|
|
726
|
+
const char *secondary_text;
|
|
727
|
+
size_t secondary_text_len;
|
|
728
|
+
const char *accessibility_label;
|
|
729
|
+
size_t accessibility_label_len;
|
|
730
|
+
} native_sdk_appkit_tray_metric_row_t;
|
|
731
|
+
|
|
732
|
+
typedef struct {
|
|
733
|
+
size_t row_index;
|
|
734
|
+
const float *values;
|
|
735
|
+
size_t value_count;
|
|
736
|
+
double min_value;
|
|
737
|
+
double max_value;
|
|
738
|
+
const char *leading_caption;
|
|
739
|
+
size_t leading_caption_len;
|
|
740
|
+
const char *trailing_summary;
|
|
741
|
+
size_t trailing_summary_len;
|
|
742
|
+
const char *accessibility_label;
|
|
743
|
+
size_t accessibility_label_len;
|
|
744
|
+
} native_sdk_appkit_tray_chart_row_t;
|
|
745
|
+
|
|
708
746
|
/* One native scroll driver's desired state (see PlatformServices
|
|
709
747
|
* set_gpu_surface_scroll_drivers_fn). Frame coordinates are view-local
|
|
710
748
|
* canvas points (top-left origin, y-down); the host flips to AppKit
|
|
@@ -772,15 +810,16 @@ int native_sdk_appkit_show_context_menu(native_sdk_appkit_host_t *host, uint64_t
|
|
|
772
810
|
native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_open_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
773
811
|
size_t native_sdk_appkit_show_save_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_save_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
774
812
|
int native_sdk_appkit_show_message_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_message_dialog_opts_t *opts);
|
|
775
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
813
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
776
814
|
void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *tooltip, size_t tooltip_len, int visible, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
777
815
|
void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t status_item_id, const uint32_t *item_ids, const char *const *labels, const size_t *label_lens, const int *separators, const int *enabled_flags, const char *const *details, const size_t *detail_lens, const int *roles, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
|
|
816
|
+
void native_sdk_appkit_update_tray_rich_rows(native_sdk_appkit_host_t *host, uint32_t status_item_id, const native_sdk_appkit_tray_segmented_row_t *segmented_rows, size_t segmented_count, const native_sdk_appkit_tray_metric_row_t *metric_rows, size_t metric_count, const native_sdk_appkit_tray_chart_row_t *chart_rows, size_t chart_count);
|
|
778
817
|
/* Retitle the live status item's button without re-creating it (create
|
|
779
818
|
* would flicker and reshuffle the menu bar). Empty title falls back to
|
|
780
819
|
* the icon-only square well, or the app-name initial when there is no
|
|
781
820
|
* icon either — the same fallbacks as create. */
|
|
782
821
|
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len);
|
|
783
|
-
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced);
|
|
822
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight);
|
|
784
823
|
void native_sdk_appkit_remove_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id);
|
|
785
824
|
void native_sdk_appkit_set_tray_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_tray_callback_t callback, void *context);
|
|
786
825
|
|
|
@@ -774,6 +774,10 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
774
774
|
@property(nonatomic, assign) uint32_t modifiers;
|
|
775
775
|
@end
|
|
776
776
|
|
|
777
|
+
@interface NativeSdkTraySegmentedControl : NSSegmentedControl
|
|
778
|
+
@property(nonatomic, assign) NSInteger sourceSelectedSegment;
|
|
779
|
+
@end
|
|
780
|
+
|
|
777
781
|
@interface NativeSdkStatusItemEntry : NSObject
|
|
778
782
|
@property(nonatomic, assign) uint32_t identifier;
|
|
779
783
|
@property(nonatomic, strong) NSStatusItem *item;
|
|
@@ -784,6 +788,8 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
784
788
|
@property(nonatomic, assign) int presentationTone;
|
|
785
789
|
@property(nonatomic, assign) double presentationIconOpacity;
|
|
786
790
|
@property(nonatomic, assign) BOOL presentationMonospaced;
|
|
791
|
+
@property(nonatomic, assign) double presentationFontSize;
|
|
792
|
+
@property(nonatomic, assign) int presentationFontWeight;
|
|
787
793
|
@property(nonatomic, strong) NSString *activationCommand;
|
|
788
794
|
@property(nonatomic, strong) NSString *alternateActivationCommand;
|
|
789
795
|
@property(nonatomic, strong) NSString *openCommand;
|
|
@@ -1095,6 +1101,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
|
|
|
1095
1101
|
- (NativeSdkStatusItemEntry *)statusEntryForMenu:(NSMenu *)menu;
|
|
1096
1102
|
- (void)emitStatusCommand:(NSString *)command statusItemId:(uint32_t)statusItemId;
|
|
1097
1103
|
- (void)statusItemActivated:(id)sender;
|
|
1104
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control;
|
|
1098
1105
|
- (uint64_t)activeCommandWindowId;
|
|
1099
1106
|
- (void)setMenusWithTitles:(const char *const *)menuTitles titleLengths:(const size_t *)menuTitleLengths count:(size_t)menuCount itemMenuIndices:(const uint32_t *)itemMenuIndices itemLabels:(const char *const *)itemLabels itemLabelLengths:(const size_t *)itemLabelLengths itemCommands:(const char *const *)itemCommands itemCommandLengths:(const size_t *)itemCommandLengths itemKeys:(const char *const *)itemKeys itemKeyLengths:(const size_t *)itemKeyLengths itemModifiers:(const uint32_t *)itemModifiers itemSeparators:(const int *)itemSeparators itemEnabled:(const int *)itemEnabled itemChecked:(const int *)itemChecked itemCount:(size_t)itemCount;
|
|
1100
1107
|
- (void)runWithCallback:(native_sdk_appkit_event_callback_t)callback context:(void *)context;
|
|
@@ -7480,6 +7487,9 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
|
|
|
7480
7487
|
@implementation NativeSdkShortcut
|
|
7481
7488
|
@end
|
|
7482
7489
|
|
|
7490
|
+
@implementation NativeSdkTraySegmentedControl
|
|
7491
|
+
@end
|
|
7492
|
+
|
|
7483
7493
|
@implementation NativeSdkStatusItemEntry
|
|
7484
7494
|
@end
|
|
7485
7495
|
|
|
@@ -12197,6 +12207,22 @@ static void NativeSdkVideoFittedSize(double naturalWidth, double naturalHeight,
|
|
|
12197
12207
|
}
|
|
12198
12208
|
}
|
|
12199
12209
|
|
|
12210
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control {
|
|
12211
|
+
NSInteger selected = control.selectedSegment;
|
|
12212
|
+
if (selected < 0 || !self.trayCallback) return;
|
|
12213
|
+
NSInteger itemId = [control tagForSegment:selected];
|
|
12214
|
+
if (itemId <= 0) return;
|
|
12215
|
+
// Selection is model-owned. AppKit applies its optimistic selection
|
|
12216
|
+
// before sending the action; restore the declared state before dispatch
|
|
12217
|
+
// so an ignored or failed command cannot leave native chrome ahead of
|
|
12218
|
+
// the model. A successful dispatch rebuilds the row from the new state.
|
|
12219
|
+
NSInteger sourceSelected = [(NativeSdkTraySegmentedControl *)control sourceSelectedSegment];
|
|
12220
|
+
for (NSInteger index = 0; index < control.segmentCount; index++) {
|
|
12221
|
+
[control setSelected:index == sourceSelected forSegment:index];
|
|
12222
|
+
}
|
|
12223
|
+
self.trayCallback(self.trayContext, (uint32_t)control.tag, (uint32_t)itemId);
|
|
12224
|
+
}
|
|
12225
|
+
|
|
12200
12226
|
- (NativeSdkStatusItemEntry *)statusEntryForId:(uint32_t)identifier {
|
|
12201
12227
|
return self.statusItems[@(identifier)];
|
|
12202
12228
|
}
|
|
@@ -13344,20 +13370,33 @@ static NSImage *NativeSdkTrayImageWithOpacity(NSImage *source, double opacity) {
|
|
|
13344
13370
|
return image;
|
|
13345
13371
|
}
|
|
13346
13372
|
|
|
13347
|
-
static
|
|
13373
|
+
static NSFontWeight NativeSdkTrayFontWeight(int weight) {
|
|
13374
|
+
switch (weight) {
|
|
13375
|
+
case 1: return NSFontWeightMedium;
|
|
13376
|
+
case 2: return NSFontWeightSemibold;
|
|
13377
|
+
case 3: return NSFontWeightBold;
|
|
13378
|
+
default: return NSFontWeightRegular;
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
|
|
13382
|
+
static void NativeSdkApplyTrayPresentation(NativeSdkAppKitHost *object, NativeSdkStatusItemEntry *entry, NSString *requestedTitle, double width, int tone, double iconOpacity, BOOL monospaced, double fontSize, int fontWeight) {
|
|
13348
13383
|
if (!entry.item) return;
|
|
13349
13384
|
entry.presentationTitle = requestedTitle ?: @"";
|
|
13350
13385
|
entry.presentationWidth = width;
|
|
13351
13386
|
entry.presentationTone = tone;
|
|
13352
13387
|
entry.presentationIconOpacity = iconOpacity;
|
|
13353
13388
|
entry.presentationMonospaced = monospaced;
|
|
13389
|
+
entry.presentationFontSize = fontSize;
|
|
13390
|
+
entry.presentationFontWeight = fontWeight;
|
|
13354
13391
|
NSString *title = requestedTitle ?: @"";
|
|
13355
13392
|
if (!entry.baseImage && title.length == 0) {
|
|
13356
13393
|
title = object.appName.length > 0 ? [object.appName substringToIndex:MIN(1, object.appName.length)] : @"Z";
|
|
13357
13394
|
}
|
|
13395
|
+
CGFloat resolvedSize = fontSize > 0 ? fontSize : 11;
|
|
13396
|
+
NSFontWeight resolvedWeight = NativeSdkTrayFontWeight(fontWeight);
|
|
13358
13397
|
NSFont *font = monospaced
|
|
13359
|
-
?
|
|
13360
|
-
: [NSFont systemFontOfSize:
|
|
13398
|
+
? [NSFont monospacedSystemFontOfSize:resolvedSize weight:resolvedWeight]
|
|
13399
|
+
: [NSFont systemFontOfSize:resolvedSize weight:resolvedWeight];
|
|
13361
13400
|
NSStatusBarButton *button = entry.item.button;
|
|
13362
13401
|
if (tone == 0) {
|
|
13363
13402
|
button.title = title;
|
|
@@ -13398,7 +13437,7 @@ static void NativeSdkApplyTrayShell(NativeSdkAppKitHost *object, NativeSdkStatus
|
|
|
13398
13437
|
entry.item.visible = visible != 0;
|
|
13399
13438
|
}
|
|
13400
13439
|
|
|
13401
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
13440
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len) {
|
|
13402
13441
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13403
13442
|
@autoreleasepool {
|
|
13404
13443
|
NSNumber *key = @(status_item_id);
|
|
@@ -13415,7 +13454,7 @@ void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t stat
|
|
|
13415
13454
|
entry.item = [[NSStatusBar systemStatusBar] statusItemWithLength:hasTitle ? NSVariableStatusItemLength : NSSquareStatusItemLength];
|
|
13416
13455
|
NSString *titleString = hasTitle ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13417
13456
|
NativeSdkApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
13418
|
-
NativeSdkApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0);
|
|
13457
|
+
NativeSdkApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
13419
13458
|
}
|
|
13420
13459
|
}
|
|
13421
13460
|
|
|
@@ -13425,7 +13464,7 @@ void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_
|
|
|
13425
13464
|
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13426
13465
|
if (!entry) return;
|
|
13427
13466
|
NativeSdkApplyTrayShell(object, entry, icon_path, icon_path_len, tooltip, tooltip_len, visible, activation_command, activation_command_len, alternate_activation_command, alternate_activation_command_len, open_command, open_command_len);
|
|
13428
|
-
NativeSdkApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced);
|
|
13467
|
+
NativeSdkApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced, entry.presentationFontSize, entry.presentationFontWeight);
|
|
13429
13468
|
if (entry.activationCommand.length == 0 && entry.alternateActivationCommand.length == 0) entry.item.menu = entry.menu;
|
|
13430
13469
|
else entry.item.menu = nil;
|
|
13431
13470
|
}
|
|
@@ -13438,8 +13477,115 @@ enum {
|
|
|
13438
13477
|
NativeSdkTrayRoleHero = 3,
|
|
13439
13478
|
NativeSdkTrayRoleAgent = 4,
|
|
13440
13479
|
NativeSdkTrayRoleContext = 5,
|
|
13480
|
+
NativeSdkTrayRoleSegmented = 6,
|
|
13481
|
+
NativeSdkTrayRoleChart = 7,
|
|
13441
13482
|
};
|
|
13442
13483
|
|
|
13484
|
+
@interface NativeSdkTrayBarChartView : NSView
|
|
13485
|
+
@property(nonatomic, copy) NSArray<NSNumber *> *values;
|
|
13486
|
+
@property(nonatomic, assign) double minValue;
|
|
13487
|
+
@property(nonatomic, assign) double maxValue;
|
|
13488
|
+
@end
|
|
13489
|
+
|
|
13490
|
+
@implementation NativeSdkTrayBarChartView
|
|
13491
|
+
- (BOOL)isFlipped { return YES; }
|
|
13492
|
+
- (void)drawRect:(NSRect)dirtyRect {
|
|
13493
|
+
[super drawRect:dirtyRect];
|
|
13494
|
+
if (self.values.count == 0 || !(self.maxValue > self.minValue)) return;
|
|
13495
|
+
CGFloat gap = 2;
|
|
13496
|
+
CGFloat barWidth = MAX(1, (NSWidth(self.bounds) - gap * (self.values.count - 1)) / self.values.count);
|
|
13497
|
+
CGFloat x = 0;
|
|
13498
|
+
[NSColor.controlAccentColor setFill];
|
|
13499
|
+
for (NSNumber *number in self.values) {
|
|
13500
|
+
double fraction = (number.doubleValue - self.minValue) / (self.maxValue - self.minValue);
|
|
13501
|
+
fraction = MIN(MAX(fraction, 0), 1);
|
|
13502
|
+
CGFloat height = MAX(fraction > 0 ? 1 : 0, floor(fraction * NSHeight(self.bounds)));
|
|
13503
|
+
NSRectFill(NSMakeRect(x, NSHeight(self.bounds) - height, barWidth, height));
|
|
13504
|
+
x += barWidth + gap;
|
|
13505
|
+
}
|
|
13506
|
+
}
|
|
13507
|
+
@end
|
|
13508
|
+
|
|
13509
|
+
static NSString *NativeSdkTrayString(const char *bytes, size_t len) {
|
|
13510
|
+
return bytes && len > 0 ? ([[NSString alloc] initWithBytes:bytes length:len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13511
|
+
}
|
|
13512
|
+
|
|
13513
|
+
static NSView *NativeSdkTraySegmentedView(NativeSdkAppKitHost *object, uint32_t statusItemId, const native_sdk_appkit_tray_segment_option_t *options, size_t count) {
|
|
13514
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 38)];
|
|
13515
|
+
NativeSdkTraySegmentedControl *control = [[NativeSdkTraySegmentedControl alloc] initWithFrame:NSMakeRect(14, 5, 292, 28)];
|
|
13516
|
+
control.segmentCount = count;
|
|
13517
|
+
control.segmentStyle = NSSegmentStyleAutomatic;
|
|
13518
|
+
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
|
|
13519
|
+
control.target = object;
|
|
13520
|
+
control.action = @selector(traySegmentChanged:);
|
|
13521
|
+
control.tag = (NSInteger)statusItemId;
|
|
13522
|
+
control.sourceSelectedSegment = -1;
|
|
13523
|
+
control.autoresizingMask = NSViewWidthSizable;
|
|
13524
|
+
for (size_t i = 0; i < count; i++) {
|
|
13525
|
+
[control setLabel:NativeSdkTrayString(options[i].label, options[i].label_len) forSegment:i];
|
|
13526
|
+
[control setEnabled:options[i].enabled != 0 forSegment:i];
|
|
13527
|
+
[control setTag:(NSInteger)options[i].item_id forSegment:i];
|
|
13528
|
+
[control setSelected:options[i].selected != 0 forSegment:i];
|
|
13529
|
+
if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;
|
|
13530
|
+
}
|
|
13531
|
+
[row addSubview:control];
|
|
13532
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13533
|
+
return row;
|
|
13534
|
+
}
|
|
13535
|
+
|
|
13536
|
+
static NSView *NativeSdkTrayMetricView(const native_sdk_appkit_tray_metric_row_t *metric) {
|
|
13537
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
13538
|
+
NSTextField *primary = [NSTextField labelWithString:NativeSdkTrayString(metric->primary_text, metric->primary_text_len)];
|
|
13539
|
+
NSTextField *secondary = [NSTextField labelWithString:NativeSdkTrayString(metric->secondary_text, metric->secondary_text_len)];
|
|
13540
|
+
primary.frame = NSMakeRect(14, 25, 292, 28);
|
|
13541
|
+
secondary.frame = NSMakeRect(14, 6, 292, 16);
|
|
13542
|
+
primary.font = [NSFont fontWithName:@"Geist Mono" size:20] ?: [NSFont monospacedDigitSystemFontOfSize:20 weight:NSFontWeightMedium];
|
|
13543
|
+
secondary.font = [NSFont systemFontOfSize:11];
|
|
13544
|
+
secondary.textColor = NSColor.secondaryLabelColor;
|
|
13545
|
+
primary.autoresizingMask = NSViewWidthSizable;
|
|
13546
|
+
secondary.autoresizingMask = NSViewWidthSizable;
|
|
13547
|
+
primary.accessibilityElement = NO;
|
|
13548
|
+
secondary.accessibilityElement = NO;
|
|
13549
|
+
[row addSubview:primary];
|
|
13550
|
+
[row addSubview:secondary];
|
|
13551
|
+
row.accessibilityLabel = NativeSdkTrayString(metric->accessibility_label, metric->accessibility_label_len);
|
|
13552
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13553
|
+
return row;
|
|
13554
|
+
}
|
|
13555
|
+
|
|
13556
|
+
static NSView *NativeSdkTrayChartView(const native_sdk_appkit_tray_chart_row_t *chart) {
|
|
13557
|
+
NSString *leading = NativeSdkTrayString(chart->leading_caption, chart->leading_caption_len);
|
|
13558
|
+
NSString *trailing = NativeSdkTrayString(chart->trailing_summary, chart->trailing_summary_len);
|
|
13559
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
13560
|
+
NSTextField *leadingField = [NSTextField labelWithString:leading];
|
|
13561
|
+
NSTextField *trailingField = [NSTextField labelWithString:trailing];
|
|
13562
|
+
leadingField.frame = NSMakeRect(14, 3, 142, 15);
|
|
13563
|
+
trailingField.frame = NSMakeRect(164, 3, 142, 15);
|
|
13564
|
+
trailingField.alignment = NSTextAlignmentRight;
|
|
13565
|
+
leadingField.font = [NSFont systemFontOfSize:10];
|
|
13566
|
+
trailingField.font = [NSFont monospacedDigitSystemFontOfSize:10 weight:NSFontWeightRegular];
|
|
13567
|
+
leadingField.textColor = NSColor.secondaryLabelColor;
|
|
13568
|
+
trailingField.textColor = NSColor.secondaryLabelColor;
|
|
13569
|
+
leadingField.autoresizingMask = NSViewWidthSizable;
|
|
13570
|
+
trailingField.autoresizingMask = NSViewMinXMargin;
|
|
13571
|
+
leadingField.accessibilityElement = NO;
|
|
13572
|
+
trailingField.accessibilityElement = NO;
|
|
13573
|
+
NativeSdkTrayBarChartView *bars = [[NativeSdkTrayBarChartView alloc] initWithFrame:NSMakeRect(14, 21, 292, 32)];
|
|
13574
|
+
NSMutableArray<NSNumber *> *values = [NSMutableArray arrayWithCapacity:chart->value_count];
|
|
13575
|
+
for (size_t i = 0; i < chart->value_count; i++) [values addObject:@(chart->values[i])];
|
|
13576
|
+
bars.values = values;
|
|
13577
|
+
bars.minValue = chart->min_value;
|
|
13578
|
+
bars.maxValue = chart->max_value;
|
|
13579
|
+
bars.autoresizingMask = NSViewWidthSizable;
|
|
13580
|
+
bars.accessibilityElement = NO;
|
|
13581
|
+
[row addSubview:leadingField];
|
|
13582
|
+
[row addSubview:trailingField];
|
|
13583
|
+
[row addSubview:bars];
|
|
13584
|
+
row.accessibilityLabel = NativeSdkTrayString(chart->accessibility_label, chart->accessibility_label_len);
|
|
13585
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
13586
|
+
return row;
|
|
13587
|
+
}
|
|
13588
|
+
|
|
13443
13589
|
static NSView *NativeSdkTrayHeroView(NSString *headline, NSString *quota) {
|
|
13444
13590
|
NSArray<NSString *> *parts = [headline componentsSeparatedByString:@"\n"];
|
|
13445
13591
|
NSString *value = parts.count > 0 ? parts[0] : @"";
|
|
@@ -13667,6 +13813,7 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
13667
13813
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:label ?: @""
|
|
13668
13814
|
action:@selector(trayMenuItemClicked:)
|
|
13669
13815
|
keyEquivalent:@""];
|
|
13816
|
+
item.representedObject = @(i);
|
|
13670
13817
|
item.tag = (NSInteger)(((uint64_t)status_item_id << 32) | item_ids[i]);
|
|
13671
13818
|
item.target = object;
|
|
13672
13819
|
item.enabled = enabled_flags[i] != 0;
|
|
@@ -13740,6 +13887,46 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
13740
13887
|
}
|
|
13741
13888
|
}
|
|
13742
13889
|
|
|
13890
|
+
void native_sdk_appkit_update_tray_rich_rows(native_sdk_appkit_host_t *host, uint32_t status_item_id, const native_sdk_appkit_tray_segmented_row_t *segmented_rows, size_t segmented_count, const native_sdk_appkit_tray_metric_row_t *metric_rows, size_t metric_count, const native_sdk_appkit_tray_chart_row_t *chart_rows, size_t chart_count) {
|
|
13891
|
+
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13892
|
+
@autoreleasepool {
|
|
13893
|
+
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13894
|
+
if (!entry || !entry.menu) return;
|
|
13895
|
+
for (size_t i = 0; i < segmented_count; i++) {
|
|
13896
|
+
const native_sdk_appkit_tray_segmented_row_t *row = &segmented_rows[i];
|
|
13897
|
+
NSMenuItem *item = nil;
|
|
13898
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13899
|
+
if ([candidate.representedObject isEqual:@(row->row_index)]) { item = candidate; break; }
|
|
13900
|
+
}
|
|
13901
|
+
if (!item) continue;
|
|
13902
|
+
item.action = NULL;
|
|
13903
|
+
item.target = nil;
|
|
13904
|
+
item.view = NativeSdkTraySegmentedView(object, status_item_id, row->options, row->option_count);
|
|
13905
|
+
}
|
|
13906
|
+
for (size_t i = 0; i < metric_count; i++) {
|
|
13907
|
+
NSMenuItem *item = nil;
|
|
13908
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13909
|
+
if ([candidate.representedObject isEqual:@(metric_rows[i].row_index)]) { item = candidate; break; }
|
|
13910
|
+
}
|
|
13911
|
+
if (!item) continue;
|
|
13912
|
+
item.action = NULL;
|
|
13913
|
+
item.target = nil;
|
|
13914
|
+
item.view = NativeSdkTrayMetricView(&metric_rows[i]);
|
|
13915
|
+
}
|
|
13916
|
+
for (size_t i = 0; i < chart_count; i++) {
|
|
13917
|
+
const native_sdk_appkit_tray_chart_row_t *row = &chart_rows[i];
|
|
13918
|
+
NSMenuItem *item = nil;
|
|
13919
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
13920
|
+
if ([candidate.representedObject isEqual:@(row->row_index)]) { item = candidate; break; }
|
|
13921
|
+
}
|
|
13922
|
+
if (!item) continue;
|
|
13923
|
+
item.action = NULL;
|
|
13924
|
+
item.target = nil;
|
|
13925
|
+
item.view = NativeSdkTrayChartView(row);
|
|
13926
|
+
}
|
|
13927
|
+
}
|
|
13928
|
+
}
|
|
13929
|
+
|
|
13743
13930
|
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len) {
|
|
13744
13931
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13745
13932
|
@autoreleasepool {
|
|
@@ -13753,18 +13940,20 @@ void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_
|
|
|
13753
13940
|
entry.presentationWidth,
|
|
13754
13941
|
entry.presentationTone,
|
|
13755
13942
|
entry.presentationIconOpacity,
|
|
13756
|
-
entry.presentationMonospaced
|
|
13943
|
+
entry.presentationMonospaced,
|
|
13944
|
+
entry.presentationFontSize,
|
|
13945
|
+
entry.presentationFontWeight
|
|
13757
13946
|
);
|
|
13758
13947
|
}
|
|
13759
13948
|
}
|
|
13760
13949
|
|
|
13761
|
-
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced) {
|
|
13950
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced, double font_size, int font_weight) {
|
|
13762
13951
|
NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
|
|
13763
13952
|
@autoreleasepool {
|
|
13764
13953
|
NativeSdkStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
13765
13954
|
if (!entry) return;
|
|
13766
13955
|
NSString *value = title ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
13767
|
-
NativeSdkApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0);
|
|
13956
|
+
NativeSdkApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
13768
13957
|
}
|
|
13769
13958
|
}
|
|
13770
13959
|
|