@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,126 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/SharedItems/MemoryManager.h>
|
|
5
|
+
#include <worklets/SharedItems/Serializable.h>
|
|
6
|
+
#include <worklets/SharedItems/UnpackerLoader.h>
|
|
7
|
+
#include <worklets/Tools/RNRuntimeStatus.h>
|
|
8
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
9
|
+
#include <worklets/WorkletRuntime/BundleModeConfig.h>
|
|
10
|
+
#include <worklets/WorkletRuntime/RuntimeBindings.h>
|
|
11
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
12
|
+
#include <worklets/WorkletRuntime/RuntimeManager.h>
|
|
13
|
+
|
|
14
|
+
#include <memory>
|
|
15
|
+
#include <string>
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
namespace worklets {
|
|
20
|
+
|
|
21
|
+
class WorkletRuntime;
|
|
22
|
+
|
|
23
|
+
class JSIWorkletsModuleProxy : public std::enable_shared_from_this<JSIWorkletsModuleProxy> {
|
|
24
|
+
public:
|
|
25
|
+
explicit JSIWorkletsModuleProxy(
|
|
26
|
+
const bool isDevBundle,
|
|
27
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
28
|
+
const std::shared_ptr<UIScheduler> &uiScheduler,
|
|
29
|
+
const std::shared_ptr<MemoryManager> &memoryManager,
|
|
30
|
+
const std::shared_ptr<RuntimeManager> &runtimeManager,
|
|
31
|
+
const std::weak_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
32
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings,
|
|
33
|
+
const BundleModeConfig &bundleModeConfig,
|
|
34
|
+
const std::shared_ptr<UnpackerLoader> &unpackerLoader,
|
|
35
|
+
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus,
|
|
36
|
+
RuntimeData::RuntimeId hostRuntimeId)
|
|
37
|
+
: isDevBundle_(isDevBundle),
|
|
38
|
+
bundleModeConfig_(bundleModeConfig),
|
|
39
|
+
jsScheduler_(jsScheduler),
|
|
40
|
+
uiScheduler_(uiScheduler),
|
|
41
|
+
memoryManager_(memoryManager),
|
|
42
|
+
runtimeManager_(runtimeManager),
|
|
43
|
+
uiWorkletRuntime_(uiWorkletRuntime),
|
|
44
|
+
runtimeBindings_(runtimeBindings),
|
|
45
|
+
unpackerLoader_(unpackerLoader),
|
|
46
|
+
rnRuntimeStatus_(rnRuntimeStatus),
|
|
47
|
+
hostRuntimeId_(hostRuntimeId) {}
|
|
48
|
+
|
|
49
|
+
static std::shared_ptr<JSIWorkletsModuleProxy> createForNewRuntime(
|
|
50
|
+
const std::shared_ptr<const JSIWorkletsModuleProxy> &sourceProxy,
|
|
51
|
+
RuntimeData::RuntimeId hostRuntimeId) {
|
|
52
|
+
return std::make_shared<JSIWorkletsModuleProxy>(
|
|
53
|
+
sourceProxy->isDevBundle_,
|
|
54
|
+
sourceProxy->jsScheduler_,
|
|
55
|
+
sourceProxy->uiScheduler_,
|
|
56
|
+
sourceProxy->memoryManager_,
|
|
57
|
+
sourceProxy->runtimeManager_,
|
|
58
|
+
sourceProxy->uiWorkletRuntime_,
|
|
59
|
+
sourceProxy->runtimeBindings_,
|
|
60
|
+
sourceProxy->bundleModeConfig_,
|
|
61
|
+
sourceProxy->unpackerLoader_,
|
|
62
|
+
sourceProxy->rnRuntimeStatus_,
|
|
63
|
+
hostRuntimeId);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** No copy constructor to prevent making JSIWorkletsModuleProxy with wrong hostRuntimeId. */
|
|
67
|
+
JSIWorkletsModuleProxy(const JSIWorkletsModuleProxy &other) = delete;
|
|
68
|
+
|
|
69
|
+
[[nodiscard]]
|
|
70
|
+
jsi::Object toOptimizedObject(jsi::Runtime &rt) const;
|
|
71
|
+
|
|
72
|
+
[[nodiscard]] std::shared_ptr<JSScheduler> getJSScheduler() const {
|
|
73
|
+
return jsScheduler_;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
[[nodiscard]] std::shared_ptr<UIScheduler> getUIScheduler() const {
|
|
77
|
+
return uiScheduler_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
[[nodiscard]] bool isBundleModeEnabled() const {
|
|
81
|
+
return bundleModeConfig_.enabled;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
[[nodiscard]] bool isDevBundle() const {
|
|
85
|
+
return isDevBundle_;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
[[nodiscard]] std::shared_ptr<const ScriptBuffer> getScript() const {
|
|
89
|
+
return bundleModeConfig_.script;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
[[nodiscard]] std::string getSourceUrl() const {
|
|
93
|
+
return bundleModeConfig_.sourceURL;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
[[nodiscard]] std::shared_ptr<MemoryManager> getMemoryManager() const {
|
|
97
|
+
return memoryManager_;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[[nodiscard]] std::shared_ptr<RuntimeManager> getRuntimeManager() const {
|
|
101
|
+
return runtimeManager_;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
[[nodiscard]] std::shared_ptr<RuntimeBindings> getRuntimeBindings() const {
|
|
105
|
+
return runtimeBindings_;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[[nodiscard]] std::shared_ptr<UnpackerLoader> getUnpackerLoader() const {
|
|
109
|
+
return unpackerLoader_;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private:
|
|
113
|
+
const bool isDevBundle_;
|
|
114
|
+
const BundleModeConfig bundleModeConfig_;
|
|
115
|
+
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
116
|
+
const std::shared_ptr<UIScheduler> uiScheduler_;
|
|
117
|
+
const std::shared_ptr<MemoryManager> memoryManager_;
|
|
118
|
+
const std::shared_ptr<RuntimeManager> runtimeManager_;
|
|
119
|
+
const std::weak_ptr<WorkletRuntime> uiWorkletRuntime_;
|
|
120
|
+
const std::shared_ptr<RuntimeBindings> runtimeBindings_;
|
|
121
|
+
const std::shared_ptr<UnpackerLoader> unpackerLoader_;
|
|
122
|
+
const std::shared_ptr<RNRuntimeStatus> rnRuntimeStatus_;
|
|
123
|
+
const RuntimeData::RuntimeId hostRuntimeId_;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
} // namespace worklets
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#include <worklets/NativeModules/JSIWorkletsModuleProxy.h>
|
|
2
|
+
#include <worklets/NativeModules/WorkletsModuleProxy.h>
|
|
3
|
+
#include <worklets/RunLoop/AsyncQueueImpl.h>
|
|
4
|
+
#include <worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h>
|
|
5
|
+
#include <worklets/WorkletRuntime/RuntimeBindings.h>
|
|
6
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
7
|
+
#include <worklets/WorkletRuntime/UIRuntimeDecorator.h>
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
using namespace facebook;
|
|
13
|
+
|
|
14
|
+
namespace worklets {
|
|
15
|
+
|
|
16
|
+
bool isDevBundleFromRNRuntime(jsi::Runtime &rnRuntime) {
|
|
17
|
+
const auto rtDev = rnRuntime.global().getProperty(rnRuntime, "__DEV__");
|
|
18
|
+
return rtDev.isBool() && rtDev.asBool();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* This method is required outside of Bundle Mode to make sure we start creating
|
|
23
|
+
* Worklet Runtimes only after unpackers code was loaded from the RN Runtime.
|
|
24
|
+
*
|
|
25
|
+
* In Bundle Mode unpackers are installed during bundle evaluation instead.
|
|
26
|
+
*/
|
|
27
|
+
void WorkletsModuleProxy::start() {
|
|
28
|
+
/**
|
|
29
|
+
* We call additional `init` method here because
|
|
30
|
+
* JSIWorkletsModuleProxy needs a weak_ptr to the UI Runtime.
|
|
31
|
+
*/
|
|
32
|
+
const auto uiRuntimeProxy = JSIWorkletsModuleProxy::createForNewRuntime(rnRuntimeProxy_, RuntimeData::uiRuntimeId);
|
|
33
|
+
uiWorkletRuntime_->init(uiRuntimeProxy);
|
|
34
|
+
|
|
35
|
+
animationFrameBatchinator_ =
|
|
36
|
+
std::make_shared<AnimationFrameBatchinator>(uiWorkletRuntime_, runtimeBindings_->requestAnimationFrame);
|
|
37
|
+
|
|
38
|
+
UIRuntimeDecorator::decorate(
|
|
39
|
+
uiWorkletRuntime_->getJSIRuntime(), animationFrameBatchinator_->getJsiRequestAnimationFrame());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
WorkletsModuleProxy::WorkletsModuleProxy(
|
|
43
|
+
jsi::Runtime &rnRuntime,
|
|
44
|
+
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
45
|
+
const std::shared_ptr<UIScheduler> &uiScheduler,
|
|
46
|
+
std::function<bool()> &&isJavaScriptThread,
|
|
47
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings,
|
|
48
|
+
const BundleModeConfig &bundleModeConfig,
|
|
49
|
+
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus)
|
|
50
|
+
: isDevBundle_(isDevBundleFromRNRuntime(rnRuntime)),
|
|
51
|
+
jsScheduler_(std::make_shared<JSScheduler>(rnRuntime, jsCallInvoker, std::move(isJavaScriptThread))),
|
|
52
|
+
uiScheduler_(uiScheduler),
|
|
53
|
+
jsLogger_(std::make_shared<JSLogger>(jsScheduler_)),
|
|
54
|
+
runtimeBindings_(runtimeBindings),
|
|
55
|
+
bundleModeConfig_(bundleModeConfig),
|
|
56
|
+
memoryManager_(std::make_shared<MemoryManager>()),
|
|
57
|
+
runtimeManager_(std::make_shared<RuntimeManager>()),
|
|
58
|
+
unpackerLoader_(std::make_shared<UnpackerLoader>()),
|
|
59
|
+
rnRuntimeStatus_(rnRuntimeStatus),
|
|
60
|
+
uiWorkletRuntime_(runtimeManager_->createUninitializedUIRuntime(std::make_shared<AsyncQueueUI>(uiScheduler_))),
|
|
61
|
+
rnRuntimeProxy_(std::make_shared<JSIWorkletsModuleProxy>(
|
|
62
|
+
isDevBundle_,
|
|
63
|
+
jsScheduler_,
|
|
64
|
+
uiScheduler_,
|
|
65
|
+
memoryManager_,
|
|
66
|
+
runtimeManager_,
|
|
67
|
+
uiWorkletRuntime_,
|
|
68
|
+
runtimeBindings_,
|
|
69
|
+
bundleModeConfig_,
|
|
70
|
+
unpackerLoader_,
|
|
71
|
+
rnRuntimeStatus_,
|
|
72
|
+
RuntimeData::rnRuntimeId)) {
|
|
73
|
+
RNRuntimeWorkletDecorator::decorate(rnRuntime, rnRuntimeProxy_->toOptimizedObject(rnRuntime), jsLogger_);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
WorkletsModuleProxy::~WorkletsModuleProxy() {
|
|
77
|
+
animationFrameBatchinator_.reset();
|
|
78
|
+
uiWorkletRuntime_.reset();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
} // namespace worklets
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/AnimationFrameQueue/AnimationFrameBatchinator.h>
|
|
5
|
+
#include <worklets/NativeModules/JSIWorkletsModuleProxy.h>
|
|
6
|
+
#include <worklets/SharedItems/MemoryManager.h>
|
|
7
|
+
#include <worklets/SharedItems/UnpackerLoader.h>
|
|
8
|
+
#include <worklets/Tools/JSLogger.h>
|
|
9
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
10
|
+
#include <worklets/Tools/RNRuntimeStatus.h>
|
|
11
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
12
|
+
#include <worklets/Tools/SingleInstanceChecker.h>
|
|
13
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
14
|
+
#include <worklets/WorkletRuntime/BundleModeConfig.h>
|
|
15
|
+
#include <worklets/WorkletRuntime/RuntimeManager.h>
|
|
16
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
|
|
20
|
+
namespace worklets {
|
|
21
|
+
|
|
22
|
+
class WorkletsModuleProxy : public std::enable_shared_from_this<WorkletsModuleProxy> {
|
|
23
|
+
public:
|
|
24
|
+
void start();
|
|
25
|
+
|
|
26
|
+
explicit WorkletsModuleProxy(
|
|
27
|
+
jsi::Runtime &rnRuntime,
|
|
28
|
+
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
29
|
+
const std::shared_ptr<UIScheduler> &uiScheduler,
|
|
30
|
+
std::function<bool()> &&isJavaScriptQueue,
|
|
31
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings,
|
|
32
|
+
const BundleModeConfig &bundleModeConfig,
|
|
33
|
+
const std::shared_ptr<RNRuntimeStatus> &rnRuntimeStatus);
|
|
34
|
+
|
|
35
|
+
~WorkletsModuleProxy();
|
|
36
|
+
|
|
37
|
+
[[nodiscard]] inline std::shared_ptr<JSScheduler> getJSScheduler() const {
|
|
38
|
+
return jsScheduler_;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[[nodiscard]] inline std::shared_ptr<UIScheduler> getUIScheduler() const {
|
|
42
|
+
return uiScheduler_;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[[nodiscard]] inline std::shared_ptr<JSLogger> getJSLogger() const {
|
|
46
|
+
return jsLogger_;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[[nodiscard]] inline std::shared_ptr<WorkletRuntime> getUIWorkletRuntime() const {
|
|
50
|
+
return uiWorkletRuntime_;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[[nodiscard]] inline bool isDevBundle() const {
|
|
54
|
+
return isDevBundle_;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private:
|
|
58
|
+
const bool isDevBundle_;
|
|
59
|
+
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
60
|
+
const std::shared_ptr<UIScheduler> uiScheduler_;
|
|
61
|
+
const std::shared_ptr<JSLogger> jsLogger_;
|
|
62
|
+
const std::shared_ptr<RuntimeBindings> runtimeBindings_;
|
|
63
|
+
const BundleModeConfig bundleModeConfig_;
|
|
64
|
+
const std::shared_ptr<MemoryManager> memoryManager_;
|
|
65
|
+
const std::shared_ptr<RuntimeManager> runtimeManager_;
|
|
66
|
+
const std::shared_ptr<UnpackerLoader> unpackerLoader_;
|
|
67
|
+
const std::shared_ptr<RNRuntimeStatus> rnRuntimeStatus_;
|
|
68
|
+
std::shared_ptr<WorkletRuntime> uiWorkletRuntime_;
|
|
69
|
+
const std::shared_ptr<JSIWorkletsModuleProxy> rnRuntimeProxy_;
|
|
70
|
+
std::shared_ptr<AnimationFrameBatchinator> animationFrameBatchinator_;
|
|
71
|
+
#ifndef NDEBUG
|
|
72
|
+
SingleInstanceChecker<WorkletsModuleProxy> singleInstanceChecker_;
|
|
73
|
+
#endif // NDEBUG
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace worklets
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// EventHandlerRegistry was fully moved to Reanimated.
|
|
2
|
+
// This file is kept only for backwards compatibility with older versions of Reanimated.
|
|
3
|
+
|
|
4
|
+
#include <worklets/Registries/EventHandlerRegistry.h>
|
|
5
|
+
#include <worklets/Tools/WorkletEventHandler.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <utility>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
void EventHandlerRegistry::registerEventHandler(const std::shared_ptr<WorkletEventHandler> &eventHandler) {
|
|
15
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
16
|
+
const auto &eventName = eventHandler->getEventName();
|
|
17
|
+
auto handlerId = eventHandler->getHandlerId();
|
|
18
|
+
|
|
19
|
+
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
20
|
+
eventMappingsWithoutTag[eventName][handlerId] = eventHandler;
|
|
21
|
+
} else {
|
|
22
|
+
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
23
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
24
|
+
eventMappingsWithTag[eventHash][handlerId] = eventHandler;
|
|
25
|
+
}
|
|
26
|
+
eventHandlers[handlerId] = eventHandler;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void EventHandlerRegistry::unregisterEventHandler(const uint64_t id) {
|
|
30
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
31
|
+
auto handlerIt = eventHandlers.find(id);
|
|
32
|
+
if (handlerIt != eventHandlers.end()) {
|
|
33
|
+
const auto &eventHandler = handlerIt->second;
|
|
34
|
+
const auto &eventName = eventHandler->getEventName();
|
|
35
|
+
|
|
36
|
+
if (eventHandler->shouldIgnoreEmitterReactTag()) {
|
|
37
|
+
const auto eventMappingIt = eventMappingsWithoutTag.find(eventName);
|
|
38
|
+
auto &handlersMap = eventMappingIt->second;
|
|
39
|
+
handlersMap.erase(id);
|
|
40
|
+
if (handlersMap.empty()) {
|
|
41
|
+
eventMappingsWithoutTag.erase(eventMappingIt);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const auto emitterReactTag = eventHandler->getEmitterReactTag();
|
|
45
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
46
|
+
const auto eventMappingIt = eventMappingsWithTag.find(eventHash);
|
|
47
|
+
auto &handlersMap = eventMappingIt->second;
|
|
48
|
+
handlersMap.erase(id);
|
|
49
|
+
if (handlersMap.empty()) {
|
|
50
|
+
eventMappingsWithTag.erase(eventMappingIt);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
eventHandlers.erase(handlerIt);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void EventHandlerRegistry::processEvent(
|
|
58
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
59
|
+
const double eventTimestamp,
|
|
60
|
+
const std::string &eventName,
|
|
61
|
+
const int emitterReactTag,
|
|
62
|
+
const jsi::Value &eventPayload) {
|
|
63
|
+
std::vector<std::shared_ptr<WorkletEventHandler>> handlersForEvent;
|
|
64
|
+
{
|
|
65
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
66
|
+
auto handlersIt = eventMappingsWithoutTag.find(eventName);
|
|
67
|
+
if (handlersIt != eventMappingsWithoutTag.end()) {
|
|
68
|
+
for (const auto &handler : handlersIt->second) {
|
|
69
|
+
handlersForEvent.push_back(handler.second);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
73
|
+
auto handlersWithTagIt = eventMappingsWithTag.find(eventHash);
|
|
74
|
+
if (handlersWithTagIt != eventMappingsWithTag.end()) {
|
|
75
|
+
for (const auto &handler : handlersWithTagIt->second) {
|
|
76
|
+
handlersForEvent.push_back(handler.second);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
jsi::Runtime &rt = uiWorkletRuntime->getJSIRuntime();
|
|
82
|
+
eventPayload.asObject(rt).setProperty(rt, "eventName", jsi::String::createFromUtf8(rt, eventName));
|
|
83
|
+
for (const auto &handler : handlersForEvent) {
|
|
84
|
+
handler->process(uiWorkletRuntime, eventTimestamp, eventPayload);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
bool EventHandlerRegistry::isAnyHandlerWaitingForEvent(const std::string &eventName, const int emitterReactTag) {
|
|
89
|
+
const std::lock_guard<std::mutex> lock(instanceMutex);
|
|
90
|
+
const auto eventHash = std::make_pair(emitterReactTag, eventName);
|
|
91
|
+
auto it = eventMappingsWithTag.find(eventHash);
|
|
92
|
+
return it != eventMappingsWithTag.end() && !it->second.empty();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
} // namespace worklets
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// EventHandlerRegistry was fully moved to Reanimated.
|
|
2
|
+
// This file is kept only for backwards compatibility with older versions of Reanimated.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
7
|
+
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
|
|
10
|
+
#include <map>
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include <mutex>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <unordered_map>
|
|
15
|
+
#include <utility>
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
namespace worklets {
|
|
20
|
+
|
|
21
|
+
class WorkletEventHandler;
|
|
22
|
+
|
|
23
|
+
class EventHandlerRegistry {
|
|
24
|
+
std::map<std::pair<int, std::string>, std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>>
|
|
25
|
+
eventMappingsWithTag;
|
|
26
|
+
std::map<std::string, std::unordered_map<uint64_t, std::shared_ptr<WorkletEventHandler>>> eventMappingsWithoutTag;
|
|
27
|
+
std::map<uint64_t, std::shared_ptr<WorkletEventHandler>> eventHandlers;
|
|
28
|
+
std::mutex instanceMutex;
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
void registerEventHandler(const std::shared_ptr<WorkletEventHandler> &eventHandler);
|
|
32
|
+
void unregisterEventHandler(const uint64_t id);
|
|
33
|
+
|
|
34
|
+
void processEvent(
|
|
35
|
+
const std::shared_ptr<WorkletRuntime> &uiWorkletRuntime,
|
|
36
|
+
const double eventTimestamp,
|
|
37
|
+
const std::string &eventName,
|
|
38
|
+
const int emitterReactTag,
|
|
39
|
+
const jsi::Value &eventPayload);
|
|
40
|
+
|
|
41
|
+
bool isAnyHandlerWaitingForEvent(const std::string &eventName, const int emitterReactTag);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace worklets
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <react/debug/react_native_assert.h>
|
|
5
|
+
|
|
6
|
+
#include <set>
|
|
7
|
+
#include <shared_mutex>
|
|
8
|
+
#include <utility>
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
class WorkletRuntimeRegistry {
|
|
15
|
+
private:
|
|
16
|
+
static std::set<jsi::Runtime *> registry_;
|
|
17
|
+
static std::shared_mutex mutex_;
|
|
18
|
+
|
|
19
|
+
WorkletRuntimeRegistry() {}
|
|
20
|
+
|
|
21
|
+
static void registerRuntime(jsi::Runtime &runtime) {
|
|
22
|
+
std::lock_guard<std::shared_mutex> lock(mutex_);
|
|
23
|
+
registry_.insert(&runtime);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static void unregisterRuntime(jsi::Runtime &runtime) {
|
|
27
|
+
std::lock_guard<std::shared_mutex> lock(mutex_);
|
|
28
|
+
registry_.erase(&runtime);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
friend class WorkletRuntimeCollector;
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
template <typename TFn>
|
|
35
|
+
static void runWhileLocked(jsi::Runtime *runtime, TFn &&fn) {
|
|
36
|
+
react_native_assert(runtime != nullptr && "runtime is nullptr");
|
|
37
|
+
std::shared_lock<std::shared_mutex> lock(mutex_);
|
|
38
|
+
const bool isAlive = registry_.find(runtime) != registry_.end();
|
|
39
|
+
std::forward<TFn>(fn)(isAlive);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
} // namespace worklets
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
|
|
5
|
+
namespace worklets {
|
|
6
|
+
|
|
7
|
+
class AsyncQueue : public facebook::jsi::NativeState {
|
|
8
|
+
public:
|
|
9
|
+
~AsyncQueue() override = default;
|
|
10
|
+
|
|
11
|
+
virtual void push(std::function<void()> &&job) = 0;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
} // namespace worklets
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#include <worklets/RunLoop/AsyncQueueImpl.h>
|
|
2
|
+
|
|
3
|
+
#ifdef ANDROID
|
|
4
|
+
#include <fbjni/fbjni.h>
|
|
5
|
+
#endif // ANDROID
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <thread>
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
|
|
16
|
+
void AsyncQueueImpl::runLoop(const std::shared_ptr<AsyncQueueState> &state) {
|
|
17
|
+
while (state->running) {
|
|
18
|
+
std::unique_lock<std::mutex> lock(state->mutex);
|
|
19
|
+
state->cv.wait(lock, [state] { return !state->queue.empty() || !state->running; });
|
|
20
|
+
if (!state->running) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (state->queue.empty()) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
auto job = std::move(state->queue.front());
|
|
27
|
+
state->queue.pop();
|
|
28
|
+
lock.unlock();
|
|
29
|
+
job();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
AsyncQueueImpl::AsyncQueueImpl(const std::string &name) : state_(std::make_shared<AsyncQueueState>()) {
|
|
34
|
+
auto thread = std::thread([name, state = state_] {
|
|
35
|
+
#ifdef ANDROID
|
|
36
|
+
pthread_setname_np(pthread_self(), name.c_str());
|
|
37
|
+
jni::ThreadScope::WithClassLoader([state]() { AsyncQueueImpl::runLoop(state); });
|
|
38
|
+
#else
|
|
39
|
+
pthread_setname_np(name.c_str());
|
|
40
|
+
AsyncQueueImpl::runLoop(state);
|
|
41
|
+
#endif // ANDROID
|
|
42
|
+
});
|
|
43
|
+
thread.detach();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
AsyncQueueImpl::~AsyncQueueImpl() {
|
|
47
|
+
{
|
|
48
|
+
std::unique_lock<std::mutex> lock(state_->mutex);
|
|
49
|
+
state_->running = false;
|
|
50
|
+
state_->queue = {};
|
|
51
|
+
}
|
|
52
|
+
state_->cv.notify_all();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void AsyncQueueImpl::push(std::function<void()> &&job) {
|
|
56
|
+
{
|
|
57
|
+
std::unique_lock<std::mutex> lock(state_->mutex);
|
|
58
|
+
state_->queue.emplace(job);
|
|
59
|
+
}
|
|
60
|
+
state_->cv.notify_one();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
AsyncQueueUI::AsyncQueueUI(const std::shared_ptr<UIScheduler> &uiScheduler) : uiScheduler_(uiScheduler) {}
|
|
64
|
+
|
|
65
|
+
void AsyncQueueUI::push(std::function<void()> &&job) {
|
|
66
|
+
uiScheduler_->scheduleOnUI(std::move(job));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
} // namespace worklets
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/RunLoop/AsyncQueue.h>
|
|
5
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
6
|
+
|
|
7
|
+
#include <atomic>
|
|
8
|
+
#include <condition_variable>
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <queue>
|
|
11
|
+
#include <string>
|
|
12
|
+
|
|
13
|
+
namespace worklets {
|
|
14
|
+
|
|
15
|
+
struct AsyncQueueState {
|
|
16
|
+
std::atomic_bool running{true};
|
|
17
|
+
std::mutex mutex;
|
|
18
|
+
std::condition_variable cv;
|
|
19
|
+
std::queue<std::function<void()>> queue;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
class AsyncQueueImpl : public AsyncQueue {
|
|
23
|
+
public:
|
|
24
|
+
explicit AsyncQueueImpl(const std::string &name);
|
|
25
|
+
|
|
26
|
+
~AsyncQueueImpl() override;
|
|
27
|
+
|
|
28
|
+
void push(std::function<void()> &&job) override;
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
static void runLoop(const std::shared_ptr<AsyncQueueState> &state);
|
|
32
|
+
|
|
33
|
+
const std::shared_ptr<AsyncQueueState> state_;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
class AsyncQueueUI : public AsyncQueue {
|
|
37
|
+
public:
|
|
38
|
+
explicit AsyncQueueUI(const std::shared_ptr<UIScheduler> &uiScheduler);
|
|
39
|
+
|
|
40
|
+
~AsyncQueueUI() override = default;
|
|
41
|
+
|
|
42
|
+
void push(std::function<void()> &&job) override;
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
std::shared_ptr<UIScheduler> uiScheduler_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace worklets
|