@native-sdk/cli 0.9.1 → 0.9.3
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 +26 -9
- package/build.zig +124 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/packages/core/sdk/events.d.ts +7 -0
- package/packages/core/sdk/events.ts +26 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +58 -1
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +10 -8
- package/skill-data/ts-core/SKILL.md +8 -5
- package/src/app_runner/root.zig +301 -12
- package/src/app_runner/ts_core_main.zig +6 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- 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 +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +271 -52
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +222 -14
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- 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 +129 -1
- 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 +14 -2
- package/src/primitives/canvas/text_interaction.zig +23 -0
- 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 +65 -0
- package/src/primitives/canvas/ui.zig +66 -10
- 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 +55 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- 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 +67 -6
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +84 -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 +593 -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 +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- 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 +33 -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/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ts_ui_app.zig +164 -1
- package/src/runtime/ui_app.zig +100 -21
- package/src/runtime/ui_app_tests.zig +351 -32
- package/src/runtime/ui_app_window_tests.zig +13 -1
- 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_text.zig +1 -1
- 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 +128 -18
- package/src/tooling/verbs.zig +1 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/shim_rt.zig +20 -0
package/src/platform/types.zig
CHANGED
|
@@ -303,14 +303,20 @@ pub const max_gpu_surface_packet_binary_bytes: usize = 512 * 1024;
|
|
|
303
303
|
/// packet present falls back because a command is not representable
|
|
304
304
|
/// (fits every `CanvasCommand` tag name).
|
|
305
305
|
pub const max_gpu_present_fallback_detail_bytes: usize = 32;
|
|
306
|
+
/// Longest decoded-image side accepted by the registered-image codec seam.
|
|
307
|
+
/// Source metadata may exceed this: conforming platform codecs combine this
|
|
308
|
+
/// axis ceiling with the caller's `max_pixels` area target and downsample
|
|
309
|
+
/// during decode. Keeping the decoded side bounded protects codec and GPU
|
|
310
|
+
/// upload paths from pathological panoramas without refusing them outright.
|
|
311
|
+
pub const max_decoded_image_dimension: usize = 8192;
|
|
306
312
|
/// Per-image bound for the binary gpu-surface image upload side-channel;
|
|
307
|
-
/// matches the runtime registry's
|
|
308
|
-
/// (`canvas_limits.
|
|
309
|
-
/// ORDINARY registered-image ids only: the
|
|
310
|
-
///
|
|
311
|
-
///
|
|
312
|
-
/// copied into host allocations.
|
|
313
|
-
pub const max_gpu_surface_image_pixel_bytes: usize = 1024 * 1024;
|
|
313
|
+
/// matches the runtime registry's app-configurable ceiling
|
|
314
|
+
/// (`canvas_limits.max_registered_canvas_image_pixel_bytes_ceiling`).
|
|
315
|
+
/// Applies to ORDINARY registered-image ids only: the runtime's frozen
|
|
316
|
+
/// app budget may be lower, but anything it accepts must remain uploadable
|
|
317
|
+
/// on packet hosts. An upload past the SDK ceiling is still an engine bug
|
|
318
|
+
/// and is refused loudly rather than copied into host allocations.
|
|
319
|
+
pub const max_gpu_surface_image_pixel_bytes: usize = 8 * 1024 * 1024;
|
|
314
320
|
/// Per-image bound for uploads in the media-surface texture namespace
|
|
315
321
|
/// (ids with `canvas.media_surface_image_id_bit` set — producer-pushed
|
|
316
322
|
/// dynamic textures, structurally disjoint from registered-image ids):
|
|
@@ -464,6 +470,16 @@ pub const WindowRestorePolicy = enum {
|
|
|
464
470
|
center_on_primary,
|
|
465
471
|
};
|
|
466
472
|
|
|
473
|
+
/// Why the host is receiving the window's initial frame. Persistence policy
|
|
474
|
+
/// (`restore_state`) is deliberately separate: only the state-store loader can
|
|
475
|
+
/// say `.restored`, while an authored x/y origin says `.explicit`; every other
|
|
476
|
+
/// fresh window uses `.default` platform placement.
|
|
477
|
+
pub const WindowInitialPlacement = enum {
|
|
478
|
+
restored,
|
|
479
|
+
explicit,
|
|
480
|
+
default,
|
|
481
|
+
};
|
|
482
|
+
|
|
467
483
|
/// How the window draws its titlebar chrome.
|
|
468
484
|
/// `.hidden_inset` is the modern editor-app shape: content extends under a
|
|
469
485
|
/// transparent titlebar with the title hidden (macOS:
|
|
@@ -621,6 +637,7 @@ pub const WindowOptions = struct {
|
|
|
621
637
|
resizable: bool = true,
|
|
622
638
|
restore_state: bool = true,
|
|
623
639
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
640
|
+
initial_placement: WindowInitialPlacement = .default,
|
|
624
641
|
titlebar: WindowTitlebarStyle = .standard,
|
|
625
642
|
show: WindowShowMode = .immediate,
|
|
626
643
|
/// Make the top-level window and its rendering surface alpha-capable.
|
|
@@ -715,6 +732,7 @@ pub const WindowCreateOptions = struct {
|
|
|
715
732
|
resizable: bool = true,
|
|
716
733
|
restore_state: bool = true,
|
|
717
734
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
735
|
+
initial_placement: WindowInitialPlacement = .default,
|
|
718
736
|
titlebar: WindowTitlebarStyle = .standard,
|
|
719
737
|
show: WindowShowMode = .immediate,
|
|
720
738
|
transparent: bool = false,
|
|
@@ -739,6 +757,15 @@ pub const WindowCreateOptions = struct {
|
|
|
739
757
|
.resizable = self.resizable,
|
|
740
758
|
.restore_state = self.restore_state,
|
|
741
759
|
.restore_policy = self.restore_policy,
|
|
760
|
+
// Preserve the historical direct-runtime shape where a non-zero
|
|
761
|
+
// `default_frame` origin meant explicit placement. Callers that
|
|
762
|
+
// intentionally need the visible-screen origin can state
|
|
763
|
+
// `.explicit`; optional-origin APIs already do so even at 0,0.
|
|
764
|
+
.initial_placement = if (self.initial_placement == .default and
|
|
765
|
+
(self.default_frame.x != 0 or self.default_frame.y != 0))
|
|
766
|
+
.explicit
|
|
767
|
+
else
|
|
768
|
+
self.initial_placement,
|
|
742
769
|
.titlebar = self.titlebar,
|
|
743
770
|
.show = self.show,
|
|
744
771
|
.transparent = self.transparent,
|
|
@@ -1263,9 +1290,14 @@ pub const AppInfo = struct {
|
|
|
1263
1290
|
/// built-in re-show affordance: hiding a window on windows removes
|
|
1264
1291
|
/// its taskbar entry and windows has no dock-reopen path, so only a
|
|
1265
1292
|
/// tray icon can bring the hidden window back. The Windows host
|
|
1266
|
-
/// folds this into its `window_hide_on_close` answer
|
|
1267
|
-
///
|
|
1293
|
+
/// folds this into its `window_hide_on_close` answer. On macOS the
|
|
1294
|
+
/// Dock is a reopen path only while `dock_visible` is true; manifest
|
|
1295
|
+
/// validation therefore requires a tray for accessory startup.
|
|
1268
1296
|
declares_tray: bool = false,
|
|
1297
|
+
/// Initial Dock/app-switcher presence. The macOS hosts translate
|
|
1298
|
+
/// false to Accessory before configuring the app or creating its
|
|
1299
|
+
/// startup window; `setDockPresence` can change it later.
|
|
1300
|
+
dock_visible: bool = true,
|
|
1269
1301
|
window_title: []const u8 = "",
|
|
1270
1302
|
bundle_id: []const u8 = "dev.native_sdk.app",
|
|
1271
1303
|
icon_path: []const u8 = "",
|
|
@@ -1289,6 +1321,7 @@ pub const AppInfo = struct {
|
|
|
1289
1321
|
pub fn resolvedMainWindow(self: AppInfo) WindowOptions {
|
|
1290
1322
|
var window = self.main_window;
|
|
1291
1323
|
if (window.title.len == 0) window.title = self.resolvedWindowTitle();
|
|
1324
|
+
inferLegacyExplicitOrigin(&window);
|
|
1292
1325
|
return window;
|
|
1293
1326
|
}
|
|
1294
1327
|
|
|
@@ -1303,8 +1336,17 @@ pub const AppInfo = struct {
|
|
|
1303
1336
|
}
|
|
1304
1337
|
if (window.label.len == 0) window.label = if (index == 0) "main" else "window";
|
|
1305
1338
|
if (window.title.len == 0) window.title = self.resolvedWindowTitle();
|
|
1339
|
+
inferLegacyExplicitOrigin(&window);
|
|
1306
1340
|
return window;
|
|
1307
1341
|
}
|
|
1342
|
+
|
|
1343
|
+
fn inferLegacyExplicitOrigin(window: *WindowOptions) void {
|
|
1344
|
+
if (window.initial_placement == .default and
|
|
1345
|
+
(window.default_frame.x != 0 or window.default_frame.y != 0))
|
|
1346
|
+
{
|
|
1347
|
+
window.initial_placement = .explicit;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1308
1350
|
};
|
|
1309
1351
|
|
|
1310
1352
|
pub const Surface = struct {
|
|
@@ -2348,6 +2390,7 @@ pub const WidgetAccessibilityRole = enum(c_int) {
|
|
|
2348
2390
|
slider = 18,
|
|
2349
2391
|
progressbar = 19,
|
|
2350
2392
|
radio = 20,
|
|
2393
|
+
radiogroup = 21,
|
|
2351
2394
|
};
|
|
2352
2395
|
|
|
2353
2396
|
pub const WidgetAccessibilityActions = struct {
|
|
@@ -2950,12 +2993,16 @@ pub const PlatformServices = struct {
|
|
|
2950
2993
|
/// framework bundles no image decoders: macOS decodes through
|
|
2951
2994
|
/// CGImageSource (ImageIO), GTK through gdk-pixbuf, Win32 through WIC.
|
|
2952
2995
|
/// Implementations may use `buffer` as decode scratch, so callers size
|
|
2953
|
-
/// it for their pixel bound, not the exact image.
|
|
2996
|
+
/// it for their pixel bound, not the exact image. `max_pixels` is a
|
|
2997
|
+
/// pixel-count cap, not a width/height box: codecs preserve aspect and
|
|
2998
|
+
/// decode down when source pixels exceed it or either decoded side would
|
|
2999
|
+
/// exceed `max_decoded_image_dimension`. Errors:
|
|
2954
3000
|
/// `error.ImageDecodeFailed` for undecodable bytes,
|
|
2955
|
-
/// `error.ImageTooLarge` when the
|
|
3001
|
+
/// `error.ImageTooLarge` when the fitted pixels violate either bound or
|
|
3002
|
+
/// do not fit `buffer`.
|
|
2956
3003
|
/// Null on platforms without a codec (the null platform by default),
|
|
2957
3004
|
/// which surfaces as `error.UnsupportedService`.
|
|
2958
|
-
decode_image_fn: ?*const fn (context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!DecodedImage = null,
|
|
3005
|
+
decode_image_fn: ?*const fn (context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!DecodedImage = null,
|
|
2959
3006
|
|
|
2960
3007
|
pub fn readClipboard(self: PlatformServices, buffer: []u8) anyerror![]const u8 {
|
|
2961
3008
|
const read_fn = self.read_clipboard_fn orelse return error.UnsupportedService;
|
|
@@ -3541,11 +3588,10 @@ pub const PlatformServices = struct {
|
|
|
3541
3588
|
// Two honest bounds, keyed by the id namespace: hosts copy every
|
|
3542
3589
|
// upload into host-owned allocations (AppKit's NSData + NSImage
|
|
3543
3590
|
// store), so each bound teaches the real cost of its id space.
|
|
3544
|
-
// Ordinary registered images
|
|
3545
|
-
//
|
|
3546
|
-
//
|
|
3547
|
-
//
|
|
3548
|
-
// producer staged can fail here.
|
|
3591
|
+
// Ordinary registered images use the registry's configurable
|
|
3592
|
+
// ceiling; media-surface textures (the reserved high-bit namespace)
|
|
3593
|
+
// use the producer channel's frame budget — the bound the producer
|
|
3594
|
+
// already enforced, so nothing either source accepted can fail here.
|
|
3549
3595
|
const bound = if ((image.id & canvas.media_surface_image_id_bit) != 0)
|
|
3550
3596
|
max_gpu_surface_media_image_pixel_bytes
|
|
3551
3597
|
else
|
|
@@ -3589,10 +3635,14 @@ pub const PlatformServices = struct {
|
|
|
3589
3635
|
|
|
3590
3636
|
/// Decode encoded image bytes through the platform codec into
|
|
3591
3637
|
/// straight-alpha RGBA8 (see `decode_image_fn`). Loop-thread only.
|
|
3592
|
-
pub fn decodeImage(self: PlatformServices, bytes: []const u8, buffer: []u8) anyerror!DecodedImage {
|
|
3638
|
+
pub fn decodeImage(self: PlatformServices, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!DecodedImage {
|
|
3593
3639
|
if (bytes.len == 0) return error.ImageDecodeFailed;
|
|
3640
|
+
if (max_pixels == 0) return error.ImageTooLarge;
|
|
3594
3641
|
const decode_fn = self.decode_image_fn orelse return error.UnsupportedService;
|
|
3595
|
-
|
|
3642
|
+
const decoded = try decode_fn(self.context, bytes, buffer, max_pixels);
|
|
3643
|
+
const pixels = std.math.mul(usize, decoded.width, decoded.height) catch return error.ImageTooLarge;
|
|
3644
|
+
if (decoded.width > max_decoded_image_dimension or decoded.height > max_decoded_image_dimension or pixels > max_pixels) return error.ImageTooLarge;
|
|
3645
|
+
return decoded;
|
|
3596
3646
|
}
|
|
3597
3647
|
};
|
|
3598
3648
|
|
|
@@ -135,13 +135,13 @@ const shortcut_modifier_control: u32 = 1 << 2;
|
|
|
135
135
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
136
136
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
137
137
|
|
|
138
|
-
extern fn native_sdk_windows_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) ?*WindowsHost;
|
|
138
|
+
extern fn native_sdk_windows_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) ?*WindowsHost;
|
|
139
139
|
extern fn native_sdk_windows_destroy(host: *WindowsHost) void;
|
|
140
140
|
extern fn native_sdk_windows_run(host: *WindowsHost, callback: WindowsCallback, context: ?*anyopaque) void;
|
|
141
141
|
extern fn native_sdk_windows_stop(host: *WindowsHost) void;
|
|
142
142
|
extern fn native_sdk_windows_wake(host: *WindowsHost) void;
|
|
143
143
|
extern fn native_sdk_windows_request_frame(host: *WindowsHost) void;
|
|
144
|
-
extern fn native_sdk_windows_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
|
|
144
|
+
extern fn native_sdk_windows_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
|
|
145
145
|
extern fn native_sdk_windows_load_webview(host: *WindowsHost, 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;
|
|
146
146
|
extern fn native_sdk_windows_load_window_webview(host: *WindowsHost, 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) c_int;
|
|
147
147
|
extern fn native_sdk_windows_set_bridge_callback(host: *WindowsHost, callback: WindowsBridgeCallback, context: ?*anyopaque) void;
|
|
@@ -152,7 +152,7 @@ extern fn native_sdk_windows_emit_window_event(host: *WindowsHost, window_id: u6
|
|
|
152
152
|
extern fn native_sdk_windows_set_security_policy(host: *WindowsHost, allowed_origins: [*]const u8, allowed_origins_len: usize, external_urls: [*]const u8, external_urls_len: usize, external_action: c_int) void;
|
|
153
153
|
extern fn native_sdk_windows_set_menus(host: *WindowsHost, 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) c_int;
|
|
154
154
|
extern fn native_sdk_windows_set_shortcuts(host: *WindowsHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
155
|
-
extern fn native_sdk_windows_create_window(host: *WindowsHost, 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;
|
|
155
|
+
extern fn native_sdk_windows_create_window(host: *WindowsHost, 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;
|
|
156
156
|
extern fn native_sdk_windows_start_window_drag(host: *WindowsHost, window_id: u64) c_int;
|
|
157
157
|
extern fn native_sdk_windows_set_window_drag_regions(host: *WindowsHost, window_id: u64, label: [*]const u8, label_len: usize, rects: [*]const f64, exclusions: [*]const c_int, count: usize) c_int;
|
|
158
158
|
extern fn native_sdk_windows_window_chrome(host: *WindowsHost, 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;
|
|
@@ -344,7 +344,7 @@ pub const WindowsPlatform = struct {
|
|
|
344
344
|
try refuseUnsupportedTransparentWindow(window_options, false);
|
|
345
345
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
346
346
|
const frame = window_options.default_frame;
|
|
347
|
-
const host = native_sdk_windows_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;
|
|
347
|
+
const host = native_sdk_windows_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;
|
|
348
348
|
// Packet text must use the same Geist metrics the engine planned
|
|
349
349
|
// against. Register both built-in faces directly from their
|
|
350
350
|
// compile-time bytes; custom application fonts keep the public
|
|
@@ -923,11 +923,11 @@ pub fn installHeadlessImageCodec(services: *platform_mod.PlatformServices) void
|
|
|
923
923
|
|
|
924
924
|
/// WIC-backed image decoding (PNG, JPEG, ... — every codec the OS
|
|
925
925
|
/// ships) into straight-alpha RGBA8.
|
|
926
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
926
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
927
927
|
_ = context;
|
|
928
928
|
var width: usize = 0;
|
|
929
929
|
var height: usize = 0;
|
|
930
|
-
return switch (native_sdk_windows_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
|
|
930
|
+
return switch (native_sdk_windows_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
|
|
931
931
|
1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
|
|
932
932
|
-1 => error.ImageTooLarge,
|
|
933
933
|
else => error.ImageDecodeFailed,
|
|
@@ -943,6 +943,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
|
|
|
943
943
|
};
|
|
944
944
|
}
|
|
945
945
|
|
|
946
|
+
fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
|
|
947
|
+
return switch (placement) {
|
|
948
|
+
.restored => 0,
|
|
949
|
+
.explicit => 1,
|
|
950
|
+
.default => 2,
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
|
|
955
|
+
return switch (policy) {
|
|
956
|
+
.clamp_to_visible_screen => 0,
|
|
957
|
+
.center_on_primary => 1,
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
946
961
|
fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
947
962
|
return switch (mode) {
|
|
948
963
|
.immediate => 0,
|
|
@@ -986,7 +1001,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
986
1001
|
try refuseUnsupportedTransparentWindow(options, self.menus_active);
|
|
987
1002
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
988
1003
|
const frame = options.default_frame;
|
|
989
|
-
if (native_sdk_windows_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;
|
|
1004
|
+
if (native_sdk_windows_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;
|
|
990
1005
|
applyWindowClosePolicy(self.host, options.id, options.close_policy);
|
|
991
1006
|
return .{
|
|
992
1007
|
.id = options.id,
|
|
@@ -6125,8 +6125,10 @@ size_t native_sdk_windows_clipboard_read_data(Host *host, const char *mime_type,
|
|
|
6125
6125
|
int native_sdk_windows_clipboard_write_data(Host *host, const char *mime_type, size_t mime_type_len, const char *bytes, size_t bytes_len);
|
|
6126
6126
|
void native_sdk_windows_cancel_timer(Host *host, uint64_t timer_id);
|
|
6127
6127
|
|
|
6128
|
-
Host *native_sdk_windows_create(const char *app_name, size_t app_name_len, 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 resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
6128
|
+
Host *native_sdk_windows_create(const char *app_name, size_t app_name_len, 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, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
6129
6129
|
(void)restore_frame;
|
|
6130
|
+
(void)initial_placement;
|
|
6131
|
+
(void)restore_policy;
|
|
6130
6132
|
INITCOMMONCONTROLSEX controls = {};
|
|
6131
6133
|
controls.dwSize = sizeof(controls);
|
|
6132
6134
|
controls.dwICC = ICC_PROGRESS_CLASS | ICC_TAB_CLASSES;
|
|
@@ -6285,11 +6287,12 @@ void native_sdk_windows_request_frame(Host *host) {
|
|
|
6285
6287
|
static const GUID kNativeSdkCLSID_WICImagingFactory = {0xcacaf262, 0x9370, 0x4615, {0xa1, 0x3b, 0x9f, 0x55, 0x39, 0xda, 0x4c, 0x0a}};
|
|
6286
6288
|
static const GUID kNativeSdkIID_IWICImagingFactory = {0xec5ec8a9, 0xc395, 0x4314, {0x9c, 0x77, 0x54, 0xd7, 0xa9, 0x35, 0xff, 0x70}};
|
|
6287
6289
|
static const GUID kNativeSdkGUID_WICPixelFormat32bppRGBA = {0xf5c7ad2d, 0x6a8d, 0x43dd, {0xa7, 0xa8, 0xa2, 0x99, 0x35, 0x26, 0x1a, 0xe9}};
|
|
6290
|
+
static constexpr size_t kNativeSdkMaxDecodedImageDimension = 8192;
|
|
6288
6291
|
|
|
6289
|
-
int native_sdk_windows_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) {
|
|
6292
|
+
int native_sdk_windows_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) {
|
|
6290
6293
|
if (out_width) *out_width = 0;
|
|
6291
6294
|
if (out_height) *out_height = 0;
|
|
6292
|
-
if (!bytes || bytes_len == 0 || !pixels || bytes_len > UINT32_MAX) return 0;
|
|
6295
|
+
if (!bytes || bytes_len == 0 || !pixels || bytes_len > UINT32_MAX || max_pixels == 0) return 0;
|
|
6293
6296
|
|
|
6294
6297
|
HRESULT init = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
|
6295
6298
|
bool uninitialize = SUCCEEDED(init); // S_FALSE still pairs with CoUninitialize.
|
|
@@ -6299,6 +6302,7 @@ int native_sdk_windows_decode_image(const uint8_t *bytes, size_t bytes_len, uint
|
|
|
6299
6302
|
IWICStream *stream = nullptr;
|
|
6300
6303
|
IWICBitmapDecoder *decoder = nullptr;
|
|
6301
6304
|
IWICBitmapFrameDecode *frame = nullptr;
|
|
6305
|
+
IWICBitmapScaler *scaler = nullptr;
|
|
6302
6306
|
IWICFormatConverter *converter = nullptr;
|
|
6303
6307
|
do {
|
|
6304
6308
|
if (FAILED(CoCreateInstance(kNativeSdkCLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, kNativeSdkIID_IWICImagingFactory, reinterpret_cast<void **>(&factory)))) break;
|
|
@@ -6310,9 +6314,21 @@ int native_sdk_windows_decode_image(const uint8_t *bytes, size_t bytes_len, uint
|
|
|
6310
6314
|
UINT frame_width = 0;
|
|
6311
6315
|
UINT frame_height = 0;
|
|
6312
6316
|
if (FAILED(frame->GetSize(&frame_width, &frame_height))) break;
|
|
6313
|
-
if (frame_width == 0 || frame_height == 0
|
|
6317
|
+
if (frame_width == 0 || frame_height == 0) break;
|
|
6314
6318
|
size_t width = frame_width;
|
|
6315
6319
|
size_t height = frame_height;
|
|
6320
|
+
double source_pixels = static_cast<double>(width) * static_cast<double>(height);
|
|
6321
|
+
if (source_pixels > static_cast<double>(max_pixels) || width > kNativeSdkMaxDecodedImageDimension || height > kNativeSdkMaxDecodedImageDimension) {
|
|
6322
|
+
double area_scale = sqrt(static_cast<double>(max_pixels) / source_pixels);
|
|
6323
|
+
double axis_scale = static_cast<double>(kNativeSdkMaxDecodedImageDimension) / static_cast<double>(std::max(width, height));
|
|
6324
|
+
double scale = std::min(1.0, std::min(area_scale, axis_scale));
|
|
6325
|
+
width = std::max<size_t>(1, static_cast<size_t>(floor(static_cast<double>(width) * scale)));
|
|
6326
|
+
height = std::max<size_t>(1, static_cast<size_t>(floor(static_cast<double>(height) * scale)));
|
|
6327
|
+
while (width * height > max_pixels) {
|
|
6328
|
+
if (width > 1 && (height == 1 || width > height)) width -= 1;
|
|
6329
|
+
else height -= 1;
|
|
6330
|
+
}
|
|
6331
|
+
}
|
|
6316
6332
|
if (out_width) *out_width = width;
|
|
6317
6333
|
if (out_height) *out_height = height;
|
|
6318
6334
|
size_t byte_len = width * height * 4;
|
|
@@ -6322,12 +6338,19 @@ int native_sdk_windows_decode_image(const uint8_t *bytes, size_t bytes_len, uint
|
|
|
6322
6338
|
}
|
|
6323
6339
|
|
|
6324
6340
|
if (FAILED(factory->CreateFormatConverter(&converter))) break;
|
|
6325
|
-
|
|
6341
|
+
IWICBitmapSource *source_bitmap = frame;
|
|
6342
|
+
if (width != frame_width || height != frame_height) {
|
|
6343
|
+
if (FAILED(factory->CreateBitmapScaler(&scaler))) break;
|
|
6344
|
+
if (FAILED(scaler->Initialize(frame, static_cast<UINT>(width), static_cast<UINT>(height), WICBitmapInterpolationModeFant))) break;
|
|
6345
|
+
source_bitmap = scaler;
|
|
6346
|
+
}
|
|
6347
|
+
if (FAILED(converter->Initialize(source_bitmap, kNativeSdkGUID_WICPixelFormat32bppRGBA, WICBitmapDitherTypeNone, nullptr, 0.0, WICBitmapPaletteTypeCustom))) break;
|
|
6326
6348
|
if (FAILED(converter->CopyPixels(nullptr, static_cast<UINT>(width * 4), static_cast<UINT>(byte_len), pixels))) break;
|
|
6327
6349
|
result = 1;
|
|
6328
6350
|
} while (false);
|
|
6329
6351
|
|
|
6330
6352
|
if (converter) converter->Release();
|
|
6353
|
+
if (scaler) scaler->Release();
|
|
6331
6354
|
if (frame) frame->Release();
|
|
6332
6355
|
if (decoder) decoder->Release();
|
|
6333
6356
|
if (stream) stream->Release();
|
|
@@ -6555,8 +6578,10 @@ void native_sdk_windows_set_shortcuts(Host *host, const char *const *ids, const
|
|
|
6555
6578
|
}
|
|
6556
6579
|
}
|
|
6557
6580
|
|
|
6558
|
-
int native_sdk_windows_create_window(Host *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, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
6581
|
+
int native_sdk_windows_create_window(Host *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, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
6559
6582
|
(void)restore_frame;
|
|
6583
|
+
(void)initial_placement;
|
|
6584
|
+
(void)restore_policy;
|
|
6560
6585
|
if (!host || host->windows.find(window_id) != host->windows.end()) return 0;
|
|
6561
6586
|
Window window;
|
|
6562
6587
|
window.id = window_id;
|
|
@@ -82,6 +82,7 @@ pub const UrlScheme = types.UrlScheme;
|
|
|
82
82
|
pub const PackageMetadata = types.PackageMetadata;
|
|
83
83
|
pub const UpdateConfig = types.UpdateConfig;
|
|
84
84
|
pub const Manifest = types.Manifest;
|
|
85
|
+
pub const ImagesConfig = types.ImagesConfig;
|
|
85
86
|
pub const validateManifest = validation.validateManifest;
|
|
86
87
|
pub const validateIdentity = validation.validateIdentity;
|
|
87
88
|
pub const validateDescription = validation.validateDescription;
|
|
@@ -105,7 +106,9 @@ pub const validateUrl = validation.validateUrl;
|
|
|
105
106
|
pub const validateIcons = validation.validateIcons;
|
|
106
107
|
pub const validatePermissions = validation.validatePermissions;
|
|
107
108
|
pub const validateCapabilities = validation.validateCapabilities;
|
|
109
|
+
pub const validateDockVisibility = validation.validateDockVisibility;
|
|
108
110
|
pub const validatePersist = validation.validatePersist;
|
|
111
|
+
pub const validateImages = validation.validateImages;
|
|
109
112
|
pub const validateBridge = validation.validateBridge;
|
|
110
113
|
pub const validateFrontend = validation.validateFrontend;
|
|
111
114
|
pub const validateBridgeOrigin = validation.validateBridgeOrigin;
|
|
@@ -88,6 +88,7 @@ const validateUrl = validation.validateUrl;
|
|
|
88
88
|
const validateIcons = validation.validateIcons;
|
|
89
89
|
const validatePermissions = validation.validatePermissions;
|
|
90
90
|
const validateCapabilities = validation.validateCapabilities;
|
|
91
|
+
const validateImages = validation.validateImages;
|
|
91
92
|
const validateBridge = validation.validateBridge;
|
|
92
93
|
const validateFrontend = validation.validateFrontend;
|
|
93
94
|
const validateBridgeOrigin = validation.validateBridgeOrigin;
|
|
@@ -105,6 +106,22 @@ test "valid minimal manifest" {
|
|
|
105
106
|
try validateManifest(manifest);
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
test "accessory startup requires the tray capability" {
|
|
110
|
+
const tray_capabilities = [_]Capability{.tray};
|
|
111
|
+
try validateManifest(.{
|
|
112
|
+
.identity = .{ .id = "com.example.menu", .name = "menu" },
|
|
113
|
+
.version = .{ .major = 1, .minor = 0, .patch = 0 },
|
|
114
|
+
.capabilities = &tray_capabilities,
|
|
115
|
+
.dock_visible = false,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
try std.testing.expectError(error.MissingTrayCapability, validateManifest(.{
|
|
119
|
+
.identity = .{ .id = "com.example.stranded", .name = "stranded" },
|
|
120
|
+
.version = .{ .major = 1, .minor = 0, .patch = 0 },
|
|
121
|
+
.dock_visible = false,
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
test "manifest validates shell windows and views" {
|
|
109
126
|
const shell_views = [_]ShellView{
|
|
110
127
|
.{ .label = "toolbar", .kind = .toolbar, .edge = .top, .height = 44, .role = "toolbar" },
|
|
@@ -759,3 +776,10 @@ test "package metadata validation catches empty authors and invalid keywords" {
|
|
|
759
776
|
try std.testing.expectError(error.InvalidKeyword, validatePackageMetadata(.{ .keywords = &.{"Bad"} }));
|
|
760
777
|
try std.testing.expectError(error.InvalidUrl, validatePackageMetadata(.{ .repository = "ssh://example.com/repo" }));
|
|
761
778
|
}
|
|
779
|
+
|
|
780
|
+
test "registered-image manifest budget accepts the documented range only" {
|
|
781
|
+
try validateImages(.{});
|
|
782
|
+
try validateImages(.{ .max_image_pixel_bytes = 8 * 1024 * 1024 });
|
|
783
|
+
try std.testing.expectError(error.InvalidDimension, validateImages(.{ .max_image_pixel_bytes = 1024 * 1024 - 1 }));
|
|
784
|
+
try std.testing.expectError(error.InvalidDimension, validateImages(.{ .max_image_pixel_bytes = 8 * 1024 * 1024 + 1 }));
|
|
785
|
+
}
|
|
@@ -26,6 +26,7 @@ pub const ValidationError = error{
|
|
|
26
26
|
InvalidTimeout,
|
|
27
27
|
InvalidKeyword,
|
|
28
28
|
MissingRequiredField,
|
|
29
|
+
MissingTrayCapability,
|
|
29
30
|
WebViewLayerConflict,
|
|
30
31
|
NoSpaceLeft,
|
|
31
32
|
};
|
|
@@ -658,13 +659,25 @@ pub const PersistConfig = struct {
|
|
|
658
659
|
restore: PersistRestore,
|
|
659
660
|
};
|
|
660
661
|
|
|
662
|
+
pub const ImagesConfig = struct {
|
|
663
|
+
/// Per-used-slot decoded RGBA8 budget. The default is 1 MiB; apps may
|
|
664
|
+
/// deliberately raise it through 8 MiB. Sixteen fully used slots at
|
|
665
|
+
/// the ceiling are a declared 128 MiB high-water mark.
|
|
666
|
+
max_image_pixel_bytes: usize = 1024 * 1024,
|
|
667
|
+
};
|
|
668
|
+
|
|
661
669
|
pub const Manifest = struct {
|
|
662
670
|
identity: AppIdentity,
|
|
663
671
|
version: Version,
|
|
664
672
|
icons: []const Icon = &.{},
|
|
665
673
|
permissions: []const Permission = &.{},
|
|
666
674
|
capabilities: []const Capability = &.{},
|
|
675
|
+
/// Whether the app starts with its ordinary desktop presence. On
|
|
676
|
+
/// macOS false selects Accessory before startup windows exist, so no
|
|
677
|
+
/// Dock tile flashes; other hosts currently ignore the field.
|
|
678
|
+
dock_visible: bool = true,
|
|
667
679
|
persist: ?PersistConfig = null,
|
|
680
|
+
images: ImagesConfig = .{},
|
|
668
681
|
bridge: BridgeConfig = .{},
|
|
669
682
|
frontend: ?FrontendConfig = null,
|
|
670
683
|
security: SecurityConfig = .{},
|
|
@@ -68,13 +68,18 @@ const UrlScheme = types.UrlScheme;
|
|
|
68
68
|
const PackageMetadata = types.PackageMetadata;
|
|
69
69
|
const UpdateConfig = types.UpdateConfig;
|
|
70
70
|
const Manifest = types.Manifest;
|
|
71
|
+
const ImagesConfig = types.ImagesConfig;
|
|
72
|
+
const default_image_pixel_bytes: usize = 1024 * 1024;
|
|
73
|
+
const max_image_pixel_bytes_ceiling: usize = 8 * 1024 * 1024;
|
|
71
74
|
pub fn validateManifest(manifest: Manifest) ValidationError!void {
|
|
72
75
|
try validateIdentity(manifest.identity);
|
|
73
76
|
try validateVersion(manifest.version);
|
|
74
77
|
try validateIcons(manifest.icons);
|
|
75
78
|
try validatePermissions(manifest.permissions);
|
|
76
79
|
try validateCapabilities(manifest.capabilities);
|
|
80
|
+
try validateDockVisibility(manifest.dock_visible, manifest.capabilities);
|
|
77
81
|
try validatePersist(manifest.persist, manifest.capabilities);
|
|
82
|
+
try validateImages(manifest.images);
|
|
78
83
|
try validateBridge(manifest.bridge);
|
|
79
84
|
if (manifest.frontend) |frontend| try validateFrontend(frontend);
|
|
80
85
|
try validateSecurity(manifest.security);
|
|
@@ -92,6 +97,14 @@ pub fn validateManifest(manifest: Manifest) ValidationError!void {
|
|
|
92
97
|
try validateUpdates(manifest.updates);
|
|
93
98
|
}
|
|
94
99
|
|
|
100
|
+
pub fn validateImages(images: ImagesConfig) ValidationError!void {
|
|
101
|
+
if (images.max_image_pixel_bytes < default_image_pixel_bytes or
|
|
102
|
+
images.max_image_pixel_bytes > max_image_pixel_bytes_ceiling)
|
|
103
|
+
{
|
|
104
|
+
return error.InvalidDimension;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
95
108
|
/// Whether the manifest declares web content — the shared declare-to-use
|
|
96
109
|
/// contract (web_layer.zig) over the typed manifest. Validation has no
|
|
97
110
|
/// engine flag, so the manifest's own engine is the resolved engine here;
|
|
@@ -544,6 +557,17 @@ pub fn validateCapabilities(capabilities: []const Capability) ValidationError!vo
|
|
|
544
557
|
}
|
|
545
558
|
}
|
|
546
559
|
|
|
560
|
+
/// An accessory app has no Dock or app-switcher route back to its
|
|
561
|
+
/// windows. Require the status-item capability as the explicit re-show
|
|
562
|
+
/// affordance instead of allowing an app to strand itself invisibly.
|
|
563
|
+
pub fn validateDockVisibility(dock_visible: bool, capabilities: []const Capability) ValidationError!void {
|
|
564
|
+
if (dock_visible) return;
|
|
565
|
+
for (capabilities) |capability| {
|
|
566
|
+
if (capability == .tray) return;
|
|
567
|
+
}
|
|
568
|
+
return error.MissingTrayCapability;
|
|
569
|
+
}
|
|
570
|
+
|
|
547
571
|
pub fn validatePersist(config: ?types.PersistConfig, capabilities: []const Capability) ValidationError!void {
|
|
548
572
|
var declared = false;
|
|
549
573
|
for (capabilities) |capability| {
|
|
@@ -140,12 +140,14 @@ fn frameHasArea(frame: geometry.RectF) bool {
|
|
|
140
140
|
// ---------------------------------------------------------- missing label
|
|
141
141
|
|
|
142
142
|
/// Roles whose announcement is useless without a name: the control set a
|
|
143
|
-
/// screen reader user OPERATES
|
|
144
|
-
///
|
|
145
|
-
///
|
|
143
|
+
/// screen reader user OPERATES, plus a radiogroup whose name supplies the
|
|
144
|
+
/// shared question for its otherwise individually named choices. Other
|
|
145
|
+
/// text/status/group/image roles either carry their name as content or
|
|
146
|
+
/// degrade without blocking (images are the markup lint's warning);
|
|
147
|
+
/// progressbars are display-only.
|
|
146
148
|
fn roleNeedsName(role: WidgetRole) bool {
|
|
147
149
|
return switch (role) {
|
|
148
|
-
.button, .textbox, .checkbox, .radio, .switch_control, .slider, .menuitem, .tab, .link, .treeitem, .listitem => true,
|
|
150
|
+
.button, .textbox, .checkbox, .radio, .radiogroup, .switch_control, .slider, .menuitem, .tab, .link, .treeitem, .listitem => true,
|
|
149
151
|
else => false,
|
|
150
152
|
};
|
|
151
153
|
}
|
|
@@ -240,9 +242,9 @@ fn auditFocusReachable(layout: WidgetLayoutTree, node_index: usize, sink: *Findi
|
|
|
240
242
|
var scrolls_vertically = false;
|
|
241
243
|
var scrolls_horizontally = false;
|
|
242
244
|
while (true) {
|
|
243
|
-
//
|
|
244
|
-
//
|
|
245
|
-
if (widget_tree.
|
|
245
|
+
// Window-level surfaces escape every ancestor clip (the routing
|
|
246
|
+
// layer keeps focus targets inside them live).
|
|
247
|
+
if (widget_tree.widgetEscapesAncestorClips(layout.nodes[current].widget)) return;
|
|
246
248
|
const parent_index = layout.nodes[current].parent_index orelse return;
|
|
247
249
|
const parent = layout.nodes[parent_index];
|
|
248
250
|
if (widgetClipsForAudit(parent.widget)) {
|
|
@@ -40,6 +40,30 @@ test "an unlabeled button is a missing-label finding; text or a label clears it"
|
|
|
40
40
|
try std.testing.expectEqual(@as(usize, 0), clean.total);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
test "a radio group needs its own accessible name" {
|
|
44
|
+
var nodes: [16]canvas.WidgetLayoutNode = undefined;
|
|
45
|
+
var storage: [8]a11y_audit.A11yAuditFinding = undefined;
|
|
46
|
+
|
|
47
|
+
const unnamed = Widget{ .kind = .column, .children = &.{
|
|
48
|
+
.{ .id = 2, .kind = .radio_group, .children = &.{
|
|
49
|
+
.{ .id = 3, .kind = .radio, .text = "Default" },
|
|
50
|
+
.{ .id = 4, .kind = .radio, .text = "Compact" },
|
|
51
|
+
} },
|
|
52
|
+
} };
|
|
53
|
+
const issues = try auditTree(unnamed, window, &nodes, &storage);
|
|
54
|
+
try std.testing.expectEqual(@as(usize, 1), issues.total);
|
|
55
|
+
try std.testing.expectEqual(a11y_audit.A11yAuditRuleKind.missing_label, issues.findings[0].rule);
|
|
56
|
+
|
|
57
|
+
const named = Widget{ .kind = .column, .children = &.{
|
|
58
|
+
.{ .id = 2, .kind = .radio_group, .semantics = .{ .label = "Density" }, .children = &.{
|
|
59
|
+
.{ .id = 3, .kind = .radio, .text = "Default" },
|
|
60
|
+
.{ .id = 4, .kind = .radio, .text = "Compact" },
|
|
61
|
+
} },
|
|
62
|
+
} };
|
|
63
|
+
const clean = try auditTree(named, window, &nodes, &storage);
|
|
64
|
+
try std.testing.expectEqual(@as(usize, 0), clean.total);
|
|
65
|
+
}
|
|
66
|
+
|
|
43
67
|
test "a text field's value is not its name; a placeholder or label is" {
|
|
44
68
|
var nodes: [16]canvas.WidgetLayoutNode = undefined;
|
|
45
69
|
var storage: [8]a11y_audit.A11yAuditFinding = undefined;
|