@native-sdk/cli 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/build/app.zig +357 -33
  2. package/build.zig +234 -11
  3. package/native-sdk.d.ts +8 -0
  4. package/package.json +10 -10
  5. package/packages/core/compile-surface/core.ts +70 -1
  6. package/packages/core/package-lock.json +11 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  9. package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
  10. package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
  11. package/packages/core/scripts/stage_external_services.mjs +1 -1
  12. package/packages/core/sdk/core.d.ts +75 -0
  13. package/packages/core/sdk/core.ts +170 -13
  14. package/packages/core/sdk/events.d.ts +53 -0
  15. package/packages/core/sdk/events.ts +78 -7
  16. package/packages/core/src/checker.ts +470 -2
  17. package/packages/core/src/cli.ts +13 -0
  18. package/packages/core/src/contract.ts +3 -1
  19. package/packages/core/src/devhost.ts +30 -1
  20. package/packages/core/src/devhost_journal.mjs +10 -8
  21. package/packages/core/src/diagnostics.ts +99 -8
  22. package/packages/core/src/frontend.ts +6 -0
  23. package/packages/core/src/infer.ts +24 -0
  24. package/skill-data/automation/SKILL.md +1 -1
  25. package/skill-data/native-ui/SKILL.md +18 -12
  26. package/skill-data/ts-core/SKILL.md +54 -21
  27. package/skill-data/ts-services/SKILL.md +4 -4
  28. package/skill-data/ts-services/references/service-surface.md +2 -1
  29. package/skill-data/zig/SKILL.md +1 -1
  30. package/src/app_runner/root.zig +122 -6
  31. package/src/app_runner/ts_core_main.zig +9 -4
  32. package/src/app_runner/ts_core_mobile.zig +241 -0
  33. package/src/app_runner/window_placement.zig +63 -0
  34. package/src/automation/protocol.zig +5 -1
  35. package/src/automation/snapshot.zig +8 -6
  36. package/src/embed/app_exports.zig +3 -1
  37. package/src/embed/conversions.zig +1 -0
  38. package/src/embed/host.zig +10 -3
  39. package/src/embed/root.zig +2 -0
  40. package/src/embed/tests.zig +41 -1
  41. package/src/embed/types.zig +2 -0
  42. package/src/embed/ui_host.zig +94 -4
  43. package/src/platform/android/NativeSdkActivity.java +49 -4
  44. package/src/platform/android/android_host.c +3 -3
  45. package/src/platform/android/native_sdk_app.h +1 -1
  46. package/src/platform/ios/apple_image_fit.h +38 -0
  47. package/src/platform/ios/files.zig +1 -0
  48. package/src/platform/ios/native_sdk_app.h +1 -1
  49. package/src/platform/ios/uikit_host.m +28 -5
  50. package/src/platform/linux/cef_host.cpp +17 -3
  51. package/src/platform/linux/gtk_host.c +243 -15
  52. package/src/platform/linux/gtk_host.h +5 -4
  53. package/src/platform/linux/root.zig +91 -11
  54. package/src/platform/macos/appkit_host.h +18 -11
  55. package/src/platform/macos/appkit_host.m +402 -128
  56. package/src/platform/macos/cef_host.mm +342 -122
  57. package/src/platform/macos/image_fit_test.m +44 -0
  58. package/src/platform/macos/root.zig +231 -39
  59. package/src/platform/null_platform.zig +251 -54
  60. package/src/platform/null_platform_tests.zig +97 -4
  61. package/src/platform/root.zig +12 -0
  62. package/src/platform/types.zig +174 -35
  63. package/src/platform/windows/root.zig +42 -13
  64. package/src/platform/windows/webview2_host.cpp +72 -11
  65. package/src/primitives/app_manifest/root.zig +3 -0
  66. package/src/primitives/app_manifest/tests.zig +24 -0
  67. package/src/primitives/app_manifest/types.zig +13 -0
  68. package/src/primitives/app_manifest/validation.zig +24 -0
  69. package/src/primitives/canvas/a11y_audit.zig +9 -7
  70. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  71. package/src/primitives/canvas/events.zig +50 -0
  72. package/src/primitives/canvas/layout_audit.zig +6 -6
  73. package/src/primitives/canvas/markdown.zig +4 -0
  74. package/src/primitives/canvas/markdown_tests.zig +1 -0
  75. package/src/primitives/canvas/png.zig +138 -0
  76. package/src/primitives/canvas/root.zig +13 -2
  77. package/src/primitives/canvas/text_span_tests.zig +5 -3
  78. package/src/primitives/canvas/text_spans.zig +2 -0
  79. package/src/primitives/canvas/text_tests.zig +20 -0
  80. package/src/primitives/canvas/ui.zig +55 -2
  81. package/src/primitives/canvas/ui_markup.zig +40 -13
  82. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  83. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  84. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  85. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  86. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  87. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  88. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  89. package/src/primitives/canvas/ui_schema.zig +17 -13
  90. package/src/primitives/canvas/ui_tests.zig +47 -0
  91. package/src/primitives/canvas/widget_access.zig +3 -3
  92. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  93. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  94. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  95. package/src/primitives/canvas/widget_layout.zig +333 -126
  96. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  97. package/src/primitives/canvas/widget_metrics.zig +7 -8
  98. package/src/primitives/canvas/widget_render.zig +76 -44
  99. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  100. package/src/primitives/canvas/widget_render_style.zig +58 -18
  101. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  102. package/src/primitives/canvas/widget_routing.zig +40 -34
  103. package/src/primitives/canvas/widget_runtime.zig +11 -2
  104. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  105. package/src/primitives/canvas/widget_semantics.zig +8 -3
  106. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  107. package/src/primitives/canvas/widget_tree.zig +99 -5
  108. package/src/primitives/canvas/widgets.zig +20 -7
  109. package/src/root.zig +10 -0
  110. package/src/runtime/api.zig +14 -0
  111. package/src/runtime/automation_commands.zig +35 -2
  112. package/src/runtime/automation_snapshot.zig +32 -24
  113. package/src/runtime/automation_widget_dispatch.zig +48 -6
  114. package/src/runtime/bridge_permission_tests.zig +35 -1
  115. package/src/runtime/bridge_responses.zig +1 -1
  116. package/src/runtime/builtin_bridge.zig +16 -3
  117. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  118. package/src/runtime/canvas_image_tests.zig +146 -2
  119. package/src/runtime/canvas_images.zig +35 -16
  120. package/src/runtime/canvas_limits.zig +13 -3
  121. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  122. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  123. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  124. package/src/runtime/canvas_widget_events.zig +151 -26
  125. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  126. package/src/runtime/canvas_widget_runtime.zig +322 -102
  127. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  128. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  129. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  130. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  131. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  132. package/src/runtime/canvas_widget_state.zig +33 -7
  133. package/src/runtime/core.zig +28 -6
  134. package/src/runtime/effects.zig +1337 -49
  135. package/src/runtime/effects_file_tests.zig +587 -0
  136. package/src/runtime/effects_image_tests.zig +91 -0
  137. package/src/runtime/effects_notification_tests.zig +11 -0
  138. package/src/runtime/file_access.zig +400 -0
  139. package/src/runtime/file_effect_crash_helper.zig +28 -0
  140. package/src/runtime/file_effect_crash_tests.zig +37 -0
  141. package/src/runtime/flow.zig +21 -9
  142. package/src/runtime/gpu_surface_events.zig +25 -2
  143. package/src/runtime/native_command_event_tests.zig +44 -2
  144. package/src/runtime/pty.zig +5 -2
  145. package/src/runtime/root.zig +7 -0
  146. package/src/runtime/session_blobs.zig +4 -1
  147. package/src/runtime/session_journal.zig +56 -5
  148. package/src/runtime/session_record.zig +38 -0
  149. package/src/runtime/session_replay.zig +110 -15
  150. package/src/runtime/session_tests.zig +192 -4
  151. package/src/runtime/shell_layout_tests.zig +12 -0
  152. package/src/runtime/state.zig +10 -0
  153. package/src/runtime/system_services.zig +129 -36
  154. package/src/runtime/ts_core_host.zig +281 -11
  155. package/src/runtime/ts_core_host_tests.zig +142 -1
  156. package/src/runtime/ts_ui_app.zig +461 -8
  157. package/src/runtime/ui_app.zig +330 -112
  158. package/src/runtime/ui_app_tests.zig +251 -25
  159. package/src/runtime/ui_app_window_tests.zig +74 -8
  160. package/src/runtime/validation.zig +20 -0
  161. package/src/runtime/view.zig +3 -0
  162. package/src/runtime/view_widget_control.zig +18 -0
  163. package/src/runtime/view_widget_scroll.zig +112 -18
  164. package/src/runtime/view_widget_tree.zig +110 -13
  165. package/src/runtime/widget_bridge.zig +2 -0
  166. package/src/runtime/window_command_bridge_tests.zig +86 -0
  167. package/src/runtime/window_storage.zig +16 -1
  168. package/src/runtime/window_views.zig +1 -0
  169. package/src/tooling/ios.zig +3 -0
  170. package/src/tooling/manifest.zig +90 -2
  171. package/src/tooling/package.zig +67 -2
  172. package/src/tooling/raw_manifest.zig +10 -0
  173. package/src/tooling/templates.zig +156 -18
  174. package/src/tooling/ts_core.zig +83 -0
  175. package/src/tooling/web_engine.zig +1 -1
  176. package/tools/corewire/emit.zig +3 -3
  177. package/tools/corewire/emit_facade.zig +65 -5
  178. package/tools/corewire/emit_profile.zig +2 -2
  179. package/tools/corewire/emit_service.zig +2 -2
  180. package/tools/corewire/service_contract.zig +4 -4
  181. package/tools/corewire/sidecar.zig +4 -4
