@native-sdk/cli 0.8.3 → 0.9.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/build/app.zig +905 -61
- package/build.zig +674 -373
- package/build.zig.zon +1 -0
- package/native-sdk.d.ts +6 -0
- package/package.json +12 -11
- package/packages/core/compile-surface/core.ts +455 -3
- package/packages/core/package-lock.json +11 -11
- package/packages/core/package.json +2 -2
- package/packages/core/scripts/compiler_typecheck.mjs +116 -15
- package/packages/core/scripts/gen_service_surface.mjs +268 -0
- package/packages/core/scripts/npm_static_spike.mjs +64 -0
- package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
- package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
- package/packages/core/scripts/stage_external_core.mjs +9 -1
- package/packages/core/scripts/stage_external_services.mjs +172 -0
- package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
- package/packages/core/scripts/vendor_service_packages.mjs +189 -0
- package/packages/core/sdk/core.d.ts +214 -2
- package/packages/core/sdk/core.ts +715 -42
- package/packages/core/sdk/events.d.ts +50 -0
- package/packages/core/sdk/events.ts +75 -0
- package/packages/core/src/checker.ts +528 -15
- package/packages/core/src/cli.ts +143 -3
- package/packages/core/src/contract.ts +26 -5
- package/packages/core/src/devhost.ts +1849 -18
- package/packages/core/src/devhost_journal.mjs +181 -0
- package/packages/core/src/devhost_resolver.mjs +17 -1
- package/packages/core/src/devhost_service_worker.mjs +90 -0
- package/packages/core/src/diagnostics.ts +84 -18
- package/packages/core/src/frontend.ts +204 -34
- package/packages/core/src/modules.ts +129 -80
- package/packages/core/src/service_contract.ts +597 -0
- package/packages/core/src/sqlite_cli.ts +93 -0
- package/packages/core/src/sqlite_codegen.ts +806 -0
- package/packages/core/src/sqlite_runtime_policy.ts +364 -0
- package/packages/core/src/typed_ast.ts +36 -8
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +3 -2
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +55 -8
- package/skill-data/ts-core/SKILL.md +92 -40
- package/skill-data/ts-services/SKILL.md +126 -0
- package/skill-data/ts-services/references/service-surface.md +603 -0
- package/skill-data/zig/SKILL.md +1 -1
- package/skills/native-sdk/SKILL.md +1 -1
- package/src/app_runner/no_migrations.zig +3 -0
- package/src/app_runner/no_services.zig +20 -0
- package/src/app_runner/root.zig +104 -4
- package/src/app_runner/ts_core_main.zig +268 -4
- package/src/automation/snapshot.zig +23 -5
- package/src/embed/app_exports.zig +11 -1
- package/src/embed/c_api.zig +48 -2
- package/src/embed/conversions.zig +4 -5
- package/src/embed/host.zig +115 -1
- package/src/embed/root.zig +7 -0
- package/src/embed/tests.zig +213 -0
- package/src/embed/types.zig +51 -0
- package/src/embed/ui_host.zig +121 -5
- package/src/platform/android/NativeSdkActivity.java +131 -0
- package/src/platform/android/android_host.c +182 -1
- package/src/platform/android/native_sdk_app.h +17 -0
- package/src/platform/ios/native_sdk_app.h +17 -0
- package/src/platform/ios/uikit_host.m +115 -0
- package/src/platform/linux/cef_host.cpp +1 -1
- package/src/platform/linux/gtk_host.c +89 -17
- package/src/platform/linux/gtk_host.h +3 -0
- package/src/platform/linux/root.zig +41 -18
- package/src/platform/macos/appkit_host.h +26 -3
- package/src/platform/macos/appkit_host.m +1051 -129
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +270 -36
- package/src/platform/macos/root.zig +312 -34
- package/src/platform/null_platform.zig +281 -19
- package/src/platform/null_platform_tests.zig +74 -0
- package/src/platform/root.zig +16 -0
- package/src/platform/types.zig +279 -15
- package/src/platform/windows/root.zig +243 -21
- package/src/platform/windows/webview2_host.cpp +464 -46
- package/src/primitives/app_manifest/comptime_scene.zig +2 -0
- package/src/primitives/app_manifest/root.zig +4 -0
- package/src/primitives/app_manifest/tests.zig +3 -0
- package/src/primitives/app_manifest/types.zig +34 -0
- package/src/primitives/app_manifest/validation.zig +19 -1
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +296 -114
- package/src/primitives/canvas/widget_runtime_tests.zig +133 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +29 -5
- package/src/root.zig +56 -0
- package/src/runtime/api.zig +11 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/bridge_permission_tests.zig +23 -2
- package/src/runtime/bridge_responses.zig +3 -1
- package/src/runtime/canvas_frame.zig +31 -13
- package/src/runtime/canvas_frame_animation_tests.zig +4 -0
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +6 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/clock.zig +13 -1
- package/src/runtime/core.zig +133 -1
- package/src/runtime/credentials_store.zig +115 -0
- package/src/runtime/effects.zig +2568 -75
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/effects_credentials_tests.zig +332 -0
- package/src/runtime/effects_host_tests.zig +208 -1
- package/src/runtime/effects_relational_tests.zig +314 -0
- package/src/runtime/effects_store_tests.zig +211 -0
- package/src/runtime/flow.zig +14 -1
- package/src/runtime/gpu_surface_events.zig +6 -1
- package/src/runtime/native_command_event_tests.zig +42 -0
- package/src/runtime/persist_store.zig +666 -0
- package/src/runtime/record_store.zig +788 -0
- package/src/runtime/relational_store.zig +854 -0
- package/src/runtime/root.zig +52 -0
- package/src/runtime/runtime_event_tests.zig +70 -0
- package/src/runtime/service_host.zig +711 -0
- package/src/runtime/service_pool.zig +1314 -0
- package/src/runtime/session_blobs.zig +1 -1
- package/src/runtime/session_journal.zig +102 -0
- package/src/runtime/session_record.zig +177 -0
- package/src/runtime/session_replay.zig +109 -4
- package/src/runtime/shell_layout.zig +1 -0
- package/src/runtime/shell_layout_tests.zig +120 -0
- package/src/runtime/sqlite_engine.zig +474 -0
- package/src/runtime/state.zig +6 -0
- package/src/runtime/system_services.zig +49 -10
- package/src/runtime/tests.zig +5 -0
- package/src/runtime/ts_core_host.zig +1189 -118
- package/src/runtime/ts_core_host_tests.zig +638 -11
- package/src/runtime/ts_ui_app.zig +537 -1
- package/src/runtime/ui_app.zig +160 -19
- package/src/runtime/ui_app_tests.zig +203 -5
- package/src/runtime/validation.zig +22 -0
- package/src/runtime/view.zig +11 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/runtime/window_storage.zig +1 -0
- package/src/runtime/window_view_runtime.zig +2 -3
- package/src/runtime/window_views.zig +19 -0
- package/src/tooling/android.zig +21 -16
- package/src/tooling/db.zig +160 -0
- package/src/tooling/ios.zig +7 -1
- package/src/tooling/manifest.zig +1248 -2
- package/src/tooling/package.zig +953 -6
- package/src/tooling/raw_manifest.zig +65 -0
- package/src/tooling/root.zig +1 -0
- package/src/tooling/templates.zig +216 -4
- package/src/tooling/ts_core.zig +283 -17
- package/src/tooling/verbs.zig +7 -0
- package/third_party/sqlite/README.md +13 -0
- package/third_party/sqlite/sqlite3.c +269649 -0
- package/third_party/sqlite/sqlite3.h +14349 -0
- package/tools/corewire/core_abi.zig +14 -2
- package/tools/corewire/emit.zig +98 -29
- package/tools/corewire/emit_facade.zig +414 -23
- package/tools/corewire/emit_profile.zig +6 -2
- package/tools/corewire/emit_service.zig +924 -0
- package/tools/corewire/main.zig +122 -0
- package/tools/corewire/service_contract.zig +250 -0
- package/tools/corewire/sidecar.zig +26 -15
|
@@ -34,6 +34,7 @@ const max_clipboard_data_bytes = types.max_clipboard_data_bytes;
|
|
|
34
34
|
const max_credential_service_bytes = types.max_credential_service_bytes;
|
|
35
35
|
const max_credential_account_bytes = types.max_credential_account_bytes;
|
|
36
36
|
const max_credential_secret_bytes = types.max_credential_secret_bytes;
|
|
37
|
+
const max_local_time_text_bytes = types.max_local_time_text_bytes;
|
|
37
38
|
const max_tray_items = types.max_tray_items;
|
|
38
39
|
const max_tray_icon_path_bytes = types.max_tray_icon_path_bytes;
|
|
39
40
|
const max_tray_title_bytes = types.max_tray_title_bytes;
|
|
@@ -110,11 +111,14 @@ const MessageDialogOptions = types.MessageDialogOptions;
|
|
|
110
111
|
const NotificationOptions = types.NotificationOptions;
|
|
111
112
|
const CredentialKey = types.CredentialKey;
|
|
112
113
|
const Credential = types.Credential;
|
|
114
|
+
const LocalTimeStyle = types.LocalTimeStyle;
|
|
113
115
|
const TrayItemId = types.TrayItemId;
|
|
114
116
|
const TrayOptions = types.TrayOptions;
|
|
117
|
+
const TrayPresentation = types.TrayPresentation;
|
|
115
118
|
const TrayMenuItem = types.TrayMenuItem;
|
|
116
119
|
const NativeCommandEvent = types.NativeCommandEvent;
|
|
117
120
|
const MenuCommandEvent = types.MenuCommandEvent;
|
|
121
|
+
const TrayCommandEvent = types.TrayCommandEvent;
|
|
118
122
|
const TimerEvent = types.TimerEvent;
|
|
119
123
|
const FileDropEvent = types.FileDropEvent;
|
|
120
124
|
const GpuFrame = types.GpuFrame;
|
|
@@ -282,6 +286,14 @@ pub const NullAudio = struct {
|
|
|
282
286
|
}
|
|
283
287
|
};
|
|
284
288
|
|
|
289
|
+
pub const NullAudioCapture = struct {
|
|
290
|
+
active: bool = false,
|
|
291
|
+
format: types.AudioCaptureFormat = .{},
|
|
292
|
+
sink: types.AudioCaptureSink = .{},
|
|
293
|
+
start_count: usize = 0,
|
|
294
|
+
stop_count: usize = 0,
|
|
295
|
+
};
|
|
296
|
+
|
|
285
297
|
pub const NullPlatform = struct {
|
|
286
298
|
surface_value: Surface = .{},
|
|
287
299
|
web_engine: WebEngine = .system,
|
|
@@ -332,11 +344,13 @@ pub const NullPlatform = struct {
|
|
|
332
344
|
window_always_on_top: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
333
345
|
window_click_through: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
334
346
|
window_activate_on_show: [max_windows]bool = [_]bool{true} ** max_windows,
|
|
347
|
+
window_allows_fullscreen: [max_windows]bool = [_]bool{true} ** max_windows,
|
|
335
348
|
/// Minimize calls per window (`minimize_window_fn`), indexed like
|
|
336
349
|
/// `windows`: the observable seam for app-drawn minimize controls —
|
|
337
350
|
/// the null platform has no Dock to genie into, so the count IS the
|
|
338
351
|
/// behavior tests pin.
|
|
339
352
|
window_minimize_count: [max_windows]u32 = [_]u32{0} ** max_windows,
|
|
353
|
+
window_hide_count: [max_windows]u32 = [_]u32{0} ** max_windows,
|
|
340
354
|
/// Show calls per window (`show_window_fn`), indexed like `windows`
|
|
341
355
|
/// — the counterpart seam (tray "Open", the un-hide verb).
|
|
342
356
|
window_show_count: [max_windows]u32 = [_]u32{0} ** max_windows,
|
|
@@ -383,6 +397,11 @@ pub const NullPlatform = struct {
|
|
|
383
397
|
/// runtime's `showWindow` rollback test uses to assert a refused
|
|
384
398
|
/// show restores hidden and moves no focus.
|
|
385
399
|
fail_next_show_window: bool = false,
|
|
400
|
+
fail_next_hide_window: bool = false,
|
|
401
|
+
dock_visible: bool = true,
|
|
402
|
+
dock_presence_count: u32 = 0,
|
|
403
|
+
launch_at_login_status: types.LaunchAtLoginStatus = .disabled,
|
|
404
|
+
launch_at_login_set_count: u32 = 0,
|
|
386
405
|
/// Captured `WindowOptions.min_width`/`min_height` per created
|
|
387
406
|
/// window — the content min-size floor that must survive to the
|
|
388
407
|
/// create seam (macOS applies it as `contentMinSize`); same
|
|
@@ -455,10 +474,18 @@ pub const NullPlatform = struct {
|
|
|
455
474
|
credential_service_len: usize = 0,
|
|
456
475
|
credential_account: [max_credential_account_bytes]u8 = undefined,
|
|
457
476
|
credential_account_len: usize = 0,
|
|
458
|
-
|
|
459
|
-
|
|
477
|
+
/// Hermetic process-local keychain. Real credential effects use four
|
|
478
|
+
/// worker threads, so the fake must be synchronized too; one old
|
|
479
|
+
/// bridge-era "last secret" buffer silently lost distinct keys.
|
|
480
|
+
credential_mutex: std.atomic.Mutex = .unlocked,
|
|
481
|
+
credential_entries: std.StringHashMapUnmanaged([]u8) = .empty,
|
|
482
|
+
credential_last_secret: ?[]const u8 = null,
|
|
460
483
|
credential_set_count: usize = 0,
|
|
461
484
|
credential_delete_count: usize = 0,
|
|
485
|
+
/// Deterministic local-zone model for tests. Real hosts consult the OS
|
|
486
|
+
/// zone (including DST at the requested instant); the null host uses this
|
|
487
|
+
/// fixed offset so suites can pin exact output without ambient state.
|
|
488
|
+
local_time_offset_minutes: i16 = 0,
|
|
462
489
|
webview_navigate_count: usize = 0,
|
|
463
490
|
tray_icon_path: [max_tray_icon_path_bytes]u8 = undefined,
|
|
464
491
|
tray_icon_path_len: usize = 0,
|
|
@@ -466,6 +493,13 @@ pub const NullPlatform = struct {
|
|
|
466
493
|
tray_title_len: usize = 0,
|
|
467
494
|
tray_tooltip: [max_tray_tooltip_bytes]u8 = undefined,
|
|
468
495
|
tray_tooltip_len: usize = 0,
|
|
496
|
+
tray_activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
497
|
+
tray_activation_command_len: usize = 0,
|
|
498
|
+
tray_alternate_activation_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
499
|
+
tray_alternate_activation_command_len: usize = 0,
|
|
500
|
+
tray_open_command: [max_tray_item_command_bytes]u8 = undefined,
|
|
501
|
+
tray_open_command_len: usize = 0,
|
|
502
|
+
tray_presentation: TrayPresentation = .{},
|
|
469
503
|
tray_items: [max_tray_items]TrayMenuItem = undefined,
|
|
470
504
|
tray_item_count: usize = 0,
|
|
471
505
|
tray_create_count: usize = 0,
|
|
@@ -625,6 +659,9 @@ pub const NullPlatform = struct {
|
|
|
625
659
|
audio_stop_count: usize = 0,
|
|
626
660
|
audio_seek_count: usize = 0,
|
|
627
661
|
audio_volume_count: usize = 0,
|
|
662
|
+
microphone_capture: bool = true,
|
|
663
|
+
system_audio_capture: bool = true,
|
|
664
|
+
audio_captures: [2]NullAudioCapture = [_]NullAudioCapture{.{}} ** 2,
|
|
628
665
|
/// Whether this modeled host has a video decoder. On by default (the
|
|
629
666
|
/// fake below stands in for AVFoundation); tests modelling a staged
|
|
630
667
|
/// host (Windows/Linux today) set it false BEFORE `platform()` so
|
|
@@ -660,9 +697,8 @@ pub const NullPlatform = struct {
|
|
|
660
697
|
/// embed host drain it on their own thread via `takeWake` and then
|
|
661
698
|
/// dispatch the `.wake` platform event themselves.
|
|
662
699
|
wake_count: std.atomic.Value(usize) = std.atomic.Value(usize).init(0),
|
|
663
|
-
/// Latched when
|
|
664
|
-
/// channel
|
|
665
|
-
/// `PlatformServices.note_channel_wake_abandoned_fn`): the stale call
|
|
700
|
+
/// Latched when effects teardown abandons an in-flight platform call
|
|
701
|
+
/// (a channel wake or blocking credential operation): the stale call
|
|
666
702
|
/// still holds this platform as its context, so `deinit` must skip
|
|
667
703
|
/// destruction and leak the host, process-lived — the reference model
|
|
668
704
|
/// of the real hosts' destroy gate, and the seam channel teardown
|
|
@@ -777,9 +813,21 @@ pub const NullPlatform = struct {
|
|
|
777
813
|
/// which is exactly what makes the gate observable in tests.
|
|
778
814
|
pub fn deinit(self: *NullPlatform) void {
|
|
779
815
|
if (self.channel_wake_abandoned.load(.seq_cst)) {
|
|
780
|
-
std.debug.print("null platform teardown: an abandoned
|
|
816
|
+
std.debug.print("null platform teardown: an abandoned platform call may still enter this host; skipping destruction and leaking it, process-lived, so the stale call stays safe\n", .{});
|
|
781
817
|
return;
|
|
782
818
|
}
|
|
819
|
+
if (self.destroyed) return;
|
|
820
|
+
self.lockCredentials();
|
|
821
|
+
var credentials = self.credential_entries.iterator();
|
|
822
|
+
while (credentials.next()) |entry| {
|
|
823
|
+
@memset(entry.value_ptr.*, 0);
|
|
824
|
+
std.heap.page_allocator.free(entry.value_ptr.*);
|
|
825
|
+
std.heap.page_allocator.free(entry.key_ptr.*);
|
|
826
|
+
}
|
|
827
|
+
self.credential_entries.deinit(std.heap.page_allocator);
|
|
828
|
+
self.credential_entries = .empty;
|
|
829
|
+
self.credential_last_secret = null;
|
|
830
|
+
self.credential_mutex.unlock();
|
|
783
831
|
self.destroyed = true;
|
|
784
832
|
}
|
|
785
833
|
|
|
@@ -805,7 +853,11 @@ pub const NullPlatform = struct {
|
|
|
805
853
|
.focus_window_fn = focusWindow,
|
|
806
854
|
.close_window_fn = closeWindow,
|
|
807
855
|
.minimize_window_fn = minimizeWindow,
|
|
856
|
+
.hide_window_fn = hideWindow,
|
|
808
857
|
.show_window_fn = showWindow,
|
|
858
|
+
.set_dock_presence_fn = setDockPresence,
|
|
859
|
+
.launch_at_login_status_fn = launchAtLoginStatus,
|
|
860
|
+
.set_launch_at_login_fn = setLaunchAtLogin,
|
|
809
861
|
.quit_app_fn = quitApp,
|
|
810
862
|
.start_window_drag_fn = startWindowDrag,
|
|
811
863
|
.window_chrome_fn = windowChrome,
|
|
@@ -830,9 +882,12 @@ pub const NullPlatform = struct {
|
|
|
830
882
|
.set_credential_fn = setCredential,
|
|
831
883
|
.get_credential_fn = getCredential,
|
|
832
884
|
.delete_credential_fn = deleteCredential,
|
|
885
|
+
.note_blocking_call_abandoned_fn = noteChannelWakeAbandoned,
|
|
886
|
+
.format_local_time_fn = formatLocalTime,
|
|
833
887
|
.create_tray_fn = createTray,
|
|
834
888
|
.update_tray_menu_fn = updateTrayMenu,
|
|
835
889
|
.update_tray_title_fn = updateTrayTitle,
|
|
890
|
+
.update_tray_presentation_fn = updateTrayPresentation,
|
|
836
891
|
.remove_tray_fn = removeTray,
|
|
837
892
|
.open_external_url_fn = openExternalUrl,
|
|
838
893
|
.reveal_path_fn = revealPath,
|
|
@@ -851,6 +906,8 @@ pub const NullPlatform = struct {
|
|
|
851
906
|
.audio_stop_fn = if (self.audio_playback) audioStop else null,
|
|
852
907
|
.audio_seek_fn = if (self.audio_playback) audioSeek else null,
|
|
853
908
|
.audio_set_volume_fn = if (self.audio_playback) audioSetVolume else null,
|
|
909
|
+
.audio_capture_start_fn = if (self.microphone_capture or self.system_audio_capture) audioCaptureStart else null,
|
|
910
|
+
.audio_capture_stop_fn = if (self.microphone_capture or self.system_audio_capture) audioCaptureStop else null,
|
|
854
911
|
.video_load_fn = if (self.video_playback) videoLoad else null,
|
|
855
912
|
.video_load_url_fn = if (self.video_playback) videoLoadUrl else null,
|
|
856
913
|
.video_play_fn = if (self.video_playback) videoPlay else null,
|
|
@@ -915,6 +972,8 @@ pub const NullPlatform = struct {
|
|
|
915
972
|
.audio_playback => self.audio_playback,
|
|
916
973
|
.audio_streaming => self.audio_playback and self.audio_streaming,
|
|
917
974
|
.audio_spectrum => self.audio_playback and self.audio_spectrum,
|
|
975
|
+
.microphone_capture => self.microphone_capture,
|
|
976
|
+
.system_audio_capture => self.system_audio_capture,
|
|
918
977
|
.video_playback => self.video_playback,
|
|
919
978
|
};
|
|
920
979
|
}
|
|
@@ -942,6 +1001,7 @@ pub const NullPlatform = struct {
|
|
|
942
1001
|
.scale_factor = self.surface_value.scale_factor,
|
|
943
1002
|
.open = true,
|
|
944
1003
|
.focused = index == 0 and window.activate_on_show and window.show == .immediate,
|
|
1004
|
+
.hidden = window.show == .hidden,
|
|
945
1005
|
} });
|
|
946
1006
|
}
|
|
947
1007
|
var frame: u32 = 0;
|
|
@@ -1053,6 +1113,7 @@ pub const NullPlatform = struct {
|
|
|
1053
1113
|
.scale_factor = self.surface_value.scale_factor,
|
|
1054
1114
|
.open = true,
|
|
1055
1115
|
.focused = focused,
|
|
1116
|
+
.hidden = options.show == .hidden,
|
|
1056
1117
|
};
|
|
1057
1118
|
self.windows[self.window_count] = info;
|
|
1058
1119
|
self.window_resizable[self.window_count] = options.resizable;
|
|
@@ -1061,6 +1122,7 @@ pub const NullPlatform = struct {
|
|
|
1061
1122
|
self.window_always_on_top[self.window_count] = options.always_on_top;
|
|
1062
1123
|
self.window_click_through[self.window_count] = options.click_through;
|
|
1063
1124
|
self.window_activate_on_show[self.window_count] = options.activate_on_show;
|
|
1125
|
+
self.window_allows_fullscreen[self.window_count] = options.allows_fullscreen;
|
|
1064
1126
|
self.window_show[self.window_count] = options.show;
|
|
1065
1127
|
self.window_close_policy[self.window_count] = options.close_policy;
|
|
1066
1128
|
self.window_min_width[self.window_count] = options.min_width;
|
|
@@ -1089,7 +1151,10 @@ pub const NullPlatform = struct {
|
|
|
1089
1151
|
self.show_op_seq += 1;
|
|
1090
1152
|
self.window_first_present_seq[index] = self.show_op_seq;
|
|
1091
1153
|
}
|
|
1092
|
-
if (!self.
|
|
1154
|
+
if (!self.windows[index].hidden and
|
|
1155
|
+
!self.window_visible[index] and
|
|
1156
|
+
self.window_show[index] == .on_first_present)
|
|
1157
|
+
{
|
|
1093
1158
|
self.window_visible[index] = true;
|
|
1094
1159
|
self.show_op_seq += 1;
|
|
1095
1160
|
self.window_shown_seq[index] = self.show_op_seq;
|
|
@@ -1136,6 +1201,7 @@ pub const NullPlatform = struct {
|
|
|
1136
1201
|
}
|
|
1137
1202
|
// An explicit focus shows a still-deferred window (the macOS
|
|
1138
1203
|
// host's makeKeyAndOrderFront override of present-before-show).
|
|
1204
|
+
self.windows[focused_index].hidden = false;
|
|
1139
1205
|
if (!self.window_visible[focused_index]) {
|
|
1140
1206
|
self.window_visible[focused_index] = true;
|
|
1141
1207
|
self.show_op_seq += 1;
|
|
@@ -1205,6 +1271,37 @@ pub const NullPlatform = struct {
|
|
|
1205
1271
|
self.window_show_count[index] += 1;
|
|
1206
1272
|
}
|
|
1207
1273
|
|
|
1274
|
+
fn hideWindow(context: ?*anyopaque, window_id: WindowId) anyerror!void {
|
|
1275
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1276
|
+
if (self.fail_next_hide_window) {
|
|
1277
|
+
self.fail_next_hide_window = false;
|
|
1278
|
+
return error.HideFailed;
|
|
1279
|
+
}
|
|
1280
|
+
const index = self.findWindowIndex(window_id) orelse return error.WindowNotFound;
|
|
1281
|
+
self.windows[index].hidden = true;
|
|
1282
|
+
self.windows[index].focused = false;
|
|
1283
|
+
self.window_visible[index] = false;
|
|
1284
|
+
self.window_hide_count[index] += 1;
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
fn setDockPresence(context: ?*anyopaque, visible: bool) anyerror!void {
|
|
1288
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1289
|
+
self.dock_visible = visible;
|
|
1290
|
+
self.dock_presence_count += 1;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
fn launchAtLoginStatus(context: ?*anyopaque) anyerror!types.LaunchAtLoginStatus {
|
|
1294
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1295
|
+
return self.launch_at_login_status;
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
fn setLaunchAtLogin(context: ?*anyopaque, enabled: bool) anyerror!types.LaunchAtLoginStatus {
|
|
1299
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1300
|
+
self.launch_at_login_set_count += 1;
|
|
1301
|
+
self.launch_at_login_status = if (enabled) .enabled else .disabled;
|
|
1302
|
+
return self.launch_at_login_status;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1208
1305
|
fn quitApp(context: ?*anyopaque) anyerror!void {
|
|
1209
1306
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1210
1307
|
self.quit_request_count += 1;
|
|
@@ -1450,40 +1547,131 @@ pub const NullPlatform = struct {
|
|
|
1450
1547
|
self.notification_count += 1;
|
|
1451
1548
|
}
|
|
1452
1549
|
|
|
1550
|
+
const max_credential_identity_bytes = max_credential_service_bytes + 1 + max_credential_account_bytes;
|
|
1551
|
+
|
|
1552
|
+
fn lockCredentials(self: *NullPlatform) void {
|
|
1553
|
+
while (!self.credential_mutex.tryLock()) std.atomic.spinLoopHint();
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
fn credentialIdentity(buffer: *[max_credential_identity_bytes]u8, key: CredentialKey) anyerror![]const u8 {
|
|
1557
|
+
if (key.service.len == 0 or key.service.len > max_credential_service_bytes or
|
|
1558
|
+
key.account.len == 0 or key.account.len > max_credential_account_bytes)
|
|
1559
|
+
{
|
|
1560
|
+
return error.CredentialFieldTooLarge;
|
|
1561
|
+
}
|
|
1562
|
+
@memcpy(buffer[0..key.service.len], key.service);
|
|
1563
|
+
buffer[key.service.len] = 0;
|
|
1564
|
+
@memcpy(buffer[key.service.len + 1 ..][0..key.account.len], key.account);
|
|
1565
|
+
return buffer[0 .. key.service.len + 1 + key.account.len];
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1453
1568
|
fn setCredential(context: ?*anyopaque, credential: Credential) anyerror!void {
|
|
1454
1569
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1570
|
+
if (credential.secret.len > max_credential_secret_bytes) return error.CredentialFieldTooLarge;
|
|
1571
|
+
var identity_storage: [max_credential_identity_bytes]u8 = undefined;
|
|
1572
|
+
const identity = try credentialIdentity(&identity_storage, .{
|
|
1573
|
+
.service = credential.service,
|
|
1574
|
+
.account = credential.account,
|
|
1575
|
+
});
|
|
1576
|
+
|
|
1577
|
+
self.lockCredentials();
|
|
1578
|
+
defer self.credential_mutex.unlock();
|
|
1579
|
+
const secret = try std.heap.page_allocator.dupe(u8, credential.secret);
|
|
1580
|
+
errdefer std.heap.page_allocator.free(secret);
|
|
1581
|
+
if (self.credential_entries.getPtr(identity)) |existing| {
|
|
1582
|
+
@memset(existing.*, 0);
|
|
1583
|
+
std.heap.page_allocator.free(existing.*);
|
|
1584
|
+
existing.* = secret;
|
|
1585
|
+
} else {
|
|
1586
|
+
const owned_identity = try std.heap.page_allocator.dupe(u8, identity);
|
|
1587
|
+
errdefer std.heap.page_allocator.free(owned_identity);
|
|
1588
|
+
try self.credential_entries.put(std.heap.page_allocator, owned_identity, secret);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1455
1591
|
self.credential_service = undefined;
|
|
1456
1592
|
self.credential_account = undefined;
|
|
1457
|
-
self.
|
|
1458
|
-
|
|
1459
|
-
self.
|
|
1460
|
-
self.
|
|
1593
|
+
@memcpy(self.credential_service[0..credential.service.len], credential.service);
|
|
1594
|
+
@memcpy(self.credential_account[0..credential.account.len], credential.account);
|
|
1595
|
+
self.credential_service_len = credential.service.len;
|
|
1596
|
+
self.credential_account_len = credential.account.len;
|
|
1597
|
+
self.credential_last_secret = secret;
|
|
1461
1598
|
self.credential_set_count += 1;
|
|
1462
1599
|
}
|
|
1463
1600
|
|
|
1464
1601
|
fn getCredential(context: ?*anyopaque, key: CredentialKey, buffer: []u8) anyerror![]const u8 {
|
|
1465
1602
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1603
|
+
var identity_storage: [max_credential_identity_bytes]u8 = undefined;
|
|
1604
|
+
const identity = try credentialIdentity(&identity_storage, key);
|
|
1605
|
+
self.lockCredentials();
|
|
1606
|
+
defer self.credential_mutex.unlock();
|
|
1607
|
+
const secret = self.credential_entries.get(identity) orelse return error.CredentialNotFound;
|
|
1608
|
+
return try copyInto(buffer, secret);
|
|
1469
1609
|
}
|
|
1470
1610
|
|
|
1471
1611
|
fn deleteCredential(context: ?*anyopaque, key: CredentialKey) anyerror!void {
|
|
1472
1612
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
self.
|
|
1613
|
+
var identity_storage: [max_credential_identity_bytes]u8 = undefined;
|
|
1614
|
+
const identity = try credentialIdentity(&identity_storage, key);
|
|
1615
|
+
self.lockCredentials();
|
|
1616
|
+
defer self.credential_mutex.unlock();
|
|
1617
|
+
const removed = self.credential_entries.fetchRemove(identity) orelse return error.CredentialNotFound;
|
|
1618
|
+
if (self.credential_last_secret) |last| {
|
|
1619
|
+
if (last.ptr == removed.value.ptr) self.credential_last_secret = null;
|
|
1620
|
+
}
|
|
1621
|
+
@memset(removed.value, 0);
|
|
1622
|
+
std.heap.page_allocator.free(removed.value);
|
|
1623
|
+
std.heap.page_allocator.free(removed.key);
|
|
1476
1624
|
self.credential_delete_count += 1;
|
|
1477
1625
|
}
|
|
1478
1626
|
|
|
1627
|
+
fn formatLocalTime(context: ?*anyopaque, timestamp_ms: i64, style: LocalTimeStyle, buffer: []u8) anyerror![]const u8 {
|
|
1628
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1629
|
+
const seconds = @divFloor(timestamp_ms, 1000) + @as(i64, self.local_time_offset_minutes) * 60;
|
|
1630
|
+
const days = @divFloor(seconds, 86_400);
|
|
1631
|
+
const second_of_day: u32 = @intCast(@mod(seconds, 86_400));
|
|
1632
|
+
const parts = localCivilFromDays(days) orelse return error.InvalidTimestamp;
|
|
1633
|
+
const hour = second_of_day / 3600;
|
|
1634
|
+
const minute = (second_of_day % 3600) / 60;
|
|
1635
|
+
const second = second_of_day % 60;
|
|
1636
|
+
return switch (style) {
|
|
1637
|
+
.date => try std.fmt.bufPrint(buffer, "{d:0>4}-{d:0>2}-{d:0>2}", .{ parts.year, parts.month, parts.day }),
|
|
1638
|
+
.time => try std.fmt.bufPrint(buffer, "{d:0>2}:{d:0>2}:{d:0>2}", .{ hour, minute, second }),
|
|
1639
|
+
.datetime => try std.fmt.bufPrint(buffer, "{d:0>4}-{d:0>2}-{d:0>2} {d:0>2}:{d:0>2}:{d:0>2}", .{ parts.year, parts.month, parts.day, hour, minute, second }),
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
const LocalCivilDate = struct { year: u32, month: u32, day: u32 };
|
|
1644
|
+
|
|
1645
|
+
fn localCivilFromDays(days: i64) ?LocalCivilDate {
|
|
1646
|
+
const shifted = days + 719_468;
|
|
1647
|
+
const era = @divFloor(shifted, 146_097);
|
|
1648
|
+
const day_of_era: u32 = @intCast(shifted - era * 146_097);
|
|
1649
|
+
const year_of_era = (day_of_era - day_of_era / 1460 + day_of_era / 36_524 - day_of_era / 146_096) / 365;
|
|
1650
|
+
const year = @as(i64, year_of_era) + era * 400;
|
|
1651
|
+
const day_of_year = day_of_era - (365 * year_of_era + year_of_era / 4 - year_of_era / 100);
|
|
1652
|
+
const month_index = (5 * day_of_year + 2) / 153;
|
|
1653
|
+
const day = day_of_year - (153 * month_index + 2) / 5 + 1;
|
|
1654
|
+
const month = if (month_index < 10) month_index + 3 else month_index - 9;
|
|
1655
|
+
const civil_year = if (month <= 2) year + 1 else year;
|
|
1656
|
+
if (civil_year < 1 or civil_year > 9999) return null;
|
|
1657
|
+
return .{ .year = @intCast(civil_year), .month = month, .day = day };
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1479
1660
|
fn createTray(context: ?*anyopaque, options: TrayOptions) anyerror!void {
|
|
1480
1661
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1481
1662
|
self.tray_icon_path = undefined;
|
|
1482
1663
|
self.tray_title = undefined;
|
|
1483
1664
|
self.tray_tooltip = undefined;
|
|
1484
1665
|
self.tray_icon_path_len = (try copyInto(&self.tray_icon_path, options.icon_path)).len;
|
|
1485
|
-
|
|
1666
|
+
var presentation = options.presentation;
|
|
1667
|
+
if (presentation.title.len == 0) presentation.title = options.title;
|
|
1668
|
+
self.tray_title_len = (try copyInto(&self.tray_title, presentation.title)).len;
|
|
1486
1669
|
self.tray_tooltip_len = (try copyInto(&self.tray_tooltip, options.tooltip)).len;
|
|
1670
|
+
self.tray_activation_command_len = (try copyInto(&self.tray_activation_command, options.activation_command)).len;
|
|
1671
|
+
self.tray_alternate_activation_command_len = (try copyInto(&self.tray_alternate_activation_command, options.alternate_activation_command)).len;
|
|
1672
|
+
self.tray_open_command_len = (try copyInto(&self.tray_open_command, options.open_command)).len;
|
|
1673
|
+
self.tray_presentation = presentation;
|
|
1674
|
+
self.tray_presentation.title = self.tray_title[0..self.tray_title_len];
|
|
1487
1675
|
try updateTrayMenu(context, options.items);
|
|
1488
1676
|
self.tray_create_count += 1;
|
|
1489
1677
|
}
|
|
@@ -1500,9 +1688,17 @@ pub const NullPlatform = struct {
|
|
|
1500
1688
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1501
1689
|
self.tray_title = undefined;
|
|
1502
1690
|
self.tray_title_len = (try copyInto(&self.tray_title, title)).len;
|
|
1691
|
+
self.tray_presentation.title = self.tray_title[0..self.tray_title_len];
|
|
1503
1692
|
self.tray_title_update_count += 1;
|
|
1504
1693
|
}
|
|
1505
1694
|
|
|
1695
|
+
fn updateTrayPresentation(context: ?*anyopaque, presentation: TrayPresentation) anyerror!void {
|
|
1696
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1697
|
+
try updateTrayTitle(context, presentation.title);
|
|
1698
|
+
self.tray_presentation = presentation;
|
|
1699
|
+
self.tray_presentation.title = self.tray_title[0..self.tray_title_len];
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1506
1702
|
fn removeTray(context: ?*anyopaque) anyerror!void {
|
|
1507
1703
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1508
1704
|
self.tray_item_count = 0;
|
|
@@ -1667,6 +1863,49 @@ pub const NullPlatform = struct {
|
|
|
1667
1863
|
self.audio.volume = volume;
|
|
1668
1864
|
}
|
|
1669
1865
|
|
|
1866
|
+
fn audioCaptureStart(context: ?*anyopaque, source: types.AudioCaptureSource, format: types.AudioCaptureFormat, sink: types.AudioCaptureSink) anyerror!void {
|
|
1867
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1868
|
+
if ((source == .microphone and !self.microphone_capture) or
|
|
1869
|
+
(source == .system and !self.system_audio_capture)) return error.UnsupportedService;
|
|
1870
|
+
const capture = &self.audio_captures[@intFromEnum(source)];
|
|
1871
|
+
capture.active = true;
|
|
1872
|
+
capture.format = format;
|
|
1873
|
+
capture.sink = sink;
|
|
1874
|
+
capture.start_count += 1;
|
|
1875
|
+
_ = sink.push(.{ .kind = .started, .source = source, .format = format });
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
fn audioCaptureStop(context: ?*anyopaque, source: types.AudioCaptureSource) anyerror!void {
|
|
1879
|
+
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
1880
|
+
const capture = &self.audio_captures[@intFromEnum(source)];
|
|
1881
|
+
capture.active = false;
|
|
1882
|
+
capture.sink = .{};
|
|
1883
|
+
capture.stop_count += 1;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/// Push deterministic PCM through a live fake capture.
|
|
1887
|
+
pub fn pushAudioCapture(self: *NullPlatform, source: types.AudioCaptureSource, timestamp_ns: u64, pcm_s16le: []const u8) types.AudioCapturePushResult {
|
|
1888
|
+
const capture = &self.audio_captures[@intFromEnum(source)];
|
|
1889
|
+
if (!capture.active) return .closed;
|
|
1890
|
+
const stride = @as(usize, capture.format.channels) * 2;
|
|
1891
|
+
if (stride == 0 or pcm_s16le.len % stride != 0) return .dropped_oversized;
|
|
1892
|
+
return capture.sink.push(.{
|
|
1893
|
+
.kind = .data,
|
|
1894
|
+
.source = source,
|
|
1895
|
+
.format = capture.format,
|
|
1896
|
+
.timestamp_ns = timestamp_ns,
|
|
1897
|
+
.frames = @intCast(pcm_s16le.len / stride),
|
|
1898
|
+
.pcm_s16le = pcm_s16le,
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
pub fn failAudioCapture(self: *NullPlatform, source: types.AudioCaptureSource) types.AudioCapturePushResult {
|
|
1903
|
+
const capture = &self.audio_captures[@intFromEnum(source)];
|
|
1904
|
+
if (!capture.active) return .closed;
|
|
1905
|
+
capture.active = false;
|
|
1906
|
+
return capture.sink.push(.{ .kind = .failed, .source = source, .format = capture.format });
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1670
1909
|
fn audioUrlHash(url: []const u8) u64 {
|
|
1671
1910
|
return std.hash.Wyhash.hash(0, url);
|
|
1672
1911
|
}
|
|
@@ -2574,6 +2813,11 @@ pub const NullPlatform = struct {
|
|
|
2574
2813
|
return self.window_minimize_count[index];
|
|
2575
2814
|
}
|
|
2576
2815
|
|
|
2816
|
+
pub fn hideCountForWindow(self: *const NullPlatform, window_id: WindowId) u32 {
|
|
2817
|
+
const index = self.findWindowIndex(window_id) orelse return 0;
|
|
2818
|
+
return self.window_hide_count[index];
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2577
2821
|
/// Test seam: show calls observed for a window (the un-hide verb's
|
|
2578
2822
|
/// pinned observable, like `minimizeCountForWindow`).
|
|
2579
2823
|
pub fn showCountForWindow(self: *const NullPlatform, window_id: WindowId) u32 {
|
|
@@ -2615,6 +2859,7 @@ pub const NullPlatform = struct {
|
|
|
2615
2859
|
self.window_always_on_top[cursor] = self.window_always_on_top[cursor + 1];
|
|
2616
2860
|
self.window_click_through[cursor] = self.window_click_through[cursor + 1];
|
|
2617
2861
|
self.window_activate_on_show[cursor] = self.window_activate_on_show[cursor + 1];
|
|
2862
|
+
self.window_allows_fullscreen[cursor] = self.window_allows_fullscreen[cursor + 1];
|
|
2618
2863
|
self.window_show[cursor] = self.window_show[cursor + 1];
|
|
2619
2864
|
self.window_visible[cursor] = self.window_visible[cursor + 1];
|
|
2620
2865
|
self.window_first_present_seq[cursor] = self.window_first_present_seq[cursor + 1];
|
|
@@ -2622,6 +2867,7 @@ pub const NullPlatform = struct {
|
|
|
2622
2867
|
self.window_min_width[cursor] = self.window_min_width[cursor + 1];
|
|
2623
2868
|
self.window_min_height[cursor] = self.window_min_height[cursor + 1];
|
|
2624
2869
|
self.window_minimize_count[cursor] = self.window_minimize_count[cursor + 1];
|
|
2870
|
+
self.window_hide_count[cursor] = self.window_hide_count[cursor + 1];
|
|
2625
2871
|
self.window_show_count[cursor] = self.window_show_count[cursor + 1];
|
|
2626
2872
|
self.window_occluded[cursor] = self.window_occluded[cursor + 1];
|
|
2627
2873
|
self.window_close_policy[cursor] = self.window_close_policy[cursor + 1];
|
|
@@ -2758,7 +3004,7 @@ pub const NullPlatform = struct {
|
|
|
2758
3004
|
}
|
|
2759
3005
|
|
|
2760
3006
|
pub fn lastCredentialSecret(self: *const NullPlatform) []const u8 {
|
|
2761
|
-
return self.
|
|
3007
|
+
return self.credential_last_secret orelse "";
|
|
2762
3008
|
}
|
|
2763
3009
|
|
|
2764
3010
|
pub fn credentialSetCount(self: *const NullPlatform) usize {
|
|
@@ -2781,6 +3027,22 @@ pub const NullPlatform = struct {
|
|
|
2781
3027
|
return self.tray_tooltip[0..self.tray_tooltip_len];
|
|
2782
3028
|
}
|
|
2783
3029
|
|
|
3030
|
+
pub fn lastTrayActivationCommand(self: *const NullPlatform) []const u8 {
|
|
3031
|
+
return self.tray_activation_command[0..self.tray_activation_command_len];
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
pub fn lastTrayAlternateActivationCommand(self: *const NullPlatform) []const u8 {
|
|
3035
|
+
return self.tray_alternate_activation_command[0..self.tray_alternate_activation_command_len];
|
|
3036
|
+
}
|
|
3037
|
+
|
|
3038
|
+
pub fn lastTrayOpenCommand(self: *const NullPlatform) []const u8 {
|
|
3039
|
+
return self.tray_open_command[0..self.tray_open_command_len];
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
pub fn lastTrayPresentation(self: *const NullPlatform) TrayPresentation {
|
|
3043
|
+
return self.tray_presentation;
|
|
3044
|
+
}
|
|
3045
|
+
|
|
2784
3046
|
pub fn trayItems(self: *const NullPlatform) []const TrayMenuItem {
|
|
2785
3047
|
return self.tray_items[0..self.tray_item_count];
|
|
2786
3048
|
}
|
|
@@ -31,6 +31,7 @@ const max_clipboard_data_bytes = types.max_clipboard_data_bytes;
|
|
|
31
31
|
const max_credential_service_bytes = types.max_credential_service_bytes;
|
|
32
32
|
const max_credential_account_bytes = types.max_credential_account_bytes;
|
|
33
33
|
const max_credential_secret_bytes = types.max_credential_secret_bytes;
|
|
34
|
+
const max_local_time_text_bytes = types.max_local_time_text_bytes;
|
|
34
35
|
const max_tray_items = types.max_tray_items;
|
|
35
36
|
const max_tray_icon_path_bytes = types.max_tray_icon_path_bytes;
|
|
36
37
|
const max_tray_tooltip_bytes = types.max_tray_tooltip_bytes;
|
|
@@ -111,6 +112,7 @@ const TrayOptions = types.TrayOptions;
|
|
|
111
112
|
const TrayMenuItem = types.TrayMenuItem;
|
|
112
113
|
const NativeCommandEvent = types.NativeCommandEvent;
|
|
113
114
|
const MenuCommandEvent = types.MenuCommandEvent;
|
|
115
|
+
const TrayCommandEvent = types.TrayCommandEvent;
|
|
114
116
|
const FileDropEvent = types.FileDropEvent;
|
|
115
117
|
const GpuFrame = types.GpuFrame;
|
|
116
118
|
const GpuSurfaceFrameEvent = types.GpuSurfaceFrameEvent;
|
|
@@ -162,6 +164,46 @@ test "null platform emits deterministic lifecycle events" {
|
|
|
162
164
|
try std.testing.expectEqualStrings("app_shutdown", recorder.names[5]);
|
|
163
165
|
}
|
|
164
166
|
|
|
167
|
+
test "null platform reports hidden startup state" {
|
|
168
|
+
const Recorder = struct {
|
|
169
|
+
startup_hidden: ?bool = null,
|
|
170
|
+
|
|
171
|
+
fn handle(context: *anyopaque, event: Event) anyerror!void {
|
|
172
|
+
const self: *@This() = @ptrCast(@alignCast(context));
|
|
173
|
+
switch (event) {
|
|
174
|
+
.window_frame_changed => |window| self.startup_hidden = window.hidden,
|
|
175
|
+
else => {},
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
var null_platform = NullPlatform.initWithOptions(.{}, .system, .{
|
|
181
|
+
.app_name = "Hidden",
|
|
182
|
+
.main_window = .{ .show = .hidden },
|
|
183
|
+
});
|
|
184
|
+
var recorder: Recorder = .{};
|
|
185
|
+
try null_platform.platform().run(Recorder.handle, &recorder);
|
|
186
|
+
|
|
187
|
+
try std.testing.expectEqual(true, recorder.startup_hidden.?);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
test "null platform focus reveals a hidden window" {
|
|
191
|
+
var null_platform = NullPlatform.init(.{});
|
|
192
|
+
const services = null_platform.platform().services;
|
|
193
|
+
const window = try services.createWindow(.{
|
|
194
|
+
.id = 7,
|
|
195
|
+
.label = "panel",
|
|
196
|
+
.show = .hidden,
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
try std.testing.expect(window.hidden);
|
|
200
|
+
try std.testing.expect(!null_platform.window_visible[0]);
|
|
201
|
+
try services.focusWindow(window.id);
|
|
202
|
+
try std.testing.expect(!null_platform.windows[0].hidden);
|
|
203
|
+
try std.testing.expect(null_platform.windows[0].focused);
|
|
204
|
+
try std.testing.expect(null_platform.window_visible[0]);
|
|
205
|
+
}
|
|
206
|
+
|
|
165
207
|
test "the videoLoadUrl seam refuses non-http(s) schemes for every caller" {
|
|
166
208
|
// The streaming contract holds at the seam, not just behind the
|
|
167
209
|
// engine's own gated loads: hosts hand the URL to their media
|
|
@@ -215,8 +257,29 @@ test "null platform records bridge response window routing" {
|
|
|
215
257
|
try std.testing.expectEqualStrings("{\"ok\":true}", null_platform.lastBridgeResponse());
|
|
216
258
|
}
|
|
217
259
|
|
|
260
|
+
test "null platform preserves the tray title when presentation styles are set" {
|
|
261
|
+
var null_platform = NullPlatform.init(.{});
|
|
262
|
+
try null_platform.platform().services.createTray(.{
|
|
263
|
+
.title = "Jobs",
|
|
264
|
+
.presentation = .{ .width = 60, .tone = .warning },
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
try std.testing.expectEqualStrings("Jobs", null_platform.lastTrayTitle());
|
|
268
|
+
const presentation = null_platform.lastTrayPresentation();
|
|
269
|
+
try std.testing.expectEqualStrings("Jobs", presentation.title);
|
|
270
|
+
try std.testing.expectEqual(@as(f32, 60), presentation.width);
|
|
271
|
+
try std.testing.expectEqual(types.TrayTone.warning, presentation.tone);
|
|
272
|
+
|
|
273
|
+
try null_platform.platform().services.updateTrayTitle("Builds");
|
|
274
|
+
const retitled = null_platform.lastTrayPresentation();
|
|
275
|
+
try std.testing.expectEqualStrings("Builds", retitled.title);
|
|
276
|
+
try std.testing.expectEqual(@as(f32, 60), retitled.width);
|
|
277
|
+
try std.testing.expectEqual(types.TrayTone.warning, retitled.tone);
|
|
278
|
+
}
|
|
279
|
+
|
|
218
280
|
test "null platform records OS actions" {
|
|
219
281
|
var null_platform = NullPlatform.init(.{});
|
|
282
|
+
defer null_platform.deinit();
|
|
220
283
|
const services = null_platform.platform().services;
|
|
221
284
|
|
|
222
285
|
try services.showNotification(.{
|
|
@@ -276,9 +339,19 @@ test "null platform records OS actions" {
|
|
|
276
339
|
const secret = try services.getCredential(.{ .service = "dev.native-sdk.test", .account = "alice" }, &credential_buffer);
|
|
277
340
|
try std.testing.expectEqualStrings("secret-token", secret);
|
|
278
341
|
try std.testing.expectError(error.CredentialNotFound, services.getCredential(.{ .service = "dev.native-sdk.test", .account = "bob" }, &credential_buffer));
|
|
342
|
+
try services.setCredential(.{ .service = "dev.native-sdk.test", .account = "bob", .secret = "second-token" });
|
|
343
|
+
try std.testing.expectEqualStrings("secret-token", try services.getCredential(.{ .service = "dev.native-sdk.test", .account = "alice" }, &credential_buffer));
|
|
344
|
+
try std.testing.expectEqualStrings("second-token", try services.getCredential(.{ .service = "dev.native-sdk.test", .account = "bob" }, &credential_buffer));
|
|
279
345
|
try services.deleteCredential(.{ .service = "dev.native-sdk.test", .account = "alice" });
|
|
280
346
|
try std.testing.expectEqual(@as(usize, 1), null_platform.credentialDeleteCount());
|
|
281
347
|
try std.testing.expectError(error.CredentialNotFound, services.getCredential(.{ .service = "dev.native-sdk.test", .account = "alice" }, &credential_buffer));
|
|
348
|
+
try std.testing.expectEqualStrings("second-token", try services.getCredential(.{ .service = "dev.native-sdk.test", .account = "bob" }, &credential_buffer));
|
|
349
|
+
|
|
350
|
+
null_platform.local_time_offset_minutes = -360;
|
|
351
|
+
var local_time_buffer: [max_local_time_text_bytes]u8 = undefined;
|
|
352
|
+
try std.testing.expectEqualStrings("2024-01-01 21:04:05", try services.formatLocalTime(1_704_164_645_000, .datetime, &local_time_buffer));
|
|
353
|
+
try std.testing.expectEqualStrings("2024-01-01", try services.formatLocalTime(1_704_164_645_000, .date, &local_time_buffer));
|
|
354
|
+
try std.testing.expectEqualStrings("21:04:05", try services.formatLocalTime(1_704_164_645_000, .time, &local_time_buffer));
|
|
282
355
|
|
|
283
356
|
try services.clearRecentDocuments();
|
|
284
357
|
try std.testing.expectEqual(@as(usize, 1), null_platform.recentDocumentsClearedCount());
|
|
@@ -391,6 +464,7 @@ test "OS actions require backend support" {
|
|
|
391
464
|
try std.testing.expectError(error.UnsupportedService, services.setCredential(.{ .service = "service", .account = "account", .secret = "secret" }));
|
|
392
465
|
try std.testing.expectError(error.UnsupportedService, services.getCredential(.{ .service = "service", .account = "account" }, &buffer));
|
|
393
466
|
try std.testing.expectError(error.UnsupportedService, services.deleteCredential(.{ .service = "service", .account = "account" }));
|
|
467
|
+
try std.testing.expectError(error.UnsupportedService, services.formatLocalTime(0, .datetime, &buffer));
|
|
394
468
|
}
|
|
395
469
|
|
|
396
470
|
test "null platform records webview lifecycle" {
|