@ng-native/desktop 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +6 -3
  2. package/bin/app-config.mjs +1 -0
  3. package/bin/archive.mjs +166 -0
  4. package/bin/autolink.mjs +61 -30
  5. package/bin/cli.mjs +127 -27
  6. package/bin/host.mjs +255 -58
  7. package/bin/package-linux.mjs +1394 -0
  8. package/bin/package.mjs +171 -35
  9. package/bin/plist.mjs +6 -2
  10. package/bin/png-icon.mjs +315 -0
  11. package/bin/prebuilt.mjs +147 -26
  12. package/bin/toolchain.mjs +258 -19
  13. package/native/CMakeLists.txt +64 -6
  14. package/native/appkit/CMakeLists.txt +2 -1
  15. package/native/appkit/appkit-backend.h +1 -0
  16. package/native/appkit/appkit-backend.mm +13 -0
  17. package/native/appkit/header-toolbar.mm +28 -25
  18. package/native/appkit/host-view.h +10 -0
  19. package/native/appkit/host-view.mm +146 -40
  20. package/native/appkit/input-replay.h +6 -0
  21. package/native/appkit/input-replay.mm +21 -12
  22. package/native/appkit/main.mm +11 -7
  23. package/native/appkit/native-controls.mm +13 -1
  24. package/native/appkit/split-view.mm +7 -13
  25. package/native/appkit/text-input-field.h +4 -0
  26. package/native/appkit/text-input-field.mm +20 -1
  27. package/native/cmake/curl.cmake +79 -0
  28. package/native/cmake/libraries/react-native-reanimated.cmake +5 -0
  29. package/native/cmake/libraries/react-native-worklets.cmake +5 -0
  30. package/native/cmake/linked-modules.cmake +20 -4
  31. package/native/cmake/react-native.cmake +18 -1
  32. package/native/core/include/ngn/accent-colors.h +38 -0
  33. package/native/core/include/ngn/accessibility-relations.h +65 -0
  34. package/native/core/include/ngn/accessibility.h +26 -0
  35. package/native/core/include/ngn/animated-frame-loop.h +56 -0
  36. package/native/core/include/ngn/app-info.h +24 -8
  37. package/native/core/include/ngn/app-menus.h +14 -1
  38. package/native/core/include/ngn/app-windows.h +15 -2
  39. package/native/core/include/ngn/aria-role.h +96 -0
  40. package/native/core/include/ngn/audio.h +2 -0
  41. package/native/core/include/ngn/camera.h +9 -0
  42. package/native/core/include/ngn/control-sizes.h +7 -2
  43. package/native/core/include/ngn/crash-report.h +31 -0
  44. package/native/core/include/ngn/curl-network.h +93 -0
  45. package/native/core/include/ngn/dbus-menu.h +39 -0
  46. package/native/core/include/ngn/default-menu.h +36 -0
  47. package/native/core/include/ngn/desktop-expo.h +7 -1
  48. package/native/core/include/ngn/desktop-modules.h +22 -0
  49. package/native/core/include/ngn/desktop-props.h +21 -1
  50. package/native/core/include/ngn/desktop-view-props.h +6 -0
  51. package/native/core/include/ngn/focus-order.h +10 -0
  52. package/native/core/include/ngn/header-bar.h +22 -0
  53. package/native/core/include/ngn/host-os.h +6 -0
  54. package/native/core/include/ngn/host-reload.h +21 -0
  55. package/native/core/include/ngn/host-state.h +23 -0
  56. package/native/core/include/ngn/image-source.h +26 -1
  57. package/native/core/include/ngn/input-script.h +3 -3
  58. package/native/core/include/ngn/input.h +4 -1
  59. package/native/core/include/ngn/launch-frame.h +21 -0
  60. package/native/core/include/ngn/launch-settings.h +23 -5
  61. package/native/core/include/ngn/mounting-backend.h +5 -0
  62. package/native/core/include/ngn/mounting-manager.h +1 -0
  63. package/native/core/include/ngn/native-controls.h +26 -5
  64. package/native/core/include/ngn/notification-schedule.h +74 -0
  65. package/native/core/include/ngn/notifications.h +2 -1
  66. package/native/core/include/ngn/openssl-update-crypto.h +15 -0
  67. package/native/core/include/ngn/photo-library.h +60 -20
  68. package/native/core/include/ngn/posix-locale.h +43 -0
  69. package/native/core/include/ngn/runtime.h +5 -0
  70. package/native/core/include/ngn/safe-areas.h +14 -2
  71. package/native/core/include/ngn/split-view.h +78 -0
  72. package/native/core/include/ngn/surface-metrics.h +7 -0
  73. package/native/core/include/ngn/system.h +14 -0
  74. package/native/core/include/ngn/text-input.h +13 -0
  75. package/native/core/include/ngn/text-units.h +38 -0
  76. package/native/core/include/ngn/updates.h +14 -2
  77. package/native/core/include/ngn/view-box.h +40 -0
  78. package/native/core/include/ngn/view-transform.h +15 -0
  79. package/native/core/include/ngn/web-browser.h +46 -0
  80. package/native/core/src/accent-colors.cpp +88 -0
  81. package/native/core/src/accessibility-relations.cpp +138 -0
  82. package/native/core/src/accessibility.cpp +50 -0
  83. package/native/core/src/animated-frame-loop.cpp +166 -0
  84. package/native/core/src/app-menus.cpp +26 -9
  85. package/native/core/src/app-windows.cpp +27 -6
  86. package/native/core/src/aria-role.cpp +127 -0
  87. package/native/core/src/control-sizes.cpp +9 -5
  88. package/native/core/src/crash-report.cpp +196 -0
  89. package/native/core/src/curl-network.cpp +1562 -0
  90. package/native/core/src/dbus-menu.cpp +71 -0
  91. package/native/core/src/default-menu.cpp +134 -0
  92. package/native/core/src/desktop-view-props.cpp +14 -0
  93. package/native/core/src/focus-order.cpp +19 -0
  94. package/native/core/src/header-bar.cpp +20 -0
  95. package/native/core/src/host-os.cpp +19 -0
  96. package/native/core/src/host-reload.cpp +45 -0
  97. package/native/core/src/host-state.cpp +8 -0
  98. package/native/core/src/image-source.cpp +90 -0
  99. package/native/core/src/input-dispatcher.cpp +27 -5
  100. package/native/core/src/input-script.cpp +3 -2
  101. package/native/core/src/launch-settings.cpp +76 -0
  102. package/native/core/src/libraries/react-native-reanimated.cpp +6 -1
  103. package/native/core/src/modules/app-info.cpp +55 -6
  104. package/native/core/src/modules/app-modules.cpp +1 -1
  105. package/native/core/src/modules/audio.cpp +4 -2
  106. package/native/core/src/modules/camera.cpp +8 -11
  107. package/native/core/src/modules/desktop-expo.cpp +10 -5
  108. package/native/core/src/modules/desktop-modules.cpp +106 -41
  109. package/native/core/src/modules/file-photo-picker.cpp +408 -0
  110. package/native/core/src/modules/notifications.cpp +13 -17
  111. package/native/core/src/modules/photo-library.cpp +42 -13
  112. package/native/core/src/modules/web-browser.cpp +89 -0
  113. package/native/core/src/mounting-manager.cpp +12 -0
  114. package/native/core/src/native-controls.cpp +42 -1
  115. package/native/core/src/notification-schedule.cpp +429 -0
  116. package/native/core/src/openssl-update-crypto.cpp +83 -0
  117. package/native/core/src/posix-locale.cpp +192 -0
  118. package/native/core/src/runtime.cpp +30 -1
  119. package/native/core/src/safe-areas.cpp +19 -4
  120. package/native/core/src/spawn-rules.cpp +4 -1
  121. package/native/core/src/split-view.cpp +93 -0
  122. package/native/core/src/system.cpp +19 -0
  123. package/native/core/src/text-input.cpp +18 -1
  124. package/native/core/src/text-units.cpp +99 -0
  125. package/native/core/src/updates.cpp +76 -17
  126. package/native/core/src/view-box.cpp +75 -40
  127. package/native/core/src/view-transform.cpp +28 -0
  128. package/native/docker/Dockerfile +38 -0
  129. package/native/docker/Dockerfile.fedora +36 -0
  130. package/native/docker/glibc-floor.sh +49 -0
  131. package/native/gtk/CMakeLists.txt +137 -0
  132. package/native/gtk/accent-colour.cpp +57 -0
  133. package/native/gtk/accent-colour.h +41 -0
  134. package/native/gtk/accessibility-settings.cpp +159 -0
  135. package/native/gtk/accessibility-settings.h +62 -0
  136. package/native/gtk/accessible-text.cpp +151 -0
  137. package/native/gtk/accessible-text.h +49 -0
  138. package/native/gtk/accessible.cpp +306 -0
  139. package/native/gtk/accessible.h +75 -0
  140. package/native/gtk/alerts.cpp +267 -0
  141. package/native/gtk/alerts.h +30 -0
  142. package/native/gtk/animation-frames.cpp +159 -0
  143. package/native/gtk/animation-frames.h +20 -0
  144. package/native/gtk/app-info.cpp +91 -0
  145. package/native/gtk/app-info.h +25 -0
  146. package/native/gtk/app-windows.cpp +439 -0
  147. package/native/gtk/app-windows.h +150 -0
  148. package/native/gtk/audio.cpp +370 -0
  149. package/native/gtk/audio.h +54 -0
  150. package/native/gtk/auth-session.cpp +73 -0
  151. package/native/gtk/auth-session.h +16 -0
  152. package/native/gtk/battery.cpp +110 -0
  153. package/native/gtk/battery.h +19 -0
  154. package/native/gtk/box-paint.cpp +262 -0
  155. package/native/gtk/box-paint.h +32 -0
  156. package/native/gtk/cairo-canvas.cpp +755 -0
  157. package/native/gtk/cairo-canvas.h +49 -0
  158. package/native/gtk/camera.cpp +909 -0
  159. package/native/gtk/camera.h +69 -0
  160. package/native/gtk/capture.cpp +46 -0
  161. package/native/gtk/capture.h +19 -0
  162. package/native/gtk/clock-format.cpp +151 -0
  163. package/native/gtk/clock-format.h +36 -0
  164. package/native/gtk/crypto.cpp +75 -0
  165. package/native/gtk/crypto.h +14 -0
  166. package/native/gtk/dbus-properties.cpp +131 -0
  167. package/native/gtk/dbus-properties.h +61 -0
  168. package/native/gtk/drag-and-drop.cpp +339 -0
  169. package/native/gtk/drag-and-drop.h +30 -0
  170. package/native/gtk/file-dialogs.cpp +239 -0
  171. package/native/gtk/file-dialogs.h +21 -0
  172. package/native/gtk/file-system.cpp +212 -0
  173. package/native/gtk/file-system.h +25 -0
  174. package/native/gtk/focus.cpp +282 -0
  175. package/native/gtk/focus.h +37 -0
  176. package/native/gtk/fonts.cpp +89 -0
  177. package/native/gtk/fonts.h +22 -0
  178. package/native/gtk/gst-frames.cpp +150 -0
  179. package/native/gtk/gst-frames.h +47 -0
  180. package/native/gtk/gst-playback.cpp +496 -0
  181. package/native/gtk/gst-playback.h +81 -0
  182. package/native/gtk/gtk-backend.cpp +690 -0
  183. package/native/gtk/gtk-backend.h +134 -0
  184. package/native/gtk/host-sources.cpp +354 -0
  185. package/native/gtk/host-sources.h +46 -0
  186. package/native/gtk/image-manipulator.cpp +254 -0
  187. package/native/gtk/image-manipulator.h +30 -0
  188. package/native/gtk/image-view.cpp +256 -0
  189. package/native/gtk/image-view.h +54 -0
  190. package/native/gtk/input-replay.cpp +299 -0
  191. package/native/gtk/input-replay.h +36 -0
  192. package/native/gtk/launcher-badge.cpp +29 -0
  193. package/native/gtk/launcher-badge.h +21 -0
  194. package/native/gtk/locales.cpp +131 -0
  195. package/native/gtk/locales.h +23 -0
  196. package/native/gtk/location.cpp +274 -0
  197. package/native/gtk/location.h +19 -0
  198. package/native/gtk/main.cpp +1092 -0
  199. package/native/gtk/menus.cpp +447 -0
  200. package/native/gtk/menus.h +100 -0
  201. package/native/gtk/native-controls.cpp +831 -0
  202. package/native/gtk/native-controls.h +58 -0
  203. package/native/gtk/network-state.cpp +72 -0
  204. package/native/gtk/network-state.h +24 -0
  205. package/native/gtk/notifications.cpp +235 -0
  206. package/native/gtk/notifications.h +30 -0
  207. package/native/gtk/pango-text.cpp +274 -0
  208. package/native/gtk/pango-text.h +73 -0
  209. package/native/gtk/portal.cpp +451 -0
  210. package/native/gtk/portal.h +71 -0
  211. package/native/gtk/printing.cpp +338 -0
  212. package/native/gtk/printing.h +34 -0
  213. package/native/gtk/proxy-resolver.cpp +74 -0
  214. package/native/gtk/proxy-resolver.h +20 -0
  215. package/native/gtk/screens.cpp +1461 -0
  216. package/native/gtk/screens.h +274 -0
  217. package/native/gtk/scroll-view.cpp +414 -0
  218. package/native/gtk/scroll-view.h +82 -0
  219. package/native/gtk/secret-store.cpp +120 -0
  220. package/native/gtk/secret-store.h +27 -0
  221. package/native/gtk/settings-portal.cpp +129 -0
  222. package/native/gtk/settings-portal.h +47 -0
  223. package/native/gtk/split-view.cpp +1105 -0
  224. package/native/gtk/split-view.h +195 -0
  225. package/native/gtk/status-notifier.cpp +487 -0
  226. package/native/gtk/status-notifier.h +43 -0
  227. package/native/gtk/surface-input.cpp +251 -0
  228. package/native/gtk/surface-input.h +57 -0
  229. package/native/gtk/system-access.cpp +295 -0
  230. package/native/gtk/system-access.h +37 -0
  231. package/native/gtk/text-field.cpp +827 -0
  232. package/native/gtk/text-field.h +78 -0
  233. package/native/gtk/video.cpp +527 -0
  234. package/native/gtk/video.h +47 -0
  235. package/native/gtk/view-widget.cpp +431 -0
  236. package/native/gtk/view-widget.h +105 -0
  237. package/native/gtk/window-scale.cpp +95 -0
  238. package/native/gtk/window-scale.h +35 -0
  239. package/native/scripts/atspi-check.py +310 -0
  240. package/native/scripts/atspi-check.test.py +48 -0
  241. package/native/scripts/build.sh +20 -3
  242. package/native/scripts/compilers.sh +17 -0
  243. package/native/scripts/deb-depends-check.sh +22 -0
  244. package/native/scripts/fetch.sh +23 -2
  245. package/native/scripts/launch-cell.sh +157 -0
  246. package/native/scripts/launch-probe.sh +14 -3
  247. package/native/scripts/make-prebuilt.mjs +133 -44
  248. package/native/scripts/prebuilt-host-cache.mjs +71 -40
  249. package/native/scripts/reset-for-compilers.sh +44 -0
  250. package/native/scripts/start-xvfb.sh +35 -0
  251. package/native/shim/paragraph-platform/react/renderer/components/text/HostPlatformParagraphProps.h +35 -0
  252. package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +5 -2
  253. package/native/shim/worklets/linux-reanimated-props.h +14 -0
  254. package/native/shim/worklets/linux-worklets.h +23 -0
  255. package/package.json +6 -3
  256. package/prebuilt.json +70 -6
