@ng-native/desktop 0.23.0 → 0.24.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 (54) hide show
  1. package/native/CMakeLists.txt +3 -2
  2. package/native/appkit/CMakeLists.txt +25 -4
  3. package/native/appkit/camera-sheet.h +59 -0
  4. package/native/appkit/camera-sheet.mm +344 -0
  5. package/native/appkit/camera-view.mm +5 -1
  6. package/native/appkit/camera.h +22 -0
  7. package/native/appkit/camera.mm +203 -69
  8. package/native/appkit/cg-canvas.h +8 -1
  9. package/native/appkit/cg-canvas.mm +166 -21
  10. package/native/appkit/header-toolbar.mm +4 -1
  11. package/native/appkit/host-view.mm +29 -1
  12. package/native/appkit/main.mm +29 -69
  13. package/native/appkit/photo-library.mm +6 -6
  14. package/native/appkit/surface-view.mm +5 -1
  15. package/native/appkit/svg-view.h +2 -1
  16. package/native/appkit/svg-view.mm +49 -3
  17. package/native/appkit/tab-walk.h +31 -0
  18. package/native/appkit/tab-walk.mm +64 -0
  19. package/native/appkit/text-input-field.h +5 -0
  20. package/native/appkit/text-input-field.mm +101 -20
  21. package/native/appkit/text-layout.h +1 -1
  22. package/native/appkit/text-layout.mm +16 -8
  23. package/native/appkit/web-view-component.h +4 -3
  24. package/native/appkit/web-view-component.mm +8 -2
  25. package/native/appkit/web-view.mm +7 -0
  26. package/native/core/include/ngn/app-menus.h +8 -3
  27. package/native/core/include/ngn/back-swipe.h +16 -7
  28. package/native/core/include/ngn/camera.h +103 -9
  29. package/native/core/include/ngn/core-modules.h +3 -0
  30. package/native/core/include/ngn/dom-web-view.h +53 -0
  31. package/native/core/include/ngn/photo-library.h +7 -3
  32. package/native/core/include/ngn/runtime.h +10 -8
  33. package/native/core/include/ngn/safe-areas.h +5 -0
  34. package/native/core/include/ngn/surface-metrics.h +51 -0
  35. package/native/core/include/ngn/svg.h +49 -8
  36. package/native/core/include/ngn/text-input.h +9 -0
  37. package/native/core/include/ngn/web-view.h +6 -2
  38. package/native/core/src/app-menus.cpp +10 -3
  39. package/native/core/src/back-swipe.cpp +12 -5
  40. package/native/core/src/dom-web-view.cpp +45 -0
  41. package/native/core/src/libraries/rnsvg.cpp +13 -0
  42. package/native/core/src/modules/app-modules.cpp +20 -13
  43. package/native/core/src/modules/camera.cpp +203 -23
  44. package/native/core/src/modules/photo-library.cpp +22 -8
  45. package/native/core/src/mounting-manager.cpp +4 -0
  46. package/native/core/src/runtime.cpp +6 -8
  47. package/native/core/src/safe-areas.cpp +7 -0
  48. package/native/core/src/svg.cpp +324 -17
  49. package/native/core/src/text-input.cpp +13 -0
  50. package/native/core/src/web-view.cpp +1 -1
  51. package/native/scripts/build.sh +5 -1
  52. package/native/scripts/launch-probe.sh +60 -0
  53. package/package.json +2 -2
  54. package/prebuilt.json +6 -6
@@ -10,6 +10,7 @@
10
10
  #include "ngn/network.h"
11
11
  #include "ngn/reload-thread.h"
12
12
  #include "ngn/surface-book.h"
13
+ #include "ngn/surface-metrics.h"
13
14
  #include "ngn/native-controls.h"
14
15
  #include "ngn/text-measurer.h"
15
16
 
@@ -36,14 +37,6 @@ class Runtime;
36
37
 
