@native-sdk/cli 0.9.1 → 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 (130) hide show
  1. package/build/app.zig +26 -9
  2. package/build.zig +55 -0
  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/skill-data/native-ui/SKILL.md +7 -7
  8. package/skill-data/ts-core/SKILL.md +1 -1
  9. package/src/app_runner/root.zig +93 -6
  10. package/src/app_runner/ts_core_main.zig +4 -4
  11. package/src/app_runner/window_placement.zig +63 -0
  12. package/src/embed/app_exports.zig +2 -1
  13. package/src/embed/conversions.zig +1 -0
  14. package/src/embed/host.zig +10 -3
  15. package/src/embed/root.zig +1 -0
  16. package/src/embed/tests.zig +13 -1
  17. package/src/embed/types.zig +2 -0
  18. package/src/embed/ui_host.zig +26 -2
  19. package/src/platform/android/NativeSdkActivity.java +49 -4
  20. package/src/platform/android/android_host.c +3 -3
  21. package/src/platform/android/native_sdk_app.h +1 -1
  22. package/src/platform/ios/apple_image_fit.h +38 -0
  23. package/src/platform/ios/files.zig +1 -0
  24. package/src/platform/ios/native_sdk_app.h +1 -1
  25. package/src/platform/ios/uikit_host.m +28 -5
  26. package/src/platform/linux/cef_host.cpp +10 -2
  27. package/src/platform/linux/gtk_host.c +43 -10
  28. package/src/platform/linux/gtk_host.h +3 -3
  29. package/src/platform/linux/root.zig +22 -7
  30. package/src/platform/macos/appkit_host.h +7 -4
  31. package/src/platform/macos/appkit_host.m +192 -40
  32. package/src/platform/macos/cef_host.mm +132 -34
  33. package/src/platform/macos/image_fit_test.m +44 -0
  34. package/src/platform/macos/root.zig +154 -9
  35. package/src/platform/null_platform.zig +17 -3
  36. package/src/platform/null_platform_tests.zig +58 -4
  37. package/src/platform/root.zig +2 -0
  38. package/src/platform/types.zig +69 -19
  39. package/src/platform/windows/root.zig +22 -7
  40. package/src/platform/windows/webview2_host.cpp +31 -6
  41. package/src/primitives/app_manifest/root.zig +3 -0
  42. package/src/primitives/app_manifest/tests.zig +24 -0
  43. package/src/primitives/app_manifest/types.zig +13 -0
  44. package/src/primitives/app_manifest/validation.zig +24 -0
  45. package/src/primitives/canvas/a11y_audit.zig +9 -7
  46. package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
  47. package/src/primitives/canvas/events.zig +50 -0
  48. package/src/primitives/canvas/layout_audit.zig +6 -6
  49. package/src/primitives/canvas/markdown.zig +4 -0
  50. package/src/primitives/canvas/markdown_tests.zig +1 -0
  51. package/src/primitives/canvas/png.zig +138 -0
  52. package/src/primitives/canvas/root.zig +13 -2
  53. package/src/primitives/canvas/text_span_tests.zig +5 -3
  54. package/src/primitives/canvas/text_spans.zig +2 -0
  55. package/src/primitives/canvas/text_tests.zig +20 -0
  56. package/src/primitives/canvas/ui.zig +55 -2
  57. package/src/primitives/canvas/ui_markup.zig +40 -13
  58. package/src/primitives/canvas/ui_markup_binary.zig +8 -6
  59. package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
  60. package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
  61. package/src/primitives/canvas/ui_markup_compiled_tests.zig +52 -0
  62. package/src/primitives/canvas/ui_markup_tests.zig +11 -2
  63. package/src/primitives/canvas/ui_markup_view.zig +8 -2
  64. package/src/primitives/canvas/ui_markup_view_tests.zig +49 -4
  65. package/src/primitives/canvas/ui_schema.zig +17 -13
  66. package/src/primitives/canvas/ui_tests.zig +47 -0
  67. package/src/primitives/canvas/widget_access.zig +3 -3
  68. package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
  69. package/src/primitives/canvas/widget_builtin_tests.zig +580 -32
  70. package/src/primitives/canvas/widget_invalidation.zig +33 -6
  71. package/src/primitives/canvas/widget_layout.zig +333 -126
  72. package/src/primitives/canvas/widget_layout_tests.zig +169 -0
  73. package/src/primitives/canvas/widget_metrics.zig +7 -8
  74. package/src/primitives/canvas/widget_render.zig +76 -44
  75. package/src/primitives/canvas/widget_render_controls.zig +110 -32
  76. package/src/primitives/canvas/widget_render_style.zig +58 -18
  77. package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
  78. package/src/primitives/canvas/widget_routing.zig +40 -34
  79. package/src/primitives/canvas/widget_runtime.zig +11 -2
  80. package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
  81. package/src/primitives/canvas/widget_semantics.zig +8 -3
  82. package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
  83. package/src/primitives/canvas/widget_tree.zig +99 -5
  84. package/src/primitives/canvas/widgets.zig +20 -7
  85. package/src/root.zig +3 -0
  86. package/src/runtime/api.zig +6 -0
  87. package/src/runtime/automation_widget_dispatch.zig +48 -6
  88. package/src/runtime/builtin_bridge.zig +5 -2
  89. package/src/runtime/canvas_frame_packet_tests.zig +22 -13
  90. package/src/runtime/canvas_image_tests.zig +146 -2
  91. package/src/runtime/canvas_images.zig +35 -16
  92. package/src/runtime/canvas_limits.zig +13 -3
  93. package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
  94. package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
  95. package/src/runtime/canvas_widget_control_tests.zig +31 -1
  96. package/src/runtime/canvas_widget_events.zig +151 -26
  97. package/src/runtime/canvas_widget_floating_tests.zig +48 -0
  98. package/src/runtime/canvas_widget_runtime.zig +322 -102
  99. package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
  100. package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
  101. package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
  102. package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
  103. package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
  104. package/src/runtime/canvas_widget_state.zig +33 -7
  105. package/src/runtime/core.zig +16 -0
  106. package/src/runtime/effects.zig +14 -14
  107. package/src/runtime/effects_image_tests.zig +91 -0
  108. package/src/runtime/gpu_surface_events.zig +25 -2
  109. package/src/runtime/root.zig +2 -0
  110. package/src/runtime/session_replay.zig +13 -8
  111. package/src/runtime/session_tests.zig +111 -4
  112. package/src/runtime/shell_layout_tests.zig +12 -0
  113. package/src/runtime/ts_core_host_tests.zig +47 -0
  114. package/src/runtime/ui_app.zig +9 -3
  115. package/src/runtime/ui_app_tests.zig +119 -19
  116. package/src/runtime/ui_app_window_tests.zig +13 -1
  117. package/src/runtime/view.zig +3 -0
  118. package/src/runtime/view_widget_control.zig +18 -0
  119. package/src/runtime/view_widget_scroll.zig +112 -18
  120. package/src/runtime/view_widget_tree.zig +110 -13
  121. package/src/runtime/widget_bridge.zig +2 -0
  122. package/src/runtime/window_command_bridge_tests.zig +86 -0
  123. package/src/runtime/window_storage.zig +16 -1
  124. package/src/runtime/window_views.zig +1 -0
  125. package/src/tooling/ios.zig +3 -0
  126. package/src/tooling/manifest.zig +90 -2
  127. package/src/tooling/package.zig +67 -2
  128. package/src/tooling/raw_manifest.zig +10 -0
  129. package/src/tooling/templates.zig +128 -18
  130. package/src/tooling/web_engine.zig +1 -1
