@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,84 @@
|
|
|
1
|
+
import groovy.json.JsonSlurper
|
|
2
|
+
|
|
3
|
+
// Workaround for Android Studio's C++ analyzer surfacing errors during Gradle
|
|
4
|
+
// Sync when CMake's precompiled header binary (`cmake_pch.hxx.pch`, generated
|
|
5
|
+
// from `WorkletsPCH.h`) hasn't been built yet. The project compiles fine,
|
|
6
|
+
// but on a clean sync the IDE can't index sources without the PCH binary. See
|
|
7
|
+
// the underlying issue: https://issuetracker.google.com/issues/187448826
|
|
8
|
+
|
|
9
|
+
// Generates minimal stub `.pch` files from an empty header so the IDE's C++
|
|
10
|
+
// engine doesn't fail during sync. The actual build regenerates the real PCH
|
|
11
|
+
// files via ninja because we set each stub PCH's mtime older than its source
|
|
12
|
+
// (`cmake_pch.hxx.cxx`).
|
|
13
|
+
|
|
14
|
+
// Adapted from Expo's PR: https://github.com/expo/expo/pull/45921
|
|
15
|
+
|
|
16
|
+
val cxxDir = project.file(".cxx")
|
|
17
|
+
|
|
18
|
+
val generateStubPCHTask = tasks.register("generateStubPCH") {
|
|
19
|
+
dependsOn("configureCMakeDebug")
|
|
20
|
+
doLast {
|
|
21
|
+
if (!cxxDir.exists()) {
|
|
22
|
+
return@doLast
|
|
23
|
+
}
|
|
24
|
+
cxxDir.walkTopDown().forEach { file ->
|
|
25
|
+
if (file.name != "compile_commands.json") {
|
|
26
|
+
return@forEach
|
|
27
|
+
}
|
|
28
|
+
@Suppress("UNCHECKED_CAST")
|
|
29
|
+
val entries = JsonSlurper().parseText(file.readText()) as List<Map<String, Any>>
|
|
30
|
+
entries.forEach entry@{ entry ->
|
|
31
|
+
val entryFile = entry["file"] as String
|
|
32
|
+
if (!entryFile.endsWith("cmake_pch.hxx.cxx")) {
|
|
33
|
+
return@entry
|
|
34
|
+
}
|
|
35
|
+
val pchFile = File(entryFile.substring(0, entryFile.length - ".cxx".length) + ".pch")
|
|
36
|
+
if (!pchFile.exists() || pchFile.length() == 0L) {
|
|
37
|
+
pchFile.parentFile.mkdirs()
|
|
38
|
+
|
|
39
|
+
val command = entry["command"] as String
|
|
40
|
+
val compiler = command.split(" ").first()
|
|
41
|
+
val target = Regex("""--target=\S+""").find(command)!!.value
|
|
42
|
+
val sysroot = Regex("""--sysroot=\S+""").find(command)!!.value
|
|
43
|
+
|
|
44
|
+
val stubHeader = File(pchFile.parentFile, "stub_pch.hxx")
|
|
45
|
+
stubHeader.writeText("")
|
|
46
|
+
|
|
47
|
+
val process = ProcessBuilder(
|
|
48
|
+
compiler,
|
|
49
|
+
target,
|
|
50
|
+
sysroot,
|
|
51
|
+
"-x", "c++-header",
|
|
52
|
+
"-o", pchFile.absolutePath,
|
|
53
|
+
stubHeader.absolutePath,
|
|
54
|
+
)
|
|
55
|
+
.directory(File(entry["directory"] as String))
|
|
56
|
+
.redirectErrorStream(true)
|
|
57
|
+
.start()
|
|
58
|
+
process.outputStream.close()
|
|
59
|
+
if (process.waitFor() != 0) {
|
|
60
|
+
throw GradleException(
|
|
61
|
+
"Stub PCH generation failed: ${process.inputStream.bufferedReader().readText()}",
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Ensure PCH is older than source so ninja rebuilds the real one during build
|
|
66
|
+
pchFile.setLastModified(File(entryFile).lastModified() - 1)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Register `prepareKotlinBuildScriptModel` if absent (Android Studio sync needs it
|
|
73
|
+
// to exist so the stub PCH generation runs) or configure it if some other plugin
|
|
74
|
+
// already registered it (e.g. on CI, where re-registering throws `Cannot add task
|
|
75
|
+
// 'prepareKotlinBuildScriptModel' as a task with that name already exists.`).
|
|
76
|
+
if (tasks.findByName("prepareKotlinBuildScriptModel") == null) {
|
|
77
|
+
tasks.register("prepareKotlinBuildScriptModel") {
|
|
78
|
+
dependsOn(generateStubPCHTask)
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
tasks.named("prepareKotlinBuildScriptModel") {
|
|
82
|
+
dependsOn(generateStubPCHTask)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Project-wide Gradle settings.
|
|
2
|
+
|
|
3
|
+
# IDE (e.g. Android Studio) users:
|
|
4
|
+
# Gradle settings configured through the IDE *will override*
|
|
5
|
+
# any settings specified in this file.
|
|
6
|
+
|
|
7
|
+
# For more details on how to configure your build environment visit
|
|
8
|
+
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
|
9
|
+
|
|
10
|
+
# Specifies the JVM arguments used for the daemon process.
|
|
11
|
+
# The setting is particularly useful for tweaking memory settings.
|
|
12
|
+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
|
|
13
|
+
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
|
14
|
+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
|
15
|
+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
|
16
|
+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
|
17
|
+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
|
18
|
+
|
|
19
|
+
# When configured, Gradle will run in incubating parallel mode.
|
|
20
|
+
# This option should only be used with decoupled projects. More details, visit
|
|
21
|
+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
|
22
|
+
# org.gradle.parallel=true
|
|
23
|
+
|
|
24
|
+
android.useAndroidX=true
|
|
25
|
+
android.enableJetifier=true
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
pluginManagement {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
resolutionStrategy {
|
|
7
|
+
eachPlugin {
|
|
8
|
+
if (requested.id.id.startsWith("com.android")) {
|
|
9
|
+
useModule("com.android.tools.build:gradle:8.13.1")
|
|
10
|
+
}
|
|
11
|
+
if (requested.id.id == "com.diffplug.spotless") {
|
|
12
|
+
useModule("com.diffplug.spotless:spotless-plugin-gradle:8.1.0")
|
|
13
|
+
}
|
|
14
|
+
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
|
|
15
|
+
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20")
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
rootProject.name = "worklets"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// IWYU pragma: begin_keep
|
|
4
|
+
|
|
5
|
+
// C++ standard library
|
|
6
|
+
#include <algorithm>
|
|
7
|
+
#include <atomic>
|
|
8
|
+
#include <functional>
|
|
9
|
+
#include <map>
|
|
10
|
+
#include <memory>
|
|
11
|
+
#include <mutex>
|
|
12
|
+
#include <optional>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <string_view>
|
|
15
|
+
#include <type_traits>
|
|
16
|
+
#include <unordered_map>
|
|
17
|
+
#include <utility>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
// fbjni
|
|
21
|
+
#include <fbjni/fbjni.h>
|
|
22
|
+
|
|
23
|
+
// jsi
|
|
24
|
+
#include <jsi/jsi.h>
|
|
25
|
+
|
|
26
|
+
// IWYU pragma: end_keep
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#include <worklets/android/AndroidUIScheduler.h>
|
|
2
|
+
|
|
3
|
+
#include <utility>
|
|
4
|
+
|
|
5
|
+
namespace worklets {
|
|
6
|
+
|
|
7
|
+
using namespace facebook;
|
|
8
|
+
using namespace react;
|
|
9
|
+
|
|
10
|
+
static thread_local bool tls_isOnUIThread = false;
|
|
11
|
+
|
|
12
|
+
class UISchedulerWrapper : public UIScheduler {
|
|
13
|
+
private:
|
|
14
|
+
jni::global_ref<AndroidUIScheduler::javaobject> androidUiScheduler_;
|
|
15
|
+
|
|
16
|
+
public:
|
|
17
|
+
explicit UISchedulerWrapper(jni::global_ref<AndroidUIScheduler::javaobject> androidUiScheduler)
|
|
18
|
+
: androidUiScheduler_(std::move(androidUiScheduler)) {}
|
|
19
|
+
|
|
20
|
+
void scheduleOnUI(std::function<void()> job) override {
|
|
21
|
+
if (tls_isOnUIThread) {
|
|
22
|
+
job();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
UIScheduler::scheduleOnUI(job);
|
|
26
|
+
if (!scheduledOnUI_) {
|
|
27
|
+
scheduledOnUI_ = true;
|
|
28
|
+
static const auto method = androidUiScheduler_->getClass()->getMethod<void()>("scheduleTriggerOnUI");
|
|
29
|
+
method(androidUiScheduler_);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void triggerUI() override {
|
|
34
|
+
tls_isOnUIThread = true;
|
|
35
|
+
UIScheduler::triggerUI();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
AndroidUIScheduler::AndroidUIScheduler(const jni::alias_ref<AndroidUIScheduler::jhybridobject> &jThis)
|
|
40
|
+
: uiScheduler_(std::make_shared<UISchedulerWrapper>(jni::make_global(jThis))) {}
|
|
41
|
+
|
|
42
|
+
jni::local_ref<AndroidUIScheduler::jhybriddata> AndroidUIScheduler::initHybrid(
|
|
43
|
+
jni::alias_ref<jhybridobject> jThis) { // NOLINT //(performance-unnecessary-value-param)
|
|
44
|
+
return makeCxxInstance(jThis);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
void AndroidUIScheduler::triggerUI() {
|
|
48
|
+
if (!uiScheduler_) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
uiScheduler_->triggerUI();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void AndroidUIScheduler::invalidate() {
|
|
55
|
+
uiScheduler_.reset();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void AndroidUIScheduler::registerNatives() {
|
|
59
|
+
registerHybrid({
|
|
60
|
+
makeNativeMethod("initHybrid", AndroidUIScheduler::initHybrid),
|
|
61
|
+
makeNativeMethod("triggerUI", AndroidUIScheduler::triggerUI),
|
|
62
|
+
makeNativeMethod("invalidate", AndroidUIScheduler::invalidate),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
} // namespace worklets
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <worklets/Tools/UIScheduler.h>
|
|
4
|
+
|
|
5
|
+
#include <fbjni/fbjni.h>
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include <memory>
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
using namespace facebook;
|
|
13
|
+
using namespace worklets;
|
|
14
|
+
|
|
15
|
+
class AndroidUIScheduler : public jni::HybridClass<AndroidUIScheduler> {
|
|
16
|
+
public:
|
|
17
|
+
static auto constexpr kJavaDescriptor = "Lcom/swmansion/worklets/AndroidUIScheduler;";
|
|
18
|
+
static jni::local_ref<jhybriddata> initHybrid(
|
|
19
|
+
jni::alias_ref<jhybridobject> jThis); // NOLINT //(performance-unnecessary-value-param)
|
|
20
|
+
static void registerNatives();
|
|
21
|
+
|
|
22
|
+
std::shared_ptr<UIScheduler> getUIScheduler() {
|
|
23
|
+
return uiScheduler_;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private:
|
|
27
|
+
friend HybridBase;
|
|
28
|
+
|
|
29
|
+
void triggerUI();
|
|
30
|
+
|
|
31
|
+
void invalidate();
|
|
32
|
+
|
|
33
|
+
std::shared_ptr<UIScheduler> uiScheduler_;
|
|
34
|
+
|
|
35
|
+
explicit AndroidUIScheduler(const jni::alias_ref<AndroidUIScheduler::jhybridobject> &jThis);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace worklets
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <fbjni/fbjni.h>
|
|
4
|
+
|
|
5
|
+
#include <utility>
|
|
6
|
+
|
|
7
|
+
namespace worklets {
|
|
8
|
+
|
|
9
|
+
class AnimationFrameCallback : public facebook::jni::HybridClass<AnimationFrameCallback> {
|
|
10
|
+
public:
|
|
11
|
+
static auto constexpr kJavaDescriptor = "Lcom/swmansion/worklets/runloop/AnimationFrameCallback;";
|
|
12
|
+
|
|
13
|
+
void onAnimationFrame(double timestampMs) {
|
|
14
|
+
callback_(timestampMs);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static void registerNatives() {
|
|
18
|
+
javaClassStatic()->registerNatives({
|
|
19
|
+
makeNativeMethod("onAnimationFrame", AnimationFrameCallback::onAnimationFrame),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private:
|
|
24
|
+
friend HybridBase;
|
|
25
|
+
|
|
26
|
+
explicit AnimationFrameCallback(std::function<void(const double)> callback) : callback_(std::move(callback)) {}
|
|
27
|
+
|
|
28
|
+
std::function<void(double)> callback_;
|
|
29
|
+
};
|
|
30
|
+
} // namespace worklets
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on
|
|
3
|
+
* https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/jni/react/jni/JSLoader.cpp
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include <cxxreact/RecoverableError.h>
|
|
7
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
8
|
+
#include <worklets/android/JScriptBufferWrapper.h>
|
|
9
|
+
|
|
10
|
+
#include <utility>
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
using namespace facebook::jni;
|
|
15
|
+
|
|
16
|
+
jni::local_ref<JScriptBufferWrapper::jhybriddata> JScriptBufferWrapper::initHybridFromAssets(
|
|
17
|
+
jni::alias_ref<jhybridobject> jThis, // NOLINT //(performance-unnecessary-value-param)
|
|
18
|
+
jni::alias_ref<JAssetManager::javaobject> assetManager, // NOLINT //(performance-unnecessary-value-param)
|
|
19
|
+
const std::string &sourceURL) {
|
|
20
|
+
auto manager = extractAssetManager(assetManager);
|
|
21
|
+
auto bigString = loadScriptFromAssets(manager, sourceURL);
|
|
22
|
+
auto script = std::make_shared<ScriptBuffer>(std::move(bigString));
|
|
23
|
+
return makeCxxInstance(std::move(script), sourceURL);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
jni::local_ref<JScriptBufferWrapper::jhybriddata> JScriptBufferWrapper::initHybridFromFile(
|
|
27
|
+
jni::alias_ref<jhybridobject> jThis, // NOLINT //(performance-unnecessary-value-param)
|
|
28
|
+
const std::string &fileName) {
|
|
29
|
+
std::shared_ptr<const ScriptBuffer> script;
|
|
30
|
+
RecoverableError::runRethrowingAsRecoverable<std::system_error>([&fileName, &script]() {
|
|
31
|
+
auto bigString = JSBigFileString::fromPath(fileName);
|
|
32
|
+
script = std::make_shared<ScriptBuffer>(std::move(bigString));
|
|
33
|
+
});
|
|
34
|
+
return makeCxxInstance(std::move(script), fileName);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
jni::local_ref<JScriptBufferWrapper::jhybriddata> JScriptBufferWrapper::initHybridFromString(
|
|
38
|
+
jni::alias_ref<jhybridobject> jThis, // NOLINT //(performance-unnecessary-value-param)
|
|
39
|
+
const std::string &scriptStr,
|
|
40
|
+
const std::string &sourceURL) {
|
|
41
|
+
auto bigString = std::make_shared<JSBigStdString>(scriptStr);
|
|
42
|
+
auto script = std::make_shared<ScriptBuffer>(std::move(bigString));
|
|
43
|
+
return makeCxxInstance(std::move(script), sourceURL);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
JScriptBufferWrapper::JScriptBufferWrapper(
|
|
47
|
+
const std::shared_ptr<const ScriptBuffer> &script,
|
|
48
|
+
const std::string &sourceUrl)
|
|
49
|
+
: script_(script), sourceUrl_(sourceUrl) {}
|
|
50
|
+
|
|
51
|
+
std::shared_ptr<const ScriptBuffer> JScriptBufferWrapper::getScript() const {
|
|
52
|
+
return script_;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::string JScriptBufferWrapper::getSourceUrl() const {
|
|
56
|
+
return sourceUrl_;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void JScriptBufferWrapper::registerNatives() {
|
|
60
|
+
registerHybrid({
|
|
61
|
+
makeNativeMethod("initHybridFromAssets", JScriptBufferWrapper::initHybridFromAssets),
|
|
62
|
+
makeNativeMethod("initHybridFromFile", JScriptBufferWrapper::initHybridFromFile),
|
|
63
|
+
makeNativeMethod("initHybridFromString", JScriptBufferWrapper::initHybridFromString),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
} // namespace worklets
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <fbjni/fbjni.h>
|
|
4
|
+
#include <jsireact/JSIExecutor.h>
|
|
5
|
+
#include <react/jni/JSLoader.h>
|
|
6
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
7
|
+
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <string>
|
|
10
|
+
|
|
11
|
+
namespace worklets {
|
|
12
|
+
|
|
13
|
+
using namespace facebook;
|
|
14
|
+
using namespace facebook::react;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* JScriptBufferWrapper is a JNI wrapper class that holds a ScriptBuffer containing
|
|
18
|
+
* JavaScript code and its source URL, to be evaluated on a WorkletRuntime.
|
|
19
|
+
*/
|
|
20
|
+
class JScriptBufferWrapper : public jni::HybridClass<JScriptBufferWrapper> {
|
|
21
|
+
public:
|
|
22
|
+
constexpr static const char *const kJavaDescriptor = "Lcom/swmansion/worklets/ScriptBufferWrapper;";
|
|
23
|
+
|
|
24
|
+
static void registerNatives();
|
|
25
|
+
|
|
26
|
+
[[nodiscard]] std::shared_ptr<const ScriptBuffer> getScript() const;
|
|
27
|
+
[[nodiscard]] std::string getSourceUrl() const;
|
|
28
|
+
|
|
29
|
+
private:
|
|
30
|
+
static jni::local_ref<JScriptBufferWrapper::jhybriddata> initHybridFromAssets(
|
|
31
|
+
jni::alias_ref<jhybridobject> jThis,
|
|
32
|
+
jni::alias_ref<JAssetManager::javaobject> assetManager,
|
|
33
|
+
const std::string &assetURL);
|
|
34
|
+
static jni::local_ref<JScriptBufferWrapper::jhybriddata> initHybridFromFile(
|
|
35
|
+
jni::alias_ref<jhybridobject> jThis,
|
|
36
|
+
const std::string &fileName);
|
|
37
|
+
static jni::local_ref<JScriptBufferWrapper::jhybriddata>
|
|
38
|
+
initHybridFromString(jni::alias_ref<jhybridobject> jThis, const std::string &script, const std::string &sourceURL);
|
|
39
|
+
|
|
40
|
+
friend HybridBase;
|
|
41
|
+
|
|
42
|
+
explicit JScriptBufferWrapper(const std::shared_ptr<const ScriptBuffer> &script, const std::string &sourceUrl);
|
|
43
|
+
|
|
44
|
+
const std::shared_ptr<const ScriptBuffer> script_;
|
|
45
|
+
const std::string sourceUrl_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace worklets
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
2
|
+
|
|
3
|
+
#include <jsi/JSIDynamic.h>
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
#include <worklets/android/JWorkletRuntimeWrapper.h>
|
|
6
|
+
|
|
7
|
+
#include <utility>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace worklets {
|
|
11
|
+
|
|
12
|
+
using namespace facebook::jni;
|
|
13
|
+
|
|
14
|
+
local_ref<JWorkletRuntimeWrapper::JavaPart> JWorkletRuntimeWrapper::makeJWorkletRuntimeWrapper(
|
|
15
|
+
std::shared_ptr<WorkletRuntime> workletRuntime) {
|
|
16
|
+
return JWorkletRuntimeWrapper::newObjectCxxArgs(std::move(workletRuntime));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
JWorkletRuntimeWrapper::JWorkletRuntimeWrapper(std::shared_ptr<WorkletRuntime> workletRuntime)
|
|
20
|
+
: workletRuntime_(std::move(workletRuntime)) {}
|
|
21
|
+
|
|
22
|
+
void JWorkletRuntimeWrapper::cxxEmitDeviceEvent(
|
|
23
|
+
jni::alias_ref<WritableNativeArray::javaobject> params // NOLINT //(performance-unnecessary-value-param
|
|
24
|
+
) {
|
|
25
|
+
workletRuntime_->schedule([params = params->cthis()->consume()](jsi::Runtime &rt) {
|
|
26
|
+
facebook::jsi::Value emitter = rt.global().getProperty(rt, "__rctDeviceEventEmitter");
|
|
27
|
+
if (!emitter.isUndefined()) {
|
|
28
|
+
facebook::jsi::Object emitterObject = emitter.asObject(rt);
|
|
29
|
+
facebook::jsi::Function emitFunction = emitterObject.getPropertyAsFunction(rt, "emit");
|
|
30
|
+
std::vector<jsi::Value> jsArgs;
|
|
31
|
+
for (auto ¶m : params) {
|
|
32
|
+
jsArgs.push_back(jsi::valueFromDynamic(rt, param));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
emitFunction.callWithThis(rt, emitterObject, static_cast<const jsi::Value *>(jsArgs.data()), jsArgs.size());
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
int JWorkletRuntimeWrapper::cxxGetRuntimeId() {
|
|
41
|
+
return static_cast<int>(workletRuntime_->getRuntimeId());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void JWorkletRuntimeWrapper::registerNatives() {
|
|
45
|
+
registerHybrid(
|
|
46
|
+
{makeNativeMethod("cxxEmitDeviceEvent", JWorkletRuntimeWrapper::cxxEmitDeviceEvent),
|
|
47
|
+
makeNativeMethod("cxxGetRuntimeId", JWorkletRuntimeWrapper::cxxGetRuntimeId)});
|
|
48
|
+
}
|
|
49
|
+
} // namespace worklets
|
|
50
|
+
|
|
51
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
4
|
+
|
|
5
|
+
#include <fbjni/fbjni.h>
|
|
6
|
+
#include <react/jni/ReadableNativeArray.h>
|
|
7
|
+
#include <react/jni/WritableNativeArray.h>
|
|
8
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
9
|
+
|
|
10
|
+
#include <memory>
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
using namespace facebook::jni;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* JNI wrapper around WorkletRuntime to expose its methods to Java.
|
|
20
|
+
*/
|
|
21
|
+
class JWorkletRuntimeWrapper : public jni::HybridClass<JWorkletRuntimeWrapper> {
|
|
22
|
+
public:
|
|
23
|
+
constexpr static const char *const kJavaDescriptor = "Lcom/swmansion/worklets/WorkletRuntimeWrapper;";
|
|
24
|
+
|
|
25
|
+
static local_ref<JWorkletRuntimeWrapper::JavaPart> makeJWorkletRuntimeWrapper(
|
|
26
|
+
std::shared_ptr<WorkletRuntime> workletRuntime);
|
|
27
|
+
|
|
28
|
+
static void registerNatives();
|
|
29
|
+
|
|
30
|
+
void cxxEmitDeviceEvent(jni::alias_ref<WritableNativeArray::javaobject> params);
|
|
31
|
+
int cxxGetRuntimeId();
|
|
32
|
+
|
|
33
|
+
private:
|
|
34
|
+
friend HybridBase;
|
|
35
|
+
|
|
36
|
+
explicit JWorkletRuntimeWrapper(std::shared_ptr<WorkletRuntime> workletRuntime);
|
|
37
|
+
|
|
38
|
+
const std::shared_ptr<WorkletRuntime> workletRuntime_;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace worklets
|
|
42
|
+
|
|
43
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#include <android/log.h>
|
|
2
|
+
|
|
3
|
+
#include <worklets/Tools/PlatformLogger.h>
|
|
4
|
+
|
|
5
|
+
#include <string>
|
|
6
|
+
|
|
7
|
+
constexpr const auto tag = "Worklets";
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
void PlatformLogger::log(const char *str) {
|
|
12
|
+
__android_log_print(ANDROID_LOG_VERBOSE, tag, "%s", str);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
void PlatformLogger::log(const std::string &str) {
|
|
16
|
+
log(str.c_str());
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
void PlatformLogger::log(const double d) {
|
|
20
|
+
__android_log_print(ANDROID_LOG_VERBOSE, tag, "%f", d);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void PlatformLogger::log(const int i) {
|
|
24
|
+
__android_log_print(ANDROID_LOG_VERBOSE, tag, "%d", i);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void PlatformLogger::log(const bool b) {
|
|
28
|
+
log(b ? "true" : "false");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
} // namespace worklets
|