37
38
  namespace ngn {
38
39
 
39
- struct SurfaceMetrics {
40
- facebook::react::Size size{};
41
- // Device pixels per point.
42
- float pointScale{2};
43
- // The text size multiplier.
44
- float fontScale{1};
45
- };
46
-
47
40
  // The OS's HTTP and WebSocket clients, which Networking, WebSocket and the dev server use.
48
41
  struct NetworkClients {
49
42
  std::shared_ptr<Http> http;
@@ -85,6 +78,9 @@ class Runtime {
85
78
  // that resumes it; then that it resumed. On the inspector's thread. Set them before loadBundle.
86
79
  std::function<void(std::function<void()> resume)> onDebuggerPaused;
87
80
  std::function<void()> onDebuggerResumed;
81
+ // Whether the app lays out right to left, asked as each JavaScript instance loads (the first
82
+ // and each reload's) and kept for its run, as its I18nManager keeps isRTL. Set before loadBundle.
83
+ std::function<bool()> rightToLeft;
88
84
 
89
85
  // Loads the bundle (JavaScript or Hermes bytecode). False if it could not be read or downloaded.
90
86
  bool loadBundle();
@@ -92,6 +88,10 @@ class Runtime {
92
88
  const std::optional<DevServer> &devServer() const {
93
89
  return devServer_;
94
90
  }
91
+ // Whether the running instance's surfaces lay out right to left, as its I18nManager.isRTL says.
92
+ bool laysOutRightToLeft() const {
93
+ return direction_.rightToLeft();
94
+ }
95
95
  // Tears the runtime down and starts it again on a fresh download of the bundle, with every
96
96
  // running surface restarted. Runs off the calling thread; a second call while one runs is
97
97
  // dropped. `done` gets whether the bundle loaded, on the UI thread once the reload's thread has
@@ -156,6 +156,8 @@ class Runtime {
156
156
  // Taken before mutex_ when both are, and never held by a reload while it holds mutex_.
157
157
  std::mutex surfacesMutex_;
158
158
  SurfaceBook<Surface> surfaces_;
159
+ // The direction the running instance's surfaces lay out from.
160
+ SurfaceDirection direction_{[this] { return rightToLeft && rightToLeft(); }};
159
161
  };
160
162
 
161
163
  } // namespace ngn
@@ -36,6 +36,11 @@ struct ContainerInsets {
36
36
  // The part of a container's insets a view at `frame` (in the container's coordinates) overlaps.
37
37
  EdgeInsets insetsWithin(const ContainerInsets &container, const Rect &frame);
38
38
 
39
+ // How far window controls spanning `minX` to `maxX` (in a container `width` wide) reach in from
40
+ // its leading edge: the left one, or the right one right to left, where AppKit puts the controls
41
+ // on the right. 0 when they lie outside it.
42
+ double titlebarLeading(double minX, double maxX, double width, bool rightToLeft);
43
+
39
44
  class SafeAreas {
40
45
  public:
41
46
  virtual ~SafeAreas() = default;
@@ -0,0 +1,51 @@
1
+ // What a surface is laid out at: its size, scale, text size and direction. Header-only, and
2
+ // toolkit-free.
3
+ #pragma once
4
+
5
+ #include <react/renderer/core/LayoutConstraints.h>
6
+ #include <react/renderer/graphics/Size.h>
7
+
8
+ #include <atomic>
9
+ #include <functional>
10
+ #include <utility>
11
+
12
+ namespace ngn {
13
+
14
+ struct SurfaceMetrics {
15
+ facebook::react::Size size{};
16
+ // Device pixels per point.
17
+ float pointScale{2};
18
+ // The text size multiplier.
19
+ float fontScale{1};
20
+ };
21
+
22
+ // The surface's root constraints: its size, and the direction its layout starts from, which React
23
+ // Native's iOS surfaces take from I18nManager.
24
+ inline facebook::react::LayoutConstraints surfaceConstraints(const SurfaceMetrics &metrics, bool rightToLeft) {
25
+ using facebook::react::LayoutDirection;
26
+ return {
27
+ .minimumSize = metrics.size,
28
+ .maximumSize = metrics.size,
29
+ .layoutDirection = rightToLeft ? LayoutDirection::RightToLeft : LayoutDirection::LeftToRight,
30
+ };
31
+ }
32
+
33
+ // The direction a runtime's surfaces lay out from: what `read` answers as each JavaScript instance
34
+ // starts (the first load and each reload), kept for that instance's run as I18nManager's constants
35
+ // are, so a surface started or resized meanwhile agrees with what JavaScript reads.
36
+ class SurfaceDirection {
37
+ public:
38
+ explicit SurfaceDirection(std::function<bool()> read) : read_(std::move(read)) {}
39
+ void instanceStarted() {
40
+ rightToLeft_ = read_ && read_();
41
+ }
42
+ bool rightToLeft() const {
43
+ return rightToLeft_;
44
+ }
45
+
46
+ private:
47
+ std::function<bool()> read_;
48
+ std::atomic<bool> rightToLeft_{false};
49
+ };
50
+
51
+ } // namespace ngn
@@ -6,9 +6,9 @@
6
6
  // backend's view for the RNSVGSvgView draws it by calling drawSvg with an SvgCanvas over its own
7
7
  // graphics context. Everything SVG means (inheritance through `propList`, `currentColor`,
8
8
  // lengths and percentages, the viewBox, path data and arcs, gradients and their units, clip
9
- // paths, masks, `use` and `symbol`, markers, patterns and filters) is decided here; the canvas only
10
- // draws paths, gradients, images and runs of text, tiles a pattern's tile, and runs a filter's
11
- // steps over pixels with runSvgFilter.
9
+ // paths, masks, `use` and `symbol`, markers, patterns and filters, text anchors and text along a
10
+ // path) is decided here; the canvas only measures and draws runs of text, draws paths, gradients
11
+ // and images, tiles a pattern's tile, and runs a filter's steps over pixels with runSvgFilter.
12
12
  #pragma once
13
13
 
14
14
  #include "ngn/view-tree.h"
@@ -112,8 +112,11 @@ enum class SvgKind {
112
112
  Mask,
113
113
  Symbol,
114
114
  Image,
115
+ // A box of native views: what is in it is views, not svg elements, which the canvas draws.
116
+ ForeignObject,
115
117
  Text,
116
118
  TSpan,
119
+ TextPath,
117
120
  Marker,
118
121
  Pattern,
119
122
  Filter,
@@ -200,11 +203,19 @@ struct SvgElement {
200
203
 
201
204
  std::string uri; // an image's source
202
205
 
203
- // Text: a span's characters, the font, and the positions written on the element.
206
+ // A foreignObject's own view, whose children the canvas draws.
207
+ Tag view{-1};
208
+
209
+ // Text: a span's characters, the font, its text-anchor ("start", "middle" or "end"; empty
210
+ // inherits), and the positions written on the element. A textPath's path is `href`, how far
211
+ // along it the text starts is the length "startOffset", and `side` "right" sets it along the
212
+ // path reversed.
204
213
  std::string content;
205
214
  SvgLength fontSize;
206
215
  std::string fontFamily;
207
216
  std::string fontWeight;
217
+ std::string textAnchor;
218
+ std::string side;
208
219
  std::vector<SvgLength> xs, ys, dxs, dys;
209
220
 
210
221
  bool operator==(const SvgElement &) const = default;
@@ -267,6 +278,16 @@ struct SvgMarkerVertex {
267
278
  // The vertices a path's markers are drawn at, in order: the first is the start, the last the end.
268
279
  std::vector<SvgMarkerVertex> svgMarkerVertices(const SvgPath &path);
269
280
 
281
+ // A glyph as text along a path draws it: what draws as one (a grapheme cluster, or the clusters a
282
+ // ligature joins), where it starts in its shaped run and its advance there, kerning included, and
283
+ // the canvas's own record of the glyphs the run shaped for it, which glyphCluster draws.
284
+ struct SvgGlyphCluster {
285
+ std::string text;
286
+ double x{0};
287
+ double advance{0};
288
+ std::shared_ptr<const void> glyphs;
289
+ };
290
+
270
291
  // A pattern's tile: what one tile covers in the pattern's own space, and from that space to the
271
292
  // user space the pattern fills.
272
293
  struct SvgPatternTile {
@@ -347,15 +368,26 @@ class SvgCanvas {
347
368
  virtual void beginFilter(const SvgFilter &filter) = 0;
348
369
  virtual void endFilter() = 0;
349
370
  virtual void image(const std::string &uri, const SvgRect &rect, const std::string &align, int meetOrSlice, double opacity) = 0;
350
- // Draws `text` with its baseline's start at (x, y) and answers its advance.
351
- virtual double text(
371
+ // The advance of `text` in the font, as text() draws it.
372
+ virtual double measureText(const std::string &text, double fontSize, const std::string &fontFamily, const std::string &fontWeight) = 0;
373
+ // `text` shaped in the font as one run, split into the glyphs text along a path draws one at a
374
+ // time, in the order of the text.
375
+ virtual std::vector<SvgGlyphCluster> glyphClusters(
376
+ const std::string &text, double fontSize, const std::string &fontFamily, const std::string &fontWeight) = 0;
377
+ // Draws a cluster's glyphs as its run shaped them, contextual forms kept, with the cluster's start
378
+ // on the baseline at (x, y).
379
+ virtual void glyphCluster(const SvgGlyphCluster &cluster, double x, double y, const SvgPaint &fill) = 0;
380
+ // Draws `text` with its baseline's start at (x, y).
381
+ virtual void text(
352
382
  const std::string &text,
353
383
  double x,
354
384
  double y,
355
385
  double fontSize,
356
386
  const std::string &fontFamily,
357
387
  const std::string &fontWeight,
358
- const SvgPaint *fill) = 0;
388
+ const SvgPaint &fill) = 0;
389
+ // Draws the native views in `view` (a foreignObject's), each at its frame in `view`.
390
+ virtual void views(Tag view) = 0;
359
391
  };
360
392
 
361
393
  // Draws `document` into a viewport of `width` by `height`, its origin at the canvas's.
@@ -372,21 +404,30 @@ class SvgDrawings {
372
404
 
373
405
  // A view was made or its props changed, or `parent`'s children changed.
374
406
  void changed(const ViewTree &tree, Tag tag);
407
+ // A view's layout or state changed: what it draws, not what it is.
408
+ void relaidOut(const ViewTree &tree, Tag tag);
375
409
  void deleted(Tag tag);
376
410
 
377
411
  struct Drawing {
378
412
  Tag svg{-1};
379
413
  std::shared_ptr<const SvgDocument> document;
380
414
  };
381
- // The svgs whose documents changed since the last call.
415
+ // The svgs whose documents changed since the last call, and those whose documents are the same
416
+ // but draw a view in a foreignObject that changed.
382
417
  std::vector<Drawing> settle(const ViewTree &tree);
383
418
 
384
419
  private:
385
420
  std::optional<SvgElement> element(const ViewTree &tree, Tag tag) const;
386
421
  std::optional<SvgNode> node(const ViewTree &tree, Tag tag) const;
422
+ void mark(const ViewTree &tree, Tag tag, bool repaint);
423
+ void repaintAbove(const ViewTree &tree, Tag tag);
387
424
 
388
425
  Reader reader_;
389
426
  std::unordered_set<Tag> dirty_;
427
+ // Svgs to draw again though their documents are the same.
428
+ std::unordered_set<Tag> repaint_;
429
+ // The foreignObjects mounted, whose views are drawn into their svgs.
430
+ std::unordered_set<Tag> foreign_;
390
431
  std::unordered_map<Tag, std::shared_ptr<const SvgDocument>> drawn_;
391
432
  };
392
433
 
@@ -82,6 +82,15 @@ struct TextInputOptions {
82
82
  // secure entry turns every substitution and check off and never capitalizes.
83
83
  TextInputOptions textInputOptions(const DesktopTextInputProps &props);
84
84
 
85
+ // Where a field puts its text and placeholder, as React Native iOS has a TextInput's: Left, Right,
86
+ // Center or Justified. A TextInput's text attributes carry no layout direction, so an alignment that
87
+ // is set resolves as RCTResolveTextAlignment resolves a left-to-right fragment's (natural and start
88
+ // left, end right, left and right as they are). With none set, UIKit's natural alignment follows the
89
+ // view's direction, the layout's: right in a right-to-left layout, left otherwise.
90
+ facebook::react::TextAlignment inputAlignment(
91
+ std::optional<facebook::react::TextAlignment> alignment,
92
+ facebook::react::LayoutDirection layoutDirection);
93
+
85
94
  // How much of an insertion of `inserted` units, replacing `replaced` of the field's `current`, fits
86
95
  // in `maxLength`: all of it, a leading part, or none.
87
96
  std::size_t insertionThatFits(
@@ -70,6 +70,9 @@ struct WebViewConfig {
70
70
  std::string applicationNameForUserAgent;
71
71
  // Nothing when the prop is not set, and then no origin is refused.
72
72
  std::optional<std::vector<std::string>> originWhitelist;
73
+ // Whether a navigation waits for the app's answer (shouldStartLoadWithRequest), as
74
+ // react-native-webview's does. Expo's DOM web view (dom-web-view.h) lets each one go ahead.
75
+ bool asksApp{true};
73
76
  bool operator==(const WebViewConfig &) const = default;
74
77
  };
75
78
 
@@ -85,8 +88,9 @@ bool passesOriginWhitelist(const std::vector<std::string> &whitelist, const std:
85
88
  // What a navigation to `url` waits for: the app's answer, or nothing. A page navigation outside
86
89
  // `originWhitelist` is handed to the OS only when the user made it (`navigationType`, the library's
87
90
  // name for it, is "click" or "formsubmit") and Linking would open it (externalUrlAllowed); any
88
- // other is cancelled, so a page's script cannot open a scheme or a file on its own.
89
- enum class NavigationStep { AskApp, OpenExternally, Cancel };
91
+ // other is cancelled, so a page's script cannot open a scheme or a file on its own. Any other
92
+ // navigation is the app's to answer, or, without `asksApp`, goes ahead.
93
+ enum class NavigationStep { AskApp, Allow, OpenExternally, Cancel };
90
94
  NavigationStep navigationStep(const WebViewConfig &config, const std::string &url, bool topFrame, std::string_view navigationType);
91
95
 
92
96
  // The script, at document start, that gives the page window.ReactNativeWebView.postMessage, sent
@@ -169,14 +169,16 @@ std::vector<MenuItem> parseMenuBar(const folly::dynamic &groups, const DefaultMe
169
169
  return bar;
170
170
  }
171
171
 
172
- std::optional<NavigationDirection> navigationFor(NavigationInput input) {
172
+ std::optional<NavigationDirection> navigationFor(NavigationInput input, bool rightToLeft) {
173
173
  switch (input) {
174
174
  case NavigationInput::MouseButton4:
175
- case NavigationInput::SwipeRight:
176
175
  return NavigationDirection::Back;
177
176
  case NavigationInput::MouseButton5:
178
- case NavigationInput::SwipeLeft:
179
177
  return NavigationDirection::Forward;
178
+ case NavigationInput::SwipeRight:
179
+ return rightToLeft ? NavigationDirection::Forward : NavigationDirection::Back;
180
+ case NavigationInput::SwipeLeft:
181
+ return rightToLeft ? NavigationDirection::Back : NavigationDirection::Forward;
180
182
  }
181
183
  return std::nullopt;
182
184
  }
@@ -304,6 +306,11 @@ std::vector<HistoryMenuItem> historyMenu(const WindowHistory &history, Navigatio
304
306
  return items;
305
307
  }
306
308
 
309
+ NavigationDirection chevronAt(double x, double width, bool rightToLeft) {
310
+ bool left = x < width / 2;
311
+ return left != rightToLeft ? NavigationDirection::Back : NavigationDirection::Forward;
312
+ }
313
+
307
314
  std::shared_ptr<void> MenuHost::listen(Listener listener) {
308
315
  return listeners_.add(std::move(listener));
309
316
  }
@@ -4,13 +4,14 @@
4
4
 
5
5
  namespace ngn {
6
6
 
7
- bool BackSwipe::begin(std::optional<BackSwipeTarget> target, double width) {
7
+ bool BackSwipe::begin(std::optional<BackSwipeTarget> target, double width, bool rightToLeft) {
8
8
  if (phase_ != Phase::Idle || !target || width <= 0) {
9
9
  return false;
10
10
  }
11
11
  phase_ = Phase::Tracking;
12
12
  target_ = target;
13
13
  width_ = width;
14
+ rightToLeft_ = rightToLeft;
14
15
  offset_ = 0;
15
16
  lastMove_ = 0;
16
17
  return true;
@@ -21,14 +22,14 @@ BackSwipeFrame BackSwipe::frameAt(double progress, bool belowShown) const {
21
22
  if (target_ && target_->style == SwipeStyle::Fade) {
22
23
  return {.offset = 0, .opacity = 1 - progress, .belowShown = belowShown};
23
24
  }
24
- return {.offset = progress * width_, .opacity = 1, .belowShown = belowShown};
25
+ return {.offset = progress * towardsBack(width_, rightToLeft_), .opacity = 1, .belowShown = belowShown};
25
26
  }
26
27
 
27
28
  BackSwipeFrame BackSwipe::moved(double dx) {
28
29
  if (phase_ != Phase::Tracking) {
29
30
  return rest();
30
31
  }
31
- // The screen stops at its home edge: a move away from back past it does not drag it left.
32
+ // The screen stops at its home edge: a move away from back past it does not drag it further.
32
33
  offset_ = std::clamp(offset_ + dx, 0.0, width_);
33
34
  lastMove_ = dx;
34
35
  return frameAt(offset_ / width_, offset_ > 0);
@@ -84,8 +85,14 @@ bool BackSwipe::fingersDown() {
84
85
  return true;
85
86
  }
86
87
 
87
- SwipeBounds swipeBounds(bool canGoBack, bool canGoForward) {
88
- return {.min = canGoForward ? -1.0 : 0.0, .max = canGoBack ? 1.0 : 0.0};
88
+ double towardsBack(double right, bool rightToLeft) {
89
+ return rightToLeft ? -right : right;
90
+ }
91
+
92
+ SwipeBounds swipeBounds(bool canGoBack, bool canGoForward, bool rightToLeft) {
93
+ bool canGoLeft = rightToLeft ? canGoBack : canGoForward;
94
+ bool canGoRight = rightToLeft ? canGoForward : canGoBack;
95
+ return {.min = canGoLeft ? -1.0 : 0.0, .max = canGoRight ? 1.0 : 0.0};
89
96
  }
90
97
 
91
98
  } // namespace ngn
@@ -0,0 +1,45 @@
1
+ #include "ngn/dom-web-view.h"
2
+
3
+ #include "ngn/desktop-view-props.h"
4
+
5
+ #include <react/renderer/core/propsConversions.h>
6
+
7
+ using namespace facebook::react;
8
+
9
+ namespace ngn {
10
+
11
+ const char DomWebViewComponentName[] = "ViewManagerAdapter_ExpoDomWebViewModule";
12
+
13
+ DomWebViewProps::DomWebViewProps(const PropsParserContext &context, const DomWebViewProps &sourceProps, const RawProps &rawProps)
14
+ : ViewProps(context, sourceProps, rawProps),
15
+ HasDesktopProps{parseDesktopProps(context, sourceProps.desktop, rawProps)},
16
+ source(convertRawProp(context, rawProps, "source", sourceProps.source, folly::dynamic(nullptr))),
17
+ injectedJavaScript(convertRawProp(context, rawProps, "injectedJavaScript", sourceProps.injectedJavaScript, {})),
18
+ injectedJavaScriptBeforeContentLoaded(convertRawProp(
19
+ context, rawProps, "injectedJavaScriptBeforeContentLoaded", sourceProps.injectedJavaScriptBeforeContentLoaded, {})),
20
+ injectedJavaScriptObject(
21
+ convertRawProp(context, rawProps, "injectedJavaScriptObject", sourceProps.injectedJavaScriptObject, {})),
22
+ webviewDebuggingEnabled(
23
+ convertRawProp(context, rawProps, "webviewDebuggingEnabled", sourceProps.webviewDebuggingEnabled, false)) {}
24
+
25
+ std::optional<WebViewConfig> domWebViewConfig(const Props &props) {
26
+ const auto *own = dynamic_cast<const DomWebViewProps *>(&props);
27
+ if (own == nullptr) {
28
+ return std::nullopt;
29
+ }
30
+ WebViewConfig config;
31
+ if (const auto *uri = own->source.isObject() ? own->source.get_ptr("uri") : nullptr; uri != nullptr && uri->isString()) {
32
+ config.source.uri = uri->asString();
33
+ }
34
+ config.injectedJavaScript = own->injectedJavaScript;
35
+ config.injectedJavaScriptBeforeContentLoaded = own->injectedJavaScriptBeforeContentLoaded;
36
+ config.injectedJavaScriptForMainFrameOnly = false;
37
+ config.injectedJavaScriptBeforeContentLoadedForMainFrameOnly = false;
38
+ config.injectedJavaScriptObject = own->injectedJavaScriptObject;
39
+ config.messagingEnabled = true;
40
+ config.webviewDebuggingEnabled = own->webviewDebuggingEnabled;
41
+ config.asksApp = false;
42
+ return config;
43
+ }
44
+
45
+ } // namespace ngn
@@ -137,7 +137,9 @@ void common(SvgElement &e, const P &p) {
137
137
  if (font.isObject()) {
138
138
  auto family = font.getDefault("fontFamily", "");
139
139
  auto weight = font.getDefault("fontWeight", "");
140
+ auto anchor = font.getDefault("textAnchor", "");
140
141
  e.fontFamily = family.isString() ? family.getString() : "";
142
+ e.textAnchor = anchor.isString() ? anchor.getString() : "";
141
143
  e.fontWeight = weight.isString() ? weight.getString() : weight.isNumber() ? std::to_string(weight.asInt()) : "";
142
144
  }
143
145
  }
@@ -264,6 +266,10 @@ std::optional<SvgElement> svgElement(const Props &props) {
264
266
  e.uri = p->src.uri;
265
267
  e.align = p->align;
266
268
  e.meetOrSlice = p->meetOrSlice;
269
+ } else if (const auto *p = dynamic_cast<const RNSVGForeignObjectProps *>(&props)) {
270
+ e.kind = SvgKind::ForeignObject;
271
+ common(e, *p);
272
+ lengths(e, {{"x", &p->x}, {"y", &p->y}, {"width", &p->width}, {"height", &p->height}});
267
273
  } else if (const auto *p = dynamic_cast<const RNSVGTextProps *>(&props)) {
268
274
  e.kind = SvgKind::Text;
269
275
  common(e, *p);
@@ -273,6 +279,13 @@ std::optional<SvgElement> svgElement(const Props &props) {
273
279
  common(e, *p);
274
280
  text(e, *p);
275
281
  e.content = p->content;
282
+ } else if (const auto *p = dynamic_cast<const RNSVGTextPathProps *>(&props)) {
283
+ e.kind = SvgKind::TextPath;
284
+ common(e, *p);
285
+ text(e, *p);
286
+ e.href = p->href;
287
+ e.side = p->side;
288
+ lengths(e, {{"startOffset", &p->startOffset}});
276
289
  } else if (const auto *p = dynamic_cast<const RNSVGMarkerProps *>(&props)) {
277
290
  e.kind = SvgKind::Marker;
278
291
  common(e, *p);
@@ -190,28 +190,35 @@ std::shared_ptr<NativeModule> makeLinking(const CoreModuleServices &s) {
190
190
  return std::make_shared<Linking>(s);
191
191
  }
192
192
 
193
+ namespace {
194
+
195
+ // React Native iOS's keys and defaults: RTL is allowed and left and right swap, until the app
196
+ // says otherwise; the choice persists across launches.
197
+ bool i18nFlag(System &system, const char *key, bool fallback) {
198
+ auto value = system.preference(key);
199
+ return value && value->isBool() ? value->asBool() : fallback;
200
+ }
201
+
202
+ } // namespace
203
+
204
+ bool appRightToLeft(System &system) {
205
+ return i18nFlag(system, "RCTI18nUtil_forceRTL", false) ||
206
+ (i18nFlag(system, "RCTI18nUtil_allowRTL", true) && system.facts().rightToLeft);
207
+ }
208
+
193
209
  std::shared_ptr<NativeModule> makeI18n(const CoreModuleServices &s) {
194
210
  struct I18n : NativeModule {
195
211
  explicit I18n(const CoreModuleServices &s) : NativeModule("I18nManager") {
196
212
  auto system = s.system;
197
- // React Native iOS's keys and defaults: RTL is allowed and left and right swap, until the
198
- // app says otherwise; the choice persists across launches.
199
- auto flag = [system](const char *key, bool fallback) {
200
- auto value = system->preference(key);
201
- return value && value->isBool() ? value->asBool() : fallback;
202
- };
203
- constants([system, flag] {
204
- auto facts = system->facts();
205
- bool forced = flag("RCTI18nUtil_forceRTL", false);
206
- bool allowed = flag("RCTI18nUtil_allowRTL", true);
207
- std::string locale = facts.locale;
213
+ constants([system] {
214
+ std::string locale = system->facts().locale;
208
215
  for (auto &c : locale) {
209
216
  if (c == '-') {
210
217
  c = '_';
211
218
  }
212
219
  }
213
- return folly::dynamic::object("isRTL", forced || (allowed && facts.rightToLeft))(
214
- "doLeftAndRightSwapInRTL", flag("RCTI18nUtil_makeRTLFlipLeftAndRightStyles", true))(
220
+ return folly::dynamic::object("isRTL", appRightToLeft(*system))(
221
+ "doLeftAndRightSwapInRTL", i18nFlag(*system, "RCTI18nUtil_makeRTLFlipLeftAndRightStyles", true))(
215
222
  "localeIdentifier", locale);
216
223
  });
217
224
  auto setter = [system](const char *key) {