@amazon-devices/react-native-worklets 1.0.0-rn-83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +71 -0
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +712 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +88 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +89 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +80 -0
- package/Common/cpp/worklets/Public/AsyncQueue.h +14 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +51 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +40 -0
- package/Common/cpp/worklets/Resources/SynchronizableUnpacker.cpp +49 -0
- package/Common/cpp/worklets/Resources/Unpackers.h +6 -0
- package/Common/cpp/worklets/Resources/ValueUnpacker.cpp +53 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +62 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +46 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.cpp +112 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.h +52 -0
- package/Common/cpp/worklets/SharedItems/Serializable.cpp +545 -0
- package/Common/cpp/worklets/SharedItems/Serializable.h +473 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +67 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.h +59 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +81 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +45 -0
- package/Common/cpp/worklets/Tools/Defs.h +10 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.cpp +15 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.h +44 -0
- package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
- package/Common/cpp/worklets/Tools/JSISerializer.h +51 -0
- package/Common/cpp/worklets/Tools/JSLogger.cpp +68 -0
- package/Common/cpp/worklets/Tools/JSLogger.h +37 -0
- package/Common/cpp/worklets/Tools/JSScheduler.cpp +24 -0
- package/Common/cpp/worklets/Tools/JSScheduler.h +39 -0
- package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
- package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +82 -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 +26 -0
- package/Common/cpp/worklets/Tools/VersionUtils.cpp +75 -0
- package/Common/cpp/worklets/Tools/VersionUtils.h +28 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +46 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +208 -0
- package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +161 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.cpp +54 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.h +20 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +38 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +21 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeData.cpp +3 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeData.h +12 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeKind.h +16 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +105 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +63 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +23 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +119 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +134 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +244 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +102 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +308 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +26 -0
- package/LICENSE +7 -0
- package/README.md +31 -0
- package/RNWorklets.podspec +94 -0
- package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.bundle +10512 -0
- package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.map +3771 -0
- package/SystemModules/amzn__react-native-worklets-1.modules.txt +39 -0
- package/SystemModules/amzn__react-native-worklets-1.private.modules.txt +61 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/android/CMakeLists.txt +124 -0
- package/android/build.gradle +350 -0
- package/android/gradle.properties +5 -0
- package/android/proguard-rules.pro +3 -0
- package/android/spotless.gradle +9 -0
- package/android/src/experimentalBundling/com/swmansion/worklets/WorkletsModule.java +149 -0
- package/android/src/legacyBundling/com/swmansion/worklets/WorkletsModule.java +122 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +43 -0
- package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +34 -0
- package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +115 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +78 -0
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
- package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
- package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +73 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +48 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.java +113 -0
- package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +135 -0
- package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
- package/apple/worklets/apple/IOSUIScheduler.h +15 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +29 -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/WorkletsMessageThread.h +16 -0
- package/apple/worklets/apple/WorkletsMessageThread.mm +31 -0
- package/apple/worklets/apple/WorkletsModule.h +28 -0
- package/apple/worklets/apple/WorkletsModule.mm +121 -0
- package/bundleMode/index.d.ts +3 -0
- package/bundleMode/index.js +59 -0
- package/compatibility.json +11 -0
- package/kepler-compatibility.json +5 -0
- package/kepler-transformed-package-info.json +3 -0
- package/lib/module/PlatformChecker/PlatformChecker.js +8 -0
- package/lib/module/PlatformChecker/PlatformChecker.js.map +1 -0
- package/lib/module/PlatformChecker/index.js +18 -0
- package/lib/module/PlatformChecker/index.js.map +1 -0
- package/lib/module/WorkletsError.js +29 -0
- package/lib/module/WorkletsError.js.map +1 -0
- package/lib/module/WorkletsModule/JSWorklets.js +111 -0
- package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/NativeWorklets.js +126 -0
- package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/index.js +4 -0
- package/lib/module/WorkletsModule/index.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
- package/lib/module/bundleUnpacker.js +47 -0
- package/lib/module/bundleUnpacker.js.map +1 -0
- package/lib/module/callGuard.js +30 -0
- package/lib/module/callGuard.js.map +1 -0
- package/lib/module/deprecated.js +20 -0
- package/lib/module/deprecated.js.map +1 -0
- package/lib/module/errors.js +69 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/featureFlags/index.js +48 -0
- package/lib/module/featureFlags/index.js.map +1 -0
- package/lib/module/featureFlags/staticFlags.json +4 -0
- package/lib/module/index.js +26 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initializers.js +221 -0
- package/lib/module/initializers.js.map +1 -0
- package/lib/module/isSynchronizable.js +6 -0
- package/lib/module/isSynchronizable.js.map +1 -0
- package/lib/module/logger.js +15 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/privateGlobals.d.js +7 -0
- package/lib/module/privateGlobals.d.js.map +1 -0
- package/lib/module/publicGlobals.js +6 -0
- package/lib/module/publicGlobals.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 +52 -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 +39 -0
- package/lib/module/runtimeKind.js.map +1 -0
- package/lib/module/runtimes.js +100 -0
- package/lib/module/runtimes.js.map +1 -0
- package/lib/module/serializable.js +568 -0
- package/lib/module/serializable.js.map +1 -0
- package/lib/module/serializableMappingCache.js +37 -0
- package/lib/module/serializableMappingCache.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/NativeWorkletsModule.kepler.js +7 -0
- package/lib/module/specs/NativeWorkletsModule.kepler.js.map +1 -0
- package/lib/module/specs/index.js +10 -0
- package/lib/module/specs/index.js.map +1 -0
- package/lib/module/synchronizable.js +9 -0
- package/lib/module/synchronizable.js.map +1 -0
- package/lib/module/synchronizableUnpacker.js +42 -0
- package/lib/module/synchronizableUnpacker.js.map +1 -0
- package/lib/module/threads.js +347 -0
- package/lib/module/threads.js.map +1 -0
- package/lib/module/utils/checkCppVersion.js +30 -0
- package/lib/module/utils/checkCppVersion.js.map +1 -0
- package/lib/module/utils/jsVersion.js +9 -0
- package/lib/module/utils/jsVersion.js.map +1 -0
- package/lib/module/valueUnpacker.js +60 -0
- package/lib/module/valueUnpacker.js.map +1 -0
- package/lib/module/workletFunction.js +37 -0
- package/lib/module/workletFunction.js.map +1 -0
- package/lib/module/workletRuntimeEntry.js +32 -0
- package/lib/module/workletRuntimeEntry.js.map +1 -0
- package/lib/module/workletTypes.js +12 -0
- package/lib/module/workletTypes.js.map +1 -0
- package/lib/typescript/PlatformChecker/PlatformChecker.d.ts +5 -0
- package/lib/typescript/PlatformChecker/PlatformChecker.d.ts.map +1 -0
- package/lib/typescript/PlatformChecker/index.d.ts +10 -0
- package/lib/typescript/PlatformChecker/index.d.ts.map +1 -0
- package/lib/typescript/WorkletsError.d.ts +15 -0
- package/lib/typescript/WorkletsError.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts.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/index.d.ts +3 -0
- package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +37 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
- package/lib/typescript/bundleUnpacker.d.ts +7 -0
- package/lib/typescript/bundleUnpacker.d.ts.map +1 -0
- package/lib/typescript/callGuard.d.ts +4 -0
- package/lib/typescript/callGuard.d.ts.map +1 -0
- package/lib/typescript/deprecated.d.ts +20 -0
- package/lib/typescript/deprecated.d.ts.map +1 -0
- package/lib/typescript/errors.d.ts +16 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/featureFlags/index.d.ts +23 -0
- package/lib/typescript/featureFlags/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/initializers.d.ts +17 -0
- package/lib/typescript/initializers.d.ts.map +1 -0
- package/lib/typescript/isSynchronizable.d.ts +3 -0
- package/lib/typescript/isSynchronizable.d.ts.map +1 -0
- package/lib/typescript/logger.d.ts +5 -0
- package/lib/typescript/logger.d.ts.map +1 -0
- package/lib/typescript/publicGlobals.d.ts +31 -0
- package/lib/typescript/publicGlobals.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 +25 -0
- package/lib/typescript/runtimeKind.d.ts.map +1 -0
- package/lib/typescript/runtimes.d.ts +77 -0
- package/lib/typescript/runtimes.d.ts.map +1 -0
- package/lib/typescript/serializable.d.ts +20 -0
- package/lib/typescript/serializable.d.ts.map +1 -0
- package/lib/typescript/serializableMappingCache.d.ts +16 -0
- package/lib/typescript/serializableMappingCache.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.kepler.d.ts +7 -0
- package/lib/typescript/specs/NativeWorkletsModule.kepler.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/synchronizable.d.ts +15 -0
- package/lib/typescript/synchronizable.d.ts.map +1 -0
- package/lib/typescript/synchronizableUnpacker.d.ts +4 -0
- package/lib/typescript/synchronizableUnpacker.d.ts.map +1 -0
- package/lib/typescript/threads.d.ts +138 -0
- package/lib/typescript/threads.d.ts.map +1 -0
- package/lib/typescript/utils/checkCppVersion.d.ts +3 -0
- package/lib/typescript/utils/checkCppVersion.d.ts.map +1 -0
- package/lib/typescript/utils/jsVersion.d.ts +7 -0
- package/lib/typescript/utils/jsVersion.d.ts.map +1 -0
- package/lib/typescript/valueUnpacker.d.ts +6 -0
- package/lib/typescript/valueUnpacker.d.ts.map +1 -0
- package/lib/typescript/workletFunction.d.ts +27 -0
- package/lib/typescript/workletFunction.d.ts.map +1 -0
- package/lib/typescript/workletRuntimeEntry.d.ts +14 -0
- package/lib/typescript/workletRuntimeEntry.d.ts.map +1 -0
- package/lib/typescript/workletTypes.d.ts +61 -0
- package/lib/typescript/workletTypes.d.ts.map +1 -0
- package/package.json +153 -0
- package/plugin/index.js +1761 -0
- package/react-native.config.js +21 -0
- package/scripts/validate-react-native-version.js +43 -0
- package/scripts/worklets_utils.rb +94 -0
- package/src/PlatformChecker/PlatformChecker.ts +7 -0
- package/src/PlatformChecker/index.ts +30 -0
- package/src/WorkletsError.ts +36 -0
- package/src/WorkletsModule/JSWorklets.ts +200 -0
- package/src/WorkletsModule/NativeWorklets.ts +256 -0
- package/src/WorkletsModule/index.ts +7 -0
- package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
- package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
- package/src/WorkletsModule/workletsModuleProxy.ts +126 -0
- package/src/bundleUnpacker.ts +75 -0
- package/src/callGuard.ts +33 -0
- package/src/deprecated.ts +32 -0
- package/src/errors.ts +80 -0
- package/src/featureFlags/index.ts +72 -0
- package/src/featureFlags/staticFlags.json +4 -0
- package/src/index.ts +53 -0
- package/src/initializers.ts +262 -0
- package/src/isSynchronizable.ts +13 -0
- package/src/logger.ts +16 -0
- package/src/privateGlobals.d.ts +79 -0
- package/src/publicGlobals.ts +39 -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 +66 -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 +37 -0
- package/src/runtimes.ts +193 -0
- package/src/serializable.ts +801 -0
- package/src/serializableMappingCache.ts +42 -0
- package/src/specs/NativeWorkletsModule.kepler.ts +11 -0
- package/src/specs/NativeWorkletsModule.ts +9 -0
- package/src/specs/index.ts +13 -0
- package/src/synchronizable.ts +32 -0
- package/src/synchronizableUnpacker.ts +67 -0
- package/src/threads.ts +452 -0
- package/src/utils/checkCppVersion.ts +34 -0
- package/src/utils/jsVersion.ts +7 -0
- package/src/valueUnpacker.ts +90 -0
- package/src/workletFunction.ts +42 -0
- package/src/workletRuntimeEntry.ts +35 -0
- package/src/workletTypes.ts +81 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import type { ValueUnpacker, WorkletFunction } from './workletTypes';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
var evalWithSourceMap:
|
|
6
|
+
| ((js: string, sourceURL: string, sourceMap: string) => () => unknown)
|
|
7
|
+
| undefined;
|
|
8
|
+
var evalWithSourceUrl:
|
|
9
|
+
| ((js: string, sourceURL: string) => () => unknown)
|
|
10
|
+
| undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function __installUnpacker() {
|
|
14
|
+
const workletsCache = new Map<number, () => unknown>();
|
|
15
|
+
const handleCache = new WeakMap<object, unknown>();
|
|
16
|
+
|
|
17
|
+
function valueUnpacker(
|
|
18
|
+
objectToUnpack: ObjectToUnpack,
|
|
19
|
+
category?: string,
|
|
20
|
+
remoteFunctionName?: string
|
|
21
|
+
): unknown {
|
|
22
|
+
'use strict';
|
|
23
|
+
const workletHash = objectToUnpack.__workletHash;
|
|
24
|
+
if (workletHash !== undefined) {
|
|
25
|
+
let workletFun = workletsCache.get(workletHash);
|
|
26
|
+
if (workletFun === undefined) {
|
|
27
|
+
const initData = objectToUnpack.__initData;
|
|
28
|
+
if (globalThis.evalWithSourceMap) {
|
|
29
|
+
// if the runtime (hermes only for now) supports loading source maps
|
|
30
|
+
// we want to use the proper filename for the location as it guarantees
|
|
31
|
+
// that debugger understands and loads the source code of the file where
|
|
32
|
+
// the worklet is defined.
|
|
33
|
+
workletFun = globalThis.evalWithSourceMap(
|
|
34
|
+
'(' + initData!.code + '\n)',
|
|
35
|
+
initData!.location!,
|
|
36
|
+
initData!.sourceMap!
|
|
37
|
+
);
|
|
38
|
+
} else if (globalThis.evalWithSourceUrl) {
|
|
39
|
+
// if the runtime doesn't support loading source maps, in dev mode we
|
|
40
|
+
// can pass source url when evaluating the worklet. Now, instead of using
|
|
41
|
+
// the actual file location we use worklet hash, as it the allows us to
|
|
42
|
+
// properly symbolicate traces (see errors.ts for details)
|
|
43
|
+
workletFun = globalThis.evalWithSourceUrl(
|
|
44
|
+
'(' + initData!.code + '\n)',
|
|
45
|
+
`worklet_${workletHash}`
|
|
46
|
+
);
|
|
47
|
+
} else {
|
|
48
|
+
// in release we use the regular eval to save on JSI calls
|
|
49
|
+
// eslint-disable-next-line no-eval
|
|
50
|
+
workletFun = eval('(' + initData!.code + '\n)');
|
|
51
|
+
}
|
|
52
|
+
workletsCache.set(workletHash, workletFun!);
|
|
53
|
+
}
|
|
54
|
+
const functionInstance = workletFun!.bind(objectToUnpack);
|
|
55
|
+
objectToUnpack._recur = functionInstance;
|
|
56
|
+
return functionInstance;
|
|
57
|
+
} else if (objectToUnpack.__init !== undefined) {
|
|
58
|
+
let value = handleCache.get(objectToUnpack);
|
|
59
|
+
if (value === undefined) {
|
|
60
|
+
value = objectToUnpack.__init();
|
|
61
|
+
handleCache.set(objectToUnpack, value);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
} else if (category === 'RemoteFunction') {
|
|
65
|
+
const fun = () => {
|
|
66
|
+
const label = remoteFunctionName
|
|
67
|
+
? `function \`${remoteFunctionName}\``
|
|
68
|
+
: 'anonymous function';
|
|
69
|
+
// eslint-disable-next-line reanimated/use-worklets-error
|
|
70
|
+
throw new Error(`[Worklets] Tried to synchronously call a non-worklet ${label} on the UI thread.
|
|
71
|
+
See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#tried-to-synchronously-call-a-non-worklet-function-on-the-ui-thread for more details.`);
|
|
72
|
+
};
|
|
73
|
+
fun.__remoteFunction = objectToUnpack;
|
|
74
|
+
return fun;
|
|
75
|
+
} else {
|
|
76
|
+
// eslint-disable-next-line reanimated/use-worklets-error
|
|
77
|
+
throw new Error(
|
|
78
|
+
`[Worklets] Data type in category "${category}" not recognized by value unpacker: "${globalThis._toString(
|
|
79
|
+
objectToUnpack
|
|
80
|
+
)}".`
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
globalThis.__valueUnpacker = valueUnpacker as ValueUnpacker;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface ObjectToUnpack extends WorkletFunction {
|
|
89
|
+
_recur: unknown;
|
|
90
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import type { WorkletFunction } from './workletTypes';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This function allows you to determine if a given function is a worklet. It
|
|
7
|
+
* only works with Reanimated Babel plugin enabled. Unless you are doing
|
|
8
|
+
* something with internals of Reanimated you shouldn't need to use this
|
|
9
|
+
* function.
|
|
10
|
+
*
|
|
11
|
+
* ### Note
|
|
12
|
+
*
|
|
13
|
+
* Do not call it before the worklet is declared, as it will always return false
|
|
14
|
+
* then. E.g.:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* isWorkletFunction(myWorklet); // Will always return false.
|
|
18
|
+
*
|
|
19
|
+
* function myWorklet() {
|
|
20
|
+
* 'worklet';
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ### Maintainer note
|
|
25
|
+
*
|
|
26
|
+
* This function is supposed to be used only in the React Runtime. It always
|
|
27
|
+
* returns `false` in Worklet Runtimes.
|
|
28
|
+
*/
|
|
29
|
+
export function isWorkletFunction<
|
|
30
|
+
Args extends unknown[] = unknown[],
|
|
31
|
+
ReturnValue = unknown,
|
|
32
|
+
>(value: unknown): value is WorkletFunction<Args, ReturnValue> {
|
|
33
|
+
'worklet';
|
|
34
|
+
// Since host objects always return true for `in` operator, we have to use dot notation to check if the property exists.
|
|
35
|
+
// See https://github.com/facebook/hermes/blob/340726ef8cf666a7cce75bc60b02fa56b3e54560/lib/VM/JSObject.cpp#L1276.
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
// `__workletHash` isn't extracted in Worklet Runtimes.
|
|
39
|
+
typeof value === 'function' &&
|
|
40
|
+
!!(value as unknown as Record<string, unknown>).__workletHash
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { init } from './initializers';
|
|
4
|
+
import { SHOULD_BE_USE_WEB } from './PlatformChecker';
|
|
5
|
+
import { RuntimeKind } from './runtimeKind';
|
|
6
|
+
import { WorkletsError } from './WorkletsError';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This function is an entry point for Worklet Runtimes. We can use it to setup
|
|
10
|
+
* necessary tools, like the ValueUnpacker.
|
|
11
|
+
*
|
|
12
|
+
* We must throw an error at the end of this function to prevent the bundle to
|
|
13
|
+
* continue executing. This is because the next module to be ran would be the
|
|
14
|
+
* React Native one, and it would break the Worklet Runtime if initialized. The
|
|
15
|
+
* error is caught in C++ code.
|
|
16
|
+
*
|
|
17
|
+
* This function has no effect on the RN Runtime beside setting the
|
|
18
|
+
* `_WORKLETS_BUNDLE_MODE` flag.
|
|
19
|
+
*/
|
|
20
|
+
export function bundleModeInit() {
|
|
21
|
+
globalThis._WORKLETS_BUNDLE_MODE = true;
|
|
22
|
+
if (
|
|
23
|
+
!SHOULD_BE_USE_WEB &&
|
|
24
|
+
globalThis.__RUNTIME_KIND !== RuntimeKind.ReactNative
|
|
25
|
+
) {
|
|
26
|
+
/**
|
|
27
|
+
* We shouldn't call `init()` on RN Runtime here, as it would initialize our
|
|
28
|
+
* module before React Native has configured the RN Runtime.
|
|
29
|
+
*/
|
|
30
|
+
init();
|
|
31
|
+
throw new WorkletsError('Worklets initialized successfully');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bundleModeInit();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The below type is used for HostObjects returned by the JSI API that don't
|
|
5
|
+
* have any accessible fields or methods but can carry data that is accessed
|
|
6
|
+
* from the c++ side. We add a field to the type to make it possible for
|
|
7
|
+
* typescript to recognize which JSI methods accept those types as arguments and
|
|
8
|
+
* to be able to correctly type check other methods that may use them. However,
|
|
9
|
+
* this field is not actually defined nor should be used for anything else as
|
|
10
|
+
* assigning any data to those objects will throw an error.
|
|
11
|
+
*/
|
|
12
|
+
export type SerializableRef<T = unknown> = {
|
|
13
|
+
__serializableRef: true;
|
|
14
|
+
__nativeStateSerializableJSRef: T;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// In case of objects with depth or arrays of objects or arrays of arrays etc.
|
|
18
|
+
// we add this utility type that makes it a `SharaebleRef` of the outermost type.
|
|
19
|
+
export type FlatSerializableRef<T> =
|
|
20
|
+
T extends SerializableRef<infer U> ? SerializableRef<U> : SerializableRef<T>;
|
|
21
|
+
|
|
22
|
+
export type WorkletRuntime = {
|
|
23
|
+
__hostObjectWorkletRuntime: never;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type WorkletStackDetails = [
|
|
28
|
+
error: Error,
|
|
29
|
+
lineOffset: number,
|
|
30
|
+
columnOffset: number,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export type WorkletClosure = Record<string, unknown>;
|
|
34
|
+
|
|
35
|
+
interface WorkletInitData {
|
|
36
|
+
code: string;
|
|
37
|
+
/** Only in dev builds. */
|
|
38
|
+
location?: string;
|
|
39
|
+
/** Only in dev builds. */
|
|
40
|
+
sourceMap?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface WorkletProps {
|
|
44
|
+
__closure: WorkletClosure;
|
|
45
|
+
__workletHash: number;
|
|
46
|
+
/** Only in Legacy Bundling. */
|
|
47
|
+
__initData?: WorkletInitData;
|
|
48
|
+
/** Only for Handles. */
|
|
49
|
+
__init?: () => unknown;
|
|
50
|
+
/** `__stackDetails` is removed after parsing. */
|
|
51
|
+
__stackDetails?: WorkletStackDetails;
|
|
52
|
+
/** Only in dev builds. */
|
|
53
|
+
__pluginVersion?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type WorkletFunction<
|
|
57
|
+
TArgs extends unknown[] = unknown[],
|
|
58
|
+
TReturn = unknown,
|
|
59
|
+
> = ((...args: TArgs) => TReturn) & WorkletProps;
|
|
60
|
+
|
|
61
|
+
export interface WorkletFactory<
|
|
62
|
+
TArgs extends unknown[] = unknown[],
|
|
63
|
+
TReturn = unknown,
|
|
64
|
+
TClosureVariables extends Record<string, unknown> = Record<string, unknown>,
|
|
65
|
+
> {
|
|
66
|
+
(closureVariables: TClosureVariables): WorkletFunction<TArgs, TReturn>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type ValueUnpacker = WorkletFunction<
|
|
70
|
+
[objectToUnpack: unknown, category?: string],
|
|
71
|
+
unknown
|
|
72
|
+
>;
|
|
73
|
+
|
|
74
|
+
export interface WorkletImport {
|
|
75
|
+
__bundleData: {
|
|
76
|
+
/** Name of the module which is the source of the import. */
|
|
77
|
+
source: string;
|
|
78
|
+
/** The name of the imported value. */
|
|
79
|
+
imported: string;
|
|
80
|
+
};
|
|
81
|
+
}
|