react-native-tvos 0.88.0-0rc2 → 0.88.1-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 (75) hide show
  1. package/Libraries/Animated/components/AnimatedScrollView.js +2 -2
  2. package/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm +26 -1
  3. package/Libraries/AppDelegate/RCTUIConfiguratorProtocol.h +1 -1
  4. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +8 -5
  5. package/Libraries/Components/Button.js +4 -2
  6. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +7 -4
  7. package/Libraries/Components/Pressable/Pressable.js +4 -2
  8. package/Libraries/Components/TextInput/InputAccessoryView.js +8 -6
  9. package/Libraries/Components/TextInput/TextInput.js +5 -5
  10. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +85 -84
  11. package/Libraries/Components/View/ViewAccessibility.js +8 -4
  12. package/Libraries/Core/ReactNativeVersion.js +2 -2
  13. package/Libraries/Image/ImageProps.js +38 -18
  14. package/Libraries/LogBox/LogBoxNotificationContainer.js +7 -1
  15. package/Libraries/LogBox/UI/LogBoxNotificationDismissButton.js +3 -3
  16. package/Libraries/Modal/Modal.js +4 -2
  17. package/Libraries/StyleSheet/StyleSheet.js +3 -9
  18. package/Libraries/StyleSheet/StyleSheet.js.flow +3 -9
  19. package/Libraries/StyleSheet/StyleSheetTypes.js +12 -9
  20. package/Libraries/StyleSheet/splitLayoutProps.js +6 -6
  21. package/Libraries/Text/Text.js +6 -6
  22. package/React/Base/RCTStatusBarAppearance.h +30 -0
  23. package/React/Base/RCTStatusBarAppearance.mm +66 -0
  24. package/React/Base/RCTVersion.m +2 -2
  25. package/React/CoreModules/RCTStatusBarManager.mm +34 -9
  26. package/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +13 -5
  27. package/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm +30 -2
  28. package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +9 -0
  29. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +8 -1
  30. package/ReactAndroid/gradle.properties +1 -1
  31. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +2 -2
  32. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +16 -2
  33. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTypefaceUtils.kt +4 -0
  34. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextDecorationStyle.kt +32 -4
  35. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt +4 -0
  36. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt +17 -12
  37. package/ReactAndroid/src/main/res/views/uimanager/values/ids.xml +3 -0
  38. package/ReactApple/RCTSwiftUI/RCTSwiftUIContainerView.swift +4 -0
  39. package/ReactCommon/cxxreact/ReactNativeVersion.h +3 -3
  40. package/ReactCommon/jsi/jsi/decorator.h +64 -0
  41. package/ReactCommon/jsi/jsi/jsi.cpp +2 -4
  42. package/ReactCommon/jsi/jsi/test/testlib.cpp +285 -8
  43. package/ReactCommon/jsi/jsi/test/testlib.h +1 -0
  44. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +2 -1
  45. package/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +6 -2
  46. package/ReactCommon/yoga/yoga/algorithm/PixelGrid.cpp +49 -19
  47. package/package.json +8 -8
  48. package/scripts/cocoapods/utils.rb +51 -0
  49. package/scripts/codegen/templates/Package.swift.spm-template +13 -2
  50. package/scripts/react_native_pods.rb +1 -0
  51. package/scripts/setup-apple-spm.js +10 -5
  52. package/scripts/spm/autolinking-plugins.js +2 -1
  53. package/scripts/spm/flavored-frameworks.js +1 -0
  54. package/scripts/spm/generate-spm-autolinking.js +34 -96
  55. package/scripts/spm/generate-spm-xcodeproj.js +798 -285
  56. package/scripts/spm/ios-deployment-target.js +16 -63
  57. package/scripts/spm/spm-pbxproj.js +8 -3
  58. package/scripts/spm/spm-types.js +2 -15
  59. package/scripts/spm/sync-spm-autolinking.js +57 -23
  60. package/scripts/spm/xcconfig-files.js +149 -0
  61. package/sdks/.hermesv1version +1 -1
  62. package/sdks/hermes-engine/version.properties +1 -1
  63. package/types_DEPRECATED/index.d.ts +1 -0
  64. package/types_DEPRECATED/src/private/assets/AssetRegistry.d.ts +44 -0
  65. package/types_generated/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +7 -6
  66. package/types_generated/Libraries/Components/Button.d.ts +30 -29
  67. package/types_generated/Libraries/Components/Keyboard/KeyboardAvoidingView.d.ts +8 -7
  68. package/types_generated/Libraries/Components/Pressable/Pressable.d.ts +6 -5
  69. package/types_generated/Libraries/Components/TextInput/InputAccessoryView.d.ts +7 -6
  70. package/types_generated/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +26 -25
  71. package/types_generated/Libraries/Components/View/ViewAccessibility.d.ts +23 -22
  72. package/types_generated/Libraries/Image/ImageProps.d.ts +39 -36
  73. package/types_generated/Libraries/Modal/Modal.d.ts +4 -3
  74. package/types_generated/Libraries/StyleSheet/StyleSheet.d.ts +5 -8
  75. package/types_generated/Libraries/StyleSheet/StyleSheetTypes.d.ts +10 -10
