@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.
Files changed (156) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +124 -1
  3. package/package.json +9 -9
  4. package/packages/core/package-lock.json +2 -2
  5. package/packages/core/package.json +1 -1
  6. package/packages/core/sdk/core.ts +3 -1
  7. package/packages/core/sdk/events.d.ts +7 -0
  8. package/packages/core/sdk/events.ts +26 -5
  9. package/packages/core/sdk/text.d.ts +4 -0
  10. package/packages/core/sdk/text.ts +51 -0
  11. package/packages/core/src/checker.ts +58 -1
  12. package/packages/core/src/contract.ts +5 -4
  13. package/packages/core/src/devhost_journal.mjs +2 -2
  14. package/packages/core/src/diagnostics.ts +2 -2
  15. package/packages/core/src/service_contract.ts +10 -0
  16. package/packages/core/src/typed_ast.ts +9 -7
  17. package/packages/core/src/types.ts +28 -8
  18. package/skill-data/automation/SKILL.md +4 -3
  19. package/skill-data/native-ui/SKILL.md +10 -8
  20. package/skill-data/ts-core/SKILL.md +8 -5
  21. package/src/app_runner/root.zig +301 -12
  22. package/src/app_runner/ts_core_main.zig +6 -4
  23. package/src/app_runner/window_placement.zig +63 -0
  24. package/src/automation/protocol.zig +5 -1
  25. package/src/automation/snapshot.zig +119 -0
  26. package/src/embed/app_exports.zig +2 -1
  27. package/src/embed/conversions.zig +1 -0
  28. package/src/embed/host.zig +10 -3
  29. package/src/embed/root.zig +1 -0
  30. package/src/embed/tests.zig +13 -1
  31. package/src/embed/types.zig +2 -0
  32. package/src/embed/ui_host.zig +26 -2
  33. package/src/platform/android/NativeSdkActivity.java +49 -4
  34. package/src/platform/android/android_host.c +3 -3
  35. package/src/platform/android/native_sdk_app.h +1 -1
  36. package/src/platform/ios/apple_image_fit.h +38 -0
  37. package/src/platform/ios/files.zig +1 -0
  38. package/src/platform/ios/native_sdk_app.h +1 -1
  39. package/src/platform/ios/uikit_host.m +28 -5
  40. package/src/platform/linux/cef_host.cpp +10 -2
  41. package/src/platform/linux/gtk_host.c +43 -10
  42. package/src/platform/linux/gtk_host.h +3 -3
  43. package/src/platform/linux/root.zig +22 -7
  44. package/src/platform/macos/appkit_host.h +7 -4
  45. package/src/platform/macos/appkit_host.m +271 -52
  46. package/src/platform/macos/cef_host.mm +132 -34
  47. package/src/platform/macos/image_fit_test.m +44 -0
  48. package/src/platform/macos/root.zig +222 -14
  49. package/src/platform/null_platform.zig +17 -3
  50. package/src/platform/null_platform_tests.zig +58 -4
  51. package/src/platform/root.zig +2 -0
  52. package/src/platform/types.zig +69 -19
  53. package/src/platform/windows/root.zig +22 -7
  54. package/src/platform/windows/webview2_host.cpp +31 -6
  55. package/src/primitives/app_manifest/root.zig +3 -0
  56. package/src/primitives/app_manifest/tests.zig +24 -0
  57. package/src/primitives/app_manifest/types.zig +13 -0
  58. package/src/primitives/app_manifest/validation.zig +24 -0
  59. package/src/primitives/canvas/a11y_audit.zig +9 -7
  60. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  61. package/src/primitives/canvas/events.zig +129 -1
  62. package/src/primitives/canvas/layout_audit.zig +6 -6
  63. package/src/primitives/canvas/markdown.zig +4 -0
  64. package/src/primitives/canvas/markdown_tests.zig +1 -0
  65. package/src/primitives/canvas/png.zig +138 -0
  66. package/src/primitives/canvas/root.zig +14 -2
  67. package/src/primitives/canvas/text_interaction.zig +23 -0
  68. package/src/primitives/canvas/text_span_tests.zig +5 -3
  69. package/src/primitives/canvas/text_spans.zig +2 -0
  70. package/src/primitives/canvas/text_tests.zig +65 -0
  71. package/src/primitives/canvas/ui.zig +66 -10
  72. package/src/primitives/canvas/ui_markup.zig +40 -13
  73. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  74. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  75. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  76. package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
  77. package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
  78. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  79. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  80. package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
  81. package/src/primitives/canvas/ui_schema.zig +17 -13
  82. package/src/primitives/canvas/ui_tests.zig +84 -0
  83. package/src/primitives/canvas/widget_access.zig +3 -3
  84. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  85. package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
  86. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  87. package/src/primitives/canvas/widget_layout.zig +333 -126
  88. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  89. package/src/primitives/canvas/widget_metrics.zig +7 -8
  90. package/src/primitives/canvas/widget_render.zig +76 -44
  91. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  92. package/src/primitives/canvas/widget_render_style.zig +58 -18
  93. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  94. package/src/primitives/canvas/widget_routing.zig +40 -34
  95. package/src/primitives/canvas/widget_runtime.zig +11 -2
  96. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  97. package/src/primitives/canvas/widget_semantics.zig +8 -3
  98. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  99. package/src/primitives/canvas/widget_tree.zig +99 -5
  100. package/src/primitives/canvas/widgets.zig +20 -7
  101. package/src/root.zig +3 -0
  102. package/src/runtime/api.zig +6 -0
  103. package/src/runtime/automation_snapshot.zig +4 -0
  104. package/src/runtime/automation_widget_dispatch.zig +48 -6
  105. package/src/runtime/builtin_bridge.zig +5 -2
  106. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  107. package/src/runtime/canvas_image_tests.zig +146 -2
  108. package/src/runtime/canvas_images.zig +35 -16
  109. package/src/runtime/canvas_limits.zig +13 -3
  110. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  111. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  112. package/src/runtime/canvas_widget_control_tests.zig +33 -1
  113. package/src/runtime/canvas_widget_events.zig +151 -26
  114. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  115. package/src/runtime/canvas_widget_runtime.zig +322 -102
  116. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  117. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  118. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  119. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  120. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  121. package/src/runtime/canvas_widget_state.zig +33 -7
  122. package/src/runtime/canvas_widget_text_tests.zig +124 -0
  123. package/src/runtime/core.zig +16 -0
  124. package/src/runtime/effects.zig +14 -14
  125. package/src/runtime/effects_image_tests.zig +91 -0
  126. package/src/runtime/gpu_surface_events.zig +25 -2
  127. package/src/runtime/native_command_event_tests.zig +29 -0
  128. package/src/runtime/root.zig +2 -0
  129. package/src/runtime/session_journal.zig +21 -2
  130. package/src/runtime/session_replay.zig +13 -8
  131. package/src/runtime/session_tests.zig +111 -4
  132. package/src/runtime/shell_layout_tests.zig +12 -0
  133. package/src/runtime/ts_core_host_tests.zig +47 -0
  134. package/src/runtime/ts_ui_app.zig +164 -1
  135. package/src/runtime/ui_app.zig +100 -21
  136. package/src/runtime/ui_app_tests.zig +351 -32
  137. package/src/runtime/ui_app_window_tests.zig +13 -1
  138. package/src/runtime/view.zig +3 -0
  139. package/src/runtime/view_widget_control.zig +18 -0
  140. package/src/runtime/view_widget_scroll.zig +112 -18
  141. package/src/runtime/view_widget_text.zig +1 -1
  142. package/src/runtime/view_widget_tree.zig +110 -13
  143. package/src/runtime/widget_bridge.zig +2 -0
  144. package/src/runtime/window_command_bridge_tests.zig +86 -0
  145. package/src/runtime/window_storage.zig +16 -1
  146. package/src/runtime/window_views.zig +1 -0
  147. package/src/tooling/ios.zig +3 -0
  148. package/src/tooling/manifest.zig +90 -2
  149. package/src/tooling/package.zig +67 -2
  150. package/src/tooling/raw_manifest.zig +10 -0
  151. package/src/tooling/templates.zig +128 -18
  152. package/src/tooling/verbs.zig +1 -0
  153. package/src/tooling/web_engine.zig +1 -1
  154. package/tools/corewire/emit.zig +31 -12
  155. package/tools/corewire/emit_facade.zig +57 -2
  156. package/tools/corewire/shim_rt.zig +20 -0
