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.
- package/.flowconfig +2 -7
- package/Libraries/Animated/components/AnimatedFlatList.js +5 -3
- package/Libraries/Animated/components/AnimatedImage.js +4 -3
- package/Libraries/Animated/components/AnimatedSectionList.js +2 -2
- package/Libraries/Animated/components/AnimatedText.js +7 -3
- package/Libraries/Animated/components/AnimatedView.js +3 -2
- package/Libraries/Animated/createAnimatedComponent.js +24 -12
- package/Libraries/Animated/nodes/AnimatedColor.js +26 -10
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +43 -15
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +43 -15
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.d.ts +2 -2
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.d.ts +2 -2
- package/Libraries/Components/Glyph/Glyph.js +4 -1
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.d.ts +2 -2
- package/Libraries/Components/RefreshControl/RefreshControl.d.ts +3 -3
- package/Libraries/Components/SafeAreaView/SafeAreaView.d.ts +2 -2
- package/Libraries/Components/ScrollView/ScrollView.js +1 -0
- package/Libraries/Components/ScrollView/ScrollView.windows.js +1 -0
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +6 -6
- package/Libraries/Components/Switch/Switch.d.ts +2 -2
- package/Libraries/Components/Switch/Switch.windows.js +1 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +2 -5
- package/Libraries/Components/TextInput/TextInput.js +6 -0
- package/Libraries/Components/TextInput/TextInput.windows.js +6 -0
- package/Libraries/Components/Touchable/TouchableBounce.js +7 -7
- package/Libraries/Components/Touchable/TouchableBounce.windows.js +7 -7
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +19 -1
- package/Libraries/Components/View/View.d.ts +2 -2
- package/Libraries/Components/View/View.windows.js +0 -1
- package/Libraries/Components/View/ViewNativeComponent.js +13 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpPerformance.js +2 -0
- package/Libraries/Debugging/DebuggingOverlay.js +14 -14
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +8 -2
- package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +5 -2
- package/Libraries/Image/Image.d.ts +3 -3
- package/Libraries/Image/ImageInjection.js +3 -6
- package/Libraries/Image/ImageTypes.flow.js +3 -7
- package/Libraries/Lists/FlatList.js +8 -8
- package/Libraries/Lists/SectionList.d.ts +5 -1
- package/Libraries/Lists/ViewabilityHelper.js +1 -1
- package/Libraries/Lists/VirtualizedList.js +1 -0
- package/Libraries/LogBox/UI/AnsiHighlight.js +4 -1
- package/Libraries/NativeComponent/BaseViewConfig.android.js +11 -2
- package/Libraries/NativeComponent/NativeComponentRegistry.d.ts +98 -0
- package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -0
- package/Libraries/NativeComponent/NativeComponentRegistryUnstable.js +3 -1
- package/Libraries/NativeComponent/ViewConfigIgnore.windows.js +45 -0
- package/Libraries/Network/RCTNetworking.android.js +3 -1
- package/Libraries/Network/RCTNetworking.ios.js +3 -0
- package/Libraries/Network/RCTNetworking.windows.js +3 -0
- package/Libraries/Network/XMLHttpRequest.js +1 -41
- package/Libraries/Pressability/usePressability.js +14 -3
- package/Libraries/ReactNative/PaperUIManager.windows.js +3 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +20 -82
- package/Libraries/ReactNative/getNativeComponentAttributes.js +12 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +6759 -4478
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +3169 -3119
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +4732 -3535
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +6646 -4070
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3136 -2825
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +4761 -3312
- package/Libraries/Renderer/shims/ReactNative.js +3 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +2 -1
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +44 -0
- package/Libraries/StyleSheet/processBackgroundPosition.js +284 -0
- package/Libraries/StyleSheet/processBackgroundRepeat.js +105 -0
- package/Libraries/StyleSheet/processBackgroundSize.js +104 -0
- package/Libraries/Text/Text.d.ts +2 -2
- package/Libraries/Text/TextNativeComponent.js +10 -0
- package/Libraries/TurboModule/TurboModuleRegistry.js +3 -9
- package/Libraries/Utilities/DevLoadingView.js +14 -6
- package/Libraries/Utilities/HMRClient.js +13 -5
- package/Microsoft.ReactNative/Base/CxxReactIncludes.h +11 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +2 -0
- package/Microsoft.ReactNative/CompositionHwndHost.idl +1 -0
- package/Microsoft.ReactNative/Fabric/ComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +10 -40
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +3 -80
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +45 -12
- package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +8 -0
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +61 -74
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +4 -3
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +2 -1
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.cpp +245 -0
- package/Microsoft.ReactNative/Fabric/Composition/ReactNativeWindow.h +80 -0
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +20 -36
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +70 -49
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -1
- package/Microsoft.ReactNative/Fabric/Composition/UriImageManager.cpp +5 -0
- package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +7 -2
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +20 -94
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -3
- package/Microsoft.ReactNative/Pch/pch.h +2 -0
- package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +5 -0
- package/Microsoft.ReactNative/ReactHost/ReactNativeHeaders.h +1 -0
- package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +0 -41
- package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +0 -11
- package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -3
- package/Microsoft.ReactNative/ReactNativeWin32App.cpp +31 -101
- package/Microsoft.ReactNative/ReactNativeWin32App.h +2 -13
- package/Microsoft.ReactNative/ReactNativeWindow.idl +44 -0
- package/Microsoft.ReactNative.Cxx/AutoDraw.h +9 -1
- package/Microsoft.ReactNative.Cxx/ReactCommon/CallInvoker.h +13 -16
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModule.h +24 -36
- package/Microsoft.ReactNative.Cxx/ReactCommon/TurboModuleUtils.h +5 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/AString.h +8 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Array.h +32 -49
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +27 -76
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +4 -2
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/CallbackWrapper.h +19 -18
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +25 -48
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Convert.h +38 -31
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Error.h +11 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/EventEmitter.h +47 -45
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Function.h +69 -89
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/HighResTimeStamp.h +8 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/LongLivedObject.h +6 -6
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +16 -8
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Object.h +17 -24
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Promise.h +17 -17
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Value.h +20 -29
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/debug/react_native_assert.h +2 -7
- package/Microsoft.ReactNative.Cxx/ReactCommon/react/timing/primitives.h +127 -115
- package/PropertySheets/External/Microsoft.ReactNative.Composition.CppLib.props +10 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +10 -0
- package/PropertySheets/Generated/PackageVersion.g.props +5 -5
- package/PropertySheets/Warnings.props +2 -1
- package/ReactCommon/ReactCommon.vcxproj +21 -12
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +381 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +49 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +145 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +100 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +256 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +13 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +93 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +149 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +25 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +86 -67
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSIExecutor.cpp +629 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +123 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +84 -68
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +31 -35
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +4 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/network/HttpUtils.cpp +2 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +24 -36
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +28 -66
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +414 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +3 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/image/conversions.h +8 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +19 -16
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +8 -9
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +25 -95
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +85 -42
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +81 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +140 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +746 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +702 -0
- package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +1 -15
- package/Scripts/creaternwapp.cmd +1 -1
- package/Scripts/perf/compare-results.js +357 -0
- package/Scripts/perf/create-perf-test.js +343 -0
- package/Scripts/perf/post-pr-comment.js +210 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.cpp +8 -0
- package/Shared/Hermes/HermesRuntimeTargetDelegate.h +3 -0
- package/Shared/Shared.vcxitems +24 -12
- package/Shared/Shared.vcxitems.filters +11 -3
- package/codegen/NativeIntersectionObserverSpec.g.h +2 -0
- package/codegen/NativeNetworkingIOSSpec.g.h +2 -0
- package/codegen/NativePerformanceSpec.g.h +6 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +229 -139
- package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +42 -25
- package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +2 -1
- package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +11 -6
- package/codegen/react/components/rnwcore/AndroidSwitch.g.h +11 -6
- package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +1 -0
- package/codegen/react/components/rnwcore/InputAccessory.g.h +2 -1
- package/codegen/react/components/rnwcore/ModalHostView.g.h +40 -23
- package/codegen/react/components/rnwcore/Props.cpp +6 -1
- package/codegen/react/components/rnwcore/Props.h +1 -0
- package/codegen/react/components/rnwcore/PullToRefreshView.g.h +11 -6
- package/codegen/react/components/rnwcore/SafeAreaView.g.h +1 -0
- package/codegen/react/components/rnwcore/Switch.g.h +11 -6
- package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +2 -1
- package/codegen/react/components/rnwcore/VirtualView.g.h +41 -8
- package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +45 -8
- package/codegen/rnwcoreJSI.h +3973 -6059
- package/index.js +6 -0
- package/index.windows.js +6 -0
- package/jest/mockComponent.js +6 -6
- package/jest/setup.js +15 -10
- package/package.json +27 -27
- package/src/private/components/virtualview/VirtualView.js +22 -27
- package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +6 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +100 -19
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +18 -3
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +12 -2
- package/src/private/webapis/intersectionobserver/IntersectionObserver.js +76 -15
- package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +1 -0
- package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +1 -0
- package/src/private/webapis/performance/ResourceTiming.js +31 -4
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +4 -1
- package/src/private/webapis/performance/specs/NativePerformance.js +3 -0
- package/stubs/double-conversion/double-conversion.h +5 -0
- package/templates/cpp-app/template.config.js +1 -1
- package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +3 -1
- package/templates/cpp-lib/template.config.js +1 -1
- package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
- package/types/index.d.ts +1 -0
- package/types/public/ReactNativeTypes.d.ts +115 -2
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +0 -152
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/conversions.h +0 -1574
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ShadowNode.cpp +0 -528
- package/Scripts/OpenSSL.nuspec +0 -39
- package/Scripts/OpenSSL.targets +0 -36
- package/codegen/rnwcoreJSI-generated.cpp +0 -3470
|
@@ -24,35 +24,31 @@ namespace array_detail {
|
|
|
24
24
|
|
|
25
25
|
template <typename T, size_t N>
|
|
26
26
|
struct BridgingStatic {
|
|
27
|
-
static jsi::Array toJs(
|
|
28
|
-
|
|
29
|
-
const T& array,
|
|
30
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
27
|
+
static jsi::Array toJs(jsi::Runtime &rt, const T &array, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
28
|
+
{
|
|
31
29
|
return toJs(rt, array, jsInvoker, std::make_index_sequence<N>{});
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
private:
|
|
35
33
|
template <size_t... Index>
|
|
36
34
|
static jsi::Array toJs(
|
|
37
|
-
facebook::jsi::Runtime&
|
|
38
|
-
const T&
|
|
39
|
-
const std::shared_ptr<CallInvoker
|
|
40
|
-
std::index_sequence<Index...>)
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
facebook::jsi::Runtime &rt,
|
|
36
|
+
const T &array,
|
|
37
|
+
const std::shared_ptr<CallInvoker> &jsInvoker,
|
|
38
|
+
std::index_sequence<Index...> /*unused*/)
|
|
39
|
+
{
|
|
40
|
+
return jsi::Array::createWithElements(rt, bridging::toJs(rt, std::get<Index>(array), jsInvoker)...);
|
|
43
41
|
}
|
|
44
42
|
};
|
|
45
43
|
|
|
46
44
|
template <typename T>
|
|
47
45
|
struct BridgingDynamic {
|
|
48
|
-
static jsi::Array toJs(
|
|
49
|
-
|
|
50
|
-
const T& list,
|
|
51
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
46
|
+
static jsi::Array toJs(jsi::Runtime &rt, const T &list, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
47
|
+
{
|
|
52
48
|
jsi::Array result(rt, list.size());
|
|
53
49
|
size_t index = 0;
|
|
54
50
|
|
|
55
|
-
for (const auto&
|
|
51
|
+
for (const auto &item : list) {
|
|
56
52
|
result.setValueAtIndex(rt, index++, bridging::toJs(rt, item, jsInvoker));
|
|
57
53
|
}
|
|
58
54
|
|
|
@@ -63,18 +59,15 @@ struct BridgingDynamic {
|
|
|
63
59
|
} // namespace array_detail
|
|
64
60
|
|
|
65
61
|
template <typename T, size_t N>
|
|
66
|
-
struct Bridging<std::array<T, N>>
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const jsi::Array& array,
|
|
71
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
62
|
+
struct Bridging<std::array<T, N>> : array_detail::BridgingStatic<std::array<T, N>, N> {
|
|
63
|
+
static std::array<T, N>
|
|
64
|
+
fromJs(facebook::jsi::Runtime &rt, const jsi::Array &array, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
65
|
+
{
|
|
72
66
|
size_t length = array.length(rt);
|
|
73
67
|
|
|
74
68
|
std::array<T, N> result;
|
|
75
69
|
for (size_t i = 0; i < length; i++) {
|
|
76
|
-
result[i] =
|
|
77
|
-
bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker);
|
|
70
|
+
result[i] = bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker);
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
return result;
|
|
@@ -82,12 +75,10 @@ struct Bridging<std::array<T, N>>
|
|
|
82
75
|
};
|
|
83
76
|
|
|
84
77
|
template <typename T1, typename T2>
|
|
85
|
-
struct Bridging<std::pair<T1, T2>>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const jsi::Array& array,
|
|
90
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
78
|
+
struct Bridging<std::pair<T1, T2>> : array_detail::BridgingStatic<std::pair<T1, T2>, 2> {
|
|
79
|
+
static std::pair<T1, T1>
|
|
80
|
+
fromJs(facebook::jsi::Runtime &rt, const jsi::Array &array, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
81
|
+
{
|
|
91
82
|
return std::make_pair(
|
|
92
83
|
bridging::fromJs<T1>(rt, array.getValueAtIndex(rt, 0), jsInvoker),
|
|
93
84
|
bridging::fromJs<T2>(rt, array.getValueAtIndex(rt, 1), jsInvoker));
|
|
@@ -95,35 +86,29 @@ struct Bridging<std::pair<T1, T2>>
|
|
|
95
86
|
};
|
|
96
87
|
|
|
97
88
|
template <typename... Types>
|
|
98
|
-
struct Bridging<std::tuple<Types...>>
|
|
99
|
-
: array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {};
|
|
89
|
+
struct Bridging<std::tuple<Types...>> : array_detail::BridgingStatic<std::tuple<Types...>, sizeof...(Types)> {};
|
|
100
90
|
|
|
101
91
|
template <typename T>
|
|
102
|
-
struct Bridging<std::deque<T>> : array_detail::BridgingDynamic<std::deque<T>> {
|
|
103
|
-
};
|
|
92
|
+
struct Bridging<std::deque<T>> : array_detail::BridgingDynamic<std::deque<T>> {};
|
|
104
93
|
|
|
105
94
|
template <typename T>
|
|
106
|
-
struct Bridging<std::initializer_list<T>>
|
|
107
|
-
: array_detail::BridgingDynamic<std::initializer_list<T>> {};
|
|
95
|
+
struct Bridging<std::initializer_list<T>> : array_detail::BridgingDynamic<std::initializer_list<T>> {};
|
|
108
96
|
|
|
109
97
|
template <typename T>
|
|
110
98
|
struct Bridging<std::list<T>> : array_detail::BridgingDynamic<std::list<T>> {};
|
|
111
99
|
|
|
112
100
|
template <typename T>
|
|
113
|
-
struct Bridging<std::vector<T>>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const jsi::Array& array,
|
|
118
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
101
|
+
struct Bridging<std::vector<T>> : array_detail::BridgingDynamic<std::vector<T>> {
|
|
102
|
+
static std::vector<T>
|
|
103
|
+
fromJs(facebook::jsi::Runtime &rt, const jsi::Array &array, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
104
|
+
{
|
|
119
105
|
size_t length = array.length(rt);
|
|
120
106
|
|
|
121
107
|
std::vector<T> vector;
|
|
122
108
|
vector.reserve(length);
|
|
123
109
|
|
|
124
110
|
for (size_t i = 0; i < length; i++) {
|
|
125
|
-
vector.push_back(
|
|
126
|
-
bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker));
|
|
111
|
+
vector.push_back(bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker));
|
|
127
112
|
}
|
|
128
113
|
|
|
129
114
|
return vector;
|
|
@@ -132,16 +117,14 @@ struct Bridging<std::vector<T>>
|
|
|
132
117
|
|
|
133
118
|
template <typename T>
|
|
134
119
|
struct Bridging<std::set<T>> : array_detail::BridgingDynamic<std::set<T>> {
|
|
135
|
-
static std::set<T>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const std::shared_ptr<CallInvoker>& jsInvoker) {
|
|
120
|
+
static std::set<T>
|
|
121
|
+
fromJs(facebook::jsi::Runtime &rt, const jsi::Array &array, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
122
|
+
{
|
|
139
123
|
size_t length = array.length(rt);
|
|
140
124
|
|
|
141
125
|
std::set<T> set;
|
|
142
126
|
for (size_t i = 0; i < length; i++) {
|
|
143
|
-
set.insert(
|
|
144
|
-
bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker));
|
|
127
|
+
set.insert(bridging::fromJs<T>(rt, array.getValueAtIndex(rt, i), jsInvoker));
|
|
145
128
|
}
|
|
146
129
|
|
|
147
130
|
return set;
|
|
@@ -24,7 +24,7 @@ struct Bridging;
|
|
|
24
24
|
template <>
|
|
25
25
|
struct Bridging<void> {
|
|
26
26
|
// Highly generic code may result in "casting" to void.
|
|
27
|
-
static void fromJs(jsi::Runtime
|
|
27
|
+
static void fromJs(jsi::Runtime & /*unused*/, const jsi::Value & /*unused*/) {}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
namespace bridging {
|
|
@@ -51,9 +51,7 @@ struct bridging_wrapper {
|
|
|
51
51
|
// Convert lambda types to move-only function types since we can't specialize
|
|
52
52
|
// Bridging templates for arbitrary lambdas.
|
|
53
53
|
template <typename T>
|
|
54
|
-
struct bridging_wrapper<
|
|
55
|
-
T,
|
|
56
|
-
std::void_t<decltype(&remove_cvref_t<T>::operator())>>
|
|
54
|
+
struct bridging_wrapper<T, std::void_t<decltype(&remove_cvref_t<T>::operator())>>
|
|
57
55
|
: function_wrapper<decltype(&remove_cvref_t<T>::operator())> {};
|
|
58
56
|
|
|
59
57
|
} // namespace detail
|
|
@@ -63,70 +61,45 @@ using bridging_t = typename detail::bridging_wrapper<T>::type;
|
|
|
63
61
|
|
|
64
62
|
template <typename ReturnT, typename JSArgT>
|
|
65
63
|
requires is_jsi_v<JSArgT>
|
|
66
|
-
auto fromJs(
|
|
67
|
-
|
|
68
|
-
JSArgT&& value,
|
|
69
|
-
const std::shared_ptr<CallInvoker>& /*unused*/)
|
|
70
|
-
-> decltype(static_cast<ReturnT>(
|
|
71
|
-
std::move(convert(rt, std::forward<JSArgT>(value)))))
|
|
64
|
+
auto fromJs(jsi::Runtime &rt, JSArgT &&value, const std::shared_ptr<CallInvoker> & /*unused*/)
|
|
65
|
+
-> decltype(static_cast<ReturnT>(std::move(convert(rt, std::forward<JSArgT>(value)))))
|
|
72
66
|
|
|
73
67
|
{
|
|
74
|
-
return static_cast<ReturnT>(
|
|
75
|
-
std::move(convert(rt, std::forward<JSArgT>(value))));
|
|
68
|
+
return static_cast<ReturnT>(std::move(convert(rt, std::forward<JSArgT>(value))));
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
template <typename ReturnT, typename JSArgT>
|
|
79
|
-
auto fromJs(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
-> decltype(Bridging<remove_cvref_t<ReturnT>>::fromJs(
|
|
84
|
-
rt,
|
|
85
|
-
convert(rt, std::forward<JSArgT>(value)))) {
|
|
86
|
-
return Bridging<remove_cvref_t<ReturnT>>::fromJs(
|
|
87
|
-
rt, convert(rt, std::forward<JSArgT>(value)));
|
|
72
|
+
auto fromJs(jsi::Runtime &rt, JSArgT &&value, const std::shared_ptr<CallInvoker> & /*unused*/)
|
|
73
|
+
-> decltype(Bridging<remove_cvref_t<ReturnT>>::fromJs(rt, convert(rt, std::forward<JSArgT>(value))))
|
|
74
|
+
{
|
|
75
|
+
return Bridging<remove_cvref_t<ReturnT>>::fromJs(rt, convert(rt, std::forward<JSArgT>(value)));
|
|
88
76
|
}
|
|
89
77
|
|
|
90
78
|
template <typename ReturnT, typename JSArgT>
|
|
91
|
-
auto fromJs(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
-> decltype(Bridging<remove_cvref_t<ReturnT>>::fromJs(
|
|
96
|
-
rt,
|
|
97
|
-
convert(rt, std::forward<JSArgT>(value)),
|
|
98
|
-
jsInvoker)) {
|
|
99
|
-
return Bridging<remove_cvref_t<ReturnT>>::fromJs(
|
|
100
|
-
rt, convert(rt, std::forward<JSArgT>(value)), jsInvoker);
|
|
79
|
+
auto fromJs(jsi::Runtime &rt, JSArgT &&value, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
80
|
+
-> decltype(Bridging<remove_cvref_t<ReturnT>>::fromJs(rt, convert(rt, std::forward<JSArgT>(value)), jsInvoker))
|
|
81
|
+
{
|
|
82
|
+
return Bridging<remove_cvref_t<ReturnT>>::fromJs(rt, convert(rt, std::forward<JSArgT>(value)), jsInvoker);
|
|
101
83
|
}
|
|
102
84
|
|
|
103
85
|
template <typename T>
|
|
104
86
|
requires is_jsi_v<T>
|
|
105
|
-
auto toJs(
|
|
106
|
-
|
|
107
|
-
T&& value,
|
|
108
|
-
const std::shared_ptr<CallInvoker>& = nullptr) -> remove_cvref_t<T> {
|
|
87
|
+
auto toJs(jsi::Runtime &rt, T &&value, const std::shared_ptr<CallInvoker> & /*unused*/ = nullptr) -> remove_cvref_t<T>
|
|
88
|
+
{
|
|
109
89
|
return convert(rt, std::forward<T>(value));
|
|
110
90
|
}
|
|
111
91
|
|
|
112
92
|
template <typename T>
|
|
113
|
-
auto toJs(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const std::shared_ptr<CallInvoker>& = nullptr)
|
|
117
|
-
-> decltype(Bridging<bridging_t<T>>::toJs(rt, std::forward<T>(value))) {
|
|
93
|
+
auto toJs(jsi::Runtime &rt, T &&value, const std::shared_ptr<CallInvoker> & /*unused*/ = nullptr)
|
|
94
|
+
-> decltype(Bridging<bridging_t<T>>::toJs(rt, std::forward<T>(value)))
|
|
95
|
+
{
|
|
118
96
|
return Bridging<bridging_t<T>>::toJs(rt, std::forward<T>(value));
|
|
119
97
|
}
|
|
120
98
|
|
|
121
99
|
template <typename T>
|
|
122
|
-
auto toJs(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const std::shared_ptr<CallInvoker>& jsInvoker)
|
|
126
|
-
-> decltype(Bridging<bridging_t<T>>::toJs(
|
|
127
|
-
rt,
|
|
128
|
-
std::forward<T>(value),
|
|
129
|
-
jsInvoker)) {
|
|
100
|
+
auto toJs(jsi::Runtime &rt, T &&value, const std::shared_ptr<CallInvoker> &jsInvoker)
|
|
101
|
+
-> decltype(Bridging<bridging_t<T>>::toJs(rt, std::forward<T>(value), jsInvoker))
|
|
102
|
+
{
|
|
130
103
|
return Bridging<bridging_t<T>>::toJs(rt, std::forward<T>(value), jsInvoker);
|
|
131
104
|
}
|
|
132
105
|
|
|
@@ -137,19 +110,13 @@ template <typename T, typename Arg>
|
|
|
137
110
|
inline constexpr bool supportsFromJs<
|
|
138
111
|
T,
|
|
139
112
|
Arg,
|
|
140
|
-
std::void_t<decltype(fromJs<T>(
|
|
141
|
-
std::declval<jsi::Runtime&>(),
|
|
142
|
-
std::declval<Arg>(),
|
|
143
|
-
nullptr))>> = true;
|
|
113
|
+
std::void_t<decltype(fromJs<T>(std::declval<jsi::Runtime &>(), std::declval<Arg>(), nullptr))>> = true;
|
|
144
114
|
|
|
145
115
|
template <typename T>
|
|
146
116
|
inline constexpr bool supportsFromJs<
|
|
147
117
|
T,
|
|
148
118
|
jsi::Value,
|
|
149
|
-
std::void_t<decltype(fromJs<T>(
|
|
150
|
-
std::declval<jsi::Runtime&>(),
|
|
151
|
-
std::declval<jsi::Value>(),
|
|
152
|
-
nullptr))>> = true;
|
|
119
|
+
std::void_t<decltype(fromJs<T>(std::declval<jsi::Runtime &>(), std::declval<jsi::Value>(), nullptr))>> = true;
|
|
153
120
|
|
|
154
121
|
template <typename, typename = jsi::Value, typename = void>
|
|
155
122
|
inline constexpr bool supportsToJs = false;
|
|
@@ -158,31 +125,15 @@ template <typename JSReturnT, typename ReturnT>
|
|
|
158
125
|
inline constexpr bool supportsToJs<
|
|
159
126
|
JSReturnT,
|
|
160
127
|
ReturnT,
|
|
161
|
-
std::void_t<decltype(toJs(
|
|
162
|
-
|
|
163
|
-
std::declval<JSReturnT>(),
|
|
164
|
-
nullptr))>> =
|
|
165
|
-
std::is_convertible_v<
|
|
166
|
-
decltype(toJs(
|
|
167
|
-
std::declval<jsi::Runtime&>(),
|
|
168
|
-
std::declval<JSReturnT>(),
|
|
169
|
-
nullptr)),
|
|
170
|
-
ReturnT>;
|
|
128
|
+
std::void_t<decltype(toJs(std::declval<jsi::Runtime &>(), std::declval<JSReturnT>(), nullptr))>> =
|
|
129
|
+
std::is_convertible_v<decltype(toJs(std::declval<jsi::Runtime &>(), std::declval<JSReturnT>(), nullptr)), ReturnT>;
|
|
171
130
|
|
|
172
131
|
template <typename ReturnT>
|
|
173
132
|
inline constexpr bool supportsToJs<
|
|
174
133
|
ReturnT,
|
|
175
134
|
jsi::Value,
|
|
176
|
-
std::void_t<decltype(toJs(
|
|
177
|
-
|
|
178
|
-
std::declval<ReturnT>(),
|
|
179
|
-
nullptr))>> =
|
|
180
|
-
std::is_convertible_v<
|
|
181
|
-
decltype(toJs(
|
|
182
|
-
std::declval<jsi::Runtime&>(),
|
|
183
|
-
std::declval<ReturnT>(),
|
|
184
|
-
nullptr)),
|
|
185
|
-
jsi::Value>;
|
|
135
|
+
std::void_t<decltype(toJs(std::declval<jsi::Runtime &>(), std::declval<ReturnT>(), nullptr))>> =
|
|
136
|
+
std::is_convertible_v<decltype(toJs(std::declval<jsi::Runtime &>(), std::declval<ReturnT>(), nullptr)), jsi::Value>;
|
|
186
137
|
|
|
187
138
|
} // namespace bridging
|
|
188
139
|
} // namespace facebook::react
|
|
@@ -13,11 +13,13 @@ namespace facebook::react {
|
|
|
13
13
|
|
|
14
14
|
template <>
|
|
15
15
|
struct Bridging<bool> {
|
|
16
|
-
static bool fromJs(jsi::Runtime
|
|
16
|
+
static bool fromJs(jsi::Runtime & /*unused*/, const jsi::Value &value)
|
|
17
|
+
{
|
|
17
18
|
return value.asBool();
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
static bool toJs(jsi::Runtime& /*unused*/, bool value)
|
|
21
|
+
static bool toJs(jsi::Runtime & /*unused*/, bool value)
|
|
22
|
+
{
|
|
21
23
|
return value;
|
|
22
24
|
}
|
|
23
25
|
};
|
|
@@ -20,46 +20,47 @@ class CallInvoker;
|
|
|
20
20
|
// Helper for passing jsi::Function arg to other methods.
|
|
21
21
|
class CallbackWrapper : public LongLivedObject {
|
|
22
22
|
private:
|
|
23
|
-
CallbackWrapper(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
: LongLivedObject(runtime),
|
|
28
|
-
callback_(std::move(callback)),
|
|
29
|
-
jsInvoker_(std::move(jsInvoker)) {}
|
|
23
|
+
CallbackWrapper(jsi::Function &&callback, jsi::Runtime &runtime, std::shared_ptr<CallInvoker> jsInvoker)
|
|
24
|
+
: LongLivedObject(runtime), callback_(std::move(callback)), jsInvoker_(std::move(jsInvoker))
|
|
25
|
+
{
|
|
26
|
+
}
|
|
30
27
|
|
|
31
28
|
jsi::Function callback_;
|
|
32
29
|
std::shared_ptr<CallInvoker> jsInvoker_;
|
|
33
30
|
|
|
34
31
|
public:
|
|
35
|
-
static std::weak_ptr<CallbackWrapper>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
std::move(callback), runtime, std::move(jsInvoker)));
|
|
32
|
+
static std::weak_ptr<CallbackWrapper>
|
|
33
|
+
createWeak(jsi::Function &&callback, jsi::Runtime &runtime, std::shared_ptr<CallInvoker> jsInvoker)
|
|
34
|
+
{
|
|
35
|
+
auto wrapper =
|
|
36
|
+
std::shared_ptr<CallbackWrapper>(new CallbackWrapper(std::move(callback), runtime, std::move(jsInvoker)));
|
|
41
37
|
LongLivedObjectCollection::get(runtime).add(wrapper);
|
|
42
38
|
return wrapper;
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
// Delete the enclosed jsi::Function
|
|
46
|
-
void destroy()
|
|
42
|
+
void destroy()
|
|
43
|
+
{
|
|
47
44
|
allowRelease();
|
|
48
45
|
}
|
|
49
46
|
|
|
50
|
-
jsi::Function&
|
|
47
|
+
jsi::Function &callback() noexcept
|
|
48
|
+
{
|
|
51
49
|
return callback_;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
jsi::Runtime&
|
|
52
|
+
jsi::Runtime &runtime() noexcept
|
|
53
|
+
{
|
|
55
54
|
return runtime_;
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
CallInvoker&
|
|
57
|
+
CallInvoker &jsInvoker() noexcept
|
|
58
|
+
{
|
|
59
59
|
return *(jsInvoker_);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
std::shared_ptr<CallInvoker> jsInvokerPtr() noexcept
|
|
62
|
+
std::shared_ptr<CallInvoker> jsInvokerPtr() noexcept
|
|
63
|
+
{
|
|
63
64
|
return jsInvoker_;
|
|
64
65
|
}
|
|
65
66
|
};
|
|
@@ -11,64 +11,41 @@
|
|
|
11
11
|
|
|
12
12
|
namespace facebook::react::bridging {
|
|
13
13
|
|
|
14
|
-
template <
|
|
15
|
-
typename JSReturnT,
|
|
16
|
-
typename ClassT,
|
|
17
|
-
typename ReturnT,
|
|
18
|
-
typename... ArgsT,
|
|
19
|
-
typename... JSArgsT>
|
|
14
|
+
template <typename JSReturnT, typename ClassT, typename ReturnT, typename... ArgsT, typename... JSArgsT>
|
|
20
15
|
JSReturnT callFromJs(
|
|
21
|
-
jsi::Runtime&
|
|
22
|
-
ReturnT (ClassT::*method)(jsi::Runtime&, ArgsT...),
|
|
23
|
-
const std::shared_ptr<CallInvoker
|
|
24
|
-
ClassT*
|
|
25
|
-
JSArgsT&&...
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
static_assert(
|
|
29
|
-
(supportsFromJs<ArgsT, JSArgsT> && ...), "Incompatible arguments");
|
|
16
|
+
jsi::Runtime &rt,
|
|
17
|
+
ReturnT (ClassT::*method)(jsi::Runtime &, ArgsT...),
|
|
18
|
+
const std::shared_ptr<CallInvoker> &jsInvoker,
|
|
19
|
+
ClassT *instance,
|
|
20
|
+
JSArgsT &&...args)
|
|
21
|
+
{
|
|
22
|
+
static_assert(sizeof...(ArgsT) == sizeof...(JSArgsT), "Incorrect arguments length");
|
|
23
|
+
static_assert((supportsFromJs<ArgsT, JSArgsT> && ...), "Incompatible arguments");
|
|
30
24
|
if constexpr (std::is_void_v<JSReturnT>) {
|
|
31
|
-
static_assert(
|
|
32
|
-
std::is_void_v<ReturnT>,
|
|
33
|
-
"Method must return void when JSReturnT is void");
|
|
25
|
+
static_assert(std::is_void_v<ReturnT>, "Method must return void when JSReturnT is void");
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
if constexpr (std::is_void_v<JSReturnT>) {
|
|
37
|
-
(instance->*method)(
|
|
38
|
-
rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
29
|
+
(instance->*method)(rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
39
30
|
|
|
40
31
|
} else if constexpr (std::is_void_v<ReturnT>) {
|
|
41
|
-
static_assert(
|
|
42
|
-
std::is_same_v<JSReturnT, jsi::Value>,
|
|
43
|
-
"Void functions may only return undefined");
|
|
32
|
+
static_assert(std::is_same_v<JSReturnT, jsi::Value>, "Void functions may only return undefined");
|
|
44
33
|
|
|
45
|
-
(instance->*method)(
|
|
46
|
-
rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
34
|
+
(instance->*method)(rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
47
35
|
return jsi::Value();
|
|
48
36
|
|
|
49
|
-
} else if constexpr (
|
|
50
|
-
is_jsi_v<JSReturnT> || supportsToJs<ReturnT, JSReturnT>) {
|
|
37
|
+
} else if constexpr (is_jsi_v<JSReturnT> || supportsToJs<ReturnT, JSReturnT>) {
|
|
51
38
|
static_assert(supportsToJs<ReturnT, JSReturnT>, "Incompatible return type");
|
|
52
39
|
|
|
53
|
-
return toJs(
|
|
54
|
-
rt,
|
|
55
|
-
(instance->*method)(
|
|
56
|
-
rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...),
|
|
57
|
-
jsInvoker);
|
|
40
|
+
return toJs(rt, (instance->*method)(rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...), jsInvoker);
|
|
58
41
|
} else if constexpr (is_optional_jsi_v<JSReturnT>) {
|
|
59
42
|
static_assert(
|
|
60
|
-
is_optional_v<ReturnT>
|
|
61
|
-
|
|
62
|
-
typename ReturnT::value_type,
|
|
63
|
-
typename JSReturnT::value_type>
|
|
64
|
-
: supportsToJs<ReturnT, typename JSReturnT::value_type>,
|
|
43
|
+
is_optional_v<ReturnT> ? supportsToJs<typename ReturnT::value_type, typename JSReturnT::value_type>
|
|
44
|
+
: supportsToJs<ReturnT, typename JSReturnT::value_type>,
|
|
65
45
|
"Incompatible return type");
|
|
66
46
|
|
|
67
|
-
auto result =
|
|
68
|
-
rt,
|
|
69
|
-
(instance->*method)(
|
|
70
|
-
rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...),
|
|
71
|
-
jsInvoker);
|
|
47
|
+
auto result =
|
|
48
|
+
toJs(rt, (instance->*method)(rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...), jsInvoker);
|
|
72
49
|
|
|
73
50
|
if constexpr (std::is_same_v<decltype(result), jsi::Value>) {
|
|
74
51
|
if (result.isNull() || result.isUndefined()) {
|
|
@@ -78,20 +55,20 @@ JSReturnT callFromJs(
|
|
|
78
55
|
|
|
79
56
|
return convert(rt, std::move(result));
|
|
80
57
|
} else {
|
|
81
|
-
static_assert(
|
|
82
|
-
|
|
83
|
-
return (instance->*method)(
|
|
84
|
-
rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
58
|
+
static_assert(std::is_convertible_v<ReturnT, JSReturnT>, "Incompatible return type");
|
|
59
|
+
return (instance->*method)(rt, fromJs<ArgsT>(rt, std::forward<JSArgsT>(args), jsInvoker)...);
|
|
85
60
|
}
|
|
86
61
|
}
|
|
87
62
|
|
|
88
63
|
template <typename ReturnT, typename... ArgsT>
|
|
89
|
-
constexpr size_t getParameterCount(ReturnT (*)(ArgsT...))
|
|
64
|
+
constexpr size_t getParameterCount(ReturnT (* /*unused*/)(ArgsT...))
|
|
65
|
+
{
|
|
90
66
|
return sizeof...(ArgsT);
|
|
91
67
|
}
|
|
92
68
|
|
|
93
69
|
template <typename Class, typename ReturnT, typename... ArgsT>
|
|
94
|
-
constexpr size_t getParameterCount(ReturnT (Class::*)(ArgsT...))
|
|
70
|
+
constexpr size_t getParameterCount(ReturnT (Class::* /*unused*/)(ArgsT...))
|
|
71
|
+
{
|
|
95
72
|
return sizeof...(ArgsT);
|
|
96
73
|
}
|
|
97
74
|
|
|
@@ -19,10 +19,8 @@ template <typename T>
|
|
|
19
19
|
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
|
|
20
20
|
|
|
21
21
|
template <typename T>
|
|
22
|
-
inline constexpr bool is_jsi_v =
|
|
23
|
-
std::is_same_v<jsi::
|
|
24
|
-
std::is_same_v<jsi::String, remove_cvref_t<T>> ||
|
|
25
|
-
std::is_base_of_v<jsi::Object, remove_cvref_t<T>>;
|
|
22
|
+
inline constexpr bool is_jsi_v = std::is_same_v<jsi::Value, remove_cvref_t<T>> ||
|
|
23
|
+
std::is_same_v<jsi::String, remove_cvref_t<T>> || std::is_base_of_v<jsi::Object, remove_cvref_t<T>>;
|
|
26
24
|
|
|
27
25
|
template <typename>
|
|
28
26
|
struct is_optional : std::false_type {};
|
|
@@ -37,9 +35,8 @@ template <typename T, typename = void>
|
|
|
37
35
|
inline constexpr bool is_optional_jsi_v = false;
|
|
38
36
|
|
|
39
37
|
template <typename T>
|
|
40
|
-
inline constexpr bool
|
|
41
|
-
|
|
42
|
-
is_jsi_v<typename T::value_type>;
|
|
38
|
+
inline constexpr bool is_optional_jsi_v<T, typename std::enable_if_t<is_optional_v<T>>> =
|
|
39
|
+
is_jsi_v<typename T::value_type>;
|
|
43
40
|
|
|
44
41
|
template <typename T>
|
|
45
42
|
struct Converter;
|
|
@@ -48,10 +45,10 @@ template <typename T>
|
|
|
48
45
|
struct ConverterBase {
|
|
49
46
|
using BaseT = remove_cvref_t<T>;
|
|
50
47
|
|
|
51
|
-
ConverterBase(jsi::Runtime&
|
|
52
|
-
: rt_(rt), value_(std::forward<T>(value)) {}
|
|
48
|
+
ConverterBase(jsi::Runtime &rt, T &&value) : rt_(rt), value_(std::forward<T>(value)) {}
|
|
53
49
|
|
|
54
|
-
operator BaseT() &&
|
|
50
|
+
operator BaseT() &&
|
|
51
|
+
{
|
|
55
52
|
if constexpr (std::is_lvalue_reference_v<T>) {
|
|
56
53
|
// Copy the reference into a Value that then can be moved from.
|
|
57
54
|
auto value = jsi::Value(rt_, value_);
|
|
@@ -79,17 +76,16 @@ struct ConverterBase {
|
|
|
79
76
|
// Ensure non-reference type can be converted to the desired type.
|
|
80
77
|
std::is_convertible_v<Converter<BaseT>, U>,
|
|
81
78
|
int> = 0>
|
|
82
|
-
operator U() &&
|
|
79
|
+
operator U() &&
|
|
80
|
+
{
|
|
83
81
|
return Converter<BaseT>(rt_, std::move(*this).operator BaseT());
|
|
84
82
|
}
|
|
85
83
|
|
|
86
|
-
template <
|
|
87
|
-
typename U,
|
|
88
|
-
std::enable_if_t<is_jsi_v<T> && std::is_same_v<U, jsi::Value>, int> = 0>
|
|
84
|
+
template <typename U, std::enable_if_t<is_jsi_v<T> && std::is_same_v<U, jsi::Value>, int> = 0>
|
|
89
85
|
operator U() && = delete; // Prevent unwanted upcasting of JSI values.
|
|
90
86
|
|
|
91
87
|
protected:
|
|
92
|
-
jsi::Runtime&
|
|
88
|
+
jsi::Runtime &rt_;
|
|
93
89
|
T value_;
|
|
94
90
|
};
|
|
95
91
|
|
|
@@ -102,19 +98,23 @@ template <>
|
|
|
102
98
|
struct Converter<jsi::Value> : public ConverterBase<jsi::Value> {
|
|
103
99
|
using ConverterBase<jsi::Value>::ConverterBase;
|
|
104
100
|
|
|
105
|
-
operator jsi::String() &&
|
|
101
|
+
operator jsi::String() &&
|
|
102
|
+
{
|
|
106
103
|
return std::move(value_).asString(rt_);
|
|
107
104
|
}
|
|
108
105
|
|
|
109
|
-
operator jsi::Object() &&
|
|
106
|
+
operator jsi::Object() &&
|
|
107
|
+
{
|
|
110
108
|
return std::move(value_).asObject(rt_);
|
|
111
109
|
}
|
|
112
110
|
|
|
113
|
-
operator jsi::Array() &&
|
|
111
|
+
operator jsi::Array() &&
|
|
112
|
+
{
|
|
114
113
|
return std::move(value_).asObject(rt_).asArray(rt_);
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
operator jsi::Function() &&
|
|
116
|
+
operator jsi::Function() &&
|
|
117
|
+
{
|
|
118
118
|
return std::move(value_).asObject(rt_).asFunction(rt_);
|
|
119
119
|
}
|
|
120
120
|
};
|
|
@@ -123,21 +123,26 @@ template <>
|
|
|
123
123
|
struct Converter<jsi::Object> : public ConverterBase<jsi::Object> {
|
|
124
124
|
using ConverterBase<jsi::Object>::ConverterBase;
|
|
125
125
|
|
|
126
|
-
operator jsi::Array() &&
|
|
126
|
+
operator jsi::Array() &&
|
|
127
|
+
{
|
|
127
128
|
return std::move(value_).asArray(rt_);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
operator jsi::Function() &&
|
|
131
|
+
operator jsi::Function() &&
|
|
132
|
+
{
|
|
131
133
|
return std::move(value_).asFunction(rt_);
|
|
132
134
|
}
|
|
133
135
|
};
|
|
134
136
|
|
|
135
137
|
template <typename T>
|
|
136
138
|
struct Converter<std::optional<T>> : public ConverterBase<jsi::Value> {
|
|
137
|
-
Converter(jsi::Runtime&
|
|
138
|
-
: ConverterBase(rt, value ? std::move(*value) : jsi::Value::null())
|
|
139
|
+
Converter(jsi::Runtime &rt, std::optional<T> value)
|
|
140
|
+
: ConverterBase(rt, value ? std::move(*value) : jsi::Value::null())
|
|
141
|
+
{
|
|
142
|
+
}
|
|
139
143
|
|
|
140
|
-
operator std::optional<T>() &&
|
|
144
|
+
operator std::optional<T>() &&
|
|
145
|
+
{
|
|
141
146
|
if (value_.isNull() || value_.isUndefined()) {
|
|
142
147
|
return {};
|
|
143
148
|
}
|
|
@@ -146,24 +151,26 @@ struct Converter<std::optional<T>> : public ConverterBase<jsi::Value> {
|
|
|
146
151
|
};
|
|
147
152
|
|
|
148
153
|
template <typename T, std::enable_if_t<is_jsi_v<T>, int> = 0>
|
|
149
|
-
auto convert(jsi::Runtime&
|
|
154
|
+
auto convert(jsi::Runtime &rt, T &&value)
|
|
155
|
+
{
|
|
150
156
|
return Converter<T>(rt, std::forward<T>(value));
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
template <
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
auto convert(jsi::Runtime& rt, std::optional<T> value) {
|
|
159
|
+
template <typename T, std::enable_if_t<is_jsi_v<T> || std::is_scalar_v<T>, int> = 0>
|
|
160
|
+
auto convert(jsi::Runtime &rt, std::optional<T> value)
|
|
161
|
+
{
|
|
157
162
|
return Converter<std::optional<T>>(rt, std::move(value));
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
template <typename T, std::enable_if_t<std::is_scalar_v<T>, int> = 0>
|
|
161
|
-
auto convert(jsi::Runtime& /*rt*/, T&&
|
|
166
|
+
auto convert(jsi::Runtime & /*rt*/, T &&value)
|
|
167
|
+
{
|
|
162
168
|
return value;
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
template <typename T>
|
|
166
|
-
auto convert(jsi::Runtime& /*rt*/, Converter<T
|
|
172
|
+
auto convert(jsi::Runtime & /*rt*/, Converter<T> &&converter)
|
|
173
|
+
{
|
|
167
174
|
return std::move(converter);
|
|
168
175
|
}
|
|
169
176
|
|