@@ -36,6 +36,9 @@
36
36
  <!--tag is used to store accessibilityStateExpanded -->
37
37
  <item type="id" name="accessibility_state_expanded"/>
38
38
 
39
+ <!--tag is used to store whether accessibilityState.disabled disabled the view -->
40
+ <item type="id" name="accessibility_state_disabled"/>
41
+
39
42
  <!--tag is used to store accessibilityLabel tag-->
40
43
  <item type="id" name="accessibility_label"/>
41
44
 
@@ -15,6 +15,10 @@ import UIKit
15
15
  @objc public override init() {
16
16
  super.init()
17
17
  hostingController = UIHostingController(rootView: SwiftUIContainerView(viewModel: containerViewModel))
18
+ if #available(iOS 16.4, tvOS 16.4, *) {
19
+ // Disable implicit safe area insets or else the view is shifted by the safe area insets
20
+ hostingController?.safeAreaRegions = []
21
+ }
18
22
  guard let view = hostingController?.view else {
19
23
  return
20
24
  }
@@ -14,15 +14,15 @@
14
14
 
15
15
  #define REACT_NATIVE_VERSION_MAJOR 0
16
16
  #define REACT_NATIVE_VERSION_MINOR 88
17
- #define REACT_NATIVE_VERSION_PATCH 0
17
+ #define REACT_NATIVE_VERSION_PATCH 1
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
21
  struct ReactNativeVersionType {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 88;
24
- int32_t Patch = 0;
25
- std::string_view Prerelease = "0rc2";
24
+ int32_t Patch = 1;
25
+ std::string_view Prerelease = "0";
26
26
  };
27
27
 
28
28
  constexpr ReactNativeVersionType ReactNativeVersion;
@@ -148,6 +148,31 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
148
148
  Instrumentation& instrumentation() override {
149
149
  return *this;
150
150
  }
151
+ Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override {
152
+ return plain_.createValueFromJsonUtf8(json, length);
153
+ }
154
+
155
+ Value createError(const String& msg) override {
156
+ return plain().createError(msg);
157
+ }
158
+ Value createEvalError(const String& msg) override {
159
+ return plain().createEvalError(msg);
160
+ }
161
+ Value createRangeError(const String& msg) override {
162
+ return plain().createRangeError(msg);
163
+ }
164
+ Value createReferenceError(const String& msg) override {
165
+ return plain().createReferenceError(msg);
166
+ }
167
+ Value createSyntaxError(const String& msg) override {
168
+ return plain().createSyntaxError(msg);
169
+ }
170
+ Value createTypeError(const String& msg) override {
171
+ return plain().createTypeError(msg);
172
+ }
173
+ Value createURIError(const String& msg) override {
174
+ return plain().createURIError(msg);
175
+ }
151
176
 
152
177
  protected:
153
178
  // plain is generally going to be a reference to an object managed
@@ -243,6 +268,10 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
243
268
  return plain_.utf16(sym);
244
269
  }
245
270
 
271
+ size_t length(const String& str) override {
272
+ return plain_.length(str);
273
+ }
274
+
246
275
  void getStringData(
247
276
  const jsi::String& str,
248
277
  void* ctx,
@@ -702,6 +731,35 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
702
731
  return RD::isInspectable();
703
732
  }
704
733
 
734
+ Value createError(const String& msg) override {
735
+ Around around{with_};
736
+ return RD::createError(msg);
737
+ }
738
+ Value createEvalError(const String& msg) override {
739
+ Around around{with_};
740
+ return RD::createEvalError(msg);
741
+ }
742
+ Value createRangeError(const String& msg) override {
743
+ Around around{with_};
744
+ return RD::createRangeError(msg);
745
+ }
746
+ Value createReferenceError(const String& msg) override {
747
+ Around around{with_};
748
+ return RD::createReferenceError(msg);
749
+ }
750
+ Value createSyntaxError(const String& msg) override {
751
+ Around around{with_};
752
+ return RD::createSyntaxError(msg);
753
+ }
754
+ Value createTypeError(const String& msg) override {
755
+ Around around{with_};
756
+ return RD::createTypeError(msg);
757
+ }
758
+ Value createURIError(const String& msg) override {
759
+ Around around{with_};
760
+ return RD::createURIError(msg);
761
+ }
762
+
705
763
  // The jsi:: prefix is necessary because MSVC compiler complains C2247:
706
764
  // Instrumentation is not accessible because RuntimeDecorator uses private
707
765
  // to inherit from Instrumentation.
@@ -822,6 +880,11 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
822
880
  return RD::utf16(sym);
823
881
  }
824
882
 
883
+ size_t length(const String& str) override {
884
+ Around around{with_};
885
+ return RD::length(str);
886
+ }
887
+
825
888
  void getStringData(
826
889
  const jsi::String& str,
827
890
  void* ctx,
@@ -996,6 +1059,7 @@ class WithRuntimeDecorator : public RuntimeDecorator<Plain, Base> {
996
1059
  }
997
1060
  ArrayBuffer createArrayBuffer(
998
1061
  std::shared_ptr<MutableBuffer> buffer) override {
1062
+ Around around{with_};
999
1063
  return RD::createArrayBuffer(std::move(buffer));
1000
1064
  }
1001
1065
  size_t size(const Array& a) override {
@@ -923,7 +923,7 @@ String Value::asString(IRuntime& rt) && {
923
923
 
924
924
  String Value::toString(IRuntime& runtime) const {
925
925
  Function toString = runtime.global().getPropertyAsFunction(runtime, "String");
926
- return toString.call(runtime, *this).getString(runtime);
926
+ return toString.call(runtime, *this).asString(runtime);
927
927
  }
928
928
 
929
929
  uint64_t BigInt::asUint64(IRuntime& runtime) const {
@@ -967,9 +967,7 @@ JSError::JSError(IRuntime& rt, Value&& value) {
967
967
 
968
968
  JSError::JSError(IRuntime& rt, std::string msg) : message_(std::move(msg)) {
969
969
  try {
970
- setValue(
971
- rt,
972
- callGlobalFunction(rt, "Error", String::createFromUtf8(rt, message_)));
970
+ setValue(rt, rt.createError(String::createFromUtf8(rt, message_)));
973
971
  } catch (const JSIException& ex) {
974
972
  message_ = std::string(ex.what()) + " (while raising " + message_ + ")";
975
973
  setValue(rt, String::createFromUtf8(rt, message_));
@@ -138,6 +138,61 @@ TEST_P(JSITest, StringLengthTest) {
138
138
  EXPECT_EQ(invalid.length(rt), 2);
139
139
  }
140
140
 
141
+ TEST_P(JSITest, DecoratorForwardsStringLength) {
142
+ // Decorators should forward length(const String&) to the decorated runtime
143
+ // instead of falling back to the default Runtime::length, which copies the
144
+ // string via utf16() and bypasses the runtime's own implementation.
145
+ class Inner : public RuntimeDecorator<Runtime, Runtime> {
146
+ public:
147
+ explicit Inner(Runtime& rt) : RuntimeDecorator(rt) {}
148
+
149
+ size_t length(const String&) override {
150
+ ++lengthCalls;
151
+ return 42;
152
+ }
153
+
154
+ std::u16string utf16(const String& str) override {
155
+ ++utf16Calls;
156
+ return RuntimeDecorator::utf16(str);
157
+ }
158
+
159
+ int lengthCalls = 0;
160
+ int utf16Calls = 0;
161
+ };
162
+
163
+ class Outer : public RuntimeDecorator<Runtime, Runtime> {
164
+ public:
165
+ explicit Outer(Runtime& rt) : RuntimeDecorator(rt) {}
166
+ };
167
+
168
+ struct Count {
169
+ void before() {
170
+ ++beforeCalls;
171
+ }
172
+ void after() {
173
+ ++afterCalls;
174
+ }
175
+ int beforeCalls = 0;
176
+ int afterCalls = 0;
177
+ };
178
+
179
+ Inner inner(rt);
180
+ String str = String::createFromAscii(inner, "hello");
181
+
182
+ Outer outer(inner);
183
+ EXPECT_EQ(str.length(outer), 42);
184
+ EXPECT_EQ(inner.lengthCalls, 1);
185
+ EXPECT_EQ(inner.utf16Calls, 0);
186
+
187
+ Count count;
188
+ WithRuntimeDecorator<Count> with(inner, count);
189
+ EXPECT_EQ(str.length(with), 42);
190
+ EXPECT_EQ(inner.lengthCalls, 2);
191
+ EXPECT_EQ(inner.utf16Calls, 0);
192
+ EXPECT_EQ(count.beforeCalls, 1);
193
+ EXPECT_EQ(count.afterCalls, 1);
194
+ }
195
+
141
196
  TEST_P(JSITest, ObjectTest) {
142
197
  eval("x = {1:2, '3':4, 5:'six', 'seven':['eight', 'nine']}");
143
198
  Object x = rt.global().getPropertyAsObject(rt, "x");
@@ -1154,10 +1209,24 @@ TEST_P(JSITest, JSErrorsCanBeConstructedWithStack) {
1154
1209
  }
1155
1210
 
1156
1211
  TEST_P(JSITest, JSErrorDoesNotInfinitelyRecurse) {
1157
- Value globalError = rt.global().getProperty(rt, "Error");
1158
- rt.global().setProperty(rt, "Error", Value::undefined());
1212
+ // JSError(rt, message) creates its value with createError. Use the default
1213
+ // implementation, which calls the global Error constructor, so that removing
1214
+ // it below makes creating the Error fail even if the runtime has a native
1215
+ // createError.
1216
+ class RD : public RuntimeDecorator<Runtime, Runtime> {
1217
+ public:
1218
+ explicit RD(Runtime& rt) : RuntimeDecorator(rt) {}
1219
+
1220
+ Value createError(const String& msg) override {
1221
+ return Runtime::createError(msg);
1222
+ }
1223
+ };
1224
+ RD drt(rt);
1225
+
1226
+ Value globalError = drt.global().getProperty(drt, "Error");
1227
+ drt.global().setProperty(drt, "Error", Value::undefined());
1159
1228
  try {
1160
- rt.global().getPropertyAsFunction(rt, "NotAFunction");
1229
+ drt.global().getPropertyAsFunction(drt, "NotAFunction");
1161
1230
  FAIL() << "expected exception";
1162
1231
  } catch (const JSError& ex) {
1163
1232
  EXPECT_EQ(
@@ -1180,14 +1249,14 @@ TEST_P(JSITest, JSErrorDoesNotInfinitelyRecurse) {
1180
1249
  "function (f) { try { f(); return 'undefined'; }"
1181
1250
  "catch (e) { return typeof e; } }")
1182
1251
  .call(
1183
- rt,
1252
+ drt,
1184
1253
  Function::createFromHostFunction(
1185
- rt, PropNameID::forAscii(rt, "fails"), 0, fails))
1186
- .getString(rt)
1187
- .utf8(rt),
1254
+ drt, PropNameID::forAscii(drt, "fails"), 0, fails))
1255
+ .getString(drt)
1256
+ .utf8(drt),
1188
1257
  "string");
1189
1258
 
1190
- rt.global().setProperty(rt, "Error", globalError);
1259
+ drt.global().setProperty(drt, "Error", globalError);
1191
1260
  }
1192
1261
 
1193
1262
  TEST_P(JSITest, JSErrorStackOverflowHandling) {
@@ -1600,6 +1669,155 @@ TEST_P(JSITest, CreateErrorTest) {
1600
1669
  }
1601
1670
  }
1602
1671
 
1672
+ TEST_P(JSITest, JSErrorMessageTest) {
1673
+ // JSError(rt, message) creates a new Error instance.
1674
+ {
1675
+ JSError e(rt, "native error");
1676
+ EXPECT_EQ(e.getMessage(), "native error");
1677
+ Object obj = e.value().getObject(rt);
1678
+ EXPECT_TRUE(
1679
+ rt.instanceOf(obj, rt.global().getPropertyAsFunction(rt, "Error")));
1680
+ EXPECT_EQ(
1681
+ obj.getProperty(rt, "message").getString(rt).utf8(rt), "native error");
1682
+ }
1683
+
1684
+ // JSError(rt, message) creates its value with Runtime::createError, so a
1685
+ // replaced global Error constructor is invoked exactly when createError
1686
+ // invokes it (e.g. the default jsi::Runtime implementation does, runtimes
1687
+ // with a native implementation do not).
1688
+ eval(
1689
+ "var OriginalError = Error;"
1690
+ "var replacedErrorCalls = 0;"
1691
+ "Error = function(message) {"
1692
+ " ++replacedErrorCalls;"
1693
+ " return new OriginalError(message);"
1694
+ "};");
1695
+ auto replacedErrorCalls = [&] {
1696
+ return rt.global().getProperty(rt, "replacedErrorCalls").getNumber();
1697
+ };
1698
+
1699
+ rt.createError(String::createFromAscii(rt, "probe"));
1700
+ double callsPerCreateError = replacedErrorCalls();
1701
+
1702
+ JSError e(rt, "replaced");
1703
+ EXPECT_EQ(replacedErrorCalls(), 2 * callsPerCreateError);
1704
+ EXPECT_EQ(e.getMessage(), "replaced");
1705
+ Object obj = e.value().getObject(rt);
1706
+ EXPECT_TRUE(rt.instanceOf(
1707
+ obj, rt.global().getPropertyAsFunction(rt, "OriginalError")));
1708
+ EXPECT_EQ(obj.getProperty(rt, "message").getString(rt).utf8(rt), "replaced");
1709
+ }
1710
+
1711
+ TEST_P(JSITest, DecoratorCreateErrorTest) {
1712
+ // Counts the createError* calls that reach it, and forwards them to the
1713
+ // underlying runtime.
1714
+ class CountingRD : public RuntimeDecorator<Runtime, Runtime> {
1715
+ public:
1716
+ explicit CountingRD(Runtime& rt) : RuntimeDecorator(rt) {}
1717
+
1718
+ Value createError(const String& msg) override {
1719
+ ++count;
1720
+ return RuntimeDecorator::createError(msg);
1721
+ }
1722
+ Value createEvalError(const String& msg) override {
1723
+ ++count;
1724
+ return RuntimeDecorator::createEvalError(msg);
1725
+ }
1726
+ Value createRangeError(const String& msg) override {
1727
+ ++count;
1728
+ return RuntimeDecorator::createRangeError(msg);
1729
+ }
1730
+ Value createReferenceError(const String& msg) override {
1731
+ ++count;
1732
+ return RuntimeDecorator::createReferenceError(msg);
1733
+ }
1734
+ Value createSyntaxError(const String& msg) override {
1735
+ ++count;
1736
+ return RuntimeDecorator::createSyntaxError(msg);
1737
+ }
1738
+ Value createTypeError(const String& msg) override {
1739
+ ++count;
1740
+ return RuntimeDecorator::createTypeError(msg);
1741
+ }
1742
+ Value createURIError(const String& msg) override {
1743
+ ++count;
1744
+ return RuntimeDecorator::createURIError(msg);
1745
+ }
1746
+
1747
+ int count = 0;
1748
+ };
1749
+
1750
+ class RD : public RuntimeDecorator<Runtime, Runtime> {
1751
+ public:
1752
+ explicit RD(Runtime& rt) : RuntimeDecorator(rt) {}
1753
+ };
1754
+
1755
+ struct Count {
1756
+ void before() {
1757
+ ++count;
1758
+ }
1759
+
1760
+ int count = 0;
1761
+ };
1762
+
1763
+ class CountRuntime : public WithRuntimeDecorator<Count> {
1764
+ public:
1765
+ explicit CountRuntime(Runtime& rt)
1766
+ : WithRuntimeDecorator<Count>(rt, count_) {}
1767
+
1768
+ Count count_;
1769
+ };
1770
+
1771
+ CountingRD counting(rt);
1772
+ RD rd(counting);
1773
+ CountRuntime crt(counting);
1774
+
1775
+ struct {
1776
+ Value (Runtime::*create)(const String&);
1777
+ const char* ctor;
1778
+ } cases[] = {
1779
+ {&Runtime::createError, "Error"},
1780
+ {&Runtime::createEvalError, "EvalError"},
1781
+ {&Runtime::createRangeError, "RangeError"},
1782
+ {&Runtime::createReferenceError, "ReferenceError"},
1783
+ {&Runtime::createSyntaxError, "SyntaxError"},
1784
+ {&Runtime::createTypeError, "TypeError"},
1785
+ {&Runtime::createURIError, "URIError"},
1786
+ };
1787
+
1788
+ // Both decorators must forward createError* to the decorated runtime rather
1789
+ // than fall back to the default implementation calling the global ctor.
1790
+ for (const auto& c : cases) {
1791
+ for (Runtime* drt :
1792
+ {static_cast<Runtime*>(&rd), static_cast<Runtime*>(&crt)}) {
1793
+ String msg = String::createFromAscii(*drt, "decorated");
1794
+ int countBefore = counting.count;
1795
+ int aroundBefore = crt.count_.count;
1796
+ Value error = (drt->*c.create)(msg);
1797
+ EXPECT_EQ(counting.count, countBefore + 1) << c.ctor;
1798
+ if (drt == &crt) {
1799
+ EXPECT_EQ(crt.count_.count, aroundBefore + 1) << c.ctor;
1800
+ }
1801
+
1802
+ Object obj = error.getObject(*drt);
1803
+ EXPECT_TRUE(drt->instanceOf(
1804
+ obj, drt->global().getPropertyAsFunction(*drt, c.ctor)))
1805
+ << c.ctor;
1806
+ EXPECT_EQ(
1807
+ obj.getProperty(*drt, "message").getString(*drt).utf8(*drt),
1808
+ "decorated")
1809
+ << c.ctor;
1810
+ }
1811
+ }
1812
+
1813
+ // JSError(rt, message) on a decorated runtime reaches the decorated
1814
+ // runtime's createError.
1815
+ int countBefore = counting.count;
1816
+ JSError e(rd, "decorated JSError");
1817
+ EXPECT_EQ(counting.count, countBefore + 1);
1818
+ EXPECT_EQ(e.getMessage(), "decorated JSError");
1819
+ }
1820
+
1603
1821
  TEST_P(JSITest, MicrotasksTest) {
1604
1822
  try {
1605
1823
  rt.global().setProperty(rt, "globalValue", String::createFromAscii(rt, ""));
@@ -1926,6 +2144,54 @@ TEST_P(JSITest, CreateFromUtf16Test) {
1926
2144
  EXPECT_EQ(cp, 55357); // 0xD83D in decimal
1927
2145
  }
1928
2146
 
2147
+ TEST_P(JSITest, CreateValueFromJsonUtf8Test) {
2148
+ uint8_t jsonText[] = "{\"a\": 1}";
2149
+
2150
+ // This Runtime Decorator is used to test the default createValueFromJsonUtf8
2151
+ // implementation for VMs that do not provide their own implementation
2152
+ class DefaultRD : public RuntimeDecorator<Runtime, Runtime> {
2153
+ public:
2154
+ explicit DefaultRD(Runtime& rt) : RuntimeDecorator(rt) {}
2155
+
2156
+ Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override {
2157
+ return Runtime::createValueFromJsonUtf8(json, length);
2158
+ }
2159
+ };
2160
+
2161
+ DefaultRD defaultRd(rt);
2162
+ Object obj =
2163
+ Value::createFromJsonUtf8(defaultRd, jsonText, sizeof(jsonText) - 1)
2164
+ .getObject(defaultRd);
2165
+ EXPECT_EQ(obj.getProperty(defaultRd, "a").getNumber(), 1);
2166
+
2167
+ // A RuntimeDecorator must forward createValueFromJsonUtf8 to the runtime it
2168
+ // decorates, like every other method.
2169
+ class CountingRD : public RuntimeDecorator<Runtime, Runtime> {
2170
+ public:
2171
+ explicit CountingRD(Runtime& rt) : RuntimeDecorator(rt) {}
2172
+
2173
+ Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override {
2174
+ ++count;
2175
+ return plain().createValueFromJsonUtf8(json, length);
2176
+ }
2177
+
2178
+ int count = 0;
2179
+ };
2180
+
2181
+ // Overrides nothing, so it should forward everything to CountingRD.
2182
+ class OuterRD : public RuntimeDecorator<Runtime, Runtime> {
2183
+ public:
2184
+ explicit OuterRD(Runtime& rt) : RuntimeDecorator(rt) {}
2185
+ };
2186
+
2187
+ CountingRD counting(rt);
2188
+ OuterRD outer(counting);
2189
+ obj = outer.createValueFromJsonUtf8(jsonText, sizeof(jsonText) - 1)
2190
+ .getObject(outer);
2191
+ EXPECT_EQ(counting.count, 1);
2192
+ EXPECT_EQ(obj.getProperty(outer, "a").getNumber(), 1);
2193
+ }
2194
+
1929
2195
  TEST_P(JSITest, GetStringDataTest) {
1930
2196
  // This Runtime Decorator is used to test the default getStringData
1931
2197
  // implementation for VMs that do not provide their own implementation
@@ -2453,6 +2719,17 @@ TEST_P(JSITest, ArrayBufferDetachedTest) {
2453
2719
  return;
2454
2720
  }
2455
2721
 
2722
+ // Skip the rest if the runtime has no way to detach an ArrayBuffer from JS.
2723
+ bool canDetach =
2724
+ eval(
2725
+ "typeof buf.transfer === 'function' || "
2726
+ "(typeof HermesInternal !== 'undefined' && "
2727
+ " typeof HermesInternal.detachArrayBuffer === 'function')")
2728
+ .getBool();
2729
+ if (!canDetach) {
2730
+ return;
2731
+ }
2732
+
2456
2733
  // Detach the ArrayBuffer. Use transfer() if available, otherwise fall back
2457
2734
  // to HermesInternal.detach for Hermes runtime.
2458
2735
  eval(
@@ -22,6 +22,7 @@ class Runtime;
22
22
  using RuntimeFactory = std::function<std::shared_ptr<Runtime>()>;
23
23
 
24
24
  std::vector<RuntimeFactory> runtimeGenerators();
25
+ std::vector<RuntimeFactory> runtimeGeneratorsWithSandBox();
25
26
 
26
27
  class JSITestBase : public ::testing::TestWithParam<RuntimeFactory> {
27
28
  public:
@@ -205,7 +205,8 @@ NSMutableDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttri
205
205
  attributes[NSForegroundColorAttributeName] = effectiveForegroundColor;
206
206
  }
207
207
 
208
- if (textAttributes.backgroundColor || !isnan(textAttributes.opacity)) {
208
+ // A clear background draws nothing, but TextKit still computes and fills its rects on every draw.
209
+ if (textAttributes.backgroundColor && textAttributes.backgroundColor != clearColor()) {
209
210
  attributes[NSBackgroundColorAttributeName] = RCTEffectiveBackgroundColorFromTextAttributes(textAttributes);
210
211
  }
211
212
 
@@ -1107,12 +1107,16 @@ static float distributeFreeSpaceSecondPass(
1107
1107
  // Use a relative epsilon guard instead of exact equality: after the
1108
1108
  // first pass removes all constrained items,
1109
1109
  // totalFlexShrinkScaledFactors may be near-zero rather than exactly 0
1110
- // due to floating-point cancellation. Dividing by a near-zero value
1110
+ // due to floating-point cancellation. Dividing by a near-zero value
1111
1111
  // produces a gigantic childSize that overwhelms the min/max clamp.
1112
+ // A positive total is always such a residual: with non-negative
1113
+ // flexShrink a real total is never positive
1114
+ // (https://github.com/react/yoga/issues/2038).
1112
1115
  const float shrinkFactorMagnitude =
1113
1116
  std::abs(flexLine.layout.totalFlexShrinkScaledFactors);
1114
1117
  if (yoga::isDefined(flexLine.layout.totalFlexShrinkScaledFactors) &&
1115
- shrinkFactorMagnitude < 1e-6f) {
1118
+ (shrinkFactorMagnitude < 1e-6f ||
1119
+ flexLine.layout.totalFlexShrinkScaledFactors > 0)) {
1116
1120
  childSize = childFlexBasis + flexShrinkScaledFactor;
1117
1121
  } else {
1118
1122
  childSize = childFlexBasis +
@@ -10,9 +10,13 @@
10
10
  #include <yoga/algorithm/PixelGrid.h>
11
11
  #include <yoga/numeric/Comparison.h>
12
12
 
13
+ #include <cmath>
14
+
13
15
  namespace facebook::yoga {
14
16
 
15
- float roundValueToPixelGrid(
17
+ namespace {
18
+
19
+ double roundValueToPixelGridDouble(
16
20
  const double value,
17
21
  const double pointScaleFactor,
18
22
  const bool forceCeil,
@@ -20,7 +24,13 @@ float roundValueToPixelGrid(
20
24
  double scaledValue = value * pointScaleFactor;
21
25
  // We want to calculate `fractial` such that `floor(scaledValue) = scaledValue
22
26
  // - fractial`.
23
- double fractial = fmod(scaledValue, 1.0);
27
+ //
28
+ // `copysign(x - trunc(x), x)` is bit-identical to `fmod(x, 1.0)` for every
29
+ // double (including -0.0, infinities and NaN) but avoids the libm `fmod`
30
+ // loop, which is slow on some platforms (e.g. Android's bionic). This
31
+ // function runs six times per node on every layout pass.
32
+ double fractial =
33
+ std::copysign(scaledValue - std::trunc(scaledValue), scaledValue);
24
34
  if (fractial < 0) {
25
35
  // This branch is for handling negative numbers for `value`.
26
36
  //
@@ -59,7 +69,18 @@ float roundValueToPixelGrid(
59
69
  }
60
70
  return (std::isnan(scaledValue) || std::isnan(pointScaleFactor))
61
71
  ? YGUndefined
62
- : (float)(scaledValue / pointScaleFactor);
72
+ : scaledValue / pointScaleFactor;
73
+ }
74
+
75
+ } // namespace
76
+
77
+ float roundValueToPixelGrid(
78
+ const double value,
79
+ const double pointScaleFactor,
80
+ const bool forceCeil,
81
+ const bool forceFloor) {
82
+ return static_cast<float>(roundValueToPixelGridDouble(
83
+ value, pointScaleFactor, forceCeil, forceFloor));
63
84
  }
64
85
 
65
86
  void roundLayoutResultsToPixelGrid(
@@ -98,9 +119,9 @@ void roundLayoutResultsToPixelGrid(
98
119
  // whole number, we don't have any fraction To verify if the result is close
99
120
  // to whole number we want to check both floor and ceil numbers
100
121
 
101
- const double scaledNodeWith = nodeWidth * pointScaleFactor;
122
+ const double scaledNodeWidth = nodeWidth * pointScaleFactor;
102
123
  const bool hasFractionalWidth =
103
- !yoga::inexactEquals(round(scaledNodeWith), scaledNodeWith);
124
+ !yoga::inexactEquals(round(scaledNodeWidth), scaledNodeWidth);
104
125
 
105
126
  const double scaledNodeHeight = nodeHeight * pointScaleFactor;
106
127
  const bool hasFractionalHeight =
@@ -108,23 +129,32 @@ void roundLayoutResultsToPixelGrid(
108
129
 
109
130
  node->getLayout().setDimension(
110
131
  Dimension::Width,
111
- roundValueToPixelGrid(
112
- absoluteNodeRight,
113
- pointScaleFactor,
114
- (textRounding && hasFractionalWidth),
115
- (textRounding && !hasFractionalWidth)) -
116
- roundValueToPixelGrid(
117
- absoluteNodeLeft, pointScaleFactor, false, textRounding));
132
+ textRounding && !hasFractionalWidth
133
+ ? static_cast<float>(round(scaledNodeWidth) / pointScaleFactor)
134
+ : static_cast<float>(
135
+ roundValueToPixelGridDouble(
136
+ absoluteNodeRight,
137
+ pointScaleFactor,
138
+ textRounding,
139
+ false) -
140
+ roundValueToPixelGridDouble(
141
+ absoluteNodeLeft,
142
+ pointScaleFactor,
143
+ false,
144
+ textRounding)));
118
145
 
119
146
  node->getLayout().setDimension(
120
147
  Dimension::Height,
121
- roundValueToPixelGrid(
122
- absoluteNodeBottom,
123
- pointScaleFactor,
124
- (textRounding && hasFractionalHeight),
125
- (textRounding && !hasFractionalHeight)) -
126
- roundValueToPixelGrid(
127
- absoluteNodeTop, pointScaleFactor, false, textRounding));
148
+ textRounding && !hasFractionalHeight
149
+ ? static_cast<float>(round(scaledNodeHeight) / pointScaleFactor)
150
+ : static_cast<float>(
151
+ roundValueToPixelGridDouble(
152
+ absoluteNodeBottom,
153
+ pointScaleFactor,
154
+ textRounding,
155
+ false) -
156
+ roundValueToPixelGridDouble(
157
+ absoluteNodeTop, pointScaleFactor, false, textRounding)));
128
158
  }
129
159
 
130
160
  for (yoga::Node* child : node->getChildren()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-tvos",
3
- "version": "0.88.0-0rc2",
3
+ "version": "0.88.1-0",
4
4
  "description": "A framework for building native apps using React",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -159,17 +159,17 @@
159
159
  }
160
160
  },
161
161
  "dependencies": {
162
- "@react-native/asset-utils": "0.88.0-rc.2",
163
- "@react-native/codegen": "0.88.0-rc.2",
164
- "@react-native/community-cli-plugin": "0.88.0-rc.2",
165
- "@react-native/gradle-plugin": "0.88.0-rc.2",
166
- "@react-native/normalize-colors": "0.88.0-rc.2",
162
+ "@react-native/asset-utils": "0.88.1",
163
+ "@react-native/codegen": "0.88.1",
164
+ "@react-native/community-cli-plugin": "0.88.1",
165
+ "@react-native/gradle-plugin": "0.88.1",
166
+ "@react-native/normalize-colors": "0.88.1",
167
167
  "anser": "^1.4.9",
168
168
  "ansi-regex": "^5.0.0",
169
169
  "flow-parser": "0.327.0",
170
170
  "base64-js": "^1.5.1",
171
171
  "flow-enums-runtime": "^0.0.6",
172
- "hermes-compiler": "260318099.0.4",
172
+ "hermes-compiler": "260318099.0.5",
173
173
  "invariant": "^2.2.4",
174
174
  "memoize-one": "^5.0.0",
175
175
  "metro-runtime": "^0.87.1",
@@ -187,7 +187,7 @@
187
187
  "whatwg-fetch": "^3.0.0",
188
188
  "ws": "^7.5.10",
189
189
  "yargs": "^17.6.2",
190
- "@react-native-tvos/virtualized-lists": "0.88.0-0rc2"
190
+ "@react-native-tvos/virtualized-lists": "0.88.1-0"
191
191
  },
192
192
  "codegenConfig": {
193
193
  "libraries": [