@native-sdk/cli 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +357 -33
- package/build.zig +234 -11
- package/native-sdk.d.ts +8 -0
- package/package.json +10 -10
- package/packages/core/compile-surface/core.ts +70 -1
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/merge_static_archives.mjs +78 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
- package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
- package/packages/core/scripts/stage_external_services.mjs +1 -1
- package/packages/core/sdk/core.d.ts +75 -0
- package/packages/core/sdk/core.ts +170 -13
- package/packages/core/sdk/events.d.ts +53 -0
- package/packages/core/sdk/events.ts +78 -7
- package/packages/core/src/checker.ts +470 -2
- package/packages/core/src/cli.ts +13 -0
- package/packages/core/src/contract.ts +3 -1
- package/packages/core/src/devhost.ts +30 -1
- package/packages/core/src/devhost_journal.mjs +10 -8
- package/packages/core/src/diagnostics.ts +99 -8
- package/packages/core/src/frontend.ts +6 -0
- package/packages/core/src/infer.ts +24 -0
- package/skill-data/automation/SKILL.md +1 -1
- package/skill-data/native-ui/SKILL.md +18 -12
- package/skill-data/ts-core/SKILL.md +54 -21
- package/skill-data/ts-services/SKILL.md +4 -4
- package/skill-data/ts-services/references/service-surface.md +2 -1
- package/skill-data/zig/SKILL.md +1 -1
- package/src/app_runner/root.zig +122 -6
- package/src/app_runner/ts_core_main.zig +9 -4
- package/src/app_runner/ts_core_mobile.zig +241 -0
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +8 -6
- package/src/embed/app_exports.zig +3 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +2 -0
- package/src/embed/tests.zig +41 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +94 -4
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +17 -3
- package/src/platform/linux/gtk_host.c +243 -15
- package/src/platform/linux/gtk_host.h +5 -4
- package/src/platform/linux/root.zig +91 -11
- package/src/platform/macos/appkit_host.h +18 -11
- package/src/platform/macos/appkit_host.m +402 -128
- package/src/platform/macos/cef_host.mm +342 -122
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +231 -39
- package/src/platform/null_platform.zig +251 -54
- package/src/platform/null_platform_tests.zig +97 -4
- package/src/platform/root.zig +12 -0
- package/src/platform/types.zig +174 -35
- package/src/platform/windows/root.zig +42 -13
- package/src/platform/windows/webview2_host.cpp +72 -11
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +50 -0
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +13 -2
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +20 -0
- package/src/primitives/canvas/ui.zig +55 -2
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +47 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +10 -0
- package/src/runtime/api.zig +14 -0
- package/src/runtime/automation_commands.zig +35 -2
- package/src/runtime/automation_snapshot.zig +32 -24
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/bridge_permission_tests.zig +35 -1
- package/src/runtime/bridge_responses.zig +1 -1
- package/src/runtime/builtin_bridge.zig +16 -3
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +31 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/core.zig +28 -6
- package/src/runtime/effects.zig +1337 -49
- package/src/runtime/effects_file_tests.zig +587 -0
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/effects_notification_tests.zig +11 -0
- package/src/runtime/file_access.zig +400 -0
- package/src/runtime/file_effect_crash_helper.zig +28 -0
- package/src/runtime/file_effect_crash_tests.zig +37 -0
- package/src/runtime/flow.zig +21 -9
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +44 -2
- package/src/runtime/pty.zig +5 -2
- package/src/runtime/root.zig +7 -0
- package/src/runtime/session_blobs.zig +4 -1
- package/src/runtime/session_journal.zig +56 -5
- package/src/runtime/session_record.zig +38 -0
- package/src/runtime/session_replay.zig +110 -15
- package/src/runtime/session_tests.zig +192 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/state.zig +10 -0
- package/src/runtime/system_services.zig +129 -36
- package/src/runtime/ts_core_host.zig +281 -11
- package/src/runtime/ts_core_host_tests.zig +142 -1
- package/src/runtime/ts_ui_app.zig +461 -8
- package/src/runtime/ui_app.zig +330 -112
- package/src/runtime/ui_app_tests.zig +251 -25
- package/src/runtime/ui_app_window_tests.zig +74 -8
- package/src/runtime/validation.zig +20 -0
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +156 -18
- package/src/tooling/ts_core.zig +83 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +3 -3
- package/tools/corewire/emit_facade.zig +65 -5
- package/tools/corewire/emit_profile.zig +2 -2
- package/tools/corewire/emit_service.zig +2 -2
- package/tools/corewire/service_contract.zig +4 -4
- package/tools/corewire/sidecar.zig +4 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <ImageIO/ImageIO.h>
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
#include "../ios/apple_image_fit.h"
|
|
6
|
+
|
|
7
|
+
/* Test-only ImageIO probe linked by build.zig, not by apps. It exercises the
|
|
8
|
+
* platform's real secondary-dimension rounding against the shared fit helper
|
|
9
|
+
* without pulling the full AppKit host into the framework unit-test binary. */
|
|
10
|
+
int native_sdk_test_imageio_thumbnail_dimensions(
|
|
11
|
+
const uint8_t *bytes,
|
|
12
|
+
size_t bytes_len,
|
|
13
|
+
size_t source_width,
|
|
14
|
+
size_t source_height,
|
|
15
|
+
size_t max_pixels,
|
|
16
|
+
size_t *out_width,
|
|
17
|
+
size_t *out_height
|
|
18
|
+
) {
|
|
19
|
+
if (out_width) *out_width = 0;
|
|
20
|
+
if (out_height) *out_height = 0;
|
|
21
|
+
if (!bytes || bytes_len == 0) return 0;
|
|
22
|
+
@autoreleasepool {
|
|
23
|
+
NSData *data = [NSData dataWithBytesNoCopy:(void *)bytes length:bytes_len freeWhenDone:NO];
|
|
24
|
+
CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
|
|
25
|
+
if (!source) return 0;
|
|
26
|
+
const size_t max_dimension = native_sdk_apple_image_thumbnail_max_dimension(
|
|
27
|
+
source_width,
|
|
28
|
+
source_height,
|
|
29
|
+
max_pixels
|
|
30
|
+
);
|
|
31
|
+
NSDictionary *options = @{
|
|
32
|
+
(NSString *)kCGImageSourceCreateThumbnailFromImageAlways: @YES,
|
|
33
|
+
(NSString *)kCGImageSourceThumbnailMaxPixelSize: @(max_dimension),
|
|
34
|
+
(NSString *)kCGImageSourceCreateThumbnailWithTransform: @YES,
|
|
35
|
+
};
|
|
36
|
+
CGImageRef image = CGImageSourceCreateThumbnailAtIndex(source, 0, (__bridge CFDictionaryRef)options);
|
|
37
|
+
CFRelease(source);
|
|
38
|
+
if (!image) return 0;
|
|
39
|
+
if (out_width) *out_width = CGImageGetWidth(image);
|
|
40
|
+
if (out_height) *out_height = CGImageGetHeight(image);
|
|
41
|
+
CGImageRelease(image);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -4,9 +4,10 @@ const geometry = @import("geometry");
|
|
|
4
4
|
const platform_mod = @import("../root.zig");
|
|
5
5
|
const policy_values = @import("../policy_values.zig");
|
|
6
6
|
const security = @import("../../security/root.zig");
|
|
7
|
+
const canvas = @import("canvas");
|
|
7
8
|
// The packaging pipeline's one-image icon machinery: dev runs borrow its
|
|
8
9
|
// macOS mask/inset render so the Dock tile matches `native package`.
|
|
9
|
-
const app_icon =
|
|
10
|
+
const app_icon = canvas.app_icon;
|
|
10
11
|
|
|
11
12
|
pub const Error = error{
|
|
12
13
|
CallbackFailed,
|
|
@@ -43,6 +44,7 @@ const AppKitEventKind = enum(c_int) {
|
|
|
43
44
|
video = 21,
|
|
44
45
|
view_focused = 22,
|
|
45
46
|
tray_command = 23,
|
|
47
|
+
notification_command = 24,
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
const AppKitEvent = extern struct {
|
|
@@ -67,6 +69,7 @@ const AppKitEvent = extern struct {
|
|
|
67
69
|
shortcut_modifiers: u32,
|
|
68
70
|
command_name: [*]const u8,
|
|
69
71
|
command_name_len: usize,
|
|
72
|
+
status_item_id: u32,
|
|
70
73
|
view_label: [*]const u8,
|
|
71
74
|
view_label_len: usize,
|
|
72
75
|
key_text: [*]const u8,
|
|
@@ -151,13 +154,23 @@ const AppKitBridgeCallback = *const fn (context: ?*anyopaque, window_id: u64, we
|
|
|
151
154
|
/// anything else one dropped frame.
|
|
152
155
|
const AppKitVideoSinkPush = *const fn (context: ?*anyopaque, width: usize, height: usize, pixels: [*c]const u8, len: usize) callconv(.c) c_int;
|
|
153
156
|
|
|
157
|
+
extern fn native_sdk_test_imageio_thumbnail_dimensions(
|
|
158
|
+
bytes: [*]const u8,
|
|
159
|
+
bytes_len: usize,
|
|
160
|
+
source_width: usize,
|
|
161
|
+
source_height: usize,
|
|
162
|
+
max_pixels: usize,
|
|
163
|
+
out_width: *usize,
|
|
164
|
+
out_height: *usize,
|
|
165
|
+
) c_int;
|
|
166
|
+
|
|
154
167
|
const shortcut_modifier_primary: u32 = 1 << 0;
|
|
155
168
|
const shortcut_modifier_command: u32 = 1 << 1;
|
|
156
169
|
const shortcut_modifier_control: u32 = 1 << 2;
|
|
157
170
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
158
171
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
159
172
|
|
|
160
|
-
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) ?*AppKitHost;
|
|
173
|
+
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, dock_visible: c_int, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) ?*AppKitHost;
|
|
161
174
|
extern fn native_sdk_appkit_destroy(host: *AppKitHost) void;
|
|
162
175
|
extern fn native_sdk_appkit_set_dock_icon_rgba(host: *AppKitHost, pixels: [*]const u8, width: usize, height: usize) void;
|
|
163
176
|
extern fn native_sdk_appkit_set_dock_icon_file(host: *AppKitHost, path: [*]const u8, path_len: usize) void;
|
|
@@ -175,7 +188,7 @@ extern fn native_sdk_appkit_set_security_policy(host: *AppKitHost, allowed_origi
|
|
|
175
188
|
extern fn native_sdk_appkit_set_menus(host: *AppKitHost, menu_titles: [*]const [*]const u8, menu_title_lens: [*]const usize, menu_count: usize, item_menu_indices: [*]const u32, item_labels: [*]const [*]const u8, item_label_lens: [*]const usize, item_commands: [*]const [*]const u8, item_command_lens: [*]const usize, item_keys: [*]const [*]const u8, item_key_lens: [*]const usize, item_modifiers: [*]const u32, item_separators: [*]const c_int, item_enabled: [*]const c_int, item_checked: [*]const c_int, item_count: usize) void;
|
|
176
189
|
extern fn native_sdk_appkit_set_shortcuts(host: *AppKitHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
177
190
|
extern fn native_sdk_appkit_request_frame(host: *AppKitHost) void;
|
|
178
|
-
extern fn native_sdk_appkit_create_window(host: *AppKitHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) c_int;
|
|
191
|
+
extern fn native_sdk_appkit_create_window(host: *AppKitHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, show_policy: c_int, window_flags: u32) c_int;
|
|
179
192
|
extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, window_id: u64, min_width: f64, min_height: f64) c_int;
|
|
180
193
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
181
194
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
@@ -242,11 +255,11 @@ extern fn native_sdk_appkit_measure_text_advances(font_id: u64, size: f64, text:
|
|
|
242
255
|
extern fn native_sdk_appkit_register_font(font_id: u64, bytes: [*]const u8, bytes_len: usize, out_token: *u64) c_int;
|
|
243
256
|
extern fn native_sdk_appkit_unregister_font(font_id: u64, token: u64) c_int;
|
|
244
257
|
extern fn native_sdk_appkit_register_bundled_fonts() void;
|
|
245
|
-
extern fn native_sdk_appkit_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
|
|
258
|
+
extern fn native_sdk_appkit_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
|
|
246
259
|
extern fn native_sdk_appkit_clipboard_write(host: *AppKitHost, text: [*]const u8, text_len: usize) void;
|
|
247
260
|
extern fn native_sdk_appkit_clipboard_read_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
248
261
|
extern fn native_sdk_appkit_clipboard_write_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, bytes: [*]const u8, bytes_len: usize) c_int;
|
|
249
|
-
extern fn native_sdk_appkit_show_notification(host: *AppKitHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
|
|
262
|
+
extern fn native_sdk_appkit_show_notification(host: *AppKitHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize, notification_id: [*]const u8, notification_id_len: usize, action_label: [*]const u8, action_label_len: usize, action_command: [*]const u8, action_command_len: usize) c_int;
|
|
250
263
|
extern fn native_sdk_appkit_open_external_url(host: *AppKitHost, url: [*]const u8, url_len: usize) c_int;
|
|
251
264
|
extern fn native_sdk_appkit_reveal_path(host: *AppKitHost, path: [*]const u8, path_len: usize) c_int;
|
|
252
265
|
extern fn native_sdk_appkit_add_recent_document(host: *AppKitHost, path: [*]const u8, path_len: usize) c_int;
|
|
@@ -335,6 +348,7 @@ const AppKitMessageDialogOpts = extern struct {
|
|
|
335
348
|
|
|
336
349
|
const AppKitWidgetAccessibilityNode = extern struct {
|
|
337
350
|
id: u64,
|
|
351
|
+
parent_id: u64,
|
|
338
352
|
role: c_int,
|
|
339
353
|
label: [*]const u8,
|
|
340
354
|
label_len: usize,
|
|
@@ -399,16 +413,17 @@ const widget_action_drag: u32 = 1 << 8;
|
|
|
399
413
|
const widget_action_drop_files: u32 = 1 << 9;
|
|
400
414
|
const widget_action_dismiss: u32 = 1 << 10;
|
|
401
415
|
|
|
402
|
-
const AppKitTrayCallback = *const fn (context: ?*anyopaque, item_id: u32) callconv(.c) void;
|
|
416
|
+
const AppKitTrayCallback = *const fn (context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void;
|
|
403
417
|
|
|
404
418
|
extern fn native_sdk_appkit_show_open_dialog(host: *AppKitHost, opts: *const AppKitOpenDialogOpts, buffer: [*]u8, buffer_len: usize) AppKitOpenDialogResult;
|
|
405
419
|
extern fn native_sdk_appkit_show_save_dialog(host: *AppKitHost, opts: *const AppKitSaveDialogOpts, buffer: [*]u8, buffer_len: usize) usize;
|
|
406
420
|
extern fn native_sdk_appkit_show_message_dialog(host: *AppKitHost, opts: *const AppKitMessageDialogOpts) c_int;
|
|
407
|
-
extern fn native_sdk_appkit_create_tray(host: *AppKitHost, icon_path: [*]const u8, icon_path_len: usize, title: [*]const u8, title_len: usize, tooltip: [*]const u8, tooltip_len: usize, 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;
|
|
408
|
-
extern fn
|
|
409
|
-
extern fn
|
|
410
|
-
extern fn
|
|
411
|
-
extern fn
|
|
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;
|
|
422
|
+
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
|
+
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;
|
|
424
|
+
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;
|
|
426
|
+
extern fn native_sdk_appkit_remove_tray(host: *AppKitHost, status_item_id: u32) void;
|
|
412
427
|
extern fn native_sdk_appkit_set_tray_callback(host: *AppKitHost, callback: AppKitTrayCallback, context: ?*anyopaque) void;
|
|
413
428
|
|
|
414
429
|
/// Whether a Dock icon path names a raw image source (.png/.svg) that
|
|
@@ -625,7 +640,7 @@ pub const MacPlatform = struct {
|
|
|
625
640
|
// the classic load byte-for-byte.
|
|
626
641
|
const dock_icon = planDockIcon(app_info.icon_path);
|
|
627
642
|
const icon_path = if (dock_icon == .host_file) app_info.icon_path else "";
|
|
628
|
-
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, 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, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
643
|
+
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;
|
|
629
644
|
switch (dock_icon) {
|
|
630
645
|
.host_file => {},
|
|
631
646
|
.masked_render => spawnDevDockIconRender(host, app_info.icon_path),
|
|
@@ -751,6 +766,7 @@ pub const MacPlatform = struct {
|
|
|
751
766
|
.add_recent_document_fn = addRecentDocument,
|
|
752
767
|
.clear_recent_documents_fn = clearRecentDocuments,
|
|
753
768
|
.create_tray_fn = createTray,
|
|
769
|
+
.update_tray_shell_fn = updateTrayShell,
|
|
754
770
|
.update_tray_menu_fn = updateTrayMenu,
|
|
755
771
|
.update_tray_title_fn = updateTrayTitle,
|
|
756
772
|
.update_tray_presentation_fn = updateTrayPresentation,
|
|
@@ -970,6 +986,11 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
|
|
|
970
986
|
.tray_command => state.emit(.{ .tray_command = .{
|
|
971
987
|
.name = event.command_name[0..event.command_name_len],
|
|
972
988
|
.window_id = event.window_id,
|
|
989
|
+
.status_item_id = event.status_item_id,
|
|
990
|
+
} }),
|
|
991
|
+
.notification_command => state.emit(.{ .notification_command = .{
|
|
992
|
+
.name = event.command_name[0..event.command_name_len],
|
|
993
|
+
.window_id = event.window_id,
|
|
973
994
|
} }),
|
|
974
995
|
.timer => state.emit(.{ .timer = .{
|
|
975
996
|
.id = event.timer_id,
|
|
@@ -1170,17 +1191,89 @@ fn measureTextAdvances(context: ?*anyopaque, font_id: u64, size: f32, text: []co
|
|
|
1170
1191
|
|
|
1171
1192
|
/// System image decoding (ImageIO raster codecs plus NSImage's SVG
|
|
1172
1193
|
/// rasterizer) into straight-alpha RGBA8.
|
|
1173
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
1194
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
1174
1195
|
_ = context;
|
|
1175
1196
|
var width: usize = 0;
|
|
1176
1197
|
var height: usize = 0;
|
|
1177
|
-
return switch (native_sdk_appkit_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
|
|
1198
|
+
return switch (native_sdk_appkit_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
|
|
1178
1199
|
1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
|
|
1179
1200
|
-1 => error.ImageTooLarge,
|
|
1180
1201
|
else => error.ImageDecodeFailed,
|
|
1181
1202
|
};
|
|
1182
1203
|
}
|
|
1183
1204
|
|
|
1205
|
+
test "mac image decoder keeps ImageIO thumbnail rounding inside the pixel cap" {
|
|
1206
|
+
// The Objective-C probe is compiled and linked only for macOS test
|
|
1207
|
+
// artifacts (build.zig's target-gated image_fit_test.m source). Keep
|
|
1208
|
+
// every other host from referencing its symbol at link time.
|
|
1209
|
+
if (comptime builtin.os.tag != .macos) return error.SkipZigTest;
|
|
1210
|
+
|
|
1211
|
+
// ImageIO derives the minor dimension from ThumbnailMaxPixelSize and
|
|
1212
|
+
// rounds it. 537x503 at the default 262,144-pixel target used to ask
|
|
1213
|
+
// for a 529px major side and return 529x496 = 262,384 pixels, which
|
|
1214
|
+
// the runtime correctly rejected as ImageTooLarge. The host must leave
|
|
1215
|
+
// enough headroom for that platform rounding before it asks ImageIO.
|
|
1216
|
+
const source_width: usize = 537;
|
|
1217
|
+
const source_height: usize = 503;
|
|
1218
|
+
const source_pixels = try std.testing.allocator.alloc(u8, source_width * source_height * 4);
|
|
1219
|
+
defer std.testing.allocator.free(source_pixels);
|
|
1220
|
+
var offset: usize = 0;
|
|
1221
|
+
while (offset < source_pixels.len) : (offset += 4) {
|
|
1222
|
+
source_pixels[offset..][0..4].* = .{ 23, 91, 177, 255 };
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
const encoded_len = try canvas.png.encodedRgba8ByteLen(source_width, source_height);
|
|
1226
|
+
const encoded = try std.testing.allocator.alloc(u8, encoded_len);
|
|
1227
|
+
defer std.testing.allocator.free(encoded);
|
|
1228
|
+
var writer = std.Io.Writer.fixed(encoded);
|
|
1229
|
+
try canvas.png.writeRgba8(&writer, source_width, source_height, source_pixels);
|
|
1230
|
+
|
|
1231
|
+
const max_pixels: usize = 512 * 512;
|
|
1232
|
+
var decoded_width: usize = 0;
|
|
1233
|
+
var decoded_height: usize = 0;
|
|
1234
|
+
try std.testing.expectEqual(@as(c_int, 1), native_sdk_test_imageio_thumbnail_dimensions(
|
|
1235
|
+
writer.buffered().ptr,
|
|
1236
|
+
writer.buffered().len,
|
|
1237
|
+
source_width,
|
|
1238
|
+
source_height,
|
|
1239
|
+
max_pixels,
|
|
1240
|
+
&decoded_width,
|
|
1241
|
+
&decoded_height,
|
|
1242
|
+
));
|
|
1243
|
+
try std.testing.expect(decoded_width > 0 and decoded_height > 0);
|
|
1244
|
+
try std.testing.expect(decoded_width * decoded_height <= max_pixels);
|
|
1245
|
+
|
|
1246
|
+
// A source panorama may exceed the decoded-axis ceiling. The host must
|
|
1247
|
+
// request a bounded thumbnail instead of rejecting the source metadata.
|
|
1248
|
+
const panorama_width = platform_mod.max_decoded_image_dimension + 1;
|
|
1249
|
+
const panorama_pixels = try std.testing.allocator.alloc(u8, panorama_width * 4);
|
|
1250
|
+
defer std.testing.allocator.free(panorama_pixels);
|
|
1251
|
+
offset = 0;
|
|
1252
|
+
while (offset < panorama_pixels.len) : (offset += 4) {
|
|
1253
|
+
panorama_pixels[offset..][0..4].* = .{ 47, 113, 191, 255 };
|
|
1254
|
+
}
|
|
1255
|
+
const panorama_encoded_len = try canvas.png.encodedRgba8ByteLen(panorama_width, 1);
|
|
1256
|
+
const panorama_encoded = try std.testing.allocator.alloc(u8, panorama_encoded_len);
|
|
1257
|
+
defer std.testing.allocator.free(panorama_encoded);
|
|
1258
|
+
var panorama_writer = std.Io.Writer.fixed(panorama_encoded);
|
|
1259
|
+
try canvas.png.writeRgba8(&panorama_writer, panorama_width, 1, panorama_pixels);
|
|
1260
|
+
|
|
1261
|
+
decoded_width = 0;
|
|
1262
|
+
decoded_height = 0;
|
|
1263
|
+
try std.testing.expectEqual(@as(c_int, 1), native_sdk_test_imageio_thumbnail_dimensions(
|
|
1264
|
+
panorama_writer.buffered().ptr,
|
|
1265
|
+
panorama_writer.buffered().len,
|
|
1266
|
+
panorama_width,
|
|
1267
|
+
1,
|
|
1268
|
+
max_pixels,
|
|
1269
|
+
&decoded_width,
|
|
1270
|
+
&decoded_height,
|
|
1271
|
+
));
|
|
1272
|
+
try std.testing.expect(decoded_width <= platform_mod.max_decoded_image_dimension);
|
|
1273
|
+
try std.testing.expect(decoded_height > 0);
|
|
1274
|
+
try std.testing.expect(decoded_width * decoded_height <= max_pixels);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1184
1277
|
fn writeClipboard(context: ?*anyopaque, text: []const u8) anyerror!void {
|
|
1185
1278
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1186
1279
|
native_sdk_appkit_clipboard_write(self.host, text.ptr, text.len);
|
|
@@ -1254,6 +1347,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
|
|
|
1254
1347
|
};
|
|
1255
1348
|
}
|
|
1256
1349
|
|
|
1350
|
+
fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
|
|
1351
|
+
return switch (placement) {
|
|
1352
|
+
.restored => 0,
|
|
1353
|
+
.explicit => 1,
|
|
1354
|
+
.default => 2,
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
|
|
1359
|
+
return switch (policy) {
|
|
1360
|
+
.clamp_to_visible_screen => 0,
|
|
1361
|
+
.center_on_primary => 1,
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1257
1365
|
fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
1258
1366
|
return switch (mode) {
|
|
1259
1367
|
.immediate => 0,
|
|
@@ -1308,13 +1416,16 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1308
1416
|
try refuseUnsupportedTransparentWindow(self.web_engine, options);
|
|
1309
1417
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
1310
1418
|
const frame = options.default_frame;
|
|
1311
|
-
if (native_sdk_appkit_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
1419
|
+
if (native_sdk_appkit_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, initialPlacementInt(options.initial_placement), restorePolicyInt(options.restore_policy), if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
1312
1420
|
applyWindowContentMinSize(self.host, options.id, options.min_width, options.min_height);
|
|
1313
1421
|
applyWindowClosePolicy(self.host, options.id, options.close_policy);
|
|
1314
1422
|
return .{
|
|
1315
1423
|
.id = options.id,
|
|
1316
1424
|
.label = options.label,
|
|
1317
1425
|
.title = title,
|
|
1426
|
+
// Placement can alter the origin synchronously in AppKit; the host's
|
|
1427
|
+
// window_frame_changed event reports that actual frame immediately
|
|
1428
|
+
// after startup/create and replaces this requested-frame placeholder.
|
|
1318
1429
|
.frame = frame,
|
|
1319
1430
|
.scale_factor = 1,
|
|
1320
1431
|
.open = true,
|
|
@@ -1975,6 +2086,7 @@ fn updateWidgetAccessibility(context: ?*anyopaque, snapshot: platform_mod.Widget
|
|
|
1975
2086
|
for (snapshot.nodes, 0..) |node, index| {
|
|
1976
2087
|
nodes[index] = .{
|
|
1977
2088
|
.id = node.id,
|
|
2089
|
+
.parent_id = node.parent_id orelse 0,
|
|
1978
2090
|
.role = @intFromEnum(node.role),
|
|
1979
2091
|
.label = node.label.ptr,
|
|
1980
2092
|
.label_len = node.label.len,
|
|
@@ -2109,6 +2221,12 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
2109
2221
|
options.subtitle.len,
|
|
2110
2222
|
options.body.ptr,
|
|
2111
2223
|
options.body.len,
|
|
2224
|
+
options.id.ptr,
|
|
2225
|
+
options.id.len,
|
|
2226
|
+
options.action_label.ptr,
|
|
2227
|
+
options.action_label.len,
|
|
2228
|
+
options.action_command.ptr,
|
|
2229
|
+
options.action_command.len,
|
|
2112
2230
|
) == 0) return error.UnsupportedService;
|
|
2113
2231
|
}
|
|
2114
2232
|
|
|
@@ -2379,6 +2497,31 @@ fn isSupportedNativeViewKind(kind: platform_mod.ViewKind) bool {
|
|
|
2379
2497
|
};
|
|
2380
2498
|
}
|
|
2381
2499
|
|
|
2500
|
+
test "macos notification actions use process-scoped opaque tokens" {
|
|
2501
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2502
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2503
|
+
u8,
|
|
2504
|
+
host_source,
|
|
2505
|
+
"NSString *actionToken = [NSUUID UUID].UUIDString;",
|
|
2506
|
+
) != null);
|
|
2507
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2508
|
+
u8,
|
|
2509
|
+
host_source,
|
|
2510
|
+
"notification.userInfo = @{ @\"native-sdk-action-token\": actionToken };",
|
|
2511
|
+
) != null);
|
|
2512
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2513
|
+
u8,
|
|
2514
|
+
host_source,
|
|
2515
|
+
"self.notificationActionCommands[token]",
|
|
2516
|
+
) != null);
|
|
2517
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2518
|
+
u8,
|
|
2519
|
+
host_source,
|
|
2520
|
+
"@\"native-sdk-action-command\"",
|
|
2521
|
+
) == null);
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2382
2525
|
test "macos supports native container and control kinds" {
|
|
2383
2526
|
try std.testing.expect(isSupportedNativeViewKind(.split));
|
|
2384
2527
|
try std.testing.expect(isSupportedNativeViewKind(.stack));
|
|
@@ -2522,18 +2665,20 @@ fn showMessageDialog(context: ?*anyopaque, options: platform_mod.MessageDialogOp
|
|
|
2522
2665
|
|
|
2523
2666
|
const max_tray_items: usize = 32;
|
|
2524
2667
|
|
|
2525
|
-
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
2668
|
+
fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
|
|
2526
2669
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2527
2670
|
var presentation = options.presentation;
|
|
2528
2671
|
if (presentation.title.len == 0) presentation.title = options.title;
|
|
2529
2672
|
native_sdk_appkit_create_tray(
|
|
2530
2673
|
self.host,
|
|
2674
|
+
status_item_id,
|
|
2531
2675
|
options.icon_path.ptr,
|
|
2532
2676
|
options.icon_path.len,
|
|
2533
2677
|
presentation.title.ptr,
|
|
2534
2678
|
presentation.title.len,
|
|
2535
2679
|
options.tooltip.ptr,
|
|
2536
2680
|
options.tooltip.len,
|
|
2681
|
+
if (options.visible) 1 else 0,
|
|
2537
2682
|
presentation.width,
|
|
2538
2683
|
@intFromEnum(presentation.tone),
|
|
2539
2684
|
presentation.icon_opacity,
|
|
@@ -2546,11 +2691,16 @@ fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!
|
|
|
2546
2691
|
options.open_command.len,
|
|
2547
2692
|
);
|
|
2548
2693
|
if (options.items.len > 0) {
|
|
2549
|
-
try updateTrayMenu(context, options.items);
|
|
2694
|
+
try updateTrayMenu(context, status_item_id, options.items);
|
|
2550
2695
|
}
|
|
2551
2696
|
}
|
|
2552
2697
|
|
|
2553
|
-
fn
|
|
2698
|
+
fn updateTrayShell(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, shell: platform_mod.TrayShell) anyerror!void {
|
|
2699
|
+
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2700
|
+
native_sdk_appkit_update_tray_shell(self.host, status_item_id, shell.icon_path.ptr, shell.icon_path.len, shell.tooltip.ptr, shell.tooltip.len, if (shell.visible) 1 else 0, shell.activation_command.ptr, shell.activation_command.len, shell.alternate_activation_command.ptr, shell.alternate_activation_command.len, shell.open_command.ptr, shell.open_command.len);
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
2554
2704
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2555
2705
|
const count = @min(items.len, max_tray_items);
|
|
2556
2706
|
var ids: [max_tray_items]u32 = undefined;
|
|
@@ -2581,27 +2731,27 @@ fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem
|
|
|
2581
2731
|
(@as(u32, @intFromBool(item.modifiers.option)) << 3) |
|
|
2582
2732
|
(@as(u32, @intFromBool(item.modifiers.shift)) << 4);
|
|
2583
2733
|
}
|
|
2584
|
-
native_sdk_appkit_update_tray_menu(self.host, &ids, &labels, &label_lens, &separators, &enabled_flags, &details, &detail_lens, &roles, &keys, &key_lens, &modifiers, count);
|
|
2734
|
+
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);
|
|
2585
2735
|
}
|
|
2586
2736
|
|
|
2587
|
-
fn updateTrayTitle(context: ?*anyopaque, title: []const u8) anyerror!void {
|
|
2737
|
+
fn updateTrayTitle(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, title: []const u8) anyerror!void {
|
|
2588
2738
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2589
|
-
native_sdk_appkit_update_tray_title(self.host, title.ptr, title.len);
|
|
2739
|
+
native_sdk_appkit_update_tray_title(self.host, status_item_id, title.ptr, title.len);
|
|
2590
2740
|
}
|
|
2591
2741
|
|
|
2592
|
-
fn updateTrayPresentation(context: ?*anyopaque, presentation: platform_mod.TrayPresentation) anyerror!void {
|
|
2742
|
+
fn updateTrayPresentation(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, presentation: platform_mod.TrayPresentation) anyerror!void {
|
|
2593
2743
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2594
|
-
native_sdk_appkit_update_tray_presentation(self.host, presentation.title.ptr, presentation.title.len, presentation.width, @intFromEnum(presentation.tone), presentation.icon_opacity, if (presentation.monospaced) 1 else 0);
|
|
2744
|
+
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);
|
|
2595
2745
|
}
|
|
2596
2746
|
|
|
2597
|
-
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
2747
|
+
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
2598
2748
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
2599
|
-
native_sdk_appkit_remove_tray(self.host);
|
|
2749
|
+
native_sdk_appkit_remove_tray(self.host, status_item_id);
|
|
2600
2750
|
}
|
|
2601
2751
|
|
|
2602
|
-
fn appkitTrayCallback(context: ?*anyopaque, item_id: u32) callconv(.c) void {
|
|
2752
|
+
fn appkitTrayCallback(context: ?*anyopaque, status_item_id: u32, item_id: u32) callconv(.c) void {
|
|
2603
2753
|
const state: *RunState = @ptrCast(@alignCast(context.?));
|
|
2604
|
-
state.emit(.{ .tray_action = item_id });
|
|
2754
|
+
state.emit(.{ .tray_action = .{ .status_item_id = status_item_id, .item_id = item_id } });
|
|
2605
2755
|
}
|
|
2606
2756
|
|
|
2607
2757
|
fn flattenFilters(filters: []const platform_mod.FileFilter, buffer: []u8) []const u8 {
|
|
@@ -2631,7 +2781,7 @@ test "mac status agent rows recognize decorated states and stay actionable" {
|
|
|
2631
2781
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"configured \"]") != null);
|
|
2632
2782
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "[state hasPrefix:@\"warning \"]") != null);
|
|
2633
2783
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "label.textColor = configured ? successColor : warning ? warningColor : NSColor.secondaryLabelColor;") != null);
|
|
2634
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.tag = itemIds[index];") != null);
|
|
2784
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.tag = (NSInteger)(((uint64_t)statusItemId << 32) | itemIds[index]);") != null);
|
|
2635
2785
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.enabled = enabled[index].boolValue;") != null);
|
|
2636
2786
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalent = NativeSdkMenuKeyEquivalent(key);") != null);
|
|
2637
2787
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "button.keyEquivalentModifierMask = NativeSdkMenuModifierFlags(modifiers[index].unsignedIntValue);") != null);
|
|
@@ -2640,22 +2790,22 @@ test "mac status agent rows recognize decorated states and stay actionable" {
|
|
|
2640
2790
|
|
|
2641
2791
|
test "mac title-only tray updates preserve the applied presentation" {
|
|
2642
2792
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2643
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "
|
|
2644
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "
|
|
2645
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "
|
|
2646
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "
|
|
2793
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationWidth = width;") != null);
|
|
2794
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationTone = tone;") != null);
|
|
2795
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationIconOpacity = iconOpacity;") != null);
|
|
2796
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "entry.presentationMonospaced = monospaced;") != null);
|
|
2647
2797
|
const update_at = std.mem.indexOf(u8, host_source, "void native_sdk_appkit_update_tray_title(") orelse return error.TestExpectedEqual;
|
|
2648
2798
|
const update_tail = host_source[update_at..];
|
|
2649
|
-
try std.testing.expect(std.mem.indexOf(u8, update_tail, "
|
|
2650
|
-
try std.testing.expect(std.mem.indexOf(u8, update_tail, "
|
|
2651
|
-
try std.testing.expect(std.mem.indexOf(u8, update_tail, "
|
|
2652
|
-
try std.testing.expect(std.mem.indexOf(u8, update_tail, "
|
|
2799
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationWidth,") != null);
|
|
2800
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationTone,") != null);
|
|
2801
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationIconOpacity,") != null);
|
|
2802
|
+
try std.testing.expect(std.mem.indexOf(u8, update_tail, "entry.presentationMonospaced") != null);
|
|
2653
2803
|
}
|
|
2654
2804
|
}
|
|
2655
2805
|
|
|
2656
2806
|
test "mac status lifecycle hooks emit tray commands" {
|
|
2657
2807
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2658
|
-
const emit_at = std.mem.indexOf(u8, host_source, "- (void)emitStatusCommand:(NSString *)command {") orelse return error.TestExpectedEqual;
|
|
2808
|
+
const emit_at = std.mem.indexOf(u8, host_source, "- (void)emitStatusCommand:(NSString *)command statusItemId:(uint32_t)statusItemId {") orelse return error.TestExpectedEqual;
|
|
2659
2809
|
const emit_tail = host_source[emit_at..];
|
|
2660
2810
|
const emit_end = std.mem.indexOf(u8, emit_tail, "- (void)statusItemActivated:") orelse return error.TestExpectedEqual;
|
|
2661
2811
|
const emit_source = emit_tail[0..emit_end];
|
|
@@ -2666,7 +2816,7 @@ test "mac status lifecycle hooks emit tray commands" {
|
|
|
2666
2816
|
|
|
2667
2817
|
test "mac status menu updates preserve the menu being opened" {
|
|
2668
2818
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2669
|
-
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu =
|
|
2819
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMenu *menu = entry.menu;") != null);
|
|
2670
2820
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "[menu removeAllItems];") != null);
|
|
2671
2821
|
}
|
|
2672
2822
|
}
|
|
@@ -2698,7 +2848,9 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2698
2848
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;") != null);
|
|
2699
2849
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMinX(referenceFrame) + 24.0") != null);
|
|
2700
2850
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(referenceFrame) - 24.0") != null);
|
|
2701
|
-
|
|
2851
|
+
// Only fresh/default windows under the default clamp policy cascade.
|
|
2852
|
+
// center_on_primary deliberately keeps the preceding center placement.
|
|
2853
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "if (initialPlacement == 2 && restorePolicy == 0 && !makeMain && referenceWindow)") != null);
|
|
2702
2854
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSRect visibleFrame = referenceScreen.visibleFrame;") != null);
|
|
2703
2855
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxX(visibleFrame) - NSWidth(cascadedFrame)") != null);
|
|
2704
2856
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(visibleFrame) - NSHeight(cascadedFrame)") != null);
|
|
@@ -2706,6 +2858,29 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2706
2858
|
}
|
|
2707
2859
|
}
|
|
2708
2860
|
|
|
2861
|
+
test "both mac hosts distinguish restored explicit and default placement" {
|
|
2862
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2863
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "const BOOL restoredPlacement = initialPlacement == 0") != null);
|
|
2864
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "initialPlacement == 2 || (restoredPlacement && restorePolicy == 1)") != null);
|
|
2865
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrameToScreen(NSMakeRect(0, 0, width, height), primaryScreen)") != null);
|
|
2866
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrame(NSMakeRect(x, y, width, height))") != null);
|
|
2867
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "return [NSScreen screens].firstObject ?: [NSScreen mainScreen]") != null);
|
|
2868
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window frameRectForContentRect:restoredContentFrame]") != null);
|
|
2869
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window setFrame:restoredWindowFrame display:NO]") != null);
|
|
2870
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window setFrame:NativeSdkCenterFrameOnScreen(window.frame, primaryScreen) display:NO]") != null);
|
|
2871
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "initialPlacement == 2 && restorePolicy == 0 && !makeMain && referenceWindow") != null);
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
test "both mac hosts preserve valid secondary-display frames" {
|
|
2876
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2877
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "static NSScreen *NativeSdkScreenForFrame(NSRect frame)") != null);
|
|
2878
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSArray<NSScreen *> *screens = [NSScreen screens]") != null);
|
|
2879
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSIntersectionRect(frame, screen.visibleFrame)") != null);
|
|
2880
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrameToScreen(frame, NativeSdkScreenForFrame(frame))") != null);
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2709
2884
|
test "mac explicit focus activates before making the window key" {
|
|
2710
2885
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2711
2886
|
const focus_at = std.mem.indexOf(u8, host_source, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
@@ -2729,6 +2904,23 @@ test "mac dock presence changes policy without activating the app" {
|
|
|
2729
2904
|
}
|
|
2730
2905
|
}
|
|
2731
2906
|
|
|
2907
|
+
test "both mac hosts apply launch dock presence before configuring the app" {
|
|
2908
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2909
|
+
const init_at = std.mem.indexOf(u8, host_source, "dockVisible:(BOOL)dockVisible") orelse return error.TestExpectedEqual;
|
|
2910
|
+
const init_tail = host_source[init_at..];
|
|
2911
|
+
const policy_at = std.mem.indexOf(u8, init_tail, "dockVisible ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory") orelse return error.TestExpectedEqual;
|
|
2912
|
+
const configure_at = std.mem.indexOf(u8, init_tail, "[self configureApplication]") orelse return error.TestExpectedEqual;
|
|
2913
|
+
const create_at = std.mem.indexOf(u8, init_tail, "[self createWindowWithId:1") orelse return error.TestExpectedEqual;
|
|
2914
|
+
try std.testing.expect(policy_at < configure_at);
|
|
2915
|
+
try std.testing.expect(policy_at < create_at);
|
|
2916
|
+
if (std.mem.indexOf(u8, init_tail, "ensureCefInitialized();")) |cef_init_at| {
|
|
2917
|
+
try std.testing.expect(policy_at < cef_init_at);
|
|
2918
|
+
}
|
|
2919
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "int has_web_content, int dock_visible") != null);
|
|
2920
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "dockVisible:(dock_visible != 0)") != null);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2732
2924
|
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
2733
2925
|
const host_source = @embedFile("appkit_host.m");
|
|
2734
2926
|
const helper_at = std.mem.indexOf(
|