@depup/react-native-worklets 0.12.1-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 +7 -7
- 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 +40 -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 +40 -5
- 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 +6 -6
- 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 +3 -31
- 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 +22 -9
- 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 +36 -22
- 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 +6 -46
- package/src/memory/synchronizable.native.ts +38 -4
- package/src/memory/synchronizable.ts +22 -2
- package/src/memory/synchronizableUnpacker.native.ts +38 -13
- 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 -373
- 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 -203
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include <jsi/decorator.h>
|
|
2
2
|
#include <jsi/jsi.h>
|
|
3
3
|
#include <worklets/NativeModules/JSIWorkletsModuleProxy.h>
|
|
4
|
+
#include <worklets/Networking/NetworkingInstaller.h>
|
|
4
5
|
#include <worklets/Tools/JSLogger.h>
|
|
5
6
|
#include <worklets/WorkletRuntime/RuntimeHolder.h>
|
|
6
7
|
#include <worklets/WorkletRuntime/ScriptLoader.h>
|
|
@@ -34,6 +35,7 @@ class AroundLock {
|
|
|
34
35
|
|
|
35
36
|
class LockableRuntime : public jsi::WithRuntimeDecorator<AroundLock> {
|
|
36
37
|
AroundLock aroundLock_;
|
|
38
|
+
const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
|
|
37
39
|
std::shared_ptr<jsi::Runtime> runtime_;
|
|
38
40
|
|
|
39
41
|
public:
|
|
@@ -42,7 +44,13 @@ class LockableRuntime : public jsi::WithRuntimeDecorator<AroundLock> {
|
|
|
42
44
|
const std::shared_ptr<std::recursive_mutex> &runtimeMutex)
|
|
43
45
|
: jsi::WithRuntimeDecorator<AroundLock>(*runtime, aroundLock_),
|
|
44
46
|
aroundLock_(runtimeMutex),
|
|
47
|
+
runtimeMutex_(runtimeMutex),
|
|
45
48
|
runtime_(std::move(runtime)) {}
|
|
49
|
+
|
|
50
|
+
~LockableRuntime() override {
|
|
51
|
+
const std::lock_guard<std::recursive_mutex> lock(*runtimeMutex_);
|
|
52
|
+
runtime_.reset();
|
|
53
|
+
}
|
|
46
54
|
};
|
|
47
55
|
|
|
48
56
|
static std::shared_ptr<jsi::Runtime>
|
|
@@ -62,9 +70,11 @@ WorkletRuntime::WorkletRuntime(
|
|
|
62
70
|
const std::string &name,
|
|
63
71
|
const std::shared_ptr<AsyncQueue> &queue,
|
|
64
72
|
bool enableEventLoop,
|
|
65
|
-
bool enableLocking
|
|
73
|
+
bool enableLocking,
|
|
74
|
+
bool enableNetworking)
|
|
66
75
|
: runtimeId_(runtimeId),
|
|
67
76
|
enableLocking_(enableLocking),
|
|
77
|
+
enableNetworking_(enableNetworking),
|
|
68
78
|
runtimeMutex_(std::make_shared<std::recursive_mutex>()),
|
|
69
79
|
microtaskQueueEnabled_(enableEventLoop || runtimeKind == RuntimeData::RuntimeKind::UI),
|
|
70
80
|
runtime_(makeRuntime(runtimeMutex_, enableLocking_, microtaskQueueEnabled_)),
|
|
@@ -78,11 +88,23 @@ WorkletRuntime::WorkletRuntime(
|
|
|
78
88
|
jsi::Runtime &rt = *runtime_;
|
|
79
89
|
WorkletRuntimeCollector::install(rt);
|
|
80
90
|
if (enableEventLoop) {
|
|
81
|
-
eventLoop_ = std::make_shared<EventLoop>(name_, runtime_, queue_, runtimeMutex_);
|
|
91
|
+
eventLoop_ = std::make_shared<EventLoop>(name_, abortToken(), runtime_, queue_, runtimeMutex_);
|
|
82
92
|
eventLoop_->run();
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
|
|
96
|
+
WorkletRuntime::~WorkletRuntime() {
|
|
97
|
+
auto lock = acquireRuntimeLock();
|
|
98
|
+
if (eventLoop_) {
|
|
99
|
+
eventLoop_->abortPending();
|
|
100
|
+
eventLoop_.reset();
|
|
101
|
+
}
|
|
102
|
+
if (queue_) {
|
|
103
|
+
queue_->abortPending(abortToken());
|
|
104
|
+
queue_.reset();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
86
108
|
void WorkletRuntime::init(const std::shared_ptr<JSIWorkletsModuleProxy> &jsiWorkletsModuleProxy) {
|
|
87
109
|
jsi::Runtime &rt = *runtime_;
|
|
88
110
|
|
|
@@ -99,7 +121,8 @@ void WorkletRuntime::init(const std::shared_ptr<JSIWorkletsModuleProxy> &jsiWork
|
|
|
99
121
|
const auto runtimeBindings = jsiWorkletsModuleProxy->getRuntimeBindings();
|
|
100
122
|
const auto bundleModeEnabled = jsiWorkletsModuleProxy->isBundleModeEnabled();
|
|
101
123
|
const auto unpackerLoader = jsiWorkletsModuleProxy->getUnpackerLoader();
|
|
102
|
-
const auto
|
|
124
|
+
const auto nativeLoggingHook =
|
|
125
|
+
bundleModeEnabled ? runtimeBindings->nativeLoggingHook : RuntimeBindings::NativeLoggingHook{};
|
|
103
126
|
|
|
104
127
|
WorkletRuntimeDecorator::decorate(
|
|
105
128
|
rt,
|
|
@@ -107,12 +130,13 @@ void WorkletRuntime::init(const std::shared_ptr<JSIWorkletsModuleProxy> &jsiWork
|
|
|
107
130
|
name_,
|
|
108
131
|
jsScheduler,
|
|
109
132
|
isDevBundle,
|
|
133
|
+
microtaskQueueEnabled_,
|
|
110
134
|
jsiWorkletsModuleProxy->toOptimizedObject(rt),
|
|
111
135
|
eventLoop_,
|
|
112
136
|
nativeLoggingHook);
|
|
113
137
|
|
|
114
138
|
if (bundleModeEnabled) {
|
|
115
|
-
bundleModeInit(jsScheduler, script, sourceUrl,
|
|
139
|
+
bundleModeInit(jsScheduler, script, sourceUrl, jsiWorkletsModuleProxy->getNetworking());
|
|
116
140
|
} else {
|
|
117
141
|
legacyModeInit(unpackerLoader);
|
|
118
142
|
}
|
|
@@ -128,16 +152,18 @@ void WorkletRuntime::bundleModeInit(
|
|
|
128
152
|
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
129
153
|
const std::shared_ptr<const ScriptBuffer> &script,
|
|
130
154
|
const std::string &sourceUrl,
|
|
131
|
-
const std::shared_ptr<
|
|
155
|
+
const std::shared_ptr<Networking> &networking) {
|
|
132
156
|
jsi::Runtime &rt = *runtime_;
|
|
133
157
|
|
|
134
158
|
if (!script) {
|
|
135
159
|
throw std::runtime_error("[Worklets] Expected to receive the bundle, but got nullptr instead.");
|
|
136
160
|
}
|
|
137
161
|
|
|
138
|
-
|
|
162
|
+
if (networking && enableNetworking_) {
|
|
163
|
+
NetworkingInstaller::install(rt, networking, runtimeId_);
|
|
164
|
+
}
|
|
139
165
|
|
|
140
|
-
|
|
166
|
+
ScriptLoader::loadScript(rt, script, sourceUrl);
|
|
141
167
|
}
|
|
142
168
|
|
|
143
169
|
void WorkletRuntime::legacyModeInit(const std::shared_ptr<UnpackerLoader> &unpackerLoader) {
|
|
@@ -158,15 +184,25 @@ void WorkletRuntime::schedule(std::shared_ptr<SerializableWorklet> worklet) cons
|
|
|
158
184
|
});
|
|
159
185
|
}
|
|
160
186
|
|
|
161
|
-
void WorkletRuntime::schedule(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
187
|
+
void WorkletRuntime::schedule(
|
|
188
|
+
std::shared_ptr<SerializableArray> serializableArrayOfWorklets,
|
|
189
|
+
std::shared_ptr<SerializableArray> serializableArrayOfArguments) const {
|
|
190
|
+
scheduleImpl(
|
|
191
|
+
[serializableArrayOfWorklets = std::move(serializableArrayOfWorklets),
|
|
192
|
+
serializableArrayOfArguments = std::move(serializableArrayOfArguments)](const WorkletRuntime &workletRuntime) {
|
|
193
|
+
workletRuntime.runSyncImpl<MicrotaskCheckpoint::Run>([&](jsi::Runtime &rt) {
|
|
194
|
+
const auto scope = jsi::Scope(rt);
|
|
195
|
+
const auto &worklets = serializableArrayOfWorklets->getList();
|
|
196
|
+
const auto &argumentArrays = serializableArrayOfArguments->getList();
|
|
197
|
+
react_native_assert(worklets.size() == argumentArrays.size());
|
|
198
|
+
for (size_t i = 0; i < worklets.size(); i++) {
|
|
199
|
+
const auto worklet = std::static_pointer_cast<SerializableWorklet>(worklets[i]);
|
|
200
|
+
const auto argumentArray = std::static_pointer_cast<SerializableArray>(argumentArrays[i]);
|
|
201
|
+
const auto args = argumentArray->getJSIValueArr(rt);
|
|
202
|
+
workletRuntime.runSyncImpl(worklet, args.data(), args.size());
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
170
206
|
}
|
|
171
207
|
|
|
172
208
|
#ifndef NDEBUG
|
|
@@ -180,16 +216,28 @@ void WorkletRuntime::scheduleWithStack(
|
|
|
180
216
|
}
|
|
181
217
|
|
|
182
218
|
void WorkletRuntime::scheduleWithStack(
|
|
183
|
-
std::
|
|
219
|
+
std::shared_ptr<SerializableArray> serializableArrayOfWorklets,
|
|
220
|
+
std::shared_ptr<SerializableArray> serializableArrayOfArguments,
|
|
184
221
|
std::vector<std::optional<std::string>> scheduleStacks) const {
|
|
185
|
-
|
|
186
|
-
|
|
222
|
+
const auto batchSize = serializableArrayOfWorklets->getList().size();
|
|
223
|
+
if (scheduleStacks.empty()) {
|
|
224
|
+
scheduleStacks.resize(batchSize);
|
|
225
|
+
}
|
|
226
|
+
react_native_assert(batchSize == scheduleStacks.size());
|
|
227
|
+
scheduleImpl([serializableArrayOfWorklets = std::move(serializableArrayOfWorklets),
|
|
228
|
+
serializableArrayOfArguments = std::move(serializableArrayOfArguments),
|
|
187
229
|
scheduleStacks = std::move(scheduleStacks)](const WorkletRuntime &workletRuntime) {
|
|
188
230
|
workletRuntime.runSyncImpl<MicrotaskCheckpoint::Run>([&](jsi::Runtime &rt) {
|
|
189
231
|
const auto scope = jsi::Scope(rt);
|
|
232
|
+
const auto &worklets = serializableArrayOfWorklets->getList();
|
|
233
|
+
const auto &argumentArrays = serializableArrayOfArguments->getList();
|
|
234
|
+
react_native_assert(worklets.size() == argumentArrays.size());
|
|
190
235
|
for (size_t i = 0; i < worklets.size(); i++) {
|
|
236
|
+
const auto worklet = std::static_pointer_cast<SerializableWorklet>(worklets[i]);
|
|
237
|
+
const auto argumentArray = std::static_pointer_cast<SerializableArray>(argumentArrays[i]);
|
|
238
|
+
const auto args = argumentArray->getJSIValueArr(rt);
|
|
191
239
|
workletRuntime.runSyncImpl<MicrotaskCheckpoint::Skip, jsi::Value, ScheduleStack::Requested>(
|
|
192
|
-
|
|
240
|
+
worklet, scheduleStacks[i], args.data(), args.size());
|
|
193
241
|
}
|
|
194
242
|
});
|
|
195
243
|
});
|
|
@@ -208,15 +256,17 @@ void WorkletRuntime::scheduleImpl(ScheduledJob job) const {
|
|
|
208
256
|
"[Worklets] Tried to invoke `schedule` on a Worklet Runtime but the "
|
|
209
257
|
"async queue is not set. Recreate the runtime with a valid async queue.");
|
|
210
258
|
|
|
211
|
-
queue_->push(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
259
|
+
queue_->push(
|
|
260
|
+
[job = std::move(job), weakThis = weak_from_this()] {
|
|
261
|
+
const auto strongThis = weakThis.lock();
|
|
262
|
+
if (!strongThis) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
auto lock = strongThis->acquireRuntimeLock();
|
|
267
|
+
job(*strongThis);
|
|
268
|
+
},
|
|
269
|
+
abortToken());
|
|
220
270
|
}
|
|
221
271
|
|
|
222
272
|
/* #endregion */
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
#include <worklets/RunLoop/AsyncQueue.h>
|
|
6
6
|
#include <worklets/RunLoop/AsyncQueueImpl.h>
|
|
7
7
|
#include <worklets/RunLoop/EventLoop.h>
|
|
8
|
-
#include <worklets/SharedItems/Serializable.h>
|
|
8
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
9
|
+
#include <worklets/SharedItems/Serializable/SerializableArray.h>
|
|
10
|
+
#include <worklets/SharedItems/Serializable/SerializableWorklet.h>
|
|
9
11
|
#include <worklets/SharedItems/UnpackerLoader.h>
|
|
10
12
|
#include <worklets/Tools/JSLogger.h>
|
|
11
13
|
#include <worklets/Tools/JSScheduler.h>
|
|
12
14
|
#include <worklets/Tools/ScriptBuffer.h>
|
|
13
|
-
#include <worklets/Tools/WorkletsJSIUtils.h>
|
|
14
15
|
#include <worklets/WorkletRuntime/RuntimeBindings.h>
|
|
15
16
|
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
16
17
|
|
|
@@ -28,6 +29,8 @@ namespace worklets {
|
|
|
28
29
|
using namespace facebook;
|
|
29
30
|
using namespace react;
|
|
30
31
|
|
|
32
|
+
class Networking;
|
|
33
|
+
|
|
31
34
|
template <typename TCallable>
|
|
32
35
|
concept RuntimeCallable = std::is_same_v<std::remove_cvref_t<TCallable>, jsi::Function> ||
|
|
33
36
|
std::is_same_v<std::remove_cvref_t<TCallable>, std::shared_ptr<SerializableWorklet>>;
|
|
@@ -76,7 +79,9 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
76
79
|
*
|
|
77
80
|
* Runs a single microtask checkpoint on completion of the batch.
|
|
78
81
|
*/
|
|
79
|
-
void schedule(
|
|
82
|
+
void schedule(
|
|
83
|
+
std::shared_ptr<SerializableArray> serializableArrayOfWorklets,
|
|
84
|
+
std::shared_ptr<SerializableArray> serializableArrayOfArguments) const;
|
|
80
85
|
#ifndef NDEBUG
|
|
81
86
|
/**
|
|
82
87
|
* Schedules a serialized worklet to run asynchronously on the worklet runtime,
|
|
@@ -94,7 +99,8 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
94
99
|
* Runs a single microtask checkpoint on completion of the batch.
|
|
95
100
|
*/
|
|
96
101
|
void scheduleWithStack(
|
|
97
|
-
std::
|
|
102
|
+
std::shared_ptr<SerializableArray> serializableArrayOfWorklets,
|
|
103
|
+
std::shared_ptr<SerializableArray> serializableArrayOfArguments,
|
|
98
104
|
std::vector<std::optional<std::string>> scheduleStacks) const;
|
|
99
105
|
#endif // NDEBUG
|
|
100
106
|
|
|
@@ -120,11 +126,17 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
120
126
|
* Does not run a microtask checkpoint.
|
|
121
127
|
*/
|
|
122
128
|
template <RuntimeCallable TCallable, typename... TArgs>
|
|
123
|
-
auto runSync(const TCallable &callable, TArgs &&...args) const -> jsi::Value {
|
|
129
|
+
[[nodiscard]] auto runSync(const TCallable &callable, TArgs &&...args) const -> jsi::Value {
|
|
124
130
|
auto lock = acquireRuntimeLock();
|
|
125
131
|
return runSyncImpl(callable, std::forward<TArgs>(args)...);
|
|
126
132
|
}
|
|
127
133
|
|
|
134
|
+
template <RuntimeCallable TCallable, typename... TArgs>
|
|
135
|
+
void runSyncAndDiscard(const TCallable &callable, TArgs &&...args) const {
|
|
136
|
+
auto lock = acquireRuntimeLock();
|
|
137
|
+
static_cast<void>(runSyncImpl(callable, std::forward<TArgs>(args)...));
|
|
138
|
+
}
|
|
139
|
+
|
|
128
140
|
/**
|
|
129
141
|
* Runs a jsi::Function or SerializableWorklet synchronously and returns its
|
|
130
142
|
* serialized result.
|
|
@@ -162,7 +174,7 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
162
174
|
* Runs a single microtask checkpoint on completion.
|
|
163
175
|
*/
|
|
164
176
|
template <RuntimeCallable TCallable, typename... TArgs>
|
|
165
|
-
auto runSyncAndDrainMicrotasks(const TCallable &callable, TArgs &&...args) const -> jsi::Value {
|
|
177
|
+
[[nodiscard]] auto runSyncAndDrainMicrotasks(const TCallable &callable, TArgs &&...args) const -> jsi::Value {
|
|
166
178
|
auto lock = acquireRuntimeLock();
|
|
167
179
|
return runSyncImpl<MicrotaskCheckpoint::Run>(callable, std::forward<TArgs>(args)...);
|
|
168
180
|
}
|
|
@@ -246,7 +258,10 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
246
258
|
const std::string &name,
|
|
247
259
|
const std::shared_ptr<AsyncQueue> &queue = nullptr,
|
|
248
260
|
bool enableEventLoop = true,
|
|
249
|
-
bool enableLocking = true
|
|
261
|
+
bool enableLocking = true,
|
|
262
|
+
bool enableNetworking = true);
|
|
263
|
+
|
|
264
|
+
~WorkletRuntime() override;
|
|
250
265
|
|
|
251
266
|
void init(const std::shared_ptr<JSIWorkletsModuleProxy> &jsiWorkletsModuleProxy);
|
|
252
267
|
|
|
@@ -265,7 +280,9 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
265
280
|
*/
|
|
266
281
|
void drainMicrotasks() const {
|
|
267
282
|
auto lock = acquireRuntimeLock();
|
|
268
|
-
|
|
283
|
+
if (microtaskQueueEnabled_) {
|
|
284
|
+
getJSIRuntime().drainMicrotasks();
|
|
285
|
+
}
|
|
269
286
|
}
|
|
270
287
|
|
|
271
288
|
private:
|
|
@@ -375,7 +392,9 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
375
392
|
using Result = std::invoke_result_t<TInvoker>;
|
|
376
393
|
const auto checkpoint = [&]() {
|
|
377
394
|
if constexpr (TCheckpoint == MicrotaskCheckpoint::Run) {
|
|
378
|
-
|
|
395
|
+
if (microtaskQueueEnabled_) {
|
|
396
|
+
getJSIRuntime().drainMicrotasks();
|
|
397
|
+
}
|
|
379
398
|
}
|
|
380
399
|
};
|
|
381
400
|
if constexpr (std::is_void_v<Result>) {
|
|
@@ -388,15 +407,6 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
388
407
|
}
|
|
389
408
|
}
|
|
390
409
|
|
|
391
|
-
/**
|
|
392
|
-
* Assumes the caller acquired the runtime lock.
|
|
393
|
-
*/
|
|
394
|
-
void drainMicrotasksImpl() const {
|
|
395
|
-
if (microtaskQueueEnabled_) {
|
|
396
|
-
jsi_utils::drainMicrotasks(getJSIRuntime());
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
410
|
/**
|
|
401
411
|
* Invokes the provided function, reporting any exception with the scheduling
|
|
402
412
|
* stack carried by the provided stack context in debug builds.
|
|
@@ -427,10 +437,14 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
427
437
|
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
428
438
|
const std::shared_ptr<const ScriptBuffer> &script,
|
|
429
439
|
const std::string &sourceUrl,
|
|
430
|
-
const std::shared_ptr<
|
|
440
|
+
const std::shared_ptr<Networking> &networking);
|
|
431
441
|
|
|
432
442
|
void legacyModeInit(const std::shared_ptr<UnpackerLoader> &unpackerLoader);
|
|
433
443
|
|
|
444
|
+
[[nodiscard]] AbortToken abortToken() const noexcept {
|
|
445
|
+
return static_cast<AbortToken>(runtimeId_);
|
|
446
|
+
}
|
|
447
|
+
|
|
434
448
|
[[nodiscard]] std::unique_lock<std::recursive_mutex> acquireRuntimeLock() const {
|
|
435
449
|
if (enableLocking_) {
|
|
436
450
|
return std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
@@ -440,6 +454,7 @@ class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_th
|
|
|
440
454
|
|
|
441
455
|
const RuntimeData::RuntimeId runtimeId_;
|
|
442
456
|
const bool enableLocking_;
|
|
457
|
+
const bool enableNetworking_;
|
|
443
458
|
const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
|
|
444
459
|
const bool microtaskQueueEnabled_;
|
|
445
460
|
const std::shared_ptr<jsi::Runtime> runtime_;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#include <jsi/jsi.h>
|
|
2
|
-
#include <worklets/SharedItems/Serializable.h>
|
|
3
|
-
#include <worklets/SharedItems/
|
|
2
|
+
#include <worklets/SharedItems/Serializable/Serializable.h>
|
|
3
|
+
#include <worklets/SharedItems/Serializable/SerializableArray.h>
|
|
4
|
+
#include <worklets/SharedItems/Serializable/SerializableBigInt.h>
|
|
5
|
+
#include <worklets/SharedItems/Serializable/SerializableHostObject.h>
|
|
6
|
+
#include <worklets/SharedItems/Serializable/SerializableObject.h>
|
|
7
|
+
#include <worklets/SharedItems/Serializable/SerializableScalar.h>
|
|
8
|
+
#include <worklets/SharedItems/Serializable/SerializableString.h>
|
|
9
|
+
#include <worklets/SharedItems/Serializable/SerializableWorklet.h>
|
|
4
10
|
#include <worklets/Tools/JSISerializer.h>
|
|
5
11
|
#include <worklets/Tools/PlatformLogger.h>
|
|
6
12
|
#include <worklets/Tools/WorkletsJSIUtils.h>
|
|
@@ -56,6 +62,7 @@ void WorkletRuntimeDecorator::decorate(
|
|
|
56
62
|
const std::string &name,
|
|
57
63
|
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
58
64
|
const bool isDevBundle,
|
|
65
|
+
const bool enableMicrotaskQueue,
|
|
59
66
|
jsi::Object &&jsiWorkletsModuleProxy,
|
|
60
67
|
const std::shared_ptr<EventLoop> &eventLoop,
|
|
61
68
|
const RuntimeBindings::NativeLoggingHook &nativeLoggingHook) {
|
|
@@ -175,10 +182,6 @@ void WorkletRuntimeDecorator::decorate(
|
|
|
175
182
|
return makeSerializableWorklet(rt, value.asObject(rt), false);
|
|
176
183
|
});
|
|
177
184
|
|
|
178
|
-
jsi_utils::installJsiFunction(rt, "_createSerializableInitializer", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
179
|
-
return makeSerializableInitializer(rt, value.asObject(rt));
|
|
180
|
-
});
|
|
181
|
-
|
|
182
185
|
jsi_utils::installJsiFunction(rt, "_createSerializableSynchronizable", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
183
186
|
return SerializableJSRef::newNativeStateObject(rt, extractSerializableOrThrow(rt, value));
|
|
184
187
|
});
|
|
@@ -220,6 +223,10 @@ void WorkletRuntimeDecorator::decorate(
|
|
|
220
223
|
return jsi::String::createFromUtf8(rt, path);
|
|
221
224
|
});
|
|
222
225
|
|
|
226
|
+
if (enableMicrotaskQueue) {
|
|
227
|
+
jsi_utils::installJsiFunction(rt, "__drainMicrotasks", [](jsi::Runtime &rt) { rt.drainMicrotasks(); });
|
|
228
|
+
}
|
|
229
|
+
|
|
223
230
|
jsi_utils::installJsiFunction(
|
|
224
231
|
rt,
|
|
225
232
|
"_scheduleTimeoutCallback",
|
|
@@ -237,84 +244,4 @@ void WorkletRuntimeDecorator::decorate(
|
|
|
237
244
|
});
|
|
238
245
|
}
|
|
239
246
|
|
|
240
|
-
void WorkletRuntimeDecorator::postEvaluateScript(
|
|
241
|
-
jsi::Runtime &rt,
|
|
242
|
-
const std::shared_ptr<RuntimeBindings> &runtimeBindings) {
|
|
243
|
-
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
244
|
-
installNetworking(rt, runtimeBindings);
|
|
245
|
-
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
249
|
-
void WorkletRuntimeDecorator::installNetworking(
|
|
250
|
-
jsi::Runtime &rt,
|
|
251
|
-
const std::shared_ptr<RuntimeBindings> &runtimeBindings) {
|
|
252
|
-
auto TurboModules = rt.global().getPropertyAsObject(rt, "TurboModules");
|
|
253
|
-
|
|
254
|
-
auto Networking = TurboModules.getPropertyAsFunction(rt, "get").callWithThis(rt, TurboModules, "Networking");
|
|
255
|
-
|
|
256
|
-
#ifdef ANDROID
|
|
257
|
-
auto jsiSendRequest = jsi::Function::createFromHostFunction(
|
|
258
|
-
rt,
|
|
259
|
-
jsi::PropNameID::forAscii(rt, "sendRequest"),
|
|
260
|
-
9,
|
|
261
|
-
[sendRequest = runtimeBindings->sendRequest](
|
|
262
|
-
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
263
|
-
auto method = args[0].asString(rt);
|
|
264
|
-
auto url = args[1].asString(rt);
|
|
265
|
-
auto requestId = args[2].asNumber();
|
|
266
|
-
auto headers = args[3].asObject(rt).asArray(rt);
|
|
267
|
-
auto data = args[4].asObject(rt);
|
|
268
|
-
auto responseType = args[5].asString(rt);
|
|
269
|
-
auto incrementalUpdates = args[6].asBool();
|
|
270
|
-
auto timeout = args[7].asNumber();
|
|
271
|
-
auto withCredentials = args[8].asBool();
|
|
272
|
-
sendRequest(
|
|
273
|
-
rt, method, url, requestId, headers, data, responseType, incrementalUpdates, timeout, withCredentials);
|
|
274
|
-
return jsi::Value::undefined();
|
|
275
|
-
});
|
|
276
|
-
#else
|
|
277
|
-
auto jsiSendRequest = jsi::Function::createFromHostFunction(
|
|
278
|
-
rt,
|
|
279
|
-
jsi::PropNameID::forAscii(rt, "sendRequest"),
|
|
280
|
-
2,
|
|
281
|
-
[sendRequest = runtimeBindings->sendRequest](
|
|
282
|
-
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
283
|
-
auto &query = args[0];
|
|
284
|
-
auto responseSender = args[1].asObject(rt).asFunction(rt);
|
|
285
|
-
sendRequest(rt, query, std::move(responseSender));
|
|
286
|
-
return jsi::Value::undefined();
|
|
287
|
-
});
|
|
288
|
-
#endif // ANDROID
|
|
289
|
-
|
|
290
|
-
Networking.asObject(rt).setProperty(rt, "sendRequest", std::move(jsiSendRequest));
|
|
291
|
-
|
|
292
|
-
auto jsiAbortRequest = jsi::Function::createFromHostFunction(
|
|
293
|
-
rt,
|
|
294
|
-
jsi::PropNameID::forAscii(rt, "abortRequest"),
|
|
295
|
-
1,
|
|
296
|
-
[abortRequest = runtimeBindings->abortRequest](
|
|
297
|
-
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
298
|
-
auto requestID = args[0].asNumber();
|
|
299
|
-
abortRequest(rt, requestID);
|
|
300
|
-
return jsi::Value::undefined();
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
Networking.asObject(rt).setProperty(rt, "abortRequest", std::move(jsiAbortRequest));
|
|
304
|
-
|
|
305
|
-
auto jsiClearCookies = jsi::Function::createFromHostFunction(
|
|
306
|
-
rt,
|
|
307
|
-
jsi::PropNameID::forAscii(rt, "clearCookies"),
|
|
308
|
-
1,
|
|
309
|
-
[clearCookies = runtimeBindings->clearCookies](
|
|
310
|
-
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
311
|
-
auto responseSender = args[0].asObject(rt).asFunction(rt);
|
|
312
|
-
clearCookies(rt, std::move(responseSender));
|
|
313
|
-
return jsi::Value::undefined();
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
Networking.asObject(rt).setProperty(rt, "clearCookies", std::move(jsiClearCookies));
|
|
317
|
-
}
|
|
318
|
-
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
319
|
-
|
|
320
247
|
} // namespace worklets
|
|
@@ -21,16 +21,10 @@ class WorkletRuntimeDecorator {
|
|
|
21
21
|
const std::string &name,
|
|
22
22
|
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
23
23
|
const bool isDevBundle,
|
|
24
|
+
const bool enableMicrotaskQueue,
|
|
24
25
|
jsi::Object &&jsiWorkletsModuleProxy,
|
|
25
26
|
const std::shared_ptr<EventLoop> &eventLoop,
|
|
26
27
|
const RuntimeBindings::NativeLoggingHook &nativeLoggingHook);
|
|
27
|
-
|
|
28
|
-
static void postEvaluateScript(jsi::Runtime &rt, const std::shared_ptr<RuntimeBindings> &runtimeBindings);
|
|
29
|
-
|
|
30
|
-
private:
|
|
31
|
-
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
32
|
-
static void installNetworking(jsi::Runtime &rt, const std::shared_ptr<RuntimeBindings> &runtimeBindings);
|
|
33
|
-
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
34
28
|
};
|
|
35
29
|
|
|
36
30
|
} // namespace worklets
|
package/Package.swift
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
let packageDirectory = Context.packageDirectory
|
|
7
|
+
|
|
8
|
+
func readPackageVersion() -> String {
|
|
9
|
+
let url = URL(fileURLWithPath: packageDirectory).appendingPathComponent("package.json")
|
|
10
|
+
let data = try! Data(contentsOf: url)
|
|
11
|
+
let json = try! JSONSerialization.jsonObject(with: data) as! [String: Any]
|
|
12
|
+
return json["version"] as! String
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
func readJSONObject(at url: URL) -> [String: Any]? {
|
|
16
|
+
guard let data = try? Data(contentsOf: url) else {
|
|
17
|
+
return nil
|
|
18
|
+
}
|
|
19
|
+
let object = try? JSONSerialization.jsonObject(with: data)
|
|
20
|
+
return object as? [String: Any]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// NSNumber needs the CFBoolean check to tell booleans apart from integers.
|
|
24
|
+
func stringifyFlagValue(_ value: Any) -> String? {
|
|
25
|
+
if let number = value as? NSNumber {
|
|
26
|
+
if CFGetTypeID(number) == CFBooleanGetTypeID() {
|
|
27
|
+
return number.boolValue ? "true" : "false"
|
|
28
|
+
}
|
|
29
|
+
return number.stringValue
|
|
30
|
+
}
|
|
31
|
+
if let string = value as? String {
|
|
32
|
+
return string
|
|
33
|
+
}
|
|
34
|
+
return nil
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
func isConsumerPackageJSON(at url: URL) -> Bool {
|
|
38
|
+
guard let json = readJSONObject(at: url),
|
|
39
|
+
let name = json["name"] as? String,
|
|
40
|
+
name != "react-native-worklets",
|
|
41
|
+
let section = json["worklets"] as? [String: Any],
|
|
42
|
+
section["staticFeatureFlags"] != nil
|
|
43
|
+
else {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
return true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// SPM autolinking uses ios/build/generated/autolinking/libs/<SwiftName>/ (symlink).
|
|
50
|
+
func findConsumerPackageJSON() -> URL? {
|
|
51
|
+
var dir = URL(fileURLWithPath: packageDirectory).standardizedFileURL
|
|
52
|
+
while dir.path != "/" {
|
|
53
|
+
let candidate = dir.appendingPathComponent("package.json")
|
|
54
|
+
if isConsumerPackageJSON(at: candidate) {
|
|
55
|
+
return candidate
|
|
56
|
+
}
|
|
57
|
+
dir = dir.deletingLastPathComponent()
|
|
58
|
+
}
|
|
59
|
+
return nil
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
func readStaticFeatureFlags() -> [String: String] {
|
|
63
|
+
var flags: [String: String] = [:]
|
|
64
|
+
|
|
65
|
+
let defaultsURL = URL(fileURLWithPath: packageDirectory)
|
|
66
|
+
.appendingPathComponent("src/featureFlags/staticFlags.json")
|
|
67
|
+
if let defaults = readJSONObject(at: defaultsURL) {
|
|
68
|
+
for (key, value) in defaults {
|
|
69
|
+
if let stringValue = stringifyFlagValue(value) {
|
|
70
|
+
flags[key] = stringValue
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if let consumerURL = findConsumerPackageJSON(),
|
|
76
|
+
let consumer = readJSONObject(at: consumerURL),
|
|
77
|
+
let section = consumer["worklets"] as? [String: Any],
|
|
78
|
+
let overrides = section["staticFeatureFlags"] as? [String: Any]
|
|
79
|
+
{
|
|
80
|
+
for (key, value) in overrides {
|
|
81
|
+
if let stringValue = stringifyFlagValue(value) {
|
|
82
|
+
flags[key] = stringValue
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return flags
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func formatFeatureFlags(_ flags: [String: String]) -> String {
|
|
91
|
+
return flags.keys.sorted().map { "[\($0):\(flags[$0]!)]" }.joined()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let version = readPackageVersion()
|
|
95
|
+
let featureFlags = formatFeatureFlags(readStaticFeatureFlags())
|
|
96
|
+
|
|
97
|
+
let reactHeaders: [Target.Dependency] = [
|
|
98
|
+
.product(name: "ReactHeaders", package: "ReactNative"),
|
|
99
|
+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
100
|
+
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
101
|
+
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
let package = Package(
|
|
105
|
+
name: "RNWorklets",
|
|
106
|
+
platforms: [.iOS(.v15)],
|
|
107
|
+
products: [
|
|
108
|
+
.library(name: "RNWorklets", targets: ["RNWorklets"]),
|
|
109
|
+
],
|
|
110
|
+
dependencies: [
|
|
111
|
+
.package(name: "ReactNative", path: "../../../../xcframeworks"),
|
|
112
|
+
.package(name: "React-GeneratedCode", path: "../../../ios"),
|
|
113
|
+
],
|
|
114
|
+
targets: [
|
|
115
|
+
.target(
|
|
116
|
+
name: "RNWorklets",
|
|
117
|
+
dependencies: reactHeaders,
|
|
118
|
+
path: ".",
|
|
119
|
+
sources: ["Common/cpp/worklets", "apple/worklets"],
|
|
120
|
+
publicHeadersPath: "Common/cpp",
|
|
121
|
+
cSettings: [
|
|
122
|
+
.headerSearchPath("."),
|
|
123
|
+
.headerSearchPath("Common/cpp"),
|
|
124
|
+
.headerSearchPath("apple"),
|
|
125
|
+
.define("WORKLETS_VERSION", to: version),
|
|
126
|
+
.define("WORKLETS_FEATURE_FLAGS", to: featureFlags),
|
|
127
|
+
.define("HERMES_ENABLE_DEBUGGER", to: "1", .when(configuration: .debug)),
|
|
128
|
+
],
|
|
129
|
+
cxxSettings: [
|
|
130
|
+
.headerSearchPath("."),
|
|
131
|
+
.headerSearchPath("Common/cpp"),
|
|
132
|
+
.headerSearchPath("apple"),
|
|
133
|
+
.define("WORKLETS_VERSION", to: version),
|
|
134
|
+
.define("WORKLETS_FEATURE_FLAGS", to: featureFlags),
|
|
135
|
+
.define("HERMES_ENABLE_DEBUGGER", to: "1", .when(configuration: .debug)),
|
|
136
|
+
.define("DEBUG", .when(configuration: .debug)),
|
|
137
|
+
.define("NDEBUG", .when(configuration: .release)),
|
|
138
|
+
],
|
|
139
|
+
linkerSettings: [
|
|
140
|
+
.linkedFramework("UIKit"),
|
|
141
|
+
.linkedFramework("Foundation"),
|
|
142
|
+
.linkedFramework("QuartzCore"),
|
|
143
|
+
]
|
|
144
|
+
),
|
|
145
|
+
],
|
|
146
|
+
cxxLanguageStandard: .cxx20
|
|
147
|
+
)
|
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/react-native-worklets
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [react-native-worklets](https://www.npmjs.com/package/react-native-worklets) @ 0.
|
|
17
|
-
| Processed | 2026-
|
|
16
|
+
| Original | [react-native-worklets](https://www.npmjs.com/package/react-native-worklets) @ 0.13.0 |
|
|
17
|
+
| Processed | 2026-09-27 |
|
|
18
18
|
| Smoke test | failed |
|
|
19
19
|
| Deps updated | 13 |
|
|
20
20
|
|
|
@@ -22,18 +22,18 @@ npm install @depup/react-native-worklets
|
|
|
22
22
|
|
|
23
23
|
| Dependency | From | To |
|
|
24
24
|
|------------|------|-----|
|
|
25
|
-
| @babel/generator | ^7.27.1 | ^8.0.
|
|
25
|
+
| @babel/generator | ^7.27.1 | ^8.0.6 |
|
|
26
26
|
| @babel/plugin-transform-arrow-functions | ^7.27.1 | ^8.0.1 |
|
|
27
27
|
| @babel/plugin-transform-class-properties | ^7.28.6 | ^8.0.1 |
|
|
28
|
-
| @babel/plugin-transform-classes | ^7.28.6 | ^8.0.
|
|
28
|
+
| @babel/plugin-transform-classes | ^7.28.6 | ^8.0.5 |
|
|
29
29
|
| @babel/plugin-transform-nullish-coalescing-operator | ^7.28.6 | ^8.0.1 |
|
|
30
|
-
| @babel/plugin-transform-optional-chaining | ^7.28.6 | ^8.0.
|
|
30
|
+
| @babel/plugin-transform-optional-chaining | ^7.28.6 | ^8.0.5 |
|
|
31
31
|
| @babel/plugin-transform-shorthand-properties | ^7.27.1 | ^8.0.1 |
|
|
32
32
|
| @babel/plugin-transform-template-literals | ^7.27.1 | ^8.0.1 |
|
|
33
33
|
| @babel/plugin-transform-unicode-regex | ^7.27.1 | ^8.0.1 |
|
|
34
34
|
| @babel/preset-typescript | ^7.28.5 | ^8.0.1 |
|
|
35
|
-
| @babel/traverse | ^7.27.1 | ^8.0.
|
|
36
|
-
| @babel/types | ^7.27.1 | ^8.0.
|
|
35
|
+
| @babel/traverse | ^7.27.1 | ^8.0.6 |
|
|
36
|
+
| @babel/types | ^7.27.1 | ^8.0.6 |
|
|
37
37
|
| semver | ^7.7.4 | ^7.8.5 |
|
|
38
38
|
|
|
39
39
|
---
|