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
|
@@ -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*
|
|
19
|
+
Error(const char *message) : Error(std::string(message)) {}
|
|
20
20
|
|
|
21
|
-
const std::string&
|
|
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&
|
|
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&
|
|
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&
|
|
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&
|
|
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&
|
|
28
|
-
EventSubscription(const EventSubscription&) = delete;
|
|
29
|
-
EventSubscription&
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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&
|
|
56
|
-
IAsyncEventEmitter(const IAsyncEventEmitter&) = delete;
|
|
57
|
-
IAsyncEventEmitter&
|
|
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&
|
|
85
|
-
AsyncEventEmitter(const AsyncEventEmitter&) = delete;
|
|
86
|
-
AsyncEventEmitter&
|
|
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&)
|
|
92
|
+
void emit(std::function<jsi::Value(jsi::Runtime &)> &&converter)
|
|
93
|
+
{
|
|
89
94
|
std::lock_guard<std::mutex> lock(state_->mutex);
|
|
90
|
-
for (auto&
|
|
91
|
-
listener.call([converter](jsi::Runtime&
|
|
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&
|
|
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
|
-
|
|
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
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
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&)
|
|
47
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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&
|
|
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&)
|
|
83
|
-
|
|
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&
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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&
|
|
113
|
+
SyncCallback(const SyncCallback &) = delete;
|
|
114
|
+
SyncCallback &operator=(const SyncCallback &) = delete;
|
|
124
115
|
|
|
125
116
|
// Allow move
|
|
126
|
-
SyncCallback(SyncCallback&& other)
|
|
127
|
-
: wrapper_(std::move(other.wrapper_)) {}
|
|
117
|
+
SyncCallback(SyncCallback &&other) noexcept : wrapper_(std::move(other.wrapper_)) {}
|
|
128
118
|
|
|
129
|
-
SyncCallback&
|
|
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&
|
|
158
|
-
auto&
|
|
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
|
|
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
|
|
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...>
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
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...)>
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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&
|
|
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&
|
|
262
|
-
jsi::Runtime&
|
|
263
|
-
const jsi::Value*
|
|
264
|
-
const std::shared_ptr<CallInvoker
|
|
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
|
-
|
|
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&
|
|
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
|
-
|
|
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&
|
|
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&
|
|
35
|
+
explicit LongLivedObject(jsi::Runtime &runtime) : runtime_(runtime) {}
|
|
36
36
|
virtual ~LongLivedObject() = default;
|
|
37
|
-
jsi::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&
|
|
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*
|
|
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&
|
|
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&
|
|
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&
|
|
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&
|
|
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
|
};
|