@native-sdk/cli 0.9.4 → 0.10.0
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 +75 -57
- package/build/ts_run.mjs +1 -1
- package/build.zig +20 -2
- package/package.json +11 -10
- package/packages/core/package-lock.json +12 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_command.mjs +1 -1
- package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
- package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
- package/packages/core/scripts/vendor_service_packages.mjs +121 -8
- package/packages/core/sdk/events.d.ts +33 -4
- package/packages/core/sdk/events.ts +45 -6
- package/packages/core/src/checker.ts +103 -8
- 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 +446 -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 +26 -5
- package/skill-data/ts-core/SKILL.md +6 -6
- package/skill-data/ts-services/references/service-surface.md +1 -1
- package/skills/native-sdk/SKILL.md +2 -2
- package/src/app_runner/root.zig +25 -0
- package/src/automation/snapshot.zig +91 -3
- package/src/platform/macos/appkit_host.h +66 -2
- package/src/platform/macos/appkit_host.m +735 -24
- package/src/platform/macos/cef_host.mm +208 -9
- package/src/platform/macos/root.zig +205 -3
- package/src/platform/null_platform.zig +50 -1
- package/src/platform/null_platform_tests.zig +53 -0
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +73 -0
- package/src/platform/windows/root.zig +88 -15
- package/src/primitives/app_manifest/tests.zig +19 -0
- package/src/primitives/app_manifest/validation.zig +14 -2
- package/src/primitives/canvas/font_ttf.zig +24 -0
- package/src/primitives/canvas/gpu.zig +5 -0
- package/src/primitives/canvas/reference.zig +41 -16
- package/src/primitives/canvas/reference_tests.zig +63 -0
- package/src/primitives/canvas/render_tests.zig +1 -1
- package/src/primitives/canvas/root.zig +1 -0
- package/src/primitives/canvas/serialization.zig +1 -0
- package/src/primitives/canvas/test_support.zig +1 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_layout.zig +84 -15
- package/src/primitives/canvas/text_layout_hash.zig +3 -1
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_metrics.zig +28 -1
- package/src/primitives/canvas/text_tests.zig +61 -6
- 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 +13 -2
- package/src/primitives/canvas/widget_render_controls.zig +1 -0
- package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
- package/src/root.zig +6 -0
- package/src/runtime/automation_snapshot.zig +3 -0
- package/src/runtime/canvas_fonts.zig +87 -0
- package/src/runtime/core.zig +1 -0
- package/src/runtime/flow.zig +8 -1
- package/src/runtime/native_command_event_tests.zig +58 -0
- package/src/runtime/state.zig +14 -0
- package/src/runtime/system_services.zig +62 -0
- package/src/runtime/ts_ui_app.zig +161 -33
- package/src/runtime/ui_app.zig +33 -1
- package/src/runtime/ui_app_tests.zig +63 -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 +199 -35
- package/src/tooling/package.zig +33 -0
- package/src/tooling/raw_manifest.zig +11 -0
- package/src/tooling/root.zig +2 -0
- package/src/tooling/templates.zig +210 -116
- package/src/tooling/ts_core.zig +11 -7
- package/src/tooling/update.zig +576 -0
- package/src/tooling/verbs.zig +7 -6
- package/src/tooling/web_engine.zig +17 -1
- package/src/updater/c_api.zig +123 -0
- package/src/updater/feed.zig +215 -0
- package/src/updater/root.zig +10 -0
|
@@ -607,6 +607,10 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
607
607
|
@property(nonatomic, assign) uint32_t modifiers;
|
|
608
608
|
@end
|
|
609
609
|
|
|
610
|
+
@interface NativeSdkCefTraySegmentedControl : NSSegmentedControl
|
|
611
|
+
@property(nonatomic, assign) NSInteger sourceSelectedSegment;
|
|
612
|
+
@end
|
|
613
|
+
|
|
610
614
|
@interface NativeSdkChromiumStatusItemEntry : NSObject
|
|
611
615
|
@property(nonatomic, assign) uint32_t identifier;
|
|
612
616
|
@property(nonatomic, strong) NSStatusItem *item;
|
|
@@ -617,6 +621,8 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
617
621
|
@property(nonatomic, assign) int presentationTone;
|
|
618
622
|
@property(nonatomic, assign) double presentationIconOpacity;
|
|
619
623
|
@property(nonatomic, assign) BOOL presentationMonospaced;
|
|
624
|
+
@property(nonatomic, assign) double presentationFontSize;
|
|
625
|
+
@property(nonatomic, assign) int presentationFontWeight;
|
|
620
626
|
@property(nonatomic, strong) NSString *activationCommand;
|
|
621
627
|
@property(nonatomic, strong) NSString *alternateActivationCommand;
|
|
622
628
|
@property(nonatomic, strong) NSString *openCommand;
|
|
@@ -769,6 +775,7 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
769
775
|
- (BOOL)handleShortcutEvent:(NSEvent *)event;
|
|
770
776
|
- (void)emitShortcutWithId:(NSString *)identifier key:(NSString *)key modifiers:(uint32_t)modifiers event:(NSEvent *)event;
|
|
771
777
|
- (void)trayMenuItemClicked:(NSMenuItem *)menuItem;
|
|
778
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control;
|
|
772
779
|
- (void)menuWillOpen:(NSMenu *)menu;
|
|
773
780
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForId:(uint32_t)identifier;
|
|
774
781
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForMenu:(NSMenu *)menu;
|
|
@@ -779,6 +786,9 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
779
786
|
@implementation NativeSdkChromiumShortcut
|
|
780
787
|
@end
|
|
781
788
|
|
|
789
|
+
@implementation NativeSdkCefTraySegmentedControl
|
|
790
|
+
@end
|
|
791
|
+
|
|
782
792
|
@implementation NativeSdkChromiumStatusItemEntry
|
|
783
793
|
@end
|
|
784
794
|
|
|
@@ -2132,6 +2142,20 @@ static const char *NativeSdkCefBridgeScript() {
|
|
|
2132
2142
|
}
|
|
2133
2143
|
}
|
|
2134
2144
|
|
|
2145
|
+
- (void)traySegmentChanged:(NSSegmentedControl *)control {
|
|
2146
|
+
NSInteger selected = control.selectedSegment;
|
|
2147
|
+
if (selected < 0 || !self.trayCallback) return;
|
|
2148
|
+
NSInteger itemId = [control tagForSegment:selected];
|
|
2149
|
+
if (itemId <= 0) return;
|
|
2150
|
+
// Keep the native control on the model-declared selection until the
|
|
2151
|
+
// dispatched command commits a new model and rebuilds this menu row.
|
|
2152
|
+
NSInteger sourceSelected = [(NativeSdkCefTraySegmentedControl *)control sourceSelectedSegment];
|
|
2153
|
+
for (NSInteger index = 0; index < control.segmentCount; index++) {
|
|
2154
|
+
[control setSelected:index == sourceSelected forSegment:index];
|
|
2155
|
+
}
|
|
2156
|
+
self.trayCallback(self.trayContext, (uint32_t)control.tag, (uint32_t)itemId);
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2135
2159
|
- (NativeSdkChromiumStatusItemEntry *)statusEntryForId:(uint32_t)identifier {
|
|
2136
2160
|
return self.statusItems[@(identifier)];
|
|
2137
2161
|
}
|
|
@@ -2453,6 +2477,23 @@ void native_sdk_appkit_destroy(native_sdk_appkit_host_t *host) {
|
|
|
2453
2477
|
CFBridgingRelease(host);
|
|
2454
2478
|
}
|
|
2455
2479
|
|
|
2480
|
+
void native_sdk_appkit_configure_updates(native_sdk_appkit_host_t *host, const char *feed_url, size_t feed_url_len, const char *public_key, size_t public_key_len, int check_on_start, const char *target, size_t target_len) {
|
|
2481
|
+
(void)host;
|
|
2482
|
+
(void)feed_url;
|
|
2483
|
+
(void)feed_url_len;
|
|
2484
|
+
(void)public_key;
|
|
2485
|
+
(void)public_key_len;
|
|
2486
|
+
(void)check_on_start;
|
|
2487
|
+
(void)target;
|
|
2488
|
+
(void)target_len;
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
int native_sdk_appkit_check_for_updates(native_sdk_appkit_host_t *host, int user_initiated) {
|
|
2492
|
+
(void)host;
|
|
2493
|
+
(void)user_initiated;
|
|
2494
|
+
return 0;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2456
2497
|
void native_sdk_appkit_run(native_sdk_appkit_host_t *host, native_sdk_appkit_event_callback_t callback, void *context) {
|
|
2457
2498
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
2458
2499
|
[object runWithCallback:callback context:context];
|
|
@@ -3604,16 +3645,29 @@ static NSImage *NativeSdkCefTrayImageWithOpacity(NSImage *source, double opacity
|
|
|
3604
3645
|
return image;
|
|
3605
3646
|
}
|
|
3606
3647
|
|
|
3607
|
-
static
|
|
3648
|
+
static NSFontWeight NativeSdkCefTrayFontWeight(int weight) {
|
|
3649
|
+
switch (weight) {
|
|
3650
|
+
case 1: return NSFontWeightMedium;
|
|
3651
|
+
case 2: return NSFontWeightSemibold;
|
|
3652
|
+
case 3: return NSFontWeightBold;
|
|
3653
|
+
default: return NSFontWeightRegular;
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
|
|
3657
|
+
static void NativeSdkCefApplyTrayPresentation(NativeSdkChromiumHost *object, NativeSdkChromiumStatusItemEntry *entry, NSString *requestedTitle, double width, int tone, double iconOpacity, BOOL monospaced, double fontSize, int fontWeight) {
|
|
3608
3658
|
if (!entry.item) return;
|
|
3609
3659
|
entry.presentationTitle = requestedTitle ?: @"";
|
|
3610
3660
|
entry.presentationWidth = width;
|
|
3611
3661
|
entry.presentationTone = tone;
|
|
3612
3662
|
entry.presentationIconOpacity = iconOpacity;
|
|
3613
3663
|
entry.presentationMonospaced = monospaced;
|
|
3664
|
+
entry.presentationFontSize = fontSize;
|
|
3665
|
+
entry.presentationFontWeight = fontWeight;
|
|
3614
3666
|
NSString *title = requestedTitle ?: @"";
|
|
3615
3667
|
if (!entry.baseImage && title.length == 0) title = object.appName.length > 0 ? [object.appName substringToIndex:MIN(1, object.appName.length)] : @"Z";
|
|
3616
|
-
|
|
3668
|
+
CGFloat resolvedSize = fontSize > 0 ? fontSize : 11;
|
|
3669
|
+
NSFontWeight resolvedWeight = NativeSdkCefTrayFontWeight(fontWeight);
|
|
3670
|
+
NSFont *font = monospaced ? [NSFont monospacedSystemFontOfSize:resolvedSize weight:resolvedWeight] : [NSFont systemFontOfSize:resolvedSize weight:resolvedWeight];
|
|
3617
3671
|
if (tone == 0) {
|
|
3618
3672
|
entry.item.button.title = title;
|
|
3619
3673
|
entry.item.button.font = font;
|
|
@@ -3650,7 +3704,7 @@ static void NativeSdkCefApplyTrayShell(NativeSdkChromiumHost *object, NativeSdkC
|
|
|
3650
3704
|
entry.item.visible = visible != 0;
|
|
3651
3705
|
}
|
|
3652
3706
|
|
|
3653
|
-
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) {
|
|
3707
|
+
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) {
|
|
3654
3708
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3655
3709
|
@autoreleasepool {
|
|
3656
3710
|
NSNumber *key = @(status_item_id);
|
|
@@ -3669,7 +3723,7 @@ void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t stat
|
|
|
3669
3723
|
entry.item = [[NSStatusBar systemStatusBar] statusItemWithLength:hasTitle ? NSVariableStatusItemLength : NSSquareStatusItemLength];
|
|
3670
3724
|
NSString *titleString = hasTitle ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3671
3725
|
NativeSdkCefApplyTrayShell(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);
|
|
3672
|
-
NativeSdkCefApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0);
|
|
3726
|
+
NativeSdkCefApplyTrayPresentation(object, entry, titleString, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
3673
3727
|
}
|
|
3674
3728
|
}
|
|
3675
3729
|
|
|
@@ -3679,7 +3733,7 @@ void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_
|
|
|
3679
3733
|
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3680
3734
|
if (!entry) return;
|
|
3681
3735
|
NativeSdkCefApplyTrayShell(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);
|
|
3682
|
-
NativeSdkCefApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced);
|
|
3736
|
+
NativeSdkCefApplyTrayPresentation(object, entry, entry.presentationTitle, entry.presentationWidth, entry.presentationTone, entry.presentationIconOpacity, entry.presentationMonospaced, entry.presentationFontSize, entry.presentationFontWeight);
|
|
3683
3737
|
if (entry.activationCommand.length == 0 && entry.alternateActivationCommand.length == 0) entry.item.menu = entry.menu;
|
|
3684
3738
|
else entry.item.menu = nil;
|
|
3685
3739
|
}
|
|
@@ -3694,6 +3748,107 @@ static NSEventModifierFlags NativeSdkCefTrayModifiers(uint32_t modifiers) {
|
|
|
3694
3748
|
return flags;
|
|
3695
3749
|
}
|
|
3696
3750
|
|
|
3751
|
+
@interface NativeSdkCefTrayBarChartView : NSView
|
|
3752
|
+
@property(nonatomic, copy) NSArray<NSNumber *> *values;
|
|
3753
|
+
@property(nonatomic, assign) double minValue;
|
|
3754
|
+
@property(nonatomic, assign) double maxValue;
|
|
3755
|
+
@end
|
|
3756
|
+
|
|
3757
|
+
@implementation NativeSdkCefTrayBarChartView
|
|
3758
|
+
- (BOOL)isFlipped { return YES; }
|
|
3759
|
+
- (void)drawRect:(NSRect)dirtyRect {
|
|
3760
|
+
[super drawRect:dirtyRect];
|
|
3761
|
+
if (self.values.count == 0 || !(self.maxValue > self.minValue)) return;
|
|
3762
|
+
CGFloat gap = 2;
|
|
3763
|
+
CGFloat barWidth = MAX(1, (NSWidth(self.bounds) - gap * (self.values.count - 1)) / self.values.count);
|
|
3764
|
+
CGFloat x = 0;
|
|
3765
|
+
[NSColor.controlAccentColor setFill];
|
|
3766
|
+
for (NSNumber *number in self.values) {
|
|
3767
|
+
double fraction = (number.doubleValue - self.minValue) / (self.maxValue - self.minValue);
|
|
3768
|
+
fraction = MIN(MAX(fraction, 0), 1);
|
|
3769
|
+
CGFloat height = MAX(fraction > 0 ? 1 : 0, floor(fraction * NSHeight(self.bounds)));
|
|
3770
|
+
NSRectFill(NSMakeRect(x, NSHeight(self.bounds) - height, barWidth, height));
|
|
3771
|
+
x += barWidth + gap;
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
@end
|
|
3775
|
+
|
|
3776
|
+
static NSString *NativeSdkCefTrayString(const char *bytes, size_t len) {
|
|
3777
|
+
return bytes && len > 0 ? ([[NSString alloc] initWithBytes:bytes length:len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3778
|
+
}
|
|
3779
|
+
|
|
3780
|
+
static NSView *NativeSdkCefTraySegmentedView(NativeSdkChromiumHost *object, uint32_t statusItemId, const native_sdk_appkit_tray_segment_option_t *options, size_t count) {
|
|
3781
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 38)];
|
|
3782
|
+
NativeSdkCefTraySegmentedControl *control = [[NativeSdkCefTraySegmentedControl alloc] initWithFrame:NSMakeRect(14, 5, 292, 28)];
|
|
3783
|
+
control.segmentCount = count;
|
|
3784
|
+
control.trackingMode = NSSegmentSwitchTrackingSelectOne;
|
|
3785
|
+
control.target = object;
|
|
3786
|
+
control.action = @selector(traySegmentChanged:);
|
|
3787
|
+
control.tag = (NSInteger)statusItemId;
|
|
3788
|
+
control.sourceSelectedSegment = -1;
|
|
3789
|
+
control.autoresizingMask = NSViewWidthSizable;
|
|
3790
|
+
for (size_t i = 0; i < count; i++) {
|
|
3791
|
+
[control setLabel:NativeSdkCefTrayString(options[i].label, options[i].label_len) forSegment:i];
|
|
3792
|
+
[control setEnabled:options[i].enabled != 0 forSegment:i];
|
|
3793
|
+
[control setTag:(NSInteger)options[i].item_id forSegment:i];
|
|
3794
|
+
[control setSelected:options[i].selected != 0 forSegment:i];
|
|
3795
|
+
if (options[i].selected != 0) control.sourceSelectedSegment = (NSInteger)i;
|
|
3796
|
+
}
|
|
3797
|
+
[row addSubview:control];
|
|
3798
|
+
return row;
|
|
3799
|
+
}
|
|
3800
|
+
|
|
3801
|
+
static NSView *NativeSdkCefTrayMetricView(const native_sdk_appkit_tray_metric_row_t *metric) {
|
|
3802
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
3803
|
+
NSTextField *primary = [NSTextField labelWithString:NativeSdkCefTrayString(metric->primary_text, metric->primary_text_len)];
|
|
3804
|
+
NSTextField *secondary = [NSTextField labelWithString:NativeSdkCefTrayString(metric->secondary_text, metric->secondary_text_len)];
|
|
3805
|
+
primary.frame = NSMakeRect(14, 25, 292, 28);
|
|
3806
|
+
secondary.frame = NSMakeRect(14, 6, 292, 16);
|
|
3807
|
+
primary.font = [NSFont fontWithName:@"Geist Mono" size:20] ?: [NSFont monospacedDigitSystemFontOfSize:20 weight:NSFontWeightMedium];
|
|
3808
|
+
secondary.font = [NSFont systemFontOfSize:11];
|
|
3809
|
+
secondary.textColor = NSColor.secondaryLabelColor;
|
|
3810
|
+
primary.autoresizingMask = NSViewWidthSizable;
|
|
3811
|
+
secondary.autoresizingMask = NSViewWidthSizable;
|
|
3812
|
+
primary.accessibilityElement = NO;
|
|
3813
|
+
secondary.accessibilityElement = NO;
|
|
3814
|
+
[row addSubview:primary];
|
|
3815
|
+
[row addSubview:secondary];
|
|
3816
|
+
row.accessibilityLabel = NativeSdkCefTrayString(metric->accessibility_label, metric->accessibility_label_len);
|
|
3817
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
3818
|
+
return row;
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
static NSView *NativeSdkCefTrayChartView(const native_sdk_appkit_tray_chart_row_t *chart) {
|
|
3822
|
+
NSView *row = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 320, 58)];
|
|
3823
|
+
NSTextField *leading = [NSTextField labelWithString:NativeSdkCefTrayString(chart->leading_caption, chart->leading_caption_len)];
|
|
3824
|
+
NSTextField *trailing = [NSTextField labelWithString:NativeSdkCefTrayString(chart->trailing_summary, chart->trailing_summary_len)];
|
|
3825
|
+
leading.frame = NSMakeRect(14, 3, 142, 15);
|
|
3826
|
+
trailing.frame = NSMakeRect(164, 3, 142, 15);
|
|
3827
|
+
trailing.alignment = NSTextAlignmentRight;
|
|
3828
|
+
leading.font = [NSFont systemFontOfSize:10];
|
|
3829
|
+
trailing.font = [NSFont monospacedDigitSystemFontOfSize:10 weight:NSFontWeightRegular];
|
|
3830
|
+
leading.textColor = NSColor.secondaryLabelColor;
|
|
3831
|
+
trailing.textColor = NSColor.secondaryLabelColor;
|
|
3832
|
+
leading.autoresizingMask = NSViewWidthSizable;
|
|
3833
|
+
trailing.autoresizingMask = NSViewMinXMargin;
|
|
3834
|
+
leading.accessibilityElement = NO;
|
|
3835
|
+
trailing.accessibilityElement = NO;
|
|
3836
|
+
NativeSdkCefTrayBarChartView *bars = [[NativeSdkCefTrayBarChartView alloc] initWithFrame:NSMakeRect(14, 21, 292, 32)];
|
|
3837
|
+
NSMutableArray<NSNumber *> *values = [NSMutableArray arrayWithCapacity:chart->value_count];
|
|
3838
|
+
for (size_t i = 0; i < chart->value_count; i++) [values addObject:@(chart->values[i])];
|
|
3839
|
+
bars.values = values;
|
|
3840
|
+
bars.minValue = chart->min_value;
|
|
3841
|
+
bars.maxValue = chart->max_value;
|
|
3842
|
+
bars.autoresizingMask = NSViewWidthSizable;
|
|
3843
|
+
bars.accessibilityElement = NO;
|
|
3844
|
+
[row addSubview:leading];
|
|
3845
|
+
[row addSubview:trailing];
|
|
3846
|
+
[row addSubview:bars];
|
|
3847
|
+
row.accessibilityLabel = NativeSdkCefTrayString(chart->accessibility_label, chart->accessibility_label_len);
|
|
3848
|
+
row.accessibilityRole = NSAccessibilityGroupRole;
|
|
3849
|
+
return row;
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3697
3852
|
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) {
|
|
3698
3853
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3699
3854
|
@autoreleasepool {
|
|
@@ -3716,9 +3871,10 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
3716
3871
|
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:label ?: @""
|
|
3717
3872
|
action:@selector(trayMenuItemClicked:)
|
|
3718
3873
|
keyEquivalent:@""];
|
|
3874
|
+
item.representedObject = @(i);
|
|
3719
3875
|
item.tag = (NSInteger)(((uint64_t)status_item_id << 32) | item_ids[i]);
|
|
3720
3876
|
item.target = object;
|
|
3721
|
-
item.enabled = enabled_flags[i] != 0 && (roles[i] == 0 || roles[i] == 4);
|
|
3877
|
+
item.enabled = enabled_flags[i] != 0 && (roles[i] == 0 || roles[i] == 4 || roles[i] == 6);
|
|
3722
3878
|
if (details[i] && detail_lens[i] > 0) {
|
|
3723
3879
|
NSString *detail = [[NSString alloc] initWithBytes:details[i] length:detail_lens[i] encoding:NSUTF8StringEncoding] ?: @"";
|
|
3724
3880
|
if (detail.length > 0 && roles[i] != 0) item.title = [NSString stringWithFormat:@"%@ — %@", label ?: @"", detail];
|
|
@@ -3735,6 +3891,47 @@ void native_sdk_appkit_update_tray_menu(native_sdk_appkit_host_t *host, uint32_t
|
|
|
3735
3891
|
}
|
|
3736
3892
|
}
|
|
3737
3893
|
|
|
3894
|
+
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) {
|
|
3895
|
+
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3896
|
+
@autoreleasepool {
|
|
3897
|
+
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3898
|
+
if (!entry || !entry.menu) return;
|
|
3899
|
+
for (size_t i = 0; i < segmented_count; i++) {
|
|
3900
|
+
NSMenuItem *item = nil;
|
|
3901
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3902
|
+
if ([candidate.representedObject isEqual:@(segmented_rows[i].row_index)]) { item = candidate; break; }
|
|
3903
|
+
}
|
|
3904
|
+
if (item) {
|
|
3905
|
+
item.action = NULL;
|
|
3906
|
+
item.target = nil;
|
|
3907
|
+
item.view = NativeSdkCefTraySegmentedView(object, status_item_id, segmented_rows[i].options, segmented_rows[i].option_count);
|
|
3908
|
+
}
|
|
3909
|
+
}
|
|
3910
|
+
for (size_t i = 0; i < metric_count; i++) {
|
|
3911
|
+
NSMenuItem *item = nil;
|
|
3912
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3913
|
+
if ([candidate.representedObject isEqual:@(metric_rows[i].row_index)]) { item = candidate; break; }
|
|
3914
|
+
}
|
|
3915
|
+
if (item) {
|
|
3916
|
+
item.action = NULL;
|
|
3917
|
+
item.target = nil;
|
|
3918
|
+
item.view = NativeSdkCefTrayMetricView(&metric_rows[i]);
|
|
3919
|
+
}
|
|
3920
|
+
}
|
|
3921
|
+
for (size_t i = 0; i < chart_count; i++) {
|
|
3922
|
+
NSMenuItem *item = nil;
|
|
3923
|
+
for (NSMenuItem *candidate in entry.menu.itemArray) {
|
|
3924
|
+
if ([candidate.representedObject isEqual:@(chart_rows[i].row_index)]) { item = candidate; break; }
|
|
3925
|
+
}
|
|
3926
|
+
if (item) {
|
|
3927
|
+
item.action = NULL;
|
|
3928
|
+
item.target = nil;
|
|
3929
|
+
item.view = NativeSdkCefTrayChartView(&chart_rows[i]);
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3738
3935
|
int native_sdk_appkit_set_window_content_min_size(native_sdk_appkit_host_t *host, uint64_t window_id, double min_width, double min_height) {
|
|
3739
3936
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3740
3937
|
NSWindow *window = object.windows[@(window_id)];
|
|
@@ -3761,18 +3958,20 @@ void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_
|
|
|
3761
3958
|
entry.presentationWidth,
|
|
3762
3959
|
entry.presentationTone,
|
|
3763
3960
|
entry.presentationIconOpacity,
|
|
3764
|
-
entry.presentationMonospaced
|
|
3961
|
+
entry.presentationMonospaced,
|
|
3962
|
+
entry.presentationFontSize,
|
|
3963
|
+
entry.presentationFontWeight
|
|
3765
3964
|
);
|
|
3766
3965
|
}
|
|
3767
3966
|
}
|
|
3768
3967
|
|
|
3769
|
-
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) {
|
|
3968
|
+
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) {
|
|
3770
3969
|
NativeSdkChromiumHost *object = (__bridge NativeSdkChromiumHost *)host;
|
|
3771
3970
|
@autoreleasepool {
|
|
3772
3971
|
NativeSdkChromiumStatusItemEntry *entry = [object statusEntryForId:status_item_id];
|
|
3773
3972
|
if (!entry) return;
|
|
3774
3973
|
NSString *value = title ? ([[NSString alloc] initWithBytes:title length:title_len encoding:NSUTF8StringEncoding] ?: @"") : @"";
|
|
3775
|
-
NativeSdkCefApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0);
|
|
3974
|
+
NativeSdkCefApplyTrayPresentation(object, entry, value, width, tone, icon_opacity, monospaced != 0, font_size, font_weight);
|
|
3776
3975
|
}
|
|
3777
3976
|
}
|
|
3778
3977
|
|
|
@@ -8,6 +8,12 @@ const canvas = @import("canvas");
|
|
|
8
8
|
// The packaging pipeline's one-image icon machinery: dev runs borrow its
|
|
9
9
|
// macOS mask/inset render so the Dock tile matches `native package`.
|
|
10
10
|
const app_icon = canvas.app_icon;
|
|
11
|
+
const updater_c_api = @import("../../updater/c_api.zig");
|
|
12
|
+
|
|
13
|
+
comptime {
|
|
14
|
+
_ = updater_c_api.native_sdk_update_verify_feed;
|
|
15
|
+
_ = updater_c_api.native_sdk_update_verify_archive;
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
pub const Error = error{
|
|
13
19
|
CallbackFailed,
|
|
@@ -174,6 +180,8 @@ extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, d
|
|
|
174
180
|
extern fn native_sdk_appkit_destroy(host: *AppKitHost) void;
|
|
175
181
|
extern fn native_sdk_appkit_set_dock_icon_rgba(host: *AppKitHost, pixels: [*]const u8, width: usize, height: usize) void;
|
|
176
182
|
extern fn native_sdk_appkit_set_dock_icon_file(host: *AppKitHost, path: [*]const u8, path_len: usize) void;
|
|
183
|
+
extern fn native_sdk_appkit_configure_updates(host: *AppKitHost, feed_url: [*]const u8, feed_url_len: usize, public_key: [*]const u8, public_key_len: usize, check_on_start: c_int, target: [*]const u8, target_len: usize) void;
|
|
184
|
+
extern fn native_sdk_appkit_check_for_updates(host: *AppKitHost, user_initiated: c_int) c_int;
|
|
177
185
|
extern fn native_sdk_appkit_run(host: *AppKitHost, callback: AppKitCallback, context: ?*anyopaque) void;
|
|
178
186
|
extern fn native_sdk_appkit_stop(host: *AppKitHost) void;
|
|
179
187
|
extern fn native_sdk_appkit_request_stop(host: *AppKitHost) void;
|
|
@@ -252,6 +260,7 @@ extern fn native_sdk_appkit_close_webview(host: *AppKitHost, window_id: u64, lab
|
|
|
252
260
|
extern fn native_sdk_appkit_clipboard_read(host: *AppKitHost, buffer: [*]u8, buffer_len: usize) usize;
|
|
253
261
|
extern fn native_sdk_appkit_measure_text(font_id: u64, size: f64, text: [*]const u8, text_len: usize) f64;
|
|
254
262
|
extern fn native_sdk_appkit_measure_text_advances(font_id: u64, size: f64, text: [*]const u8, text_len: usize, advances: [*]f32) c_int;
|
|
263
|
+
extern fn native_sdk_appkit_measure_text_ink(font_id: u64, size: f64, text: [*]const u8, text_len: usize, min_x: *f64, max_x: *f64, min_y: *f64, max_y: *f64) c_int;
|
|
255
264
|
extern fn native_sdk_appkit_register_font(font_id: u64, bytes: [*]const u8, bytes_len: usize, out_token: *u64) c_int;
|
|
256
265
|
extern fn native_sdk_appkit_unregister_font(font_id: u64, token: u64) c_int;
|
|
257
266
|
extern fn native_sdk_appkit_register_bundled_fonts() void;
|
|
@@ -414,15 +423,50 @@ const widget_action_drop_files: u32 = 1 << 9;
|
|
|
414
423
|
const widget_action_dismiss: u32 = 1 << 10;
|
|
415
424
|
|
|
416
425
|
const AppKitTrayCallback = *const fn (context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void;
|
|
426
|
+
const AppKitTraySegmentOption = extern struct {
|
|
427
|
+
item_id: u32,
|
|
428
|
+
label: [*]const u8,
|
|
429
|
+
label_len: usize,
|
|
430
|
+
selected: c_int,
|
|
431
|
+
enabled: c_int,
|
|
432
|
+
};
|
|
433
|
+
const AppKitTraySegmentedRow = extern struct {
|
|
434
|
+
row_index: usize,
|
|
435
|
+
options: [*]const AppKitTraySegmentOption,
|
|
436
|
+
option_count: usize,
|
|
437
|
+
};
|
|
438
|
+
const AppKitTrayMetricRow = extern struct {
|
|
439
|
+
row_index: usize,
|
|
440
|
+
primary_text: [*]const u8,
|
|
441
|
+
primary_text_len: usize,
|
|
442
|
+
secondary_text: [*]const u8,
|
|
443
|
+
secondary_text_len: usize,
|
|
444
|
+
accessibility_label: [*]const u8,
|
|
445
|
+
accessibility_label_len: usize,
|
|
446
|
+
};
|
|
447
|
+
const AppKitTrayChartRow = extern struct {
|
|
448
|
+
row_index: usize,
|
|
449
|
+
values: [*]const f32,
|
|
450
|
+
value_count: usize,
|
|
451
|
+
min_value: f64,
|
|
452
|
+
max_value: f64,
|
|
453
|
+
leading_caption: [*]const u8,
|
|
454
|
+
leading_caption_len: usize,
|
|
455
|
+
trailing_summary: [*]const u8,
|
|
456
|
+
trailing_summary_len: usize,
|
|
457
|
+
accessibility_label: [*]const u8,
|
|
458
|
+
accessibility_label_len: usize,
|
|
459
|
+
};
|
|
417
460
|
|
|
418
461
|
extern fn native_sdk_appkit_show_open_dialog(host: *AppKitHost, opts: *const AppKitOpenDialogOpts, buffer: [*]u8, buffer_len: usize) AppKitOpenDialogResult;
|
|
419
462
|
extern fn native_sdk_appkit_show_save_dialog(host: *AppKitHost, opts: *const AppKitSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
420
463
|
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;
|
|
464
|
+
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
465
|
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
466
|
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;
|
|
467
|
+
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
468
|
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;
|
|
469
|
+
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
470
|
extern fn native_sdk_appkit_remove_tray(host: *AppKitHost, status_item_id: u32) void;
|
|
427
471
|
extern fn native_sdk_appkit_set_tray_callback(host: *AppKitHost, callback: AppKitTrayCallback, context: ?*anyopaque) void;
|
|
428
472
|
|
|
@@ -641,6 +685,12 @@ pub const MacPlatform = struct {
|
|
|
641
685
|
const dock_icon = planDockIcon(app_info.icon_path);
|
|
642
686
|
const icon_path = if (dock_icon == .host_file) app_info.icon_path else "";
|
|
643
687
|
const host = native_sdk_appkit_create(app_info.app_name.ptr, app_info.app_name.len, display_name.ptr, display_name.len, app_info.version.ptr, app_info.version.len, app_info.description.ptr, app_info.description.len, if (app_info.has_web_content) 1 else 0, if (app_info.dock_visible) 1 else 0, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, icon_path.ptr, icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, initialPlacementInt(window_options.initial_placement), restorePolicyInt(window_options.restore_policy), if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
688
|
+
const update_target = comptime switch (builtin.cpu.arch) {
|
|
689
|
+
.aarch64 => "macos-aarch64",
|
|
690
|
+
.x86_64 => "macos-x86_64",
|
|
691
|
+
else => "macos-unsupported",
|
|
692
|
+
};
|
|
693
|
+
native_sdk_appkit_configure_updates(host, app_info.update_feed_url.ptr, app_info.update_feed_url.len, app_info.update_public_key.ptr, app_info.update_public_key.len, if (app_info.update_check_on_start) 1 else 0, update_target.ptr, update_target.len);
|
|
644
694
|
switch (dock_icon) {
|
|
645
695
|
.host_file => {},
|
|
646
696
|
.masked_render => spawnDevDockIconRender(host, app_info.icon_path),
|
|
@@ -765,6 +815,7 @@ pub const MacPlatform = struct {
|
|
|
765
815
|
.reveal_path_fn = revealPath,
|
|
766
816
|
.add_recent_document_fn = addRecentDocument,
|
|
767
817
|
.clear_recent_documents_fn = clearRecentDocuments,
|
|
818
|
+
.check_for_updates_fn = checkForUpdates,
|
|
768
819
|
.create_tray_fn = createTray,
|
|
769
820
|
.update_tray_shell_fn = updateTrayShell,
|
|
770
821
|
.update_tray_menu_fn = updateTrayMenu,
|
|
@@ -812,6 +863,7 @@ pub const MacPlatform = struct {
|
|
|
812
863
|
.update_widget_accessibility_fn = updateWidgetAccessibility,
|
|
813
864
|
.measure_text_fn = measureText,
|
|
814
865
|
.measure_text_advances_fn = measureTextAdvances,
|
|
866
|
+
.measure_text_ink_fn = measureTextInk,
|
|
815
867
|
.decode_image_fn = decodeImage,
|
|
816
868
|
},
|
|
817
869
|
.app_info = self.app_info,
|
|
@@ -1167,6 +1219,7 @@ pub fn installHeadlessTextServices(services: *platform_mod.PlatformServices) voi
|
|
|
1167
1219
|
native_sdk_appkit_register_bundled_fonts();
|
|
1168
1220
|
services.measure_text_fn = measureText;
|
|
1169
1221
|
services.measure_text_advances_fn = measureTextAdvances;
|
|
1222
|
+
services.measure_text_ink_fn = measureTextInk;
|
|
1170
1223
|
services.register_gpu_surface_font_fn = registerGpuSurfaceFont;
|
|
1171
1224
|
services.unregister_gpu_surface_font_fn = unregisterGpuSurfaceFont;
|
|
1172
1225
|
}
|
|
@@ -1196,6 +1249,23 @@ fn measureTextAdvances(context: ?*anyopaque, font_id: u64, size: f32, text: []co
|
|
|
1196
1249
|
return native_sdk_appkit_measure_text_advances(font_id, size, text.ptr, text.len, advances.ptr) == 1;
|
|
1197
1250
|
}
|
|
1198
1251
|
|
|
1252
|
+
fn measureTextInk(context: ?*anyopaque, font_id: u64, size: f32, text: []const u8, metrics: *canvas.TextInkMetrics) bool {
|
|
1253
|
+
_ = context;
|
|
1254
|
+
if (text.len == 0) return false;
|
|
1255
|
+
var min_x: f64 = 0;
|
|
1256
|
+
var max_x: f64 = 0;
|
|
1257
|
+
var min_y: f64 = 0;
|
|
1258
|
+
var max_y: f64 = 0;
|
|
1259
|
+
if (native_sdk_appkit_measure_text_ink(font_id, size, text.ptr, text.len, &min_x, &max_x, &min_y, &max_y) != 1) return false;
|
|
1260
|
+
metrics.* = .{
|
|
1261
|
+
.min_x = @floatCast(min_x),
|
|
1262
|
+
.max_x = @floatCast(max_x),
|
|
1263
|
+
.min_y = @floatCast(min_y),
|
|
1264
|
+
.max_y = @floatCast(max_y),
|
|
1265
|
+
};
|
|
1266
|
+
return true;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1199
1269
|
/// System image decoding (ImageIO raster codecs plus NSImage's SVG
|
|
1200
1270
|
/// rasterizer) into straight-alpha RGBA8.
|
|
1201
1271
|
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
@@ -2314,6 +2384,11 @@ fn clearRecentDocuments(context: ?*anyopaque) anyerror!void {
|
|
|
2314
2384
|
if (native_sdk_appkit_clear_recent_documents(self.host) == 0) return error.UnsupportedService;
|
|
2315
2385
|
}
|
|
2316
2386
|
|
|
2387
|
+
fn checkForUpdates(context: ?*anyopaque, user_initiated: bool) anyerror!void {
|
|
2388
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2389
|
+
if (native_sdk_appkit_check_for_updates(self.host, if (user_initiated) 1 else 0) == 0) return error.UnsupportedService;
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2317
2392
|
fn configureSecurityPolicy(context: ?*anyopaque, policy: security.Policy) anyerror!void {
|
|
2318
2393
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2319
2394
|
var origins_buffer: [4096]u8 = undefined;
|
|
@@ -2690,6 +2765,8 @@ fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, o
|
|
|
2690
2765
|
@intFromEnum(presentation.tone),
|
|
2691
2766
|
presentation.icon_opacity,
|
|
2692
2767
|
if (presentation.monospaced) 1 else 0,
|
|
2768
|
+
presentation.font_size,
|
|
2769
|
+
@intFromEnum(presentation.font_weight),
|
|
2693
2770
|
options.activation_command.ptr,
|
|
2694
2771
|
options.activation_command.len,
|
|
2695
2772
|
options.alternate_activation_command.ptr,
|
|
@@ -2739,6 +2816,65 @@ fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemI
|
|
|
2739
2816
|
(@as(u32, @intFromBool(item.modifiers.shift)) << 4);
|
|
2740
2817
|
}
|
|
2741
2818
|
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);
|
|
2819
|
+
|
|
2820
|
+
var segment_options: [max_tray_items * platform_mod.max_tray_segment_options]AppKitTraySegmentOption = undefined;
|
|
2821
|
+
var segmented_rows: [max_tray_items]AppKitTraySegmentedRow = undefined;
|
|
2822
|
+
var metric_rows: [max_tray_items]AppKitTrayMetricRow = undefined;
|
|
2823
|
+
var chart_rows: [max_tray_items]AppKitTrayChartRow = undefined;
|
|
2824
|
+
var option_count: usize = 0;
|
|
2825
|
+
var segmented_count: usize = 0;
|
|
2826
|
+
var metric_count: usize = 0;
|
|
2827
|
+
var chart_count: usize = 0;
|
|
2828
|
+
for (items[0..count], 0..) |item, row_index| {
|
|
2829
|
+
if (item.segmented) |segmented| {
|
|
2830
|
+
const start = option_count;
|
|
2831
|
+
for (segmented.options) |option| {
|
|
2832
|
+
segment_options[option_count] = .{
|
|
2833
|
+
.item_id = option.id,
|
|
2834
|
+
.label = option.label.ptr,
|
|
2835
|
+
.label_len = option.label.len,
|
|
2836
|
+
.selected = if (option.selected) 1 else 0,
|
|
2837
|
+
.enabled = if (option.enabled) 1 else 0,
|
|
2838
|
+
};
|
|
2839
|
+
option_count += 1;
|
|
2840
|
+
}
|
|
2841
|
+
segmented_rows[segmented_count] = .{
|
|
2842
|
+
.row_index = row_index,
|
|
2843
|
+
.options = segment_options[start..option_count].ptr,
|
|
2844
|
+
.option_count = option_count - start,
|
|
2845
|
+
};
|
|
2846
|
+
segmented_count += 1;
|
|
2847
|
+
}
|
|
2848
|
+
if (item.metric) |metric| {
|
|
2849
|
+
metric_rows[metric_count] = .{
|
|
2850
|
+
.row_index = row_index,
|
|
2851
|
+
.primary_text = metric.primary_text.ptr,
|
|
2852
|
+
.primary_text_len = metric.primary_text.len,
|
|
2853
|
+
.secondary_text = metric.secondary_text.ptr,
|
|
2854
|
+
.secondary_text_len = metric.secondary_text.len,
|
|
2855
|
+
.accessibility_label = metric.accessibility_label.ptr,
|
|
2856
|
+
.accessibility_label_len = metric.accessibility_label.len,
|
|
2857
|
+
};
|
|
2858
|
+
metric_count += 1;
|
|
2859
|
+
}
|
|
2860
|
+
if (item.chart) |chart| {
|
|
2861
|
+
chart_rows[chart_count] = .{
|
|
2862
|
+
.row_index = row_index,
|
|
2863
|
+
.values = chart.values.ptr,
|
|
2864
|
+
.value_count = chart.values.len,
|
|
2865
|
+
.min_value = chart.min_value,
|
|
2866
|
+
.max_value = chart.max_value,
|
|
2867
|
+
.leading_caption = chart.leading_caption.ptr,
|
|
2868
|
+
.leading_caption_len = chart.leading_caption.len,
|
|
2869
|
+
.trailing_summary = chart.trailing_summary.ptr,
|
|
2870
|
+
.trailing_summary_len = chart.trailing_summary.len,
|
|
2871
|
+
.accessibility_label = chart.accessibility_label.ptr,
|
|
2872
|
+
.accessibility_label_len = chart.accessibility_label.len,
|
|
2873
|
+
};
|
|
2874
|
+
chart_count += 1;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
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
2878
|
}
|
|
2743
2879
|
|
|
2744
2880
|
fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, title: []const u8) anyerror!void {
|
|
@@ -2748,7 +2884,7 @@ fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItem
|
|
|
2748
2884
|
|
|
2749
2885
|
fn updateTrayPresentation(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, presentation: platform_mod.TrayPresentation) anyerror!void {
|
|
2750
2886
|
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);
|
|
2887
|
+
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
2888
|
}
|
|
2753
2889
|
|
|
2754
2890
|
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
@@ -2783,6 +2919,14 @@ test "mac platform module exports type" {
|
|
|
2783
2919
|
_ = MacPlatform;
|
|
2784
2920
|
}
|
|
2785
2921
|
|
|
2922
|
+
test "mac AppKit packet text anchors use the resolved font ascent" {
|
|
2923
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2924
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "static BOOL NativeSdkPacketDrawAttributedText(") != null);
|
|
2925
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "drawGlyphsForGlyphRange:glyphRange atPoint:") != null);
|
|
2926
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "glyphRangeForTextContainer:container") != null);
|
|
2927
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "native_sdk_appkit_measure_text_ink(") != null);
|
|
2928
|
+
}
|
|
2929
|
+
|
|
2786
2930
|
test "mac status agent rows recognize decorated states and stay actionable" {
|
|
2787
2931
|
const host_source = @embedFile("appkit_host.m");
|
|
2788
2932
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"configured \"]") != null);
|
|
@@ -2821,6 +2965,17 @@ test "mac status lifecycle hooks emit tray commands" {
|
|
|
2821
2965
|
}
|
|
2822
2966
|
}
|
|
2823
2967
|
|
|
2968
|
+
test "mac typed tray rows cross the AppKit ABI without text conventions" {
|
|
2969
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |source| {
|
|
2970
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "TraySegmentedView") != null);
|
|
2971
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "NSSegmentedControl") != null);
|
|
2972
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "TrayChartView") != null);
|
|
2973
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "native_sdk_appkit_update_tray_rich_rows") != null);
|
|
2974
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "range_selected") == null);
|
|
2975
|
+
try std.testing.expect(std.mem.indexOf(u8, source, "chart|") == null);
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2824
2979
|
test "mac status menu updates preserve the menu being opened" {
|
|
2825
2980
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2826
2981
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu = entry.menu;") != null);
|
|
@@ -2928,6 +3083,53 @@ test "both mac hosts apply launch dock presence before configuring the app" {
|
|
|
2928
3083
|
}
|
|
2929
3084
|
}
|
|
2930
3085
|
|
|
3086
|
+
test "mac updater hashes archives off the main thread and treats user cancellation silently" {
|
|
3087
|
+
const host_source = @embedFile("appkit_host.m");
|
|
3088
|
+
const install_at = std.mem.indexOf(u8, host_source, "- (void)installDownloadedUpdate:(NSURL *)downloadURL version:(NSString *)version archiveBytes:(uint64_t)archiveBytes sha256:(NSString *)sha256 {") orelse return error.TestExpectedEqual;
|
|
3089
|
+
const install_tail = host_source[install_at..];
|
|
3090
|
+
const install_end = std.mem.indexOf(u8, install_tail, "- (NSMenuItem *)menuItem:") orelse return error.TestExpectedEqual;
|
|
3091
|
+
const install_body = install_tail[0..install_end];
|
|
3092
|
+
const background_at = std.mem.indexOf(u8, install_body, "dispatch_get_global_queue(QOS_CLASS_USER_INITIATED, 0)") orelse return error.TestExpectedEqual;
|
|
3093
|
+
const verify_at = std.mem.indexOf(u8, install_body, "native_sdk_update_verify_archive(") orelse return error.TestExpectedEqual;
|
|
3094
|
+
try std.testing.expect(background_at < verify_at);
|
|
3095
|
+
|
|
3096
|
+
const download_at = std.mem.indexOf(u8, host_source, "- (void)downloadUpdateVersion:(NSString *)version archiveURL:(NSString *)archiveURL archiveBytes:(uint64_t)archiveBytes sha256:(NSString *)sha256 releaseNotes:(NSString *)releaseNotes {") orelse return error.TestExpectedEqual;
|
|
3097
|
+
const download_tail = host_source[download_at..];
|
|
3098
|
+
const download_end = std.mem.indexOf(u8, download_tail, "- (void)updateDownloadLimitTimerFired:") orelse return error.TestExpectedEqual;
|
|
3099
|
+
const download_body = download_tail[0..download_end];
|
|
3100
|
+
try std.testing.expect(std.mem.indexOf(u8, download_body, "strongSelf.updateDownloadCancelledByUser = YES;") != null);
|
|
3101
|
+
try std.testing.expect(std.mem.indexOf(u8, download_body, "if (cancelledByUser)") != null);
|
|
3102
|
+
try std.testing.expect(std.mem.indexOf(u8, download_body, "strongSelf.updateCheckRunning = NO;") != null);
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3105
|
+
test "mac updater binds packaged releases to the installed bundle identity" {
|
|
3106
|
+
const host_source = @embedFile("appkit_host.m");
|
|
3107
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "static NSString *NativeSdkPackagedBundleIdentifier(void)") != null);
|
|
3108
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "self.bundleIdentifier = NativeSdkPackagedBundleIdentifier() ?: configuredBundleIdentifier;") != null);
|
|
3109
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "strongSelf.bundleIdentifier.UTF8String") != null);
|
|
3110
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[candidateBundle.bundleIdentifier isEqualToString:strongSelf.bundleIdentifier]") != null);
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3113
|
+
test "mac updater presents without relying on the startup window and cleans failed staging" {
|
|
3114
|
+
const host_source = @embedFile("appkit_host.m");
|
|
3115
|
+
const helper_at = std.mem.lastIndexOf(u8, host_source, "- (void)presentUpdateAlert:(NSAlert *)alert completionHandler:") orelse return error.TestExpectedEqual;
|
|
3116
|
+
const helper_tail = host_source[helper_at..];
|
|
3117
|
+
const helper_end = std.mem.indexOf(u8, helper_tail, "- (void)showUpdateError:") orelse return error.TestExpectedEqual;
|
|
3118
|
+
const helper_body = helper_tail[0..helper_end];
|
|
3119
|
+
try std.testing.expect(std.mem.indexOf(u8, helper_body, "[self updatePresentationWindow]") != null);
|
|
3120
|
+
try std.testing.expect(std.mem.indexOf(u8, helper_body, "[alert runModal]") != null);
|
|
3121
|
+
try std.testing.expect(std.mem.indexOf(u8, helper_body, "self.window") == null);
|
|
3122
|
+
|
|
3123
|
+
const install_at = std.mem.indexOf(u8, host_source, "- (void)installDownloadedUpdate:(NSURL *)downloadURL version:") orelse return error.TestExpectedEqual;
|
|
3124
|
+
const install_tail = host_source[install_at..];
|
|
3125
|
+
const create_failure = std.mem.indexOf(u8, install_tail, "if (![manager createDirectoryAtPath:extractPath") orelse return error.TestExpectedEqual;
|
|
3126
|
+
const failure_tail = install_tail[create_failure..];
|
|
3127
|
+
const failure_end = std.mem.indexOf(u8, failure_tail, "NSString *taskOutput") orelse return error.TestExpectedEqual;
|
|
3128
|
+
const failure_body = failure_tail[0..failure_end];
|
|
3129
|
+
try std.testing.expect(std.mem.indexOf(u8, failure_body, "removeItemAtPath:stagePath") != null);
|
|
3130
|
+
try std.testing.expect(std.mem.indexOf(u8, failure_body, "removeItemAtURL:downloadURL") != null);
|
|
3131
|
+
}
|
|
3132
|
+
|
|
2931
3133
|
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
2932
3134
|
const host_source = @embedFile("appkit_host.m");
|
|
2933
3135
|
const helper_at = std.mem.indexOf(
|