react-native-windows 0.82.3 → 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/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/CompositionEventHandler.cpp +2 -52
- 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/UriImageManager.cpp +5 -0
- package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +1 -0
- 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/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/Generated/PackageVersion.g.props +5 -5
- package/PropertySheets/Warnings.props +2 -1
- package/ReactCommon/ReactCommon.vcxproj +11 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +4 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +5 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +4 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +6 -4
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +2 -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 +15 -8
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +4 -2
- 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 +5 -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 +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +2 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/imagemanager/primitives.h +25 -31
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +19 -5
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +16 -1
- 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 +15 -3
- 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 +1 -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/BaseViewProps.cpp +0 -628
- 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
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import "ReactNativeIsland.idl";
|
|
5
|
+
|
|
6
|
+
#include "NamespaceRedirect.h"
|
|
7
|
+
#include "DocString.h"
|
|
8
|
+
|
|
9
|
+
namespace Microsoft.ReactNative
|
|
10
|
+
{
|
|
11
|
+
|
|
12
|
+
[experimental]
|
|
13
|
+
enum ContentSizePolicy
|
|
14
|
+
{
|
|
15
|
+
None,
|
|
16
|
+
ResizeContentToParentWindow,
|
|
17
|
+
ResizeParentWindowToContent,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
[default_interface]
|
|
21
|
+
[webhosthidden]
|
|
22
|
+
[experimental]
|
|
23
|
+
DOC_STRING("Simplifies hosting a ReactNativeIsland inside a Window.")
|
|
24
|
+
runtimeclass ReactNativeWindow : Windows.Foundation.IClosable
|
|
25
|
+
{
|
|
26
|
+
static ReactNativeWindow CreateFromCompositor(Microsoft.UI.Composition.Compositor compositor);
|
|
27
|
+
static ReactNativeWindow CreateFromWindow(Microsoft.UI.Windowing.AppWindow appWindow, Microsoft.UI.Composition.Compositor compositor);
|
|
28
|
+
static ReactNativeWindow CreateFromContentSiteBridgeAndIsland(Microsoft.UI.Content.IContentSiteBridge bridge, Microsoft.ReactNative.ReactNativeIsland island);
|
|
29
|
+
static ReactNativeWindow CreateFromWindowAndIsland(Microsoft.UI.Windowing.AppWindow appWindow, Microsoft.ReactNative.ReactNativeIsland island);
|
|
30
|
+
|
|
31
|
+
ReactNativeIsland ReactNativeIsland { get; };
|
|
32
|
+
|
|
33
|
+
Microsoft.UI.Windowing.AppWindow AppWindow { get; };
|
|
34
|
+
|
|
35
|
+
Microsoft.UI.Content.IContentSiteBridge ContentSiteBridge { get; };
|
|
36
|
+
ContentSizePolicy ResizePolicy { get; set; };
|
|
37
|
+
|
|
38
|
+
DOC_STRING("When the ResizePolicy is set to ResizeParentWindowToContent, these LayoutConstraints will control the layout of the content."
|
|
39
|
+
" When ResizePolicy is set to ResizeContentToParentWindow, these constraints will be ignored. Instead the window can be constrained using"
|
|
40
|
+
" OverlappedPresenter.PreferredMaximumHeight etc.")
|
|
41
|
+
LayoutConstraints LayoutConstraints { get; set; };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace Microsoft.ReactNative
|
|
@@ -16,7 +16,10 @@ class AutoDrawDrawingSurface {
|
|
|
16
16
|
POINT *offset) noexcept {
|
|
17
17
|
drawingSurface.as(m_drawingSurfaceInterop);
|
|
18
18
|
auto dpi = scaleFactor * 96.0f;
|
|
19
|
-
m_drawingSurfaceInterop->BeginDraw(m_d2dDeviceContext.put(), dpi, dpi, offset);
|
|
19
|
+
auto hr = m_drawingSurfaceInterop->BeginDraw(m_d2dDeviceContext.put(), dpi, dpi, offset);
|
|
20
|
+
if (FAILED(hr)) {
|
|
21
|
+
m_d2dDeviceContext = nullptr;
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
~AutoDrawDrawingSurface() noexcept {
|
|
@@ -34,6 +37,11 @@ class AutoDrawDrawingSurface {
|
|
|
34
37
|
return m_d2dDeviceContext.get();
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
// Returns true if the device context is valid and safe to use for drawing operations
|
|
41
|
+
bool IsValid() const noexcept {
|
|
42
|
+
return m_d2dDeviceContext != nullptr;
|
|
43
|
+
}
|
|
44
|
+
|
|
37
45
|
private:
|
|
38
46
|
winrt::com_ptr<Experimental::ICompositionDrawingSurfaceInterop> m_drawingSurfaceInterop;
|
|
39
47
|
winrt::com_ptr<ID2D1DeviceContext> m_d2dDeviceContext;
|
|
@@ -18,7 +18,7 @@ class Runtime;
|
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
|
-
using CallFunc = std::function<void(jsi::Runtime&)>;
|
|
21
|
+
using CallFunc = std::function<void(jsi::Runtime &)>;
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* An interface for a generic native-to-JS call invoker. See BridgeJSCallInvoker
|
|
@@ -26,23 +26,24 @@ using CallFunc = std::function<void(jsi::Runtime&)>;
|
|
|
26
26
|
*/
|
|
27
27
|
class CallInvoker {
|
|
28
28
|
public:
|
|
29
|
-
virtual void invokeAsync(CallFunc&&
|
|
30
|
-
virtual void invokeAsync(
|
|
31
|
-
|
|
32
|
-
CallFunc&& func) noexcept {
|
|
29
|
+
virtual void invokeAsync(CallFunc &&func) noexcept = 0;
|
|
30
|
+
virtual void invokeAsync(SchedulerPriority /*priority*/, CallFunc &&func) noexcept
|
|
31
|
+
{
|
|
33
32
|
// When call with priority is not implemented, fall back to a regular async
|
|
34
33
|
// execution
|
|
35
34
|
invokeAsync(std::move(func));
|
|
36
35
|
}
|
|
37
|
-
virtual void invokeSync(CallFunc&&
|
|
36
|
+
virtual void invokeSync(CallFunc &&func) = 0;
|
|
38
37
|
|
|
39
38
|
// Backward compatibility only, prefer the CallFunc methods instead
|
|
40
|
-
virtual void invokeAsync(std::function<void()
|
|
41
|
-
|
|
39
|
+
virtual void invokeAsync(std::function<void()> &&func) noexcept
|
|
40
|
+
{
|
|
41
|
+
invokeAsync([func = std::move(func)](jsi::Runtime &) { func(); });
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
virtual void invokeSync(std::function<void()
|
|
45
|
-
|
|
44
|
+
virtual void invokeSync(std::function<void()> &&func)
|
|
45
|
+
{
|
|
46
|
+
invokeSync([func = std::move(func)](jsi::Runtime &) { func(); });
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
virtual ~CallInvoker() = default;
|
|
@@ -52,12 +53,8 @@ using NativeMethodCallFunc = std::function<void()>;
|
|
|
52
53
|
|
|
53
54
|
class NativeMethodCallInvoker {
|
|
54
55
|
public:
|
|
55
|
-
virtual void invokeAsync(
|
|
56
|
-
|
|
57
|
-
NativeMethodCallFunc&& func) noexcept = 0;
|
|
58
|
-
virtual void invokeSync(
|
|
59
|
-
const std::string& methodName,
|
|
60
|
-
NativeMethodCallFunc&& func) = 0;
|
|
56
|
+
virtual void invokeAsync(const std::string &methodName, NativeMethodCallFunc &&func) noexcept = 0;
|
|
57
|
+
virtual void invokeSync(const std::string &methodName, NativeMethodCallFunc &&func) = 0;
|
|
61
58
|
virtual ~NativeMethodCallInvoker() = default;
|
|
62
59
|
};
|
|
63
60
|
|
|
@@ -36,9 +36,7 @@ enum TurboModuleMethodValueKind {
|
|
|
36
36
|
/**
|
|
37
37
|
* Determines TurboModuleMethodValueKind based on the jsi::Value type.
|
|
38
38
|
*/
|
|
39
|
-
TurboModuleMethodValueKind getTurboModuleMethodValueKind(
|
|
40
|
-
jsi::Runtime& rt,
|
|
41
|
-
const jsi::Value* value);
|
|
39
|
+
TurboModuleMethodValueKind getTurboModuleMethodValueKind(jsi::Runtime &rt, const jsi::Value *value);
|
|
42
40
|
|
|
43
41
|
class TurboCxxModule;
|
|
44
42
|
class TurboModuleBinding;
|
|
@@ -55,8 +53,8 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
55
53
|
// JS representation. To customize lookup of properties, override `create`.
|
|
56
54
|
// Note: keep this method declared inline to avoid conflicts
|
|
57
55
|
// between RTTI and non-RTTI compilation units
|
|
58
|
-
jsi::Value get(jsi::Runtime&
|
|
59
|
-
|
|
56
|
+
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &propName) override
|
|
57
|
+
{
|
|
60
58
|
auto prop = create(runtime, propName);
|
|
61
59
|
// If we have a JS wrapper, cache the result of this lookup
|
|
62
60
|
// We don't cache misses, to allow for methodMap_ to dynamically be
|
|
@@ -64,15 +62,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
64
62
|
// [Windows] Reenable once https://github.com/microsoft/react-native-windows/issues/14128 is fixed
|
|
65
63
|
#ifndef WINAPI_FAMILY
|
|
66
64
|
if (jsRepresentation_ && !prop.isUndefined()) {
|
|
67
|
-
jsRepresentation_->lock(runtime).asObject(runtime).setProperty(
|
|
68
|
-
runtime, propName, prop);
|
|
65
|
+
jsRepresentation_->lock(runtime).asObject(runtime).setProperty(runtime, propName, prop);
|
|
69
66
|
}
|
|
70
67
|
#endif
|
|
71
68
|
return prop;
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
std::vector<jsi::PropNameID> getPropertyNames(
|
|
75
|
-
|
|
71
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &runtime) override
|
|
72
|
+
{
|
|
76
73
|
std::vector<jsi::PropNameID> result;
|
|
77
74
|
result.reserve(methodMap_.size());
|
|
78
75
|
for (auto it = methodMap_.cbegin(); it != methodMap_.cend(); ++it) {
|
|
@@ -87,18 +84,14 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
87
84
|
|
|
88
85
|
struct MethodMetadata {
|
|
89
86
|
size_t argCount;
|
|
90
|
-
jsi::Value (*invoker)(
|
|
91
|
-
jsi::Runtime& rt,
|
|
92
|
-
TurboModule& turboModule,
|
|
93
|
-
const jsi::Value* args,
|
|
94
|
-
size_t count);
|
|
87
|
+
jsi::Value (*invoker)(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value *args, size_t count);
|
|
95
88
|
};
|
|
96
89
|
std::unordered_map<std::string, MethodMetadata> methodMap_;
|
|
97
|
-
std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>>
|
|
98
|
-
eventEmitterMap_;
|
|
99
90
|
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
friend class TurboModuleTestFixtureInternal;
|
|
92
|
+
std::unordered_map<std::string, std::shared_ptr<IAsyncEventEmitter>> eventEmitterMap_;
|
|
93
|
+
|
|
94
|
+
using ArgFactory = std::function<void(jsi::Runtime &runtime, std::vector<jsi::Value> &args)>;
|
|
102
95
|
|
|
103
96
|
/**
|
|
104
97
|
* Calls RCTDeviceEventEmitter.emit to JavaScript, with given event name and
|
|
@@ -112,35 +105,31 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
112
105
|
* args.emplace_back(jsi::Value(42));
|
|
113
106
|
* });
|
|
114
107
|
*/
|
|
115
|
-
void emitDeviceEvent(
|
|
116
|
-
const std::string& eventName,
|
|
117
|
-
ArgFactory&& argFactory = nullptr);
|
|
108
|
+
void emitDeviceEvent(const std::string &eventName, ArgFactory &&argFactory = nullptr);
|
|
118
109
|
|
|
119
110
|
// Backwards compatibility version
|
|
120
111
|
void emitDeviceEvent(
|
|
121
|
-
jsi::Runtime& /*runtime*/,
|
|
112
|
+
jsi::Runtime & /*runtime*/,
|
|
122
113
|
|
|
123
|
-
const std::string&
|
|
124
|
-
ArgFactory&&
|
|
114
|
+
const std::string &eventName,
|
|
115
|
+
ArgFactory &&argFactory = nullptr)
|
|
116
|
+
{
|
|
125
117
|
emitDeviceEvent(eventName, std::move(argFactory));
|
|
126
118
|
}
|
|
127
119
|
|
|
128
|
-
virtual jsi::Value create(
|
|
129
|
-
|
|
130
|
-
const jsi::PropNameID& propName) {
|
|
120
|
+
virtual jsi::Value create(jsi::Runtime &runtime, const jsi::PropNameID &propName)
|
|
121
|
+
{
|
|
131
122
|
std::string propNameUtf8 = propName.utf8(runtime);
|
|
132
|
-
if (auto methodIter = methodMap_.find(propNameUtf8);
|
|
133
|
-
|
|
134
|
-
const MethodMetadata& meta = methodIter->second;
|
|
123
|
+
if (auto methodIter = methodMap_.find(propNameUtf8); methodIter != methodMap_.end()) {
|
|
124
|
+
const MethodMetadata &meta = methodIter->second;
|
|
135
125
|
return jsi::Function::createFromHostFunction(
|
|
136
126
|
runtime,
|
|
137
127
|
propName,
|
|
138
128
|
static_cast<unsigned int>(meta.argCount),
|
|
139
129
|
[this, meta](
|
|
140
|
-
jsi::Runtime&
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
size_t count) { return meta.invoker(rt, *this, args, count); });
|
|
130
|
+
jsi::Runtime &rt, [[maybe_unused]] const jsi::Value &thisVal, const jsi::Value *args, size_t count) {
|
|
131
|
+
return meta.invoker(rt, *this, args, count);
|
|
132
|
+
});
|
|
144
133
|
} else if (auto eventEmitterIter = eventEmitterMap_.find(propNameUtf8);
|
|
145
134
|
eventEmitterIter != eventEmitterMap_.end()) {
|
|
146
135
|
return eventEmitterIter->second->get(runtime, jsInvoker_);
|
|
@@ -159,7 +148,6 @@ class JSI_EXPORT TurboModule : public jsi::HostObject {
|
|
|
159
148
|
* An app/platform-specific provider function to get an instance of a module
|
|
160
149
|
* given a name.
|
|
161
150
|
*/
|
|
162
|
-
using TurboModuleProviderFunctionType =
|
|
163
|
-
std::function<std::shared_ptr<TurboModule>(const std::string& name)>;
|
|
151
|
+
using TurboModuleProviderFunctionType = std::function<std::shared_ptr<TurboModule>(const std::string &name)>;
|
|
164
152
|
|
|
165
153
|
} // namespace facebook::react
|
|
@@ -16,19 +16,16 @@
|
|
|
16
16
|
namespace facebook::react {
|
|
17
17
|
|
|
18
18
|
struct Promise : public LongLivedObject {
|
|
19
|
-
Promise(jsi::Runtime&
|
|
19
|
+
Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
|
|
20
20
|
|
|
21
|
-
void resolve(const jsi::Value&
|
|
22
|
-
void reject(const std::string&
|
|
21
|
+
void resolve(const jsi::Value &result);
|
|
22
|
+
void reject(const std::string &message);
|
|
23
23
|
|
|
24
24
|
jsi::Function resolve_;
|
|
25
25
|
jsi::Function reject_;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
using PromiseSetupFunctionType =
|
|
29
|
-
|
|
30
|
-
jsi::Value createPromiseAsJSIValue(
|
|
31
|
-
jsi::Runtime& rt,
|
|
32
|
-
PromiseSetupFunctionType&& func);
|
|
28
|
+
using PromiseSetupFunctionType = std::function<void(jsi::Runtime &rt, std::shared_ptr<Promise>)>;
|
|
29
|
+
jsi::Value createPromiseAsJSIValue(jsi::Runtime &rt, PromiseSetupFunctionType &&func);
|
|
33
30
|
|
|
34
31
|
} // namespace facebook::react
|
|
@@ -16,25 +16,27 @@ namespace facebook::react {
|
|
|
16
16
|
|
|
17
17
|
template <>
|
|
18
18
|
struct Bridging<std::string> {
|
|
19
|
-
static std::string fromJs(jsi::Runtime&
|
|
19
|
+
static std::string fromJs(jsi::Runtime &rt, const jsi::String &value)
|
|
20
|
+
{
|
|
20
21
|
return value.utf8(rt);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
static jsi::String toJs(jsi::Runtime&
|
|
24
|
+
static jsi::String toJs(jsi::Runtime &rt, const std::string &value)
|
|
25
|
+
{
|
|
24
26
|
return jsi::String::createFromUtf8(rt, value);
|
|
25
27
|
}
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
template <>
|
|
29
31
|
struct Bridging<std::string_view> {
|
|
30
|
-
static jsi::String toJs(jsi::Runtime&
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
static jsi::String toJs(jsi::Runtime &rt, std::string_view value)
|
|
33
|
+
{
|
|
34
|
+
return jsi::String::createFromUtf8(rt, reinterpret_cast<const uint8_t *>(value.data()), value.length());
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
37
|
|
|
36
38
|
template <>
|
|
37
|
-
struct Bridging<const char*> : Bridging<std::string_view> {};
|
|
39
|
+
struct Bridging<const char *> : Bridging<std::string_view> {};
|
|
38
40
|
|
|
39
41
|
template <size_t N>
|
|
40
42
|
struct Bridging<char[N]> : Bridging<std::string_view> {};
|
|
@@ -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
|
};
|