@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,256 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <react/debug/react_native_assert.h>
|
|
5
|
+
#include <worklets/RunLoop/AsyncQueue.h>
|
|
6
|
+
#include <worklets/RunLoop/AsyncQueueImpl.h>
|
|
7
|
+
#include <worklets/RunLoop/EventLoop.h>
|
|
8
|
+
#include <worklets/SharedItems/Serializable.h>
|
|
9
|
+
#include <worklets/SharedItems/UnpackerLoader.h>
|
|
10
|
+
#include <worklets/Tools/JSLogger.h>
|
|
11
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
12
|
+
#include <worklets/Tools/ScriptBuffer.h>
|
|
13
|
+
#include <worklets/WorkletRuntime/RuntimeBindings.h>
|
|
14
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
15
|
+
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <type_traits>
|
|
20
|
+
#include <utility>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
namespace worklets {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
using namespace react;
|
|
27
|
+
|
|
28
|
+
template <typename TCallable>
|
|
29
|
+
concept ImplicitlySerializableCallable = std::is_assignable_v<const jsi::Function &, TCallable> ||
|
|
30
|
+
std::is_assignable_v<const std::shared_ptr<SerializableWorklet> &, TCallable>;
|
|
31
|
+
|
|
32
|
+
template <typename TCallable>
|
|
33
|
+
concept RuntimeCallable = requires(TCallable &&callable, jsi::Runtime &rt) {
|
|
34
|
+
{ callable(rt) };
|
|
35
|
+
} || ImplicitlySerializableCallable<TCallable>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Forward declaration to avoid circular dependencies.
|
|
39
|
+
*/
|
|
40
|
+
class JSIWorkletsModuleProxy;
|
|
41
|
+
|
|
42
|
+
class WorkletRuntime : public jsi::HostObject, public std::enable_shared_from_this<WorkletRuntime> {
|
|
43
|
+
public:
|
|
44
|
+
void schedule(jsi::Function &&function) const;
|
|
45
|
+
void schedule(std::shared_ptr<SerializableWorklet> worklet) const;
|
|
46
|
+
#ifndef NDEBUG
|
|
47
|
+
void schedule(std::shared_ptr<SerializableWorklet> worklet, std::optional<std::string> scheduleStack) const;
|
|
48
|
+
#endif // NDEBUG
|
|
49
|
+
void schedule(std::function<void()> job) const;
|
|
50
|
+
void schedule(std::function<void(jsi::Runtime &)> job) const;
|
|
51
|
+
|
|
52
|
+
/* #region runSync */
|
|
53
|
+
|
|
54
|
+
template <RuntimeCallable TCallable, typename... Args>
|
|
55
|
+
std::invoke_result_t<TCallable, Args...> runSync(TCallable &&callable, Args &&...args) const;
|
|
56
|
+
template <typename... Args>
|
|
57
|
+
jsi::Value runSync(const jsi::Function &function, Args &&...args) const {
|
|
58
|
+
#ifndef NDEBUG
|
|
59
|
+
return callGuarded(function, std::nullopt, std::forward<Args>(args)...);
|
|
60
|
+
#else
|
|
61
|
+
return function.call(*runtime_, args...);
|
|
62
|
+
#endif // NDEBUG
|
|
63
|
+
}
|
|
64
|
+
template <typename... Args>
|
|
65
|
+
jsi::Value runSync(const std::shared_ptr<SerializableWorklet> &worklet, Args &&...args) const {
|
|
66
|
+
#ifndef NDEBUG
|
|
67
|
+
return runSyncWithStack(worklet, std::nullopt, std::forward<Args>(args)...);
|
|
68
|
+
#else
|
|
69
|
+
jsi::Runtime &rt = *runtime_;
|
|
70
|
+
auto function = worklet->toJSValue(rt).asObject(rt).asFunction(rt);
|
|
71
|
+
return function.call(rt, args...);
|
|
72
|
+
#endif // NDEBUG
|
|
73
|
+
}
|
|
74
|
+
#ifndef NDEBUG
|
|
75
|
+
template <typename... Args>
|
|
76
|
+
jsi::Value runSyncWithStack(
|
|
77
|
+
const std::shared_ptr<SerializableWorklet> &worklet,
|
|
78
|
+
const std::optional<std::string> &scheduleStack,
|
|
79
|
+
Args &&...args) const {
|
|
80
|
+
jsi::Runtime &rt = *runtime_;
|
|
81
|
+
auto function = worklet->toJSValue(rt).asObject(rt).asFunction(rt);
|
|
82
|
+
return callGuarded(function, scheduleStack, std::forward<Args>(args)...);
|
|
83
|
+
}
|
|
84
|
+
#endif // NDEBUG
|
|
85
|
+
template <RuntimeCallable TCallable>
|
|
86
|
+
std::invoke_result_t<TCallable, jsi::Runtime &> runSync(TCallable &&job) const {
|
|
87
|
+
jsi::Runtime &rt = getJSIRuntime();
|
|
88
|
+
auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
89
|
+
return job(rt);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* #endregion */
|
|
93
|
+
|
|
94
|
+
void callMicrotasks() const;
|
|
95
|
+
|
|
96
|
+
/* #region runSyncSerialized */
|
|
97
|
+
|
|
98
|
+
template <ImplicitlySerializableCallable TCallable, typename... Args>
|
|
99
|
+
std::shared_ptr<Serializable> runSyncSerialized(TCallable &&callable, Args &&...args) const;
|
|
100
|
+
template <typename... Args>
|
|
101
|
+
std::shared_ptr<Serializable> runSyncSerialized(const jsi::Function &function, Args &&...args) const {
|
|
102
|
+
jsi::Runtime &rt = getJSIRuntime();
|
|
103
|
+
auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
104
|
+
auto result = runSync(function, std::forward<Args>(args)...);
|
|
105
|
+
auto serializableResult = extractSerializableOrThrow(
|
|
106
|
+
rt,
|
|
107
|
+
result,
|
|
108
|
+
"[Worklets] Function passed to `runSyncSerialized`"
|
|
109
|
+
"must return a value serialized with `createSerializable`.");
|
|
110
|
+
return serializableResult;
|
|
111
|
+
}
|
|
112
|
+
#ifndef NDEBUG
|
|
113
|
+
template <typename... Args>
|
|
114
|
+
std::shared_ptr<Serializable> runSyncSerializedWithStack(
|
|
115
|
+
const std::shared_ptr<SerializableWorklet> &worklet,
|
|
116
|
+
const std::optional<std::string> &scheduleStack,
|
|
117
|
+
Args &&...args) const {
|
|
118
|
+
jsi::Runtime &rt = getJSIRuntime();
|
|
119
|
+
auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
120
|
+
auto result = runSyncWithStack(worklet, scheduleStack, std::forward<Args>(args)...);
|
|
121
|
+
auto serializableResult = extractSerializableOrThrow(
|
|
122
|
+
rt,
|
|
123
|
+
result,
|
|
124
|
+
"[Worklets] Worklet passed to `runSyncSerialized`"
|
|
125
|
+
"must return a value serialized with `createSerializable`.");
|
|
126
|
+
return serializableResult;
|
|
127
|
+
}
|
|
128
|
+
#endif // NDEBUG
|
|
129
|
+
template <typename... Args>
|
|
130
|
+
std::shared_ptr<Serializable> runSyncSerialized(const std::shared_ptr<SerializableWorklet> &worklet, Args &&...args)
|
|
131
|
+
const {
|
|
132
|
+
jsi::Runtime &rt = getJSIRuntime();
|
|
133
|
+
auto lock = std::unique_lock<std::recursive_mutex>(*runtimeMutex_);
|
|
134
|
+
auto result = runSync(worklet, std::forward<Args>(args)...);
|
|
135
|
+
auto serializableResult = extractSerializableOrThrow(
|
|
136
|
+
rt,
|
|
137
|
+
result,
|
|
138
|
+
"[Worklets] Worklet passed to `runSyncSerialized`"
|
|
139
|
+
"must return a value serialized with `createSerializable`.");
|
|
140
|
+
return serializableResult;
|
|
141
|
+
}
|
|
142
|
+
/* #endregion */
|
|
143
|
+
|
|
144
|
+
jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override;
|
|
145
|
+
|
|
146
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
|
|
147
|
+
|
|
148
|
+
[[nodiscard]] std::string toString() const noexcept {
|
|
149
|
+
return "[WorkletRuntime \"" + name_ + "\"]";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
[[nodiscard]] jsi::Runtime &getJSIRuntime() const noexcept {
|
|
153
|
+
return *runtime_;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
[[nodiscard]] RuntimeData::RuntimeId getRuntimeId() const noexcept {
|
|
157
|
+
return runtimeId_;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[[nodiscard]] std::string getRuntimeName() const noexcept {
|
|
161
|
+
return name_;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
explicit WorkletRuntime(
|
|
165
|
+
RuntimeData::RuntimeId runtimeId,
|
|
166
|
+
RuntimeData::RuntimeKind runtimeKind,
|
|
167
|
+
const std::string &name,
|
|
168
|
+
const std::shared_ptr<AsyncQueue> &queue = nullptr,
|
|
169
|
+
bool enableEventLoop = true);
|
|
170
|
+
|
|
171
|
+
void init(const std::shared_ptr<JSIWorkletsModuleProxy> &jsiWorkletsModuleProxy);
|
|
172
|
+
|
|
173
|
+
/* #region deprecated */
|
|
174
|
+
|
|
175
|
+
/** @deprecated Use `runSync` instead. */
|
|
176
|
+
template <typename... Args>
|
|
177
|
+
jsi::Value runGuarded(const std::shared_ptr<SerializableWorklet> &worklet, Args &&...args) const {
|
|
178
|
+
return runSync(worklet, std::forward<Args>(args)...);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** @deprecated Use `schedule` instead. */
|
|
182
|
+
void runAsyncGuarded(const std::shared_ptr<SerializableWorklet> &worklet);
|
|
183
|
+
|
|
184
|
+
/** @deprecated Use `runSyncSerialized` and extract to `jsi::Value` with
|
|
185
|
+
* `extractSerializableOrThrow` instead. */
|
|
186
|
+
jsi::Value executeSync(jsi::Runtime &rt, const jsi::Value &worklet) const;
|
|
187
|
+
/** @deprecated Use `runSync` instead. */
|
|
188
|
+
jsi::Value executeSync(std::function<jsi::Value(jsi::Runtime &)> &&job) const;
|
|
189
|
+
/** @deprecated Use `runSync` instead. */
|
|
190
|
+
jsi::Value executeSync(const std::function<jsi::Value(jsi::Runtime &)> &job) const;
|
|
191
|
+
|
|
192
|
+
/* #endregion */
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Retrieves a weak reference to the WorkletRuntime associated with the
|
|
196
|
+
* provided jsi::Runtime.
|
|
197
|
+
*
|
|
198
|
+
* Throws when invoked with a non-worklet runtime.
|
|
199
|
+
*
|
|
200
|
+
* Available only on React Native 0.81 and higher.
|
|
201
|
+
*/
|
|
202
|
+
static std::weak_ptr<WorkletRuntime> getWeakRuntimeFromJSIRuntime(jsi::Runtime &rt);
|
|
203
|
+
|
|
204
|
+
private:
|
|
205
|
+
#ifndef NDEBUG
|
|
206
|
+
// Wraps the provided function in a try/catch so an exception thrown on the
|
|
207
|
+
// worklet runtime can be reported on the RN Runtime LogBox with a
|
|
208
|
+
// stack pointing back to the JS call site that scheduled the worklet.
|
|
209
|
+
template <typename... Args>
|
|
210
|
+
jsi::Value callGuarded(const jsi::Function &function, const std::optional<std::string> &scheduleStack, Args &&...args)
|
|
211
|
+
const {
|
|
212
|
+
auto &rt = *runtime_;
|
|
213
|
+
try {
|
|
214
|
+
return function.call(rt, args...);
|
|
215
|
+
} catch (jsi::JSError &e) {
|
|
216
|
+
JSLogger::handleJSError(jsScheduler_, rt, name_, e, scheduleStack);
|
|
217
|
+
return jsi::Value::undefined();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
#endif // NDEBUG
|
|
221
|
+
|
|
222
|
+
void bundleModeInit(
|
|
223
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
224
|
+
const std::shared_ptr<const ScriptBuffer> &script,
|
|
225
|
+
const std::string &sourceUrl,
|
|
226
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings);
|
|
227
|
+
|
|
228
|
+
void legacyModeInit(const std::shared_ptr<UnpackerLoader> &unpackerLoader);
|
|
229
|
+
|
|
230
|
+
const RuntimeData::RuntimeId runtimeId_;
|
|
231
|
+
const std::shared_ptr<std::recursive_mutex> runtimeMutex_;
|
|
232
|
+
const std::shared_ptr<jsi::Runtime> runtime_;
|
|
233
|
+
std::shared_ptr<JSScheduler> jsScheduler_;
|
|
234
|
+
const RuntimeData::RuntimeKind runtimeKind_;
|
|
235
|
+
const std::string name_;
|
|
236
|
+
std::shared_ptr<AsyncQueue> queue_;
|
|
237
|
+
std::shared_ptr<EventLoop> eventLoop_;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// This function needs to be non-inline to avoid problems with dynamic_cast on
|
|
241
|
+
// Android
|
|
242
|
+
std::shared_ptr<WorkletRuntime> extractWorkletRuntime(jsi::Runtime &rt, const jsi::Value &value);
|
|
243
|
+
|
|
244
|
+
void scheduleOnRuntime(
|
|
245
|
+
jsi::Runtime &rt,
|
|
246
|
+
const jsi::Value &workletRuntimeValue,
|
|
247
|
+
const jsi::Value &serializableWorkletValue);
|
|
248
|
+
#ifndef NDEBUG
|
|
249
|
+
void scheduleOnRuntime(
|
|
250
|
+
jsi::Runtime &rt,
|
|
251
|
+
const jsi::Value &workletRuntimeValue,
|
|
252
|
+
const jsi::Value &serializableWorkletValue,
|
|
253
|
+
const std::optional<std::string> &scheduleStack);
|
|
254
|
+
#endif // NDEBUG
|
|
255
|
+
|
|
256
|
+
} // namespace worklets
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <worklets/Registries/WorkletRuntimeRegistry.h>
|
|
4
|
+
|
|
5
|
+
#include <jsi/jsi.h>
|
|
6
|
+
|
|
7
|
+
#include <memory>
|
|
8
|
+
|
|
9
|
+
namespace worklets {
|
|
10
|
+
|
|
11
|
+
class WorkletRuntimeCollector : public jsi::HostObject {
|
|
12
|
+
// When worklet runtime is created, we inject an instance of this class as a
|
|
13
|
+
// `jsi::HostObject` into the global object. When worklet runtime is
|
|
14
|
+
// terminated, the object is garbage-collected, which runs the C++ destructor.
|
|
15
|
+
// In the destructor, we unregister the worklet runtime from the registry.
|
|
16
|
+
|
|
17
|
+
public:
|
|
18
|
+
explicit WorkletRuntimeCollector(jsi::Runtime &runtime) : runtime_(runtime) {
|
|
19
|
+
WorkletRuntimeRegistry::registerRuntime(runtime_);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
~WorkletRuntimeCollector() override {
|
|
23
|
+
WorkletRuntimeRegistry::unregisterRuntime(runtime_);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static void install(jsi::Runtime &rt) {
|
|
27
|
+
auto collector = std::make_shared<WorkletRuntimeCollector>(rt);
|
|
28
|
+
auto object = jsi::Object::createFromHostObject(rt, collector);
|
|
29
|
+
rt.global().setProperty(rt, "__workletRuntimeCollector", object);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private:
|
|
33
|
+
jsi::Runtime &runtime_;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
} // namespace worklets
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
#include <jsi/jsi.h>
|
|
2
|
+
#include <worklets/SharedItems/Serializable.h>
|
|
3
|
+
#include <worklets/SharedItems/SerializableFactory.h>
|
|
4
|
+
#include <worklets/Tools/JSISerializer.h>
|
|
5
|
+
#include <worklets/Tools/PlatformLogger.h>
|
|
6
|
+
#include <worklets/Tools/WorkletsJSIUtils.h>
|
|
7
|
+
#include <worklets/WorkletRuntime/HermesProfiling.h>
|
|
8
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
9
|
+
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
10
|
+
#include <worklets/WorkletRuntime/WorkletRuntimeDecorator.h>
|
|
11
|
+
|
|
12
|
+
#ifdef ANDROID
|
|
13
|
+
#include <android/trace.h>
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#if defined(__APPLE__)
|
|
17
|
+
#include <os/trace_base.h>
|
|
18
|
+
#if OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
19
|
+
#include <os/log.h>
|
|
20
|
+
#include <os/signpost.h>
|
|
21
|
+
#endif
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#include <chrono>
|
|
25
|
+
#include <memory>
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <utility>
|
|
28
|
+
|
|
29
|
+
#if defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
30
|
+
static os_log_t workletsInstrumentsLogHandle = nullptr;
|
|
31
|
+
static thread_local os_signpost_id_t tls_signpostId = OS_SIGNPOST_ID_INVALID;
|
|
32
|
+
static thread_local std::string tls_signpostName;
|
|
33
|
+
|
|
34
|
+
static os_log_t getWorkletsInstrumentsLogHandle() {
|
|
35
|
+
if (!workletsInstrumentsLogHandle) {
|
|
36
|
+
workletsInstrumentsLogHandle = os_log_create("dev.worklets.instruments", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
|
|
37
|
+
}
|
|
38
|
+
return workletsInstrumentsLogHandle;
|
|
39
|
+
}
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
namespace worklets {
|
|
43
|
+
|
|
44
|
+
static inline double performanceNow() {
|
|
45
|
+
// copied from JSExecutor.cpp
|
|
46
|
+
auto time = std::chrono::steady_clock::now();
|
|
47
|
+
auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(time.time_since_epoch()).count();
|
|
48
|
+
|
|
49
|
+
constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;
|
|
50
|
+
return duration / NANOSECONDS_IN_MILLISECOND;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void WorkletRuntimeDecorator::decorate(
|
|
54
|
+
jsi::Runtime &rt,
|
|
55
|
+
const RuntimeData::RuntimeKind runtimeKind,
|
|
56
|
+
const std::string &name,
|
|
57
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
58
|
+
const bool isDevBundle,
|
|
59
|
+
jsi::Object &&jsiWorkletsModuleProxy,
|
|
60
|
+
const std::shared_ptr<EventLoop> &eventLoop,
|
|
61
|
+
const RuntimeBindings::NativeLoggingHook &nativeLoggingHook) {
|
|
62
|
+
// resolves "ReferenceError: Property 'global' doesn't exist at ..."
|
|
63
|
+
rt.global().setProperty(rt, "global", rt.global());
|
|
64
|
+
|
|
65
|
+
rt.global().setProperty(rt, RuntimeData::runtimeKindBindingName, static_cast<int>(runtimeKind));
|
|
66
|
+
|
|
67
|
+
rt.global().setProperty(rt, "_WORKLET", true);
|
|
68
|
+
|
|
69
|
+
rt.global().setProperty(rt, RuntimeData::runtimeNameBindingName, jsi::String::createFromAscii(rt, name));
|
|
70
|
+
|
|
71
|
+
rt.global().setProperty(rt, "__DEV__", isDevBundle);
|
|
72
|
+
|
|
73
|
+
rt.global().setProperty(rt, "__workletsModuleProxy", std::move(jsiWorkletsModuleProxy));
|
|
74
|
+
|
|
75
|
+
#ifndef NDEBUG
|
|
76
|
+
auto evalWithSourceUrl =
|
|
77
|
+
[](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) -> jsi::Value {
|
|
78
|
+
auto code = std::make_shared<const jsi::StringBuffer>(args[0].asString(rt).utf8(rt));
|
|
79
|
+
std::string url;
|
|
80
|
+
if (count > 1 && args[1].isString()) {
|
|
81
|
+
url = args[1].asString(rt).utf8(rt);
|
|
82
|
+
}
|
|
83
|
+
return rt.evaluateJavaScript(code, url);
|
|
84
|
+
};
|
|
85
|
+
rt.global().setProperty(
|
|
86
|
+
rt,
|
|
87
|
+
"evalWithSourceUrl",
|
|
88
|
+
jsi::Function::createFromHostFunction(
|
|
89
|
+
rt, jsi::PropNameID::forAscii(rt, "evalWithSourceUrl"), 1, evalWithSourceUrl));
|
|
90
|
+
#endif // NDEBUG
|
|
91
|
+
|
|
92
|
+
jsi_utils::installJsiFunction(
|
|
93
|
+
rt, "_log", [](jsi::Runtime &rt, const jsi::Value &value) { PlatformLogger::log(stringifyJSIValue(rt, value)); });
|
|
94
|
+
|
|
95
|
+
if (nativeLoggingHook) {
|
|
96
|
+
rt.global().setProperty(
|
|
97
|
+
rt,
|
|
98
|
+
"nativeLoggingHook",
|
|
99
|
+
jsi::Function::createFromHostFunction(
|
|
100
|
+
rt, jsi::PropNameID::forAscii(rt, "nativeLoggingHook"), 2, nativeLoggingHook));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
jsi_utils::installJsiFunction(rt, "_toString", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
104
|
+
return jsi::String::createFromUtf8(rt, stringifyJSIValue(rt, value));
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
jsi_utils::installJsiFunction(rt, "_beginSection", [](jsi::Runtime &rt, const jsi::Value &nameValue) {
|
|
108
|
+
#ifdef ANDROID
|
|
109
|
+
ATrace_beginSection(nameValue.asString(rt).utf8(rt).c_str());
|
|
110
|
+
#elif defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
111
|
+
os_log_t logHandle = getWorkletsInstrumentsLogHandle();
|
|
112
|
+
if (os_signpost_enabled(logHandle)) {
|
|
113
|
+
tls_signpostName = nameValue.asString(rt).utf8(rt);
|
|
114
|
+
tls_signpostId = os_signpost_id_make_with_pointer(logHandle, &tls_signpostId);
|
|
115
|
+
os_signpost_interval_begin(logHandle, tls_signpostId, "Worklets", "%s", tls_signpostName.c_str());
|
|
116
|
+
}
|
|
117
|
+
#endif
|
|
118
|
+
return jsi::Value::undefined();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
jsi_utils::installJsiFunction(rt, "_endSection", [](jsi::Runtime &rt) {
|
|
122
|
+
#ifdef ANDROID
|
|
123
|
+
ATrace_endSection();
|
|
124
|
+
#elif defined(__APPLE__) && OS_LOG_TARGET_HAS_10_15_FEATURES
|
|
125
|
+
os_log_t logHandle = getWorkletsInstrumentsLogHandle();
|
|
126
|
+
if (os_signpost_enabled(logHandle) && tls_signpostId != OS_SIGNPOST_ID_INVALID) {
|
|
127
|
+
os_signpost_interval_end(logHandle, tls_signpostId, "Worklets", "%s end", tls_signpostName.c_str());
|
|
128
|
+
tls_signpostId = OS_SIGNPOST_ID_INVALID;
|
|
129
|
+
}
|
|
130
|
+
#endif
|
|
131
|
+
return jsi::Value::undefined();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableHostObject", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
135
|
+
return makeSerializableHostObject(rt, value.asObject(rt).asHostObject(rt));
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableString", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
139
|
+
return makeSerializableString(rt, value.asString(rt));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableNumber", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
143
|
+
return makeSerializableNumber(rt, value.asNumber());
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableBoolean", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
147
|
+
return makeSerializableBoolean(rt, value.asBool());
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableBigInt", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
151
|
+
return makeSerializableBigInt(rt, value.asBigInt(rt));
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
jsi_utils::installJsiFunction(
|
|
155
|
+
rt, "_createSerializableUndefined", [](jsi::Runtime &rt) { return makeSerializableUndefined(rt); });
|
|
156
|
+
|
|
157
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableArray", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
158
|
+
return makeSerializableArray(rt, value.asObject(rt).asArray(rt), false);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
jsi_utils::installJsiFunction(
|
|
162
|
+
rt, "_createSerializableNull", [](jsi::Runtime &rt) { return makeSerializableNull(rt); });
|
|
163
|
+
|
|
164
|
+
jsi_utils::installJsiFunction(
|
|
165
|
+
rt,
|
|
166
|
+
"_createSerializableObject",
|
|
167
|
+
[](jsi::Runtime &rt,
|
|
168
|
+
const jsi::Value &value,
|
|
169
|
+
const jsi::Value &shouldRetainRemote,
|
|
170
|
+
const jsi::Value &nativeStateSource) {
|
|
171
|
+
return makeSerializableObject(rt, value.getObject(rt), shouldRetainRemote.getBool(), nativeStateSource);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableWorklet", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
175
|
+
return makeSerializableWorklet(rt, value.asObject(rt), false);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableInitializer", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
179
|
+
return makeSerializableInitializer(rt, value.asObject(rt));
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
jsi_utils::installJsiFunction(rt, "_createSerializableSynchronizable", [](jsi::Runtime &rt, const jsi::Value &value) {
|
|
183
|
+
return SerializableJSRef::newNativeStateObject(rt, extractSerializableOrThrow(rt, value));
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
jsi_utils::installJsiFunction(
|
|
187
|
+
rt,
|
|
188
|
+
"_scheduleOnRuntime",
|
|
189
|
+
[](jsi::Runtime &rt, const jsi::Value &workletRuntimeValue, const jsi::Value &serializableWorkletValue) {
|
|
190
|
+
scheduleOnRuntime(rt, workletRuntimeValue, serializableWorkletValue);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
jsi::Object performance(rt);
|
|
194
|
+
performance.setProperty(
|
|
195
|
+
rt,
|
|
196
|
+
"now",
|
|
197
|
+
jsi::Function::createFromHostFunction(
|
|
198
|
+
rt,
|
|
199
|
+
jsi::PropNameID::forAscii(rt, "now"),
|
|
200
|
+
0,
|
|
201
|
+
[](jsi::Runtime &runtime, const jsi::Value &, const jsi::Value *args, size_t count) {
|
|
202
|
+
return jsi::Value(performanceNow());
|
|
203
|
+
}));
|
|
204
|
+
rt.global().setProperty(rt, "performance", performance);
|
|
205
|
+
|
|
206
|
+
rt.global().setProperty(
|
|
207
|
+
rt,
|
|
208
|
+
"_startProfiling",
|
|
209
|
+
jsi::Function::createFromHostFunction(
|
|
210
|
+
rt,
|
|
211
|
+
jsi::PropNameID::forAscii(rt, "_startProfiling"),
|
|
212
|
+
1,
|
|
213
|
+
[](jsi::Runtime &rt, const jsi::Value &, const jsi::Value *args, size_t count) {
|
|
214
|
+
const double meanHzFreq = (count > 0 && !args[0].isUndefined()) ? args[0].asNumber() : 100.0;
|
|
215
|
+
startProfiling(rt, meanHzFreq);
|
|
216
|
+
return jsi::Value::undefined();
|
|
217
|
+
}));
|
|
218
|
+
jsi_utils::installJsiFunction(rt, "_stopProfiling", [](jsi::Runtime &rt) {
|
|
219
|
+
std::string path = stopProfiling(rt);
|
|
220
|
+
return jsi::String::createFromUtf8(rt, path);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
jsi_utils::installJsiFunction(
|
|
224
|
+
rt,
|
|
225
|
+
"_scheduleTimeoutCallback",
|
|
226
|
+
[weakEventLoop = std::weak_ptr<EventLoop>(eventLoop)](
|
|
227
|
+
jsi::Runtime &rt, const jsi::Value &delayJs, const jsi::Value &handlerIdJs) -> jsi::Value {
|
|
228
|
+
const auto delay = delayJs.asNumber();
|
|
229
|
+
const auto handlerId = handlerIdJs.asNumber();
|
|
230
|
+
const auto job = [handlerId](jsi::Runtime &rt) {
|
|
231
|
+
rt.global().getPropertyAsFunction(rt, "__runTimeoutCallback").call(rt, handlerId);
|
|
232
|
+
};
|
|
233
|
+
if (auto strongEventLoop = weakEventLoop.lock()) {
|
|
234
|
+
strongEventLoop->pushTimeout(job, delay);
|
|
235
|
+
}
|
|
236
|
+
return jsi::Value::undefined();
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
void WorkletRuntimeDecorator::postEvaluateScript(
|
|
241
|
+
jsi::Runtime &rt,
|
|
242
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings) {
|
|
243
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
244
|
+
installNetworking(rt, runtimeBindings);
|
|
245
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
249
|
+
void WorkletRuntimeDecorator::installNetworking(
|
|
250
|
+
jsi::Runtime &rt,
|
|
251
|
+
const std::shared_ptr<RuntimeBindings> &runtimeBindings) {
|
|
252
|
+
auto TurboModules = rt.global().getPropertyAsObject(rt, "TurboModules");
|
|
253
|
+
|
|
254
|
+
auto Networking = TurboModules.getPropertyAsFunction(rt, "get").callWithThis(rt, TurboModules, "Networking");
|
|
255
|
+
|
|
256
|
+
#ifdef ANDROID
|
|
257
|
+
auto jsiSendRequest = jsi::Function::createFromHostFunction(
|
|
258
|
+
rt,
|
|
259
|
+
jsi::PropNameID::forAscii(rt, "sendRequest"),
|
|
260
|
+
9,
|
|
261
|
+
[sendRequest = runtimeBindings->sendRequest](
|
|
262
|
+
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
263
|
+
auto method = args[0].asString(rt);
|
|
264
|
+
auto url = args[1].asString(rt);
|
|
265
|
+
auto requestId = args[2].asNumber();
|
|
266
|
+
auto headers = args[3].asObject(rt).asArray(rt);
|
|
267
|
+
auto data = args[4].asObject(rt);
|
|
268
|
+
auto responseType = args[5].asString(rt);
|
|
269
|
+
auto incrementalUpdates = args[6].asBool();
|
|
270
|
+
auto timeout = args[7].asNumber();
|
|
271
|
+
auto withCredentials = args[8].asBool();
|
|
272
|
+
sendRequest(
|
|
273
|
+
rt, method, url, requestId, headers, data, responseType, incrementalUpdates, timeout, withCredentials);
|
|
274
|
+
return jsi::Value::undefined();
|
|
275
|
+
});
|
|
276
|
+
#else
|
|
277
|
+
auto jsiSendRequest = jsi::Function::createFromHostFunction(
|
|
278
|
+
rt,
|
|
279
|
+
jsi::PropNameID::forAscii(rt, "sendRequest"),
|
|
280
|
+
2,
|
|
281
|
+
[sendRequest = runtimeBindings->sendRequest](
|
|
282
|
+
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
283
|
+
auto &query = args[0];
|
|
284
|
+
auto responseSender = args[1].asObject(rt).asFunction(rt);
|
|
285
|
+
sendRequest(rt, query, std::move(responseSender));
|
|
286
|
+
return jsi::Value::undefined();
|
|
287
|
+
});
|
|
288
|
+
#endif // ANDROID
|
|
289
|
+
|
|
290
|
+
Networking.asObject(rt).setProperty(rt, "sendRequest", std::move(jsiSendRequest));
|
|
291
|
+
|
|
292
|
+
auto jsiAbortRequest = jsi::Function::createFromHostFunction(
|
|
293
|
+
rt,
|
|
294
|
+
jsi::PropNameID::forAscii(rt, "abortRequest"),
|
|
295
|
+
1,
|
|
296
|
+
[abortRequest = runtimeBindings->abortRequest](
|
|
297
|
+
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
298
|
+
auto requestID = args[0].asNumber();
|
|
299
|
+
abortRequest(rt, requestID);
|
|
300
|
+
return jsi::Value::undefined();
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
Networking.asObject(rt).setProperty(rt, "abortRequest", std::move(jsiAbortRequest));
|
|
304
|
+
|
|
305
|
+
auto jsiClearCookies = jsi::Function::createFromHostFunction(
|
|
306
|
+
rt,
|
|
307
|
+
jsi::PropNameID::forAscii(rt, "clearCookies"),
|
|
308
|
+
1,
|
|
309
|
+
[clearCookies = runtimeBindings->clearCookies](
|
|
310
|
+
jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
|
311
|
+
auto responseSender = args[0].asObject(rt).asFunction(rt);
|
|
312
|
+
clearCookies(rt, std::move(responseSender));
|
|
313
|
+
return jsi::Value::undefined();
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
Networking.asObject(rt).setProperty(rt, "clearCookies", std::move(jsiClearCookies));
|
|
317
|
+
}
|
|
318
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
319
|
+
|
|
320
|
+
} // namespace worklets
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <worklets/RunLoop/EventLoop.h>
|
|
5
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
6
|
+
#include <worklets/WorkletRuntime/RuntimeBindings.h>
|
|
7
|
+
#include <worklets/WorkletRuntime/RuntimeData.h>
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <string>
|
|
11
|
+
|
|
12
|
+
using namespace facebook;
|
|
13
|
+
|
|
14
|
+
namespace worklets {
|
|
15
|
+
|
|
16
|
+
class WorkletRuntimeDecorator {
|
|
17
|
+
public:
|
|
18
|
+
static void decorate(
|
|
19
|
+
jsi::Runtime &rt,
|
|
20
|
+
const RuntimeData::RuntimeKind runtimeKind,
|
|
21
|
+
const std::string &name,
|
|
22
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
23
|
+
const bool isDevBundle,
|
|
24
|
+
jsi::Object &&jsiWorkletsModuleProxy,
|
|
25
|
+
const std::shared_ptr<EventLoop> &eventLoop,
|
|
26
|
+
const RuntimeBindings::NativeLoggingHook &nativeLoggingHook);
|
|
27
|
+
|
|
28
|
+
static void postEvaluateScript(jsi::Runtime &rt, const std::shared_ptr<RuntimeBindings> &runtimeBindings);
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
32
|
+
static void installNetworking(jsi::Runtime &rt, const std::shared_ptr<RuntimeBindings> &runtimeBindings);
|
|
33
|
+
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
} // namespace worklets
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 nobody
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|