@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
|
@@ -35,6 +35,7 @@ const GtkEventKind = enum(c_int) {
|
|
|
35
35
|
audio = 17,
|
|
36
36
|
context_menu_action = 18,
|
|
37
37
|
view_focused = 19,
|
|
38
|
+
notification_command = 20,
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
const GtkEvent = extern struct {
|
|
@@ -112,13 +113,13 @@ const shortcut_modifier_control: u32 = 1 << 2;
|
|
|
112
113
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
113
114
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
114
115
|
|
|
115
|
-
extern fn native_sdk_gtk_create(app_name: [*]const u8, app_name_len: usize, 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, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*GtkHost;
|
|
116
|
+
extern fn native_sdk_gtk_create(app_name: [*]const u8, app_name_len: usize, 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, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*GtkHost;
|
|
116
117
|
extern fn native_sdk_gtk_destroy(host: *GtkHost) void;
|
|
117
118
|
extern fn native_sdk_gtk_run(host: *GtkHost, callback: GtkCallback, context: ?*anyopaque) void;
|
|
118
119
|
extern fn native_sdk_gtk_stop(host: *GtkHost) void;
|
|
119
120
|
extern fn native_sdk_gtk_wake(host: *GtkHost) void;
|
|
120
121
|
extern fn native_sdk_gtk_request_frame(host: *GtkHost) void;
|
|
121
|
-
extern fn native_sdk_gtk_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
|
|
122
|
+
extern fn native_sdk_gtk_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
|
|
122
123
|
extern fn native_sdk_gtk_load_webview(host: *GtkHost, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) void;
|
|
123
124
|
extern fn native_sdk_gtk_load_window_webview(host: *GtkHost, window_id: u64, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) void;
|
|
124
125
|
extern fn native_sdk_gtk_set_bridge_callback(host: *GtkHost, callback: GtkBridgeCallback, context: ?*anyopaque) void;
|
|
@@ -129,7 +130,7 @@ extern fn native_sdk_gtk_emit_window_event(host: *GtkHost, window_id: u64, name:
|
|
|
129
130
|
extern fn native_sdk_gtk_set_security_policy(host: *GtkHost, allowed_origins: [*]const u8, allowed_origins_len: usize, external_urls: [*]const u8, external_urls_len: usize, external_action: c_int) void;
|
|
130
131
|
extern fn native_sdk_gtk_set_menus(host: *GtkHost, 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;
|
|
131
132
|
extern fn native_sdk_gtk_set_shortcuts(host: *GtkHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
132
|
-
extern fn native_sdk_gtk_create_window(host: *GtkHost, 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, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
|
|
133
|
+
extern fn native_sdk_gtk_create_window(host: *GtkHost, 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, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
|
|
133
134
|
extern fn native_sdk_gtk_start_window_drag(host: *GtkHost, window_id: u64) c_int;
|
|
134
135
|
extern fn native_sdk_gtk_set_window_drag_regions(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize, rects: [*]const f64, exclusions: [*]const c_int, count: usize) c_int;
|
|
135
136
|
extern fn native_sdk_gtk_window_chrome(host: *GtkHost, window_id: u64, top: *f64, left: *f64, bottom: *f64, right: *f64, buttons_x: *f64, buttons_y: *f64, buttons_width: *f64, buttons_height: *f64) c_int;
|
|
@@ -156,7 +157,7 @@ extern fn native_sdk_gtk_set_webview_layer(host: *GtkHost, window_id: u64, label
|
|
|
156
157
|
extern fn native_sdk_gtk_close_webview(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize) c_int;
|
|
157
158
|
extern fn native_sdk_gtk_open_external_url(host: *GtkHost, url: [*]const u8, url_len: usize) c_int;
|
|
158
159
|
extern fn native_sdk_gtk_reveal_path(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
159
|
-
extern fn native_sdk_gtk_show_notification(host: *GtkHost, title: [*]const u8, title_len: usize, subtitle: [*]const u8, subtitle_len: usize, body: [*]const u8, body_len: usize) c_int;
|
|
160
|
+
extern fn native_sdk_gtk_show_notification(host: *GtkHost, 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;
|
|
160
161
|
extern fn native_sdk_gtk_add_recent_document(host: *GtkHost, path: [*]const u8, path_len: usize) c_int;
|
|
161
162
|
extern fn native_sdk_gtk_clear_recent_documents(host: *GtkHost) c_int;
|
|
162
163
|
extern fn native_sdk_gtk_credentials_available(host: *GtkHost) c_int;
|
|
@@ -289,7 +290,7 @@ pub const LinuxPlatform = struct {
|
|
|
289
290
|
try refuseUnsupportedMainWindowClosePolicy(window_options);
|
|
290
291
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
291
292
|
const frame = window_options.default_frame;
|
|
292
|
-
const host = native_sdk_gtk_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.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), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
293
|
+
const host = native_sdk_gtk_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.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), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
293
294
|
return .{
|
|
294
295
|
.host = host,
|
|
295
296
|
.web_engine = web_engine,
|
|
@@ -599,6 +600,10 @@ fn gtkCallback(context: ?*anyopaque, event: *const GtkEvent) callconv(.c) void {
|
|
|
599
600
|
.name = event.command_name[0..event.command_name_len],
|
|
600
601
|
.window_id = event.window_id,
|
|
601
602
|
} }),
|
|
603
|
+
.notification_command => state.emit(.{ .notification_command = .{
|
|
604
|
+
.name = event.command_name[0..event.command_name_len],
|
|
605
|
+
.window_id = event.window_id,
|
|
606
|
+
} }),
|
|
602
607
|
.files_dropped => {
|
|
603
608
|
var paths_buffer: [platform_mod.max_drop_paths][]const u8 = undefined;
|
|
604
609
|
const paths = platform_mod.splitDropPaths(event.drop_paths[0..event.drop_paths_len], paths_buffer[0..]);
|
|
@@ -836,11 +841,11 @@ pub fn installHeadlessImageCodec(services: *platform_mod.PlatformServices) void
|
|
|
836
841
|
|
|
837
842
|
/// gdk-pixbuf-backed image decoding (PNG, JPEG, ... — whatever loaders
|
|
838
843
|
/// the system ships) into straight-alpha RGBA8.
|
|
839
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
844
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
840
845
|
_ = context;
|
|
841
846
|
var width: usize = 0;
|
|
842
847
|
var height: usize = 0;
|
|
843
|
-
return switch (native_sdk_gtk_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
|
|
848
|
+
return switch (native_sdk_gtk_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
|
|
844
849
|
1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
|
|
845
850
|
-1 => error.ImageTooLarge,
|
|
846
851
|
else => error.ImageDecodeFailed,
|
|
@@ -856,6 +861,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
|
|
|
856
861
|
};
|
|
857
862
|
}
|
|
858
863
|
|
|
864
|
+
fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
|
|
865
|
+
return switch (placement) {
|
|
866
|
+
.restored => 0,
|
|
867
|
+
.explicit => 1,
|
|
868
|
+
.default => 2,
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
|
|
873
|
+
return switch (policy) {
|
|
874
|
+
.clamp_to_visible_screen => 0,
|
|
875
|
+
.center_on_primary => 1,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
859
879
|
fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
860
880
|
return switch (mode) {
|
|
861
881
|
.immediate => 0,
|
|
@@ -884,7 +904,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
884
904
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
885
905
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
886
906
|
const frame = options.default_frame;
|
|
887
|
-
if (native_sdk_gtk_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), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
907
|
+
if (native_sdk_gtk_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), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
888
908
|
return .{
|
|
889
909
|
.id = options.id,
|
|
890
910
|
.label = options.label,
|
|
@@ -1330,6 +1350,12 @@ fn showNotification(context: ?*anyopaque, options: platform_mod.NotificationOpti
|
|
|
1330
1350
|
options.subtitle.len,
|
|
1331
1351
|
options.body.ptr,
|
|
1332
1352
|
options.body.len,
|
|
1353
|
+
options.id.ptr,
|
|
1354
|
+
options.id.len,
|
|
1355
|
+
options.action_label.ptr,
|
|
1356
|
+
options.action_label.len,
|
|
1357
|
+
options.action_command.ptr,
|
|
1358
|
+
options.action_command.len,
|
|
1333
1359
|
) == 0) return error.UnsupportedService;
|
|
1334
1360
|
}
|
|
1335
1361
|
|
|
@@ -1480,20 +1506,23 @@ fn videoLoadUrl(context: ?*anyopaque, url: []const u8, token: u64, sink: platfor
|
|
|
1480
1506
|
return videoLoad(context, url, token, sink);
|
|
1481
1507
|
}
|
|
1482
1508
|
|
|
1483
|
-
fn createTray(context: ?*anyopaque, options: platform_mod.TrayOptions) anyerror!void {
|
|
1509
|
+
fn createTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, options: platform_mod.TrayOptions) anyerror!void {
|
|
1484
1510
|
_ = context;
|
|
1511
|
+
_ = status_item_id;
|
|
1485
1512
|
_ = options;
|
|
1486
1513
|
return error.UnsupportedService;
|
|
1487
1514
|
}
|
|
1488
1515
|
|
|
1489
|
-
fn updateTrayMenu(context: ?*anyopaque, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1516
|
+
fn updateTrayMenu(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId, items: []const platform_mod.TrayMenuItem) anyerror!void {
|
|
1490
1517
|
_ = context;
|
|
1518
|
+
_ = status_item_id;
|
|
1491
1519
|
_ = items;
|
|
1492
1520
|
return error.UnsupportedService;
|
|
1493
1521
|
}
|
|
1494
1522
|
|
|
1495
|
-
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
1523
|
+
fn removeTray(context: ?*anyopaque, status_item_id: platform_mod.StatusItemId) anyerror!void {
|
|
1496
1524
|
_ = context;
|
|
1525
|
+
_ = status_item_id;
|
|
1497
1526
|
return error.UnsupportedService;
|
|
1498
1527
|
}
|
|
1499
1528
|
|
|
@@ -1878,6 +1907,57 @@ test "linux platform module exports type" {
|
|
|
1878
1907
|
_ = LinuxPlatform;
|
|
1879
1908
|
}
|
|
1880
1909
|
|
|
1910
|
+
test "linux message dialogs construct alerts with a non-null format string" {
|
|
1911
|
+
// gtk_alert_dialog_new takes a required printf-style format string.
|
|
1912
|
+
// The host sets the real message below, but NULL still makes GTK
|
|
1913
|
+
// dereference an invalid format pointer during construction.
|
|
1914
|
+
const host_source = @embedFile("gtk_host.c");
|
|
1915
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1916
|
+
u8,
|
|
1917
|
+
host_source,
|
|
1918
|
+
"GtkAlertDialog *dialog = gtk_alert_dialog_new(\"\");",
|
|
1919
|
+
) != null);
|
|
1920
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1921
|
+
u8,
|
|
1922
|
+
host_source,
|
|
1923
|
+
"gtk_alert_dialog_new(NULL)",
|
|
1924
|
+
) == null);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
test "linux notification actions use process-scoped opaque tokens" {
|
|
1928
|
+
const host_source = @embedFile("gtk_host.c");
|
|
1929
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1930
|
+
u8,
|
|
1931
|
+
host_source,
|
|
1932
|
+
"char *action_token = native_sdk_random_notification_action_token();",
|
|
1933
|
+
) != null);
|
|
1934
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1935
|
+
u8,
|
|
1936
|
+
host_source,
|
|
1937
|
+
"open(\"/dev/urandom\", O_RDONLY | O_CLOEXEC)",
|
|
1938
|
+
) != null);
|
|
1939
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1940
|
+
u8,
|
|
1941
|
+
host_source,
|
|
1942
|
+
"g_variant_new_string(action_token)",
|
|
1943
|
+
) != null);
|
|
1944
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1945
|
+
u8,
|
|
1946
|
+
host_source,
|
|
1947
|
+
"native_sdk_take_notification_action_command(host, token, token_len)",
|
|
1948
|
+
) != null);
|
|
1949
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1950
|
+
u8,
|
|
1951
|
+
host_source,
|
|
1952
|
+
"g_hash_table_remove(host->notification_actions, token);",
|
|
1953
|
+
) != null);
|
|
1954
|
+
try std.testing.expect(std.mem.indexOf(
|
|
1955
|
+
u8,
|
|
1956
|
+
host_source,
|
|
1957
|
+
"g_variant_new_string(command_copy)",
|
|
1958
|
+
) == null);
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1881
1961
|
test "linux transparent windows clear the main webview background" {
|
|
1882
1962
|
const host_source = @embedFile("gtk_host.c");
|
|
1883
1963
|
const ensure_at = std.mem.indexOf(
|
|
@@ -35,6 +35,7 @@ typedef enum {
|
|
|
35
35
|
NATIVE_SDK_APPKIT_EVENT_VIDEO = 21,
|
|
36
36
|
NATIVE_SDK_APPKIT_EVENT_VIEW_FOCUSED = 22,
|
|
37
37
|
NATIVE_SDK_APPKIT_EVENT_TRAY_COMMAND = 23,
|
|
38
|
+
NATIVE_SDK_APPKIT_EVENT_NOTIFICATION_COMMAND = 24,
|
|
38
39
|
} native_sdk_appkit_event_kind_t;
|
|
39
40
|
|
|
40
41
|
/* Audio player reports (EVENT_AUDIO payloads). LOADED acknowledges a
|
|
@@ -160,6 +161,7 @@ typedef enum {
|
|
|
160
161
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_SLIDER = 18,
|
|
161
162
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_PROGRESSBAR = 19,
|
|
162
163
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIO = 20,
|
|
164
|
+
NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIOGROUP = 21,
|
|
163
165
|
} native_sdk_appkit_widget_role_t;
|
|
164
166
|
|
|
165
167
|
enum {
|
|
@@ -206,6 +208,7 @@ typedef enum {
|
|
|
206
208
|
|
|
207
209
|
typedef struct {
|
|
208
210
|
uint64_t id;
|
|
211
|
+
uint64_t parent_id;
|
|
209
212
|
int role;
|
|
210
213
|
const char *label;
|
|
211
214
|
size_t label_len;
|
|
@@ -270,6 +273,8 @@ typedef struct {
|
|
|
270
273
|
uint32_t shortcut_modifiers;
|
|
271
274
|
const char *command_name;
|
|
272
275
|
size_t command_name_len;
|
|
276
|
+
/* TRAY_COMMAND: stable owner id for the status item that emitted it. */
|
|
277
|
+
uint32_t status_item_id;
|
|
273
278
|
const char *view_label;
|
|
274
279
|
size_t view_label_len;
|
|
275
280
|
const char *key_text;
|
|
@@ -375,8 +380,9 @@ typedef void (*native_sdk_appkit_bridge_callback_t)(void *context, uint64_t wind
|
|
|
375
380
|
// About panel, which also shows version and about_description when
|
|
376
381
|
// non-empty. has_web_content declares whether the app hosts a webview;
|
|
377
382
|
// web-only default menu items (Reload, Toggle Web Inspector, Undo/Redo)
|
|
378
|
-
// exist only when it is set.
|
|
379
|
-
|
|
383
|
+
// exist only when it is set. dock_visible selects Regular (nonzero) or
|
|
384
|
+
// Accessory (zero) before application configuration and window creation.
|
|
385
|
+
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
380
386
|
void native_sdk_appkit_destroy(native_sdk_appkit_host_t *host);
|
|
381
387
|
// Adopt pre-rendered straight-alpha RGBA8 pixels as the Dock icon (and
|
|
382
388
|
// the About panel copy). The pixels are copied before return, so the
|
|
@@ -415,7 +421,7 @@ void native_sdk_appkit_emit_window_event(native_sdk_appkit_host_t *host, uint64_
|
|
|
415
421
|
void native_sdk_appkit_set_security_policy(native_sdk_appkit_host_t *host, const char *allowed_origins, size_t allowed_origins_len, const char *external_urls, size_t external_urls_len, int external_action);
|
|
416
422
|
void native_sdk_appkit_set_menus(native_sdk_appkit_host_t *host, const char *const *menu_titles, const size_t *menu_title_lens, size_t menu_count, const uint32_t *item_menu_indices, const char *const *item_labels, const size_t *item_label_lens, const char *const *item_commands, const size_t *item_command_lens, const char *const *item_keys, const size_t *item_key_lens, const uint32_t *item_modifiers, const int *item_separators, const int *item_enabled, const int *item_checked, size_t item_count);
|
|
417
423
|
void native_sdk_appkit_set_shortcuts(native_sdk_appkit_host_t *host, const char *const *ids, const size_t *id_lens, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
|
|
418
|
-
int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
424
|
+
int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
419
425
|
// Content min-size floor for a created window (NSWindow contentMinSize):
|
|
420
426
|
// the user's resize stops at the floor. Values <= 0 leave that axis at
|
|
421
427
|
// AppKit's default minimum. Returns 0 when the window id is unknown.
|
|
@@ -640,11 +646,11 @@ int native_sdk_appkit_unregister_font(uint64_t font_id, uint64_t token);
|
|
|
640
646
|
* and -1 when the decoded pixels do not fit `pixels_len` (`out_width`/
|
|
641
647
|
* `out_height` still report the decoded dimensions). It retains no AppKit
|
|
642
648
|
* state, needs no host, and is main-thread independent. */
|
|
643
|
-
int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height);
|
|
649
|
+
int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t max_pixels, size_t *out_width, size_t *out_height);
|
|
644
650
|
void native_sdk_appkit_clipboard_write(native_sdk_appkit_host_t *host, const char *text, size_t text_len);
|
|
645
651
|
size_t native_sdk_appkit_clipboard_read_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, char *buffer, size_t buffer_len);
|
|
646
652
|
int native_sdk_appkit_clipboard_write_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, const char *bytes, size_t bytes_len);
|
|
647
|
-
int native_sdk_appkit_show_notification(native_sdk_appkit_host_t *host, const char *title, size_t title_len, const char *subtitle, size_t subtitle_len, const char *body, size_t body_len);
|
|
653
|
+
int native_sdk_appkit_show_notification(native_sdk_appkit_host_t *host, const char *title, size_t title_len, const char *subtitle, size_t subtitle_len, const char *body, size_t body_len, const char *notification_id, size_t notification_id_len, const char *action_label, size_t action_label_len, const char *action_command, size_t action_command_len);
|
|
648
654
|
int native_sdk_appkit_open_external_url(native_sdk_appkit_host_t *host, const char *url, size_t url_len);
|
|
649
655
|
int native_sdk_appkit_reveal_path(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
|
|
650
656
|
int native_sdk_appkit_add_recent_document(native_sdk_appkit_host_t *host, const char *path, size_t path_len);
|
|
@@ -697,7 +703,7 @@ typedef struct {
|
|
|
697
703
|
size_t tertiary_button_len;
|
|
698
704
|
} native_sdk_appkit_message_dialog_opts_t;
|
|
699
705
|
|
|
700
|
-
typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t item_id);
|
|
706
|
+
typedef void (*native_sdk_appkit_tray_callback_t)(void *context, uint32_t status_item_id, uint32_t item_id);
|
|
701
707
|
|
|
702
708
|
/* One native scroll driver's desired state (see PlatformServices
|
|
703
709
|
* set_gpu_surface_scroll_drivers_fn). Frame coordinates are view-local
|
|
@@ -766,15 +772,16 @@ int native_sdk_appkit_show_context_menu(native_sdk_appkit_host_t *host, uint64_t
|
|
|
766
772
|
native_sdk_appkit_open_dialog_result_t native_sdk_appkit_show_open_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_open_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
767
773
|
size_t native_sdk_appkit_show_save_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_save_dialog_opts_t *opts, char *buffer, size_t buffer_len);
|
|
768
774
|
int native_sdk_appkit_show_message_dialog(native_sdk_appkit_host_t *host, const native_sdk_appkit_message_dialog_opts_t *opts);
|
|
769
|
-
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, 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);
|
|
770
|
-
void
|
|
775
|
+
void native_sdk_appkit_create_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *title, size_t title_len, const char *tooltip, size_t tooltip_len, int visible, double width, int tone, double icon_opacity, int monospaced, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
776
|
+
void native_sdk_appkit_update_tray_shell(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *icon_path, size_t icon_path_len, const char *tooltip, size_t tooltip_len, int visible, const char *activation_command, size_t activation_command_len, const char *alternate_activation_command, size_t alternate_activation_command_len, const char *open_command, size_t open_command_len);
|
|
777
|
+
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);
|
|
771
778
|
/* Retitle the live status item's button without re-creating it (create
|
|
772
779
|
* would flicker and reshuffle the menu bar). Empty title falls back to
|
|
773
780
|
* the icon-only square well, or the app-name initial when there is no
|
|
774
781
|
* icon either — the same fallbacks as create. */
|
|
775
|
-
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, const char *title, size_t title_len);
|
|
776
|
-
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced);
|
|
777
|
-
void native_sdk_appkit_remove_tray(native_sdk_appkit_host_t *host);
|
|
782
|
+
void native_sdk_appkit_update_tray_title(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len);
|
|
783
|
+
void native_sdk_appkit_update_tray_presentation(native_sdk_appkit_host_t *host, uint32_t status_item_id, const char *title, size_t title_len, double width, int tone, double icon_opacity, int monospaced);
|
|
784
|
+
void native_sdk_appkit_remove_tray(native_sdk_appkit_host_t *host, uint32_t status_item_id);
|
|
778
785
|
void native_sdk_appkit_set_tray_callback(native_sdk_appkit_host_t *host, native_sdk_appkit_tray_callback_t callback, void *context);
|
|
779
786
|
|
|
780
787
|
#ifdef __cplusplus
|