@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
|
@@ -183,10 +183,6 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
createSerializableInitializer(obj: object) {
|
|
187
|
-
return this.#workletsModuleProxy.createSerializableInitializer(obj);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
186
|
createSerializableNonWorkletFunction<TArgs extends unknown[], TReturn>(
|
|
191
187
|
fun: (...args: TArgs) => TReturn,
|
|
192
188
|
functionName: string | undefined
|
|
@@ -250,10 +246,12 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
250
246
|
|
|
251
247
|
scheduleOnUI<TValue>(
|
|
252
248
|
serializableArrayOfWorklets: SerializableRef<TValue[]>,
|
|
249
|
+
serializableArrayOfArguments: SerializableRef<unknown[]>,
|
|
253
250
|
scheduleStacks: string[] | undefined
|
|
254
251
|
) {
|
|
255
252
|
return this.#workletsModuleProxy.scheduleOnUI(
|
|
256
253
|
serializableArrayOfWorklets,
|
|
254
|
+
serializableArrayOfArguments,
|
|
257
255
|
scheduleStacks
|
|
258
256
|
);
|
|
259
257
|
}
|
|
@@ -271,7 +269,8 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
271
269
|
useDefaultQueue: boolean,
|
|
272
270
|
customQueue: object | undefined,
|
|
273
271
|
enableEventLoop: boolean,
|
|
274
|
-
enableLocking: boolean
|
|
272
|
+
enableLocking: boolean,
|
|
273
|
+
enableNetworking: boolean
|
|
275
274
|
) {
|
|
276
275
|
return this.#workletsModuleProxy.createWorkletRuntime(
|
|
277
276
|
name,
|
|
@@ -279,7 +278,8 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
279
278
|
useDefaultQueue,
|
|
280
279
|
customQueue,
|
|
281
280
|
enableEventLoop,
|
|
282
|
-
enableLocking
|
|
281
|
+
enableLocking,
|
|
282
|
+
enableNetworking
|
|
283
283
|
);
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -343,8 +343,11 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
343
343
|
);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
createSynchronizable<TValue>(
|
|
347
|
-
|
|
346
|
+
createSynchronizable<TValue>(
|
|
347
|
+
value: SerializableRef<TValue> | TValue,
|
|
348
|
+
isFixed: boolean
|
|
349
|
+
): SynchronizableRef<TValue> {
|
|
350
|
+
return this.#workletsModuleProxy.createSynchronizable(value, isFixed);
|
|
348
351
|
}
|
|
349
352
|
|
|
350
353
|
synchronizableGetDirty<TValue>(
|
|
@@ -363,7 +366,7 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
363
366
|
|
|
364
367
|
synchronizableSetBlocking<TValue>(
|
|
365
368
|
synchronizableRef: SynchronizableRef<TValue>,
|
|
366
|
-
value: SerializableRef<TValue>
|
|
369
|
+
value: SerializableRef<TValue> | TValue
|
|
367
370
|
) {
|
|
368
371
|
return this.#workletsModuleProxy.synchronizableSetBlocking(
|
|
369
372
|
synchronizableRef,
|
|
@@ -371,6 +374,16 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
371
374
|
);
|
|
372
375
|
}
|
|
373
376
|
|
|
377
|
+
synchronizableSetDirty<TValue extends number | boolean>(
|
|
378
|
+
synchronizableRef: SynchronizableRef<TValue>,
|
|
379
|
+
value: TValue
|
|
380
|
+
): void {
|
|
381
|
+
return this.#workletsModuleProxy.synchronizableSetDirty(
|
|
382
|
+
synchronizableRef,
|
|
383
|
+
value
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
374
387
|
synchronizableLock<TValue>(
|
|
375
388
|
synchronizableRef: SynchronizableRef<TValue>
|
|
376
389
|
): void {
|
|
@@ -395,6 +408,10 @@ See https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting
|
|
|
395
408
|
this.#workletsModuleProxy.setDynamicFeatureFlag(name, value);
|
|
396
409
|
}
|
|
397
410
|
|
|
411
|
+
getCurrentThreadId(): string {
|
|
412
|
+
return this.#workletsModuleProxy.getCurrentThreadId();
|
|
413
|
+
}
|
|
414
|
+
|
|
398
415
|
getUIRuntimeHolder(): object {
|
|
399
416
|
return this.#workletsModuleProxy.getUIRuntimeHolder();
|
|
400
417
|
}
|
|
@@ -108,8 +108,6 @@ export interface WorkletsModuleProxy {
|
|
|
108
108
|
length: number
|
|
109
109
|
): SerializableRef<TValue>;
|
|
110
110
|
|
|
111
|
-
createSerializableInitializer(obj: object): SerializableRef<object>;
|
|
112
|
-
|
|
113
111
|
createSerializableNonWorkletFunction<TArgs extends unknown[], TReturn>(
|
|
114
112
|
fun: (...args: TArgs) => TReturn,
|
|
115
113
|
functionName: string | undefined
|
|
@@ -147,6 +145,7 @@ export interface WorkletsModuleProxy {
|
|
|
147
145
|
|
|
148
146
|
scheduleOnUI<TValue>(
|
|
149
147
|
serializableArrayOfWorklets: SerializableRef<TValue[]>,
|
|
148
|
+
serializableArrayOfArguments: SerializableRef<unknown[]>,
|
|
150
149
|
scheduleStacks: string[] | undefined
|
|
151
150
|
): void;
|
|
152
151
|
|
|
@@ -161,7 +160,8 @@ export interface WorkletsModuleProxy {
|
|
|
161
160
|
useDefaultQueue: boolean,
|
|
162
161
|
customQueue: object | undefined,
|
|
163
162
|
enableEventLoop: boolean,
|
|
164
|
-
enableLocking: boolean
|
|
163
|
+
enableLocking: boolean,
|
|
164
|
+
enableNetworking: boolean
|
|
165
165
|
): WorkletRuntime;
|
|
166
166
|
|
|
167
167
|
scheduleOnRuntime<TValue>(
|
|
@@ -197,7 +197,10 @@ export interface WorkletsModuleProxy {
|
|
|
197
197
|
|
|
198
198
|
reportFatalErrorOnJS(message: string, stack: string, name: string): void;
|
|
199
199
|
|
|
200
|
-
createSynchronizable<TValue>(
|
|
200
|
+
createSynchronizable<TValue>(
|
|
201
|
+
value: SerializableRef<TValue> | TValue,
|
|
202
|
+
isFixed: boolean
|
|
203
|
+
): SynchronizableRef<TValue>;
|
|
201
204
|
|
|
202
205
|
synchronizableGetDirty<TValue>(
|
|
203
206
|
synchronizableRef: SynchronizableRef<TValue>
|
|
@@ -209,7 +212,12 @@ export interface WorkletsModuleProxy {
|
|
|
209
212
|
|
|
210
213
|
synchronizableSetBlocking<TValue>(
|
|
211
214
|
synchronizableRef: SynchronizableRef<TValue>,
|
|
212
|
-
value: SerializableRef<TValue>
|
|
215
|
+
value: SerializableRef<TValue> | TValue
|
|
216
|
+
): void;
|
|
217
|
+
|
|
218
|
+
synchronizableSetDirty<TValue extends number | boolean>(
|
|
219
|
+
synchronizableRef: SynchronizableRef<TValue>,
|
|
220
|
+
value: TValue
|
|
213
221
|
): void;
|
|
214
222
|
|
|
215
223
|
synchronizableLock<TValue>(
|
|
@@ -224,6 +232,8 @@ export interface WorkletsModuleProxy {
|
|
|
224
232
|
|
|
225
233
|
setDynamicFeatureFlag(name: string, value: boolean): void;
|
|
226
234
|
|
|
235
|
+
getCurrentThreadId(): string;
|
|
236
|
+
|
|
227
237
|
getUIRuntimeHolder(): object;
|
|
228
238
|
|
|
229
239
|
getUISchedulerHolder(): object;
|
package/src/debug/jsVersion.ts
CHANGED
|
@@ -22,7 +22,6 @@ export type DynamicFlagName = keyof Omit<
|
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
23
|
const DefaultStaticFeatureFlags = {
|
|
24
24
|
RUNTIME_TEST_FLAG: false,
|
|
25
|
-
FETCH_PREVIEW_ENABLED: false,
|
|
26
25
|
IOS_DYNAMIC_FRAMERATE_ENABLED: true,
|
|
27
26
|
ENABLE_CROSS_RUNTIME_STACK_TRACES: true,
|
|
28
27
|
} as const satisfies typeof StaticFeatureFlagsJSON;
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { serializableMappingCache } from './memory/serializableMappingCache';
|
|
|
37
37
|
export { createShareable } from './memory/shareable';
|
|
38
38
|
export { createSynchronizable } from './memory/synchronizable';
|
|
39
39
|
export type {
|
|
40
|
+
FixedSynchronizable,
|
|
40
41
|
RegistrationData,
|
|
41
42
|
SerializableRef,
|
|
42
43
|
Shareable,
|
|
@@ -50,6 +51,7 @@ export type {
|
|
|
50
51
|
ShareableHostMeta,
|
|
51
52
|
ShareableHostProps,
|
|
52
53
|
Synchronizable,
|
|
54
|
+
SynchronizableConfig,
|
|
53
55
|
SynchronizableRef,
|
|
54
56
|
} from './memory/types';
|
|
55
57
|
export {
|
|
@@ -75,6 +77,7 @@ export {
|
|
|
75
77
|
} from './runtimes';
|
|
76
78
|
export {
|
|
77
79
|
executeOnUIRuntimeSync,
|
|
80
|
+
getCurrentThreadId,
|
|
78
81
|
runOnJS,
|
|
79
82
|
runOnUI,
|
|
80
83
|
runOnUIAsync,
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
import { silenceHMRWarnings } from '../bundleMode/metroOverrides';
|
|
4
|
-
import { initializeNetworking } from '../bundleMode/network';
|
|
5
4
|
import { registerReportFatalRemoteError } from '../debug/errors';
|
|
6
|
-
import { getStaticFeatureFlag } from '../featureFlags/featureFlags';
|
|
7
5
|
import { bundleValueUnpacker } from '../memory/bundleUnpacker';
|
|
8
6
|
import { installCustomSerializableUnpacker } from '../memory/customSerializableUnpacker';
|
|
9
7
|
import { installRemoteFunctionUnpacker } from '../memory/remoteFunctionUnpacker';
|
|
@@ -12,12 +10,14 @@ import { installShareableGuestUnpacker } from '../memory/shareableGuestUnpacker'
|
|
|
12
10
|
import { installShareableHostUnpacker } from '../memory/shareableHostUnpacker';
|
|
13
11
|
import { installSynchronizableUnpacker } from '../memory/synchronizableUnpacker';
|
|
14
12
|
import { installValueUnpacker } from '../memory/valueUnpacker';
|
|
13
|
+
import { installNetworking } from '../networking/install';
|
|
14
|
+
import { setupQueueMicrotask } from '../runLoop/common/queueMicrotaskPolyfill';
|
|
15
15
|
import { setupSetImmediate } from '../runLoop/common/setImmediatePolyfill';
|
|
16
16
|
import { setupSetInterval } from '../runLoop/common/setIntervalPolyfill';
|
|
17
17
|
import { setupRequestAnimationFrame } from '../runLoop/uiRuntime/requestAnimationFrame';
|
|
18
18
|
import { setupSetTimeout } from '../runLoop/uiRuntime/setTimeoutPolyfill';
|
|
19
19
|
import { RuntimeKind } from '../runtimeKind';
|
|
20
|
-
import { runOnUISync, scheduleOnRN
|
|
20
|
+
import { runOnUISync, scheduleOnRN } from '../threads';
|
|
21
21
|
import type { ValueUnpacker } from '../types';
|
|
22
22
|
import { isWorkletFunction } from '../workletFunction';
|
|
23
23
|
import { WorkletsModule } from '../WorkletsModule/NativeWorklets';
|
|
@@ -172,9 +172,7 @@ function initializeWorkletRuntime() {
|
|
|
172
172
|
silenceHMRWarnings();
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
initializeNetworking();
|
|
177
|
-
}
|
|
175
|
+
installNetworking();
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -196,19 +194,13 @@ function installRNBindingsOnUIRuntime() {
|
|
|
196
194
|
|
|
197
195
|
runOnUISync(() => {
|
|
198
196
|
'worklet';
|
|
199
|
-
/**
|
|
200
|
-
* TODO: Move `setupMicrotasks` and `setupRequestAnimationFrame` to a
|
|
201
|
-
* separate function once we have a better way to distinguish between
|
|
202
|
-
* Worklet Runtimes.
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
197
|
if (!globalThis._WORKLETS_BUNDLE_MODE_ENABLED) {
|
|
206
198
|
setupConsole(runtimeBoundCapturableConsole!);
|
|
207
199
|
} else if (__DEV__) {
|
|
208
200
|
setupConsoleForwarding(runtimeBoundCapturableConsole!);
|
|
209
201
|
}
|
|
210
202
|
|
|
211
|
-
|
|
203
|
+
setupQueueMicrotask();
|
|
212
204
|
setupRequestAnimationFrame();
|
|
213
205
|
setupSetTimeout();
|
|
214
206
|
setupSetImmediate();
|
|
@@ -3,19 +3,10 @@
|
|
|
3
3
|
import { logger } from '../debug/logger';
|
|
4
4
|
import type { WorkletFactory, WorkletFunction } from '../types';
|
|
5
5
|
|
|
6
|
-
const handleCache = new WeakMap<WorkletFunction, unknown>();
|
|
7
|
-
|
|
8
6
|
export function bundleValueUnpacker(objectToUnpack: ObjectToUnpack): unknown {
|
|
9
7
|
const workletHash = objectToUnpack.__workletHash;
|
|
10
8
|
if (workletHash !== undefined) {
|
|
11
9
|
return getWorklet(workletHash, objectToUnpack.__closure);
|
|
12
|
-
} else if (objectToUnpack.__init !== undefined) {
|
|
13
|
-
let value = handleCache.get(objectToUnpack);
|
|
14
|
-
if (value === undefined) {
|
|
15
|
-
value = objectToUnpack.__init();
|
|
16
|
-
handleCache.set(objectToUnpack, value);
|
|
17
|
-
}
|
|
18
|
-
return value;
|
|
19
10
|
} else {
|
|
20
11
|
throw new Error(
|
|
21
12
|
`[Worklets] Data type not recognized by value unpacker: "${globalThis._toString(
|
|
@@ -27,7 +18,7 @@ export function bundleValueUnpacker(objectToUnpack: ObjectToUnpack): unknown {
|
|
|
27
18
|
|
|
28
19
|
function getWorklet(
|
|
29
20
|
workletHash: number,
|
|
30
|
-
closureVariables:
|
|
21
|
+
closureVariables: unknown[] | undefined
|
|
31
22
|
): WorkletFunction | undefined {
|
|
32
23
|
let worklet;
|
|
33
24
|
if (__DEV__) {
|
|
@@ -48,10 +39,12 @@ const metroRequire = globalThis.__r;
|
|
|
48
39
|
|
|
49
40
|
function getWorkletFromMetroRequire(
|
|
50
41
|
workletHash: number,
|
|
51
|
-
closureVariables:
|
|
42
|
+
closureVariables: unknown[] | undefined
|
|
52
43
|
): WorkletFunction {
|
|
53
|
-
const
|
|
54
|
-
return
|
|
44
|
+
const exportedWorklet = metroRequire(workletHash).default;
|
|
45
|
+
return closureVariables === undefined
|
|
46
|
+
? (exportedWorklet as WorkletFunction)
|
|
47
|
+
: (exportedWorklet as WorkletFactory)(closureVariables);
|
|
55
48
|
}
|
|
56
49
|
|
|
57
50
|
interface ObjectToUnpack extends WorkletFunction {
|
|
@@ -181,16 +181,6 @@ export function createSerializable<TValue>(
|
|
|
181
181
|
if (isHostObject(value)) {
|
|
182
182
|
return cloneHostObject(value);
|
|
183
183
|
}
|
|
184
|
-
if (isPlainJSObject(value) && value.__init) {
|
|
185
|
-
return cloneInitializer(
|
|
186
|
-
value,
|
|
187
|
-
shouldPersistRemote,
|
|
188
|
-
depth
|
|
189
|
-
) as SerializableRef<TValue>;
|
|
190
|
-
}
|
|
191
|
-
if (isPlainJSObject(value) && value.__workletContextObjectFactory) {
|
|
192
|
-
return cloneContextObject(value);
|
|
193
|
-
}
|
|
194
184
|
if ((isPlainJSObject(value) || isFunction) && isWorkletFunction(value)) {
|
|
195
185
|
return cloneWorklet(value, shouldPersistRemote, depth);
|
|
196
186
|
}
|
|
@@ -397,19 +387,6 @@ function cloneObjectProperties<T extends object>(
|
|
|
397
387
|
return clonedProps;
|
|
398
388
|
}
|
|
399
389
|
|
|
400
|
-
function cloneInitializer(
|
|
401
|
-
value: object,
|
|
402
|
-
shouldPersistRemote = false,
|
|
403
|
-
depth = 0
|
|
404
|
-
): SerializableRef<object> {
|
|
405
|
-
const clonedProps: Record<string, unknown> = cloneObjectProperties(
|
|
406
|
-
value,
|
|
407
|
-
shouldPersistRemote,
|
|
408
|
-
depth
|
|
409
|
-
);
|
|
410
|
-
return WorkletsModule.createSerializableInitializer(clonedProps);
|
|
411
|
-
}
|
|
412
|
-
|
|
413
390
|
function cloneArray<T extends unknown[]>(
|
|
414
391
|
value: T,
|
|
415
392
|
shouldPersistRemote: boolean,
|
|
@@ -541,21 +518,6 @@ function cloneTurboModuleLike<TValue extends object>(
|
|
|
541
518
|
return clone;
|
|
542
519
|
}
|
|
543
520
|
|
|
544
|
-
function cloneContextObject<TValue extends object>(
|
|
545
|
-
value: TValue
|
|
546
|
-
): SerializableRef<TValue> {
|
|
547
|
-
const workletContextObjectFactory = (value as Record<string, unknown>)
|
|
548
|
-
.__workletContextObjectFactory as () => TValue;
|
|
549
|
-
const handle = cloneInitializer({
|
|
550
|
-
__init: () => {
|
|
551
|
-
'worklet';
|
|
552
|
-
return workletContextObjectFactory();
|
|
553
|
-
},
|
|
554
|
-
});
|
|
555
|
-
serializableMappingCache.set(value, handle);
|
|
556
|
-
return handle as SerializableRef<TValue>;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
521
|
function clonePlainJSObject<TValue extends object>(
|
|
560
522
|
value: TValue,
|
|
561
523
|
shouldPersistRemote: boolean,
|
|
@@ -948,12 +910,7 @@ export function makeShareable<TValue extends object>(value: TValue): TValue {
|
|
|
948
910
|
if (serializableMappingCache.get(value)) {
|
|
949
911
|
return value;
|
|
950
912
|
}
|
|
951
|
-
const handle = createSerializable(
|
|
952
|
-
__init: () => {
|
|
953
|
-
'worklet';
|
|
954
|
-
return value;
|
|
955
|
-
},
|
|
956
|
-
});
|
|
913
|
+
const handle = createSerializable(value, true);
|
|
957
914
|
serializableMappingCache.set(value, handle);
|
|
958
915
|
return value;
|
|
959
916
|
}
|
|
@@ -2,16 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
import { WorkletsModule } from '../WorkletsModule/NativeWorklets';
|
|
4
4
|
import { createSerializable } from './serializable';
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
FixedSynchronizable,
|
|
7
|
+
Synchronizable,
|
|
8
|
+
SynchronizableConfig,
|
|
9
|
+
} from './types';
|
|
10
|
+
|
|
11
|
+
export function createSynchronizable<TValue extends number | boolean>(
|
|
12
|
+
initialValue: TValue,
|
|
13
|
+
config: SynchronizableConfig & { fixedType: true }
|
|
14
|
+
): FixedSynchronizable<TValue extends boolean ? boolean : number>;
|
|
15
|
+
|
|
16
|
+
export function createSynchronizable<TValue extends number | boolean>(
|
|
17
|
+
initialValue: TValue,
|
|
18
|
+
config: SynchronizableConfig
|
|
19
|
+
): Synchronizable<TValue> | FixedSynchronizable<TValue>;
|
|
20
|
+
|
|
21
|
+
export function createSynchronizable<TValue = unknown>(
|
|
22
|
+
initialValue: TValue,
|
|
23
|
+
config?: SynchronizableConfig
|
|
24
|
+
): Synchronizable<TValue>;
|
|
6
25
|
|
|
7
26
|
export function createSynchronizable<TValue = unknown>(
|
|
8
|
-
initialValue: TValue
|
|
27
|
+
initialValue: TValue,
|
|
28
|
+
config?: SynchronizableConfig
|
|
9
29
|
): Synchronizable<TValue> {
|
|
30
|
+
const isFixed = !!config?.fixedType;
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
__DEV__ &&
|
|
34
|
+
isFixed &&
|
|
35
|
+
!(typeof initialValue === 'number' || typeof initialValue === 'boolean')
|
|
36
|
+
) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
'[Worklets] `fixedType` requires a number or boolean initial value.'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
10
42
|
const synchronizableRef = WorkletsModule.createSynchronizable(
|
|
11
|
-
createSerializable(initialValue)
|
|
43
|
+
isFixed ? initialValue : createSerializable(initialValue),
|
|
44
|
+
isFixed
|
|
12
45
|
);
|
|
13
46
|
|
|
14
47
|
return globalThis.__synchronizableUnpacker(
|
|
15
|
-
synchronizableRef
|
|
48
|
+
synchronizableRef,
|
|
49
|
+
isFixed
|
|
16
50
|
) as unknown as Synchronizable<TValue>;
|
|
17
51
|
}
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
FixedSynchronizable,
|
|
5
|
+
Synchronizable,
|
|
6
|
+
SynchronizableConfig,
|
|
7
|
+
} from './types';
|
|
8
|
+
|
|
9
|
+
export function createSynchronizable<TValue extends number | boolean>(
|
|
10
|
+
initialValue: TValue,
|
|
11
|
+
config: SynchronizableConfig & { fixedType: true }
|
|
12
|
+
): FixedSynchronizable<TValue extends boolean ? boolean : number>;
|
|
13
|
+
|
|
14
|
+
export function createSynchronizable<TValue extends number | boolean>(
|
|
15
|
+
initialValue: TValue,
|
|
16
|
+
config: SynchronizableConfig
|
|
17
|
+
): Synchronizable<TValue> | FixedSynchronizable<TValue>;
|
|
18
|
+
|
|
19
|
+
export function createSynchronizable<TValue = unknown>(
|
|
20
|
+
initialValue: TValue,
|
|
21
|
+
config?: SynchronizableConfig
|
|
22
|
+
): Synchronizable<TValue>;
|
|
4
23
|
|
|
5
24
|
export function createSynchronizable<TValue = unknown>(
|
|
6
|
-
|
|
25
|
+
_initialValue: TValue,
|
|
26
|
+
_config?: SynchronizableConfig
|
|
7
27
|
): Synchronizable<TValue> {
|
|
8
28
|
throw new Error('[Worklets] `createSynchronizable` is not supported on web.');
|
|
9
29
|
}
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type FixedSynchronizable,
|
|
8
|
+
type Synchronizable,
|
|
9
|
+
type SynchronizableRef,
|
|
10
|
+
} from './types';
|
|
7
11
|
|
|
8
12
|
export function installSynchronizableUnpacker() {
|
|
9
13
|
'worklet';
|
|
@@ -15,7 +19,8 @@ export function installSynchronizableUnpacker() {
|
|
|
15
19
|
: (value: unknown) => globalThis.__serializer(value);
|
|
16
20
|
|
|
17
21
|
function synchronizableUnpacker<TValue>(
|
|
18
|
-
synchronizableRef: SynchronizableRef<TValue
|
|
22
|
+
synchronizableRef: SynchronizableRef<TValue>,
|
|
23
|
+
isFixed: boolean
|
|
19
24
|
): Synchronizable<TValue> {
|
|
20
25
|
const synchronizable =
|
|
21
26
|
synchronizableRef as unknown as Synchronizable<TValue>;
|
|
@@ -29,7 +34,10 @@ export function installSynchronizableUnpacker() {
|
|
|
29
34
|
return proxy.synchronizableGetBlocking(synchronizable);
|
|
30
35
|
};
|
|
31
36
|
const setBlockingValue = (newValue: TValue) => {
|
|
32
|
-
proxy.synchronizableSetBlocking(
|
|
37
|
+
proxy.synchronizableSetBlocking(
|
|
38
|
+
synchronizable,
|
|
39
|
+
isFixed ? newValue : serializer(newValue)
|
|
40
|
+
);
|
|
33
41
|
};
|
|
34
42
|
synchronizable.setBlocking = (
|
|
35
43
|
valueOrFunction: TValue | ((prev: TValue) => TValue)
|
|
@@ -59,6 +67,16 @@ export function installSynchronizableUnpacker() {
|
|
|
59
67
|
synchronizable.unlock = () => {
|
|
60
68
|
proxy.synchronizableUnlock(synchronizable);
|
|
61
69
|
};
|
|
70
|
+
if (isFixed) {
|
|
71
|
+
(
|
|
72
|
+
synchronizable as unknown as FixedSynchronizable<number | boolean>
|
|
73
|
+
).setDirty = (value: number | boolean) => {
|
|
74
|
+
proxy.synchronizableSetDirty(
|
|
75
|
+
synchronizable as unknown as SynchronizableRef<number | boolean>,
|
|
76
|
+
value
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
62
80
|
|
|
63
81
|
return synchronizable;
|
|
64
82
|
}
|
|
@@ -67,5 +85,6 @@ export function installSynchronizableUnpacker() {
|
|
|
67
85
|
}
|
|
68
86
|
|
|
69
87
|
export type SynchronizableUnpacker = <TValue>(
|
|
70
|
-
synchronizableRef: SynchronizableRef<TValue
|
|
88
|
+
synchronizableRef: SynchronizableRef<TValue>,
|
|
89
|
+
isFixed: boolean
|
|
71
90
|
) => Synchronizable<TValue>;
|
package/src/memory/types.ts
CHANGED
|
@@ -36,6 +36,15 @@ export type Synchronizable<TValue = unknown> = SerializableRef<TValue> &
|
|
|
36
36
|
unlock(): void;
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export type FixedSynchronizable<TValue extends number | boolean> =
|
|
40
|
+
Synchronizable<TValue> & {
|
|
41
|
+
setDirty(value: TValue): void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type SynchronizableConfig = {
|
|
45
|
+
fixedType?: boolean;
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
/**
|
|
40
49
|
* Registration data for
|
|
41
50
|
* [registerCustomSerializable](https://docs.swmansion.com/react-native-worklets/docs/memory/registerCustomSerializable)
|
|
@@ -16,7 +16,6 @@ export function installValueUnpacker() {
|
|
|
16
16
|
'worklet';
|
|
17
17
|
'no-worklet-closure';
|
|
18
18
|
const workletsCache = new Map<number, () => unknown>();
|
|
19
|
-
const handleCache = new WeakMap<object, unknown>();
|
|
20
19
|
|
|
21
20
|
function valueUnpacker(objectToUnpack: ObjectToUnpack): unknown {
|
|
22
21
|
const workletHash = objectToUnpack.__workletHash;
|
|
@@ -55,13 +54,6 @@ export function installValueUnpacker() {
|
|
|
55
54
|
const functionInstance = workletFun!.bind(objectToUnpack);
|
|
56
55
|
objectToUnpack._recur = functionInstance;
|
|
57
56
|
return functionInstance;
|
|
58
|
-
} else if (objectToUnpack.__init !== undefined) {
|
|
59
|
-
let value = handleCache.get(objectToUnpack);
|
|
60
|
-
if (value === undefined) {
|
|
61
|
-
value = objectToUnpack.__init();
|
|
62
|
-
handleCache.set(objectToUnpack, value);
|
|
63
|
-
}
|
|
64
|
-
return value;
|
|
65
57
|
} else {
|
|
66
58
|
throw new Error(
|
|
67
59
|
`[Worklets] Data type not recognized by value unpacker: "${globalThis._toString(
|
package/src/mock.ts
CHANGED
|
@@ -44,9 +44,36 @@ const WorkletAPI = {
|
|
|
44
44
|
setSync: set,
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
|
-
createSynchronizable:
|
|
47
|
+
createSynchronizable: <TValue>(
|
|
48
|
+
initialValue: TValue,
|
|
49
|
+
config?: { fixedType?: boolean }
|
|
50
|
+
) => {
|
|
51
|
+
let value = initialValue;
|
|
52
|
+
const synchronizable = {
|
|
53
|
+
__synchronizableRef: true,
|
|
54
|
+
getDirty: () => value,
|
|
55
|
+
getBlocking: () => value,
|
|
56
|
+
setBlocking: (newValue: TValue | ((prev: TValue) => TValue)) => {
|
|
57
|
+
value =
|
|
58
|
+
typeof newValue === 'function'
|
|
59
|
+
? (newValue as (prev: TValue) => TValue)(value)
|
|
60
|
+
: newValue;
|
|
61
|
+
},
|
|
62
|
+
lock: NOOP,
|
|
63
|
+
unlock: NOOP,
|
|
64
|
+
};
|
|
65
|
+
if (config?.fixedType) {
|
|
66
|
+
Object.assign(synchronizable, {
|
|
67
|
+
setDirty: (newValue: TValue) => {
|
|
68
|
+
value = newValue;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return synchronizable;
|
|
73
|
+
},
|
|
48
74
|
createWorkletRuntime: NOOP_FACTORY,
|
|
49
75
|
executeOnUIRuntimeSync: ID,
|
|
76
|
+
getCurrentThreadId: () => '0',
|
|
50
77
|
getDynamicFeatureFlag: () => false,
|
|
51
78
|
getRuntimeKind: () => RuntimeKind.ReactNative,
|
|
52
79
|
getStaticFeatureFlag: () => false,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { NetworkingEventListener } from './events';
|
|
4
|
+
import { EventTargetLite } from './events';
|
|
5
|
+
|
|
6
|
+
export class AbortSignal extends EventTargetLite {
|
|
7
|
+
aborted = false;
|
|
8
|
+
reason: unknown = undefined;
|
|
9
|
+
onabort: NetworkingEventListener | null = null;
|
|
10
|
+
|
|
11
|
+
static abort(reason?: unknown): AbortSignal {
|
|
12
|
+
const signal = new AbortSignal();
|
|
13
|
+
signal.__abort(reason);
|
|
14
|
+
return signal;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static timeout(delayMs: number): AbortSignal {
|
|
18
|
+
const signal = new AbortSignal();
|
|
19
|
+
setTimeout(() => signal.__abort(makeAbortError('TimeoutError')), delayMs);
|
|
20
|
+
return signal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
throwIfAborted() {
|
|
24
|
+
if (this.aborted) {
|
|
25
|
+
throw this.reason;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
__abort(reason?: unknown) {
|
|
30
|
+
if (this.aborted) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.aborted = true;
|
|
34
|
+
this.reason = reason !== undefined ? reason : makeAbortError('AbortError');
|
|
35
|
+
this.__dispatch('abort');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class AbortController {
|
|
40
|
+
readonly signal = new AbortSignal();
|
|
41
|
+
|
|
42
|
+
abort(reason?: unknown) {
|
|
43
|
+
this.signal.__abort(reason);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function makeAbortError(name: string): Error {
|
|
48
|
+
const error = new Error(
|
|
49
|
+
`[Worklets] ${
|
|
50
|
+
name === 'TimeoutError'
|
|
51
|
+
? 'The operation timed out.'
|
|
52
|
+
: 'The operation was aborted.'
|
|
53
|
+
}`
|
|
54
|
+
);
|
|
55
|
+
error.name = name;
|
|
56
|
+
return error;
|
|
57
|
+
}
|