@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,187 @@
|
|
|
1
|
+
package com.swmansion.worklets
|
|
2
|
+
|
|
3
|
+
import com.facebook.jni.HybridData
|
|
4
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
5
|
+
import com.facebook.react.bridge.Callback
|
|
6
|
+
import com.facebook.react.bridge.LifecycleEventListener
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
|
9
|
+
import com.facebook.react.bridge.ReadableNativeArray
|
|
10
|
+
import com.facebook.react.bridge.ReadableNativeMap
|
|
11
|
+
import com.facebook.react.common.annotations.FrameworkAPI
|
|
12
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
13
|
+
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
|
|
14
|
+
import com.facebook.soloader.SoLoader
|
|
15
|
+
import com.swmansion.worklets.runloop.AnimationFrameCallback
|
|
16
|
+
import com.swmansion.worklets.runloop.AnimationFrameQueue
|
|
17
|
+
import java.util.concurrent.atomic.AtomicBoolean
|
|
18
|
+
|
|
19
|
+
@Suppress("KotlinJniMissingFunction")
|
|
20
|
+
@ReactModule(name = WorkletsModule.NAME)
|
|
21
|
+
class WorkletsModule(
|
|
22
|
+
reactContext: ReactApplicationContext,
|
|
23
|
+
) : NativeWorkletsModuleSpec(reactContext),
|
|
24
|
+
LifecycleEventListener {
|
|
25
|
+
companion object {
|
|
26
|
+
const val NAME = "WorkletsModule"
|
|
27
|
+
|
|
28
|
+
init {
|
|
29
|
+
SoLoader.loadLibrary("worklets")
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@field:DoNotStrip
|
|
34
|
+
@Suppress("unused")
|
|
35
|
+
private var mHybridData: HybridData? = null
|
|
36
|
+
|
|
37
|
+
@Suppress("unused")
|
|
38
|
+
protected fun getHybridData(): HybridData? = mHybridData
|
|
39
|
+
|
|
40
|
+
init {
|
|
41
|
+
reactContext.assertOnJSQueueThread()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private val mAndroidUIScheduler = AndroidUIScheduler(reactContext)
|
|
45
|
+
private val mAnimationFrameQueue = AnimationFrameQueue(reactContext)
|
|
46
|
+
private val mWorkletsNetworking = WorkletsNetworking()
|
|
47
|
+
private var mSlowAnimationsEnabled = false
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Invalidating concurrently could be fatal. It shouldn't happen in a normal flow, but it doesn't
|
|
51
|
+
* cost us much to add synchronization for extra safety.
|
|
52
|
+
*/
|
|
53
|
+
private val mInvalidated = AtomicBoolean(false)
|
|
54
|
+
|
|
55
|
+
@OptIn(FrameworkAPI::class)
|
|
56
|
+
private external fun initHybrid(
|
|
57
|
+
bundleModeEnabled: Boolean,
|
|
58
|
+
jsContext: Long,
|
|
59
|
+
jsCallInvokerHolder: CallInvokerHolderImpl,
|
|
60
|
+
androidUIScheduler: AndroidUIScheduler,
|
|
61
|
+
scriptBufferWrapper: ScriptBufferWrapper?,
|
|
62
|
+
): HybridData
|
|
63
|
+
|
|
64
|
+
@OptIn(FrameworkAPI::class)
|
|
65
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
66
|
+
override fun installTurboModule(bundleModeEnabled: Boolean): Boolean {
|
|
67
|
+
val context = reactApplicationContext
|
|
68
|
+
|
|
69
|
+
context.assertOnJSQueueThread()
|
|
70
|
+
|
|
71
|
+
val jsContext = checkNotNull(context.javaScriptContextHolder).get()
|
|
72
|
+
val jsCallInvokerHolder = context.jsCallInvokerHolder as CallInvokerHolderImpl
|
|
73
|
+
|
|
74
|
+
val sourceURL = context.sourceURL
|
|
75
|
+
|
|
76
|
+
val scriptBufferWrapper: ScriptBufferWrapper? =
|
|
77
|
+
if (bundleModeEnabled) {
|
|
78
|
+
ScriptBufferWrapper(sourceURL!!, context.assets)
|
|
79
|
+
} else {
|
|
80
|
+
null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
mHybridData =
|
|
84
|
+
initHybrid(
|
|
85
|
+
bundleModeEnabled,
|
|
86
|
+
jsContext,
|
|
87
|
+
jsCallInvokerHolder,
|
|
88
|
+
mAndroidUIScheduler,
|
|
89
|
+
scriptBufferWrapper,
|
|
90
|
+
)
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@OptIn(FrameworkAPI::class)
|
|
95
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
96
|
+
override fun start(): Boolean {
|
|
97
|
+
reactApplicationContext.assertOnJSQueueThread()
|
|
98
|
+
startCpp()
|
|
99
|
+
return true
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@DoNotStrip
|
|
103
|
+
fun abortRequest(
|
|
104
|
+
runtimeId: Int,
|
|
105
|
+
requestIdAsDouble: Double,
|
|
106
|
+
) {
|
|
107
|
+
mWorkletsNetworking.jsiAbortRequest(runtimeId, requestIdAsDouble)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@DoNotStrip
|
|
111
|
+
fun clearCookies(callback: Callback) {
|
|
112
|
+
mWorkletsNetworking.jsiClearCookies(callback)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@DoNotStrip
|
|
116
|
+
fun sendRequest(
|
|
117
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
118
|
+
method: String,
|
|
119
|
+
url: String,
|
|
120
|
+
requestIdAsDouble: Double,
|
|
121
|
+
headers: ReadableNativeArray,
|
|
122
|
+
data: ReadableNativeMap,
|
|
123
|
+
responseType: String,
|
|
124
|
+
useIncrementalUpdates: Boolean,
|
|
125
|
+
timeoutAsDouble: Double,
|
|
126
|
+
withCredentials: Boolean,
|
|
127
|
+
) {
|
|
128
|
+
mWorkletsNetworking.jsiSendRequest(
|
|
129
|
+
runtimeWrapper,
|
|
130
|
+
method,
|
|
131
|
+
url,
|
|
132
|
+
requestIdAsDouble,
|
|
133
|
+
headers,
|
|
134
|
+
data,
|
|
135
|
+
responseType,
|
|
136
|
+
useIncrementalUpdates,
|
|
137
|
+
timeoutAsDouble,
|
|
138
|
+
withCredentials,
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@DoNotStrip
|
|
143
|
+
fun requestAnimationFrame(animationFrameCallback: AnimationFrameCallback) {
|
|
144
|
+
mAnimationFrameQueue.requestAnimationFrame(animationFrameCallback)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** @noinspection unused */
|
|
148
|
+
@DoNotStrip
|
|
149
|
+
fun isOnJSQueueThread(): Boolean = reactApplicationContext.isOnJSQueueThread
|
|
150
|
+
|
|
151
|
+
fun toggleSlowAnimations() {
|
|
152
|
+
val animationsDragFactor = 10
|
|
153
|
+
mSlowAnimationsEnabled = !mSlowAnimationsEnabled
|
|
154
|
+
mAnimationFrameQueue.enableSlowAnimations(mSlowAnimationsEnabled, animationsDragFactor)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@OptIn(FrameworkAPI::class)
|
|
158
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
159
|
+
override fun toggleSlowAnimationsOnUIRuntime(): Boolean {
|
|
160
|
+
toggleSlowAnimations()
|
|
161
|
+
return mSlowAnimationsEnabled
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
override fun invalidate() {
|
|
165
|
+
if (mInvalidated.getAndSet(true)) {
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
if (mHybridData != null && mHybridData!!.isValid) {
|
|
169
|
+
invalidateCpp()
|
|
170
|
+
}
|
|
171
|
+
mAndroidUIScheduler.deactivate()
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
private external fun invalidateCpp()
|
|
175
|
+
|
|
176
|
+
private external fun startCpp()
|
|
177
|
+
|
|
178
|
+
override fun onHostResume() {
|
|
179
|
+
mAnimationFrameQueue.resume()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
override fun onHostPause() {
|
|
183
|
+
mAnimationFrameQueue.pause()
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
override fun onHostDestroy() {}
|
|
187
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Based on NetworkEventUtil.kt from React Native
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
@file:Suppress("DEPRECATION_ERROR") // Conflicting okhttp versions
|
|
6
|
+
|
|
7
|
+
package com.swmansion.worklets
|
|
8
|
+
|
|
9
|
+
import android.os.Bundle
|
|
10
|
+
import android.util.Base64
|
|
11
|
+
import com.facebook.react.bridge.Arguments
|
|
12
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
13
|
+
import com.facebook.react.bridge.WritableMap
|
|
14
|
+
import com.facebook.react.bridge.buildReadableArray
|
|
15
|
+
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
|
|
16
|
+
import okhttp3.Headers
|
|
17
|
+
import okhttp3.Protocol
|
|
18
|
+
import okhttp3.Request
|
|
19
|
+
import okhttp3.Response
|
|
20
|
+
import java.net.SocketTimeoutException
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Utility class for reporting network lifecycle events to JavaScript and InspectorNetworkReporter.
|
|
24
|
+
*/
|
|
25
|
+
internal object WorkletsNetworkEventUtil {
|
|
26
|
+
@JvmStatic
|
|
27
|
+
fun onCreateRequest(
|
|
28
|
+
devToolsRequestId: String,
|
|
29
|
+
request: Request,
|
|
30
|
+
) {
|
|
31
|
+
if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
|
32
|
+
val headersMap = okHttpHeadersToMap(request.headers())
|
|
33
|
+
// InspectorNetworkReporter.reportRequestStart(
|
|
34
|
+
// devToolsRequestId,
|
|
35
|
+
// request.url().toString(),
|
|
36
|
+
// request.method(),
|
|
37
|
+
// headersMap,
|
|
38
|
+
// (request.body() as? ProgressRequestBody)?.getBodyPreview()
|
|
39
|
+
// ?: request.body()?.toString().orEmpty(),
|
|
40
|
+
// request.body()?.contentLength() ?: 0,
|
|
41
|
+
// )
|
|
42
|
+
// InspectorNetworkReporter.reportConnectionTiming(devToolsRequestId, headersMap)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@JvmStatic
|
|
47
|
+
fun onDataSend(
|
|
48
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
49
|
+
requestId: Int,
|
|
50
|
+
progress: Long,
|
|
51
|
+
total: Long,
|
|
52
|
+
) {
|
|
53
|
+
runtimeWrapper.emitDeviceEvent(
|
|
54
|
+
"didSendNetworkData",
|
|
55
|
+
buildReadableArray {
|
|
56
|
+
add(requestId)
|
|
57
|
+
add(progress.toInt())
|
|
58
|
+
add(total.toInt())
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@JvmStatic
|
|
64
|
+
fun onIncrementalDataReceived(
|
|
65
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
66
|
+
requestId: Int,
|
|
67
|
+
devToolsRequestId: String,
|
|
68
|
+
data: String?,
|
|
69
|
+
progress: Long,
|
|
70
|
+
total: Long,
|
|
71
|
+
) {
|
|
72
|
+
// if (ReactNativeFeatureFlags.enableNetworkEventReporting() && data != null) {
|
|
73
|
+
// InspectorNetworkReporter.reportDataReceived(devToolsRequestId, data)
|
|
74
|
+
// InspectorNetworkReporter.maybeStoreResponseBodyIncremental(devToolsRequestId, data)
|
|
75
|
+
// }
|
|
76
|
+
runtimeWrapper.emitDeviceEvent(
|
|
77
|
+
"didReceiveNetworkIncrementalData",
|
|
78
|
+
buildReadableArray {
|
|
79
|
+
add(requestId)
|
|
80
|
+
add(data)
|
|
81
|
+
add(progress.toInt())
|
|
82
|
+
add(total.toInt())
|
|
83
|
+
},
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@JvmStatic
|
|
88
|
+
fun onDataReceivedProgress(
|
|
89
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
90
|
+
requestId: Int,
|
|
91
|
+
progress: Long,
|
|
92
|
+
total: Long,
|
|
93
|
+
) {
|
|
94
|
+
runtimeWrapper.emitDeviceEvent(
|
|
95
|
+
"didReceiveNetworkDataProgress",
|
|
96
|
+
buildReadableArray {
|
|
97
|
+
add(requestId)
|
|
98
|
+
add(progress.toInt())
|
|
99
|
+
add(total.toInt())
|
|
100
|
+
},
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@JvmStatic
|
|
105
|
+
fun onDataReceived(
|
|
106
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
107
|
+
requestId: Int,
|
|
108
|
+
devToolsRequestId: String,
|
|
109
|
+
data: String?,
|
|
110
|
+
responseType: String,
|
|
111
|
+
) {
|
|
112
|
+
// if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
|
113
|
+
// InspectorNetworkReporter.maybeStoreResponseBody(
|
|
114
|
+
// devToolsRequestId,
|
|
115
|
+
// data.orEmpty(),
|
|
116
|
+
// responseType == "base64",
|
|
117
|
+
// )
|
|
118
|
+
// }
|
|
119
|
+
runtimeWrapper.emitDeviceEvent(
|
|
120
|
+
"didReceiveNetworkData",
|
|
121
|
+
buildReadableArray {
|
|
122
|
+
add(requestId)
|
|
123
|
+
add(data)
|
|
124
|
+
},
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@JvmStatic
|
|
129
|
+
fun onDataReceived(
|
|
130
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
131
|
+
requestId: Int,
|
|
132
|
+
devToolsRequestId: String,
|
|
133
|
+
data: WritableMap,
|
|
134
|
+
rawData: ByteArray,
|
|
135
|
+
) {
|
|
136
|
+
// if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
|
137
|
+
// InspectorNetworkReporter.maybeStoreResponseBody(
|
|
138
|
+
// devToolsRequestId,
|
|
139
|
+
// Base64.encodeToString(rawData, Base64.NO_WRAP),
|
|
140
|
+
// true,
|
|
141
|
+
// )
|
|
142
|
+
// }
|
|
143
|
+
runtimeWrapper.emitDeviceEvent(
|
|
144
|
+
"didReceiveNetworkData",
|
|
145
|
+
Arguments.createArray().apply {
|
|
146
|
+
pushInt(requestId)
|
|
147
|
+
pushMap(data)
|
|
148
|
+
},
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
@JvmStatic
|
|
153
|
+
fun onRequestError(
|
|
154
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
155
|
+
requestId: Int,
|
|
156
|
+
devToolsRequestId: String,
|
|
157
|
+
error: String?,
|
|
158
|
+
e: Throwable?,
|
|
159
|
+
) {
|
|
160
|
+
runtimeWrapper.emitDeviceEvent(
|
|
161
|
+
"didCompleteNetworkResponse",
|
|
162
|
+
buildReadableArray {
|
|
163
|
+
add(requestId)
|
|
164
|
+
add(error)
|
|
165
|
+
if (e?.javaClass == SocketTimeoutException::class.java) {
|
|
166
|
+
add(true) // last argument is a time out boolean
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@JvmStatic
|
|
173
|
+
fun onRequestSuccess(
|
|
174
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
175
|
+
requestId: Int,
|
|
176
|
+
devToolsRequestId: String,
|
|
177
|
+
encodedDataLength: Long,
|
|
178
|
+
) {
|
|
179
|
+
runtimeWrapper.emitDeviceEvent(
|
|
180
|
+
"didCompleteNetworkResponse",
|
|
181
|
+
buildReadableArray {
|
|
182
|
+
add(requestId)
|
|
183
|
+
addNull()
|
|
184
|
+
},
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@JvmStatic
|
|
189
|
+
fun onResponseReceived(
|
|
190
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
191
|
+
requestId: Int,
|
|
192
|
+
devToolsRequestId: String,
|
|
193
|
+
requestUrl: String?,
|
|
194
|
+
response: Response,
|
|
195
|
+
) {
|
|
196
|
+
val headersMap = okHttpHeadersToMap(response.headers())
|
|
197
|
+
val headersBundle = Bundle()
|
|
198
|
+
for ((headerName, headerValue) in headersMap) {
|
|
199
|
+
headersBundle.putString(headerName, headerValue)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// if (ReactNativeFeatureFlags.enableNetworkEventReporting()) {
|
|
203
|
+
// InspectorNetworkReporter.reportResponseStart(
|
|
204
|
+
// devToolsRequestId,
|
|
205
|
+
// requestUrl.orEmpty(),
|
|
206
|
+
// response.code(),
|
|
207
|
+
// headersMap,
|
|
208
|
+
// response.body()?.contentLength() ?: 0,
|
|
209
|
+
// )
|
|
210
|
+
// }
|
|
211
|
+
runtimeWrapper.emitDeviceEvent(
|
|
212
|
+
"didReceiveNetworkResponse",
|
|
213
|
+
Arguments.createArray().apply {
|
|
214
|
+
pushInt(requestId)
|
|
215
|
+
pushInt(response.code())
|
|
216
|
+
pushMap(Arguments.fromBundle(headersBundle))
|
|
217
|
+
pushString(requestUrl)
|
|
218
|
+
},
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@Deprecated("Compatibility overload")
|
|
223
|
+
@JvmStatic
|
|
224
|
+
fun onResponseReceived(
|
|
225
|
+
runtimeWrapper: WorkletRuntimeWrapper,
|
|
226
|
+
requestId: Int,
|
|
227
|
+
devToolsRequestId: String,
|
|
228
|
+
statusCode: Int,
|
|
229
|
+
headers: WritableMap?,
|
|
230
|
+
url: String?,
|
|
231
|
+
) {
|
|
232
|
+
val headersBuilder = Headers.Builder()
|
|
233
|
+
headers?.let { map ->
|
|
234
|
+
val iterator = map.keySetIterator()
|
|
235
|
+
while (iterator.hasNextKey()) {
|
|
236
|
+
val key = iterator.nextKey()
|
|
237
|
+
val value = map.getString(key)
|
|
238
|
+
if (value != null) {
|
|
239
|
+
headersBuilder.add(key, value)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
onResponseReceived(
|
|
244
|
+
runtimeWrapper,
|
|
245
|
+
requestId,
|
|
246
|
+
devToolsRequestId,
|
|
247
|
+
url,
|
|
248
|
+
Response
|
|
249
|
+
.Builder()
|
|
250
|
+
.protocol(Protocol.HTTP_1_1)
|
|
251
|
+
.request(Request.Builder().url(url.orEmpty()).build())
|
|
252
|
+
.headers(headersBuilder.build())
|
|
253
|
+
.code(statusCode)
|
|
254
|
+
.message("")
|
|
255
|
+
.build(),
|
|
256
|
+
)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
private fun okHttpHeadersToMap(headers: Headers): Map<String, String> {
|
|
260
|
+
val responseHeaders = mutableMapOf<String, String>()
|
|
261
|
+
for (i in 0 until headers.size()) {
|
|
262
|
+
val headerName = headers.name(i)
|
|
263
|
+
// multiple values for the same header
|
|
264
|
+
if (responseHeaders.containsKey(headerName)) {
|
|
265
|
+
responseHeaders[headerName] = "${responseHeaders[headerName]}, ${headers.value(i)}"
|
|
266
|
+
} else {
|
|
267
|
+
responseHeaders[headerName] = headers.value(i)
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return responseHeaders
|
|
271
|
+
}
|
|
272
|
+
}
|