react-native-windows 0.82.1 → 0.83.0-preview.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 (232) hide show
  1. package/.flowconfig +2 -7
  2. package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
  3. package/Libraries/Animated/components/AnimatedImage.js +4 -3
  4. package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
  5. package/Libraries/Animated/components/AnimatedText.js +7 -3
  6. package/Libraries/Animated/components/AnimatedView.js +3 -2
  7. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  8. package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
  9. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
  10. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
  11. package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
  12. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
  13. package/Libraries/Components/Glyph/Glyph.js +4 -1
  14. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
  15. package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
  16. package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
  17. package/Libraries/Components/ScrollView/ScrollView.js +1 -0
  18. package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
  19. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
  20. package/Libraries/Components/Switch/Switch.d.ts +2 -2
  21. package/Libraries/Components/Switch/Switch.windows.js +1 -1
  22. package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
  23. package/Libraries/Components/TextInput/TextInput.js +6 -0
  24. package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
  25. package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
  26. package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
  27. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
  28. package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
  29. package/Libraries/Components/View/View.d.ts +2 -2
  30. package/Libraries/Components/View/View.windows.js +0 -1
  31. package/Libraries/Components/View/ViewNativeComponent.js +13 -1
  32. package/Libraries/Core/ReactNativeVersion.js +3 -3
  33. package/Libraries/Core/setUpPerformance.js +2 -0
  34. package/Libraries/Debugging/DebuggingOverlay.js +14 -14
  35. package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
  36. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
  37. package/Libraries/Image/Image.d.ts +3 -3
  38. package/Libraries/Image/ImageInjection.js +3 -6
  39. package/Libraries/Image/ImageTypes.flow.js +3 -7
  40. package/Libraries/Lists/FlatList.js +8 -8
  41. package/Libraries/Lists/SectionList.d.ts +5 -1
  42. package/Libraries/Lists/ViewabilityHelper.js +1 -1
  43. package/Libraries/Lists/VirtualizedList.js +1 -0
  44. package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
  45. package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
  46. package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
  47. package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
  48. package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
  49. package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
  50. package/Libraries/Network/RCTNetworking.android.js +3 -1
  51. package/Libraries/Network/RCTNetworking.ios.js +3 -0
  52. package/Libraries/Network/RCTNetworking.windows.js +3 -0
  53. package/Libraries/Network/XMLHttpRequest.js +1 -41
  54. package/Libraries/Pressability/usePressability.js +14 -3
  55. package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
  56. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
  57. package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
  58. package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
  59. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
  60. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
  61. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
  62. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
  63. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
  64. package/Libraries/Renderer/shims/ReactNative.js +3 -1
  65. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
  66. package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
  67. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
  68. package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
  69. package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
  70. package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
  71. package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
  72. package/Libraries/Text/Text.d.ts +2 -2
  73. package/Libraries/Text/TextNativeComponent.js +10 -0
  74. package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
  75. package/Libraries/Utilities/DevLoadingView.js +14 -6
  76. package/Libraries/Utilities/HMRClient.js +13 -5
  77. package/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
  78. package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
  79. package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
  80. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
  81. package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
  82. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
  83. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
  84. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
  85. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
  86. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
  87. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
  88. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
  89. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
  90. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
  91. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
  92. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
  93. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
  94. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
  95. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
  96. package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
  97. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
  98. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
  99. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
  100. package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
  101. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
  102. package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
  103. package/Microsoft.ReactNative/Pch/pch.h +2 -0
  104. package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
  105. package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
  106. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
  107. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
  108. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
  109. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
  110. package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
  111. package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
  112. package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
  113. package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
  114. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
  115. package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
  116. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
  117. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
  118. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
  119. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
  120. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
  121. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
  122. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
  123. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
  124. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
  125. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
  126. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
  127. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
  128. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
  129. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
  130. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
  131. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
  132. package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
  133. package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
  134. package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
  135. package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
  136. package/PropertySheets/Generated/PackageVersion.g.props +5 -5
  137. package/PropertySheets/Warnings.props +2 -1
  138. package/ReactCommon/ReactCommon.vcxproj +21 -12
  139. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
  140. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +381 -0
  141. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +49 -0
  142. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +145 -0
  143. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +100 -0
  144. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +256 -0
  145. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +13 -4
  146. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +93 -0
  147. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +149 -0
  148. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
  149. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
  150. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +629 -0
  151. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +123 -0
  152. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
  153. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
  154. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
  155. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
  156. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
  157. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
  158. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +414 -0
  159. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
  160. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
  161. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
  162. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
  163. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
  164. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
  165. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +81 -0
  166. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +140 -0
  167. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
  168. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +746 -0
  169. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +702 -0
  170. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
  171. package/Scripts/creaternwapp.cmd +1 -1
  172. package/Scripts/perf/compare-results.js +357 -0
  173. package/Scripts/perf/create-perf-test.js +343 -0
  174. package/Scripts/perf/post-pr-comment.js +210 -0
  175. package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
  176. package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
  177. package/Shared/Shared.vcxitems +24 -12
  178. package/Shared/Shared.vcxitems.filters +11 -3
  179. package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
  180. package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
  181. package/codegen/NativePerformanceSpec.g.h +6 -0
  182. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
  183. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
  184. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
  185. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
  186. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
  187. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
  188. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
  189. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
  190. package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
  191. package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
  192. package/codegen/react/components/rnwcore/Props.cpp +6 -1
  193. package/codegen/react/components/rnwcore/Props.h +1 -0
  194. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
  195. package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
  196. package/codegen/react/components/rnwcore/Switch.g.h +11 -6
  197. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
  198. package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
  199. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
  200. package/codegen/rnwcoreJSI.h +3973 -6059
  201. package/index.js +6 -0
  202. package/index.windows.js +6 -0
  203. package/jest/mockComponent.js +6 -6
  204. package/jest/setup.js +15 -10
  205. package/package.json +27 -27
  206. package/src/private/components/virtualview/VirtualView.js +22 -27
  207. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
  208. package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
  209. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
  210. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  211. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
  212. package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
  213. package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
  214. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
  215. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
  216. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
  217. package/src/private/webapis/performance/ResourceTiming.js +31 -4
  218. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
  219. package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
  220. package/stubs/double-conversion/double-conversion.h +5 -0
  221. package/templates/cpp-app/template.config.js +1 -1
  222. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +3 -1
  223. package/templates/cpp-lib/template.config.js +1 -1
  224. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  225. package/types/index.d.ts +1 -0
  226. package/types/public/ReactNativeTypes.d.ts +115 -2
  227. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
  228. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
  229. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
  230. package/Scripts/OpenSSL.nuspec +0 -39
  231. package/Scripts/OpenSSL.targets +0 -36
  232. package/codegen/rnwcoreJSI-generated.cpp +0 -3470
