@depup/react-native-worklets 0.12.2-depup.0 → 0.13.0-depup.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/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +1 -2
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +1 -1
- package/Common/cpp/worklets/Compat/StableApi.cpp +24 -8
- package/Common/cpp/worklets/Compat/StableApi.h +1 -1
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +113 -50
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +10 -1
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +95 -37
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +57 -7
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.cpp +94 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.h +58 -0
- package/Common/cpp/worklets/Networking/Networking.cpp +283 -0
- package/Common/cpp/worklets/Networking/Networking.h +51 -0
- package/Common/cpp/worklets/Networking/NetworkingBackend.h +47 -0
- package/Common/cpp/worklets/Networking/NetworkingInstaller.cpp +127 -0
- package/Common/cpp/worklets/Networking/NetworkingInstaller.h +19 -0
- package/Common/cpp/worklets/Networking/NetworkingTypes.h +33 -0
- package/Common/cpp/worklets/Networking/TextDecoding.cpp +189 -0
- package/Common/cpp/worklets/Networking/TextDecoding.h +29 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueue.h +28 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +9 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +6 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.cpp +19 -4
- package/Common/cpp/worklets/RunLoop/EventLoop.h +3 -0
- package/Common/cpp/worklets/SharedItems/MemoryManager.cpp +1 -1
- package/Common/cpp/worklets/SharedItems/MemoryManager.h +2 -1
- package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.cpp +37 -0
- package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.h +33 -0
- package/Common/cpp/worklets/SharedItems/Serializable/RetainingSerializable.h +112 -0
- package/Common/cpp/worklets/SharedItems/Serializable/Serializable.cpp +129 -0
- package/Common/cpp/worklets/SharedItems/Serializable/Serializable.h +121 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.cpp +38 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.h +39 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.cpp +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.h +43 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.cpp +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.h +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.cpp +38 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.h +30 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.cpp +24 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.h +32 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.cpp +19 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.cpp +29 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.cpp +44 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.cpp +80 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.h +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.cpp +22 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.h +25 -0
- package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.cpp → Serializable/SerializableRemoteFunction.cpp} +30 -2
- package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.h → Serializable/SerializableRemoteFunction.h} +24 -10
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.cpp +46 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.h +41 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.cpp +36 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.h +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.cpp +19 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.h +22 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.cpp +26 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.h +33 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.cpp +31 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.h +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable.h +21 -409
- package/Common/cpp/worklets/SharedItems/Shareable.cpp +1 -1
- package/Common/cpp/worklets/SharedItems/Shareable.h +1 -1
- package/Common/cpp/worklets/SharedItems/Synchronizable.h +43 -20
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +24 -26
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +5 -7
- package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.cpp +36 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.h +27 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableFixed.cpp +76 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableFixed.h +48 -0
- package/Common/cpp/worklets/Tools/ScriptBuffer.h +0 -5
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +16 -30
- package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +27 -30
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +4 -3
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +2 -1
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +79 -29
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +34 -19
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +13 -86
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +1 -7
- package/Package.swift +147 -0
- package/README.md +5 -5
- package/RNWorklets.podspec +1 -2
- package/android/CMakeLists.txt +7 -26
- package/android/build.gradle.kts +5 -31
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +46 -129
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +21 -11
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +2 -4
- package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.cpp +82 -0
- package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.h +32 -0
- package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.cpp +73 -0
- package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.h +38 -0
- package/android/src/{no-networking → main/java}/com/swmansion/worklets/WorkletsModule.kt +39 -28
- package/android/src/main/java/com/swmansion/worklets/networking/NetworkRequestListener.kt +37 -0
- package/android/src/main/java/com/swmansion/worklets/networking/Networking.kt +244 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.kt +3 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +9 -1
- package/apple/worklets/apple/AssertJavaScriptQueue.h +3 -2
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +4 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +3 -0
- package/apple/worklets/apple/Networking/AppleNetworkingBackend.h +29 -0
- package/apple/worklets/apple/Networking/AppleNetworkingBackend.mm +93 -0
- package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.h +37 -0
- package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.mm +447 -0
- package/apple/worklets/apple/WorkletsModule.h +3 -2
- package/apple/worklets/apple/WorkletsModule.mm +82 -74
- package/bundleMode/index.js +10 -47
- package/bundleMode/polyfills/prepareBundleMode.js +16 -0
- package/changes.json +4 -4
- package/compatibility.json +4 -1
- package/lib/module/WorkletsModule/NativeWorklets.native.js +12 -9
- package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
- package/lib/module/debug/jsVersion.js +1 -1
- package/lib/module/featureFlags/staticFlags.json +0 -1
- package/lib/module/featureFlags/types.js +0 -1
- package/lib/module/featureFlags/types.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/initializers/initializers.native.js +5 -12
- package/lib/module/initializers/initializers.native.js.map +1 -1
- package/lib/module/memory/bundleUnpacker.native.js +2 -10
- package/lib/module/memory/bundleUnpacker.native.js.map +1 -1
- package/lib/module/memory/serializable.native.js +1 -29
- package/lib/module/memory/serializable.native.js.map +1 -1
- package/lib/module/memory/synchronizable.js +1 -1
- package/lib/module/memory/synchronizable.js.map +1 -1
- package/lib/module/memory/synchronizable.native.js +7 -3
- package/lib/module/memory/synchronizable.native.js.map +1 -1
- package/lib/module/memory/synchronizableUnpacker.native.js +7 -2
- package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -1
- package/lib/module/memory/valueUnpacker.native.js +0 -8
- package/lib/module/memory/valueUnpacker.native.js.map +1 -1
- package/lib/module/mock.js +22 -1
- package/lib/module/mock.js.map +1 -1
- package/lib/module/networking/AbortController.js +43 -0
- package/lib/module/networking/AbortController.js.map +1 -0
- package/lib/module/networking/Blob.js +60 -0
- package/lib/module/networking/Blob.js.map +1 -0
- package/lib/module/networking/DOMException.js +35 -0
- package/lib/module/networking/DOMException.js.map +1 -0
- package/lib/module/networking/FileReader.js +83 -0
- package/lib/module/networking/FileReader.js.map +1 -0
- package/lib/module/networking/FormData.js +105 -0
- package/lib/module/networking/FormData.js.map +1 -0
- package/lib/module/networking/XMLHttpRequest.js +450 -0
- package/lib/module/networking/XMLHttpRequest.js.map +1 -0
- package/lib/module/networking/bytes.js +6 -0
- package/lib/module/networking/bytes.js.map +1 -0
- package/lib/module/networking/events.js +44 -0
- package/lib/module/networking/events.js.map +1 -0
- package/lib/module/networking/http.js +100 -0
- package/lib/module/networking/http.js.map +1 -0
- package/lib/module/networking/install.js +37 -0
- package/lib/module/networking/install.js.map +1 -0
- package/lib/module/networking/utf8.js +99 -0
- package/lib/module/networking/utf8.js.map +1 -0
- package/lib/module/privateGlobals.d.js +0 -1
- package/lib/module/privateGlobals.d.js.map +1 -1
- package/lib/module/runLoop/common/queueMicrotaskPolyfill.js +9 -0
- package/lib/module/runLoop/common/queueMicrotaskPolyfill.js.map +1 -0
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +7 -3
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/index.js +1 -1
- package/lib/module/runLoop/workletRuntime/index.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +1 -1
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/taskQueue.js +0 -13
- package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -1
- package/lib/module/runtimes.native.js +8 -1
- package/lib/module/runtimes.native.js.map +1 -1
- package/lib/module/specs/NativeWorkletsModule.js.map +1 -1
- package/lib/module/threads.js +11 -0
- package/lib/module/threads.js.map +1 -1
- package/lib/module/threads.native.js +35 -42
- package/lib/module/threads.native.js.map +1 -1
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +6 -5
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
- package/lib/typescript/debug/jsVersion.d.ts +1 -1
- package/lib/typescript/featureFlags/types.d.ts +0 -1
- package/lib/typescript/featureFlags/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/memory/serializable.native.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizable.d.ts +6 -2
- package/lib/typescript/memory/synchronizable.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizable.native.d.ts +6 -2
- package/lib/typescript/memory/synchronizable.native.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts +1 -1
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/memory/types.d.ts +6 -0
- package/lib/typescript/memory/types.d.ts.map +1 -1
- package/lib/typescript/memory/valueUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/networking/AbortController.d.ts +16 -0
- package/lib/typescript/networking/AbortController.d.ts.map +1 -0
- package/lib/typescript/networking/Blob.d.ts +16 -0
- package/lib/typescript/networking/Blob.d.ts.map +1 -0
- package/lib/typescript/networking/DOMException.d.ts +5 -0
- package/lib/typescript/networking/DOMException.d.ts.map +1 -0
- package/lib/typescript/networking/FileReader.d.ts +19 -0
- package/lib/typescript/networking/FileReader.d.ts.map +1 -0
- package/lib/typescript/networking/FormData.d.ts +30 -0
- package/lib/typescript/networking/FormData.d.ts.map +1 -0
- package/lib/typescript/networking/XMLHttpRequest.d.ts +77 -0
- package/lib/typescript/networking/XMLHttpRequest.d.ts.map +1 -0
- package/lib/typescript/networking/bytes.d.ts +2 -0
- package/lib/typescript/networking/bytes.d.ts.map +1 -0
- package/lib/typescript/networking/events.d.ts +18 -0
- package/lib/typescript/networking/events.d.ts.map +1 -0
- package/lib/typescript/networking/http.d.ts +14 -0
- package/lib/typescript/networking/http.d.ts.map +1 -0
- package/lib/typescript/networking/install.d.ts +2 -0
- package/lib/typescript/networking/install.d.ts.map +1 -0
- package/lib/typescript/networking/utf8.d.ts +4 -0
- package/lib/typescript/networking/utf8.d.ts.map +1 -0
- package/lib/typescript/runLoop/{workletRuntime/queueMicrotask.d.ts → common/queueMicrotaskPolyfill.d.ts} +1 -1
- package/lib/typescript/runLoop/common/queueMicrotaskPolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -1
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +0 -2
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -1
- package/lib/typescript/runtimes.native.d.ts.map +1 -1
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -1
- package/lib/typescript/threads.d.ts +8 -0
- package/lib/typescript/threads.d.ts.map +1 -1
- package/lib/typescript/threads.native.d.ts +8 -1
- package/lib/typescript/threads.native.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +9 -5
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +32 -18
- package/plugin/index.js +63 -93
- package/plugin-oxc/babel.d.ts +7 -0
- package/plugin-oxc/babel.js +200 -0
- package/plugin-oxc/index.d.ts +33 -0
- package/plugin-oxc/index.js +36 -0
- package/plugin-oxc/worklets-oxc-plugin.darwin-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.darwin-x64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.linux-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.linux-x64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.win32-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.win32-x64.node +0 -0
- package/react-native.config.js +5 -0
- package/scripts/worklets_utils.rb +0 -10
- package/src/WorkletsModule/NativeWorklets.native.ts +26 -9
- package/src/WorkletsModule/workletsModuleProxy.ts +15 -5
- package/src/debug/jsVersion.ts +1 -1
- package/src/featureFlags/staticFlags.json +0 -1
- package/src/featureFlags/types.ts +0 -1
- package/src/index.ts +3 -0
- package/src/initializers/initializers.native.ts +5 -13
- package/src/memory/bundleUnpacker.native.ts +6 -13
- package/src/memory/serializable.native.ts +1 -44
- package/src/memory/synchronizable.native.ts +38 -4
- package/src/memory/synchronizable.ts +22 -2
- package/src/memory/synchronizableUnpacker.native.ts +23 -4
- package/src/memory/types.ts +9 -0
- package/src/memory/valueUnpacker.native.ts +0 -8
- package/src/mock.ts +28 -1
- package/src/networking/AbortController.ts +57 -0
- package/src/networking/Blob.ts +74 -0
- package/src/networking/DOMException.ts +37 -0
- package/src/networking/FileReader.ts +99 -0
- package/src/networking/FormData.ts +135 -0
- package/src/networking/XMLHttpRequest.ts +557 -0
- package/src/networking/bytes.ts +8 -0
- package/src/networking/events.ts +61 -0
- package/src/networking/http.ts +173 -0
- package/src/networking/install.ts +38 -0
- package/src/networking/utf8.ts +122 -0
- package/src/privateGlobals.d.ts +20 -13
- package/src/runLoop/common/queueMicrotaskPolyfill.ts +12 -0
- package/src/runLoop/uiRuntime/requestAnimationFrame.ts +7 -4
- package/src/runLoop/workletRuntime/index.ts +1 -1
- package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +1 -1
- package/src/runLoop/workletRuntime/taskQueue.ts +0 -15
- package/src/runtimes.native.ts +10 -1
- package/src/specs/NativeWorkletsModule.ts +1 -0
- package/src/threads.native.ts +49 -54
- package/src/threads.ts +11 -0
- package/src/types.ts +9 -5
- package/Common/cpp/worklets/SharedItems/Serializable.cpp +0 -389
- package/Common/cpp/worklets/SharedItems/SerializableFactory.cpp +0 -172
- package/Common/cpp/worklets/SharedItems/SerializableFactory.h +0 -85
- package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +0 -59
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +0 -51
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +0 -43
- package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +0 -27
- package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +0 -30
- package/android/src/networking/com/swmansion/worklets/WorkletsModule.kt +0 -204
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +0 -272
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +0 -1124
- package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +0 -40
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +0 -13
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +0 -98
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +0 -60
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +0 -87
- package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +0 -181
- package/apple/worklets/apple/Networking/WorkletsNetworking.h +0 -25
- package/apple/worklets/apple/Networking/WorkletsNetworking.mm +0 -707
- package/bundleMode/shims/turboModuleRegistryShim.js +0 -47
- package/lib/module/bundleMode/network.native.js +0 -44
- package/lib/module/bundleMode/network.native.js.map +0 -1
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js +0 -11
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +0 -1
- package/lib/typescript/bundleMode/network.native.d.ts +0 -7
- package/lib/typescript/bundleMode/network.native.d.ts.map +0 -1
- package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +0 -1
- package/src/bundleMode/network.native.ts +0 -63
- package/src/runLoop/workletRuntime/queueMicrotask.ts +0 -13
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
class SerializableHostFunction : public Serializable {
|
|
11
|
+
public:
|
|
12
|
+
SerializableHostFunction(
|
|
13
|
+
const facebook::jsi::HostFunctionType &function,
|
|
14
|
+
const std::string &name,
|
|
15
|
+
unsigned int paramCount)
|
|
16
|
+
: Serializable(ValueType::HostFunctionType), hostFunction_(function), name_(name), paramCount_(paramCount) {}
|
|
17
|
+
|
|
18
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
19
|
+
|
|
20
|
+
protected:
|
|
21
|
+
const facebook::jsi::HostFunctionType hostFunction_;
|
|
22
|
+
const std::string name_;
|
|
23
|
+
const unsigned int paramCount_;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
facebook::jsi::Value makeSerializableHostFunction(
|
|
27
|
+
facebook::jsi::Runtime &rt,
|
|
28
|
+
const facebook::jsi::HostFunctionType &function,
|
|
29
|
+
const std::string &name,
|
|
30
|
+
unsigned int paramCount);
|
|
31
|
+
|
|
32
|
+
} // namespace worklets
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableHostObject.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
jsi::Value SerializableHostObject::toJSValue(jsi::Runtime &rt) {
|
|
11
|
+
return jsi::Object::createFromHostObject(rt, hostObject_);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
jsi::Value makeSerializableHostObject(jsi::Runtime &rt, const std::shared_ptr<jsi::HostObject> &value) {
|
|
15
|
+
const auto serializable = std::make_shared<SerializableHostObject>(rt, value);
|
|
16
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
} // namespace worklets
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
class SerializableHostObject : public Serializable {
|
|
11
|
+
public:
|
|
12
|
+
SerializableHostObject(facebook::jsi::Runtime &, const std::shared_ptr<facebook::jsi::HostObject> &hostObject)
|
|
13
|
+
: Serializable(ValueType::HostObjectType), hostObject_(hostObject) {}
|
|
14
|
+
|
|
15
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
16
|
+
|
|
17
|
+
protected:
|
|
18
|
+
const std::shared_ptr<facebook::jsi::HostObject> hostObject_;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
facebook::jsi::Value makeSerializableHostObject(
|
|
22
|
+
facebook::jsi::Runtime &rt,
|
|
23
|
+
const std::shared_ptr<facebook::jsi::HostObject> &value);
|
|
24
|
+
|
|
25
|
+
} // namespace worklets
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableImport.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
jsi::Value SerializableImport::toJSValue(jsi::Runtime &rt) {
|
|
11
|
+
/**
|
|
12
|
+
* The only way to obtain a module in runtime is to use the Metro's require
|
|
13
|
+
* method implementation, which is injected into the global object as `__r`.
|
|
14
|
+
*/
|
|
15
|
+
const auto metroRequire = rt.global().getProperty(rt, "__r");
|
|
16
|
+
if (metroRequire.isUndefined()) {
|
|
17
|
+
return jsi::Value::undefined();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const auto imported = jsi::String::createFromUtf8(rt, imported_);
|
|
21
|
+
return metroRequire.asObject(rt).asFunction(rt).call(rt, source_).asObject(rt).getProperty(rt, imported);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
jsi::Value makeSerializableImport(jsi::Runtime &rt, const double source, const jsi::String &imported) {
|
|
25
|
+
auto serializable = std::make_shared<SerializableImport>(rt, source, imported);
|
|
26
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
} // namespace worklets
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
class SerializableImport : public Serializable {
|
|
11
|
+
public:
|
|
12
|
+
SerializableImport(facebook::jsi::Runtime &rt, const double source, const facebook::jsi::String &imported)
|
|
13
|
+
: Serializable(ValueType::ImportType), source_(source), imported_(imported.utf8(rt)) {}
|
|
14
|
+
|
|
15
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
16
|
+
|
|
17
|
+
protected:
|
|
18
|
+
const double source_;
|
|
19
|
+
const std::string imported_;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
facebook::jsi::Value
|
|
23
|
+
makeSerializableImport(facebook::jsi::Runtime &rt, double source, const facebook::jsi::String &imported);
|
|
24
|
+
|
|
25
|
+
} // namespace worklets
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <react/debug/react_native_assert.h>
|
|
3
|
+
#include <worklets/SharedItems/Serializable/SerializableMap.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <utility>
|
|
7
|
+
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
SerializableMap::SerializableMap(jsi::Runtime &rt, const jsi::Array &keys, const jsi::Array &values)
|
|
13
|
+
: Serializable(ValueType::MapType) {
|
|
14
|
+
auto size = keys.size(rt);
|
|
15
|
+
react_native_assert(size == values.size(rt) && "Keys and values arrays must have the same size.");
|
|
16
|
+
data_.reserve(size);
|
|
17
|
+
for (size_t i = 0; i < size; i++) {
|
|
18
|
+
auto key = extractSerializableOrThrow(rt, keys.getValueAtIndex(rt, i));
|
|
19
|
+
auto value = extractSerializableOrThrow(rt, values.getValueAtIndex(rt, i));
|
|
20
|
+
data_.emplace_back(key, value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
jsi::Value SerializableMap::toJSValue(jsi::Runtime &rt) {
|
|
25
|
+
const auto keyValues = jsi::Array(rt, data_.size());
|
|
26
|
+
for (size_t i = 0, size = data_.size(); i < size; i++) {
|
|
27
|
+
const auto pair = jsi::Array(rt, 2);
|
|
28
|
+
pair.setValueAtIndex(rt, 0, data_[i].first->toJSValue(rt));
|
|
29
|
+
pair.setValueAtIndex(rt, 1, data_[i].second->toJSValue(rt));
|
|
30
|
+
keyValues.setValueAtIndex(rt, i, std::move(pair));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const auto &global = rt.global();
|
|
34
|
+
auto map = global.getPropertyAsFunction(rt, "Map").callAsConstructor(rt, std::move(keyValues));
|
|
35
|
+
|
|
36
|
+
return map;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
jsi::Value makeSerializableMap(jsi::Runtime &rt, const jsi::Array &keys, const jsi::Array &values) {
|
|
40
|
+
auto serializable = std::make_shared<SerializableMap>(rt, keys, values);
|
|
41
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace worklets
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
class SerializableMap : public Serializable {
|
|
13
|
+
public:
|
|
14
|
+
SerializableMap(facebook::jsi::Runtime &rt, const facebook::jsi::Array &keys, const facebook::jsi::Array &values);
|
|
15
|
+
|
|
16
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
17
|
+
|
|
18
|
+
protected:
|
|
19
|
+
std::vector<std::pair<std::shared_ptr<Serializable>, std::shared_ptr<Serializable>>> data_;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
facebook::jsi::Value
|
|
23
|
+
makeSerializableMap(facebook::jsi::Runtime &rt, const facebook::jsi::Array &keys, const facebook::jsi::Array &values);
|
|
24
|
+
|
|
25
|
+
} // namespace worklets
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/RetainingSerializable.h>
|
|
3
|
+
#include <worklets/SharedItems/Serializable/SerializableObject.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <utility>
|
|
8
|
+
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
namespace worklets {
|
|
12
|
+
|
|
13
|
+
namespace {
|
|
14
|
+
|
|
15
|
+
void defineOwnDataProperty(jsi::Runtime &rt, const jsi::Object &target, const std::string &key, jsi::Value value) {
|
|
16
|
+
jsi::Object descriptor(rt);
|
|
17
|
+
descriptor.setProperty(rt, "configurable", true);
|
|
18
|
+
descriptor.setProperty(rt, "enumerable", true);
|
|
19
|
+
descriptor.setProperty(rt, "writable", true);
|
|
20
|
+
descriptor.setProperty(rt, "value", std::move(value));
|
|
21
|
+
|
|
22
|
+
const auto objectCtor = rt.global().getPropertyAsObject(rt, "Object");
|
|
23
|
+
const auto defineProperty = objectCtor.getPropertyAsFunction(rt, "defineProperty");
|
|
24
|
+
defineProperty.call(rt, jsi::Value(rt, target), jsi::String::createFromUtf8(rt, key), std::move(descriptor));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
} // namespace
|
|
28
|
+
|
|
29
|
+
SerializableObject::SerializableObject(jsi::Runtime &rt, const jsi::Object &object)
|
|
30
|
+
: Serializable(ValueType::ObjectType) {
|
|
31
|
+
auto propertyNames = object.getPropertyNames(rt);
|
|
32
|
+
auto size = propertyNames.size(rt);
|
|
33
|
+
data_.reserve(size);
|
|
34
|
+
for (size_t i = 0; i < size; i++) {
|
|
35
|
+
auto key = propertyNames.getValueAtIndex(rt, i).asString(rt);
|
|
36
|
+
auto value = extractSerializableOrThrow(rt, object.getProperty(rt, key));
|
|
37
|
+
data_.emplace_back(key.utf8(rt), value);
|
|
38
|
+
}
|
|
39
|
+
if (object.hasNativeState(rt)) {
|
|
40
|
+
nativeState_ = object.getNativeState(rt);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
SerializableObject::SerializableObject(jsi::Runtime &rt, const jsi::Object &object, const jsi::Value &nativeStateSource)
|
|
45
|
+
: SerializableObject(rt, object) {
|
|
46
|
+
if (nativeStateSource.isObject() && nativeStateSource.asObject(rt).hasNativeState(rt)) {
|
|
47
|
+
nativeState_ = nativeStateSource.asObject(rt).getNativeState(rt);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
jsi::Value SerializableObject::toJSValue(jsi::Runtime &rt) {
|
|
52
|
+
auto obj = jsi::Object(rt);
|
|
53
|
+
for (const auto &i : data_) {
|
|
54
|
+
if (i.first == "__proto__") [[unlikely]] {
|
|
55
|
+
defineOwnDataProperty(rt, obj, i.first, i.second->toJSValue(rt));
|
|
56
|
+
} else {
|
|
57
|
+
obj.setProperty(rt, jsi::String::createFromUtf8(rt, i.first), i.second->toJSValue(rt));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (nativeState_ != nullptr) {
|
|
61
|
+
obj.setNativeState(rt, nativeState_);
|
|
62
|
+
}
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
jsi::Value makeSerializableObject(
|
|
67
|
+
jsi::Runtime &rt,
|
|
68
|
+
jsi::Object object,
|
|
69
|
+
bool shouldRetainRemote,
|
|
70
|
+
const jsi::Value &nativeStateSource) {
|
|
71
|
+
std::shared_ptr<Serializable> serializable;
|
|
72
|
+
if (shouldRetainRemote) {
|
|
73
|
+
serializable = std::make_shared<RetainingSerializable<SerializableObject>>(rt, object, nativeStateSource);
|
|
74
|
+
} else {
|
|
75
|
+
serializable = std::make_shared<SerializableObject>(rt, object, nativeStateSource);
|
|
76
|
+
}
|
|
77
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
} // namespace worklets
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <utility>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
namespace worklets {
|
|
12
|
+
|
|
13
|
+
class SerializableObject : public Serializable {
|
|
14
|
+
public:
|
|
15
|
+
SerializableObject(facebook::jsi::Runtime &rt, const facebook::jsi::Object &object);
|
|
16
|
+
|
|
17
|
+
SerializableObject(
|
|
18
|
+
facebook::jsi::Runtime &rt,
|
|
19
|
+
const facebook::jsi::Object &object,
|
|
20
|
+
const facebook::jsi::Value &nativeStateSource);
|
|
21
|
+
|
|
22
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
23
|
+
|
|
24
|
+
protected:
|
|
25
|
+
std::vector<std::pair<std::string, std::shared_ptr<Serializable>>> data_;
|
|
26
|
+
std::shared_ptr<facebook::jsi::NativeState> nativeState_;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
facebook::jsi::Value makeSerializableObject(
|
|
30
|
+
facebook::jsi::Runtime &rt,
|
|
31
|
+
facebook::jsi::Object object,
|
|
32
|
+
bool shouldRetainRemote,
|
|
33
|
+
const facebook::jsi::Value &nativeStateSource);
|
|
34
|
+
|
|
35
|
+
} // namespace worklets
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableRegExp.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
using namespace facebook;
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
jsi::Value SerializableRegExp::toJSValue(jsi::Runtime &rt) {
|
|
12
|
+
return rt.global()
|
|
13
|
+
.getPropertyAsFunction(rt, "RegExp")
|
|
14
|
+
.callAsConstructor(rt, jsi::String::createFromUtf8(rt, pattern_), jsi::String::createFromUtf8(rt, flags_));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
jsi::Value makeSerializableRegExp(jsi::Runtime &rt, const std::string &pattern, const std::string &flags) {
|
|
18
|
+
auto serializable = std::make_shared<SerializableRegExp>(pattern, flags);
|
|
19
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace worklets
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
class SerializableRegExp : public Serializable {
|
|
11
|
+
public:
|
|
12
|
+
SerializableRegExp(const std::string &pattern, const std::string &flags)
|
|
13
|
+
: Serializable(ValueType::RegExpType), pattern_(pattern), flags_(flags) {}
|
|
14
|
+
|
|
15
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
16
|
+
|
|
17
|
+
protected:
|
|
18
|
+
const std::string pattern_;
|
|
19
|
+
const std::string flags_;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
facebook::jsi::Value
|
|
23
|
+
makeSerializableRegExp(facebook::jsi::Runtime &rt, const std::string &pattern, const std::string &flags);
|
|
24
|
+
|
|
25
|
+
} // namespace worklets
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#include <jsi/jsi.h>
|
|
2
2
|
#include <react/debug/react_native_assert.h>
|
|
3
|
-
#include <worklets/SharedItems/Serializable.h>
|
|
4
|
-
#include <worklets/SharedItems/SerializableRemoteFunction.h>
|
|
3
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/SerializableRemoteFunction.h>
|
|
5
5
|
#include <worklets/WorkletRuntime/RuntimeManager.h>
|
|
6
6
|
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
7
7
|
|
|
@@ -68,4 +68,32 @@ void SerializableRemoteFunction::resolveOrRejectPromise(
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
jsi::Value makeRNRuntimeSerializableRemoteFunction(
|
|
72
|
+
jsi::Runtime &rnRuntime,
|
|
73
|
+
const std::string &name,
|
|
74
|
+
const jsi::Function &function,
|
|
75
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
76
|
+
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus) {
|
|
77
|
+
auto serializable = std::make_shared<SerializableRemoteFunction>(
|
|
78
|
+
rnRuntime,
|
|
79
|
+
name,
|
|
80
|
+
jsi::Value(rnRuntime, function).getObject(rnRuntime).getFunction(rnRuntime),
|
|
81
|
+
jsScheduler,
|
|
82
|
+
rnRuntimeStatus);
|
|
83
|
+
return SerializableJSRef::newNativeStateObject(rnRuntime, serializable);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
jsi::Value makeWorkletRuntimeSerializableRemoteFunction(
|
|
87
|
+
jsi::Runtime &workletRuntime,
|
|
88
|
+
const std::string &name,
|
|
89
|
+
const jsi::Function &function,
|
|
90
|
+
RuntimeData::RuntimeId hostRuntimeId) {
|
|
91
|
+
auto serializable = std::make_shared<SerializableRemoteFunction>(
|
|
92
|
+
workletRuntime,
|
|
93
|
+
name,
|
|
94
|
+
jsi::Value(workletRuntime, function).getObject(workletRuntime).getFunction(workletRuntime),
|
|
95
|
+
hostRuntimeId);
|
|
96
|
+
return SerializableJSRef::newNativeStateObject(workletRuntime, serializable);
|
|
97
|
+
}
|
|
98
|
+
|
|
71
99
|
} // namespace worklets
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
|
-
#include <worklets/SharedItems/Serializable.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
5
|
#include <worklets/Tools/JSScheduler.h>
|
|
6
6
|
#include <worklets/Tools/RNRuntimeStatus.h>
|
|
7
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
7
8
|
|
|
8
9
|
#include <memory>
|
|
9
10
|
#include <string>
|
|
@@ -17,29 +18,29 @@ class SerializableRemoteFunction : public Serializable,
|
|
|
17
18
|
public:
|
|
18
19
|
/** Creates RN Runtime Remote Function. */
|
|
19
20
|
SerializableRemoteFunction(
|
|
20
|
-
jsi::Runtime &rnRuntime,
|
|
21
|
+
facebook::jsi::Runtime &rnRuntime,
|
|
21
22
|
const std::string &name,
|
|
22
|
-
jsi::Function &&function,
|
|
23
|
+
facebook::jsi::Function &&function,
|
|
23
24
|
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
24
25
|
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus)
|
|
25
26
|
: Serializable(ValueType::RemoteFunctionType),
|
|
26
27
|
hostRuntime_(&rnRuntime),
|
|
27
28
|
hostRuntimeId_(RuntimeData::rnRuntimeId),
|
|
28
|
-
function_(std::make_unique<jsi::Value>(rnRuntime, std::move(function))),
|
|
29
|
+
function_(std::make_unique<facebook::jsi::Value>(rnRuntime, std::move(function))),
|
|
29
30
|
name_(name),
|
|
30
31
|
jsScheduler_(jsScheduler),
|
|
31
32
|
rnRuntimeStatus_(rnRuntimeStatus) {}
|
|
32
33
|
|
|
33
34
|
/** Creates Worklet Runtime Remote Function. */
|
|
34
35
|
SerializableRemoteFunction(
|
|
35
|
-
jsi::Runtime &workletRuntime,
|
|
36
|
+
facebook::jsi::Runtime &workletRuntime,
|
|
36
37
|
const std::string &name,
|
|
37
|
-
jsi::Function &&function,
|
|
38
|
+
facebook::jsi::Function &&function,
|
|
38
39
|
RuntimeData::RuntimeId hostRuntimeId)
|
|
39
40
|
: Serializable(ValueType::RemoteFunctionType),
|
|
40
41
|
hostRuntime_(&workletRuntime),
|
|
41
42
|
hostRuntimeId_(hostRuntimeId),
|
|
42
|
-
function_(std::make_unique<jsi::Value>(workletRuntime, std::move(function))),
|
|
43
|
+
function_(std::make_unique<facebook::jsi::Value>(workletRuntime, std::move(function))),
|
|
43
44
|
name_(name),
|
|
44
45
|
jsScheduler_(nullptr),
|
|
45
46
|
rnRuntimeStatus_(nullptr) {}
|
|
@@ -53,7 +54,7 @@ class SerializableRemoteFunction : public Serializable,
|
|
|
53
54
|
const std::shared_ptr<Serializable> &resolveValue,
|
|
54
55
|
const std::shared_ptr<RuntimeManager> &runtimeManager);
|
|
55
56
|
|
|
56
|
-
jsi::Value toJSValue(jsi::Runtime &rt) override;
|
|
57
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
57
58
|
|
|
58
59
|
[[nodiscard]] bool isHostedOnRNRuntime() const noexcept {
|
|
59
60
|
return hostRuntimeId_ == RuntimeData::rnRuntimeId;
|
|
@@ -64,12 +65,25 @@ class SerializableRemoteFunction : public Serializable,
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
private:
|
|
67
|
-
jsi::Runtime *hostRuntime_;
|
|
68
|
+
facebook::jsi::Runtime *hostRuntime_;
|
|
68
69
|
const RuntimeData::RuntimeId hostRuntimeId_;
|
|
69
|
-
std::unique_ptr<jsi::Value> function_;
|
|
70
|
+
std::unique_ptr<facebook::jsi::Value> function_;
|
|
70
71
|
const std::string name_;
|
|
71
72
|
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
72
73
|
const std::shared_ptr<RNRuntimeStatus> rnRuntimeStatus_;
|
|
73
74
|
};
|
|
74
75
|
|
|
76
|
+
facebook::jsi::Value makeRNRuntimeSerializableRemoteFunction(
|
|
77
|
+
facebook::jsi::Runtime &rnRuntime,
|
|
78
|
+
const std::string &name,
|
|
79
|
+
const facebook::jsi::Function &function,
|
|
80
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
81
|
+
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus);
|
|
82
|
+
|
|
83
|
+
facebook::jsi::Value makeWorkletRuntimeSerializableRemoteFunction(
|
|
84
|
+
facebook::jsi::Runtime &workletRuntime,
|
|
85
|
+
const std::string &name,
|
|
86
|
+
const facebook::jsi::Function &function,
|
|
87
|
+
RuntimeData::RuntimeId hostRuntimeId);
|
|
88
|
+
|
|
75
89
|
} // namespace worklets
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableScalar.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <stdexcept>
|
|
6
|
+
|
|
7
|
+
using namespace facebook;
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
jsi::Value SerializableScalar::toJSValue(jsi::Runtime &) {
|
|
12
|
+
switch (valueType_) {
|
|
13
|
+
case Serializable::ValueType::UndefinedType:
|
|
14
|
+
return jsi::Value();
|
|
15
|
+
case Serializable::ValueType::NullType:
|
|
16
|
+
return jsi::Value(nullptr);
|
|
17
|
+
case Serializable::ValueType::BooleanType:
|
|
18
|
+
return jsi::Value(data_.boolean);
|
|
19
|
+
case Serializable::ValueType::NumberType:
|
|
20
|
+
return jsi::Value(data_.number);
|
|
21
|
+
default:
|
|
22
|
+
throw std::runtime_error("[Worklets] Attempted to convert object that's not of a scalar type.");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
jsi::Value makeSerializableNumber(jsi::Runtime &rt, double number) {
|
|
27
|
+
const auto serializable = std::make_shared<SerializableScalar>(number);
|
|
28
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
jsi::Value makeSerializableBoolean(jsi::Runtime &rt, bool boolean) {
|
|
32
|
+
const auto serializable = std::make_shared<SerializableScalar>(boolean);
|
|
33
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
jsi::Value makeSerializableUndefined(jsi::Runtime &rt) {
|
|
37
|
+
const auto serializable = std::make_shared<SerializableScalar>();
|
|
38
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
jsi::Value makeSerializableNull(jsi::Runtime &rt) {
|
|
42
|
+
const auto serializable = std::make_shared<SerializableScalar>(nullptr);
|
|
43
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
} // namespace worklets
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
class SerializableScalar : public Serializable {
|
|
11
|
+
public:
|
|
12
|
+
explicit SerializableScalar(double number) : Serializable(ValueType::NumberType) {
|
|
13
|
+
data_.number = number;
|
|
14
|
+
}
|
|
15
|
+
explicit SerializableScalar(bool boolean) : Serializable(ValueType::BooleanType) {
|
|
16
|
+
data_.boolean = boolean;
|
|
17
|
+
}
|
|
18
|
+
SerializableScalar() : Serializable(ValueType::UndefinedType) {}
|
|
19
|
+
explicit SerializableScalar(std::nullptr_t) : Serializable(ValueType::NullType) {}
|
|
20
|
+
|
|
21
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &) override;
|
|
22
|
+
|
|
23
|
+
protected:
|
|
24
|
+
union Data {
|
|
25
|
+
bool boolean;
|
|
26
|
+
double number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
Data data_;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
facebook::jsi::Value makeSerializableNumber(facebook::jsi::Runtime &rt, double number);
|
|
34
|
+
|
|
35
|
+
facebook::jsi::Value makeSerializableBoolean(facebook::jsi::Runtime &rt, bool boolean);
|
|
36
|
+
|
|
37
|
+
facebook::jsi::Value makeSerializableUndefined(facebook::jsi::Runtime &rt);
|
|
38
|
+
|
|
39
|
+
facebook::jsi::Value makeSerializableNull(facebook::jsi::Runtime &rt);
|
|
40
|
+
|
|
41
|
+
} // namespace worklets
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableSet.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <utility>
|
|
6
|
+
|
|
7
|
+
using namespace facebook;
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
SerializableSet::SerializableSet(jsi::Runtime &rt, const jsi::Array &values) : Serializable(ValueType::SetType) {
|
|
12
|
+
auto size = values.size(rt);
|
|
13
|
+
data_.reserve(size);
|
|
14
|
+
for (size_t i = 0; i < size; i++) {
|
|
15
|
+
data_.push_back(extractSerializableOrThrow(rt, values.getValueAtIndex(rt, i)));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
jsi::Value SerializableSet::toJSValue(jsi::Runtime &rt) {
|
|
20
|
+
const auto values = jsi::Array(rt, data_.size());
|
|
21
|
+
for (size_t i = 0, size = data_.size(); i < size; i++) {
|
|
22
|
+
values.setValueAtIndex(rt, i, data_[i]->toJSValue(rt));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const auto &global = rt.global();
|
|
26
|
+
auto set = global.getPropertyAsFunction(rt, "Set").callAsConstructor(rt, std::move(values));
|
|
27
|
+
|
|
28
|
+
return set;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
jsi::Value makeSerializableSet(jsi::Runtime &rt, const jsi::Array &values) {
|
|
32
|
+
auto serializable = std::make_shared<SerializableSet>(rt, values);
|
|
33
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
} // namespace worklets
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
class SerializableSet : public Serializable {
|
|
12
|
+
public:
|
|
13
|
+
SerializableSet(facebook::jsi::Runtime &rt, const facebook::jsi::Array &values);
|
|
14
|
+
|
|
15
|
+
facebook::jsi::Value toJSValue(facebook::jsi::Runtime &rt) override;
|
|
16
|
+
|
|
17
|
+
protected:
|
|
18
|
+
std::vector<std::shared_ptr<Serializable>> data_;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
facebook::jsi::Value makeSerializableSet(facebook::jsi::Runtime &rt, const facebook::jsi::Array &values);
|
|
22
|
+
|
|
23
|
+
} // namespace worklets
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable/SerializableString.h>
|
|
3
|
+
|
|
4
|
+
#include <memory>
|
|
5
|
+
|
|
6
|
+
using namespace facebook;
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
jsi::Value SerializableString::toJSValue(jsi::Runtime &rt) {
|
|
11
|
+
return jsi::String::createFromUtf8(rt, data_);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
jsi::Value makeSerializableString(jsi::Runtime &rt, const jsi::String &string) {
|
|
15
|
+
const auto serializable = std::make_shared<SerializableString>(string.utf8(rt));
|
|
16
|
+
return SerializableJSRef::newNativeStateObject(rt, serializable);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
} // namespace worklets
|