@@ -233,6 +233,8 @@ pub const TrayItem = struct {
233
233
  /// The macOS menu bar is outside every window capture, so this is the
234
234
  /// only automation-visible evidence a model-driven tray exists.
235
235
  pub const Tray = struct {
236
+ id: platform.StatusItemId = platform.primary_status_item_id,
237
+ visible: bool = true,
236
238
  title: []const u8 = "",
237
239
  items: []const TrayItem = &.{},
238
240
  };
@@ -304,8 +306,8 @@ pub const Input = struct {
304
306
  /// headroom.
305
307
  text_layout_plan_budget: usize = 0,
306
308
  text_layout_line_budget: usize = 0,
307
- /// The live status item, when the app created one.
308
- tray: ?Tray = null,
309
+ /// Every live status item, keyed by its stable identifier.
310
+ trays: []const Tray = &.{},
309
311
  /// Live audio playback, when the app started any (null once stopped
310
312
  /// or failed — an idle player is honest, not zeroed-out noise).
311
313
  audio: ?Audio = null,
@@ -593,8 +595,8 @@ pub fn writeText(input: Input, writer: anytype) !void {
593
595
  try writeWidgetContextMenu(widget, writer);
594
596
  try writer.writeByte('\n');
595
597
  }
596
- if (input.tray) |tray| {
597
- try writer.print("tray title=\"{s}\" items={d}\n", .{ tray.title, tray.items.len });
598
+ for (input.trays) |tray| {
599
+ try writer.print("tray #{d} title=\"{s}\" visible={any} items={d}\n", .{ tray.id, tray.title, tray.visible, tray.items.len });
598
600
  for (tray.items) |item| {
599
601
  if (item.separator) {
600
602
  try writer.writeAll(" tray-item separator\n");
@@ -925,10 +927,10 @@ test "snapshot emits tray title and dropdown items" {
925
927
  };
926
928
  try writeText(.{
927
929
  .windows = &windows,
928
- .tray = .{ .title = "ZN 3", .items = &items },
930
+ .trays = &.{.{ .id = 7, .title = "ZN 3", .visible = false, .items = &items }},
929
931
  }, &writer);
930
932
  const text = writer.buffered();
931
- try std.testing.expect(std.mem.indexOf(u8, text, "\ntray title=\"ZN 3\" items=3\n") != null);
933
+ try std.testing.expect(std.mem.indexOf(u8, text, "\ntray #7 title=\"ZN 3\" visible=false items=3\n") != null);
932
934
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
933
935
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item separator\n") != null);
934
936
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false detail=\"warning ⚠\" role=agent key=\"q\" modifiers=(primary=false,command=true,control=false,option=false,shift=false)\n") != null);
@@ -9,13 +9,15 @@ 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,
16
16
  &relational_migrations.migrations,
17
17
  mobile_build_options.credentials_capability,
18
18
  mobile_build_options.credentials_permission,
19
+ mobile_build_options.filesystem_permission,
19
20
  mobile_build_options.credentials_service,
21
+ mobile_build_options.max_image_pixel_bytes,
20
22
  ));
21
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`:
@@ -23,6 +23,7 @@ pub const MobileImageService = types.MobileImageService;
23
23
  pub const MobileChromeItem = chrome.MobileChromeItem;
24
24
  pub const renderChromeIconPixels = chrome.renderIconPixels;
25
25
  pub const mobile_gpu_surface_label = types.mobile_gpu_surface_label;
26
+ pub const max_mobile_asset_root_bytes = types.max_mobile_asset_root_bytes;
26
27
 
27
28
  pub const EmbeddedApp = host.EmbeddedApp;
28
29
  pub const MobileHostApp = host.MobileHostApp;
@@ -30,6 +31,7 @@ pub const UiAppHost = ui_host.UiAppHost;
30
31
  pub const UiAppHostWithRecordStore = ui_host.UiAppHostWithRecordStore;
31
32
  pub const UiAppHostWithStorage = ui_host.UiAppHostWithStorage;
32
33
  pub const UiAppHostWithStorageAndCredentials = ui_host.UiAppHostWithStorageAndCredentials;
34
+ pub const UiAppHostWithStorageCredentialsAndImages = ui_host.UiAppHostWithStorageCredentialsAndImages;
33
35
  pub const mobile_shell_scene = ui_host.mobile_shell_scene;
34
36
  pub const MobileCApi = c_api.MobileCApi;
35
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);
@@ -982,6 +992,9 @@ test "mobile C ABI dispatches GPU widget accessibility actions" {
982
992
  // render pixels, touch that mutates the model, and IME text that lands in a
983
993
  // textbox — with NullPlatform standing in for the (M2) real surface.
984
994
 
995
+ var mobile_service_data_root: [types.max_mobile_asset_root_bytes]u8 = undefined;
996
+ var mobile_service_data_root_len: usize = 0;
997
+
985
998
  const MobileCounterDef = struct {
986
999
  pub const Model = struct {
987
1000
  count: u32 = 0,
@@ -1009,6 +1022,11 @@ const MobileCounterDef = struct {
1009
1022
  };
1010
1023
  }
1011
1024
 
1025
+ pub fn serviceDataRoot(root: []const u8) void {
1026
+ @memcpy(mobile_service_data_root[0..root.len], root);
1027
+ mobile_service_data_root_len = root.len;
1028
+ }
1029
+
1012
1030
  fn update(model: *Model, msg: Msg) void {
1013
1031
  switch (msg) {
1014
1032
  .increment => model.count += 1,
@@ -1044,6 +1062,7 @@ const MobileCredentialHost = ui_host.UiAppHostWithStorageAndCredentials(
1044
1062
  &.{},
1045
1063
  true,
1046
1064
  true,
1065
+ false,
1047
1066
  "dev.native-sdk.mobile-credentials",
1048
1067
  );
1049
1068
  const MobileCredentialApi = c_api.MobileCApi(MobileCredentialHost);
@@ -1210,6 +1229,10 @@ test "mobile store capability requires and binds the OS app-data root before sta
1210
1229
  try std.testing.expectEqual(@as(c_int, 1), MobileStoreApi.native_sdk_app_set_data_root(app, path.ptr, path.len));
1211
1230
  try std.testing.expect(self.record_store_open);
1212
1231
  try std.testing.expect(self.embedded.runtime.options.record_store != null);
1232
+ try std.testing.expectEqual(@as(usize, 6), self.embedded.runtime.options.file_access.?.roots.len);
1233
+ for (self.embedded.runtime.options.file_access.?.roots) |root| {
1234
+ try std.testing.expectEqualStrings(path, root);
1235
+ }
1213
1236
 
1214
1237
  MobileStoreApi.native_sdk_app_start(app);
1215
1238
  try std.testing.expectEqualStrings("", std.mem.span(MobileStoreApi.native_sdk_app_last_error_name(app)));
@@ -1221,6 +1244,21 @@ test "mobile store capability requires and binds the OS app-data root before sta
1221
1244
  MobileStoreApi.native_sdk_app_stop(app);
1222
1245
  }
1223
1246
 
1247
+ test "mobile host passes the complete maximum-length data root to app wiring" {
1248
+ const app = MobileCounterApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
1249
+ defer MobileCounterApi.native_sdk_app_destroy(app);
1250
+
1251
+ var root: [types.max_mobile_asset_root_bytes]u8 = @splat('a');
1252
+ root[0] = '.';
1253
+ mobile_service_data_root_len = 0;
1254
+ try std.testing.expectEqual(
1255
+ @as(c_int, 1),
1256
+ MobileCounterApi.native_sdk_app_set_data_root(app, &root, root.len),
1257
+ );
1258
+ try std.testing.expectEqual(root.len, mobile_service_data_root_len);
1259
+ try std.testing.expectEqualSlices(u8, &root, mobile_service_data_root[0..mobile_service_data_root_len]);
1260
+ }
1261
+
1224
1262
  test "mobile relational capability opens app.db from the OS app-data root" {
1225
1263
  const app = MobileRelationalApi.native_sdk_app_create() orelse return error.TestUnexpectedResult;
1226
1264
  defer MobileRelationalApi.native_sdk_app_destroy(app);
@@ -2238,6 +2276,7 @@ fn recorderImageDecode(
2238
2276
  bytes_len: usize,
2239
2277
  pixels: ?[*]u8,
2240
2278
  pixels_len: usize,
2279
+ max_pixels: usize,
2241
2280
  out_width: ?*usize,
2242
2281
  out_height: ?*usize,
2243
2282
  ) callconv(.c) c_int {
@@ -2245,6 +2284,7 @@ fn recorderImageDecode(
2245
2284
  recorder.decode_count += 1;
2246
2285
  recorder.last_bytes_len = conversions.copyInputText(&recorder.last_bytes, if (bytes) |value| value[0..bytes_len] else "");
2247
2286
  recorder.last_pixels_len = pixels_len;
2287
+ _ = max_pixels;
2248
2288
  if (recorder.result != 1) return recorder.result;
2249
2289
  out_width.?.* = recorder.width;
2250
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;
@@ -14,6 +14,10 @@
14
14
  //! `canvas_label` must be `mobile-surface` (use `mobile_shell_scene` /
15
15
  //! `mobile_gpu_surface_label` for the canonical single-surface scene).
16
16
  //! - optional `pub const features: native_sdk.UiAppFeatures`
17
+ //! - optional `pub fn serviceDataRoot([]const u8) void` /
18
+ //! `pub fn serviceTeardown() void` — the generated TypeScript mobile
19
+ //! wiring's hooks: the host hands `setDataRoot`'s directory to the
20
+ //! in-process service pool and tears the pool down on destroy.
17
21
  //!
18
22
  //! The host owns a `NullPlatform` runtime (M1: no real surface — M2 adds
19
23
  //! presentation) and pumps the `UiApp` loop from the shim's frame callback:
@@ -24,10 +28,12 @@
24
28
  //! the ABI via `native_sdk_app_render_pixels`.
25
29
 
26
30
  const std = @import("std");
31
+ const builtin = @import("builtin");
27
32
  const app_manifest = @import("app_manifest");
28
33
  const canvas = @import("canvas");
29
34
  const runtime = @import("../runtime/root.zig");
30
35
  const platform = @import("../platform/root.zig");
36
+ const app_dirs = @import("app_dirs");
31
37
  const security = @import("../security/root.zig");
32
38
  const types = @import("types.zig");
33
39
  const host = @import("host.zig");
@@ -83,6 +89,7 @@ pub fn UiAppHostWithStorage(
83
89
  relational_migrations,
84
90
  false,
85
91
  false,
92
+ false,
86
93
  "dev.native_sdk.app",
87
94
  );
88
95
  }
@@ -96,7 +103,32 @@ pub fn UiAppHostWithStorageAndCredentials(
96
103
  comptime relational_migrations: []const runtime.relational_store.Migration,
97
104
  comptime credentials_enabled: bool,
98
105
  comptime credentials_permitted: bool,
106
+ comptime filesystem_permitted: bool,
99
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,
100
132
  ) type {
101
133
  const features: runtime.UiAppFeatures = if (@hasDecl(AppDef, "features")) AppDef.features else .{};
102
134
  const RecordStoreType = if (record_store_enabled) runtime.RecordStore else void;
@@ -125,6 +157,8 @@ pub fn UiAppHostWithStorageAndCredentials(
125
157
  asset_root_len: usize = 0,
126
158
  asset_entry: [max_mobile_asset_entry_bytes]u8 = undefined,
127
159
  asset_entry_len: usize = 0,
160
+ file_root_storage: [6][max_mobile_asset_root_bytes]u8 = undefined,
161
+ file_roots: [6][]const u8 = undefined,
128
162
  automation_dir: [max_mobile_asset_root_bytes]u8 = undefined,
129
163
  automation_dir_len: usize = 0,
130
164
  automation_io: ?*std.Io.Threaded = null,
@@ -191,6 +225,8 @@ pub fn UiAppHostWithStorageAndCredentials(
191
225
  self.asset_root_len = 0;
192
226
  self.asset_entry = undefined;
193
227
  self.asset_entry_len = 0;
228
+ self.file_root_storage = undefined;
229
+ self.file_roots = undefined;
194
230
  self.automation_dir = undefined;
195
231
  self.automation_dir_len = 0;
196
232
  self.automation_io = null;
@@ -209,22 +245,33 @@ pub fn UiAppHostWithStorageAndCredentials(
209
245
  MobileUi.initInPlace(&self.ui, allocator, options);
210
246
  self.ui.model = AppDef.initModel();
211
247
  self.inner_app = self.ui.app();
212
- self.embedded.initInPlace(.{
248
+ self.embedded.initInPlaceWithImageBudget(.{
213
249
  .context = self,
214
250
  .name = options.name,
215
251
  .scene_fn = hostScene,
216
252
  .event_fn = hostEvent,
217
253
  .stop_fn = hostStop,
218
- }, self.null_platform.platform());
254
+ }, self.null_platform.platform(), max_image_pixel_bytes);
219
255
  // The NullPlatform map is for native test only. Installed mobile
220
256
  // apps start with no backing until the UIKit/Android shim
221
257
  // registers its OS credential service.
222
258
  try host.setCredentialService(self, .{}, null);
223
259
  self.embedded.runtime.options.credentials_enabled = credentials_enabled;
224
- self.embedded.runtime.options.security.permissions = if (credentials_permitted)
260
+ self.embedded.runtime.options.security.permissions = if (credentials_permitted and filesystem_permitted)
261
+ &.{ security.permission_credentials, security.permission_filesystem }
262
+ else if (credentials_permitted)
225
263
  &.{security.permission_credentials}
264
+ else if (filesystem_permitted)
265
+ &.{security.permission_filesystem}
226
266
  else
227
267
  &.{};
268
+ // Until the OS data root is installed, fail closed for ungranted
269
+ // raw paths. A filesystem grant is sufficient on its own.
270
+ self.embedded.runtime.options.file_access = .{
271
+ .roots = &.{},
272
+ .permitted = filesystem_permitted,
273
+ .enforce = true,
274
+ };
228
275
  // The damage seam: capture pixel presents (chained through
229
276
  // the null platform's recording present, so nonblank
230
277
  // sampling keeps working), drop the packet presenters no
@@ -247,6 +294,11 @@ pub fn UiAppHostWithStorageAndCredentials(
247
294
  // its heap-owned registrations (registered canvas font
248
295
  // bytes) before the host storage goes.
249
296
  self.embedded.deinit();
297
+ // An AppDef owning module-level service state (the generated
298
+ // TypeScript mobile wiring's in-process pool) tears it down
299
+ // after the effects channel is gone; the pool's own shutdown
300
+ // already ran through the binding.
301
+ if (comptime @hasDecl(AppDef, "serviceTeardown")) AppDef.serviceTeardown();
250
302
  if (comptime record_store_enabled) {
251
303
  if (self.record_store_open) self.record_store.deinit();
252
304
  }
@@ -284,10 +336,48 @@ pub fn UiAppHostWithStorageAndCredentials(
284
336
  /// Install the OS-owned app-data directory before start. iOS passes
285
337
  /// Library/Application Support and Android passes files/, exactly the
286
338
  /// `.data` directories resolved by `app_dirs` on those platforms.
339
+ /// An AppDef declaring `serviceDataRoot` (the generated TypeScript
340
+ /// mobile wiring) receives the directory too — the in-process
341
+ /// service pool keeps its cooperative-cancellation markers and
342
+ /// stream relays there, and cores reading `NATIVE_SDK_APP_DATA_DIR`
343
+ /// through `envMsgs` get this value.
287
344
  pub fn setDataRoot(self: *Self, data_root: []const u8) !void {
288
- if (comptime !record_store_enabled and !relational_store_enabled) return;
289
345
  if (self.started) return error.AppAlreadyStarted;
290
346
  if (data_root.len == 0 or data_root.len > max_mobile_asset_root_bytes) return error.InvalidStoreDataDir;
347
+ if (comptime @hasDecl(AppDef, "serviceDataRoot")) AppDef.serviceDataRoot(data_root);
348
+ const platform_value = app_dirs.currentPlatform();
349
+ if (builtin.is_test and platform_value != .ios and platform_value != .android) {
350
+ for (&self.file_root_storage, 0..) |*storage, index| {
351
+ @memcpy(storage[0..data_root.len], data_root);
352
+ self.file_roots[index] = storage[0..data_root.len];
353
+ }
354
+ self.embedded.runtime.options.file_access = .{
355
+ .roots = &self.file_roots,
356
+ .permitted = filesystem_permitted,
357
+ .enforce = true,
358
+ };
359
+ } else {
360
+ const home = switch (platform_value) {
361
+ // iOS data_root is HOME/Library/Application Support.
362
+ .ios => std.fs.path.dirname(std.fs.path.dirname(data_root) orelse return error.InvalidStoreDataDir) orelse return error.InvalidStoreDataDir,
363
+ // Android data_root is HOME/files.
364
+ .android => std.fs.path.dirname(data_root) orelse return error.InvalidStoreDataDir,
365
+ else => return error.InvalidStoreDataDir,
366
+ };
367
+ const dir_buffers = app_dirs.Buffers.fromArray(max_mobile_asset_root_bytes, &self.file_root_storage);
368
+ const dirs = try app_dirs.resolve(
369
+ .{ .name = credentials_service },
370
+ platform_value,
371
+ .{ .home = home },
372
+ dir_buffers,
373
+ );
374
+ self.file_roots = .{ dirs.config, dirs.cache, dirs.data, dirs.state, dirs.logs, dirs.temp };
375
+ self.embedded.runtime.options.file_access = .{
376
+ .roots = &self.file_roots,
377
+ .permitted = filesystem_permitted,
378
+ .enforce = true,
379
+ };
380
+ }
291
381
  if (comptime record_store_enabled) {
292
382
  if (self.record_store_open) {
293
383
  self.record_store.deinit();
@@ -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);