@@ -26,6 +26,8 @@
26
26
  #include <string.h>
27
27
  #include <time.h>
28
28
 
29
+ #include "../ios/apple_image_fit.h"
30
+
29
31
  @class NativeSdkAppKitHost;
30
32
  @class NativeSdkAudioCaptureTarget;
31
33
  @class NativeSdkScreenAudioCapture;
@@ -99,7 +101,11 @@ static void *NativeSdkAppKitVideoTimeControlContext = &NativeSdkAppKitVideoTimeC
99
101
  /* Render-thread ring state for the spectrum tap; defined with the rest
100
102
  * of the spectrum machinery in the audio section below. */
101
103
  typedef struct native_sdk_spectrum_tap_state native_sdk_spectrum_tap_state_t;
102
- static NSRect constrainFrame(NSRect frame);
104
+ static NSScreen *NativeSdkPrimaryScreen(void);
105
+ static NSScreen *NativeSdkScreenForFrame(NSRect frame);
106
+ static NSRect NativeSdkConstrainFrameToScreen(NSRect frame, NSScreen *screen);
107
+ static NSRect NativeSdkConstrainFrame(NSRect frame);
108
+ static NSRect NativeSdkCenterFrameOnScreen(NSRect frame, NSScreen *screen);
103
109
  static NSString *NativeSdkAppKitBridgeScript(void);
104
110
  static NSString *NativeSdkMenuKeyEquivalent(NSString *key);
105
111
  static NSString *NativeSdkMimeTypeForPath(NSString *path);
