@depup/react-native-worklets 0.11.3-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/.worklets/dummy.md +1 -0
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +64 -0
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
- package/Common/cpp/worklets/Compat/Holders.h +25 -0
- package/Common/cpp/worklets/Compat/StableApi.cpp +145 -0
- package/Common/cpp/worklets/Compat/StableApi.h +128 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +729 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +126 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +81 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +76 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +95 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +44 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +10 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +43 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueue.h +14 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +69 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +48 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.cpp +103 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.h +52 -0
- package/Common/cpp/worklets/SharedItems/MemoryManager.cpp +60 -0
- package/Common/cpp/worklets/SharedItems/MemoryManager.h +29 -0
- package/Common/cpp/worklets/SharedItems/Serializable.cpp +373 -0
- package/Common/cpp/worklets/SharedItems/Serializable.h +413 -0
- package/Common/cpp/worklets/SharedItems/SerializableFactory.cpp +172 -0
- package/Common/cpp/worklets/SharedItems/SerializableFactory.h +85 -0
- package/Common/cpp/worklets/SharedItems/SerializableRemoteFunction.cpp +71 -0
- package/Common/cpp/worklets/SharedItems/SerializableRemoteFunction.h +75 -0
- package/Common/cpp/worklets/SharedItems/Shareable.cpp +84 -0
- package/Common/cpp/worklets/SharedItems/Shareable.h +43 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +59 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.h +57 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +78 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +45 -0
- package/Common/cpp/worklets/SharedItems/UnpackerLoader.h +78 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.cpp +18 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.h +44 -0
- package/Common/cpp/worklets/Tools/JSISerializer.cpp +312 -0
- package/Common/cpp/worklets/Tools/JSISerializer.h +42 -0
- package/Common/cpp/worklets/Tools/JSLogger.cpp +92 -0
- package/Common/cpp/worklets/Tools/JSLogger.h +48 -0
- package/Common/cpp/worklets/Tools/JSScheduler.cpp +21 -0
- package/Common/cpp/worklets/Tools/JSScheduler.h +35 -0
- package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
- package/Common/cpp/worklets/Tools/RNRuntimeStatus.h +27 -0
- package/Common/cpp/worklets/Tools/ScriptBuffer.h +56 -0
- package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +75 -0
- package/Common/cpp/worklets/Tools/ThreadSafeQueue.h +49 -0
- package/Common/cpp/worklets/Tools/UIScheduler.cpp +19 -0
- package/Common/cpp/worklets/Tools/UIScheduler.h +22 -0
- package/Common/cpp/worklets/Tools/VersionUtils.cpp +61 -0
- package/Common/cpp/worklets/Tools/VersionUtils.h +24 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +34 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.h +44 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +30 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +222 -0
- package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +116 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.cpp +46 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.h +18 -0
- package/Common/cpp/worklets/WorkletRuntime/BundleModeConfig.h +17 -0
- package/Common/cpp/worklets/WorkletRuntime/HermesProfiling.cpp +45 -0
- package/Common/cpp/worklets/WorkletRuntime/HermesProfiling.h +12 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +68 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +24 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +59 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeData.h +38 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeHolder.h +19 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +122 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +75 -0
- package/Common/cpp/worklets/WorkletRuntime/ScriptLoader.h +116 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +14 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +15 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +58 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +100 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +327 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +256 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +320 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +36 -0
- package/LICENSE +20 -0
- package/README.md +43 -0
- package/RNWorklets.podspec +94 -0
- package/android/CMakeLists.txt +108 -0
- package/android/build.gradle.kts +369 -0
- package/android/fix-prefab.gradle.kts +56 -0
- package/android/generate-stub-pch.gradle.kts +84 -0
- package/android/gradle.properties +25 -0
- package/android/proguard-rules.pro +3 -0
- package/android/settings.gradle.kts +21 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/WorkletsPCH.h +26 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +66 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +38 -0
- package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +30 -0
- package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.cpp +66 -0
- package/android/src/main/cpp/worklets/android/JScriptBufferWrapper.h +48 -0
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +51 -0
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +43 -0
- package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +31 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +203 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +75 -0
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +19 -0
- package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.kt +56 -0
- package/android/src/main/java/com/swmansion/worklets/ScriptBufferWrapper.kt +103 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.kt +42 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameCallback.kt +14 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.kt +112 -0
- package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +27 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +30 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsModule.kt +187 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +272 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +1124 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +40 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +13 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +98 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +60 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +87 -0
- package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +181 -0
- package/android/src/no-networking/com/swmansion/worklets/WorkletsModule.kt +143 -0
- package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +145 -0
- package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +12 -0
- package/apple/worklets/apple/IOSUIScheduler.h +14 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +29 -0
- package/apple/worklets/apple/Networking/WorkletsNetworking.h +25 -0
- package/apple/worklets/apple/Networking/WorkletsNetworking.mm +707 -0
- package/apple/worklets/apple/PlatformLogger.mm +31 -0
- package/apple/worklets/apple/SlowAnimations.h +8 -0
- package/apple/worklets/apple/SlowAnimations.mm +45 -0
- package/apple/worklets/apple/WorkletsDisplayLink.h +21 -0
- package/apple/worklets/apple/WorkletsModule.h +28 -0
- package/apple/worklets/apple/WorkletsModule.mm +177 -0
- package/bundleMode/index.d.ts +6 -0
- package/bundleMode/index.js +182 -0
- package/bundleMode/shims/reactNativeShim.js +21 -0
- package/bundleMode/shims/turboModuleRegistryShim.js +47 -0
- package/changes.json +58 -0
- package/compatibility.json +29 -0
- package/jest/pluginTestUtils.ts +16 -0
- package/jest/resolver.js +18 -0
- package/lib/module/WorkletsModule/NativeWorklets.js +4 -0
- package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/NativeWorklets.native.js +199 -0
- package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
- package/lib/module/bundleMode/metroOverrides.native.js +26 -0
- package/lib/module/bundleMode/metroOverrides.native.js.map +1 -0
- package/lib/module/bundleMode/network.native.js +44 -0
- package/lib/module/bundleMode/network.native.js.map +1 -0
- package/lib/module/debug/bundleMode.js +6 -0
- package/lib/module/debug/bundleMode.js.map +1 -0
- package/lib/module/debug/bundleMode.native.js +11 -0
- package/lib/module/debug/bundleMode.native.js.map +1 -0
- package/lib/module/debug/checkCppVersion.js +29 -0
- package/lib/module/debug/checkCppVersion.js.map +1 -0
- package/lib/module/debug/errors.native.js +67 -0
- package/lib/module/debug/errors.native.js.map +1 -0
- package/lib/module/debug/jsVersion.js +9 -0
- package/lib/module/debug/jsVersion.js.map +1 -0
- package/lib/module/debug/logger.js +15 -0
- package/lib/module/debug/logger.js.map +1 -0
- package/lib/module/debug/slowAnimations.js +7 -0
- package/lib/module/debug/slowAnimations.js.map +1 -0
- package/lib/module/debug/slowAnimations.native.js +17 -0
- package/lib/module/debug/slowAnimations.native.js.map +1 -0
- package/lib/module/deprecated.js +27 -0
- package/lib/module/deprecated.js.map +1 -0
- package/lib/module/featureFlags/featureFlags.js +12 -0
- package/lib/module/featureFlags/featureFlags.js.map +1 -0
- package/lib/module/featureFlags/featureFlags.native.js +51 -0
- package/lib/module/featureFlags/featureFlags.native.js.map +1 -0
- package/lib/module/featureFlags/staticFlags.json +6 -0
- package/lib/module/featureFlags/types.js +16 -0
- package/lib/module/featureFlags/types.js.map +1 -0
- package/lib/module/guardImplementation.native.js +17 -0
- package/lib/module/guardImplementation.native.js.map +1 -0
- package/lib/module/index.js +26 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initializers/initializers.js +24 -0
- package/lib/module/initializers/initializers.js.map +1 -0
- package/lib/module/initializers/initializers.native.js +195 -0
- package/lib/module/initializers/initializers.native.js.map +1 -0
- package/lib/module/memory/bundleUnpacker.native.js +38 -0
- package/lib/module/memory/bundleUnpacker.native.js.map +1 -0
- package/lib/module/memory/customSerializableUnpacker.native.js +20 -0
- package/lib/module/memory/customSerializableUnpacker.native.js.map +1 -0
- package/lib/module/memory/isShareable.js +8 -0
- package/lib/module/memory/isShareable.js.map +1 -0
- package/lib/module/memory/isSynchronizable.js +8 -0
- package/lib/module/memory/isSynchronizable.js.map +1 -0
- package/lib/module/memory/remoteFunctionUnpacker.native.js +18 -0
- package/lib/module/memory/remoteFunctionUnpacker.native.js.map +1 -0
- package/lib/module/memory/serializable.js +18 -0
- package/lib/module/memory/serializable.js.map +1 -0
- package/lib/module/memory/serializable.native.js +619 -0
- package/lib/module/memory/serializable.native.js.map +1 -0
- package/lib/module/memory/serializableMappingCache.js +11 -0
- package/lib/module/memory/serializableMappingCache.js.map +1 -0
- package/lib/module/memory/serializableMappingCache.native.js +29 -0
- package/lib/module/memory/serializableMappingCache.native.js.map +1 -0
- package/lib/module/memory/shareable.js +18 -0
- package/lib/module/memory/shareable.js.map +1 -0
- package/lib/module/memory/shareable.native.js +42 -0
- package/lib/module/memory/shareable.native.js.map +1 -0
- package/lib/module/memory/shareableGuestUnpacker.native.js +105 -0
- package/lib/module/memory/shareableGuestUnpacker.native.js.map +1 -0
- package/lib/module/memory/shareableHostUnpacker.native.js +20 -0
- package/lib/module/memory/shareableHostUnpacker.native.js.map +1 -0
- package/lib/module/memory/synchronizable.js +6 -0
- package/lib/module/memory/synchronizable.js.map +1 -0
- package/lib/module/memory/synchronizable.native.js +9 -0
- package/lib/module/memory/synchronizable.native.js.map +1 -0
- package/lib/module/memory/synchronizableUnpacker.native.js +47 -0
- package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -0
- package/lib/module/memory/types.js +12 -0
- package/lib/module/memory/types.js.map +1 -0
- package/lib/module/memory/valueUnpacker.native.js +52 -0
- package/lib/module/memory/valueUnpacker.native.js.map +1 -0
- package/lib/module/mock.js +85 -0
- package/lib/module/mock.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/platformChecker.js +4 -0
- package/lib/module/platformChecker.js.map +1 -0
- package/lib/module/platformChecker.native.js +4 -0
- package/lib/module/platformChecker.native.js.map +1 -0
- package/lib/module/privateGlobals.d.js +7 -0
- package/lib/module/privateGlobals.d.js.map +1 -0
- package/lib/module/runLoop/common/setImmediatePolyfill.js +15 -0
- package/lib/module/runLoop/common/setImmediatePolyfill.js.map +1 -0
- package/lib/module/runLoop/common/setIntervalPolyfill.js +26 -0
- package/lib/module/runLoop/common/setIntervalPolyfill.js.map +1 -0
- package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js +10 -0
- package/lib/module/runLoop/uiRuntime/mockedRequestAnimationFrame.js.map +1 -0
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +71 -0
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -0
- package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js +32 -0
- package/lib/module/runLoop/uiRuntime/setTimeoutPolyfill.js.map +1 -0
- package/lib/module/runLoop/workletRuntime/index.js +19 -0
- package/lib/module/runLoop/workletRuntime/index.js.map +1 -0
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js +11 -0
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +1 -0
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +48 -0
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -0
- package/lib/module/runLoop/workletRuntime/setTimeout.js +28 -0
- package/lib/module/runLoop/workletRuntime/setTimeout.js.map +1 -0
- package/lib/module/runLoop/workletRuntime/taskQueue.js +37 -0
- package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -0
- package/lib/module/runtimeKind.js +92 -0
- package/lib/module/runtimeKind.js.map +1 -0
- package/lib/module/runtimes.js +36 -0
- package/lib/module/runtimes.js.map +1 -0
- package/lib/module/runtimes.native.js +379 -0
- package/lib/module/runtimes.native.js.map +1 -0
- package/lib/module/specs/NativeWorkletsModule.js +5 -0
- package/lib/module/specs/NativeWorkletsModule.js.map +1 -0
- package/lib/module/specs/index.js +10 -0
- package/lib/module/specs/index.js.map +1 -0
- package/lib/module/threads.js +60 -0
- package/lib/module/threads.js.map +1 -0
- package/lib/module/threads.native.js +295 -0
- package/lib/module/threads.native.js.map +1 -0
- package/lib/module/types.js +5 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/workletFunction.js +36 -0
- package/lib/module/workletFunction.js.map +1 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.d.ts +3 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts +3 -0
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +59 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
- package/lib/typescript/bundleMode/metroOverrides.native.d.ts +9 -0
- package/lib/typescript/bundleMode/metroOverrides.native.d.ts.map +1 -0
- package/lib/typescript/bundleMode/network.native.d.ts +7 -0
- package/lib/typescript/bundleMode/network.native.d.ts.map +1 -0
- package/lib/typescript/debug/bundleMode.d.ts +2 -0
- package/lib/typescript/debug/bundleMode.d.ts.map +1 -0
- package/lib/typescript/debug/bundleMode.native.d.ts +2 -0
- package/lib/typescript/debug/bundleMode.native.d.ts.map +1 -0
- package/lib/typescript/debug/checkCppVersion.d.ts +3 -0
- package/lib/typescript/debug/checkCppVersion.d.ts.map +1 -0
- package/lib/typescript/debug/errors.native.d.ts +13 -0
- package/lib/typescript/debug/errors.native.d.ts.map +1 -0
- package/lib/typescript/debug/jsVersion.d.ts +7 -0
- package/lib/typescript/debug/jsVersion.d.ts.map +1 -0
- package/lib/typescript/debug/logger.d.ts +5 -0
- package/lib/typescript/debug/logger.d.ts.map +1 -0
- package/lib/typescript/debug/slowAnimations.d.ts +2 -0
- package/lib/typescript/debug/slowAnimations.d.ts.map +1 -0
- package/lib/typescript/debug/slowAnimations.native.d.ts +11 -0
- package/lib/typescript/debug/slowAnimations.native.d.ts.map +1 -0
- package/lib/typescript/deprecated.d.ts +19 -0
- package/lib/typescript/deprecated.d.ts.map +1 -0
- package/lib/typescript/featureFlags/featureFlags.d.ts +5 -0
- package/lib/typescript/featureFlags/featureFlags.d.ts.map +1 -0
- package/lib/typescript/featureFlags/featureFlags.native.d.ts +6 -0
- package/lib/typescript/featureFlags/featureFlags.native.d.ts.map +1 -0
- package/lib/typescript/featureFlags/types.d.ts +23 -0
- package/lib/typescript/featureFlags/types.d.ts.map +1 -0
- package/lib/typescript/guardImplementation.native.d.ts +3 -0
- package/lib/typescript/guardImplementation.native.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +19 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/initializers/initializers.d.ts +2 -0
- package/lib/typescript/initializers/initializers.d.ts.map +1 -0
- package/lib/typescript/initializers/initializers.native.d.ts +19 -0
- package/lib/typescript/initializers/initializers.native.d.ts.map +1 -0
- package/lib/typescript/memory/bundleUnpacker.native.d.ts +7 -0
- package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/customSerializableUnpacker.native.d.ts +3 -0
- package/lib/typescript/memory/customSerializableUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/isShareable.d.ts +3 -0
- package/lib/typescript/memory/isShareable.d.ts.map +1 -0
- package/lib/typescript/memory/isSynchronizable.d.ts +3 -0
- package/lib/typescript/memory/isSynchronizable.d.ts.map +1 -0
- package/lib/typescript/memory/remoteFunctionUnpacker.native.d.ts +3 -0
- package/lib/typescript/memory/remoteFunctionUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/serializable.d.ts +7 -0
- package/lib/typescript/memory/serializable.d.ts.map +1 -0
- package/lib/typescript/memory/serializable.native.d.ts +37 -0
- package/lib/typescript/memory/serializable.native.d.ts.map +1 -0
- package/lib/typescript/memory/serializableMappingCache.d.ts +6 -0
- package/lib/typescript/memory/serializableMappingCache.d.ts.map +1 -0
- package/lib/typescript/memory/serializableMappingCache.native.d.ts +13 -0
- package/lib/typescript/memory/serializableMappingCache.native.d.ts.map +1 -0
- package/lib/typescript/memory/shareable.d.ts +15 -0
- package/lib/typescript/memory/shareable.d.ts.map +1 -0
- package/lib/typescript/memory/shareable.native.d.ts +15 -0
- package/lib/typescript/memory/shareable.native.d.ts.map +1 -0
- package/lib/typescript/memory/shareableGuestUnpacker.native.d.ts +4 -0
- package/lib/typescript/memory/shareableGuestUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/shareableHostUnpacker.native.d.ts +4 -0
- package/lib/typescript/memory/shareableHostUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/synchronizable.d.ts +3 -0
- package/lib/typescript/memory/synchronizable.d.ts.map +1 -0
- package/lib/typescript/memory/synchronizable.native.d.ts +3 -0
- package/lib/typescript/memory/synchronizable.native.d.ts.map +1 -0
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts +4 -0
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/memory/types.d.ts +136 -0
- package/lib/typescript/memory/types.d.ts.map +1 -0
- package/lib/typescript/memory/valueUnpacker.native.d.ts +7 -0
- package/lib/typescript/memory/valueUnpacker.native.d.ts.map +1 -0
- package/lib/typescript/mock.d.ts +2 -0
- package/lib/typescript/mock.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/platformChecker.d.ts +2 -0
- package/lib/typescript/platformChecker.d.ts.map +1 -0
- package/lib/typescript/platformChecker.native.d.ts +2 -0
- package/lib/typescript/platformChecker.native.d.ts.map +1 -0
- package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts +2 -0
- package/lib/typescript/runLoop/common/setImmediatePolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts +2 -0
- package/lib/typescript/runLoop/common/setIntervalPolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts +6 -0
- package/lib/typescript/runLoop/uiRuntime/mockedRequestAnimationFrame.d.ts.map +1 -0
- package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts +2 -0
- package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -0
- package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts +2 -0
- package/lib/typescript/runLoop/uiRuntime/setTimeoutPolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/workletRuntime/index.d.ts +2 -0
- package/lib/typescript/runLoop/workletRuntime/index.d.ts.map +1 -0
- package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts +2 -0
- package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +1 -0
- package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts +2 -0
- package/lib/typescript/runLoop/workletRuntime/requestAnimationFramePolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts +2 -0
- package/lib/typescript/runLoop/workletRuntime/setTimeout.d.ts.map +1 -0
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +10 -0
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -0
- package/lib/typescript/runtimeKind.d.ts +56 -0
- package/lib/typescript/runtimeKind.d.ts.map +1 -0
- package/lib/typescript/runtimes.d.ts +15 -0
- package/lib/typescript/runtimes.d.ts.map +1 -0
- package/lib/typescript/runtimes.native.d.ts +155 -0
- package/lib/typescript/runtimes.native.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +9 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
- package/lib/typescript/specs/index.d.ts +3 -0
- package/lib/typescript/specs/index.d.ts.map +1 -0
- package/lib/typescript/threads.d.ts +8 -0
- package/lib/typescript/threads.d.ts.map +1 -0
- package/lib/typescript/threads.native.d.ts +125 -0
- package/lib/typescript/threads.native.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +136 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/workletFunction.d.ts +26 -0
- package/lib/typescript/workletFunction.d.ts.map +1 -0
- package/package.json +220 -0
- package/plugin/index.d.ts +168 -0
- package/plugin/index.js +2188 -0
- package/scripts/validate-react-native-version.js +43 -0
- package/scripts/worklets_utils.rb +94 -0
- package/src/WorkletsModule/NativeWorklets.native.ts +461 -0
- package/src/WorkletsModule/NativeWorklets.ts +5 -0
- package/src/WorkletsModule/workletsModuleProxy.ts +247 -0
- package/src/bundleMode/metroOverrides.native.ts +33 -0
- package/src/bundleMode/network.native.ts +63 -0
- package/src/debug/bundleMode.native.ts +18 -0
- package/src/debug/bundleMode.ts +5 -0
- package/src/debug/checkCppVersion.ts +34 -0
- package/src/debug/errors.native.ts +74 -0
- package/src/debug/jsVersion.ts +8 -0
- package/src/debug/logger.ts +16 -0
- package/src/debug/slowAnimations.native.ts +15 -0
- package/src/debug/slowAnimations.ts +6 -0
- package/src/deprecated.ts +38 -0
- package/src/featureFlags/featureFlags.native.ts +70 -0
- package/src/featureFlags/featureFlags.ts +20 -0
- package/src/featureFlags/staticFlags.json +6 -0
- package/src/featureFlags/types.ts +32 -0
- package/src/guardImplementation.native.ts +26 -0
- package/src/index.ts +95 -0
- package/src/initializers/initializers.native.ts +218 -0
- package/src/initializers/initializers.ts +24 -0
- package/src/memory/bundleUnpacker.native.ts +59 -0
- package/src/memory/customSerializableUnpacker.native.ts +30 -0
- package/src/memory/isShareable.ts +16 -0
- package/src/memory/isSynchronizable.ts +14 -0
- package/src/memory/remoteFunctionUnpacker.native.ts +27 -0
- package/src/memory/serializable.native.ts +889 -0
- package/src/memory/serializable.ts +36 -0
- package/src/memory/serializableMappingCache.native.ts +37 -0
- package/src/memory/serializableMappingCache.ts +12 -0
- package/src/memory/shareable.native.ts +68 -0
- package/src/memory/shareable.ts +27 -0
- package/src/memory/shareableGuestUnpacker.native.ts +168 -0
- package/src/memory/shareableHostUnpacker.native.ts +31 -0
- package/src/memory/synchronizable.native.ts +17 -0
- package/src/memory/synchronizable.ts +9 -0
- package/src/memory/synchronizableUnpacker.native.ts +65 -0
- package/src/memory/types.ts +191 -0
- package/src/memory/valueUnpacker.native.ts +79 -0
- package/src/mock.ts +111 -0
- package/src/platformChecker.native.ts +3 -0
- package/src/platformChecker.ts +4 -0
- package/src/privateGlobals.d.ts +127 -0
- package/src/runLoop/common/setImmediatePolyfill.ts +20 -0
- package/src/runLoop/common/setIntervalPolyfill.ts +38 -0
- package/src/runLoop/uiRuntime/mockedRequestAnimationFrame.ts +11 -0
- package/src/runLoop/uiRuntime/requestAnimationFrame.ts +87 -0
- package/src/runLoop/uiRuntime/setTimeoutPolyfill.ts +40 -0
- package/src/runLoop/workletRuntime/index.ts +18 -0
- package/src/runLoop/workletRuntime/queueMicrotask.ts +13 -0
- package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +61 -0
- package/src/runLoop/workletRuntime/setTimeout.ts +37 -0
- package/src/runLoop/workletRuntime/taskQueue.ts +44 -0
- package/src/runtimeKind.ts +85 -0
- package/src/runtimes.native.ts +572 -0
- package/src/runtimes.ts +107 -0
- package/src/specs/NativeWorkletsModule.ts +11 -0
- package/src/specs/index.ts +13 -0
- package/src/threads.native.ts +408 -0
- package/src/threads.ts +110 -0
- package/src/types.ts +164 -0
- package/src/workletFunction.ts +41 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { ValueUnpacker, WorkletFunction } from '../types';
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
var evalWithSourceMap:
|
|
7
|
+
| ((js: string, sourceURL: string, sourceMap: string) => () => unknown)
|
|
8
|
+
| undefined;
|
|
9
|
+
var evalWithSourceUrl:
|
|
10
|
+
| ((js: string, sourceURL: string) => () => unknown)
|
|
11
|
+
| undefined;
|
|
12
|
+
var evalBytecode: ((bytecode: ArrayBuffer) => () => unknown) | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function installValueUnpacker() {
|
|
16
|
+
'worklet';
|
|
17
|
+
'no-worklet-closure';
|
|
18
|
+
const workletsCache = new Map<number, () => unknown>();
|
|
19
|
+
const handleCache = new WeakMap<object, unknown>();
|
|
20
|
+
|
|
21
|
+
function valueUnpacker(objectToUnpack: ObjectToUnpack): unknown {
|
|
22
|
+
const workletHash = objectToUnpack.__workletHash;
|
|
23
|
+
if (workletHash !== undefined) {
|
|
24
|
+
let workletFun = workletsCache.get(workletHash);
|
|
25
|
+
if (workletFun === undefined) {
|
|
26
|
+
const initData = objectToUnpack.__initData;
|
|
27
|
+
if (initData!.bytecode !== undefined) {
|
|
28
|
+
workletFun = globalThis.evalBytecode!(initData!.bytecode);
|
|
29
|
+
} else if (globalThis.evalWithSourceMap && initData!.sourceMap) {
|
|
30
|
+
// if the runtime (hermes only for now) supports loading source maps
|
|
31
|
+
// we want to use the proper filename for the location as it guarantees
|
|
32
|
+
// that debugger understands and loads the source code of the file where
|
|
33
|
+
// the worklet is defined.
|
|
34
|
+
workletFun = globalThis.evalWithSourceMap(
|
|
35
|
+
initData!.code!,
|
|
36
|
+
initData!.location!,
|
|
37
|
+
initData!.sourceMap
|
|
38
|
+
);
|
|
39
|
+
} else if (globalThis.evalWithSourceUrl) {
|
|
40
|
+
// if the runtime doesn't support loading source maps, in dev mode we
|
|
41
|
+
// can pass source url when evaluating the worklet. Now, instead of using
|
|
42
|
+
// the actual file location we use worklet hash, as it the allows us to
|
|
43
|
+
// properly symbolicate traces (see errors.ts for details)
|
|
44
|
+
workletFun = globalThis.evalWithSourceUrl(
|
|
45
|
+
initData!.code!,
|
|
46
|
+
`worklet_${workletHash}`
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
// in release we use the regular eval to save on JSI calls
|
|
50
|
+
// eslint-disable-next-line no-eval
|
|
51
|
+
workletFun = eval(initData!.code!);
|
|
52
|
+
}
|
|
53
|
+
workletsCache.set(workletHash, workletFun!);
|
|
54
|
+
}
|
|
55
|
+
const functionInstance = workletFun!.bind(objectToUnpack);
|
|
56
|
+
objectToUnpack._recur = functionInstance;
|
|
57
|
+
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
|
+
} else {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`[Worklets] Data type not recognized by value unpacker: "${globalThis._toString(
|
|
68
|
+
objectToUnpack
|
|
69
|
+
)}".`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
globalThis.__valueUnpacker = valueUnpacker as ValueUnpacker;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface ObjectToUnpack extends WorkletFunction {
|
|
78
|
+
_recur: unknown;
|
|
79
|
+
}
|
package/src/mock.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { mockedRequestAnimationFrame } from './runLoop/uiRuntime/mockedRequestAnimationFrame';
|
|
4
|
+
import { RuntimeKind } from './runtimeKind';
|
|
5
|
+
import { isWorkletFunction } from './workletFunction';
|
|
6
|
+
|
|
7
|
+
const NOOP = () => {};
|
|
8
|
+
const NOOP_FACTORY = () => NOOP;
|
|
9
|
+
const ID = <TValue>(value: TValue) => value;
|
|
10
|
+
const IMMEDIATE_CALLBACK_INVOCATION = <TCallback>(callback: () => TCallback) =>
|
|
11
|
+
callback();
|
|
12
|
+
|
|
13
|
+
globalThis._WORKLET = false;
|
|
14
|
+
globalThis.__RUNTIME_KIND = RuntimeKind.ReactNative;
|
|
15
|
+
globalThis._log = console.log;
|
|
16
|
+
globalThis._getAnimationTimestamp = () => performance.now();
|
|
17
|
+
// requestAnimationFrame react-native jest's setup is incorrect as it polyfills
|
|
18
|
+
// the method directly using setTimeout, therefore the callback doesn't get the
|
|
19
|
+
// expected timestamp as the only argument.
|
|
20
|
+
// We override this setup here to make sure that callbacks get the proper timestamps
|
|
21
|
+
// when executed. For non-jest environments we define requestAnimationFrame in setupRequestAnimationFrame
|
|
22
|
+
// @ts-ignore TypeScript uses Node definition for rAF, setTimeout, etc which returns a Timeout object rather than a number
|
|
23
|
+
globalThis.requestAnimationFrame = mockedRequestAnimationFrame;
|
|
24
|
+
|
|
25
|
+
const WorkletAPI = {
|
|
26
|
+
isShareableRef: () => true,
|
|
27
|
+
makeShareable: ID,
|
|
28
|
+
makeShareableCloneOnUIRecursive: ID,
|
|
29
|
+
makeShareableCloneRecursive: ID,
|
|
30
|
+
shareableMappingCache: new Map(),
|
|
31
|
+
getStaticFeatureFlag: () => false,
|
|
32
|
+
setDynamicFeatureFlag: NOOP,
|
|
33
|
+
isSynchronizable: () => false,
|
|
34
|
+
getRuntimeKind: () => RuntimeKind.ReactNative,
|
|
35
|
+
RuntimeKind: RuntimeKind,
|
|
36
|
+
createWorkletRuntime: NOOP_FACTORY,
|
|
37
|
+
runOnRuntime: ID,
|
|
38
|
+
runOnRuntimeAsync<Args extends unknown[], ReturnValue>(
|
|
39
|
+
_workletRuntime: unknown,
|
|
40
|
+
worklet: (...args: Args) => ReturnValue,
|
|
41
|
+
...args: Args
|
|
42
|
+
): Promise<ReturnValue> {
|
|
43
|
+
return WorkletAPI.runOnUIAsync(worklet, ...args);
|
|
44
|
+
},
|
|
45
|
+
scheduleOnRuntime: IMMEDIATE_CALLBACK_INVOCATION,
|
|
46
|
+
createSerializable: ID,
|
|
47
|
+
isSerializableRef: ID,
|
|
48
|
+
serializableMappingCache: new Map(),
|
|
49
|
+
createSynchronizable: ID,
|
|
50
|
+
callMicrotasks: NOOP,
|
|
51
|
+
executeOnUIRuntimeSync: ID,
|
|
52
|
+
runOnJS<Args extends unknown[], ReturnValue>(
|
|
53
|
+
fun: (...args: Args) => ReturnValue
|
|
54
|
+
): (...args: Args) => void {
|
|
55
|
+
return (...args) =>
|
|
56
|
+
queueMicrotask(
|
|
57
|
+
args.length
|
|
58
|
+
? () => (fun as (...args: Args) => ReturnValue)(...args)
|
|
59
|
+
: (fun as () => ReturnValue)
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
runOnUI<Args extends unknown[], ReturnValue>(
|
|
63
|
+
worklet: (...args: Args) => ReturnValue
|
|
64
|
+
): (...args: Args) => void {
|
|
65
|
+
return (...args) => {
|
|
66
|
+
// Mocking time in Jest is tricky as both requestAnimationFrame and queueMicrotask
|
|
67
|
+
// callbacks run on the same queue and can be interleaved. There is no way
|
|
68
|
+
// to flush particular queue in Jest and the only control over mocked timers
|
|
69
|
+
// is by using jest.advanceTimersByTime() method which advances all types
|
|
70
|
+
// of timers including immediate and animation callbacks. Ideally we'd like
|
|
71
|
+
// to have some way here to schedule work along with React updates, but
|
|
72
|
+
// that's not possible, and hence in Jest environment instead of using scheduling
|
|
73
|
+
// mechanism we just schedule the work ommiting the queue. This is ok for the
|
|
74
|
+
// uses that we currently have but may not be ok for future tests that we write.
|
|
75
|
+
mockedRequestAnimationFrame(() => {
|
|
76
|
+
worklet(...args);
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
runOnUIAsync<Args extends unknown[], ReturnValue>(
|
|
81
|
+
worklet: (...args: Args) => ReturnValue,
|
|
82
|
+
...args: Args
|
|
83
|
+
): Promise<ReturnValue> {
|
|
84
|
+
return new Promise<ReturnValue>((resolve) => {
|
|
85
|
+
mockedRequestAnimationFrame(() => {
|
|
86
|
+
const result = worklet(...args);
|
|
87
|
+
resolve(result);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
runOnUISync: IMMEDIATE_CALLBACK_INVOCATION,
|
|
92
|
+
scheduleOnRN<Args extends unknown[], ReturnValue>(
|
|
93
|
+
fun: (...args: Args) => ReturnValue,
|
|
94
|
+
...args: Args
|
|
95
|
+
): void {
|
|
96
|
+
WorkletAPI.runOnJS(fun)(...args);
|
|
97
|
+
},
|
|
98
|
+
scheduleOnUI<Args extends unknown[], ReturnValue>(
|
|
99
|
+
worklet: (...args: Args) => ReturnValue,
|
|
100
|
+
...args: Args
|
|
101
|
+
): void {
|
|
102
|
+
WorkletAPI.runOnUI(worklet)(...args);
|
|
103
|
+
},
|
|
104
|
+
isWorkletFunction: isWorkletFunction,
|
|
105
|
+
WorkletsModule: {},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
module.exports = {
|
|
109
|
+
__esModule: true,
|
|
110
|
+
...WorkletAPI,
|
|
111
|
+
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
// This file works by accident - currently Builder Bob doesn't move `.d.ts` files to output types.
|
|
5
|
+
// If it ever breaks, we should address it so we'd not pollute the user's global namespace.
|
|
6
|
+
import type { reportFatalRemoteError } from './debug/errors';
|
|
7
|
+
import type { CustomSerializableUnpacker } from './memory/customSerializableUnpacker';
|
|
8
|
+
import type { RemoteFunctionUnpacker } from './memory/remoteFunctionUnpacker';
|
|
9
|
+
import type { makeShareableCloneOnUIRecursive } from './memory/serializable';
|
|
10
|
+
import type { ShareableGuestUnpacker } from './memory/shareableGuestUnpacker';
|
|
11
|
+
import type { ShareableHostUnpacker } from './memory/shareableHostUnpacker';
|
|
12
|
+
import type { SynchronizableUnpacker } from './memory/synchronizableUnpacker';
|
|
13
|
+
import type { CustomSerializationRegistry } from './memory/types';
|
|
14
|
+
import type { Queue } from './runLoop/workletRuntime/taskQueue';
|
|
15
|
+
import type { ValueUnpacker } from './types';
|
|
16
|
+
import type { WorkletsModuleProxy } from './WorkletsModule/workletsModuleProxy';
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
/** The only runtime-available require method is `__r` defined by Metro. */
|
|
20
|
+
var __r: ((moduleId: number) => Record<string, unknown>) &
|
|
21
|
+
Record<string, unknown>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The name of the current runtime, used in debugging.
|
|
25
|
+
*
|
|
26
|
+
* - "RN" for the RN Runtime.
|
|
27
|
+
* - "UI" for the UI Runtime.
|
|
28
|
+
* - A custom name for Worker Runtimes.
|
|
29
|
+
*/
|
|
30
|
+
var __RUNTIME_NAME: string;
|
|
31
|
+
|
|
32
|
+
var _toString: (value: unknown) => string;
|
|
33
|
+
var __workletsModuleProxy: WorkletsModuleProxy;
|
|
34
|
+
var _WORKLETS_BUNDLE_MODE_ENABLED: boolean | undefined;
|
|
35
|
+
var _WORKLETS_VERSION_CPP: string | undefined;
|
|
36
|
+
var _WORKLETS_VERSION_JS: string | undefined;
|
|
37
|
+
var _createSerializableString: (value: string) => FlatSerializableRef<string>;
|
|
38
|
+
var _createSerializableNumber: (value: number) => FlatSerializableRef<number>;
|
|
39
|
+
var _createSerializableBoolean: (
|
|
40
|
+
value: boolean
|
|
41
|
+
) => FlatSerializableRef<boolean>;
|
|
42
|
+
var _createSerializableBigInt: (value: bigint) => FlatSerializableRef<bigint>;
|
|
43
|
+
var _createSerializableUndefined: () => FlatSerializableRef<undefined>;
|
|
44
|
+
var _createSerializableNull: () => FlatSerializableRef<null>;
|
|
45
|
+
var _createSerializableObject: <T extends object>(
|
|
46
|
+
value: T,
|
|
47
|
+
shouldRetainRemote: boolean,
|
|
48
|
+
nativeStateSource?: object
|
|
49
|
+
) => FlatSerializableRef<T>;
|
|
50
|
+
var _createSerializableHostObject: <T extends object>(
|
|
51
|
+
value: T
|
|
52
|
+
) => FlatSerializableRef<T>;
|
|
53
|
+
var _createSerializableWorklet: (
|
|
54
|
+
value: object,
|
|
55
|
+
shouldPersistRemote: boolean
|
|
56
|
+
) => FlatSerializableRef<object>;
|
|
57
|
+
var _createSerializableArray: (
|
|
58
|
+
value: unknown[]
|
|
59
|
+
) => FlatSerializableRef<unknown[]>;
|
|
60
|
+
var _createSerializableInitializer: (
|
|
61
|
+
value: object
|
|
62
|
+
) => FlatSerializableRef<object>;
|
|
63
|
+
var _createSerializableSynchronizable: (
|
|
64
|
+
value: object
|
|
65
|
+
) => FlatShareableRef<object>;
|
|
66
|
+
var __serializer: typeof makeShareableCloneOnUIRecursive;
|
|
67
|
+
var __callMicrotasks: () => void;
|
|
68
|
+
/** Available only on the UI Runtime */
|
|
69
|
+
var __nativeRequestAnimationFrame: (
|
|
70
|
+
callback: (timestamp: number) => void
|
|
71
|
+
) => void;
|
|
72
|
+
/** Available only on RN Runtime */
|
|
73
|
+
var __reportFatalRemoteError: typeof reportFatalRemoteError | undefined;
|
|
74
|
+
var __valueUnpacker: ValueUnpacker;
|
|
75
|
+
var __synchronizableUnpacker: SynchronizableUnpacker;
|
|
76
|
+
var __customSerializationRegistry: CustomSerializationRegistry;
|
|
77
|
+
var __customSerializableUnpacker: CustomSerializableUnpacker;
|
|
78
|
+
var __remoteFunctionUnpacker: RemoteFunctionUnpacker;
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Kept for backwards compatibility. Remove it after support for
|
|
81
|
+
* Reanimated 4.3 is dropped. Reanimated uses it to handle event updates
|
|
82
|
+
* synchronously.
|
|
83
|
+
*/
|
|
84
|
+
var __flushAnimationFrame: (timestamp: number) => void;
|
|
85
|
+
var __frameTimestamp: number | undefined;
|
|
86
|
+
var _log: (value: unknown) => void;
|
|
87
|
+
var _startProfiling: (meanHzFreq?: number) => void;
|
|
88
|
+
var _stopProfiling: () => string;
|
|
89
|
+
var _beginSection: (name: string) => void;
|
|
90
|
+
var _endSection: () => void;
|
|
91
|
+
var _getAnimationTimestamp: () => number;
|
|
92
|
+
var _scheduleOnRuntime: (
|
|
93
|
+
runtime: WorkletRuntime,
|
|
94
|
+
worklet: SerializableRef<() => void>
|
|
95
|
+
) => void;
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Kept for backwards compatibility. Remove it after support for
|
|
98
|
+
* Reanimated 4.3 is dropped. Reanimated uses it to handle event updates
|
|
99
|
+
* synchronously.
|
|
100
|
+
*/
|
|
101
|
+
var _microtaskQueueFinalizers: (() => void)[];
|
|
102
|
+
var _scheduleTimeoutCallback: (delay: number, handlerId: number) => void;
|
|
103
|
+
var __runTimeoutCallback: (handlerId: number) => void;
|
|
104
|
+
var _taskQueue: Queue;
|
|
105
|
+
/** Only in Debug builds. */
|
|
106
|
+
var __hasNativeState: (value: object) => boolean;
|
|
107
|
+
/** Only in Debug builds. */
|
|
108
|
+
var __isHostObject: (value: object) => boolean;
|
|
109
|
+
var __shareableHostUnpacker: ShareableHostUnpacker<unknown, unknown, unknown>;
|
|
110
|
+
var __shareableGuestUnpacker: ShareableGuestUnpacker<
|
|
111
|
+
unknown,
|
|
112
|
+
unknown,
|
|
113
|
+
unknown
|
|
114
|
+
>;
|
|
115
|
+
/** Only in Bundle Mode on Worklet Runtimes. */
|
|
116
|
+
var TurboModules: Map<string, unknown>;
|
|
117
|
+
/**
|
|
118
|
+
* Native logging hook installed by React Native on the RN Runtime and
|
|
119
|
+
* propagated to Worklet Runtimes in Bundle Mode. Level values match RN's
|
|
120
|
+
* `LOG_LEVELS`: 0 = trace, 1 = info, 2 = warn, 3 = error.
|
|
121
|
+
*/
|
|
122
|
+
var nativeLoggingHook: ((message: string, level: number) => void) | undefined;
|
|
123
|
+
interface NodeRequire {
|
|
124
|
+
resolveWeak(id: string): number;
|
|
125
|
+
getModules(): Map<number, unknown>;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function setupSetImmediate() {
|
|
4
|
+
'worklet';
|
|
5
|
+
|
|
6
|
+
const setImmediatePolyfill = (
|
|
7
|
+
callback: (...args: unknown[]) => void,
|
|
8
|
+
...args: unknown[]
|
|
9
|
+
) => {
|
|
10
|
+
return setTimeout(callback, 0, ...args);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const clearImmediatePolyfill = (immediateHandle: number) => {
|
|
14
|
+
clearTimeout(immediateHandle);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
globalThis.setImmediate =
|
|
18
|
+
setImmediatePolyfill as unknown as typeof setImmediate;
|
|
19
|
+
globalThis.clearImmediate = clearImmediatePolyfill as typeof clearImmediate;
|
|
20
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function setupSetInterval() {
|
|
4
|
+
'worklet';
|
|
5
|
+
|
|
6
|
+
const intervalHandleToTimeoutHandle: Map<number, number> = new Map();
|
|
7
|
+
|
|
8
|
+
const setIntervalPolyfill = (
|
|
9
|
+
callback: (...args: unknown[]) => void,
|
|
10
|
+
delay: number = 0,
|
|
11
|
+
...args: unknown[]
|
|
12
|
+
) => {
|
|
13
|
+
let intervalHandle = 0;
|
|
14
|
+
|
|
15
|
+
const repeatingCallback = () => {
|
|
16
|
+
const timeoutHandle = setTimeout(
|
|
17
|
+
repeatingCallback,
|
|
18
|
+
delay
|
|
19
|
+
) as unknown as number;
|
|
20
|
+
intervalHandleToTimeoutHandle.set(intervalHandle, timeoutHandle);
|
|
21
|
+
callback(...args);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
intervalHandle = setTimeout(repeatingCallback, delay) as unknown as number;
|
|
25
|
+
intervalHandleToTimeoutHandle.set(intervalHandle, intervalHandle);
|
|
26
|
+
|
|
27
|
+
return intervalHandle;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const clearIntervalPolyfill = (intervalHandle: number) => {
|
|
31
|
+
const timeoutHandle = intervalHandleToTimeoutHandle.get(intervalHandle);
|
|
32
|
+
clearTimeout(timeoutHandle);
|
|
33
|
+
intervalHandleToTimeoutHandle.delete(intervalHandle);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
globalThis.setInterval = setIntervalPolyfill as typeof setInterval;
|
|
37
|
+
globalThis.clearInterval = clearIntervalPolyfill as typeof clearInterval;
|
|
38
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is Jest implementation of `requestAnimationFrame` that is required by
|
|
5
|
+
* React Native for test purposes.
|
|
6
|
+
*/
|
|
7
|
+
export function mockedRequestAnimationFrame(
|
|
8
|
+
callback: (timestamp: number) => void
|
|
9
|
+
): ReturnType<typeof setTimeout> {
|
|
10
|
+
return setTimeout(() => callback(performance.now()), 0);
|
|
11
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function setupRequestAnimationFrame() {
|
|
4
|
+
'worklet';
|
|
5
|
+
const callMicrotasks = globalThis.__callMicrotasks;
|
|
6
|
+
|
|
7
|
+
let queuedCallbacks: ((timestamp: number) => void)[] = [];
|
|
8
|
+
let queuedCallbacksBegin = 0;
|
|
9
|
+
let queuedCallbacksEnd = 0;
|
|
10
|
+
|
|
11
|
+
let flushedCallbacks = queuedCallbacks;
|
|
12
|
+
let flushedCallbacksBegin = 0;
|
|
13
|
+
let flushedCallbacksEnd = 0;
|
|
14
|
+
|
|
15
|
+
let queuedFinalizers: (() => void)[] = [];
|
|
16
|
+
|
|
17
|
+
function executeQueue(timestamp: number) {
|
|
18
|
+
flushedCallbacks = queuedCallbacks;
|
|
19
|
+
queuedCallbacks = [];
|
|
20
|
+
|
|
21
|
+
flushedCallbacksBegin = queuedCallbacksBegin;
|
|
22
|
+
flushedCallbacksEnd = queuedCallbacksEnd;
|
|
23
|
+
queuedCallbacksBegin = queuedCallbacksEnd;
|
|
24
|
+
|
|
25
|
+
for (const callback of flushedCallbacks) {
|
|
26
|
+
callback(timestamp);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
flushedCallbacksBegin = flushedCallbacksEnd;
|
|
30
|
+
|
|
31
|
+
callMicrotasks();
|
|
32
|
+
|
|
33
|
+
const finalizers = queuedFinalizers;
|
|
34
|
+
queuedFinalizers = [];
|
|
35
|
+
for (const finalizer of finalizers) {
|
|
36
|
+
finalizer();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function requestAnimationFrame(
|
|
41
|
+
callback: (timestamp: number) => void
|
|
42
|
+
): number {
|
|
43
|
+
const handle = queuedCallbacksEnd++;
|
|
44
|
+
queuedCallbacks.push(callback);
|
|
45
|
+
return handle;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function cancelAnimationFrame(handle: number) {
|
|
49
|
+
if (handle < flushedCallbacksBegin || handle >= queuedCallbacksEnd) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (handle < flushedCallbacksEnd) {
|
|
54
|
+
flushedCallbacks[handle - flushedCallbacksBegin] = () => {};
|
|
55
|
+
} else {
|
|
56
|
+
queuedCallbacks[handle - queuedCallbacksBegin] = () => {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function nativeFlushQueue(timestamp: number) {
|
|
61
|
+
flushQueue(timestamp);
|
|
62
|
+
|
|
63
|
+
/* Schedule next frame */
|
|
64
|
+
globalThis.__nativeRequestAnimationFrame(nativeFlushQueue);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function flushQueue(timestamp: number) {
|
|
68
|
+
globalThis.__frameTimestamp = timestamp;
|
|
69
|
+
executeQueue(timestamp);
|
|
70
|
+
globalThis.__frameTimestamp = undefined;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
globalThis.requestAnimationFrame = requestAnimationFrame;
|
|
74
|
+
globalThis.cancelAnimationFrame =
|
|
75
|
+
cancelAnimationFrame as typeof globalThis.cancelAnimationFrame;
|
|
76
|
+
globalThis.requestAnimationFrameFinalizer = (callback: () => void) => {
|
|
77
|
+
queuedFinalizers.push(callback);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/* Start the loop */
|
|
81
|
+
globalThis.__nativeRequestAnimationFrame(nativeFlushQueue);
|
|
82
|
+
|
|
83
|
+
// TODO: Remove it after support for Reanimated 4.3 is dropped.
|
|
84
|
+
globalThis.__flushAnimationFrame = (eventTimestamp: number) => {
|
|
85
|
+
flushQueue(eventTimestamp);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function setupSetTimeout() {
|
|
4
|
+
'worklet';
|
|
5
|
+
|
|
6
|
+
const timeoutHandleToRafHandle: Map<number, number> = new Map();
|
|
7
|
+
|
|
8
|
+
const setTimeoutPolyfill = (
|
|
9
|
+
callback: (...args: unknown[]) => void,
|
|
10
|
+
delay: number = 0,
|
|
11
|
+
...args: unknown[]
|
|
12
|
+
) => {
|
|
13
|
+
const start = performance.now();
|
|
14
|
+
let timeoutHandle = 0;
|
|
15
|
+
|
|
16
|
+
const rafCallback = () => {
|
|
17
|
+
const now = performance.now();
|
|
18
|
+
if (now - start >= delay) {
|
|
19
|
+
callback(...args);
|
|
20
|
+
timeoutHandleToRafHandle.delete(timeoutHandle);
|
|
21
|
+
} else {
|
|
22
|
+
const rafHandle = requestAnimationFrame(rafCallback);
|
|
23
|
+
timeoutHandleToRafHandle.set(timeoutHandle, rafHandle);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
timeoutHandle = requestAnimationFrame(rafCallback);
|
|
28
|
+
timeoutHandleToRafHandle.set(timeoutHandle, timeoutHandle);
|
|
29
|
+
return timeoutHandle;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const clearTimeoutPolyfill = (timeoutHandle: number) => {
|
|
33
|
+
const rafHandle = timeoutHandleToRafHandle.get(timeoutHandle);
|
|
34
|
+
timeoutHandleToRafHandle.delete(timeoutHandle);
|
|
35
|
+
cancelAnimationFrame(rafHandle);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
globalThis.setTimeout = setTimeoutPolyfill as typeof setTimeout;
|
|
39
|
+
globalThis.clearTimeout = clearTimeoutPolyfill as typeof clearTimeout;
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { setupSetImmediate } from '../common/setImmediatePolyfill';
|
|
4
|
+
import { setupSetInterval } from '../common/setIntervalPolyfill';
|
|
5
|
+
import { setupQueueMicrotask } from './queueMicrotask';
|
|
6
|
+
import { setupRequestAnimationFrame } from './requestAnimationFramePolyfill';
|
|
7
|
+
import { setupSetTimeout } from './setTimeout';
|
|
8
|
+
import { setupTaskQueue } from './taskQueue';
|
|
9
|
+
|
|
10
|
+
export function setupRunLoop(animationQueuePollingRate: number) {
|
|
11
|
+
'worklet';
|
|
12
|
+
setupTaskQueue();
|
|
13
|
+
setupQueueMicrotask();
|
|
14
|
+
setupSetTimeout();
|
|
15
|
+
setupRequestAnimationFrame(animationQueuePollingRate);
|
|
16
|
+
setupSetImmediate();
|
|
17
|
+
setupSetInterval();
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { pushMicrotask } from './taskQueue';
|
|
4
|
+
|
|
5
|
+
export function setupQueueMicrotask() {
|
|
6
|
+
'worklet';
|
|
7
|
+
globalThis.queueMicrotask = function (
|
|
8
|
+
callback: (...args: unknown[]) => void,
|
|
9
|
+
...args: unknown[]
|
|
10
|
+
) {
|
|
11
|
+
pushMicrotask(() => callback(...args));
|
|
12
|
+
} as typeof queueMicrotask;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export function setupRequestAnimationFrame(animationQueuePollingRate: number) {
|
|
4
|
+
'worklet';
|
|
5
|
+
const timeoutInterval = animationQueuePollingRate;
|
|
6
|
+
|
|
7
|
+
let queuedCallbacks: ((timestamp: number) => void)[] = [];
|
|
8
|
+
let queuedCallbacksBegin = 0;
|
|
9
|
+
let queuedCallbacksEnd = 0;
|
|
10
|
+
|
|
11
|
+
let flushedCallbacks = queuedCallbacks;
|
|
12
|
+
let flushedCallbacksBegin = 0;
|
|
13
|
+
let flushedCallbacksEnd = 0;
|
|
14
|
+
|
|
15
|
+
let flushRequested = false;
|
|
16
|
+
|
|
17
|
+
function flushAnimationFrame() {
|
|
18
|
+
flushRequested = false;
|
|
19
|
+
const timestamp = performance.now();
|
|
20
|
+
|
|
21
|
+
flushedCallbacks = queuedCallbacks;
|
|
22
|
+
queuedCallbacks = [];
|
|
23
|
+
|
|
24
|
+
flushedCallbacksBegin = queuedCallbacksBegin;
|
|
25
|
+
flushedCallbacksEnd = queuedCallbacksEnd;
|
|
26
|
+
queuedCallbacksBegin = queuedCallbacksEnd;
|
|
27
|
+
|
|
28
|
+
for (const callback of flushedCallbacks) {
|
|
29
|
+
callback(timestamp);
|
|
30
|
+
globalThis.__callMicrotasks();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
flushedCallbacksBegin = flushedCallbacksEnd;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
globalThis.requestAnimationFrame = (
|
|
37
|
+
callback: (timestamp: number) => void
|
|
38
|
+
): number => {
|
|
39
|
+
const handle = queuedCallbacksEnd++;
|
|
40
|
+
|
|
41
|
+
queuedCallbacks.push(callback);
|
|
42
|
+
if (!flushRequested) {
|
|
43
|
+
flushRequested = true;
|
|
44
|
+
|
|
45
|
+
setTimeout(flushAnimationFrame, timeoutInterval);
|
|
46
|
+
}
|
|
47
|
+
return handle;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
globalThis.cancelAnimationFrame = ((handle: number) => {
|
|
51
|
+
if (handle < flushedCallbacksBegin || handle >= queuedCallbacksEnd) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (handle < flushedCallbacksEnd) {
|
|
56
|
+
flushedCallbacks[handle - flushedCallbacksBegin] = () => {};
|
|
57
|
+
} else {
|
|
58
|
+
queuedCallbacks[handle - queuedCallbacksBegin] = () => {};
|
|
59
|
+
}
|
|
60
|
+
}) as typeof globalThis.cancelAnimationFrame;
|
|
61
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { pushTask } from './taskQueue';
|
|
4
|
+
|
|
5
|
+
export function setupSetTimeout() {
|
|
6
|
+
'worklet';
|
|
7
|
+
|
|
8
|
+
const pendingHandlers: Set<number> = new Set();
|
|
9
|
+
let ID = 0;
|
|
10
|
+
|
|
11
|
+
const setTimeoutPolyfill = (
|
|
12
|
+
callback: (...args: unknown[]) => void,
|
|
13
|
+
delay: number = 0,
|
|
14
|
+
...args: unknown[]
|
|
15
|
+
) => {
|
|
16
|
+
const handlerId = ID++;
|
|
17
|
+
|
|
18
|
+
const timeoutCallback = () => {
|
|
19
|
+
if (!pendingHandlers.has(handlerId)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
callback(...args);
|
|
23
|
+
pendingHandlers.delete(handlerId);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
pendingHandlers.add(handlerId);
|
|
27
|
+
pushTask(timeoutCallback, handlerId, delay);
|
|
28
|
+
return handlerId;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const clearTimeoutPolyfill = (timeoutHandle: number) => {
|
|
32
|
+
pendingHandlers.delete(timeoutHandle);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
globalThis.setTimeout = setTimeoutPolyfill as typeof setTimeout;
|
|
36
|
+
globalThis.clearTimeout = clearTimeoutPolyfill as typeof clearTimeout;
|
|
37
|
+
}
|