@depup/react-native-worklets 0.12.2-depup.0 → 0.13.0-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/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.cpp +1 -2
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +1 -1
- package/Common/cpp/worklets/Compat/StableApi.cpp +24 -8
- package/Common/cpp/worklets/Compat/StableApi.h +1 -1
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +113 -50
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +10 -1
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +95 -37
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +57 -7
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.cpp +94 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxyInitializer.h +58 -0
- package/Common/cpp/worklets/Networking/Networking.cpp +283 -0
- package/Common/cpp/worklets/Networking/Networking.h +51 -0
- package/Common/cpp/worklets/Networking/NetworkingBackend.h +47 -0
- package/Common/cpp/worklets/Networking/NetworkingInstaller.cpp +127 -0
- package/Common/cpp/worklets/Networking/NetworkingInstaller.h +19 -0
- package/Common/cpp/worklets/Networking/NetworkingTypes.h +33 -0
- package/Common/cpp/worklets/Networking/TextDecoding.cpp +189 -0
- package/Common/cpp/worklets/Networking/TextDecoding.h +29 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueue.h +28 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +9 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +6 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.cpp +19 -4
- package/Common/cpp/worklets/RunLoop/EventLoop.h +3 -0
- package/Common/cpp/worklets/SharedItems/MemoryManager.cpp +1 -1
- package/Common/cpp/worklets/SharedItems/MemoryManager.h +2 -1
- package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.cpp +37 -0
- package/Common/cpp/worklets/SharedItems/Serializable/CustomSerializable.h +33 -0
- package/Common/cpp/worklets/SharedItems/Serializable/RetainingSerializable.h +112 -0
- package/Common/cpp/worklets/SharedItems/Serializable/Serializable.cpp +129 -0
- package/Common/cpp/worklets/SharedItems/Serializable/Serializable.h +121 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.cpp +38 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArray.h +39 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.cpp +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableArrayBuffer.h +43 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.cpp +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableBigInt.h +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.cpp +38 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableError.h +30 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.cpp +24 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostFunction.h +32 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.cpp +19 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableHostObject.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.cpp +29 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableImport.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.cpp +44 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableMap.h +25 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.cpp +80 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableObject.h +35 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.cpp +22 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableRegExp.h +25 -0
- package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.cpp → Serializable/SerializableRemoteFunction.cpp} +30 -2
- package/Common/cpp/worklets/SharedItems/{SerializableRemoteFunction.h → Serializable/SerializableRemoteFunction.h} +24 -10
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.cpp +46 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableScalar.h +41 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.cpp +36 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableSet.h +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.cpp +19 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableString.h +22 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.cpp +26 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableTurboModuleLike.h +33 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.cpp +31 -0
- package/Common/cpp/worklets/SharedItems/Serializable/SerializableWorklet.h +23 -0
- package/Common/cpp/worklets/SharedItems/Serializable.h +21 -409
- package/Common/cpp/worklets/SharedItems/Shareable.cpp +1 -1
- package/Common/cpp/worklets/SharedItems/Shareable.h +1 -1
- package/Common/cpp/worklets/SharedItems/Synchronizable.h +43 -20
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +24 -26
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +5 -7
- package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.cpp +36 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableDynamic.h +27 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableFixed.cpp +76 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableFixed.h +48 -0
- package/Common/cpp/worklets/Tools/ScriptBuffer.h +0 -5
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +16 -30
- package/Common/cpp/worklets/WorkletRuntime/RuntimeBindings.h +27 -30
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +4 -3
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +2 -1
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +79 -29
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +34 -19
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +13 -86
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +1 -7
- package/Package.swift +147 -0
- package/README.md +5 -5
- package/RNWorklets.podspec +1 -2
- package/android/CMakeLists.txt +7 -26
- package/android/build.gradle.kts +5 -31
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +46 -129
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +21 -11
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +2 -4
- package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.cpp +82 -0
- package/android/src/main/cpp/worklets/android/networking/AndroidNetworkingBackend.h +32 -0
- package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.cpp +73 -0
- package/android/src/main/cpp/worklets/android/networking/JNetworkRequestListener.h +38 -0
- package/android/src/{no-networking → main/java}/com/swmansion/worklets/WorkletsModule.kt +39 -28
- package/android/src/main/java/com/swmansion/worklets/networking/NetworkRequestListener.kt +37 -0
- package/android/src/main/java/com/swmansion/worklets/networking/Networking.kt +244 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.kt +3 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +9 -1
- package/apple/worklets/apple/AssertJavaScriptQueue.h +3 -2
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +4 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +3 -0
- package/apple/worklets/apple/Networking/AppleNetworkingBackend.h +29 -0
- package/apple/worklets/apple/Networking/AppleNetworkingBackend.mm +93 -0
- package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.h +37 -0
- package/apple/worklets/apple/Networking/WorkletsURLSessionDelegate.mm +447 -0
- package/apple/worklets/apple/WorkletsModule.h +3 -2
- package/apple/worklets/apple/WorkletsModule.mm +82 -74
- package/bundleMode/index.js +10 -47
- package/bundleMode/polyfills/prepareBundleMode.js +16 -0
- package/changes.json +4 -4
- package/compatibility.json +4 -1
- package/lib/module/WorkletsModule/NativeWorklets.native.js +12 -9
- package/lib/module/WorkletsModule/NativeWorklets.native.js.map +1 -1
- package/lib/module/debug/jsVersion.js +1 -1
- package/lib/module/featureFlags/staticFlags.json +0 -1
- package/lib/module/featureFlags/types.js +0 -1
- package/lib/module/featureFlags/types.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/initializers/initializers.native.js +5 -12
- package/lib/module/initializers/initializers.native.js.map +1 -1
- package/lib/module/memory/bundleUnpacker.native.js +2 -10
- package/lib/module/memory/bundleUnpacker.native.js.map +1 -1
- package/lib/module/memory/serializable.native.js +1 -29
- package/lib/module/memory/serializable.native.js.map +1 -1
- package/lib/module/memory/synchronizable.js +1 -1
- package/lib/module/memory/synchronizable.js.map +1 -1
- package/lib/module/memory/synchronizable.native.js +7 -3
- package/lib/module/memory/synchronizable.native.js.map +1 -1
- package/lib/module/memory/synchronizableUnpacker.native.js +7 -2
- package/lib/module/memory/synchronizableUnpacker.native.js.map +1 -1
- package/lib/module/memory/valueUnpacker.native.js +0 -8
- package/lib/module/memory/valueUnpacker.native.js.map +1 -1
- package/lib/module/mock.js +22 -1
- package/lib/module/mock.js.map +1 -1
- package/lib/module/networking/AbortController.js +43 -0
- package/lib/module/networking/AbortController.js.map +1 -0
- package/lib/module/networking/Blob.js +60 -0
- package/lib/module/networking/Blob.js.map +1 -0
- package/lib/module/networking/DOMException.js +35 -0
- package/lib/module/networking/DOMException.js.map +1 -0
- package/lib/module/networking/FileReader.js +83 -0
- package/lib/module/networking/FileReader.js.map +1 -0
- package/lib/module/networking/FormData.js +105 -0
- package/lib/module/networking/FormData.js.map +1 -0
- package/lib/module/networking/XMLHttpRequest.js +450 -0
- package/lib/module/networking/XMLHttpRequest.js.map +1 -0
- package/lib/module/networking/bytes.js +6 -0
- package/lib/module/networking/bytes.js.map +1 -0
- package/lib/module/networking/events.js +44 -0
- package/lib/module/networking/events.js.map +1 -0
- package/lib/module/networking/http.js +100 -0
- package/lib/module/networking/http.js.map +1 -0
- package/lib/module/networking/install.js +37 -0
- package/lib/module/networking/install.js.map +1 -0
- package/lib/module/networking/utf8.js +99 -0
- package/lib/module/networking/utf8.js.map +1 -0
- package/lib/module/privateGlobals.d.js +0 -1
- package/lib/module/privateGlobals.d.js.map +1 -1
- package/lib/module/runLoop/common/queueMicrotaskPolyfill.js +9 -0
- package/lib/module/runLoop/common/queueMicrotaskPolyfill.js.map +1 -0
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js +7 -3
- package/lib/module/runLoop/uiRuntime/requestAnimationFrame.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/index.js +1 -1
- package/lib/module/runLoop/workletRuntime/index.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js +1 -1
- package/lib/module/runLoop/workletRuntime/requestAnimationFramePolyfill.js.map +1 -1
- package/lib/module/runLoop/workletRuntime/taskQueue.js +0 -13
- package/lib/module/runLoop/workletRuntime/taskQueue.js.map +1 -1
- package/lib/module/runtimes.native.js +8 -1
- package/lib/module/runtimes.native.js.map +1 -1
- package/lib/module/specs/NativeWorkletsModule.js.map +1 -1
- package/lib/module/threads.js +11 -0
- package/lib/module/threads.js.map +1 -1
- package/lib/module/threads.native.js +35 -42
- package/lib/module/threads.native.js.map +1 -1
- package/lib/typescript/WorkletsModule/NativeWorklets.native.d.ts.map +1 -1
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +6 -5
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -1
- package/lib/typescript/debug/jsVersion.d.ts +1 -1
- package/lib/typescript/featureFlags/types.d.ts +0 -1
- package/lib/typescript/featureFlags/types.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/memory/bundleUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/memory/serializable.native.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizable.d.ts +6 -2
- package/lib/typescript/memory/synchronizable.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizable.native.d.ts +6 -2
- package/lib/typescript/memory/synchronizable.native.d.ts.map +1 -1
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts +1 -1
- package/lib/typescript/memory/synchronizableUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/memory/types.d.ts +6 -0
- package/lib/typescript/memory/types.d.ts.map +1 -1
- package/lib/typescript/memory/valueUnpacker.native.d.ts.map +1 -1
- package/lib/typescript/networking/AbortController.d.ts +16 -0
- package/lib/typescript/networking/AbortController.d.ts.map +1 -0
- package/lib/typescript/networking/Blob.d.ts +16 -0
- package/lib/typescript/networking/Blob.d.ts.map +1 -0
- package/lib/typescript/networking/DOMException.d.ts +5 -0
- package/lib/typescript/networking/DOMException.d.ts.map +1 -0
- package/lib/typescript/networking/FileReader.d.ts +19 -0
- package/lib/typescript/networking/FileReader.d.ts.map +1 -0
- package/lib/typescript/networking/FormData.d.ts +30 -0
- package/lib/typescript/networking/FormData.d.ts.map +1 -0
- package/lib/typescript/networking/XMLHttpRequest.d.ts +77 -0
- package/lib/typescript/networking/XMLHttpRequest.d.ts.map +1 -0
- package/lib/typescript/networking/bytes.d.ts +2 -0
- package/lib/typescript/networking/bytes.d.ts.map +1 -0
- package/lib/typescript/networking/events.d.ts +18 -0
- package/lib/typescript/networking/events.d.ts.map +1 -0
- package/lib/typescript/networking/http.d.ts +14 -0
- package/lib/typescript/networking/http.d.ts.map +1 -0
- package/lib/typescript/networking/install.d.ts +2 -0
- package/lib/typescript/networking/install.d.ts.map +1 -0
- package/lib/typescript/networking/utf8.d.ts +4 -0
- package/lib/typescript/networking/utf8.d.ts.map +1 -0
- package/lib/typescript/runLoop/{workletRuntime/queueMicrotask.d.ts → common/queueMicrotaskPolyfill.d.ts} +1 -1
- package/lib/typescript/runLoop/common/queueMicrotaskPolyfill.d.ts.map +1 -0
- package/lib/typescript/runLoop/uiRuntime/requestAnimationFrame.d.ts.map +1 -1
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts +0 -2
- package/lib/typescript/runLoop/workletRuntime/taskQueue.d.ts.map +1 -1
- package/lib/typescript/runtimes.native.d.ts.map +1 -1
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -1
- package/lib/typescript/threads.d.ts +8 -0
- package/lib/typescript/threads.d.ts.map +1 -1
- package/lib/typescript/threads.native.d.ts +8 -1
- package/lib/typescript/threads.native.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +9 -5
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +32 -18
- package/plugin/index.js +63 -93
- package/plugin-oxc/babel.d.ts +7 -0
- package/plugin-oxc/babel.js +200 -0
- package/plugin-oxc/index.d.ts +33 -0
- package/plugin-oxc/index.js +36 -0
- package/plugin-oxc/worklets-oxc-plugin.darwin-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.darwin-x64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.linux-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.linux-x64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.win32-arm64.node +0 -0
- package/plugin-oxc/worklets-oxc-plugin.win32-x64.node +0 -0
- package/react-native.config.js +5 -0
- package/scripts/worklets_utils.rb +0 -10
- package/src/WorkletsModule/NativeWorklets.native.ts +26 -9
- package/src/WorkletsModule/workletsModuleProxy.ts +15 -5
- package/src/debug/jsVersion.ts +1 -1
- package/src/featureFlags/staticFlags.json +0 -1
- package/src/featureFlags/types.ts +0 -1
- package/src/index.ts +3 -0
- package/src/initializers/initializers.native.ts +5 -13
- package/src/memory/bundleUnpacker.native.ts +6 -13
- package/src/memory/serializable.native.ts +1 -44
- package/src/memory/synchronizable.native.ts +38 -4
- package/src/memory/synchronizable.ts +22 -2
- package/src/memory/synchronizableUnpacker.native.ts +23 -4
- package/src/memory/types.ts +9 -0
- package/src/memory/valueUnpacker.native.ts +0 -8
- package/src/mock.ts +28 -1
- package/src/networking/AbortController.ts +57 -0
- package/src/networking/Blob.ts +74 -0
- package/src/networking/DOMException.ts +37 -0
- package/src/networking/FileReader.ts +99 -0
- package/src/networking/FormData.ts +135 -0
- package/src/networking/XMLHttpRequest.ts +557 -0
- package/src/networking/bytes.ts +8 -0
- package/src/networking/events.ts +61 -0
- package/src/networking/http.ts +173 -0
- package/src/networking/install.ts +38 -0
- package/src/networking/utf8.ts +122 -0
- package/src/privateGlobals.d.ts +20 -13
- package/src/runLoop/common/queueMicrotaskPolyfill.ts +12 -0
- package/src/runLoop/uiRuntime/requestAnimationFrame.ts +7 -4
- package/src/runLoop/workletRuntime/index.ts +1 -1
- package/src/runLoop/workletRuntime/requestAnimationFramePolyfill.ts +1 -1
- package/src/runLoop/workletRuntime/taskQueue.ts +0 -15
- package/src/runtimes.native.ts +10 -1
- package/src/specs/NativeWorkletsModule.ts +1 -0
- package/src/threads.native.ts +49 -54
- package/src/threads.ts +11 -0
- package/src/types.ts +9 -5
- package/Common/cpp/worklets/SharedItems/Serializable.cpp +0 -389
- package/Common/cpp/worklets/SharedItems/SerializableFactory.cpp +0 -172
- package/Common/cpp/worklets/SharedItems/SerializableFactory.h +0 -85
- package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +0 -59
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.cpp +0 -51
- package/android/src/main/cpp/worklets/android/JWorkletRuntimeWrapper.h +0 -43
- package/android/src/networking/com/swmansion/worklets/WorkletRuntimeWrapper.kt +0 -27
- package/android/src/networking/com/swmansion/worklets/WorkletsHeaderUtil.kt +0 -30
- package/android/src/networking/com/swmansion/worklets/WorkletsModule.kt +0 -204
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworkEventUtil.kt +0 -272
- package/android/src/networking/com/swmansion/worklets/WorkletsNetworking.kt +0 -1124
- package/android/src/networking/com/swmansion/worklets/WorkletsOkHttpCallUtil.kt +0 -40
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressListener.kt +0 -13
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressRequestBody.kt +0 -98
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressResponseBody.kt +0 -60
- package/android/src/networking/com/swmansion/worklets/WorkletsProgressiveStringDecoder.kt +0 -87
- package/android/src/networking/com/swmansion/worklets/WorkletsRequestBodyUtil.kt +0 -181
- package/apple/worklets/apple/Networking/WorkletsNetworking.h +0 -25
- package/apple/worklets/apple/Networking/WorkletsNetworking.mm +0 -707
- package/bundleMode/shims/turboModuleRegistryShim.js +0 -47
- package/lib/module/bundleMode/network.native.js +0 -44
- package/lib/module/bundleMode/network.native.js.map +0 -1
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js +0 -11
- package/lib/module/runLoop/workletRuntime/queueMicrotask.js.map +0 -1
- package/lib/typescript/bundleMode/network.native.d.ts +0 -7
- package/lib/typescript/bundleMode/network.native.d.ts.map +0 -1
- package/lib/typescript/runLoop/workletRuntime/queueMicrotask.d.ts.map +0 -1
- package/src/bundleMode/network.native.ts +0 -63
- package/src/runLoop/workletRuntime/queueMicrotask.ts +0 -13
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#include <react/debug/react_native_assert.h>
|
|
2
|
-
#include <worklets/SharedItems/Synchronizable.h>
|
|
3
|
-
|
|
4
|
-
#include <memory>
|
|
5
|
-
#include <utility>
|
|
6
|
-
|
|
7
|
-
namespace worklets {
|
|
8
|
-
|
|
9
|
-
std::shared_ptr<Serializable> Synchronizable::getDirty() {
|
|
10
|
-
return value_;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
std::shared_ptr<Serializable> Synchronizable::getBlocking() {
|
|
14
|
-
getBlockingBefore();
|
|
15
|
-
auto value = value_;
|
|
16
|
-
getBlockingAfter();
|
|
17
|
-
return value;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// TODO: Shared pointer members (unless they're atomic) can't be assigned
|
|
21
|
-
// in a non thread-safe manner, therefore `setDirty` has little sense now.
|
|
22
|
-
// void Synchronizable::setDirty(const std::shared_ptr<Serializable> &value) {
|
|
23
|
-
// setDirtyBefore();
|
|
24
|
-
// value_ = value;
|
|
25
|
-
// setDirtyAfter();
|
|
26
|
-
// }
|
|
27
|
-
|
|
28
|
-
void Synchronizable::setBlocking(const std::shared_ptr<Serializable> &value) {
|
|
29
|
-
setBlockingBefore();
|
|
30
|
-
value_ = value;
|
|
31
|
-
setBlockingAfter();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
jsi::Value Synchronizable::toJSValue(jsi::Runtime &rt) {
|
|
35
|
-
auto synchronizableUnpacker = getSynchronizableUnpacker(rt);
|
|
36
|
-
auto ref = SerializableJSRef::newNativeStateObject(rt, this->shared_from_this());
|
|
37
|
-
return synchronizableUnpacker.call(rt, std::move(ref));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Synchronizable::Synchronizable(const std::shared_ptr<Serializable> &value)
|
|
41
|
-
: Serializable(ValueType::SynchronizableType), value_(value) {}
|
|
42
|
-
|
|
43
|
-
jsi::Function getSynchronizableUnpacker(jsi::Runtime &rt) {
|
|
44
|
-
auto synchronizableUnpacker = rt.global().getProperty(rt, "__synchronizableUnpacker");
|
|
45
|
-
react_native_assert(synchronizableUnpacker.isObject() && "synchronizableUnpacker not found");
|
|
46
|
-
return synchronizableUnpacker.asObject(rt).asFunction(rt);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
std::shared_ptr<Synchronizable> extractSynchronizableOrThrow(jsi::Runtime &rt, const jsi::Value &value) {
|
|
50
|
-
auto serializable =
|
|
51
|
-
extractSerializableOrThrow(rt, value, "[Worklets] Expecting the object to be of type SerializableJSRef.");
|
|
52
|
-
|
|
53
|
-
auto synchronizable = std::dynamic_pointer_cast<Synchronizable>(serializable);
|
|
54
|
-
react_native_assert(synchronizable != nullptr && "[Worklets] Expected the object to be a Synchronizable.");
|
|
55
|
-
|
|
56
|
-
return synchronizable;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
} // namespace worklets
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
2
|
-
|
|
3
|
-
#include <jsi/JSIDynamic.h>
|
|
4
|
-
#include <jsi/jsi.h>
|
|
5
|
-
#include <worklets/android/JWorkletRuntimeWrapper.h>
|
|
6
|
-
|
|
7
|
-
#include <utility>
|
|
8
|
-
#include <vector>
|
|
9
|
-
|
|
10
|
-
namespace worklets {
|
|
11
|
-
|
|
12
|
-
using namespace facebook::jni;
|
|
13
|
-
|
|
14
|
-
local_ref<JWorkletRuntimeWrapper::JavaPart> JWorkletRuntimeWrapper::makeJWorkletRuntimeWrapper(
|
|
15
|
-
std::shared_ptr<WorkletRuntime> workletRuntime) {
|
|
16
|
-
return JWorkletRuntimeWrapper::newObjectCxxArgs(std::move(workletRuntime));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
JWorkletRuntimeWrapper::JWorkletRuntimeWrapper(std::shared_ptr<WorkletRuntime> workletRuntime)
|
|
20
|
-
: workletRuntime_(std::move(workletRuntime)) {}
|
|
21
|
-
|
|
22
|
-
void JWorkletRuntimeWrapper::cxxEmitDeviceEvent(
|
|
23
|
-
jni::alias_ref<WritableNativeArray::javaobject> params // NOLINT //(performance-unnecessary-value-param
|
|
24
|
-
) {
|
|
25
|
-
workletRuntime_->schedule([params = params->cthis()->consume()](jsi::Runtime &rt) {
|
|
26
|
-
facebook::jsi::Value emitter = rt.global().getProperty(rt, "__rctDeviceEventEmitter");
|
|
27
|
-
if (!emitter.isUndefined()) {
|
|
28
|
-
facebook::jsi::Object emitterObject = emitter.asObject(rt);
|
|
29
|
-
facebook::jsi::Function emitFunction = emitterObject.getPropertyAsFunction(rt, "emit");
|
|
30
|
-
std::vector<jsi::Value> jsArgs;
|
|
31
|
-
for (auto ¶m : params) {
|
|
32
|
-
jsArgs.push_back(jsi::valueFromDynamic(rt, param));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
emitFunction.callWithThis(rt, emitterObject, static_cast<const jsi::Value *>(jsArgs.data()), jsArgs.size());
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
int JWorkletRuntimeWrapper::cxxGetRuntimeId() {
|
|
41
|
-
return static_cast<int>(workletRuntime_->getRuntimeId());
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
void JWorkletRuntimeWrapper::registerNatives() {
|
|
45
|
-
registerHybrid(
|
|
46
|
-
{makeNativeMethod("cxxEmitDeviceEvent", JWorkletRuntimeWrapper::cxxEmitDeviceEvent),
|
|
47
|
-
makeNativeMethod("cxxGetRuntimeId", JWorkletRuntimeWrapper::cxxGetRuntimeId)});
|
|
48
|
-
}
|
|
49
|
-
} // namespace worklets
|
|
50
|
-
|
|
51
|
-
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#ifdef WORKLETS_FETCH_PREVIEW_ENABLED
|
|
4
|
-
|
|
5
|
-
#include <fbjni/fbjni.h>
|
|
6
|
-
#include <react/jni/ReadableNativeArray.h>
|
|
7
|
-
#include <react/jni/WritableNativeArray.h>
|
|
8
|
-
#include <worklets/WorkletRuntime/WorkletRuntime.h>
|
|
9
|
-
|
|
10
|
-
#include <memory>
|
|
11
|
-
|
|
12
|
-
namespace worklets {
|
|
13
|
-
|
|
14
|
-
using namespace facebook;
|
|
15
|
-
using namespace facebook::react;
|
|
16
|
-
using namespace facebook::jni;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* JNI wrapper around WorkletRuntime to expose its methods to Java.
|
|
20
|
-
*/
|
|
21
|
-
class JWorkletRuntimeWrapper : public jni::HybridClass<JWorkletRuntimeWrapper> {
|
|
22
|
-
public:
|
|
23
|
-
constexpr static const char *const kJavaDescriptor = "Lcom/swmansion/worklets/WorkletRuntimeWrapper;";
|
|
24
|
-
|
|
25
|
-
static local_ref<JWorkletRuntimeWrapper::JavaPart> makeJWorkletRuntimeWrapper(
|
|
26
|
-
std::shared_ptr<WorkletRuntime> workletRuntime);
|
|
27
|
-
|
|
28
|
-
static void registerNatives();
|
|
29
|
-
|
|
30
|
-
void cxxEmitDeviceEvent(jni::alias_ref<WritableNativeArray::javaobject> params);
|
|
31
|
-
int cxxGetRuntimeId();
|
|
32
|
-
|
|
33
|
-
private:
|
|
34
|
-
friend HybridBase;
|
|
35
|
-
|
|
36
|
-
explicit JWorkletRuntimeWrapper(std::shared_ptr<WorkletRuntime> workletRuntime);
|
|
37
|
-
|
|
38
|
-
const std::shared_ptr<WorkletRuntime> workletRuntime_;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
} // namespace worklets
|
|
42
|
-
|
|
43
|
-
#endif // WORKLETS_FETCH_PREVIEW_ENABLED
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
package com.swmansion.worklets
|
|
2
|
-
|
|
3
|
-
import com.facebook.jni.HybridData
|
|
4
|
-
import com.facebook.jni.annotations.DoNotStrip
|
|
5
|
-
import com.facebook.react.bridge.Arguments
|
|
6
|
-
import com.facebook.react.bridge.WritableNativeArray
|
|
7
|
-
|
|
8
|
-
@DoNotStrip
|
|
9
|
-
@Suppress("KotlinJniMissingFunction")
|
|
10
|
-
class WorkletRuntimeWrapper
|
|
11
|
-
@DoNotStrip
|
|
12
|
-
private constructor(
|
|
13
|
-
@field:DoNotStrip private val mHybridData: HybridData,
|
|
14
|
-
) {
|
|
15
|
-
fun emitDeviceEvent(
|
|
16
|
-
eventName: String,
|
|
17
|
-
params: Any?,
|
|
18
|
-
) {
|
|
19
|
-
cxxEmitDeviceEvent(Arguments.fromJavaArgs(arrayOf(eventName, params)))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
fun getRuntimeId(): Int = cxxGetRuntimeId()
|
|
23
|
-
|
|
24
|
-
private external fun cxxEmitDeviceEvent(args: WritableNativeArray)
|
|
25
|
-
|
|
26
|
-
private external fun cxxGetRuntimeId(): Int
|
|
27
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Based on HeaderUtil.kt from React Native
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
package com.swmansion.worklets
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The class purpose is to weaken too strict OkHttp restriction on http headers. See:
|
|
9
|
-
* https://github.com/square/okhttp/issues/2016 Auth headers might have an Authentication
|
|
10
|
-
* information. It is better to get 401 from the server in this case, rather than non descriptive
|
|
11
|
-
* error as 401 could be handled to invalidate the wrong token in the client code.
|
|
12
|
-
*/
|
|
13
|
-
internal class WorkletsHeaderUtil {
|
|
14
|
-
companion object {
|
|
15
|
-
@JvmStatic
|
|
16
|
-
fun stripHeaderName(name: String): String {
|
|
17
|
-
val builder = StringBuilder(name.length)
|
|
18
|
-
var modified = false
|
|
19
|
-
for (i in 0 until name.length) {
|
|
20
|
-
val c = name[i]
|
|
21
|
-
if (c > '\u0020' && c < '\u007f') {
|
|
22
|
-
builder.append(c)
|
|
23
|
-
} else {
|
|
24
|
-
modified = true
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return if (modified) builder.toString() else name
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
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
|
-
|
|
18
|
-
@Suppress("KotlinJniMissingFunction")
|
|
19
|
-
@ReactModule(name = WorkletsModule.NAME)
|
|
20
|
-
class WorkletsModule(
|
|
21
|
-
reactContext: ReactApplicationContext,
|
|
22
|
-
) : NativeWorkletsModuleSpec(reactContext),
|
|
23
|
-
LifecycleEventListener {
|
|
24
|
-
companion object {
|
|
25
|
-
const val NAME = "WorkletsModule"
|
|
26
|
-
|
|
27
|
-
init {
|
|
28
|
-
SoLoader.loadLibrary("worklets")
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@field:DoNotStrip
|
|
33
|
-
@Suppress("unused")
|
|
34
|
-
private var mHybridData: HybridData? = null
|
|
35
|
-
|
|
36
|
-
@Suppress("unused")
|
|
37
|
-
protected fun getHybridData(): HybridData? = mHybridData
|
|
38
|
-
|
|
39
|
-
init {
|
|
40
|
-
reactContext.assertOnJSQueueThread()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
private val mAndroidUIScheduler = AndroidUIScheduler(reactContext)
|
|
44
|
-
private val mAnimationFrameQueue = AnimationFrameQueue(reactContext)
|
|
45
|
-
private val mWorkletsNetworking = WorkletsNetworking()
|
|
46
|
-
private var mSlowAnimationsEnabled = false
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Invalidating concurrently could be fatal. It shouldn't happen in a normal flow, but it doesn't
|
|
50
|
-
* cost us much to add synchronization for extra safety.
|
|
51
|
-
*/
|
|
52
|
-
private val mInvalidationLock = Any()
|
|
53
|
-
private var mInvalidated = 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 scriptBufferWrapper: ScriptBufferWrapper? =
|
|
75
|
-
if (bundleModeEnabled) {
|
|
76
|
-
ScriptBufferWrapper(context.sourceURL, context)
|
|
77
|
-
} else {
|
|
78
|
-
null
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
mHybridData =
|
|
82
|
-
initHybrid(
|
|
83
|
-
bundleModeEnabled,
|
|
84
|
-
jsContext,
|
|
85
|
-
jsCallInvokerHolder,
|
|
86
|
-
mAndroidUIScheduler,
|
|
87
|
-
scriptBufferWrapper,
|
|
88
|
-
)
|
|
89
|
-
return true
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
@OptIn(FrameworkAPI::class)
|
|
93
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
94
|
-
override fun start(): Boolean {
|
|
95
|
-
reactApplicationContext.assertOnJSQueueThread()
|
|
96
|
-
startCpp()
|
|
97
|
-
return true
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
@DoNotStrip
|
|
101
|
-
fun abortRequest(
|
|
102
|
-
runtimeId: Int,
|
|
103
|
-
requestIdAsDouble: Double,
|
|
104
|
-
) {
|
|
105
|
-
mWorkletsNetworking.jsiAbortRequest(runtimeId, requestIdAsDouble)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
@DoNotStrip
|
|
109
|
-
fun clearCookies(callback: Callback) {
|
|
110
|
-
mWorkletsNetworking.jsiClearCookies(callback)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
@DoNotStrip
|
|
114
|
-
fun sendRequest(
|
|
115
|
-
runtimeWrapper: WorkletRuntimeWrapper,
|
|
116
|
-
method: String,
|
|
117
|
-
url: String,
|
|
118
|
-
requestIdAsDouble: Double,
|
|
119
|
-
headers: ReadableNativeArray,
|
|
120
|
-
data: ReadableNativeMap,
|
|
121
|
-
responseType: String,
|
|
122
|
-
useIncrementalUpdates: Boolean,
|
|
123
|
-
timeoutAsDouble: Double,
|
|
124
|
-
withCredentials: Boolean,
|
|
125
|
-
) {
|
|
126
|
-
mWorkletsNetworking.jsiSendRequest(
|
|
127
|
-
runtimeWrapper,
|
|
128
|
-
method,
|
|
129
|
-
url,
|
|
130
|
-
requestIdAsDouble,
|
|
131
|
-
headers,
|
|
132
|
-
data,
|
|
133
|
-
responseType,
|
|
134
|
-
useIncrementalUpdates,
|
|
135
|
-
timeoutAsDouble,
|
|
136
|
-
withCredentials,
|
|
137
|
-
)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@DoNotStrip
|
|
141
|
-
fun requestAnimationFrame(animationFrameCallback: AnimationFrameCallback) {
|
|
142
|
-
mAnimationFrameQueue.requestAnimationFrame(animationFrameCallback)
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/** @noinspection unused */
|
|
146
|
-
@DoNotStrip
|
|
147
|
-
fun isOnJSQueueThread(): Boolean = reactApplicationContext.isOnJSQueueThread
|
|
148
|
-
|
|
149
|
-
fun toggleSlowAnimations() {
|
|
150
|
-
val animationsDragFactor = 10
|
|
151
|
-
mSlowAnimationsEnabled = !mSlowAnimationsEnabled
|
|
152
|
-
mAnimationFrameQueue.enableSlowAnimations(mSlowAnimationsEnabled, animationsDragFactor)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@OptIn(FrameworkAPI::class)
|
|
156
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
157
|
-
override fun toggleSlowAnimationsOnUIRuntime(): Boolean {
|
|
158
|
-
toggleSlowAnimations()
|
|
159
|
-
return mSlowAnimationsEnabled
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
override fun initialize() {
|
|
163
|
-
reactApplicationContext.addLifecycleEventListener(this)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
override fun invalidate() {
|
|
167
|
-
synchronized(mInvalidationLock) {
|
|
168
|
-
if (mInvalidated) {
|
|
169
|
-
return
|
|
170
|
-
}
|
|
171
|
-
mInvalidated = true
|
|
172
|
-
reactApplicationContext.removeLifecycleEventListener(this)
|
|
173
|
-
}
|
|
174
|
-
mAnimationFrameQueue.invalidate()
|
|
175
|
-
if (mHybridData != null && mHybridData!!.isValid) {
|
|
176
|
-
invalidateCpp()
|
|
177
|
-
}
|
|
178
|
-
mAndroidUIScheduler.deactivate()
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private external fun invalidateCpp()
|
|
182
|
-
|
|
183
|
-
private external fun startCpp()
|
|
184
|
-
|
|
185
|
-
override fun onHostResume() {
|
|
186
|
-
synchronized(mInvalidationLock) {
|
|
187
|
-
if (mInvalidated) {
|
|
188
|
-
return
|
|
189
|
-
}
|
|
190
|
-
mAnimationFrameQueue.resume()
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
override fun onHostPause() {
|
|
195
|
-
synchronized(mInvalidationLock) {
|
|
196
|
-
if (mInvalidated) {
|
|
197
|
-
return
|
|
198
|
-
}
|
|
199
|
-
mAnimationFrameQueue.pause()
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
override fun onHostDestroy() {}
|
|
204
|
-
}
|
|
@@ -1,272 +0,0 @@
|
|
|
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
|
-
}
|