@@ -522,16 +522,14 @@ NSEvent *swipeScroll(NSEvent *event, NSWindow *window) {
522
522
  // ng-native app with AppWindows) gets that surface in a window once it has something on it.
523
523
  void showAppWindow();
524
524
 
525
- // A launch counts once its window has been up this long: an update that crashes before then is
526
- // rolled back at the next launch (updates.h).
527
- constexpr int64_t kLaunchSuccessDelay = 10 * NSEC_PER_SEC;
528
-
525
+ // A launch counts once its window has been up kLaunchSuccessSeconds (launch-frame.h).
529
526
  void markLaunchSucceededLater(uint64_t generation) {
530
527
  if (!gHost.updates || !gHost.updates->running()) {
531
528
  return;
532
529
  }
533
530
  // For this launch only: a reload since begins another, with a timer of its own.
534
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, kLaunchSuccessDelay), dispatch_get_main_queue(), ^{
531
+ int64_t delay = static_cast<int64_t>(ngn::kLaunchSuccessSeconds * NSEC_PER_SEC);
532
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay), dispatch_get_main_queue(), ^{
535
533
  gHost.updates->markLaunchSucceeded(generation);
536
534
  });
537
535
  }
@@ -572,7 +570,9 @@ void reloadLaunched(uint64_t generation, uint64_t instance) {
572
570
  void reloadSameLaunch() {
573
571
  uint64_t generation = gHost.updates ? gHost.updates->launchGeneration() : 0;
574
572
  gHost.launchFrame.reloadBegan();
573
+ gHost.launchFrame.bundleLoading();
575
574
  gHost.runtime->reload([generation](bool loaded) {
575
+ gHost.launchFrame.bundleLoadEnded(loaded);
576
576
  if (!loaded) {
577
577
  fprintf(stderr, "ngn-macos: the reload could not load the bundle\n");
578
578
  return;
@@ -794,8 +794,9 @@ void showAppWindow() {
794
794
  }
795
795
  - (void)applicationWillTerminate:(NSNotification *)note {
796
796
  ngn::appkit::endTestLaunch();
797
- // A clean quit is no crash: the update running is not rolled back, however soon it quit.
798
- if (gHost.updates) {
797
+ // A clean quit is no crash: the update running is not rolled back, however soon it quit. Not so
798
+ // while its reload is pending or its bundle did not load: that launch never ran.
799
+ if (gHost.updates && gHost.launchFrame.bundleLoaded()) {
799
800
  gHost.updates->markLaunchSucceeded();
800
801
  }
801
802
  // The programs the app started go with it, rather than run on with no one to read them.
@@ -1205,6 +1206,7 @@ int main(int argc, const char *argv[]) {
1205
1206
  return surface == kAppSurface ? gHost.appWindow : gHost.windows->window(surface);
1206
1207
  }),
1207
1208
  .reviewPrompt = ngn::appkit::makeReviewPrompt(packaged && packaged->distribution == "mas"),
1209
+ .mapViews = true,
1208
1210
  .crypto = ngn::appkit::makeCryptoSource(),
1209
1211
  .locales = ngn::appkit::makeLocaleSource(),
1210
1212
  .regionCode = ngn::appkit::systemRegionCode,
@@ -1215,7 +1217,9 @@ int main(int argc, const char *argv[]) {
1215
1217
  setRunningBundle(next);
1216
1218
  // The launch the module's beginReload just began.
1217
1219
  uint64_t generation = gHost.updates->launchGeneration();
1220
+ gHost.launchFrame.bundleLoading();
1218
1221
  gHost.runtime->reload(next, [next, done, generation](bool loaded) {
1222
+ gHost.launchFrame.bundleLoadEnded(loaded);
1219
1223
  if (!loaded) {
1220
1224
  fprintf(stderr, "ngn-macos: the update's bundle %s did not load\n", next.c_str());
1221
1225
  }
@@ -46,7 +46,8 @@ void configureButton(NSButton *button, const NativeControlProps &p) {
46
46
  button.bezelStyle = NSBezelStylePush;
47
47
  button.image = p.sfSymbol.empty() ? nil : [NSImage imageWithSystemSymbolName:nsString(p.sfSymbol) accessibilityDescription:nil];
48
48
  button.imagePosition = button.image == nil ? NSNoImage : (p.title.empty() ? NSImageOnly : NSImageLeading);
49
- // Return presses the default button of its window, and Escape the cancel one.
49
+ // Return presses the default button of its window, and Escape the cancel one. Only a `default`
50
+ // button takes Return, on every desktop OS; one with no kind takes neither key.
50
51
  button.keyEquivalent = p.kind == "default" ? @"\r" : p.kind == "cancel" ? @"\x1b" : @"";
51
52
  button.hasDestructiveAction = p.kind == "destructive";
52
53
  button.contentTintColor = p.kind == "destructive" ? NSColor.systemRedColor : nil;
@@ -186,6 +187,12 @@ RNSize AppKitControlMeasurer::measure(ControlKind kind, const NativeControlProps
186
187
  if (const auto *p = self.controlProps) {
187
188
  [self apply:*p];
188
189
  }
190
+ // The control's own title goes over what the views it is labelled by said: they say it again.
191
+ [self refreshControlRelations];
192
+ }
193
+
194
+ - (NSView *)accessibilityControl {
195
+ return self.control;
189
196
  }
190
197
 
191
198
  - (void)apply:(const NativeControlProps &)p {
@@ -384,6 +391,11 @@ RNSize AppKitControlMeasurer::measure(ControlKind kind, const NativeControlProps
384
391
  if (const auto *p = dynamic_cast<const NativeControlProps *>(props.get())) {
385
392
  [_search apply:*p];
386
393
  }
394
+ [self refreshControlRelations];
395
+ }
396
+
397
+ - (NSView *)accessibilityControl {
398
+ return _search.field;
387
399
  }
388
400
 
389
401
  - (void)handleCommand:(const std::string &)name args:(const folly::dynamic &)args {
@@ -730,8 +730,8 @@ NSWindow *NGNWindowOfSplit(NSView *surfaceView) {
730
730
  NSArray *_top;
731
731
  NSMutableDictionary<NSNumber *, id> *_objects;
732
732
  NSMutableDictionary<NSNumber *, NGNSourceRowHost *> *_hosts;
733
- // Sections the user folded away.
734
- NSMutableSet<NSNumber *> *_folded;
733
+ // Sections the user folded away, the same on every toolkit.
734
+ ngn::SourceListFolds _folds;
735
735
  BOOL _syncing;
736
736
  // The custom row whose content took the click in progress.
737
737
  NGNSourceRowHost *_claimedBy;
@@ -741,7 +741,6 @@ NSWindow *NGNWindowOfSplit(NSView *surfaceView) {
741
741
  if ((self = [super initWithFrame:frame])) {
742
742
  _objects = [NSMutableDictionary dictionary];
743
743
  _hosts = [NSMutableDictionary dictionary];
744
- _folded = [NSMutableSet set];
745
744
  _top = @[];
746
745
  NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"row"];
747
746
  column.resizingMask = NSTableColumnAutoresizingMask;
@@ -834,17 +833,17 @@ NSWindow *NGNWindowOfSplit(NSView *surfaceView) {
834
833
  }
835
834
  }
836
835
  _top = top;
836
+ _folds.setList(list);
837
837
  for (NSNumber *tag in _objects.allKeys) {
838
838
  if (![live containsObject:tag]) {
839
839
  [_objects removeObjectForKey:tag];
840
- [_folded removeObject:tag];
841
840
  [_hosts removeObjectForKey:tag];
842
841
  }
843
842
  }
844
843
  _syncing = YES;
845
844
  [self reloadData];
846
845
  for (id item in _top) {
847
- if ([item isKindOfClass:NGNSourceGroup.class] && ![_folded containsObject:@(((NGNSourceGroup *)item).tag)]) {
846
+ if ([item isKindOfClass:NGNSourceGroup.class] && !_folds.folded(((NGNSourceGroup *)item).tag)) {
848
847
  [self expandItem:item];
849
848
  }
850
849
  }
@@ -857,9 +856,8 @@ NSWindow *NGNWindowOfSplit(NSView *surfaceView) {
857
856
  - (void)syncSelection {
858
857
  _syncing = YES;
859
858
  NSInteger selected = -1;
860
- for (NSNumber *tag in _objects) {
861
- NGNSourceRow *row = _objects[tag];
862
- if ([row isKindOfClass:NGNSourceRow.class] && row.row.selected) {
859
+ if (auto tag = ngn::selectedRow(_list)) {
860
+ if (NGNSourceRow *row = _objects[@(*tag)]; [row isKindOfClass:NGNSourceRow.class]) {
863
861
  selected = [self rowForItem:row];
864
862
  }
865
863
  }
@@ -1066,11 +1064,7 @@ NSWindow *NGNWindowOfSplit(NSView *surfaceView) {
1066
1064
  }
1067
1065
  NSInteger tag = ((NGNSourceGroup *)item).tag;
1068
1066
  if (!_syncing) {
1069
- if (folded) {
1070
- [_folded addObject:@(tag)];
1071
- } else {
1072
- [_folded removeObject:@(tag)];
1073
- }
1067
+ _folds.fold(tag, folded);
1074
1068
  }
1075
1069
  NGNView *section = self.views ? self.views(tag) : nil;
1076
1070
  if ([section isKindOfClass:NGNSidebarSectionView.class]) {
@@ -58,6 +58,8 @@ BOOL NGNControlShouldChangeText(
58
58
  @property (nonatomic) BOOL autoFocus;
59
59
  // Called when the field takes the keyboard.
60
60
  @property (nonatomic, copy) void (^focused)(void);
61
+ // Whether its value is refused (aria-invalid), as VoiceOver reads it from the control.
62
+ @property (nonatomic) BOOL invalid;
61
63
  - (void)applyOptions:(const ngn::TextInputOptions &)options;
62
64
  - (const ngn::TextInputOptions &)options;
63
65
  // Drawn in the field's font; nil colour is the system's placeholder colour.
@@ -70,6 +72,8 @@ BOOL NGNControlShouldChangeText(
70
72
 
71
73
  @interface NGNTextView : NSTextView
72
74
  @property (nonatomic) BOOL autoFocus;
75
+ // Whether its value is refused (aria-invalid), as VoiceOver reads it.
76
+ @property (nonatomic) BOOL invalid;
73
77
  @property (nonatomic, copy) void (^focused)(void);
74
78
  @property (nonatomic, copy, readonly) NSAttributedString *placeholder;
75
79
  - (void)applyOptions:(const ngn::TextInputOptions &)options;
@@ -140,6 +140,22 @@ NSDictionary<NSTextCheckingOptionKey, id> *NGNTextCheckingOptions(
140
140
  - (void)controlDidEndEditing;
141
141
  @end
142
142
 
143
+ // WebKit's AXInvalid, which AppKit has no property for, said as `invalid` is: a field whose value
144
+ // is refused (aria-invalid).
145
+ #define NGN_INVALID_ATTRIBUTE_METHODS(invalid) \
146
+ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
147
+ -(NSArray<NSAccessibilityAttributeName> *)accessibilityAttributeNames { \
148
+ NSArray *names = [super accessibilityAttributeNames]; \
149
+ return [names containsObject:@"AXInvalid"] ? names : [names arrayByAddingObject:@"AXInvalid"]; \
150
+ } \
151
+ -(id)accessibilityAttributeValue : (NSAccessibilityAttributeName)attribute { \
152
+ if ([attribute isEqualToString:@"AXInvalid"]) { \
153
+ return (invalid) ? @"true" : @"false"; \
154
+ } \
155
+ return [super accessibilityAttributeValue:attribute]; \
156
+ } \
157
+ _Pragma("clang diagnostic pop")
158
+
143
159
  // The two controls a field swaps between. AppKit's secure field editor takes only an
144
160
  // NSSecureTextField as its delegate, so each is a subclass of its own, with the same few
145
161
  // overrides: they report focus to their box, and keep the shared field editor to its options.
@@ -165,7 +181,8 @@ NSDictionary<NSTextCheckingOptionKey, id> *NGNTextCheckingOptions(
165
181
  : (NSRange)range options : (NSDictionary<NSTextCheckingOptionKey, id> *)options types \
166
182
  : (NSTextCheckingTypes *)checkingTypes { \
167
183
  return self.box ? NGNTextCheckingOptions(options, self.box.options) : options; \
168
- }
184
+ } \
185
+ NGN_INVALID_ATTRIBUTE_METHODS(self.box.invalid)
169
186
 
170
187
  #define NGN_FIELD_CELL_METHODS \
171
188
  -(NSText *)setUpFieldEditorAttributes : (NSText *)text { \
@@ -438,6 +455,8 @@ NGN_FIELD_CELL_METHODS
438
455
  NSWritingDirection _writingDirection;
439
456
  }
440
457
 
458
+ NGN_INVALID_ATTRIBUTE_METHODS(self.invalid)
459
+
441
460
  - (instancetype)initWithFrame:(NSRect)frame textContainer:(NSTextContainer *)container {
442
461
  if ((self = [super initWithFrame:frame textContainer:container])) {
443
462
  _textAlignment = NSTextAlignmentNatural;
@@ -0,0 +1,79 @@
1
+ # libcurl for the HTTP and WebSocket client in core/src/curl-network.cpp: the version fetch.sh pins,
2
+ # built static as part of the host build, with only what the client uses. HTTP/1.1 and HTTP/2
3
+ # (nghttp2), `file:`, WebSockets, cookies, and gzip and deflate bodies (zlib); no other protocol,
4
+ # no IDN, PSL, brotli or zstd, and none of curl's own messages, which name an OpenSSL 3.2 call
5
+ # (curl-network.cpp has its own).
6
+ #
7
+ # TLS is the system's OpenSSL 3, linked dynamically with nghttp2 and zlib: every tier 1 distribution
8
+ # ships libssl.so.3, which keeps its ABI across 3.x, and its CA certificates are found at run time,
9
+ # so curl is built with no bundle path of its own. native/docker/glibc-floor.sh checks that nothing
10
+ # needs an OpenSSL newer than 3.0, Ubuntu 24.04's. The libraries come from pkg-config: on Linux the
11
+ # distribution's -devel packages; on a Mac Homebrew's, with
12
+ # PKG_CONFIG_PATH="$(brew --prefix openssl@3)/lib/pkgconfig".
13
+ #
14
+ # curl configures in a build of its own (ExternalProject), so its find_package(OpenSSL) never meets
15
+ # the OpenSSL::Crypto shim cmake/runtime-dependencies.cmake defines for React Native.
16
+ include(ExternalProject)
17
+ find_package(PkgConfig REQUIRED)
18
+ find_package(Threads REQUIRED)
19
+ find_package(ZLIB REQUIRED)
20
+ pkg_check_modules(NGN_OPENSSL REQUIRED openssl>=3.0)
21
+ pkg_check_modules(NGN_NGHTTP2 REQUIRED libnghttp2)
22
+
23
+ if(NOT EXISTS ${NGN_SOURCES}/curl/CMakeLists.txt)
24
+ message(FATAL_ERROR "${NGN_SOURCES} has no curl; build through scripts/build.sh")
25
+ endif()
26
+
27
+ set(_curl_build ${CMAKE_BINARY_DIR}/third-party/curl)
28
+ set(_curl_library ${_curl_build}/lib/libcurl.a)
29
+ string(REPLACE ";" "|" _curl_archs "${CMAKE_OSX_ARCHITECTURES}")
30
+ set(_curl_off
31
+ BUILD_SHARED_LIBS BUILD_CURL_EXE BUILD_TESTING BUILD_EXAMPLES BUILD_LIBCURL_DOCS BUILD_MISC_DOCS
32
+ ENABLE_CURL_MANUAL CURL_ENABLE_EXPORT_TARGET PICKY_COMPILER ENABLE_ARES CURL_BROTLI CURL_ZSTD
33
+ USE_LIBIDN2 USE_APPLE_IDN CURL_USE_LIBPSL CURL_USE_LIBSSH2 CURL_USE_LIBSSH CURL_USE_GSSAPI
34
+ CURL_USE_GSASL CURL_USE_LIBUV USE_NGTCP2 USE_QUICHE USE_ECH USE_HTTPSRR CURL_ENABLE_NTLM)
35
+ set(_curl_on
36
+ BUILD_STATIC_LIBS CURL_DISABLE_INSTALL CURL_USE_OPENSSL USE_NGHTTP2 CURL_ZLIB ENABLE_THREADED_RESOLVER
37
+ CURL_CA_FALLBACK CURL_DISABLE_VERBOSE_STRINGS CURL_DISABLE_DICT CURL_DISABLE_FTP CURL_DISABLE_GOPHER
38
+ CURL_DISABLE_IMAP CURL_DISABLE_LDAP CURL_DISABLE_LDAPS CURL_DISABLE_MQTT CURL_DISABLE_POP3
39
+ CURL_DISABLE_RTSP CURL_DISABLE_SMTP CURL_DISABLE_TELNET CURL_DISABLE_TFTP CURL_DISABLE_IPFS
40
+ CURL_DISABLE_DOH CURL_DISABLE_NETRC CURL_DISABLE_AWS)
41
+ set(_curl_args)
42
+ foreach(option ${_curl_off})
43
+ list(APPEND _curl_args -D${option}=OFF)
44
+ endforeach()
45
+ foreach(option ${_curl_on})
46
+ list(APPEND _curl_args -D${option}=ON)
47
+ endforeach()
48
+
49
+ ExternalProject_Add(ngn_curl_build
50
+ SOURCE_DIR ${NGN_SOURCES}/curl
51
+ BINARY_DIR ${_curl_build}
52
+ LIST_SEPARATOR |
53
+ CMAKE_ARGS
54
+ -DCMAKE_BUILD_TYPE=Release
55
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
56
+ -DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}
57
+ -DCMAKE_OSX_ARCHITECTURES=${_curl_archs}
58
+ -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
59
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON
60
+ -DOPENSSL_ROOT_DIR=${NGN_OPENSSL_PREFIX}
61
+ # The certificates are found at run time (findCaCertificates), else OpenSSL's defaults.
62
+ -DCURL_CA_BUNDLE=none
63
+ -DCURL_CA_PATH=none
64
+ ${_curl_args}
65
+ BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --target libcurl_static
66
+ INSTALL_COMMAND ""
67
+ BUILD_BYPRODUCTS ${_curl_library})
68
+
69
+ add_library(ngn_libcurl STATIC IMPORTED GLOBAL)
70
+ set(_curl_links ${NGN_OPENSSL_LINK_LIBRARIES} ${NGN_NGHTTP2_LINK_LIBRARIES} ZLIB::ZLIB Threads::Threads)
71
+ if(APPLE)
72
+ list(APPEND _curl_links "-framework CoreFoundation" "-framework SystemConfiguration")
73
+ endif()
74
+ set_target_properties(ngn_libcurl PROPERTIES
75
+ IMPORTED_LOCATION ${_curl_library}
76
+ INTERFACE_INCLUDE_DIRECTORIES ${NGN_SOURCES}/curl/include
77
+ INTERFACE_COMPILE_DEFINITIONS CURL_STATICLIB
78
+ INTERFACE_LINK_LIBRARIES "${_curl_links}")
79
+ add_dependencies(ngn_libcurl ngn_curl_build)
@@ -40,6 +40,11 @@ target_compile_definitions(ngn_rnreanimated PUBLIC
40
40
  # react-native-worklets' recipe's, in either order of the libraries.
41
41
  target_link_libraries(ngn_rnreanimated PUBLIC ngn_rnworklets react_native)
42
42
  target_compile_options(ngn_rnreanimated PRIVATE -fexceptions -frtti -include cstdint -w)
43
+ # Linux: the synchronous props function Reanimated declares for Android and Apple only
44
+ # (shim/worklets/linux-reanimated-props.h).
45
+ if(NOT APPLE)
46
+ target_compile_options(ngn_rnreanimated PRIVATE "SHELL:-include ${CMAKE_CURRENT_SOURCE_DIR}/shim/worklets/linux-reanimated-props.h")
47
+ endif()
43
48
  list(APPEND _lib_targets ngn_rnreanimated)
44
49
  string(APPEND _lib_glue_decls "void installGlue_rnreanimated();\n")
45
50
  string(APPEND _lib_glue_calls " installGlue_rnreanimated();\n")
@@ -41,6 +41,11 @@ target_compile_definitions(ngn_rnworklets PUBLIC
41
41
  HERMES_V1_ENABLED=1)
42
42
  target_link_libraries(ngn_rnworklets PUBLIC react_native hermes-engine::hermesvm)
43
43
  target_compile_options(ngn_rnworklets PRIVATE -fexceptions -frtti -include cstdint -w)
44
+ # Linux: what the library takes from Apple's libc and libc++ that glibc and libstdc++ lack
45
+ # (shim/worklets/linux-worklets.h).
46
+ if(NOT APPLE)
47
+ target_compile_options(ngn_rnworklets PRIVATE "SHELL:-include ${CMAKE_CURRENT_SOURCE_DIR}/shim/worklets/linux-worklets.h")
48
+ endif()
44
49
  list(APPEND _lib_targets ngn_rnworklets)
45
50
  string(APPEND _lib_glue_decls "void installGlue_rnworklets();\n")
46
51
  string(APPEND _lib_glue_calls " installGlue_rnworklets();\n")
@@ -1,13 +1,15 @@
1
1
  # Autolinked native code: the libraries and app modules bin/autolink.mjs lists in the app's
2
- # link.json, which scripts/build.sh passes as NGN_DESKTOP_LINK.
2
+ # link.json, which scripts/build.sh passes as NGN_DESKTOP_LINK. The link.json is for one desktop OS
3
+ # (its `os`: macos for the appkit backend, linux for the gtk one), and the build refuses one made
4
+ # for another, since its modules' sources are that OS's.
3
5
  #
4
- # - A library's CMake fragment (its `macos.cmakeDir`, `desktop` by default) declares the target its
5
- # `macos.cmakeTarget` names. The build gives that target React Native's headers, JSI and folly,
6
+ # - A library's CMake fragment (its `<os>.cmakeDir`, `desktop` by default) declares the target its
7
+ # `<os>.cmakeTarget` names. The build gives that target React Native's headers, JSI and folly,
6
8
  # the host's appkit/component-view.h, and the codegen of the library's specs when its
7
9
  # package.json has a codegenConfig: the `<Name>JSI.h` its C++ module implements, and its Fabric
8
10
  # components' props, events and shadow nodes, which scripts/build.sh also compiles in and
9
11
  # registers through cmake/libraries.cmake, as on Android.
10
- # - An app module's `modules/<name>/macos/` folder either has a CMakeLists.txt declaring the target
12
+ # - An app module's `modules/<name>/<os>/` folder either has a CMakeLists.txt declaring the target
11
13
  # its expo-module.config.json names, or is compiled whole: every .cpp, .mm, .m and .c in it.
12
14
  #
13
15
  # Either way the code registers its TurboModules itself as it loads, the way React Native's iOS
@@ -26,6 +28,8 @@ target_link_libraries(ngn_module_api INTERFACE react_native)
26
28
  # A library's views include appkit/component-view.h, and through it the core's headers.
27
29
  if(NGN_BACKEND STREQUAL "appkit")
28
30
  target_include_directories(ngn_module_api INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/appkit ${CMAKE_CURRENT_SOURCE_DIR}/core/include)
31
+ elseif(NGN_BACKEND STREQUAL "gtk")
32
+ target_include_directories(ngn_module_api INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/core/include)
29
33
  endif()
30
34
 
31
35
  set(NGN_LINKED "")
@@ -50,6 +54,18 @@ if(NGN_DESKTOP_LINK)
50
54
  if(NOT _version EQUAL 1)
51
55
  message(FATAL_ERROR "${NGN_DESKTOP_LINK} is version ${_version}; this host reads version 1")
52
56
  endif()
57
+ if(NGN_BACKEND STREQUAL "gtk")
58
+ set(_os linux)
59
+ else()
60
+ set(_os macos)
61
+ endif()
62
+ string(JSON _link_os ERROR_VARIABLE _no_os GET "${_link}" os)
63
+ if(_no_os)
64
+ set(_link_os macos) # written before link.json named its OS
65
+ endif()
66
+ if(NOT _link_os STREQUAL _os)
67
+ message(FATAL_ERROR "${NGN_DESKTOP_LINK} links native code for ${_link_os}, and the ${NGN_BACKEND} backend is built for ${_os}")
68
+ endif()
53
69
 
54
70
  string(JSON _count LENGTH "${_link}" libraries)
55
71
  if(_count GREATER 0)
@@ -83,6 +83,15 @@ foreach(_property INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES)
83
83
  ${_property} "${CMAKE_CURRENT_LIST_DIR}/../shim/text-platform;${_dirs}")
84
84
  endforeach()
85
85
 
86
+ # The paragraph props are the shim's too (shim/paragraph-platform), which carry the desktop props
87
+ # beside React Native's: in front of the cxx platform's for rrc_text and each target that links it,
88
+ # as above. A directory of its own, for the same reason.
89
+ foreach(_property INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES)
90
+ get_target_property(_dirs rrc_text ${_property})
91
+ set_target_properties(rrc_text PROPERTIES
92
+ ${_property} "${CMAKE_CURRENT_LIST_DIR}/../shim/paragraph-platform;${_dirs}")
93
+ endforeach()
94
+
86
95
  # React Native's component codegen (FBReactNativeSpec), generated by scripts/fetch.sh.
87
96
  set(CODEGEN_DIR ${NGN_SOURCES}/codegen)
88
97
  file(GLOB codegen_SRC CONFIGURE_DEPENDS ${CODEGEN_DIR}/react/renderer/components/FBReactNativeSpec/*.cpp)
@@ -133,7 +142,15 @@ if(NGN_WITH_RUNTIME)
133
142
  message(FATAL_ERROR "ReactHost.cpp no longer makes its Scheduler as cmake/react-native.cmake expects")
134
143
  endif()
135
144
  string(REPLACE "${_rh_from}" "ngn::makeScheduler(toolbox, schedulerDelegate.get());" _rh "${_rh}")
136
- string(REPLACE "#include \"ReactHost.h\"" "#include \"ReactHost.h\"\n#include \"ngn/layout-animations.h\"" _rh "${_rh}")
145
+ # Its own reload rebuilds the instance with nothing holding off the UI thread's surface calls, so
146
+ # it goes to the core's Runtime::reload first (ngn/host-reload.h).
147
+ set(_rh_reload "void ReactHost::reloadReactInstance() {")
148
+ string(FIND "${_rh}" "${_rh_reload}" _rh_at)
149
+ if(_rh_at EQUAL -1)
150
+ message(FATAL_ERROR "ReactHost.cpp no longer reloads in reloadReactInstance as cmake/react-native.cmake expects")
151
+ endif()
152
+ string(REPLACE "${_rh_reload}" "${_rh_reload}\n if (ngn::reloadThroughRoute(this)) {\n return;\n }" _rh "${_rh}")
153
+ string(REPLACE "#include \"ReactHost.h\"" "#include \"ReactHost.h\"\n#include \"ngn/host-reload.h\"\n#include \"ngn/layout-animations.h\"" _rh "${_rh}")
137
154
  file(WRITE ${CMAKE_BINARY_DIR}/generated/ReactHost.cpp.in "${_rh}")
138
155
  configure_file(${CMAKE_BINARY_DIR}/generated/ReactHost.cpp.in ${CMAKE_BINARY_DIR}/generated/ReactHost.cpp COPYONLY)
139
156
  get_target_property(_rhs react_cxx_platform_react_runtime SOURCES)
@@ -0,0 +1,38 @@
1
+ // The accent colours a libadwaita app draws with, from the desktop's accent colour (the settings
2
+ // portal's org.freedesktop.appearance accent-color), as libadwaita 1.6 works them out for its own
3
+ // stylesheet: the nearest of its nine accent colours by OKLCh hue, as the background, white text on
4
+ // it, and the accent as text or an icon on the window's background, its OKLab lightness at most 0.5
5
+ // in a light style and at least 0.85 in a dark one so it reads (adw-accent-color.c).
6
+ // libadwaita 1.6 and later follow the portal themselves; the GTK host applies these below 1.6.
7
+ #pragma once
8
+
9
+ #include <optional>
10
+ #include <string>
11
+
12
+ namespace ngn {
13
+
14
+ // sRGB, each channel 0 to 1.
15
+ struct Rgb {
16
+ double red{0};
17
+ double green{0};
18
+ double blue{0};
19
+ bool operator==(const Rgb &other) const = default;
20
+ };
21
+
22
+ struct AccentColors {
23
+ Rgb background;
24
+ Rgb foreground;
25
+ Rgb standalone;
26
+ bool operator==(const AccentColors &other) const = default;
27
+ };
28
+
29
+ // Nothing for a portal colour out of range, the portal's way of saying the desktop sets none.
30
+ std::optional<AccentColors> accentColors(Rgb accent, bool dark);
31
+
32
+ // The colour as CSS writes it, `rgb(53,132,228)`.
33
+ std::string cssColor(Rgb color);
34
+
35
+ // GTK CSS defining libadwaita's accent_bg_color, accent_fg_color and accent_color as `colors`.
36
+ std::string accentCss(const AccentColors &colors);
37
+
38
+ } // namespace ngn
@@ -0,0 +1,65 @@
1
+ // The views a view is labelled and described by: `accessibilityLabelledBy` (`aria-labelledby`) and
2
+ // `accessibilityDescribedBy` (`aria-describedby`), each a list of `nativeID`s. The core resolves the
3
+ // ids to the views mounted with them on the same surface, in the order written, and the backend
4
+ // points its toolkit's relations at their views (labelled-by and described-by on GTK, the title
5
+ // element and the help on AppKit). An id no view has is left out; one that several views have
6
+ // names the one with the lowest tag (Fabric counts tags up as views are made, so the one made first).
7
+ //
8
+ // A relation follows both of its ends: a view gaining or losing the props, and a view named by
9
+ // them being made, deleted or given another id. Kept by the mounting manager, which tells the
10
+ // backend after each transaction which views' relations changed.
11
+ #pragma once
12
+
13
+ #include "ngn/view-tree.h"
14
+
15
+ #include <map>
16
+ #include <set>
17
+ #include <string>
18
+ #include <utility>
19
+ #include <vector>
20
+
21
+ namespace ngn {
22
+
23
+ struct AxRelations {
24
+ std::vector<Tag> labelledBy;
25
+ std::vector<Tag> describedBy;
26
+
27
+ bool empty() const {
28
+ return labelledBy.empty() && describedBy.empty();
29
+ }
30
+ bool operator==(const AxRelations &) const = default;
31
+ };
32
+
33
+ class AccessibilityRelations {
34
+ public:
35
+ // A view was created or its props changed: its own ids, and the ids it names.
36
+ void update(const ShadowView &view);
37
+ // A view was deleted.
38
+ void remove(Tag tag);
39
+
40
+ // After a transaction on `surfaceId`: each view whose relations changed, with what they are now,
41
+ // empty for one that lost them.
42
+ std::vector<std::pair<Tag, AxRelations>> didMount(SurfaceId surfaceId);
43
+
44
+ private:
45
+ struct Names {
46
+ SurfaceId surfaceId{-1};
47
+ std::vector<std::string> labelledBy;
48
+ std::vector<std::string> describedBy;
49
+ };
50
+ std::vector<Tag> resolve(SurfaceId surfaceId, const std::vector<std::string> &ids) const;
51
+ void forgetId(Tag tag);
52
+
53
+ // Each surface's ids, with the views that have each.
54
+ std::map<SurfaceId, std::map<std::string, std::set<Tag>>> ids_;
55
+ // Each view's id, to take it out of ids_ as it changes or goes.
56
+ std::map<Tag, std::pair<SurfaceId, std::string>> idOf_;
57
+ // The views that name others.
58
+ std::map<Tag, Names> naming_;
59
+ // What each view's relations were last reported as, while not empty, and its surface.
60
+ std::map<Tag, std::pair<SurfaceId, AxRelations>> reported_;
61
+ // The surfaces a change since their last transaction may have touched.
62
+ std::set<SurfaceId> dirty_;
63
+ };
64
+
65
+ } // namespace ngn
@@ -4,9 +4,11 @@
4
4
  // maps the role and subrole to its own (NSAccessibility on macOS).
5
5
  #pragma once
6
6
 
7
+ #include <react/renderer/components/view/ViewEventEmitter.h>
7
8
  #include <react/renderer/components/view/ViewProps.h>
8
9
  #include <react/renderer/mounting/ShadowView.h>
9
10
 
11
+ #include <functional>
10
12
  #include <optional>
11
13
  #include <string>
12
14
  #include <vector>
@@ -79,6 +81,16 @@ struct AxInfo {
79
81
  std::optional<int> checked;
80
82
  // Nothing for a view that neither expands nor collapses.
81
83
  std::optional<bool> expanded;
84
+ // `aria-required` and `aria-invalid`: a field that must be filled in, or whose value is refused.
85
+ bool required{false};
86
+ bool invalid{false};
87
+ // `aria-posinset` and `aria-setsize`: an item's place in its set, from 1, and how many the set
88
+ // has, for a set not all in the tree. Nothing where unset or below 1.
89
+ std::optional<int> positionInSet;
90
+ std::optional<int> setSize;
91
+ // `aria-rowcount` and `aria-colcount`: how many rows and columns a grid or table has.
92
+ std::optional<int> rowCount;
93
+ std::optional<int> columnCount;
82
94
  // The declared actions AppKit has no verb of its own for, in their order.
83
95
  std::vector<AxAction> customActions;
84
96
  // Whether the view offers AppKit's press (VoiceOver's VO-Space), increment and decrement, and
@@ -137,4 +149,18 @@ struct AxDispatch {
137
149
 
138
150
  AxDispatch axDispatch(const facebook::react::ViewProps &props, AxVerb verb);
139
151
 
152
+ // Sends what `verb` reaches on a view through its emitter, as axDispatch decides; a click goes to
153
+ // `click`, which the host sends as a press, and needs no emitter. Whether anything was sent: what
154
+ // AppKit's perform methods and GTK's accessible actions answer.
155
+ bool performAxVerb(
156
+ const facebook::react::ViewProps &props,
157
+ const facebook::react::ViewEventEmitter *emitter,
158
+ AxVerb verb,
159
+ const std::function<bool()> &click);
160
+
161
+ // Sends the declared action `name` (one of AxInfo's customActions) through the view's emitter, to a
162
+ // view that listens for actions, as iOS sends one only to such a view. Whether it was sent: what
163
+ // AppKit's custom action handler and GTK's accessible action answer.
164
+ bool sendAxAction(const facebook::react::ViewProps &props, const facebook::react::ViewEventEmitter *emitter, const std::string &name);
165
+
140
166
  } // namespace ngn
@@ -0,0 +1,56 @@
1
+ // The frames React Native's animated module (AnimatedModule, NativeAnimatedNodesManager) renders
2
+ // on, from the host's display frames: what React Native iOS's RCTAnimatedModuleProvider does over a
3
+ // display link. The manager starts the loop when an animation or a value it drives needs a frame and
4
+ // stops it once nothing does, so an app with nothing animating takes no frames for it.
5
+ #pragma once
6
+
7
+ #include "ngn/animation-frames.h"
8
+
9
+ #include <functional>
10
+ #include <memory>
11
+
12
+ namespace facebook::react {
13
+ class NativeAnimatedNodesManagerProvider;
14
+ }
15
+
16
+ namespace ngn {
17
+
18
+ class AnimatedFrameLoop {
19
+ public:
20
+ explicit AnimatedFrameLoop(AnimationFrames &frames);
21
+ ~AnimatedFrameLoop();
22
+ AnimatedFrameLoop(const AnimatedFrameLoop &) = delete;
23
+ AnimatedFrameLoop &operator=(const AnimatedFrameLoop &) = delete;
24
+
25
+ // Any thread. `render` runs on the UI thread once each display frame until `stop`. A start while
26
+ // running replaces the callback.
27
+ void start(std::function<void()> render);
28
+ // Any thread, the render itself too. The loop runs while it has had more starts than stops, as
29
+ // React Native's manager makes them in turn but they can come out of order: a start that
30
+ // overtakes the stop before it keeps the loop running, and a stop that overtakes its start
31
+ // leaves it stopped.
32
+ void stop();
33
+ // Any thread but the render's: stops the loop for good, once a render running on another thread
34
+ // has returned. A reload closes it before it destroys the ReactHost whose manager renders here.
35
+ void close();
36
+
37
+ // Whether it renders each frame, and whether it is closed. Any thread.
38
+ bool running() const;
39
+ bool closed() const;
40
+ // How many stops or closes are waiting for a render on another thread to return. Any thread.
41
+ int waiting() const;
42
+
43
+ // What a frame waiting for the loop holds: the loop may be gone by the frame.
44
+ struct State;
45
+
46
+ private:
47
+ std::shared_ptr<State> state_;
48
+ };
49
+
50
+ // React Native's animated module over this loop, for a ReactHost: one each, as a reload's new
51
+ // instance has a new UIManager. Animated's native driver and the engine's native paint then run on
52
+ // the host's frames instead of a commit a frame from JavaScript.
53
+ std::shared_ptr<facebook::react::NativeAnimatedNodesManagerProvider> animatedNodesManagerProvider(
54
+ std::shared_ptr<AnimatedFrameLoop> loop);
55
+
56
+ } // namespace ngn