@@ -267,6 +273,8 @@ static NSAccessibilityRole NativeSdkAccessibilityRoleForWidgetRole(NSInteger rol
267
273
  return NSAccessibilityCheckBoxRole;
268
274
  case NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIO:
269
275
  return NSAccessibilityRadioButtonRole;
276
+ case NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIOGROUP:
277
+ return NSAccessibilityRadioGroupRole;
270
278
  case NATIVE_SDK_APPKIT_WIDGET_ROLE_MENU:
271
279
  return NSAccessibilityMenuRole;
272
280
  case NATIVE_SDK_APPKIT_WIDGET_ROLE_MENUITEM:
@@ -470,6 +478,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
470
478
  @property(nonatomic, assign) uint32_t actionFlags;
471
479
  @property(nonatomic, assign) BOOL canUndo;
472
480
  @property(nonatomic, assign) BOOL canRedo;
481
+ @property(nonatomic, assign) NSRect surfaceFrame;
473
482
  - (BOOL)emitSetTextAccessibilityValue:(id)value;
474
483
  - (BOOL)emitSetSelectionAccessibilityValue:(id)value;
475
484
  @end
@@ -665,6 +674,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
665
674
  @property(nonatomic, assign) NSRange selectedTextRange;
666
675
  @property(nonatomic, assign) BOOL interpretedKeyEventEmittedInput;
667
676
  @property(nonatomic, strong) NSArray<NSAccessibilityElement *> *widgetAccessibilityElements;
677
+ @property(nonatomic, strong) NSArray<NSAccessibilityElement *> *widgetAccessibilityRootElements;
668
678
  @property(nonatomic, strong) NSMutableArray<NativeSdkScrollDriverView *> *scrollDrivers;
669
679
  @property(nonatomic, assign) NSPoint wheelGesturePoint;
670
680
  @property(nonatomic, assign) BOOL wheelGestureActive;
@@ -743,7 +753,7 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
743
753
  - (void)updateSurfaceTrackingArea;
744
754
  - (void)emitSelectAllTextInputCommand;
745
755
  - (void)emitTextInputEventWithKind:(NSInteger)kind text:(NSString *)text compositionCursor:(NSInteger)compositionCursor;
746
- - (NSAccessibilityElement *)focusedTextAccessibilityElement;
756
+ - (NativeSdkWidgetAccessibilityElement *)focusedTextAccessibilityElement;
747
757
  - (BOOL)emitWidgetAccessibilityActionWithId:(uint64_t)widgetId action:(NSInteger)action;
748
758
  - (BOOL)emitWidgetAccessibilityActionWithId:(uint64_t)widgetId action:(NSInteger)action text:(NSString *)text selectedRange:(NSRange)selectedRange hasSelectedRange:(BOOL)hasSelectedRange;
749
759
  - (void)setSurfaceCursor:(NSCursor *)cursor;
@@ -1013,8 +1023,8 @@ static int NativeSdkCredentialStatus(OSStatus status, int missingCode) {
1013
1023
  @property(nonatomic, strong) NSArray<NSString *> *allowedNavigationOrigins;
1014
1024
  @property(nonatomic, strong) NSArray<NSString *> *allowedExternalURLs;
1015
1025
  @property(nonatomic, assign) NSInteger externalLinkAction;
1016
- - (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags;
1017
- - (BOOL)createWindowWithId:(uint64_t)windowId title:(NSString *)title label:(NSString *)label x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags makeMain:(BOOL)makeMain;
1026
+ - (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags;
1027
+ - (BOOL)createWindowWithId:(uint64_t)windowId title:(NSString *)title label:(NSString *)label x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags makeMain:(BOOL)makeMain;
1018
1028
  - (void)orderWindowForImplicitShow:(uint64_t)windowId;
1019
1029
  - (void)showDeferredWindowIfPending:(uint64_t)windowId reason:(const char *)reason;
1020
1030
  - (void)applyWindowClearColor:(uint64_t)windowId red:(uint8_t)red green:(uint8_t)green blue:(uint8_t)blue alpha:(uint8_t)alpha;
@@ -2536,28 +2546,48 @@ int native_sdk_appkit_measure_text_advances(uint64_t font_id, double size, const
2536
2546
  // CGBitmapContext can render into) and is un-premultiplied in place,
2537
2547
  // because the canvas image pipeline — the reference renderer and the
2538
2548
  // packet host's kCGImageAlphaLast upload — expects straight alpha.
2539
- int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height) {
2549
+ int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t max_pixels, size_t *out_width, size_t *out_height) {
2540
2550
  if (out_width) *out_width = 0;
2541
2551
  if (out_height) *out_height = 0;
2542
- if (!bytes || bytes_len == 0 || !pixels) return 0;
2552
+ if (!bytes || bytes_len == 0 || !pixels || max_pixels == 0) return 0;
2543
2553
  @autoreleasepool {
2544
2554
  NSData *data = [NSData dataWithBytesNoCopy:(void *)bytes length:bytes_len freeWhenDone:NO];
2545
2555
  CGImageRef image = NULL;
2546
2556
  CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL);
2547
2557
  if (source) {
2548
- image = CGImageSourceCreateImageAtIndex(source, 0, NULL);
2558
+ CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(source, 0, NULL);
2559
+ int64_t source_width_value = 0;
2560
+ int64_t source_height_value = 0;
2561
+ if (properties) {
2562
+ CFNumberRef width_value = CFDictionaryGetValue(properties, kCGImagePropertyPixelWidth);
2563
+ CFNumberRef height_value = CFDictionaryGetValue(properties, kCGImagePropertyPixelHeight);
2564
+ if (width_value) CFNumberGetValue(width_value, kCFNumberSInt64Type, &source_width_value);
2565
+ if (height_value) CFNumberGetValue(height_value, kCFNumberSInt64Type, &source_height_value);
2566
+ CFRelease(properties);
2567
+ }
2568
+ size_t source_width = source_width_value > 0 ? (size_t)source_width_value : 0;
2569
+ size_t source_height = source_height_value > 0 ? (size_t)source_height_value : 0;
2570
+ if (source_width > 0 && source_height > 0) {
2571
+ const size_t max_dimension = native_sdk_apple_image_thumbnail_max_dimension(source_width, source_height, max_pixels);
2572
+ NSDictionary *thumbnail_options = @{
2573
+ (NSString *)kCGImageSourceCreateThumbnailFromImageAlways: @YES,
2574
+ (NSString *)kCGImageSourceThumbnailMaxPixelSize: @(max_dimension),
2575
+ (NSString *)kCGImageSourceCreateThumbnailWithTransform: @YES,
2576
+ };
2577
+ image = CGImageSourceCreateThumbnailAtIndex(source, 0, (__bridge CFDictionaryRef)thumbnail_options);
2578
+ }
2549
2579
  CFRelease(source);
2550
2580
  }
2551
2581
  if (!image) {
2552
2582
  NSImage *system_image = [[NSImage alloc] initWithData:data];
2553
2583
  NSSize size = system_image ? system_image.size : NSZeroSize;
2554
- if (size.width > 0 && size.height > 0 && size.width <= 8192 && size.height <= 8192) {
2584
+ if (size.width > 0 && size.height > 0 && isfinite(size.width) && isfinite(size.height)) {
2555
2585
  // SVG is resolution-independent, so cap the proposed point
2556
2586
  // extent before NSImage selects its Retina representation.
2557
2587
  // A 256pt square becomes at most the registry's 512px square
2558
2588
  // on macOS's 2x displays instead of materializing an
2559
2589
  // attacker-declared multi-hundred-megabyte bitmap first.
2560
- const CGFloat max_raster_points = 256.0;
2590
+ const CGFloat max_raster_points = sqrt((CGFloat)max_pixels) / 2.0;
2561
2591
  const CGFloat raster_scale = MIN(1.0, MIN(max_raster_points / size.width, max_raster_points / size.height));
2562
2592
  NSRect proposed = NSMakeRect(0, 0, size.width * raster_scale, size.height * raster_scale);
2563
2593
  CGImageRef rendered = [system_image CGImageForProposedRect:&proposed context:nil hints:nil];
@@ -2568,14 +2598,14 @@ int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8
2568
2598
 
2569
2599
  size_t width = CGImageGetWidth(image);
2570
2600
  size_t height = CGImageGetHeight(image);
2571
- if (width == 0 || height == 0 || width > 8192 || height > 8192) {
2601
+ if (width == 0 || height == 0 || width > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION || height > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) {
2572
2602
  CGImageRelease(image);
2573
2603
  return 0;
2574
2604
  }
2575
2605
  if (out_width) *out_width = width;
2576
2606
  if (out_height) *out_height = height;
2577
2607
  size_t byte_len = width * height * 4;
2578
- if (byte_len / 4 / height != width || pixels_len < byte_len) {
2608
+ if (width > max_pixels / height || byte_len / 4 / height != width || pixels_len < byte_len) {
2579
2609
  CGImageRelease(image);
2580
2610
  return -1;
2581
2611
  }
@@ -3752,7 +3782,7 @@ static void NativeSdkPremultiplyStraightRgba8(const uint8_t *source, uint8_t *de
3752
3782
  }
3753
3783
 
3754
3784
  - (NSArray *)accessibilityChildren {
3755
- return self.widgetAccessibilityElements ?: @[];
3785
+ return self.widgetAccessibilityRootElements ?: @[];
3756
3786
  }
3757
3787
 
3758
3788
  - (BOOL)isAvailable {
@@ -5612,11 +5642,14 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
5612
5642
  - (void)updateWidgetAccessibilityWithNodes:(const native_sdk_appkit_widget_accessibility_node_t *)nodes count:(NSUInteger)count {
5613
5643
  if (!nodes || count == 0) {
5614
5644
  self.widgetAccessibilityElements = @[];
5645
+ self.widgetAccessibilityRootElements = @[];
5615
5646
  NSAccessibilityPostNotification(self, NSAccessibilityLayoutChangedNotification);
5616
5647
  return;
5617
5648
  }
5618
5649
 
5619
- NSMutableArray<NSAccessibilityElement *> *elements = [NSMutableArray arrayWithCapacity:count];
5650
+ NSMutableArray<NativeSdkWidgetAccessibilityElement *> *elements = [NSMutableArray arrayWithCapacity:count];
5651
+ NSMutableArray<NSNumber *> *parentIds = [NSMutableArray arrayWithCapacity:count];
5652
+ NSMutableDictionary<NSNumber *, NativeSdkWidgetAccessibilityElement *> *elementsById = [NSMutableDictionary dictionaryWithCapacity:count];
5620
5653
  for (NSUInteger index = 0; index < count; index++) {
5621
5654
  const native_sdk_appkit_widget_accessibility_node_t node = nodes[index];
5622
5655
  NSString *label = NativeSdkStringFromBytes(node.label, node.label_len) ?: @"";
@@ -5627,7 +5660,6 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
5627
5660
  element.surfaceView = self;
5628
5661
  element.widgetId = node.id;
5629
5662
  element.actionFlags = node.action_flags;
5630
- element.accessibilityParent = self;
5631
5663
  element.accessibilityRole = NativeSdkAccessibilityRoleForWidgetRole(node.role);
5632
5664
  element.accessibilityIdentifier = [NSString stringWithFormat:@"native-sdk-widget-%llu", node.id];
5633
5665
  element.accessibilityLabel = name;
@@ -5704,10 +5736,46 @@ static BOOL NativeSdkCompositeBlurWriteRegion(NSDictionary *command, CGFloat sca
5704
5736
  element.accessibilityValueDescription = [stateDescriptions componentsJoinedByString:@", "];
5705
5737
  }
5706
5738
  CGFloat nativeY = self.bounds.size.height - node.y - node.height;
5707
- element.accessibilityFrameInParentSpace = NSMakeRect(node.x, nativeY, node.width, node.height);
5739
+ element.surfaceFrame = NSMakeRect(node.x, nativeY, node.width, node.height);
5740
+ element.accessibilityFrameInParentSpace = element.surfaceFrame;
5708
5741
  [elements addObject:element];
5742
+ [parentIds addObject:@(node.parent_id)];
5743
+ [elementsById setObject:element forKey:@(node.id)];
5744
+ }
5745
+
5746
+ NSMutableArray<NSAccessibilityElement *> *rootElements = [NSMutableArray arrayWithCapacity:count];
5747
+ NSMutableDictionary<NSNumber *, NSMutableArray<NSAccessibilityElement *> *> *childrenByParentId = [NSMutableDictionary dictionaryWithCapacity:count];
5748
+ for (NSUInteger index = 0; index < elements.count; index++) {
5749
+ NativeSdkWidgetAccessibilityElement *element = elements[index];
5750
+ NSNumber *parentId = parentIds[index];
5751
+ NativeSdkWidgetAccessibilityElement *parent = parentId.unsignedLongLongValue == 0 ? nil : [elementsById objectForKey:parentId];
5752
+ if (parent && parent != element) {
5753
+ element.accessibilityParent = parent;
5754
+ NSRect parentFrame = parent.surfaceFrame;
5755
+ NSRect childFrame = element.surfaceFrame;
5756
+ element.accessibilityFrameInParentSpace = NSMakeRect(
5757
+ childFrame.origin.x - parentFrame.origin.x,
5758
+ childFrame.origin.y - parentFrame.origin.y,
5759
+ childFrame.size.width,
5760
+ childFrame.size.height
5761
+ );
5762
+ NSMutableArray<NSAccessibilityElement *> *children = [childrenByParentId objectForKey:parentId];
5763
+ if (!children) {
5764
+ children = [NSMutableArray array];
5765
+ [childrenByParentId setObject:children forKey:parentId];
5766
+ }
5767
+ [children addObject:element];
5768
+ } else {
5769
+ element.accessibilityParent = self;
5770
+ [rootElements addObject:element];
5771
+ }
5772
+ }
5773
+ for (NSNumber *parentId in childrenByParentId) {
5774
+ NativeSdkWidgetAccessibilityElement *parent = [elementsById objectForKey:parentId];
5775
+ parent.accessibilityChildren = [childrenByParentId objectForKey:parentId];
5709
5776
  }
5710
5777
  self.widgetAccessibilityElements = elements;
5778
+ self.widgetAccessibilityRootElements = rootElements;
5711
5779
  NSAccessibilityPostNotification(self, NSAccessibilityLayoutChangedNotification);
5712
5780
  }
5713
5781
 
@@ -7082,10 +7150,10 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
7082
7150
  }
7083
7151
 
7084
7152
  - (NSUInteger)characterIndexForPoint:(NSPoint)point {
7085
- NSAccessibilityElement *element = [self focusedTextAccessibilityElement];
7153
+ NativeSdkWidgetAccessibilityElement *element = [self focusedTextAccessibilityElement];
7086
7154
  if (!element || !self.window) return 0;
7087
7155
 
7088
- NSRect frame = element.accessibilityFrameInParentSpace;
7156
+ NSRect frame = element.surfaceFrame;
7089
7157
  if (NSIsEmptyRect(frame)) return 0;
7090
7158
 
7091
7159
  NSPoint windowPoint = [self.window convertPointFromScreen:point];
@@ -7100,10 +7168,10 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
7100
7168
  }
7101
7169
 
7102
7170
  - (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(NSRangePointer)actualRange {
7103
- NSAccessibilityElement *element = [self focusedTextAccessibilityElement];
7171
+ NativeSdkWidgetAccessibilityElement *element = [self focusedTextAccessibilityElement];
7104
7172
  NSRect localRect = NSZeroRect;
7105
7173
  if (element) {
7106
- NSRect frame = element.accessibilityFrameInParentSpace;
7174
+ NSRect frame = element.surfaceFrame;
7107
7175
  NSInteger characterCount = MAX(0, element.accessibilityNumberOfCharacters);
7108
7176
  NSUInteger location = range.location == NSNotFound ? 0 : MIN(range.location, (NSUInteger)characterCount);
7109
7177
  NSUInteger length = range.location == NSNotFound ? 0 : MIN(range.length, (NSUInteger)characterCount - location);
@@ -7126,8 +7194,8 @@ static BOOL NativeSdkScrollDriverCanConsumeHorizontally(NativeSdkScrollDriverVie
7126
7194
  return self.window ? [self.window convertRectToScreen:windowRect] : windowRect;
7127
7195
  }
7128
7196
 
7129
- - (NSAccessibilityElement *)focusedTextAccessibilityElement {
7130
- for (NSAccessibilityElement *element in self.widgetAccessibilityElements ?: @[]) {
7197
+ - (NativeSdkWidgetAccessibilityElement *)focusedTextAccessibilityElement {
7198
+ for (NativeSdkWidgetAccessibilityElement *element in self.widgetAccessibilityElements ?: @[]) {
7131
7199
  if (!element.accessibilityFocused) continue;
7132
7200
  if ([element.accessibilityRole isEqualToString:NSAccessibilityTextFieldRole]) return element;
7133
7201
  }
@@ -7684,7 +7752,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7684
7752
 
7685
7753
  @implementation NativeSdkAppKitHost
7686
7754
 
7687
- - (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags {
7755
+ - (instancetype)initWithAppName:(NSString *)appName displayName:(NSString *)displayName version:(NSString *)version aboutDescription:(NSString *)aboutDescription hasWebContent:(BOOL)hasWebContent dockVisible:(BOOL)dockVisible windowTitle:(NSString *)windowTitle bundleIdentifier:(NSString *)bundleIdentifier iconPath:(NSString *)iconPath windowLabel:(NSString *)windowLabel x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags {
7688
7756
  self = [super init];
7689
7757
  if (!self) {
7690
7758
  return nil;
@@ -7692,7 +7760,8 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7692
7760
 
7693
7761
  NativeSdkLaunchLap("host_init");
7694
7762
  [NSApplication sharedApplication];
7695
- [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
7763
+ NSApplicationActivationPolicy policy = dockVisible ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory;
7764
+ [NSApp setActivationPolicy:policy];
7696
7765
  NativeSdkLaunchLap("nsapp_ready");
7697
7766
  NativeSdkRegisterBundledFonts();
7698
7767
  NativeSdkLaunchLap("fonts_registered");
@@ -7733,7 +7802,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7733
7802
  [self configureApplication];
7734
7803
  NativeSdkLaunchLap("app_configured");
7735
7804
 
7736
- [self createWindowWithId:1 title:(windowTitle.length > 0 ? windowTitle : self.appName) label:self.windowLabel x:x y:y width:width height:height restoreFrame:restoreFrame resizable:resizable titlebarStyle:titlebarStyle showPolicy:showPolicy windowFlags:windowFlags makeMain:YES];
7805
+ [self createWindowWithId:1 title:(windowTitle.length > 0 ? windowTitle : self.appName) label:self.windowLabel x:x y:y width:width height:height restoreFrame:restoreFrame initialPlacement:initialPlacement restorePolicy:restorePolicy resizable:resizable titlebarStyle:titlebarStyle showPolicy:showPolicy windowFlags:windowFlags makeMain:YES];
7737
7806
  self.didShutdown = NO;
7738
7807
  self.pendingPreRunStop = NO;
7739
7808
  self.observesApplicationActivation = NO;
@@ -7741,16 +7810,23 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7741
7810
  return self;
7742
7811
  }
7743
7812
 
7744
- - (BOOL)createWindowWithId:(uint64_t)windowId title:(NSString *)title label:(NSString *)label x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags makeMain:(BOOL)makeMain {
7813
+ - (BOOL)createWindowWithId:(uint64_t)windowId title:(NSString *)title label:(NSString *)label x:(double)x y:(double)y width:(double)width height:(double)height restoreFrame:(BOOL)restoreFrame initialPlacement:(int)initialPlacement restorePolicy:(int)restorePolicy resizable:(BOOL)resizable titlebarStyle:(int)titlebarStyle showPolicy:(int)showPolicy windowFlags:(uint32_t)windowFlags makeMain:(BOOL)makeMain {
7745
7814
  NSNumber *key = @(windowId);
7746
7815
  if (self.windows[key]) {
7747
7816
  return NO;
7748
7817
  }
7749
7818
 
7750
- NSRect rect = restoreFrame ? NSMakeRect(x, y, width, height) : NSMakeRect(0, 0, width, height);
7751
- if (restoreFrame) {
7752
- rect = constrainFrame(rect);
7753
- }
7819
+ (void)restoreFrame; // Persistence opt-in; initialPlacement says whether a frame was found.
7820
+ const BOOL restoredPlacement = initialPlacement == 0;
7821
+ // A restored center policy deliberately discards only the saved origin;
7822
+ // its saved OUTER size is reapplied after construction below. Fresh
7823
+ // frames remain content rectangles, preserving the public width/height
7824
+ // contract for authored windows.
7825
+ const BOOL centerOnPrimary = initialPlacement == 2 || (restoredPlacement && restorePolicy == 1);
7826
+ NSScreen *primaryScreen = NativeSdkPrimaryScreen();
7827
+ NSRect rect = centerOnPrimary
7828
+ ? NativeSdkConstrainFrameToScreen(NSMakeRect(0, 0, width, height), primaryScreen)
7829
+ : NativeSdkConstrainFrame(NSMakeRect(x, y, width, height));
7754
7830
  NSWindowStyleMask styleMask = NSWindowStyleMaskTitled |
7755
7831
  NSWindowStyleMaskClosable |
7756
7832
  NSWindowStyleMaskMiniaturizable;
@@ -7832,14 +7908,30 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7832
7908
  window.toolbarStyle = NSWindowToolbarStyleUnified;
7833
7909
  window.titlebarSeparatorStyle = NSTitlebarSeparatorStyleNone;
7834
7910
  }
7835
- if (!restoreFrame) {
7836
- [window center];
7911
+ if (restoredPlacement) {
7912
+ // Window-state events persist content geometry. Convert that saved
7913
+ // rect through the window's FINAL chrome, then constrain/center the
7914
+ // completed outer frame so the content rect round-trips without
7915
+ // titlebar growth while the whole window stays visible.
7916
+ NSRect restoredContentFrame = NSMakeRect(x, y, width, height);
7917
+ NSRect restoredWindowFrame = [window frameRectForContentRect:restoredContentFrame];
7918
+ restoredWindowFrame = restorePolicy == 1
7919
+ ? NativeSdkCenterFrameOnScreen(restoredWindowFrame, primaryScreen)
7920
+ : NativeSdkConstrainFrame(restoredWindowFrame);
7921
+ [window setFrame:restoredWindowFrame display:NO];
7922
+ } else if (initialPlacement == 1) {
7923
+ // Fresh authored dimensions are content size, but visibility is an
7924
+ // OUTER-frame guarantee. AppKit adds titlebar chrome during
7925
+ // construction, so constrain the completed frame as the final step.
7926
+ [window setFrame:NativeSdkConstrainFrame(window.frame) display:NO];
7927
+ } else if (centerOnPrimary) {
7928
+ [window setFrame:NativeSdkCenterFrameOnScreen(window.frame, primaryScreen) display:NO];
7837
7929
  // AppKit centers every new window by default, which leaves a
7838
7930
  // model-declared secondary window exactly covering the editor that
7839
7931
  // opened it. Cascade from the active window like Win32's default
7840
7932
  // placement so repeated Command+N windows stay visibly distinct.
7841
7933
  NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;
7842
- if (!makeMain && referenceWindow) {
7934
+ if (initialPlacement == 2 && restorePolicy == 0 && !makeMain && referenceWindow) {
7843
7935
  NSRect referenceFrame = referenceWindow.frame;
7844
7936
  NSRect cascadedFrame = window.frame;
7845
7937
  cascadedFrame.origin.x = NSMinX(referenceFrame) + 24.0;
@@ -7861,7 +7953,7 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
7861
7953
  }
7862
7954
  if (makeMain) NativeSdkLaunchLap("window_chrome_ready");
7863
7955
 
7864
- NSView *container = [[NSView alloc] initWithFrame:rect];
7956
+ NSView *container = [[NSView alloc] initWithFrame:window.contentView.bounds];
7865
7957
  container.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
7866
7958
  window.contentView = container;
7867
7959
  // The window's MAIN WebView is created lazily
@@ -9175,8 +9267,46 @@ static float NativeSdkCaptureReadRemixedSample(const AudioBufferList *buffers, c
9175
9267
  }
9176
9268
  }
9177
9269
 
9178
- static NSRect constrainFrame(NSRect frame) {
9179
- NSScreen *screen = [NSScreen mainScreen];
9270
+ static NSScreen *NativeSdkPrimaryScreen(void) {
9271
+ // AppKit's mainScreen follows the key window. The first screen is the
9272
+ // menu-bar display: macOS's primary screen and the policy contract.
9273
+ return [NSScreen screens].firstObject ?: [NSScreen mainScreen];
9274
+ }
9275
+
9276
+ static NSScreen *NativeSdkScreenForFrame(NSRect frame) {
9277
+ NSArray<NSScreen *> *screens = [NSScreen screens];
9278
+ NSScreen *bestScreen = nil;
9279
+ CGFloat bestArea = 0;
9280
+ for (NSScreen *screen in screens) {
9281
+ NSRect intersection = NSIntersectionRect(frame, screen.visibleFrame);
9282
+ CGFloat area = NSWidth(intersection) * NSHeight(intersection);
9283
+ if (area > bestArea) {
9284
+ bestArea = area;
9285
+ bestScreen = screen;
9286
+ }
9287
+ }
9288
+ if (bestScreen) return bestScreen;
9289
+
9290
+ // A frame from a disconnected display has no intersection. Clamp it to
9291
+ // the nearest remaining display instead of always teleporting to primary.
9292
+ NSPoint center = NSMakePoint(NSMidX(frame), NSMidY(frame));
9293
+ CGFloat bestDistance = CGFLOAT_MAX;
9294
+ for (NSScreen *screen in screens) {
9295
+ NSRect visible = screen.visibleFrame;
9296
+ CGFloat nearestX = MIN(MAX(center.x, NSMinX(visible)), NSMaxX(visible));
9297
+ CGFloat nearestY = MIN(MAX(center.y, NSMinY(visible)), NSMaxY(visible));
9298
+ CGFloat dx = center.x - nearestX;
9299
+ CGFloat dy = center.y - nearestY;
9300
+ CGFloat distance = dx * dx + dy * dy;
9301
+ if (distance < bestDistance) {
9302
+ bestDistance = distance;
9303
+ bestScreen = screen;
9304
+ }
9305
+ }
9306
+ return bestScreen ?: [NSScreen mainScreen];
9307
+ }
9308
+
9309
+ static NSRect NativeSdkConstrainFrameToScreen(NSRect frame, NSScreen *screen) {
9180
9310
  if (!screen) return frame;
9181
9311
  NSRect visible = screen.visibleFrame;
9182
9312
  if (frame.size.width > visible.size.width) frame.size.width = visible.size.width;
@@ -9188,6 +9318,19 @@ static NSRect constrainFrame(NSRect frame) {
9188
9318
  return frame;
9189
9319
  }
9190
9320
 
9321
+ static NSRect NativeSdkConstrainFrame(NSRect frame) {
9322
+ return NativeSdkConstrainFrameToScreen(frame, NativeSdkScreenForFrame(frame));
9323
+ }
9324
+
9325
+ static NSRect NativeSdkCenterFrameOnScreen(NSRect frame, NSScreen *screen) {
9326
+ frame = NativeSdkConstrainFrameToScreen(frame, screen);
9327
+ if (!screen) return frame;
9328
+ NSRect visible = screen.visibleFrame;
9329
+ frame.origin.x = NSMidX(visible) - NSWidth(frame) / 2.0;
9330
+ frame.origin.y = NSMidY(visible) - NSHeight(frame) / 2.0;
9331
+ return NativeSdkConstrainFrameToScreen(frame, screen);
9332
+ }
9333
+
9191
9334
  static NSString *NativeSdkAppKitBridgeScript(void) {
9192
9335
  return @"(function(){"
9193
9336
  "if(window.zero&&window.zero.invoke){return;}"
@@ -10037,7 +10180,16 @@ static void NativeSdkApplyProcessDisplayName(NSString *displayName) {
10037
10180
  - (void)emitWindowFrameForWindowId:(uint64_t)windowId open:(BOOL)open {
10038
10181
  NSWindow *window = self.windows[@(windowId)] ?: self.window;
10039
10182
  NSString *label = self.windowLabels[@(windowId)] ?: (windowId == 1 ? self.windowLabel : @"");
10040
- NSRect frame = window.frame;
10183
+ // The frame event's rect is the CONTENT rect in screen coordinates,
10184
+ // never window.frame: every consumer treats these numbers as content
10185
+ // geometry — shell layout bounds, the resize channel
10186
+ // (contentView.bounds), window-state persistence, and
10187
+ // createWindowWithId:'s initWithContentRect: round-trip — and the
10188
+ // GTK/Win32 hosts report content size on the same event. The outer
10189
+ // frame here laid shell views past the content's bottom edge on
10190
+ // open/restore and grew every restored window by the titlebar height
10191
+ // once per launch.
10192
+ NSRect frame = [window contentRectForFrameRect:window.frame];
10041
10193
  [self emitEvent:(native_sdk_appkit_event_t){
10042
10194
  .kind = NATIVE_SDK_APPKIT_EVENT_WINDOW_FRAME,
10043
10195
  .window_id = windowId,
@@ -12209,7 +12361,7 @@ static BOOL NativeSdkPolicyListMatches(NSArray<NSString *> *values, NSURL *url)
12209
12361
  return NO;
12210
12362
  }
12211
12363
 
12212
- native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, 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, int show_policy, uint32_t window_flags) {
12364
+ native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
12213
12365
  @autoreleasepool {
12214
12366
  NSString *appNameString = [[NSString alloc] initWithBytes:app_name length:app_name_len encoding:NSUTF8StringEncoding] ?: @"native-sdk";
12215
12367
  NSString *displayNameString = [[NSString alloc] initWithBytes:display_name length:display_name_len encoding:NSUTF8StringEncoding] ?: @"";
@@ -12219,7 +12371,7 @@ native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t
12219
12371
  NSString *bundleIdString = [[NSString alloc] initWithBytes:bundle_id length:bundle_id_len encoding:NSUTF8StringEncoding] ?: @"dev.native_sdk.app";
12220
12372
  NSString *iconPathString = [[NSString alloc] initWithBytes:icon_path length:icon_path_len encoding:NSUTF8StringEncoding] ?: @"";
12221
12373
  NSString *windowLabelString = [[NSString alloc] initWithBytes:window_label length:window_label_len encoding:NSUTF8StringEncoding] ?: @"main";
12222
- NativeSdkAppKitHost *host = [[NativeSdkAppKitHost alloc] initWithAppName:appNameString displayName:displayNameString version:versionString aboutDescription:aboutDescriptionString hasWebContent:(has_web_content != 0) windowTitle:windowTitleString bundleIdentifier:bundleIdString iconPath:iconPathString windowLabel:windowLabelString x:x y:y width:width height:height restoreFrame:(restore_frame != 0) resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags];
12374
+ NativeSdkAppKitHost *host = [[NativeSdkAppKitHost alloc] initWithAppName:appNameString displayName:displayNameString version:versionString aboutDescription:aboutDescriptionString hasWebContent:(has_web_content != 0) dockVisible:(dock_visible != 0) windowTitle:windowTitleString bundleIdentifier:bundleIdString iconPath:iconPathString windowLabel:windowLabelString x:x y:y width:width height:height restoreFrame:(restore_frame != 0) initialPlacement:initial_placement restorePolicy:restore_policy resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags];
12223
12375
  return (__bridge_retained native_sdk_appkit_host_t *)host;
12224
12376
  }
12225
12377
  }
@@ -12537,11 +12689,11 @@ void native_sdk_appkit_set_shortcuts(native_sdk_appkit_host_t *host, const char
12537
12689
  [object setShortcutsWithIds:ids idLengths:id_lens keys:keys keyLengths:key_lens modifiers:modifiers count:count];
12538
12690
  }
12539
12691
 
12540
- int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
12692
+ int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags) {
12541
12693
  NativeSdkAppKitHost *object = (__bridge NativeSdkAppKitHost *)host;
12542
12694
  NSString *titleString = window_title ? [[NSString alloc] initWithBytes:window_title length:window_title_len encoding:NSUTF8StringEncoding] : @"";
12543
12695
  NSString *labelString = window_label ? [[NSString alloc] initWithBytes:window_label length:window_label_len encoding:NSUTF8StringEncoding] : @"";
12544
- return [object createWindowWithId:window_id title:titleString ?: @"" label:labelString ?: @"" x:x y:y width:width height:height restoreFrame:(restore_frame != 0) resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags makeMain:NO] ? 1 : 0;
12696
+ return [object createWindowWithId:window_id title:titleString ?: @"" label:labelString ?: @"" x:x y:y width:width height:height restoreFrame:(restore_frame != 0) initialPlacement:initial_placement restorePolicy:restore_policy resizable:(resizable != 0) titlebarStyle:titlebar_style showPolicy:show_policy windowFlags:window_flags makeMain:NO] ? 1 : 0;
12545
12697
  }
12546
12698
 
12547
12699
  int native_sdk_appkit_set_window_content_min_size(native_sdk_appkit_host_t *host, uint64_t window_id, double min_width, double min_height) {