@@ -16,9 +16,10 @@ class Error {
16
16
  // TODO (T114055466): Retain stack trace (at least caller location)
17
17
  Error(std::string message) : message_(std::move(message)) {}
18
18
 
19
- Error(const char* message) : Error(std::string(message)) {}
19
+ Error(const char *message) : Error(std::string(message)) {}
20
20
 
21
- const std::string& message() const {
21
+ const std::string &message() const
22
+ {
22
23
  return message_;
23
24
  }
24
25
 
@@ -28,22 +29,26 @@ class Error {
28
29
 
29
30
  template <>
30
31
  struct Bridging<jsi::JSError> {
31
- static jsi::JSError fromJs(jsi::Runtime& rt, const jsi::Value& value) {
32
+ static jsi::JSError fromJs(jsi::Runtime &rt, const jsi::Value &value)
33
+ {
32
34
  return jsi::JSError(rt, jsi::Value(rt, value));
33
35
  }
34
36
 
35
- static jsi::JSError fromJs(jsi::Runtime& rt, jsi::Value&& value) {
37
+ static jsi::JSError fromJs(jsi::Runtime &rt, jsi::Value &&value)
38
+ {
36
39
  return jsi::JSError(rt, std::move(value));
37
40
  }
38
41
 
39
- static jsi::Value toJs(jsi::Runtime& rt, std::string message) {
42
+ static jsi::Value toJs(jsi::Runtime &rt, std::string message)
43
+ {
40
44
  return jsi::Value(rt, jsi::JSError(rt, std::move(message)).value());
41
45
  }
42
46
  };
43
47
 
44
48
  template <>
45
49
  struct Bridging<Error> {
46
- static jsi::Value toJs(jsi::Runtime& rt, const Error& error) {
50
+ static jsi::Value toJs(jsi::Runtime &rt, const Error &error)
51
+ {
47
52
  return jsi::Value(rt, jsi::JSError(rt, error.message()).value());
48
53
  }
49
54
  };
@@ -13,36 +13,43 @@
13
13
  #include <mutex>
14
14
  #include <unordered_map>
15
15
 
16
- #define FRIEND_TEST(test_case_name, test_name) \
17
- friend class test_case_name##_##test_name##_Test
16
+ #define FRIEND_TEST(test_case_name, test_name) friend class test_case_name##_##test_name##_Test
18
17
 
19
18
  namespace facebook::react {
20
19
 
21
20
  class EventSubscription {
22
21
  public:
23
- explicit EventSubscription(std::function<void()> remove)
24
- : remove_(std::move(remove)) {}
22
+ explicit EventSubscription(std::function<void()> remove) : remove_(std::move(remove)) {}
25
23
  ~EventSubscription() = default;
26
- EventSubscription(EventSubscription&&) noexcept = default;
27
- EventSubscription& operator=(EventSubscription&&) noexcept = default;
28
- EventSubscription(const EventSubscription&) = delete;
29
- EventSubscription& operator=(const EventSubscription&) = delete;
24
+ EventSubscription(EventSubscription &&) noexcept = default;
25
+ EventSubscription &operator=(EventSubscription &&) noexcept = default;
26
+ EventSubscription(const EventSubscription &) = delete;
27
+ EventSubscription &operator=(const EventSubscription &) = delete;
28
+
29
+ void remove()
30
+ {
31
+ remove_();
32
+ }
30
33
 
31
34
  private:
32
35
  friend Bridging<EventSubscription>;
33
-
34
36
  std::function<void()> remove_;
35
37
  };
36
38
 
37
39
  template <>
38
40
  struct Bridging<EventSubscription> {
39
- static jsi::Object toJs(
40
- jsi::Runtime& rt,
41
- const EventSubscription& eventSubscription,
42
- const std::shared_ptr<CallInvoker>& jsInvoker) {
41
+ static EventSubscription
42
+ fromJs(jsi::Runtime &rt, const jsi::Object &value, const std::shared_ptr<CallInvoker> &jsInvoker)
43
+ {
44
+ auto listener = bridging::fromJs<AsyncCallback<>>(rt, value.getProperty(rt, "remove"), jsInvoker);
45
+ return EventSubscription([listener = std::move(listener)]() mutable { listener(); });
46
+ }
47
+
48
+ static jsi::Object
49
+ toJs(jsi::Runtime &rt, const EventSubscription &eventSubscription, const std::shared_ptr<CallInvoker> &jsInvoker)
50
+ {
43
51
  auto result = jsi::Object(rt);
44
- result.setProperty(
45
- rt, "remove", bridging::toJs(rt, eventSubscription.remove_, jsInvoker));
52
+ result.setProperty(rt, "remove", bridging::toJs(rt, eventSubscription.remove_, jsInvoker));
46
53
  return result;
47
54
  }
48
55
  };
@@ -51,24 +58,21 @@ class IAsyncEventEmitter {
51
58
  public:
52
59
  IAsyncEventEmitter() noexcept = default;
53
60
  virtual ~IAsyncEventEmitter() noexcept = default;
54
- IAsyncEventEmitter(IAsyncEventEmitter&&) noexcept = default;
55
- IAsyncEventEmitter& operator=(IAsyncEventEmitter&&) noexcept = default;
56
- IAsyncEventEmitter(const IAsyncEventEmitter&) = delete;
57
- IAsyncEventEmitter& operator=(const IAsyncEventEmitter&) = delete;
58
-
59
- virtual jsi::Object get(
60
- jsi::Runtime& rt,
61
- const std::shared_ptr<CallInvoker>& jsInvoker) const = 0;
61
+ IAsyncEventEmitter(IAsyncEventEmitter &&) noexcept = default;
62
+ IAsyncEventEmitter &operator=(IAsyncEventEmitter &&) noexcept = default;
63
+ IAsyncEventEmitter(const IAsyncEventEmitter &) = delete;
64
+ IAsyncEventEmitter &operator=(const IAsyncEventEmitter &) = delete;
65
+
66
+ virtual jsi::Object get(jsi::Runtime &rt, const std::shared_ptr<CallInvoker> &jsInvoker) const = 0;
62
67
  };
63
68
 
64
69
  template <typename... Args>
65
70
  class AsyncEventEmitter : public IAsyncEventEmitter {
66
- static_assert(
67
- sizeof...(Args) <= 1,
68
- "AsyncEventEmitter must have at most one argument");
71
+ static_assert(sizeof...(Args) <= 1, "AsyncEventEmitter must have at most one argument");
69
72
 
70
73
  public:
71
- AsyncEventEmitter() : state_(std::make_shared<SharedState>()) {
74
+ AsyncEventEmitter() : state_(std::make_shared<SharedState>())
75
+ {
72
76
  listen_ = [state = state_](AsyncCallback<Args...> listener) {
73
77
  std::lock_guard<std::mutex> lock(state->mutex);
74
78
  auto listenerId = state->listenerId++;
@@ -80,30 +84,29 @@ class AsyncEventEmitter : public IAsyncEventEmitter {
80
84
  };
81
85
  }
82
86
  ~AsyncEventEmitter() override = default;
83
- AsyncEventEmitter(AsyncEventEmitter&&) noexcept = default;
84
- AsyncEventEmitter& operator=(AsyncEventEmitter&&) noexcept = default;
85
- AsyncEventEmitter(const AsyncEventEmitter&) = delete;
86
- AsyncEventEmitter& operator=(const AsyncEventEmitter&) = delete;
87
+ AsyncEventEmitter(AsyncEventEmitter &&) noexcept = default;
88
+ AsyncEventEmitter &operator=(AsyncEventEmitter &&) noexcept = default;
89
+ AsyncEventEmitter(const AsyncEventEmitter &) = delete;
90
+ AsyncEventEmitter &operator=(const AsyncEventEmitter &) = delete;
87
91
 
88
- void emit(std::function<jsi::Value(jsi::Runtime&)>&& converter) {
92
+ void emit(std::function<jsi::Value(jsi::Runtime &)> &&converter)
93
+ {
89
94
  std::lock_guard<std::mutex> lock(state_->mutex);
90
- for (auto& [_, listener] : state_->listeners) {
91
- listener.call([converter](jsi::Runtime& rt, jsi::Function& jsFunction) {
92
- jsFunction.call(rt, converter(rt));
93
- });
95
+ for (auto &[_, listener] : state_->listeners) {
96
+ listener.call([converter](jsi::Runtime &rt, jsi::Function &jsFunction) { jsFunction.call(rt, converter(rt)); });
94
97
  }
95
98
  }
96
99
 
97
- void emit(Args... value) {
100
+ void emit(Args... value)
101
+ {
98
102
  std::lock_guard<std::mutex> lock(state_->mutex);
99
- for (const auto& [_, listener] : state_->listeners) {
103
+ for (const auto &[_, listener] : state_->listeners) {
100
104
  listener.call(static_cast<Args>(value)...);
101
105
  }
102
106
  }
103
107
 
104
- jsi::Object get(
105
- jsi::Runtime& rt,
106
- const std::shared_ptr<CallInvoker>& jsInvoker) const override {
108
+ jsi::Object get(jsi::Runtime &rt, const std::shared_ptr<CallInvoker> &jsInvoker) const override
109
+ {
107
110
  return bridging::toJs(rt, listen_, jsInvoker);
108
111
  }
109
112
 
@@ -123,10 +126,9 @@ class AsyncEventEmitter : public IAsyncEventEmitter {
123
126
 
124
127
  template <typename... Args>
125
128
  struct Bridging<AsyncEventEmitter<Args...>> {
126
- static jsi::Object toJs(
127
- jsi::Runtime& rt,
128
- const AsyncEventEmitter<Args...>& eventEmitter,
129
- const std::shared_ptr<CallInvoker>& jsInvoker) {
129
+ static jsi::Object
130
+ toJs(jsi::Runtime &rt, const AsyncEventEmitter<Args...> &eventEmitter, const std::shared_ptr<CallInvoker> &jsInvoker)
131
+ {
130
132
  return eventEmitter.get(rt, jsInvoker);
131
133
  }
132
134
  };
@@ -21,37 +21,34 @@ class SyncCallback;
21
21
  template <typename... Args>
22
22
  class AsyncCallback {
23
23
  public:
24
- AsyncCallback(
25
- jsi::Runtime& runtime,
26
- jsi::Function function,
27
- std::shared_ptr<CallInvoker> jsInvoker)
28
- : callback_(std::make_shared<SyncCallback<void(Args...)>>(
29
- runtime,
30
- std::move(function),
31
- std::move(jsInvoker))) {}
32
-
33
- void operator()(Args... args) const noexcept {
24
+ AsyncCallback(jsi::Runtime &runtime, jsi::Function function, std::shared_ptr<CallInvoker> jsInvoker)
25
+ : callback_(std::make_shared<SyncCallback<void(Args...)>>(runtime, std::move(function), std::move(jsInvoker)))
26
+ {
27
+ }
28
+
29
+ void operator()(Args... args) const noexcept
30
+ {
34
31
  call(std::forward<Args>(args)...);
35
32
  }
36
33
 
37
- void call(Args... args) const noexcept {
34
+ void call(Args... args) const noexcept
35
+ {
38
36
  callWithArgs(std::nullopt, std::forward<Args>(args)...);
39
37
  }
40
38
 
41
- void callWithPriority(SchedulerPriority priority, Args... args)
42
- const noexcept {
39
+ void callWithPriority(SchedulerPriority priority, Args... args) const noexcept
40
+ {
43
41
  callWithArgs(priority, std::forward<Args>(args)...);
44
42
  }
45
43
 
46
- void call(std::function<void(jsi::Runtime&, jsi::Function&)>&& callImpl)
47
- const noexcept {
44
+ void call(std::function<void(jsi::Runtime &, jsi::Function &)> &&callImpl) const noexcept
45
+ {
48
46
  callWithFunction(std::nullopt, std::move(callImpl));
49
47
  }
50
48
 
51
- void callWithPriority(
52
- SchedulerPriority priority,
53
- std::function<void(jsi::Runtime&, jsi::Function&)>&& callImpl)
54
- const noexcept {
49
+ void callWithPriority(SchedulerPriority priority, std::function<void(jsi::Runtime &, jsi::Function &)> &&callImpl)
50
+ const noexcept
51
+ {
55
52
  callWithFunction(priority, std::move(callImpl));
56
53
  }
57
54
 
@@ -60,15 +57,14 @@ class AsyncCallback {
60
57
 
61
58
  std::shared_ptr<SyncCallback<void(Args...)>> callback_;
62
59
 
63
- void callWithArgs(std::optional<SchedulerPriority> priority, Args... args)
64
- const noexcept {
60
+ void callWithArgs(std::optional<SchedulerPriority> priority, Args... args) const noexcept
61
+ {
65
62
  if (auto wrapper = callback_->wrapper_.lock()) {
66
63
  auto fn = [callback = callback_,
67
- argsPtr = std::make_shared<std::tuple<Args...>>(
68
- std::make_tuple(std::forward<Args>(args)...))](
69
- jsi::Runtime&) { callback->apply(std::move(*argsPtr)); };
64
+ argsPtr = std::make_shared<std::tuple<Args...>>(std::make_tuple(std::forward<Args>(args)...))](
65
+ jsi::Runtime &) { callback->apply(std::move(*argsPtr)); };
70
66
 
71
- auto& jsInvoker = wrapper->jsInvoker();
67
+ auto &jsInvoker = wrapper->jsInvoker();
72
68
  if (priority) {
73
69
  jsInvoker.invokeAsync(*priority, std::move(fn));
74
70
  } else {
@@ -79,20 +75,19 @@ class AsyncCallback {
79
75
 
80
76
  void callWithFunction(
81
77
  std::optional<SchedulerPriority> priority,
82
- std::function<void(jsi::Runtime&, jsi::Function&)>&& callImpl)
83
- const noexcept {
78
+ std::function<void(jsi::Runtime &, jsi::Function &)> &&callImpl) const noexcept
79
+ {
84
80
  if (auto wrapper = callback_->wrapper_.lock()) {
85
81
  // Capture callback_ and not wrapper_. If callback_ is deallocated or the
86
82
  // JSVM is shutdown before the async task is scheduled, the underlying
87
83
  // function will have been deallocated.
88
- auto fn = [callback = callback_,
89
- callImpl = std::move(callImpl)](jsi::Runtime& rt) {
84
+ auto fn = [callback = callback_, callImpl = std::move(callImpl)](jsi::Runtime &rt) {
90
85
  if (auto wrapper2 = callback->wrapper_.lock()) {
91
86
  callImpl(rt, wrapper2->callback());
92
87
  }
93
88
  };
94
89
 
95
- auto& jsInvoker = wrapper->jsInvoker();
90
+ auto &jsInvoker = wrapper->jsInvoker();
96
91
  if (priority) {
97
92
  jsInvoker.invokeAsync(*priority, std::move(fn));
98
93
  } else {
@@ -108,40 +103,39 @@ class AsyncCallback {
108
103
  template <typename R, typename... Args>
109
104
  class SyncCallback<R(Args...)> {
110
105
  public:
111
- SyncCallback(
112
- jsi::Runtime& rt,
113
- jsi::Function function,
114
- std::shared_ptr<CallInvoker> jsInvoker)
115
- : wrapper_(CallbackWrapper::createWeak(
116
- std::move(function),
117
- rt,
118
- std::move(jsInvoker))) {}
106
+ SyncCallback(jsi::Runtime &rt, jsi::Function function, std::shared_ptr<CallInvoker> jsInvoker)
107
+ : wrapper_(CallbackWrapper::createWeak(std::move(function), rt, std::move(jsInvoker)))
108
+ {
109
+ }
119
110
 
120
111
  // Disallow copying, as we can no longer safely destroy the callback
121
112
  // from the destructor if there's multiple copies
122
- SyncCallback(const SyncCallback&) = delete;
123
- SyncCallback& operator=(const SyncCallback&) = delete;
113
+ SyncCallback(const SyncCallback &) = delete;
114
+ SyncCallback &operator=(const SyncCallback &) = delete;
124
115
 
125
116
  // Allow move
126
- SyncCallback(SyncCallback&& other) noexcept
127
- : wrapper_(std::move(other.wrapper_)) {}
117
+ SyncCallback(SyncCallback &&other) noexcept : wrapper_(std::move(other.wrapper_)) {}
128
118
 
129
- SyncCallback& operator=(SyncCallback&& other) noexcept {
119
+ SyncCallback &operator=(SyncCallback &&other) noexcept
120
+ {
130
121
  wrapper_ = std::move(other.wrapper_);
131
122
  return *this;
132
123
  }
133
124
 
134
- ~SyncCallback() {
125
+ ~SyncCallback()
126
+ {
135
127
  if (auto wrapper = wrapper_.lock()) {
136
128
  wrapper->destroy();
137
129
  }
138
130
  }
139
131
 
140
- R operator()(Args... args) const {
132
+ R operator()(Args... args) const
133
+ {
141
134
  return call(std::forward<Args>(args)...);
142
135
  }
143
136
 
144
- R call(Args... args) const {
137
+ R call(Args... args) const
138
+ {
145
139
  auto wrapper = wrapper_.lock();
146
140
 
147
141
  // If the wrapper has been deallocated, we can no longer provide a return
@@ -154,19 +148,15 @@ class SyncCallback<R(Args...)> {
154
148
  }
155
149
  }
156
150
 
157
- auto& callback = wrapper->callback();
158
- auto& rt = wrapper->runtime();
151
+ auto &callback = wrapper->callback();
152
+ auto &rt = wrapper->runtime();
159
153
  auto jsInvoker = wrapper->jsInvokerPtr();
160
154
 
161
155
  if constexpr (std::is_void_v<R>) {
162
- callback.call(
163
- rt, bridging::toJs(rt, std::forward<Args>(args), jsInvoker)...);
156
+ callback.call(rt, bridging::toJs(rt, std::forward<Args>(args), jsInvoker)...);
164
157
  } else {
165
158
  return bridging::fromJs<R>(
166
- rt,
167
- callback.call(
168
- rt, bridging::toJs(rt, std::forward<Args>(args), jsInvoker)...),
169
- jsInvoker);
159
+ rt, callback.call(rt, bridging::toJs(rt, std::forward<Args>(args), jsInvoker)...), jsInvoker);
170
160
  }
171
161
  }
172
162
 
@@ -174,12 +164,14 @@ class SyncCallback<R(Args...)> {
174
164
  friend AsyncCallback<Args...>;
175
165
  friend Bridging<SyncCallback>;
176
166
 
177
- R apply(std::tuple<Args...>&& args) const {
167
+ R apply(std::tuple<Args...> &&args) const
168
+ {
178
169
  return apply(std::move(args), std::index_sequence_for<Args...>{});
179
170
  }
180
171
 
181
172
  template <size_t... Index>
182
- R apply(std::tuple<Args...>&& args, std::index_sequence<Index...>) const {
173
+ R apply(std::tuple<Args...> &&args, std::index_sequence<Index...> /*unused*/) const
174
+ {
183
175
  return call(std::move(std::get<Index>(args))...);
184
176
  }
185
177
 
@@ -189,32 +181,28 @@ class SyncCallback<R(Args...)> {
189
181
 
190
182
  template <typename... Args>
191
183
  struct Bridging<AsyncCallback<Args...>> {
192
- static AsyncCallback<Args...> fromJs(
193
- jsi::Runtime& rt,
194
- jsi::Function&& value,
195
- const std::shared_ptr<CallInvoker>& jsInvoker) {
184
+ static AsyncCallback<Args...>
185
+ fromJs(jsi::Runtime &rt, jsi::Function &&value, const std::shared_ptr<CallInvoker> &jsInvoker)
186
+ {
196
187
  return AsyncCallback<Args...>(rt, std::move(value), jsInvoker);
197
188
  }
198
189
 
199
- static jsi::Function toJs(
200
- jsi::Runtime& rt,
201
- const AsyncCallback<Args...>& value) {
190
+ static jsi::Function toJs(jsi::Runtime &rt, const AsyncCallback<Args...> &value)
191
+ {
202
192
  return value.callback_->function_.getFunction(rt);
203
193
  }
204
194
  };
205
195
 
206
196
  template <typename R, typename... Args>
207
197
  struct Bridging<SyncCallback<R(Args...)>> {
208
- static SyncCallback<R(Args...)> fromJs(
209
- jsi::Runtime& rt,
210
- jsi::Function&& value,
211
- const std::shared_ptr<CallInvoker>& jsInvoker) {
198
+ static SyncCallback<R(Args...)>
199
+ fromJs(jsi::Runtime &rt, jsi::Function &&value, const std::shared_ptr<CallInvoker> &jsInvoker)
200
+ {
212
201
  return SyncCallback<R(Args...)>(rt, std::move(value), jsInvoker);
213
202
  }
214
203
 
215
- static jsi::Function toJs(
216
- jsi::Runtime& rt,
217
- const SyncCallback<R(Args...)>& value) {
204
+ static jsi::Function toJs(jsi::Runtime &rt, const SyncCallback<R(Args...)> &value)
205
+ {
218
206
  return value.function_.getFunction(rt);
219
207
  }
220
208
  };
@@ -226,19 +214,14 @@ struct Bridging<std::function<R(Args...)>> {
226
214
 
227
215
  static constexpr size_t kArgumentCount = sizeof...(Args);
228
216
 
229
- static jsi::Function toJs(
230
- jsi::Runtime& rt,
231
- Func fn,
232
- const std::shared_ptr<CallInvoker>& jsInvoker) {
217
+ static jsi::Function toJs(jsi::Runtime &rt, Func fn, const std::shared_ptr<CallInvoker> &jsInvoker)
218
+ {
233
219
  return jsi::Function::createFromHostFunction(
234
220
  rt,
235
221
  jsi::PropNameID::forAscii(rt, "BridgedFunction"),
236
222
  kArgumentCount,
237
223
  [fn = std::make_shared<Func>(std::move(fn)), jsInvoker](
238
- jsi::Runtime& rt,
239
- const jsi::Value&,
240
- const jsi::Value* args,
241
- size_t count) -> jsi::Value {
224
+ jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t count) -> jsi::Value {
242
225
  if (count < kArgumentCount) {
243
226
  throw jsi::JSError(rt, "Incorrect number of arguments");
244
227
  }
@@ -247,10 +230,7 @@ struct Bridging<std::function<R(Args...)>> {
247
230
  callFromJs(*fn, rt, args, jsInvoker, IndexSequence{});
248
231
  return jsi::Value();
249
232
  } else {
250
- return bridging::toJs(
251
- rt,
252
- callFromJs(*fn, rt, args, jsInvoker, IndexSequence{}),
253
- jsInvoker);
233
+ return bridging::toJs(rt, callFromJs(*fn, rt, args, jsInvoker, IndexSequence{}), jsInvoker);
254
234
  }
255
235
  });
256
236
  }
@@ -258,11 +238,12 @@ struct Bridging<std::function<R(Args...)>> {
258
238
  private:
259
239
  template <size_t... Index>
260
240
  static R callFromJs(
261
- Func& fn,
262
- jsi::Runtime& rt,
263
- const jsi::Value* args,
264
- const std::shared_ptr<CallInvoker>& jsInvoker,
265
- std::index_sequence<Index...>) {
241
+ Func &fn,
242
+ jsi::Runtime &rt,
243
+ const jsi::Value *args,
244
+ const std::shared_ptr<CallInvoker> &jsInvoker,
245
+ std::index_sequence<Index...> /*unused*/)
246
+ {
266
247
  return fn(bridging::fromJs<Args>(rt, args[Index], jsInvoker)...);
267
248
  }
268
249
  };
@@ -270,8 +251,7 @@ struct Bridging<std::function<R(Args...)>> {
270
251
  template <typename R, typename... Args>
271
252
  struct Bridging<
272
253
  std::function<R(Args...)>,
273
- std::enable_if_t<
274
- !std::is_same_v<std::function<R(Args...)>, std::function<R(Args...)>>>>
254
+ std::enable_if_t<!std::is_same_v<std::function<R(Args...)>, std::function<R(Args...)>>>>
275
255
  : Bridging<std::function<R(Args...)>> {};
276
256
 
277
257
  template <typename R, typename... Args>
@@ -14,26 +14,26 @@ namespace facebook::react {
14
14
 
15
15
  template <>
16
16
  struct Bridging<HighResTimeStamp> {
17
- static HighResTimeStamp fromJs(
18
- jsi::Runtime& /*rt*/,
19
- const jsi::Value& jsiValue) {
17
+ static HighResTimeStamp fromJs(jsi::Runtime & /*rt*/, const jsi::Value &jsiValue)
18
+ {
20
19
  return HighResTimeStamp::fromDOMHighResTimeStamp(jsiValue.asNumber());
21
20
  }
22
21
 
23
- static double toJs(jsi::Runtime& /*rt*/, const HighResTimeStamp& value) {
22
+ static double toJs(jsi::Runtime & /*rt*/, const HighResTimeStamp &value)
23
+ {
24
24
  return value.toDOMHighResTimeStamp();
25
25
  }
26
26
  };
27
27
 
28
28
  template <>
29
29
  struct Bridging<HighResDuration> {
30
- static HighResDuration fromJs(
31
- jsi::Runtime& /*rt*/,
32
- const jsi::Value& jsiValue) {
30
+ static HighResDuration fromJs(jsi::Runtime & /*rt*/, const jsi::Value &jsiValue)
31
+ {
33
32
  return HighResDuration::fromDOMHighResTimeStamp(jsiValue.asNumber());
34
33
  }
35
34
 
36
- static double toJs(jsi::Runtime& /*rt*/, const HighResDuration& value) {
35
+ static double toJs(jsi::Runtime & /*rt*/, const HighResDuration &value)
36
+ {
37
37
  return value.toDOMHighResTimeStamp();
38
38
  }
39
39
  };
@@ -32,9 +32,9 @@ class LongLivedObject {
32
32
  virtual void allowRelease();
33
33
 
34
34
  protected:
35
- explicit LongLivedObject(jsi::Runtime& runtime) : runtime_(runtime) {}
35
+ explicit LongLivedObject(jsi::Runtime &runtime) : runtime_(runtime) {}
36
36
  virtual ~LongLivedObject() = default;
37
- jsi::Runtime& runtime_;
37
+ jsi::Runtime &runtime_;
38
38
  };
39
39
 
40
40
  /**
@@ -42,14 +42,14 @@ class LongLivedObject {
42
42
  */
43
43
  class LongLivedObjectCollection {
44
44
  public:
45
- static LongLivedObjectCollection& get(jsi::Runtime& runtime);
45
+ static LongLivedObjectCollection &get(jsi::Runtime &runtime);
46
46
 
47
47
  LongLivedObjectCollection() = default;
48
- LongLivedObjectCollection(const LongLivedObjectCollection&) = delete;
49
- void operator=(const LongLivedObjectCollection&) = delete;
48
+ LongLivedObjectCollection(const LongLivedObjectCollection &) = delete;
49
+ void operator=(const LongLivedObjectCollection &) = delete;
50
50
 
51
51
  void add(std::shared_ptr<LongLivedObject> o);
52
- void remove(const LongLivedObject* o);
52
+ void remove(const LongLivedObject *o);
53
53
  void clear();
54
54
  size_t size() const;
55
55
 
@@ -13,44 +13,52 @@ namespace facebook::react {
13
13
 
14
14
  template <>
15
15
  struct Bridging<double> {
16
- static double fromJs(jsi::Runtime& /*unused*/, const jsi::Value& value) {
16
+ static double fromJs(jsi::Runtime & /*unused*/, const jsi::Value &value)
17
+ {
17
18
  return value.asNumber();
18
19
  }
19
20
 
20
- static double toJs(jsi::Runtime& /*unused*/, double value) {
21
+ static double toJs(jsi::Runtime & /*unused*/, double value)
22
+ {
21
23
  return value;
22
24
  }
23
25
  };
24
26
 
25
27
  template <>
26
28
  struct Bridging<float> {
27
- static float fromJs(jsi::Runtime& /*unused*/, const jsi::Value& value) {
29
+ static float fromJs(jsi::Runtime & /*unused*/, const jsi::Value &value)
30
+ {
28
31
  return (float)value.asNumber();
29
32
  }
30
33
 
31
- static float toJs(jsi::Runtime& /*unused*/, float value) {
34
+ static float toJs(jsi::Runtime & /*unused*/, float value)
35
+ {
32
36
  return value;
33
37
  }
34
38
  };
35
39
 
36
40
  template <>
37
41
  struct Bridging<int32_t> {
38
- static int32_t fromJs(jsi::Runtime& /*unused*/, const jsi::Value& value) {
42
+ static int32_t fromJs(jsi::Runtime & /*unused*/, const jsi::Value &value)
43
+ {
39
44
  return (int32_t)value.asNumber();
40
45
  }
41
46
 
42
- static int32_t toJs(jsi::Runtime& /*unused*/, int32_t value) {
47
+ static int32_t toJs(jsi::Runtime & /*unused*/, int32_t value)
48
+ {
43
49
  return value;
44
50
  }
45
51
  };
46
52
 
47
53
  template <>
48
54
  struct Bridging<uint32_t> {
49
- static uint32_t fromJs(jsi::Runtime& /*unused*/, const jsi::Value& value) {
55
+ static uint32_t fromJs(jsi::Runtime & /*unused*/, const jsi::Value &value)
56
+ {
50
57
  return (uint32_t)value.asNumber();
51
58
  }
52
59
 
53
- static jsi::Value toJs(jsi::Runtime& /*unused*/, uint32_t value) {
60
+ static jsi::Value toJs(jsi::Runtime & /*unused*/, uint32_t value)
61
+ {
54
62
  return double(value);
55
63
  }
56
64
  };