@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,116 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <string>
|
|
3
|
+
#include <vector>
|
|
4
|
+
|
|
5
|
+
#ifdef WORKLETS_PROFILING
|
|
6
|
+
|
|
7
|
+
#if defined(__APPLE__)
|
|
8
|
+
#include <os/trace_base.h>
|
|
9
|
+
|
|
10
|
+
#if OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
11
|
+
#include <os/log.h>
|
|
12
|
+
#include <os/signpost.h>
|
|
13
|
+
#include <sstream>
|
|
14
|
+
#endif // OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
15
|
+
|
|
16
|
+
#elif defined(ANDROID)
|
|
17
|
+
|
|
18
|
+
#include <android/trace.h>
|
|
19
|
+
|
|
20
|
+
#endif // defined(ANDROID)
|
|
21
|
+
|
|
22
|
+
#endif // WORKLETS_PROFILING
|
|
23
|
+
|
|
24
|
+
namespace worklets {
|
|
25
|
+
|
|
26
|
+
#if defined(ANDROID) && defined(WORKLETS_PROFILING)
|
|
27
|
+
|
|
28
|
+
// avg 6.10 min 2.87 max 7.68 dev 0.42
|
|
29
|
+
// avg 6.09 min 3.29 max 8.62 dev 0.50
|
|
30
|
+
|
|
31
|
+
struct WorkletsSystraceSection {
|
|
32
|
+
public:
|
|
33
|
+
template <typename... ConvertsToStringPiece>
|
|
34
|
+
explicit WorkletsSystraceSection(const char *name, ConvertsToStringPiece &&...args) {
|
|
35
|
+
ATrace_beginSection(name);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
~WorkletsSystraceSection() {
|
|
39
|
+
ATrace_endSection();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// The apple part is copied from React Native
|
|
44
|
+
// from
|
|
45
|
+
// https://github.com/facebook/react-native/blob/5697d923a05119314b4cfcd556cb243986637764/packages/react-native/ReactCommon/cxxreact/SystraceSection.h
|
|
46
|
+
#elif defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && defined(WORKLETS_PROFILING)
|
|
47
|
+
|
|
48
|
+
template <typename T, typename = void>
|
|
49
|
+
struct renderer {
|
|
50
|
+
static std::string render(const T &t) {
|
|
51
|
+
std::ostringstream oss;
|
|
52
|
+
oss << t;
|
|
53
|
+
return oss.str();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
template <typename T>
|
|
58
|
+
static auto render(const T &t) -> decltype(renderer<T>::render(std::declval<const T &>())) {
|
|
59
|
+
return renderer<T>::render(t);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inline os_log_t instrumentsLogHandle = nullptr;
|
|
63
|
+
|
|
64
|
+
static inline os_log_t getOrCreateInstrumentsLogHandle() {
|
|
65
|
+
if (!instrumentsLogHandle) {
|
|
66
|
+
instrumentsLogHandle = os_log_create("dev.worklets.instruments", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
|
|
67
|
+
}
|
|
68
|
+
return instrumentsLogHandle;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
struct WorkletsSystraceSection {
|
|
72
|
+
public:
|
|
73
|
+
template <typename... ConvertsToStringPiece>
|
|
74
|
+
explicit WorkletsSystraceSection(const char *name, ConvertsToStringPiece &&...args) {
|
|
75
|
+
os_log_t instrumentsLogHandle = worklets::getOrCreateInstrumentsLogHandle();
|
|
76
|
+
|
|
77
|
+
// If the log isn't enabled, we don't want the performance overhead of the
|
|
78
|
+
// rest of the code below.
|
|
79
|
+
if (!os_signpost_enabled(instrumentsLogHandle)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
name_ = name;
|
|
84
|
+
|
|
85
|
+
const auto argsVector = std::vector<std::string>{worklets::render(args)...};
|
|
86
|
+
std::string argsString = "";
|
|
87
|
+
for (size_t i = 0; i < argsVector.size(); i += 2) {
|
|
88
|
+
argsString += argsVector[i] + "=" + argsVector[i + 1] + ";";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
signpostID_ = os_signpost_id_make_with_pointer(instrumentsLogHandle, this);
|
|
92
|
+
|
|
93
|
+
os_signpost_interval_begin(instrumentsLogHandle, signpostID_, "Worklets", "%s begin: %s", name, argsString.c_str());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
~WorkletsSystraceSection() {
|
|
97
|
+
os_signpost_interval_end(worklets::instrumentsLogHandle, signpostID_, "Worklets", "%s end", name_.data());
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private:
|
|
101
|
+
os_signpost_id_t signpostID_ = OS_SIGNPOST_ID_INVALID;
|
|
102
|
+
std::string_view name_;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
#else
|
|
106
|
+
|
|
107
|
+
struct WorkletsSystraceSection {
|
|
108
|
+
public:
|
|
109
|
+
template <typename... ConvertsToStringPiece>
|
|
110
|
+
explicit WorkletsSystraceSection(const char *name, ConvertsToStringPiece &&...args) {}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
#endif // defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES && \
|
|
114
|
+
// defined(WORKLETS_PROFILING)
|
|
115
|
+
|
|
116
|
+
} // namespace worklets
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#include <worklets/Tools/JSLogger.h>
|
|
2
|
+
#include <worklets/Tools/VersionUtils.h>
|
|
3
|
+
#include <worklets/Tools/WorkletsVersion.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
#ifdef WORKLETS_VERSION
|
|
9
|
+
#define STRINGIZE(x) #x
|
|
10
|
+
#define STRINGIZE2(x) STRINGIZE(x)
|
|
11
|
+
#define WORKLETS_VERSION_STRING STRINGIZE2(WORKLETS_VERSION)
|
|
12
|
+
#endif // WORKLETS_VERSION
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
|
|
16
|
+
namespace worklets {
|
|
17
|
+
|
|
18
|
+
std::string getWorkletsCppVersion() {
|
|
19
|
+
return std::string(WORKLETS_VERSION_STRING);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void injectWorkletsCppVersion(jsi::Runtime &rnRuntime) {
|
|
23
|
+
auto version = getWorkletsCppVersion();
|
|
24
|
+
rnRuntime.global().setProperty(rnRuntime, "_WORKLETS_VERSION_CPP", jsi::String::createFromUtf8(rnRuntime, version));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#ifndef NDEBUG
|
|
28
|
+
void checkJSVersion(jsi::Runtime &rnRuntime, const std::shared_ptr<worklets::JSLogger> &jsLogger) {
|
|
29
|
+
auto cppVersion = getWorkletsCppVersion();
|
|
30
|
+
auto jsVersionValue = rnRuntime.global().getProperty(rnRuntime, "_WORKLETS_VERSION_JS");
|
|
31
|
+
worklets::checkJSVersion(
|
|
32
|
+
rnRuntime,
|
|
33
|
+
jsVersionValue,
|
|
34
|
+
jsLogger,
|
|
35
|
+
cppVersion,
|
|
36
|
+
"Worklets",
|
|
37
|
+
"https://docs.swmansion.com/react-native-worklets/docs");
|
|
38
|
+
}
|
|
39
|
+
#else
|
|
40
|
+
void checkJSVersion(jsi::Runtime &rnRuntime, const std::shared_ptr<worklets::JSLogger> &jsLogger) {
|
|
41
|
+
// In release builds we don't check the version, hence
|
|
42
|
+
// this function is a NOOP.
|
|
43
|
+
}
|
|
44
|
+
#endif // NDEBUG
|
|
45
|
+
|
|
46
|
+
}; // namespace worklets
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <worklets/Tools/JSLogger.h>
|
|
4
|
+
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
std::string getWorkletsCppVersion();
|
|
15
|
+
void injectWorkletsCppVersion(jsi::Runtime &);
|
|
16
|
+
void checkJSVersion(jsi::Runtime &, const std::shared_ptr<worklets::JSLogger> &);
|
|
17
|
+
|
|
18
|
+
}; // namespace worklets
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
struct BundleModeConfig {
|
|
12
|
+
bool enabled;
|
|
13
|
+
std::shared_ptr<const ScriptBuffer> script;
|
|
14
|
+
std::string sourceURL;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
} // namespace worklets
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#include <worklets/WorkletRuntime/HermesProfiling.h>
|
|
2
|
+
|
|
3
|
+
#include <hermes/hermes.h>
|
|
4
|
+
|
|
5
|
+
#include <chrono>
|
|
6
|
+
#include <filesystem>
|
|
7
|
+
#include <sstream>
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
static std::string generateUniqueProfilePath() {
|
|
13
|
+
auto now = std::chrono::steady_clock::now().time_since_epoch().count();
|
|
14
|
+
std::ostringstream oss;
|
|
15
|
+
oss << "profile-" << now << ".cpuprofile";
|
|
16
|
+
std::filesystem::path dir = std::filesystem::temp_directory_path();
|
|
17
|
+
return (dir / oss.str()).string();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void startProfiling(facebook::jsi::Runtime &rt, double meanHzFreq) {
|
|
21
|
+
auto *ihermes = facebook::jsi::castInterface<facebook::hermes::IHermes>(&rt);
|
|
22
|
+
if (ihermes) {
|
|
23
|
+
ihermes->registerForProfiling();
|
|
24
|
+
}
|
|
25
|
+
auto *api = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(facebook::hermes::makeHermesRootAPI());
|
|
26
|
+
if (api) {
|
|
27
|
+
api->enableSamplingProfiler(meanHzFreq);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
std::string stopProfiling(facebook::jsi::Runtime &rt) {
|
|
32
|
+
std::string path = generateUniqueProfilePath();
|
|
33
|
+
auto *api = facebook::jsi::castInterface<facebook::hermes::IHermesRootAPI>(facebook::hermes::makeHermesRootAPI());
|
|
34
|
+
if (api) {
|
|
35
|
+
api->dumpSampledTraceToFile(path);
|
|
36
|
+
api->disableSamplingProfiler();
|
|
37
|
+
}
|
|
38
|
+
auto *ihermes = facebook::jsi::castInterface<facebook::hermes::IHermes>(&rt);
|
|
39
|
+
if (ihermes) {
|
|
40
|
+
ihermes->unregisterForProfiling();
|
|
41
|
+
}
|
|
42
|
+
return path;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
} // namespace worklets
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#include <worklets/Tools/WorkletsJSIUtils.h>
|
|
2
|
+
#include <worklets/Tools/WorkletsVersion.h>
|
|
3
|
+
#include <worklets/WorkletRuntime/HermesProfiling.h>
|
|
4
|
+
#include <worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h>
|
|
5
|
+
#include <worklets/WorkletRuntime/WorkletRuntimeCollector.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <utility>
|
|
10
|
+
|
|
11
|
+
namespace worklets {
|
|
12
|
+
|
|
13
|
+
void RNRuntimeWorkletDecorator::decorate(
|
|
14
|
+
jsi::Runtime &rnRuntime,
|
|
15
|
+
jsi::Object &&jsiWorkletsModuleProxy,
|
|
16
|
+
const std::shared_ptr<JSLogger> &jsLogger) {
|
|
17
|
+
rnRuntime.global().setProperty(
|
|
18
|
+
rnRuntime, RuntimeData::runtimeKindBindingName, static_cast<int>(RuntimeData::RuntimeKind::ReactNative));
|
|
19
|
+
|
|
20
|
+
rnRuntime.global().setProperty(
|
|
21
|
+
rnRuntime,
|
|
22
|
+
RuntimeData::runtimeNameBindingName,
|
|
23
|
+
jsi::String::createFromUtf8(rnRuntime, RuntimeData::rnRuntimeName));
|
|
24
|
+
|
|
25
|
+
rnRuntime.global().setProperty(rnRuntime, "_WORKLET", false);
|
|
26
|
+
|
|
27
|
+
rnRuntime.global().setProperty(rnRuntime, "__workletsModuleProxy", std::move(jsiWorkletsModuleProxy));
|
|
28
|
+
|
|
29
|
+
WorkletRuntimeCollector::install(rnRuntime);
|
|
30
|
+
|
|
31
|
+
#ifndef NDEBUG
|
|
32
|
+
checkJSVersion(rnRuntime, jsLogger);
|
|
33
|
+
#endif // NDEBUG
|
|
34
|
+
|
|
35
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
36
|
+
installDebugBindings(rnRuntime);
|
|
37
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
38
|
+
|
|
39
|
+
injectWorkletsCppVersion(rnRuntime);
|
|
40
|
+
|
|
41
|
+
rnRuntime.global().setProperty(
|
|
42
|
+
rnRuntime,
|
|
43
|
+
"_startProfiling",
|
|
44
|
+
jsi::Function::createFromHostFunction(
|
|
45
|
+
rnRuntime,
|
|
46
|
+
jsi::PropNameID::forAscii(rnRuntime, "_startProfiling"),
|
|
47
|
+
1,
|
|
48
|
+
[](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t count) {
|
|
49
|
+
const double meanHzFreq = (count > 0 && !args[0].isUndefined()) ? args[0].asNumber() : 100.0;
|
|
50
|
+
startProfiling(rt, meanHzFreq);
|
|
51
|
+
return jsi::Value::undefined();
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
jsi_utils::installJsiFunction(rnRuntime, "_stopProfiling", [](jsi::Runtime &rt) {
|
|
55
|
+
std::string path = stopProfiling(rt);
|
|
56
|
+
return jsi::String::createFromUtf8(rt, path);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
61
|
+
void RNRuntimeWorkletDecorator::installDebugBindings(jsi::Runtime &rnRuntime) {
|
|
62
|
+
jsi_utils::installJsiFunction(rnRuntime, "__hasNativeState", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
63
|
+
return jsi::Value(value.isObject() && value.asObject(rt).hasNativeState(rt));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
67
|
+
|
|
68
|
+
} // namespace worklets
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/NativeModules/WorkletsModuleProxy.h>
|
|
5
|
+
#include <worklets/Tools/JSLogger.h>
|
|
6
|
+
#include <memory>
|
|
7
|
+
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
class RNRuntimeWorkletDecorator {
|
|
13
|
+
// TODO: Rename to `RNRuntimeWorkletsDecorator` or something more suitable.
|
|
14
|
+
public:
|
|
15
|
+
static void
|
|
16
|
+
decorate(jsi::Runtime &rnRuntime, jsi::Object &&jsiWorkletsModuleProxy, const std::shared_ptr<JSLogger> &jsLogger);
|
|
17
|
+
|
|
18
|
+
#ifdef IS_REANIMATED_EXAMPLE_APP
|
|
19
|
+
private:
|
|
20
|
+
static void installDebugBindings(jsi::Runtime &rnRuntime);
|
|
21
|
+
#endif // IS_REANIMATED_EXAMPLE_APP
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
} // namespace worklets
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
|
|
5
|
+
#include <functional>
|
|
6
|
+
#include <stdexcept>
|
|
7
|
+
|
|
8
|
+
using namespace facebook;
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
struct RuntimeBindings {
|
|
13
|
+
using RequestAnimationFrame = std::function<void(std::function<void(const double)>)>;
|
|
14
|
+
// Host function extracted from RN runtime's `global.nativeLoggingHook`, used
|
|
15
|
+
// to forward logs from Worklet runtimes to the native console in Bundle Mode.
|
|
16
|
+
// Signature:
|
|
17
|
+
// jsi::Value(jsi::Runtime &rt, const jsi::Value &thisVal,
|
|
18
|
+
// const jsi::Value *args, size_t count)
|
|
19
|
+
// where args[0] is the message string and args[1] is the log level (double).
|
|
20
|
+
// https://github.com/facebook/react-native/blob/654d64655ab3e3319fdfd4bfbe1c19c0b1233ff8/packages/react-native/ReactCommon/jsitooling/react/runtime/JSRuntimeBindings.cpp
|
|
21
|
+
using NativeLoggingHook = jsi::HostFunctionType;
|
|
22
|
+
|
|
23
|
+
const RequestAnimationFrame requestAnimationFrame;
|
|
24
|
+
const NativeLoggingHook nativeLoggingHook;
|
|
25
|
+
|
|
26
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
27
|
+
using AbortRequest = std::function<void(jsi::Runtime &rt, double requestId)>;
|
|
28
|
+
using ClearCookies = std::function<void(jsi::Runtime &rt, jsi::Function &&responseSender)>;
|
|
29
|
+
#ifdef ANDROID
|
|
30
|
+
using SendRequest = std::function<void(
|
|
31
|
+
jsi::Runtime &rt,
|
|
32
|
+
jsi::String &method,
|
|
33
|
+
jsi::String &url,
|
|
34
|
+
double requestId,
|
|
35
|
+
jsi::Array &headers,
|
|
36
|
+
jsi::Object &data,
|
|
37
|
+
jsi::String &responseType,
|
|
38
|
+
bool incrementalUpdates,
|
|
39
|
+
double timeout,
|
|
40
|
+
bool withCredentials)>;
|
|
41
|
+
#else
|
|
42
|
+
using SendRequest = std::function<void(jsi::Runtime &rt, const jsi::Value &query, jsi::Function &&responseSender)>;
|
|
43
|
+
#endif // ANDROID
|
|
44
|
+
|
|
45
|
+
const AbortRequest abortRequest;
|
|
46
|
+
const ClearCookies clearCookies;
|
|
47
|
+
const SendRequest sendRequest;
|
|
48
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
inline RuntimeBindings::NativeLoggingHook extractNativeLoggingHookFromRNRuntime(jsi::Runtime &rnRuntime) {
|
|
52
|
+
auto nativeLoggingHookValue = rnRuntime.global().getProperty(rnRuntime, "nativeLoggingHook");
|
|
53
|
+
if (!nativeLoggingHookValue.isObject() || !nativeLoggingHookValue.asObject(rnRuntime).isFunction(rnRuntime)) {
|
|
54
|
+
throw std::runtime_error("[Worklets] nativeLoggingHook is missing.");
|
|
55
|
+
}
|
|
56
|
+
return nativeLoggingHookValue.asObject(rnRuntime).asFunction(rnRuntime).getHostFunction(rnRuntime);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} // namespace worklets
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
|
|
7
|
+
namespace worklets {
|
|
8
|
+
namespace RuntimeData {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents the different types of runtime environments available for
|
|
12
|
+
* worklets.
|
|
13
|
+
*/
|
|
14
|
+
enum class RuntimeKind : std::uint8_t {
|
|
15
|
+
ReactNative = 1,
|
|
16
|
+
UI = 2,
|
|
17
|
+
Worker = 3,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
constexpr auto runtimeKindBindingName = "__RUNTIME_KIND";
|
|
21
|
+
|
|
22
|
+
using RuntimeId = uint64_t;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Unused, but kept for possible future use.
|
|
26
|
+
*/
|
|
27
|
+
constexpr RuntimeId rnRuntimeId{static_cast<RuntimeId>(RuntimeKind::ReactNative)};
|
|
28
|
+
constexpr RuntimeId uiRuntimeId{static_cast<RuntimeId>(RuntimeKind::UI)};
|
|
29
|
+
|
|
30
|
+
constexpr facebook::jsi::UUID weakRuntimeUUID{0x770c6f2e, 0x1e4d, 0x436a, 0xa2b1, 0x9f322c8d5f5e};
|
|
31
|
+
|
|
32
|
+
constexpr const char *rnRuntimeName = "RN";
|
|
33
|
+
constexpr const char *uiRuntimeName = "UI";
|
|
34
|
+
constexpr const char *runtimeNameBindingName = "__RUNTIME_NAME";
|
|
35
|
+
|
|
36
|
+
}; // namespace RuntimeData
|
|
37
|
+
|
|
38
|
+
} // namespace worklets
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
|
|
5
|
+
namespace worklets {
|
|
6
|
+
|
|
7
|
+
class WorkletRuntime;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Holds a weak reference to a WorkletRuntime instance.
|
|
11
|
+
*
|
|
12
|
+
* Used to link jsi::Runtime instances back to their WorkletRuntime holders
|
|
13
|
+
* without inducing reference cycles.
|
|
14
|
+
*/
|
|
15
|
+
struct WeakRuntimeHolder {
|
|
16
|
+
std::weak_ptr<WorkletRuntime> weakRuntime;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
} // namespace worklets
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#include <worklets/NativeModules/JSIWorkletsModuleProxy.h>
|
|
2
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
3
|
+
#include <worklets/WorkletRuntime/RuntimeManager.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
#ifndef NDEBUG
|
|
13
|
+
namespace {
|
|
14
|
+
void evaluateModuleUpdate(
|
|
15
|
+
const std::shared_ptr<WorkletRuntime> &workletRuntime,
|
|
16
|
+
const std::string &code,
|
|
17
|
+
const std::string &sourceUrl) {
|
|
18
|
+
workletRuntime->runSync([&code, &sourceUrl](jsi::Runtime &rt) -> void {
|
|
19
|
+
const auto buffer = std::make_shared<jsi::StringBuffer>(code);
|
|
20
|
+
rt.evaluateJavaScript(buffer, sourceUrl);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
} // namespace
|
|
24
|
+
#endif // NDEBUG
|
|
25
|
+
|
|
26
|
+
std::shared_ptr<WorkletRuntime> RuntimeManager::getRuntime(uint64_t runtimeId) {
|
|
27
|
+
std::shared_lock lock(weakRuntimesMutex_);
|
|
28
|
+
if (weakRuntimes_.contains(runtimeId)) {
|
|
29
|
+
return weakRuntimes_.at(runtimeId).lock();
|
|
30
|
+
}
|
|
31
|
+
return nullptr;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
std::vector<std::shared_ptr<WorkletRuntime>> RuntimeManager::getAllRuntimes() {
|
|
35
|
+
std::shared_lock lock(weakRuntimesMutex_);
|
|
36
|
+
|
|
37
|
+
std::vector<std::shared_ptr<WorkletRuntime>> runtimes;
|
|
38
|
+
runtimes.reserve(weakRuntimes_.size());
|
|
39
|
+
|
|
40
|
+
for (const auto &[id, weakRuntime] : weakRuntimes_) {
|
|
41
|
+
if (auto runtime = weakRuntime.lock()) {
|
|
42
|
+
runtimes.push_back(runtime);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return runtimes;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
std::shared_ptr<WorkletRuntime> RuntimeManager::getUIRuntime() {
|
|
50
|
+
return getRuntime(RuntimeData::uiRuntimeId);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::shared_ptr<WorkletRuntime> RuntimeManager::createWorkletRuntime(
|
|
54
|
+
const std::shared_ptr<const JSIWorkletsModuleProxy> &sourceProxy,
|
|
55
|
+
const std::string &name,
|
|
56
|
+
const std::shared_ptr<SerializableWorklet> &initializer,
|
|
57
|
+
const std::shared_ptr<AsyncQueue> &queue,
|
|
58
|
+
bool enableEventLoop) {
|
|
59
|
+
const auto runtimeId = getNextRuntimeId();
|
|
60
|
+
|
|
61
|
+
const auto workletRuntime =
|
|
62
|
+
std::make_shared<WorkletRuntime>(runtimeId, RuntimeData::RuntimeKind::Worker, name, queue, enableEventLoop);
|
|
63
|
+
const auto targetProxy = JSIWorkletsModuleProxy::createForNewRuntime(sourceProxy, runtimeId);
|
|
64
|
+
|
|
65
|
+
workletRuntime->init(targetProxy);
|
|
66
|
+
|
|
67
|
+
#ifndef NDEBUG
|
|
68
|
+
withRegistrationPaused([&] { loadModuleUpdates(workletRuntime); });
|
|
69
|
+
#endif // NDEBUG
|
|
70
|
+
|
|
71
|
+
if (initializer) {
|
|
72
|
+
workletRuntime->runSync(initializer);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
registerRuntime(runtimeId, workletRuntime);
|
|
76
|
+
|
|
77
|
+
return workletRuntime;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
#ifndef NDEBUG
|
|
81
|
+
void RuntimeManager::propagateModuleUpdate(const std::string &code, const std::string &sourceUrl) {
|
|
82
|
+
std::unique_lock registrationLock(registrationMutex_);
|
|
83
|
+
|
|
84
|
+
moduleUpdates_.push_back(ModuleUpdate{.sourceUrl = sourceUrl, .code = code});
|
|
85
|
+
|
|
86
|
+
for (const auto &runtime : getAllRuntimes()) {
|
|
87
|
+
evaluateModuleUpdate(runtime, code, sourceUrl);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
void RuntimeManager::loadModuleUpdates(const std::shared_ptr<WorkletRuntime> &workletRuntime) {
|
|
92
|
+
for (const auto &update : moduleUpdates_) {
|
|
93
|
+
evaluateModuleUpdate(workletRuntime, update.code, update.sourceUrl);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
#endif // NDEBUG
|
|
97
|
+
|
|
98
|
+
std::shared_ptr<WorkletRuntime> RuntimeManager::createUninitializedUIRuntime(
|
|
99
|
+
const std::shared_ptr<AsyncQueue> &uiAsyncQueue) {
|
|
100
|
+
const auto uiRuntime = std::make_shared<WorkletRuntime>(
|
|
101
|
+
RuntimeData::uiRuntimeId,
|
|
102
|
+
RuntimeData::RuntimeKind::UI,
|
|
103
|
+
RuntimeData::uiRuntimeName,
|
|
104
|
+
uiAsyncQueue,
|
|
105
|
+
/*enableEventLoop*/ false);
|
|
106
|
+
|
|
107
|
+
registerRuntime(RuntimeData::uiRuntimeId, uiRuntime);
|
|
108
|
+
|
|
109
|
+
return uiRuntime;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
uint64_t RuntimeManager::getNextRuntimeId() {
|
|
113
|
+
return nextRuntimeId_.fetch_add(1, std::memory_order_relaxed);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
void RuntimeManager::registerRuntime(const uint64_t runtimeId, const std::shared_ptr<WorkletRuntime> &workletRuntime) {
|
|
117
|
+
std::unique_lock registrationLock(registrationMutex_);
|
|
118
|
+
std::unique_lock lock(weakRuntimesMutex_);
|
|
119
|
+
weakRuntimes_[runtimeId] = workletRuntime;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
} // namespace worklets
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
5
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
6
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
7
|
+
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <map>
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include <mutex>
|
|
13
|
+
#include <shared_mutex>
|
|
14
|
+
#include <string>
|
|
15
|
+
#include <utility>
|
|
16
|
+
#include <vector>
|
|
17
|
+
|
|
18
|
+
namespace worklets {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Forward declaration to avoid circular dependencies.
|
|
22
|
+
*/
|
|
23
|
+
class JSIWorkletsModuleProxy;
|
|
24
|
+
|
|
25
|
+
class RuntimeManager {
|
|
26
|
+
public:
|
|
27
|
+
std::shared_ptr<WorkletRuntime> getRuntime(uint64_t runtimeId);
|
|
28
|
+
|
|
29
|
+
std::vector<std::shared_ptr<WorkletRuntime>> getAllRuntimes();
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<WorkletRuntime> getUIRuntime();
|
|
32
|
+
|
|
33
|
+
std::shared_ptr<WorkletRuntime> createWorkletRuntime(
|
|
34
|
+
const std::shared_ptr<const JSIWorkletsModuleProxy> &sourceProxy,
|
|
35
|
+
const std::string &name,
|
|
36
|
+
const std::shared_ptr<SerializableWorklet> &initializer = nullptr,
|
|
37
|
+
const std::shared_ptr<AsyncQueue> &queue = nullptr,
|
|
38
|
+
bool enableEventLoop = true);
|
|
39
|
+
|
|
40
|
+
std::shared_ptr<WorkletRuntime> createUninitializedUIRuntime(const std::shared_ptr<AsyncQueue> &uiAsyncQueue);
|
|
41
|
+
|
|
42
|
+
#ifndef NDEBUG
|
|
43
|
+
void propagateModuleUpdate(const std::string &code, const std::string &sourceUrl);
|
|
44
|
+
#endif // NDEBUG
|
|
45
|
+
|
|
46
|
+
template <class Fn>
|
|
47
|
+
decltype(auto) withRegistrationPaused(Fn &&fn) {
|
|
48
|
+
std::unique_lock lock(registrationMutex_);
|
|
49
|
+
return std::forward<Fn>(fn)();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private:
|
|
53
|
+
uint64_t getNextRuntimeId();
|
|
54
|
+
|
|
55
|
+
void registerRuntime(const uint64_t runtimeId, const std::shared_ptr<WorkletRuntime> &workletRuntime);
|
|
56
|
+
|
|
57
|
+
#ifndef NDEBUG
|
|
58
|
+
void loadModuleUpdates(const std::shared_ptr<WorkletRuntime> &workletRuntime);
|
|
59
|
+
|
|
60
|
+
struct ModuleUpdate {
|
|
61
|
+
std::string sourceUrl;
|
|
62
|
+
std::string code;
|
|
63
|
+
};
|
|
64
|
+
#endif // NDEBUG
|
|
65
|
+
|
|
66
|
+
std::atomic_uint64_t nextRuntimeId_{RuntimeData::uiRuntimeId + 1};
|
|
67
|
+
std::map<uint64_t, std::weak_ptr<WorkletRuntime>> weakRuntimes_;
|
|
68
|
+
std::shared_mutex weakRuntimesMutex_;
|
|
69
|
+
std::mutex registrationMutex_;
|
|
70
|
+
#ifndef NDEBUG
|
|
71
|
+
std::vector<ModuleUpdate> moduleUpdates_;
|
|
72
|
+
#endif // NDEBUG
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace worklets
|