@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,247 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
RemoteFunction,
|
|
5
|
+
SerializableRef,
|
|
6
|
+
SynchronizableRef,
|
|
7
|
+
} from '../memory/types';
|
|
8
|
+
import type { WorkletRuntime } from '../types';
|
|
9
|
+
|
|
10
|
+
/** Type of `__workletsModuleProxy` injected with JSI. */
|
|
11
|
+
export interface WorkletsModuleProxy {
|
|
12
|
+
loadUnpackersWithCode(
|
|
13
|
+
valueUnpackerCode: string,
|
|
14
|
+
valueUnpackerLocation: string,
|
|
15
|
+
valueUnpackerSourceMap: string,
|
|
16
|
+
synchronizableUnpackerCode: string,
|
|
17
|
+
synchronizableUnpackerLocation: string,
|
|
18
|
+
synchronizableUnpackerSourceMap: string,
|
|
19
|
+
customSerializableUnpackerCode: string,
|
|
20
|
+
customSerializableUnpackerLocation: string,
|
|
21
|
+
customSerializableUnpackerSourceMap: string,
|
|
22
|
+
shareableHostUnpackerCode: string,
|
|
23
|
+
shareableHostUnpackerLocation: string,
|
|
24
|
+
shareableHostUnpackerSourceMap: string,
|
|
25
|
+
shareableGuestUnpackerCode: string,
|
|
26
|
+
shareableGuestUnpackerLocation: string,
|
|
27
|
+
shareableGuestUnpackerSourceMap: string,
|
|
28
|
+
remoteFunctionUnpackerCode: string,
|
|
29
|
+
remoteFunctionUnpackerLocation: string,
|
|
30
|
+
remoteFunctionUnpackerSourceMap: string
|
|
31
|
+
): void;
|
|
32
|
+
|
|
33
|
+
loadUnpackersWithBytecode(
|
|
34
|
+
valueUnpackerBytecode: ArrayBuffer,
|
|
35
|
+
synchronizableUnpackerBytecode: ArrayBuffer,
|
|
36
|
+
customSerializableUnpackerBytecode: ArrayBuffer,
|
|
37
|
+
shareableHostUnpackerBytecode: ArrayBuffer,
|
|
38
|
+
shareableGuestUnpackerBytecode: ArrayBuffer,
|
|
39
|
+
remoteFunctionUnpackerBytecode: ArrayBuffer
|
|
40
|
+
): void;
|
|
41
|
+
|
|
42
|
+
createSerializableImport<TValue>(
|
|
43
|
+
source: string,
|
|
44
|
+
imported: string
|
|
45
|
+
): SerializableRef<TValue>;
|
|
46
|
+
|
|
47
|
+
createSerializableString(str: string): SerializableRef<string>;
|
|
48
|
+
|
|
49
|
+
createSerializableNumber(num: number): SerializableRef<number>;
|
|
50
|
+
|
|
51
|
+
createSerializableBoolean(bool: boolean): SerializableRef<boolean>;
|
|
52
|
+
|
|
53
|
+
createSerializableBigInt(bigInt: bigint): SerializableRef<bigint>;
|
|
54
|
+
|
|
55
|
+
createSerializableUndefined(): SerializableRef<undefined>;
|
|
56
|
+
|
|
57
|
+
createSerializableNull(): SerializableRef<null>;
|
|
58
|
+
|
|
59
|
+
createSerializableTurboModuleLike<
|
|
60
|
+
TProps extends object,
|
|
61
|
+
TProto extends object,
|
|
62
|
+
>(
|
|
63
|
+
props: TProps,
|
|
64
|
+
proto: TProto
|
|
65
|
+
): SerializableRef<TProps>;
|
|
66
|
+
|
|
67
|
+
createSerializableObject<T extends object>(
|
|
68
|
+
obj: T,
|
|
69
|
+
shouldRetainRemote: boolean,
|
|
70
|
+
nativeStateSource?: object
|
|
71
|
+
): SerializableRef<T>;
|
|
72
|
+
|
|
73
|
+
createSerializableHostObject<T extends object>(obj: T): SerializableRef<T>;
|
|
74
|
+
|
|
75
|
+
createSerializableArray(
|
|
76
|
+
array: unknown[],
|
|
77
|
+
shouldRetainRemote?: boolean
|
|
78
|
+
): SerializableRef<unknown[]>;
|
|
79
|
+
|
|
80
|
+
createSerializableArrayBuffer(
|
|
81
|
+
arrayBuffer: ArrayBuffer
|
|
82
|
+
): SerializableRef<ArrayBuffer>;
|
|
83
|
+
|
|
84
|
+
createSerializableMap<TKey, TValue>(
|
|
85
|
+
keys: TKey[],
|
|
86
|
+
values: TValue[]
|
|
87
|
+
): SerializableRef<Map<TKey, TValue>>;
|
|
88
|
+
|
|
89
|
+
createSerializableSet<TValues>(
|
|
90
|
+
values: TValues[]
|
|
91
|
+
): SerializableRef<Set<TValues>>;
|
|
92
|
+
|
|
93
|
+
createSerializableError(
|
|
94
|
+
name: string,
|
|
95
|
+
message: string,
|
|
96
|
+
stack: string | undefined
|
|
97
|
+
): SerializableRef<Error>;
|
|
98
|
+
|
|
99
|
+
createSerializableRegExp(
|
|
100
|
+
pattern: string,
|
|
101
|
+
flags: string
|
|
102
|
+
): SerializableRef<RegExp>;
|
|
103
|
+
|
|
104
|
+
createSerializableArrayBufferView<TValue extends ArrayBufferView>(
|
|
105
|
+
typeName: string,
|
|
106
|
+
buffer: ArrayBuffer,
|
|
107
|
+
byteOffset: number,
|
|
108
|
+
length: number
|
|
109
|
+
): SerializableRef<TValue>;
|
|
110
|
+
|
|
111
|
+
createSerializableInitializer(obj: object): SerializableRef<object>;
|
|
112
|
+
|
|
113
|
+
createSerializableNonWorkletFunction<TArgs extends unknown[], TReturn>(
|
|
114
|
+
fun: (...args: TArgs) => TReturn,
|
|
115
|
+
functionName: string | undefined
|
|
116
|
+
): SerializableRef<(...args: TArgs) => TReturn>;
|
|
117
|
+
|
|
118
|
+
createSerializableWorklet(
|
|
119
|
+
worklet: object,
|
|
120
|
+
shouldPersistRemote: boolean
|
|
121
|
+
): SerializableRef<object>;
|
|
122
|
+
|
|
123
|
+
createCustomSerializable(
|
|
124
|
+
data: SerializableRef<unknown>,
|
|
125
|
+
typeId: number
|
|
126
|
+
): SerializableRef<unknown>;
|
|
127
|
+
|
|
128
|
+
registerCustomSerializable(
|
|
129
|
+
determine: SerializableRef<object>,
|
|
130
|
+
pack: SerializableRef<object>,
|
|
131
|
+
unpack: SerializableRef<object>,
|
|
132
|
+
typeId: number
|
|
133
|
+
): void;
|
|
134
|
+
|
|
135
|
+
createShareable<TValue = unknown>(
|
|
136
|
+
hostRuntimeId: number,
|
|
137
|
+
initial: SerializableRef<TValue>,
|
|
138
|
+
initSynchronously: boolean,
|
|
139
|
+
decorateHost: SerializableRef,
|
|
140
|
+
decorateGuest: SerializableRef
|
|
141
|
+
): SerializableRef<TValue>;
|
|
142
|
+
|
|
143
|
+
scheduleOnRN<TArgs extends unknown[]>(
|
|
144
|
+
fun: RemoteFunction | ((...args: TArgs) => unknown),
|
|
145
|
+
args: SerializableRef<TArgs> | undefined
|
|
146
|
+
): void;
|
|
147
|
+
|
|
148
|
+
scheduleOnUI<TValue>(
|
|
149
|
+
serializableArrayOfWorklets: SerializableRef<TValue[]>,
|
|
150
|
+
scheduleStacks: string[] | undefined
|
|
151
|
+
): void;
|
|
152
|
+
|
|
153
|
+
runOnUISync<TValue, TReturn>(
|
|
154
|
+
serializable: SerializableRef<TValue>,
|
|
155
|
+
scheduleStack: string | undefined
|
|
156
|
+
): TReturn;
|
|
157
|
+
|
|
158
|
+
createWorkletRuntime(
|
|
159
|
+
name: string,
|
|
160
|
+
initializer: SerializableRef<() => void>,
|
|
161
|
+
useDefaultQueue: boolean,
|
|
162
|
+
customQueue: object | undefined,
|
|
163
|
+
enableEventLoop: boolean
|
|
164
|
+
): WorkletRuntime;
|
|
165
|
+
|
|
166
|
+
scheduleOnRuntime<TValue>(
|
|
167
|
+
workletRuntime: WorkletRuntime,
|
|
168
|
+
worklet: SerializableRef<TValue>,
|
|
169
|
+
scheduleStack?: string
|
|
170
|
+
): void;
|
|
171
|
+
|
|
172
|
+
scheduleOnRuntimeWithId<TValue>(
|
|
173
|
+
runtimeId: number,
|
|
174
|
+
worklet: SerializableRef<TValue>,
|
|
175
|
+
scheduleStack?: string
|
|
176
|
+
): void;
|
|
177
|
+
|
|
178
|
+
runOnRuntimeSync<TValue, TReturn>(
|
|
179
|
+
workletRuntime: WorkletRuntime,
|
|
180
|
+
worklet: SerializableRef<TValue>,
|
|
181
|
+
scheduleStack?: string
|
|
182
|
+
): TReturn;
|
|
183
|
+
|
|
184
|
+
runOnRuntimeSyncWithId<TValue, TReturn>(
|
|
185
|
+
runtimeId: number,
|
|
186
|
+
worklet: SerializableRef<TValue>,
|
|
187
|
+
scheduleStack?: string
|
|
188
|
+
): TReturn;
|
|
189
|
+
|
|
190
|
+
handlePromise<TValue>(
|
|
191
|
+
resolveOrReject:
|
|
192
|
+
| ((value: TValue | PromiseLike<TValue>) => void)
|
|
193
|
+
| RemoteFunction,
|
|
194
|
+
valueOrError: SerializableRef<TValue>
|
|
195
|
+
): void;
|
|
196
|
+
|
|
197
|
+
reportFatalErrorOnJS(message: string, stack: string, name: string): void;
|
|
198
|
+
|
|
199
|
+
createSynchronizable<TValue>(value: TValue): SynchronizableRef<TValue>;
|
|
200
|
+
|
|
201
|
+
synchronizableGetDirty<TValue>(
|
|
202
|
+
synchronizableRef: SynchronizableRef<TValue>
|
|
203
|
+
): TValue;
|
|
204
|
+
|
|
205
|
+
synchronizableGetBlocking<TValue>(
|
|
206
|
+
synchronizableRef: SynchronizableRef<TValue>
|
|
207
|
+
): TValue;
|
|
208
|
+
|
|
209
|
+
synchronizableSetBlocking<TValue>(
|
|
210
|
+
synchronizableRef: SynchronizableRef<TValue>,
|
|
211
|
+
value: SerializableRef<TValue>
|
|
212
|
+
): void;
|
|
213
|
+
|
|
214
|
+
synchronizableLock<TValue>(
|
|
215
|
+
synchronizableRef: SynchronizableRef<TValue>
|
|
216
|
+
): void;
|
|
217
|
+
|
|
218
|
+
synchronizableUnlock<TValue>(
|
|
219
|
+
synchronizableRef: SynchronizableRef<TValue>
|
|
220
|
+
): void;
|
|
221
|
+
|
|
222
|
+
getStaticFeatureFlag(name: string): boolean;
|
|
223
|
+
|
|
224
|
+
setDynamicFeatureFlag(name: string, value: boolean): void;
|
|
225
|
+
|
|
226
|
+
getUIRuntimeHolder(): object;
|
|
227
|
+
|
|
228
|
+
getUISchedulerHolder(): object;
|
|
229
|
+
|
|
230
|
+
/** @deprecated Don't use unless you have to. */
|
|
231
|
+
createSerializableLEGACY<TValue>(
|
|
232
|
+
value: TValue,
|
|
233
|
+
nativeStateSource: object | undefined
|
|
234
|
+
): SerializableRef<TValue>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
type InternalMethods =
|
|
238
|
+
| 'loadUnpackersWithCode'
|
|
239
|
+
| 'loadUnpackersWithBytecode'
|
|
240
|
+
| 'createSerializableLEGACY';
|
|
241
|
+
|
|
242
|
+
type TurboModulePublic = {
|
|
243
|
+
toggleSlowAnimationsOnUIRuntime(): boolean;
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export type IWorkletsModule = Omit<WorkletsModuleProxy, InternalMethods> &
|
|
247
|
+
TurboModulePublic;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { isWorkletRuntime } from '../runtimeKind';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Evaluating HMR updates on Worklet Runtimes leads to verbose warnings which
|
|
7
|
+
* don't affect runtime. This function silences those warnings by providing a
|
|
8
|
+
* dummy Refresh module to the global scope.
|
|
9
|
+
*
|
|
10
|
+
* Use only in dev builds.
|
|
11
|
+
*/
|
|
12
|
+
export function silenceHMRWarnings() {
|
|
13
|
+
assertWorkletRuntime('silenceHMRWarnings');
|
|
14
|
+
|
|
15
|
+
const Refresh = new Proxy(
|
|
16
|
+
{},
|
|
17
|
+
{
|
|
18
|
+
get() {
|
|
19
|
+
return () => {};
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
globalThis.__r.Refresh = Refresh;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function assertWorkletRuntime(functionName: string) {
|
|
28
|
+
if (!isWorkletRuntime()) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`[Worklets] ${functionName} can be used only on Worklet Runtimes.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mocks necessary networking TurboModules on Worklet Runtimes to prevent
|
|
5
|
+
* crashes when code running on Worklet Runtimes tries to use networking APIs.
|
|
6
|
+
* The NetworkingModule itself is injected via C++.
|
|
7
|
+
*/
|
|
8
|
+
export function initializeNetworking() {
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
require('react-native/Libraries/TurboModule/TurboModuleRegistry');
|
|
11
|
+
const TurboModules = globalThis.TurboModules;
|
|
12
|
+
|
|
13
|
+
TurboModules.set('FileReaderModule', makeMockTurboModule('FileReaderModule'));
|
|
14
|
+
TurboModules.set(
|
|
15
|
+
'PlatformConstants',
|
|
16
|
+
makeMockTurboModule('PlatformConstants')
|
|
17
|
+
);
|
|
18
|
+
TurboModules.set('WebSocketModule', makeMockTurboModule('WebSocketModule'));
|
|
19
|
+
TurboModules.set(
|
|
20
|
+
'NativeReactNativeFeatureFlagsCxx',
|
|
21
|
+
new Proxy({}, { get: () => () => undefined })
|
|
22
|
+
);
|
|
23
|
+
TurboModules.set(
|
|
24
|
+
'BlobModule',
|
|
25
|
+
makeMockTurboModule('BlobModule', ['addNetworkingHandler'])
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This require statement below is the key part of the implementation here. It
|
|
30
|
+
* pulls all the code that properly sets up XHR on a Runtime, using underlying
|
|
31
|
+
* C++ NetworkingModule. Thanks to that we can have the same JavaScript
|
|
32
|
+
* implementation for fetch on all runtimes in the app and we don't have to
|
|
33
|
+
* write the code ourselves.
|
|
34
|
+
*/
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
36
|
+
require('react-native/Libraries/Core/setUpXHR');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const noopMethods = ['getConstants'];
|
|
40
|
+
|
|
41
|
+
function makeMockTurboModule(name: string, extraNoopMethods?: string[]) {
|
|
42
|
+
const proxy = new Proxy(
|
|
43
|
+
{},
|
|
44
|
+
{
|
|
45
|
+
get: function get(_target, prop) {
|
|
46
|
+
if (
|
|
47
|
+
[...noopMethods, ...(extraNoopMethods ?? [])].includes(prop as string)
|
|
48
|
+
) {
|
|
49
|
+
return () => {
|
|
50
|
+
return () => {};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
throw new Error(
|
|
54
|
+
`[Worklets] You tried to call method '${String(
|
|
55
|
+
prop
|
|
56
|
+
)}' from '${name}' TurboModule on a Worklet Runtime. Using '${name}' TurboModule on a Worklet Runtime is not allowed.`
|
|
57
|
+
);
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return proxy;
|
|
63
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { WorkletFunction } from '../types';
|
|
4
|
+
|
|
5
|
+
// Worklets Babel Plugin replaces `false` with `true` here
|
|
6
|
+
// when Bundle Mode is enabled.
|
|
7
|
+
globalThis._WORKLETS_BUNDLE_MODE_ENABLED = false;
|
|
8
|
+
|
|
9
|
+
export function isBundleModeEnabled(): boolean {
|
|
10
|
+
return (
|
|
11
|
+
globalThis._WORKLETS_BUNDLE_MODE_ENABLED === true &&
|
|
12
|
+
(
|
|
13
|
+
(() => {
|
|
14
|
+
'worklet';
|
|
15
|
+
}) as WorkletFunction
|
|
16
|
+
).__initData === undefined
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { jsVersion } from './jsVersion';
|
|
4
|
+
import { logger } from './logger';
|
|
5
|
+
|
|
6
|
+
export function checkCppVersion() {
|
|
7
|
+
const cppVersion = global._WORKLETS_VERSION_CPP;
|
|
8
|
+
if (cppVersion === undefined) {
|
|
9
|
+
logger.warn(
|
|
10
|
+
`Couldn't determine the version of the native part of Worklets.
|
|
11
|
+
See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#couldnt-determine-the-version-of-the-native-part-of-worklets\` for more details.`
|
|
12
|
+
);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const ok = matchVersion(jsVersion, cppVersion);
|
|
16
|
+
if (!ok) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
`[Worklets] Mismatch between JavaScript part and native part of Worklets (${jsVersion} vs ${cppVersion}).
|
|
19
|
+
See \`https://docs.swmansion.com/react-native-worklets/docs/guides/troubleshooting#mismatch-between-javascript-part-and-native-part-of-worklets\` for more details.`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function matchVersion(version1: string, version2: string) {
|
|
25
|
+
if (version1.match(/^\d+\.\d+\.\d+$/) && version2.match(/^\d+\.\d+\.\d+$/)) {
|
|
26
|
+
// x.y.z, compare only major and minor, skip patch
|
|
27
|
+
const [major1, minor1] = version1.split('.');
|
|
28
|
+
const [major2, minor2] = version2.split('.');
|
|
29
|
+
return major1 === major2 && minor1 === minor2;
|
|
30
|
+
} else {
|
|
31
|
+
// alpha, beta or rc, compare everything
|
|
32
|
+
return version1 === version2;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { WorkletStackDetails } from '../types';
|
|
4
|
+
|
|
5
|
+
const _workletStackDetails = new Map<number, WorkletStackDetails>();
|
|
6
|
+
|
|
7
|
+
export function registerWorkletStackDetails(
|
|
8
|
+
hash: number,
|
|
9
|
+
stackDetails: WorkletStackDetails
|
|
10
|
+
) {
|
|
11
|
+
_workletStackDetails.set(hash, stackDetails);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getBundleOffset(error: Error): [string, number, number] {
|
|
15
|
+
const frame = error.stack?.split('\n')?.[0];
|
|
16
|
+
if (frame) {
|
|
17
|
+
const parsedFrame = /@([^@]+):(\d+):(\d+)/.exec(frame);
|
|
18
|
+
if (parsedFrame) {
|
|
19
|
+
const [, file, line, col] = parsedFrame;
|
|
20
|
+
return [file, Number(line), Number(col)];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ['unknown', 0, 0];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function processStack(stack?: string): string | undefined {
|
|
27
|
+
if (stack === '' || stack === undefined) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const workletStackEntries = stack.match(/worklet_(\d+):(\d+):(\d+)/g);
|
|
31
|
+
let result = stack;
|
|
32
|
+
workletStackEntries?.forEach((match) => {
|
|
33
|
+
const [, hash, origLine, origCol] = match.split(/:|_/).map(Number);
|
|
34
|
+
const errorDetails = _workletStackDetails.get(hash);
|
|
35
|
+
if (!errorDetails) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const [error, lineOffset, colOffset] = errorDetails;
|
|
39
|
+
const [bundleFile, bundleLine, bundleCol] = getBundleOffset(error);
|
|
40
|
+
const line = origLine + bundleLine + lineOffset;
|
|
41
|
+
const col = origCol + bundleCol + colOffset;
|
|
42
|
+
|
|
43
|
+
result = result.replace(match, `${bundleFile}:${line}:${col}`);
|
|
44
|
+
});
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Remote error is an error coming from a Worklet Runtime that we bubble up to
|
|
50
|
+
* the RN Runtime.
|
|
51
|
+
*/
|
|
52
|
+
export function reportFatalRemoteError(
|
|
53
|
+
{ message, stack, name }: Error,
|
|
54
|
+
force: boolean
|
|
55
|
+
): void {
|
|
56
|
+
const error = new Error('[Worklets]');
|
|
57
|
+
error.message = message;
|
|
58
|
+
error.stack = processStack(stack);
|
|
59
|
+
error.name = name;
|
|
60
|
+
if (force) {
|
|
61
|
+
throw error;
|
|
62
|
+
} else {
|
|
63
|
+
// @ts-expect-error React Native's `ErrorUtils` are hidden from the global scope.
|
|
64
|
+
globalThis.ErrorUtils.reportFatalError(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Registers `reportFatalRemoteError` function in global scope to allow to
|
|
70
|
+
* invoke it from C++.
|
|
71
|
+
*/
|
|
72
|
+
export function registerReportFatalRemoteError() {
|
|
73
|
+
globalThis.__reportFatalRemoteError = reportFatalRemoteError;
|
|
74
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* We hardcode the version of Worklets here in order to compare it with the
|
|
5
|
+
* version used to build the native part of the library in runtime. Remember to
|
|
6
|
+
* keep this in sync with the version declared in `package.json`
|
|
7
|
+
*/
|
|
8
|
+
export const jsVersion = '0.11.3';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PREFIX = '[Worklets]';
|
|
4
|
+
|
|
5
|
+
function formatMessage(message: string) {
|
|
6
|
+
return `${PREFIX} ${message}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const logger = {
|
|
10
|
+
warn(message: string) {
|
|
11
|
+
console.warn(formatMessage(message));
|
|
12
|
+
},
|
|
13
|
+
error(message: string) {
|
|
14
|
+
console.error(formatMessage(message));
|
|
15
|
+
},
|
|
16
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { WorkletsModule } from '../WorkletsModule/NativeWorklets';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Toggles slow animations on the UI runtime. When enabled, animations will run
|
|
6
|
+
* at a reduced speed to aid debugging.
|
|
7
|
+
*
|
|
8
|
+
* Available only on Android. iOS offers built-in slow animations toggle.
|
|
9
|
+
*
|
|
10
|
+
* @returns Whether slow animations are now enabled.
|
|
11
|
+
* @throws When invoked on platform different than Android.
|
|
12
|
+
*/
|
|
13
|
+
export function toggleSlowAnimationsOnUIRuntime(): boolean {
|
|
14
|
+
return WorkletsModule.toggleSlowAnimationsOnUIRuntime();
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
createSerializable,
|
|
5
|
+
isSerializableRef,
|
|
6
|
+
makeShareable,
|
|
7
|
+
makeShareableCloneOnUIRecursive,
|
|
8
|
+
} from './memory/serializable';
|
|
9
|
+
import { serializableMappingCache } from './memory/serializableMappingCache';
|
|
10
|
+
import type { SerializableRef } from './memory/types';
|
|
11
|
+
|
|
12
|
+
/** @deprecated Use {@link SerializableRef} instead. */
|
|
13
|
+
export type ShareableRef<T> = SerializableRef<T>;
|
|
14
|
+
|
|
15
|
+
export { makeShareable, makeShareableCloneOnUIRecursive };
|
|
16
|
+
|
|
17
|
+
/** @deprecated It will be removed in the next major version. */
|
|
18
|
+
export type MakeShareableClone = <T>(
|
|
19
|
+
value: T,
|
|
20
|
+
shouldPersistRemote?: boolean,
|
|
21
|
+
depth?: number
|
|
22
|
+
) => ShareableRef<T>;
|
|
23
|
+
|
|
24
|
+
/** @deprecated Use {@link createSerializable} instead. */
|
|
25
|
+
export const makeShareableCloneRecursive: MakeShareableClone =
|
|
26
|
+
createSerializable;
|
|
27
|
+
|
|
28
|
+
/** @deprecated Use {@link isSerializableRef} instead. */
|
|
29
|
+
export const isShareableRef = isSerializableRef;
|
|
30
|
+
|
|
31
|
+
/** @deprecated Use {@link serializableMappingCache} instead. */
|
|
32
|
+
export const shareableMappingCache = serializableMappingCache;
|
|
33
|
+
|
|
34
|
+
/** @deprecated NOOP, don't use. */
|
|
35
|
+
export function callMicrotasks(): void {
|
|
36
|
+
'worklet';
|
|
37
|
+
// NOOP for backwards compatibility.
|
|
38
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import { logger } from '../debug/logger';
|
|
3
|
+
import { WorkletsModule } from '../WorkletsModule/NativeWorklets';
|
|
4
|
+
import type {
|
|
5
|
+
DynamicFlagName,
|
|
6
|
+
DynamicFlagsType,
|
|
7
|
+
StaticFeatureFlagsSchema,
|
|
8
|
+
} from './types';
|
|
9
|
+
|
|
10
|
+
export const DynamicFlags: DynamicFlagsType = {
|
|
11
|
+
EXAMPLE_DYNAMIC_FLAG: true,
|
|
12
|
+
|
|
13
|
+
init() {
|
|
14
|
+
Object.keys(DynamicFlags).forEach((key) => {
|
|
15
|
+
if (key !== 'init' && key !== 'setFlag' && key !== 'getFlag') {
|
|
16
|
+
WorkletsModule.setDynamicFeatureFlag(
|
|
17
|
+
key,
|
|
18
|
+
DynamicFlags[key as DynamicFlagName]
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
setFlag(name, value) {
|
|
24
|
+
if (name in DynamicFlags) {
|
|
25
|
+
DynamicFlags[name] = value;
|
|
26
|
+
WorkletsModule.setDynamicFeatureFlag(name, value);
|
|
27
|
+
} else {
|
|
28
|
+
logger.warn(
|
|
29
|
+
`The feature flag: '${name}' no longer exists, you can safely remove invocation of \`setDynamicFeatureFlag('${name}')\` from your code.`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
getFlag(name) {
|
|
34
|
+
if (name in DynamicFlags) {
|
|
35
|
+
return DynamicFlags[name];
|
|
36
|
+
} else {
|
|
37
|
+
logger.warn(
|
|
38
|
+
`The feature flag: '${name}' no longer exists, you can safely remove invocation of \`getDynamicFeatureFlag('${name}')\` from your code.`
|
|
39
|
+
);
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
DynamicFlags.init();
|
|
45
|
+
|
|
46
|
+
// Public API function to update a feature flag
|
|
47
|
+
export function setDynamicFeatureFlag(
|
|
48
|
+
name: DynamicFlagName,
|
|
49
|
+
value: boolean
|
|
50
|
+
): void {
|
|
51
|
+
DynamicFlags.setFlag(name, value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Public API function to read a feature flag
|
|
55
|
+
export function getDynamicFeatureFlag(name: DynamicFlagName): boolean {
|
|
56
|
+
return DynamicFlags.getFlag(name);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const staticFeatureFlags: Partial<StaticFeatureFlagsSchema> = {};
|
|
60
|
+
|
|
61
|
+
export function getStaticFeatureFlag(
|
|
62
|
+
name: keyof StaticFeatureFlagsSchema
|
|
63
|
+
): boolean {
|
|
64
|
+
if (name in staticFeatureFlags) {
|
|
65
|
+
return staticFeatureFlags[name]!;
|
|
66
|
+
}
|
|
67
|
+
const featureFlagValue = WorkletsModule.getStaticFeatureFlag(name);
|
|
68
|
+
staticFeatureFlags[name] = featureFlagValue;
|
|
69
|
+
return featureFlagValue;
|
|
70
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { DynamicFlagName, StaticFeatureFlagsSchema } from './types';
|
|
4
|
+
|
|
5
|
+
export function getStaticFeatureFlag(
|
|
6
|
+
_name: keyof StaticFeatureFlagsSchema
|
|
7
|
+
): boolean {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function setDynamicFeatureFlag(
|
|
12
|
+
_name: DynamicFlagName,
|
|
13
|
+
_value: boolean
|
|
14
|
+
): void {
|
|
15
|
+
// no-op
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getDynamicFeatureFlag(_name: DynamicFlagName): boolean {
|
|
19
|
+
return false;
|
|
20
|
+
}
|