@@ -1,5 +1,6 @@
1
1
  const std = @import("std");
2
2
  const geometry = @import("geometry");
3
+ const app_manifest = @import("app_manifest");
3
4
  const platform = @import("../platform/root.zig");
4
5
  const protocol = @import("protocol.zig");
5
6
 
@@ -290,6 +291,12 @@ pub const Input = struct {
290
291
  windows: []const Window,
291
292
  views: []const platform.ViewInfo = &.{},
292
293
  widgets: []const Widget = &.{},
294
+ /// Static command and app-menu catalogs configured on the runtime.
295
+ /// These receipts let automation prove generated/ejected runners
296
+ /// loaded their manifest declarations before injecting command-source
297
+ /// events that cannot drive an OS menu tracking loop directly.
298
+ commands: []const app_manifest.Command = &.{},
299
+ menus: []const platform.Menu = &.{},
293
300
  diagnostics: Diagnostics = .{},
294
301
  /// Per-stage frame timing, non-null while `profile on` is active —
295
302
  /// printed as the `frame_profile` line right after the header.
@@ -595,6 +602,40 @@ pub fn writeText(input: Input, writer: anytype) !void {
595
602
  try writeWidgetContextMenu(widget, writer);
596
603
  try writer.writeByte('\n');
597
604
  }
605
+ for (input.commands) |command| {
606
+ try writer.writeAll("command id=");
607
+ try writeQuotedSnapshotText(command.id, writer);
608
+ try writer.writeAll(" title=");
609
+ try writeQuotedSnapshotText(command.title, writer);
610
+ try writer.print(" enabled={any} checked={any}\n", .{ command.enabled, command.checked });
611
+ }
612
+ for (input.menus) |menu| {
613
+ try writer.writeAll("app-menu title=");
614
+ try writeQuotedSnapshotText(menu.title, writer);
615
+ try writer.print(" items={d}\n", .{menu.items.len});
616
+ for (menu.items) |item| {
617
+ if (item.separator) {
618
+ try writer.writeAll(" app-menu-item separator\n");
619
+ continue;
620
+ }
621
+ try writer.writeAll(" app-menu-item label=");
622
+ try writeQuotedSnapshotText(item.label, writer);
623
+ try writer.writeAll(" command=");
624
+ try writeQuotedSnapshotText(item.command, writer);
625
+ try writer.print(" enabled={any} checked={any} key=", .{
626
+ item.enabled,
627
+ item.checked,
628
+ });
629
+ try writeQuotedSnapshotText(item.key, writer);
630
+ try writer.print(" modifiers=(primary={any},command={any},control={any},option={any},shift={any})\n", .{
631
+ item.modifiers.primary,
632
+ item.modifiers.command,
633
+ item.modifiers.control,
634
+ item.modifiers.option,
635
+ item.modifiers.shift,
636
+ });
637
+ }
638
+ }
598
639
  for (input.trays) |tray| {
599
640
  try writer.print("tray #{d} title=\"{s}\" visible={any} items={d}\n", .{ tray.id, tray.title, tray.visible, tray.items.len });
600
641
  for (tray.items) |item| {
@@ -726,6 +767,31 @@ pub fn writeA11yText(input: Input, writer: anytype) !void {
726
767
  }
727
768
  }
728
769
 
770
+ /// Catalog values are user-authored but snapshots are line-oriented. Keep
771
+ /// each configured command/menu record on exactly one line and preserve its
772
+ /// byte identity with JSON-style escapes for delimiters and control bytes.
773
+ fn writeQuotedSnapshotText(value: []const u8, writer: anytype) !void {
774
+ const hex = "0123456789abcdef";
775
+ try writer.writeByte('"');
776
+ for (value) |byte| {
777
+ switch (byte) {
778
+ '"' => try writer.writeAll("\\\""),
779
+ '\\' => try writer.writeAll("\\\\"),
780
+ '\n' => try writer.writeAll("\\n"),
781
+ '\r' => try writer.writeAll("\\r"),
782
+ '\t' => try writer.writeAll("\\t"),
783
+ else => if (byte < 0x20 or byte == 0x7f) {
784
+ try writer.writeAll("\\u00");
785
+ try writer.writeByte(hex[byte >> 4]);
786
+ try writer.writeByte(hex[byte & 0x0f]);
787
+ } else {
788
+ try writer.writeByte(byte);
789
+ },
790
+ }
791
+ }
792
+ try writer.writeByte('"');
793
+ }
794
+
729
795
  fn writeWidgetParent(widget: Widget, writer: anytype) !void {
730
796
  if (widget.parent_id) |parent_id| try writer.print(" parent=#{d}", .{parent_id});
731
797
  }
@@ -942,6 +1008,59 @@ test "snapshot emits tray title and dropdown items" {
942
1008
  try std.testing.expect(std.mem.indexOf(u8, empty_writer.buffered(), "tray") == null);
943
1009
  }
944
1010
 
1011
+ test "snapshot emits configured command and app-menu catalogs" {
1012
+ var buffer: [2048]u8 = undefined;
1013
+ var writer = std.Io.Writer.fixed(&buffer);
1014
+ const windows = [_]Window{.{ .title = "Test", .bounds = geometry.RectF.init(0, 0, 100, 100) }};
1015
+ const commands = [_]app_manifest.Command{
1016
+ .{ .id = "app.refresh", .title = "Refresh" },
1017
+ };
1018
+ const items = [_]platform.MenuItem{
1019
+ .{ .label = "Refresh", .command = "app.refresh", .key = "r", .modifiers = .{ .primary = true } },
1020
+ .{ .separator = true },
1021
+ };
1022
+ const menus = [_]platform.Menu{
1023
+ .{ .title = "View", .items = &items },
1024
+ };
1025
+ try writeText(.{
1026
+ .windows = &windows,
1027
+ .commands = &commands,
1028
+ .menus = &menus,
1029
+ }, &writer);
1030
+ const text = writer.buffered();
1031
+ try std.testing.expect(std.mem.indexOf(u8, text, "\ncommand id=\"app.refresh\" title=\"Refresh\" enabled=true checked=false\n") != null);
1032
+ try std.testing.expect(std.mem.indexOf(u8, text, "app-menu title=\"View\" items=2\n") != null);
1033
+ try std.testing.expect(std.mem.indexOf(u8, text, " app-menu-item label=\"Refresh\" command=\"app.refresh\" enabled=true checked=false key=\"r\" modifiers=(primary=true,command=false,control=false,option=false,shift=false)\n") != null);
1034
+ try std.testing.expect(std.mem.indexOf(u8, text, " app-menu-item separator\n") != null);
1035
+ }
1036
+
1037
+ test "snapshot escapes hostile command and app-menu catalog text" {
1038
+ var buffer: [2048]u8 = undefined;
1039
+ var writer = std.Io.Writer.fixed(&buffer);
1040
+ const windows = [_]Window{.{ .title = "Test", .bounds = geometry.RectF.init(0, 0, 100, 100) }};
1041
+ const commands = [_]app_manifest.Command{
1042
+ .{ .id = "app.\"quoted", .title = "Line 1\nLine 2\\tail\t\x01\x7f Café" },
1043
+ };
1044
+ const items = [_]platform.MenuItem{
1045
+ .{ .label = "Open \"now\"\rnext\\", .command = "app.\"run", .key = "r\t" },
1046
+ };
1047
+ const menus = [_]platform.Menu{
1048
+ .{ .title = "Tools\"\nInjected", .items = &items },
1049
+ };
1050
+ try writeText(.{
1051
+ .windows = &windows,
1052
+ .commands = &commands,
1053
+ .menus = &menus,
1054
+ }, &writer);
1055
+ const text = writer.buffered();
1056
+ try std.testing.expect(std.mem.indexOf(u8, text, "\ncommand id=\"app.\\\"quoted\" title=\"Line 1\\nLine 2\\\\tail\\t\\u0001\\u007f Café\" enabled=true checked=false\n") != null);
1057
+ try std.testing.expect(std.mem.indexOf(u8, text, "app-menu title=\"Tools\\\"\\nInjected\" items=1\n") != null);
1058
+ try std.testing.expect(std.mem.indexOf(u8, text, " app-menu-item label=\"Open \\\"now\\\"\\rnext\\\\\" command=\"app.\\\"run\" enabled=true checked=false key=\"r\\t\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
1059
+ // Header, window, command, menu, and item: hostile values inject no
1060
+ // additional records into the line-oriented snapshot.
1061
+ try std.testing.expectEqual(@as(usize, 5), std.mem.count(u8, text, "\n"));
1062
+ }
1063
+
945
1064
  test "accessibility snapshot uses visible view text as name" {
946
1065
  var buffer: [512]u8 = undefined;
947
1066
  var writer = std.Io.Writer.fixed(&buffer);
@@ -9,7 +9,7 @@ const mobile_build_options = @import("mobile_build_options");
9
9
  const relational_migrations = @import("relational_migrations");
10
10
 
11
11
  comptime {
12
- native_sdk.embed.exportMobileCApi(native_sdk.embed.UiAppHostWithStorageAndCredentials(
12
+ native_sdk.embed.exportMobileCApi(native_sdk.embed.UiAppHostWithStorageCredentialsAndImages(
13
13
  @import("app"),
14
14
  mobile_build_options.store_capability,
15
15
  mobile_build_options.relational_capability,
@@ -18,5 +18,6 @@ comptime {
18
18
  mobile_build_options.credentials_permission,
19
19
  mobile_build_options.filesystem_permission,
20
20
  mobile_build_options.credentials_service,
21
+ mobile_build_options.max_image_pixel_bytes,
21
22
  ));
22
23
  }
@@ -283,6 +283,7 @@ pub fn mobileWidgetRole(role: canvas.WidgetRole) MobileWidgetRole {
283
283
  .tab => .tab,
284
284
  .checkbox => .checkbox,
285
285
  .radio => .radio,
286
+ .radiogroup => .radiogroup,
286
287
  .switch_control => .switch_control,
287
288
  .slider => .slider,
288
289
  .progressbar => .progressbar,
@@ -3,6 +3,7 @@ const geometry = @import("geometry");
3
3
  const canvas = @import("canvas");
4
4
  const app_manifest = @import("app_manifest");
5
5
  const runtime = @import("../runtime/root.zig");
6
+ const canvas_limits = @import("../runtime/canvas_limits.zig");
6
7
  const platform = @import("../platform/root.zig");
7
8
  const automation = @import("../automation/root.zig");
8
9
  const types = @import("types.zig");
@@ -288,17 +289,19 @@ fn MobileImageBridge(comptime Host: type) type {
288
289
  return @alignCast(@fieldParentPtr("null_platform", null_platform));
289
290
  }
290
291
 
291
- fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform.DecodedImage {
292
+ fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform.DecodedImage {
292
293
  const image = &hostFromContext(context).image;
293
294
  const decode_fn = image.service.decode orelse return error.UnsupportedService;
294
295
  var width: usize = 0;
295
296
  var height: usize = 0;
296
- return switch (decode_fn(image.context, bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
297
+ return switch (decode_fn(image.context, bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
297
298
  1 => {
298
299
  if (width == 0 or height == 0) return error.ImageDecodeFailed;
299
300
  const row_len = std.math.mul(usize, width, 4) catch return error.ImageDecodeFailed;
300
301
  const byte_len = std.math.mul(usize, row_len, height) catch return error.ImageDecodeFailed;
301
302
  if (byte_len > buffer.len) return error.ImageDecodeFailed;
303
+ const pixel_count = std.math.mul(usize, width, height) catch return error.ImageDecodeFailed;
304
+ if (pixel_count > max_pixels) return error.ImageTooLarge;
302
305
  return .{ .width = width, .height = height, .rgba8 = buffer[0..byte_len] };
303
306
  },
304
307
  -1 => error.ImageTooLarge,
@@ -552,8 +555,12 @@ pub const EmbeddedApp = struct {
552
555
  }
553
556
 
554
557
  pub fn initInPlace(self: *EmbeddedApp, app: runtime.App, platform_value: platform.Platform) void {
558
+ self.initInPlaceWithImageBudget(app, platform_value, canvas_limits.max_registered_canvas_image_pixel_bytes);
559
+ }
560
+
561
+ pub fn initInPlaceWithImageBudget(self: *EmbeddedApp, app: runtime.App, platform_value: platform.Platform, max_image_pixel_bytes: usize) void {
555
562
  self.app = app;
556
- runtime.Runtime.initAt(&self.runtime, .{ .platform = platform_value });
563
+ runtime.Runtime.initAt(&self.runtime, .{ .platform = platform_value, .max_image_pixel_bytes = max_image_pixel_bytes });
557
564
  }
558
565
 
559
566
  /// End of the embedded lifecycle, symmetric with `init`/`initInPlace`:
@@ -31,6 +31,7 @@ pub const UiAppHost = ui_host.UiAppHost;
31
31
  pub const UiAppHostWithRecordStore = ui_host.UiAppHostWithRecordStore;
32
32
  pub const UiAppHostWithStorage = ui_host.UiAppHostWithStorage;
33
33
  pub const UiAppHostWithStorageAndCredentials = ui_host.UiAppHostWithStorageAndCredentials;
34
+ pub const UiAppHostWithStorageCredentialsAndImages = ui_host.UiAppHostWithStorageCredentialsAndImages;
34
35
  pub const mobile_shell_scene = ui_host.mobile_shell_scene;
35
36
  pub const MobileCApi = c_api.MobileCApi;
36
37
  pub const exportMobileCApi = c_api.exportMobileCApi;
@@ -651,6 +651,12 @@ test "mobile C ABI exposes GPU widget accessibility semantics" {
651
651
  .layout = .{ .gap = 2 },
652
652
  .children = &grid_rows,
653
653
  },
654
+ .{
655
+ .id = 14,
656
+ .kind = .radio_group,
657
+ .frame = geometry.RectF.init(12, 148, 120, 28),
658
+ .semantics = .{ .label = "Density" },
659
+ },
654
660
  };
655
661
  var nodes: [16]canvas.WidgetLayoutNode = undefined;
656
662
  const layout = try canvas.layoutWidgetTree(.{
@@ -661,7 +667,7 @@ test "mobile C ABI exposes GPU widget accessibility semantics" {
661
667
  }, geometry.RectF.init(0, 0, 320, 180), &nodes);
662
668
  _ = try self.embedded.runtime.setCanvasWidgetLayout(1, mobile_gpu_surface_label, layout);
663
669
 
664
- try std.testing.expectEqual(@as(usize, 13), native_sdk_app_widget_semantics_count(app));
670
+ try std.testing.expectEqual(@as(usize, 14), native_sdk_app_widget_semantics_count(app));
665
671
 
666
672
  var root_node: MobileWidgetSemantics = .{};
667
673
  try std.testing.expectEqual(@as(c_int, 1), native_sdk_app_widget_semantics_at(app, 0, &root_node));
@@ -737,6 +743,10 @@ test "mobile C ABI exposes GPU widget accessibility semantics" {
737
743
  try std.testing.expectEqual(@as(isize, 2), status_cell.grid_column_count);
738
744
  try std.testing.expect((status_cell.actions & @intFromEnum(MobileWidgetAction.select)) != 0);
739
745
 
746
+ const radio_group_node = try mobileWidgetSemanticsByIdForTest(app, 14);
747
+ try std.testing.expectEqual(@intFromEnum(MobileWidgetRole.radiogroup), radio_group_node.role);
748
+ try std.testing.expectEqualStrings("Density", radio_group_node.label.?[0..radio_group_node.label_len]);
749
+
740
750
  var text_geometry: MobileWidgetTextGeometry = .{};
741
751
  try std.testing.expectEqual(@as(c_int, 1), native_sdk_app_widget_text_geometry(app, 3, &text_geometry));
742
752
  try std.testing.expectEqual(@as(u64, 3), text_geometry.id);
@@ -2266,6 +2276,7 @@ fn recorderImageDecode(
2266
2276
  bytes_len: usize,
2267
2277
  pixels: ?[*]u8,
2268
2278
  pixels_len: usize,
2279
+ max_pixels: usize,
2269
2280
  out_width: ?*usize,
2270
2281
  out_height: ?*usize,
2271
2282
  ) callconv(.c) c_int {
@@ -2273,6 +2284,7 @@ fn recorderImageDecode(
2273
2284
  recorder.decode_count += 1;
2274
2285
  recorder.last_bytes_len = conversions.copyInputText(&recorder.last_bytes, if (bytes) |value| value[0..bytes_len] else "");
2275
2286
  recorder.last_pixels_len = pixels_len;
2287
+ _ = max_pixels;
2276
2288
  if (recorder.result != 1) return recorder.result;
2277
2289
  out_width.?.* = recorder.width;
2278
2290
  out_height.?.* = recorder.height;
@@ -28,6 +28,7 @@ pub const MobileWidgetRole = enum(c_int) {
28
28
  slider = 18,
29
29
  progressbar = 19,
30
30
  radio = 20,
31
+ radiogroup = 21,
31
32
  };
32
33
 
33
34
  pub const MobileWidgetFlag = enum(u32) {
@@ -345,6 +346,7 @@ pub const MobileImageDecodeFn = *const fn (
345
346
  bytes_len: usize,
346
347
  pixels: ?[*]u8,
347
348
  pixels_len: usize,
349
+ max_pixels: usize,
348
350
  out_width: ?*usize,
349
351
  out_height: ?*usize,
350
352
  ) callconv(.c) c_int;
@@ -105,6 +105,30 @@ pub fn UiAppHostWithStorageAndCredentials(
105
105
  comptime credentials_permitted: bool,
106
106
  comptime filesystem_permitted: bool,
107
107
  comptime credentials_service: []const u8,
108
+ ) type {
109
+ return UiAppHostWithStorageCredentialsAndImages(
110
+ AppDef,
111
+ record_store_enabled,
112
+ relational_store_enabled,
113
+ relational_migrations,
114
+ credentials_enabled,
115
+ credentials_permitted,
116
+ filesystem_permitted,
117
+ credentials_service,
118
+ 1024 * 1024,
119
+ );
120
+ }
121
+
122
+ pub fn UiAppHostWithStorageCredentialsAndImages(
123
+ comptime AppDef: type,
124
+ comptime record_store_enabled: bool,
125
+ comptime relational_store_enabled: bool,
126
+ comptime relational_migrations: []const runtime.relational_store.Migration,
127
+ comptime credentials_enabled: bool,
128
+ comptime credentials_permitted: bool,
129
+ comptime filesystem_permitted: bool,
130
+ comptime credentials_service: []const u8,
131
+ comptime max_image_pixel_bytes: usize,
108
132
  ) type {
109
133
  const features: runtime.UiAppFeatures = if (@hasDecl(AppDef, "features")) AppDef.features else .{};
110
134
  const RecordStoreType = if (record_store_enabled) runtime.RecordStore else void;
@@ -221,13 +245,13 @@ pub fn UiAppHostWithStorageAndCredentials(
221
245
  MobileUi.initInPlace(&self.ui, allocator, options);
222
246
  self.ui.model = AppDef.initModel();
223
247
  self.inner_app = self.ui.app();
224
- self.embedded.initInPlace(.{
248
+ self.embedded.initInPlaceWithImageBudget(.{
225
249
  .context = self,
226
250
  .name = options.name,
227
251
  .scene_fn = hostScene,
228
252
  .event_fn = hostEvent,
229
253
  .stop_fn = hostStop,
230
- }, self.null_platform.platform());
254
+ }, self.null_platform.platform(), max_image_pixel_bytes);
231
255
  // The NullPlatform map is for native test only. Installed mobile
232
256
  // apps start with no backing until the UIKit/Android shim
233
257
  // registers its OS credential service.
@@ -116,6 +116,7 @@ import javax.crypto.SecretKey;
116
116
  import javax.crypto.spec.GCMParameterSpec;
117
117
 
118
118
  public final class NativeSdkActivity extends Activity implements SurfaceHolder.Callback, Choreographer.FrameCallback {
119
+ private static final int MAX_DECODED_IMAGE_DIMENSION = 8192;
119
120
  private static final int TOUCH_MODE_IDLE = 0;
120
121
  // Touch down seen, under slop: undecided between tap / drag / scroll.
121
122
  private static final int TOUCH_MODE_PENDING = 1;
@@ -578,9 +579,42 @@ public final class NativeSdkActivity extends Activity implements SurfaceHolder.C
578
579
  // size[0]/size[1]), -1 when the decoded pixels do not fit the buffer,
579
580
  // 0 undecodable — the embed image service contract.
580
581
  @SuppressWarnings("unused") // called from android_host.c
581
- int imageDecode(byte[] encoded, ByteBuffer pixels, long[] size) {
582
- if (encoded == null || encoded.length == 0 || pixels == null || size == null || size.length < 2) return 0;
582
+ int imageDecode(byte[] encoded, ByteBuffer pixels, long maxPixels, long[] size) {
583
+ if (encoded == null || encoded.length == 0 || pixels == null || maxPixels <= 0 || size == null || size.length < 2) return 0;
583
584
  BitmapFactory.Options options = new BitmapFactory.Options();
585
+ options.inJustDecodeBounds = true;
586
+ BitmapFactory.decodeByteArray(encoded, 0, encoded.length, options);
587
+ int sourceWidth = options.outWidth;
588
+ int sourceHeight = options.outHeight;
589
+ if (sourceWidth <= 0 || sourceHeight <= 0) return 0;
590
+ long sourcePixels = (long)sourceWidth * sourceHeight;
591
+ int targetWidth = sourceWidth;
592
+ int targetHeight = sourceHeight;
593
+ if (sourcePixels > maxPixels || sourceWidth > MAX_DECODED_IMAGE_DIMENSION || sourceHeight > MAX_DECODED_IMAGE_DIMENSION) {
594
+ double areaScale = Math.sqrt((double)maxPixels / (double)sourcePixels);
595
+ double axisScale = (double)MAX_DECODED_IMAGE_DIMENSION / Math.max(sourceWidth, sourceHeight);
596
+ double scale = Math.min(1.0, Math.min(areaScale, axisScale));
597
+ targetWidth = Math.max(1, (int)Math.floor(sourceWidth * scale));
598
+ targetHeight = Math.max(1, (int)Math.floor(sourceHeight * scale));
599
+ while ((long)targetWidth * targetHeight > maxPixels) {
600
+ if (targetWidth > 1 && (targetHeight == 1 || targetWidth > targetHeight)) targetWidth--;
601
+ else targetHeight--;
602
+ }
603
+ }
604
+ int sampleSize = 1;
605
+ while (sampleSize <= (1 << 28)) {
606
+ int nextSampleSize = sampleSize << 1;
607
+ // BitmapFactory rounds a sampled dimension up rather than
608
+ // collapsing a one-pixel side to zero. Mirror that here so a
609
+ // panorama can still use the largest safe power-of-two decode
610
+ // sample before the exact resize below.
611
+ int sampledWidth = (sourceWidth - 1) / nextSampleSize + 1;
612
+ int sampledHeight = (sourceHeight - 1) / nextSampleSize + 1;
613
+ if (sampledWidth < targetWidth || sampledHeight < targetHeight) break;
614
+ sampleSize = nextSampleSize;
615
+ }
616
+ options.inJustDecodeBounds = false;
617
+ options.inSampleSize = sampleSize;
584
618
  options.inPreferredConfig = Bitmap.Config.ARGB_8888;
585
619
  // Straight alpha, matching the desktop decoders: the canvas
586
620
  // pipeline un-premultiplies nothing downstream.
@@ -603,8 +637,19 @@ public final class NativeSdkActivity extends Activity implements SurfaceHolder.C
603
637
  }
604
638
  long width = bitmap.getWidth();
605
639
  long height = bitmap.getHeight();
606
- // The dimension ceiling mirrors the iOS/macOS decode callback.
607
- if (width <= 0 || height <= 0 || width > 8192 || height > 8192) return 0;
640
+ if (width <= 0 || height <= 0) return 0;
641
+ if (width != targetWidth || height != targetHeight) {
642
+ Bitmap fitted = Bitmap.createScaledBitmap(bitmap, targetWidth, targetHeight, true);
643
+ bitmap.recycle();
644
+ if (fitted == null) return 0;
645
+ bitmap = fitted;
646
+ width = targetWidth;
647
+ height = targetHeight;
648
+ }
649
+ // Validate the final registered geometry, not BitmapFactory's
650
+ // intermediate power-of-two sample. In particular, 8193x1 must
651
+ // be allowed to reach the exact 8192x1 fit above.
652
+ if (width > MAX_DECODED_IMAGE_DIMENSION || height > MAX_DECODED_IMAGE_DIMENSION || width > maxPixels / height) return 0;
608
653
  size[0] = width;
609
654
  size[1] = height;
610
655
  long byteLen = width * height * 4;
@@ -801,7 +801,7 @@ JNIEXPORT void JNICALL Java_dev_native_1sdk_host_NativeSdkActivity_nativeSetCred
801
801
  // Returns 1 decoded (dimensions in out_width/out_height), -1 when the
802
802
  // decoded pixels do not fit pixels_len, 0 undecodable — the embed image
803
803
  // service contract (native_sdk_app.h).
804
- static int host_image_decode(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t *out_width, uintptr_t *out_height) {
804
+ static int host_image_decode(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t max_pixels, uintptr_t *out_width, uintptr_t *out_height) {
805
805
  (void)context;
806
806
  if (out_width) *out_width = 0;
807
807
  if (out_height) *out_height = 0;
@@ -823,7 +823,7 @@ static int host_image_decode(void *context, const uint8_t *bytes, uintptr_t byte
823
823
  (*env)->DeleteLocalRef(env, encoded);
824
824
  return 0;
825
825
  }
826
- jint result = (*env)->CallIntMethod(env, host_state.image_activity, host_state.image_decode_method, encoded, buffer, dims);
826
+ jint result = (*env)->CallIntMethod(env, host_state.image_activity, host_state.image_decode_method, encoded, buffer, (jlong)max_pixels, dims);
827
827
  if ((*env)->ExceptionCheck(env)) {
828
828
  (*env)->ExceptionClear(env);
829
829
  result = 0;
@@ -847,7 +847,7 @@ JNIEXPORT void JNICALL Java_dev_native_1sdk_host_NativeSdkActivity_nativeSetImag
847
847
  if (host_state.image_activity) (*env)->DeleteGlobalRef(env, host_state.image_activity);
848
848
  host_state.image_activity = (*env)->NewGlobalRef(env, self);
849
849
  jclass cls = (*env)->GetObjectClass(env, self);
850
- host_state.image_decode_method = (*env)->GetMethodID(env, cls, "imageDecode", "([BLjava/nio/ByteBuffer;[J)I");
850
+ host_state.image_decode_method = (*env)->GetMethodID(env, cls, "imageDecode", "([BLjava/nio/ByteBuffer;J[J)I");
851
851
  (*env)->DeleteLocalRef(env, cls);
852
852
  if (!host_state.image_activity || !host_state.image_decode_method) {
853
853
  NATIVE_SDK_LOGE("image_service registration failed");
@@ -239,7 +239,7 @@ void native_sdk_app_audio_event(void *app, int kind, uint64_t position_ms, uint6
239
239
  // declines image decoding honestly and image/avatar widgets keep their
240
240
  // fallback.
241
241
  typedef struct native_sdk_image_service {
242
- int (*decode)(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t *out_width, uintptr_t *out_height);
242
+ int (*decode)(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t max_pixels, uintptr_t *out_width, uintptr_t *out_height);
243
243
  } native_sdk_image_service_t;
244
244
  int native_sdk_app_set_image_service(void *app, const native_sdk_image_service_t *service, void *context);
245
245
  int native_sdk_app_set_automation_dir(void *app, const char *path, uintptr_t len);
@@ -0,0 +1,38 @@
1
+ #ifndef NATIVE_SDK_APPLE_IMAGE_FIT_H
2
+ #define NATIVE_SDK_APPLE_IMAGE_FIT_H
3
+
4
+ #include <math.h>
5
+ #include <stddef.h>
6
+
7
+ #define NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION 8192
8
+
9
+ /* ImageIO accepts a longest-side bound, then derives and rounds the other
10
+ * side itself. Choose a longest side whose CEILING-rounded companion still
11
+ * fits the caller's area budget, while also constraining pathological source
12
+ * panoramas to the codec seam's decoded-axis ceiling. Keeping this in one C
13
+ * header makes AppKit, CEF, and UIKit share exactly the same contract. */
14
+ static inline size_t native_sdk_apple_image_thumbnail_max_dimension(
15
+ size_t width,
16
+ size_t height,
17
+ size_t max_pixels
18
+ ) {
19
+ const size_t major = width > height ? width : height;
20
+ const size_t minor = width < height ? width : height;
21
+ if (major == 0 || minor == 0 || max_pixels == 0) return 0;
22
+ if (major <= max_pixels / minor && major <= NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) return major;
23
+
24
+ const double area_scale = sqrt((double)max_pixels / (double)major / (double)minor);
25
+ const double axis_scale = (double)NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION / (double)major;
26
+ const double scale = fmin(1.0, fmin(area_scale, axis_scale));
27
+ size_t dimension = (size_t)floor((double)major * scale);
28
+ if (dimension < 1) dimension = 1;
29
+ if (dimension > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) dimension = NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION;
30
+ while (dimension > 1) {
31
+ const size_t minor_ceiling = (size_t)ceill((long double)minor * (long double)dimension / (long double)major);
32
+ if (dimension <= max_pixels / minor_ceiling) break;
33
+ dimension -= 1;
34
+ }
35
+ return dimension;
36
+ }
37
+
38
+ #endif
@@ -6,3 +6,4 @@
6
6
 
7
7
  pub const uikit_host_m = @embedFile("uikit_host.m");
8
8
  pub const native_sdk_app_h = @embedFile("native_sdk_app.h");
9
+ pub const apple_image_fit_h = @embedFile("apple_image_fit.h");
@@ -257,7 +257,7 @@ void native_sdk_app_audio_event(void *app, int kind, uint64_t position_ms, uint6
257
257
  // declines image decoding honestly and image/avatar widgets keep their
258
258
  // fallback.
259
259
  typedef struct native_sdk_image_service {
260
- int (*decode)(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t *out_width, uintptr_t *out_height);
260
+ int (*decode)(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t max_pixels, uintptr_t *out_width, uintptr_t *out_height);
261
261
  } native_sdk_image_service_t;
262
262
  int native_sdk_app_set_image_service(void *app, const native_sdk_image_service_t *service, void *context);
263
263
  int native_sdk_app_set_automation_dir(void *app, const char *path, uintptr_t len);
@@ -102,11 +102,13 @@
102
102
  #import <Security/Security.h>
103
103
 
104
104
  #include <dlfcn.h>
105
+ #include <math.h>
105
106
  #include <mach-o/dyld.h>
106
107
  #include <stdlib.h>
107
108
  #include <string.h>
108
109
 
109
110
  #include "native_sdk_app.h"
111
+ #include "apple_image_fit.h"
110
112
 
111
113
  // ----------------------------------------------------------- credentials
112
114
  // Generic-password Keychain entries shared by the WebView bridge and core
@@ -956,29 +958,50 @@ static int NativeSdkAudioServiceSetVolume(void *context, double volume) {
956
958
  // because the canvas image pipeline expects straight alpha. Returns 1
957
959
  // decoded, -1 when the decoded pixels do not fit `pixels_len`, 0 for
958
960
  // undecodable bytes.
959
- static int NativeSdkImageServiceDecode(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t *out_width, uintptr_t *out_height) {
961
+ static int NativeSdkImageServiceDecode(void *context, const uint8_t *bytes, uintptr_t bytes_len, uint8_t *pixels, uintptr_t pixels_len, uintptr_t max_pixels, uintptr_t *out_width, uintptr_t *out_height) {
960
962
  (void)context;
961
963
  if (out_width) *out_width = 0;
962
964
  if (out_height) *out_height = 0;
963
- if (!bytes || bytes_len == 0 || !pixels) return 0;
965
+ if (!bytes || bytes_len == 0 || !pixels || max_pixels == 0) return 0;
964
966
  @autoreleasepool {
965
967
  NSData *data = [NSData dataWithBytesNoCopy:(void *)bytes length:bytes_len freeWhenDone:NO];
966
968
  CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
967
969
  if (!source) return 0;
968
- CGImageRef image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
970
+ CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
971
+ int64_t source_width_value = 0;
972
+ int64_t source_height_value = 0;
973
+ if (properties) {
974
+ CFNumberRef width_value = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
975
+ CFNumberRef height_value = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
976
+ if (width_value) CFNumberGetValue(width_value, kCFNumberSInt64Type, &source_width_value);
977
+ if (height_value) CFNumberGetValue(height_value, kCFNumberSInt64Type, &source_height_value);
978
+ CFRelease(properties);
979
+ }
980
+ size_t source_width = source_width_value > 0 ? (size_t)source_width_value : 0;
981
+ size_t source_height = source_height_value > 0 ? (size_t)source_height_value : 0;
982
+ CGImageRef image = NULL;
983
+ if (source_width > 0 && source_height > 0) {
984
+ const size_t max_dimension = native_sdk_apple_image_thumbnail_max_dimension(source_width, source_height, max_pixels);
985
+ NSDictionary *thumbnail_options = @{
986
+ (NSString *)kCGImageSourceCreateThumbnailFromImageAlways: @YES,
987
+ (NSString *)kCGImageSourceThumbnailMaxPixelSize: @(max_dimension),
988
+ (NSString *)kCGImageSourceCreateThumbnailWithTransform: @YES,
989
+ };
990
+ image = CGImageSourceCreateThumbnailAtIndex(source, 0, (__bridge CFDictionaryRef)thumbnail_options);
991
+ }
969
992
  CFRelease(source);
970
993
  if (!image) return 0;
971
994
 
972
995
  size_t width = CGImageGetWidth(image);
973
996
  size_t height = CGImageGetHeight(image);
974
- if (width == 0 || height == 0 || width > 8192 || height > 8192) {
997
+ if (width == 0 || height == 0 || width > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION || height > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) {
975
998
  CGImageRelease(image);
976
999
  return 0;
977
1000
  }
978
1001
  if (out_width) *out_width = width;
979
1002
  if (out_height) *out_height = height;
980
1003
  size_t byte_len = width * height * 4;
981
- if (byte_len / 4 / height != width || pixels_len < byte_len) {
1004
+ if (width > max_pixels / height || byte_len / 4 / height != width || pixels_len < byte_len) {
982
1005
  CGImageRelease(image);
983
1006
  return -1;
984
1007
  }
@@ -120,16 +120,20 @@ static void destroyChildWebViewsForWindow(Host *host, uint64_t window_id) {
120
120
 
121
121
  extern "C" {
122
122
 
123
- Host *native_sdk_gtk_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) {
123
+ Host *native_sdk_gtk_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) {
124
124
  (void)bundle_id;
125
125
  (void)bundle_id_len;
126
126
  (void)icon_path;
127
127
  (void)icon_path_len;
128
128
  (void)restore_frame;
129
+ (void)initial_placement;
130
+ (void)restore_policy;
129
131
  (void)resizable;
130
132
  (void)titlebar_style;
131
133
  (void)min_width;
132
134
  (void)min_height;
135
+ (void)show_policy;
136
+ (void)window_flags;
133
137
  Host *host = new Host();
134
138
  host->app_name = slice(app_name, app_name_len);
135
139
  host->window_title = slice(window_title, window_title_len);
@@ -250,12 +254,16 @@ void native_sdk_gtk_set_shortcuts(Host *host, const char *const *ids, const size
250
254
  (void)count;
251
255
  }
252
256
 
253
- int native_sdk_gtk_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) {
257
+ int native_sdk_gtk_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) {
254
258
  (void)restore_frame;
259
+ (void)initial_placement;
260
+ (void)restore_policy;
255
261
  (void)resizable;
256
262
  (void)titlebar_style;
257
263
  (void)min_width;
258
264
  (void)min_height;
265
+ (void)show_policy;
266
+ (void)window_flags;
259
267
  if (!host || host->windows.find(window_id) != host->windows.end()) return 0;
260
268
  Window window;
261
269
  window.id = window_id;