@amazon-devices/react-native-worklets 1.0.0-rn-83
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 +71 -0
- package/Common/cpp/worklets/AnimationFrameQueue/AnimationFrameBatchinator.h +38 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.cpp +712 -0
- package/Common/cpp/worklets/NativeModules/JSIWorkletsModuleProxy.h +88 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.cpp +89 -0
- package/Common/cpp/worklets/NativeModules/WorkletsModuleProxy.h +80 -0
- package/Common/cpp/worklets/Public/AsyncQueue.h +14 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.cpp +94 -0
- package/Common/cpp/worklets/Registries/EventHandlerRegistry.h +51 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.cpp +8 -0
- package/Common/cpp/worklets/Registries/WorkletRuntimeRegistry.h +40 -0
- package/Common/cpp/worklets/Resources/SynchronizableUnpacker.cpp +49 -0
- package/Common/cpp/worklets/Resources/Unpackers.h +6 -0
- package/Common/cpp/worklets/Resources/ValueUnpacker.cpp +53 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.cpp +62 -0
- package/Common/cpp/worklets/RunLoop/AsyncQueueImpl.h +46 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.cpp +112 -0
- package/Common/cpp/worklets/RunLoop/EventLoop.h +52 -0
- package/Common/cpp/worklets/SharedItems/Serializable.cpp +545 -0
- package/Common/cpp/worklets/SharedItems/Serializable.h +473 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.cpp +67 -0
- package/Common/cpp/worklets/SharedItems/Synchronizable.h +59 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.cpp +81 -0
- package/Common/cpp/worklets/SharedItems/SynchronizableAccess.h +45 -0
- package/Common/cpp/worklets/Tools/Defs.h +10 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.cpp +15 -0
- package/Common/cpp/worklets/Tools/FeatureFlags.h +44 -0
- package/Common/cpp/worklets/Tools/JSISerializer.cpp +342 -0
- package/Common/cpp/worklets/Tools/JSISerializer.h +51 -0
- package/Common/cpp/worklets/Tools/JSLogger.cpp +68 -0
- package/Common/cpp/worklets/Tools/JSLogger.h +37 -0
- package/Common/cpp/worklets/Tools/JSScheduler.cpp +24 -0
- package/Common/cpp/worklets/Tools/JSScheduler.h +39 -0
- package/Common/cpp/worklets/Tools/PlatformLogger.h +16 -0
- package/Common/cpp/worklets/Tools/SingleInstanceChecker.h +82 -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 +26 -0
- package/Common/cpp/worklets/Tools/VersionUtils.cpp +75 -0
- package/Common/cpp/worklets/Tools/VersionUtils.h +28 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.cpp +29 -0
- package/Common/cpp/worklets/Tools/WorkletEventHandler.h +41 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.cpp +46 -0
- package/Common/cpp/worklets/Tools/WorkletsJSIUtils.h +208 -0
- package/Common/cpp/worklets/Tools/WorkletsSystraceSection.h +161 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.cpp +54 -0
- package/Common/cpp/worklets/Tools/WorkletsVersion.h +20 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.cpp +38 -0
- package/Common/cpp/worklets/WorkletRuntime/RNRuntimeWorkletDecorator.h +21 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeData.cpp +3 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeData.h +12 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeInitialization.md +191 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeKind.h +16 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.cpp +105 -0
- package/Common/cpp/worklets/WorkletRuntime/RuntimeManager.h +63 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.cpp +23 -0
- package/Common/cpp/worklets/WorkletRuntime/UIRuntimeDecorator.h +16 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.cpp +119 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletHermesRuntime.h +134 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.cpp +244 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntime.h +102 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeCollector.h +36 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.cpp +308 -0
- package/Common/cpp/worklets/WorkletRuntime/WorkletRuntimeDecorator.h +26 -0
- package/LICENSE +7 -0
- package/README.md +31 -0
- package/RNWorklets.podspec +94 -0
- package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.bundle +10512 -0
- package/SystemBundles/cc12deac6e91c435b76698c8445aed85612f2f88e733218d14f88a35d06fb0f4.map +3771 -0
- package/SystemModules/amzn__react-native-worklets-1.modules.txt +39 -0
- package/SystemModules/amzn__react-native-worklets-1.private.modules.txt +61 -0
- package/SystemModules/keplerscript-system-bundle-config.json +7 -0
- package/android/CMakeLists.txt +124 -0
- package/android/build.gradle +350 -0
- package/android/gradle.properties +5 -0
- package/android/proguard-rules.pro +3 -0
- package/android/spotless.gradle +9 -0
- package/android/src/experimentalBundling/com/swmansion/worklets/WorkletsModule.java +149 -0
- package/android/src/legacyBundling/com/swmansion/worklets/WorkletsModule.java +122 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.cpp +63 -0
- package/android/src/main/cpp/worklets/android/AndroidUIScheduler.h +43 -0
- package/android/src/main/cpp/worklets/android/AnimationFrameCallback.h +34 -0
- package/android/src/main/cpp/worklets/android/PlatformLogger.cpp +29 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.cpp +115 -0
- package/android/src/main/cpp/worklets/android/WorkletsModule.h +78 -0
- package/android/src/main/cpp/worklets/android/WorkletsOnLoad.cpp +13 -0
- package/android/src/main/java/com/swmansion/worklets/AndroidUIScheduler.java +60 -0
- package/android/src/main/java/com/swmansion/worklets/JSCallInvokerResolver.java +27 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThread.java +16 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsMessageQueueThreadBase.java +73 -0
- package/android/src/main/java/com/swmansion/worklets/WorkletsPackage.java +48 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameCallback.java +19 -0
- package/android/src/main/java/com/swmansion/worklets/runloop/AnimationFrameQueue.java +113 -0
- package/apple/worklets/apple/AnimationFrameQueue.h +15 -0
- package/apple/worklets/apple/AnimationFrameQueue.mm +135 -0
- package/apple/worklets/apple/AssertJavaScriptQueue.h +14 -0
- package/apple/worklets/apple/AssertTurboModuleManagerQueue.h +16 -0
- package/apple/worklets/apple/IOSUIScheduler.h +15 -0
- package/apple/worklets/apple/IOSUIScheduler.mm +29 -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/WorkletsMessageThread.h +16 -0
- package/apple/worklets/apple/WorkletsMessageThread.mm +31 -0
- package/apple/worklets/apple/WorkletsModule.h +28 -0
- package/apple/worklets/apple/WorkletsModule.mm +121 -0
- package/bundleMode/index.d.ts +3 -0
- package/bundleMode/index.js +59 -0
- package/compatibility.json +11 -0
- package/kepler-compatibility.json +5 -0
- package/kepler-transformed-package-info.json +3 -0
- package/lib/module/PlatformChecker/PlatformChecker.js +8 -0
- package/lib/module/PlatformChecker/PlatformChecker.js.map +1 -0
- package/lib/module/PlatformChecker/index.js +18 -0
- package/lib/module/PlatformChecker/index.js.map +1 -0
- package/lib/module/WorkletsError.js +29 -0
- package/lib/module/WorkletsError.js.map +1 -0
- package/lib/module/WorkletsModule/JSWorklets.js +111 -0
- package/lib/module/WorkletsModule/JSWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/NativeWorklets.js +126 -0
- package/lib/module/WorkletsModule/NativeWorklets.js.map +1 -0
- package/lib/module/WorkletsModule/index.js +4 -0
- package/lib/module/WorkletsModule/index.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js +7 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js +5 -0
- package/lib/module/WorkletsModule/workletsModuleInstance.web.js.map +1 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js +4 -0
- package/lib/module/WorkletsModule/workletsModuleProxy.js.map +1 -0
- package/lib/module/bundleUnpacker.js +47 -0
- package/lib/module/bundleUnpacker.js.map +1 -0
- package/lib/module/callGuard.js +30 -0
- package/lib/module/callGuard.js.map +1 -0
- package/lib/module/deprecated.js +20 -0
- package/lib/module/deprecated.js.map +1 -0
- package/lib/module/errors.js +69 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/featureFlags/index.js +48 -0
- package/lib/module/featureFlags/index.js.map +1 -0
- package/lib/module/featureFlags/staticFlags.json +4 -0
- package/lib/module/index.js +26 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/initializers.js +221 -0
- package/lib/module/initializers.js.map +1 -0
- package/lib/module/isSynchronizable.js +6 -0
- package/lib/module/isSynchronizable.js.map +1 -0
- package/lib/module/logger.js +15 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/privateGlobals.d.js +7 -0
- package/lib/module/privateGlobals.d.js.map +1 -0
- package/lib/module/publicGlobals.js +6 -0
- package/lib/module/publicGlobals.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 +52 -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 +39 -0
- package/lib/module/runtimeKind.js.map +1 -0
- package/lib/module/runtimes.js +100 -0
- package/lib/module/runtimes.js.map +1 -0
- package/lib/module/serializable.js +568 -0
- package/lib/module/serializable.js.map +1 -0
- package/lib/module/serializableMappingCache.js +37 -0
- package/lib/module/serializableMappingCache.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/NativeWorkletsModule.kepler.js +7 -0
- package/lib/module/specs/NativeWorkletsModule.kepler.js.map +1 -0
- package/lib/module/specs/index.js +10 -0
- package/lib/module/specs/index.js.map +1 -0
- package/lib/module/synchronizable.js +9 -0
- package/lib/module/synchronizable.js.map +1 -0
- package/lib/module/synchronizableUnpacker.js +42 -0
- package/lib/module/synchronizableUnpacker.js.map +1 -0
- package/lib/module/threads.js +347 -0
- package/lib/module/threads.js.map +1 -0
- package/lib/module/utils/checkCppVersion.js +30 -0
- package/lib/module/utils/checkCppVersion.js.map +1 -0
- package/lib/module/utils/jsVersion.js +9 -0
- package/lib/module/utils/jsVersion.js.map +1 -0
- package/lib/module/valueUnpacker.js +60 -0
- package/lib/module/valueUnpacker.js.map +1 -0
- package/lib/module/workletFunction.js +37 -0
- package/lib/module/workletFunction.js.map +1 -0
- package/lib/module/workletRuntimeEntry.js +32 -0
- package/lib/module/workletRuntimeEntry.js.map +1 -0
- package/lib/module/workletTypes.js +12 -0
- package/lib/module/workletTypes.js.map +1 -0
- package/lib/typescript/PlatformChecker/PlatformChecker.d.ts +5 -0
- package/lib/typescript/PlatformChecker/PlatformChecker.d.ts.map +1 -0
- package/lib/typescript/PlatformChecker/index.d.ts +10 -0
- package/lib/typescript/PlatformChecker/index.d.ts.map +1 -0
- package/lib/typescript/WorkletsError.d.ts +15 -0
- package/lib/typescript/WorkletsError.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts +3 -0
- package/lib/typescript/WorkletsModule/JSWorklets.d.ts.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/index.d.ts +3 -0
- package/lib/typescript/WorkletsModule/index.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts +2 -0
- package/lib/typescript/WorkletsModule/workletsModuleInstance.web.d.ts.map +1 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts +37 -0
- package/lib/typescript/WorkletsModule/workletsModuleProxy.d.ts.map +1 -0
- package/lib/typescript/bundleUnpacker.d.ts +7 -0
- package/lib/typescript/bundleUnpacker.d.ts.map +1 -0
- package/lib/typescript/callGuard.d.ts +4 -0
- package/lib/typescript/callGuard.d.ts.map +1 -0
- package/lib/typescript/deprecated.d.ts +20 -0
- package/lib/typescript/deprecated.d.ts.map +1 -0
- package/lib/typescript/errors.d.ts +16 -0
- package/lib/typescript/errors.d.ts.map +1 -0
- package/lib/typescript/featureFlags/index.d.ts +23 -0
- package/lib/typescript/featureFlags/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/initializers.d.ts +17 -0
- package/lib/typescript/initializers.d.ts.map +1 -0
- package/lib/typescript/isSynchronizable.d.ts +3 -0
- package/lib/typescript/isSynchronizable.d.ts.map +1 -0
- package/lib/typescript/logger.d.ts +5 -0
- package/lib/typescript/logger.d.ts.map +1 -0
- package/lib/typescript/publicGlobals.d.ts +31 -0
- package/lib/typescript/publicGlobals.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 +25 -0
- package/lib/typescript/runtimeKind.d.ts.map +1 -0
- package/lib/typescript/runtimes.d.ts +77 -0
- package/lib/typescript/runtimes.d.ts.map +1 -0
- package/lib/typescript/serializable.d.ts +20 -0
- package/lib/typescript/serializable.d.ts.map +1 -0
- package/lib/typescript/serializableMappingCache.d.ts +16 -0
- package/lib/typescript/serializableMappingCache.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts +7 -0
- package/lib/typescript/specs/NativeWorkletsModule.d.ts.map +1 -0
- package/lib/typescript/specs/NativeWorkletsModule.kepler.d.ts +7 -0
- package/lib/typescript/specs/NativeWorkletsModule.kepler.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/synchronizable.d.ts +15 -0
- package/lib/typescript/synchronizable.d.ts.map +1 -0
- package/lib/typescript/synchronizableUnpacker.d.ts +4 -0
- package/lib/typescript/synchronizableUnpacker.d.ts.map +1 -0
- package/lib/typescript/threads.d.ts +138 -0
- package/lib/typescript/threads.d.ts.map +1 -0
- package/lib/typescript/utils/checkCppVersion.d.ts +3 -0
- package/lib/typescript/utils/checkCppVersion.d.ts.map +1 -0
- package/lib/typescript/utils/jsVersion.d.ts +7 -0
- package/lib/typescript/utils/jsVersion.d.ts.map +1 -0
- package/lib/typescript/valueUnpacker.d.ts +6 -0
- package/lib/typescript/valueUnpacker.d.ts.map +1 -0
- package/lib/typescript/workletFunction.d.ts +27 -0
- package/lib/typescript/workletFunction.d.ts.map +1 -0
- package/lib/typescript/workletRuntimeEntry.d.ts +14 -0
- package/lib/typescript/workletRuntimeEntry.d.ts.map +1 -0
- package/lib/typescript/workletTypes.d.ts +61 -0
- package/lib/typescript/workletTypes.d.ts.map +1 -0
- package/package.json +153 -0
- package/plugin/index.js +1761 -0
- package/react-native.config.js +21 -0
- package/scripts/validate-react-native-version.js +43 -0
- package/scripts/worklets_utils.rb +94 -0
- package/src/PlatformChecker/PlatformChecker.ts +7 -0
- package/src/PlatformChecker/index.ts +30 -0
- package/src/WorkletsError.ts +36 -0
- package/src/WorkletsModule/JSWorklets.ts +200 -0
- package/src/WorkletsModule/NativeWorklets.ts +256 -0
- package/src/WorkletsModule/index.ts +7 -0
- package/src/WorkletsModule/workletsModuleInstance.ts +9 -0
- package/src/WorkletsModule/workletsModuleInstance.web.ts +5 -0
- package/src/WorkletsModule/workletsModuleProxy.ts +126 -0
- package/src/bundleUnpacker.ts +75 -0
- package/src/callGuard.ts +33 -0
- package/src/deprecated.ts +32 -0
- package/src/errors.ts +80 -0
- package/src/featureFlags/index.ts +72 -0
- package/src/featureFlags/staticFlags.json +4 -0
- package/src/index.ts +53 -0
- package/src/initializers.ts +262 -0
- package/src/isSynchronizable.ts +13 -0
- package/src/logger.ts +16 -0
- package/src/privateGlobals.d.ts +79 -0
- package/src/publicGlobals.ts +39 -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 +66 -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 +37 -0
- package/src/runtimes.ts +193 -0
- package/src/serializable.ts +801 -0
- package/src/serializableMappingCache.ts +42 -0
- package/src/specs/NativeWorkletsModule.kepler.ts +11 -0
- package/src/specs/NativeWorkletsModule.ts +9 -0
- package/src/specs/index.ts +13 -0
- package/src/synchronizable.ts +32 -0
- package/src/synchronizableUnpacker.ts +67 -0
- package/src/threads.ts +452 -0
- package/src/utils/checkCppVersion.ts +34 -0
- package/src/utils/jsVersion.ts +7 -0
- package/src/valueUnpacker.ts +90 -0
- package/src/workletFunction.ts +42 -0
- package/src/workletRuntimeEntry.ts +35 -0
- package/src/workletTypes.ts +81 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <condition_variable>
|
|
4
|
+
#include <mutex>
|
|
5
|
+
|
|
6
|
+
namespace worklets {
|
|
7
|
+
|
|
8
|
+
class SynchronizableAccess {
|
|
9
|
+
public:
|
|
10
|
+
/**
|
|
11
|
+
* Allows you to imperatively lock the synchronizable to perform a
|
|
12
|
+
* transaction.
|
|
13
|
+
*/
|
|
14
|
+
void lock();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Unlocks the synchronizable after an imperative lock when the transaction is
|
|
18
|
+
* complete.
|
|
19
|
+
*/
|
|
20
|
+
void unlock();
|
|
21
|
+
|
|
22
|
+
protected:
|
|
23
|
+
void getBlockingBefore();
|
|
24
|
+
void getBlockingAfter();
|
|
25
|
+
|
|
26
|
+
// TODO: Shared pointer members (unless they're atomic) can't be assigned
|
|
27
|
+
// in a non thread-safe manner, therefore `setDirty` has little sense now.
|
|
28
|
+
// void setDirtyBefore();
|
|
29
|
+
// void setDirtyAfter();
|
|
30
|
+
|
|
31
|
+
void setBlockingBefore();
|
|
32
|
+
void setBlockingAfter();
|
|
33
|
+
|
|
34
|
+
private:
|
|
35
|
+
int blockingReaders_{0};
|
|
36
|
+
// int dirtyWriters_{0};
|
|
37
|
+
bool blockingWriter_{false};
|
|
38
|
+
bool imperativelyLocked_{false};
|
|
39
|
+
pthread_t imperativeOwner_{};
|
|
40
|
+
std::mutex accessLock_;
|
|
41
|
+
std::recursive_mutex imperativeLock_;
|
|
42
|
+
std::condition_variable queue_;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
} // namespace worklets
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
On Android JS_RUNTIME_HERMES is set in CMakeList.txt,
|
|
5
|
+
but on iOS there is no simple way to defect if Hermes exists
|
|
6
|
+
so we have to check if headers are available.
|
|
7
|
+
*/
|
|
8
|
+
#if __APPLE__ && __has_include(<hermes/hermes.h>)
|
|
9
|
+
#define JS_RUNTIME_HERMES 1
|
|
10
|
+
#endif
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include <worklets/Tools/FeatureFlags.h>
|
|
2
|
+
|
|
3
|
+
namespace worklets {
|
|
4
|
+
|
|
5
|
+
std::unordered_map<std::string, bool> DynamicFeatureFlags::flags_;
|
|
6
|
+
|
|
7
|
+
bool DynamicFeatureFlags::getFlag(const std::string &name) {
|
|
8
|
+
return flags_.contains(name) && flags_[name];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
void DynamicFeatureFlags::setFlag(const std::string &name, bool value) {
|
|
12
|
+
flags_[name] = value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
} // namespace worklets
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <string>
|
|
3
|
+
#include <unordered_map>
|
|
4
|
+
|
|
5
|
+
namespace worklets {
|
|
6
|
+
|
|
7
|
+
class StaticFeatureFlags {
|
|
8
|
+
public:
|
|
9
|
+
#ifdef WORKLETS_FEATURE_FLAGS
|
|
10
|
+
|
|
11
|
+
// Convert the value under x into a string
|
|
12
|
+
#define XTOSTRING(x) #x
|
|
13
|
+
// Evaluate the flag value; without this step, it would stringify the flag name
|
|
14
|
+
// itself instead of the flag value
|
|
15
|
+
#define TOSTRING(x) XTOSTRING(x)
|
|
16
|
+
|
|
17
|
+
static constexpr bool getFlag(const std::string_view &name) {
|
|
18
|
+
std::string nameStr = name.data();
|
|
19
|
+
std::string featureFlags = TOSTRING(WORKLETS_FEATURE_FLAGS);
|
|
20
|
+
if (featureFlags.find("[" + nameStr + ":") == std::string::npos) {
|
|
21
|
+
throw std::logic_error("Unable to recognize flag: " + nameStr);
|
|
22
|
+
}
|
|
23
|
+
return featureFlags.find("[" + nameStr + ":true]") != std::string::npos;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#else
|
|
27
|
+
|
|
28
|
+
static constexpr bool getFlag(const std::string_view &) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
#endif
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
class DynamicFeatureFlags {
|
|
36
|
+
public:
|
|
37
|
+
static bool getFlag(const std::string &name);
|
|
38
|
+
static void setFlag(const std::string &name, bool value);
|
|
39
|
+
|
|
40
|
+
private:
|
|
41
|
+
static std::unordered_map<std::string, bool> flags_;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace worklets
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
#include <worklets/Tools/JSISerializer.h>
|
|
2
|
+
|
|
3
|
+
#include <cxxabi.h>
|
|
4
|
+
#include <iostream>
|
|
5
|
+
#include <sstream>
|
|
6
|
+
|
|
7
|
+
namespace worklets {
|
|
8
|
+
|
|
9
|
+
const std::vector<std::string> SUPPORTED_ERROR_TYPES = {
|
|
10
|
+
"Error",
|
|
11
|
+
"AggregateError",
|
|
12
|
+
"EvalError",
|
|
13
|
+
"RangeError",
|
|
14
|
+
"ReferenceError",
|
|
15
|
+
"SyntaxError",
|
|
16
|
+
"TypeError",
|
|
17
|
+
"URIError",
|
|
18
|
+
"InternalError"};
|
|
19
|
+
|
|
20
|
+
const std::vector<std::string> SUPPORTED_INDEXED_COLLECTION_TYPES = {
|
|
21
|
+
"Int8Array",
|
|
22
|
+
"Uint8Array",
|
|
23
|
+
"Uint8ClampedArray",
|
|
24
|
+
"Int16Array",
|
|
25
|
+
"Uint16Array",
|
|
26
|
+
"Int32Array",
|
|
27
|
+
"Uint32Array",
|
|
28
|
+
"BigInt64Array",
|
|
29
|
+
"BigUint64Array",
|
|
30
|
+
"Float32Array",
|
|
31
|
+
"Float64Array",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const std::vector<std::string> SUPPORTED_STRUCTURED_DATA_TYPES = {
|
|
35
|
+
"ArrayBuffer",
|
|
36
|
+
"SharedArrayBuffer",
|
|
37
|
+
"DataView",
|
|
38
|
+
"Atomics",
|
|
39
|
+
"JSON",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const std::vector<std::string> SUPPORTED_MANAGING_MEMORY_TYPES = {
|
|
43
|
+
"WeakRef",
|
|
44
|
+
"FinalizationRegistry",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const std::vector<std::string> SUPPORTED_ABSTRACTION_OBJECT_TYPES = {
|
|
48
|
+
"Iterator",
|
|
49
|
+
"AsyncIterator",
|
|
50
|
+
"Promise",
|
|
51
|
+
"GeneratorFunction",
|
|
52
|
+
"AsyncGeneratorFunction",
|
|
53
|
+
"Generator",
|
|
54
|
+
"AsyncGenerator",
|
|
55
|
+
"AsyncFunction",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const std::vector<std::string> SUPPORTED_REFLECTION_TYPES = {
|
|
59
|
+
"Reflect",
|
|
60
|
+
"Proxy",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
static inline std::string getObjectTypeName(
|
|
64
|
+
jsi::Runtime &rt,
|
|
65
|
+
const jsi::Object &object) {
|
|
66
|
+
return object.getPropertyAsObject(rt, "constructor")
|
|
67
|
+
.getProperty(rt, "name")
|
|
68
|
+
.toString(rt)
|
|
69
|
+
.utf8(rt);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static inline bool isInstanceOf(
|
|
73
|
+
jsi::Runtime &rt,
|
|
74
|
+
const jsi::Object &object,
|
|
75
|
+
const std::string &type) {
|
|
76
|
+
return getObjectTypeName(rt, object) == type;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static inline bool isInstanceOfAny(
|
|
80
|
+
jsi::Runtime &rt,
|
|
81
|
+
const jsi::Object &object,
|
|
82
|
+
const std::vector<std::string> &supportedTypes) {
|
|
83
|
+
auto instanceType = getObjectTypeName(rt, object);
|
|
84
|
+
|
|
85
|
+
return std::find(
|
|
86
|
+
supportedTypes.begin(), supportedTypes.end(), instanceType) !=
|
|
87
|
+
supportedTypes.end();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
JSISerializer::JSISerializer(jsi::Runtime &rt)
|
|
91
|
+
: rt_(rt),
|
|
92
|
+
visitedNodes_(rt_.global()
|
|
93
|
+
.getPropertyAsFunction(rt_, "Set")
|
|
94
|
+
.callAsConstructor(rt_)
|
|
95
|
+
.asObject(rt_)) {}
|
|
96
|
+
|
|
97
|
+
std::string JSISerializer::stringifyWithName(const jsi::Object &object) {
|
|
98
|
+
std::stringstream ss;
|
|
99
|
+
ss << '[' << getObjectTypeName(rt_, object) << ']';
|
|
100
|
+
|
|
101
|
+
return ss.str();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
std::string JSISerializer::stringifyArray(const jsi::Array &arr) {
|
|
105
|
+
std::stringstream ss;
|
|
106
|
+
ss << '[';
|
|
107
|
+
|
|
108
|
+
for (size_t i = 0, length = arr.size(rt_); i < length; i++) {
|
|
109
|
+
jsi::Value element = arr.getValueAtIndex(rt_, i);
|
|
110
|
+
ss << stringifyJSIValueRecursively(element);
|
|
111
|
+
if (i != length - 1) {
|
|
112
|
+
ss << ", ";
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
ss << ']';
|
|
117
|
+
|
|
118
|
+
return ss.str();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
std::string JSISerializer::stringifyFunction(const jsi::Function &func) {
|
|
122
|
+
std::stringstream ss;
|
|
123
|
+
auto kind = (func.isHostFunction(rt_) ? "jsi::HostFunction" : "Function");
|
|
124
|
+
auto name = func.getProperty(rt_, "name").toString(rt_).utf8(rt_);
|
|
125
|
+
name = name.empty() ? "anonymous" : name;
|
|
126
|
+
|
|
127
|
+
ss << '[' << kind << ' ' << name << ']';
|
|
128
|
+
return ss.str();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
std::string JSISerializer::stringifyHostObject(jsi::HostObject &hostObject) {
|
|
132
|
+
int status = -1;
|
|
133
|
+
char *hostObjClassName =
|
|
134
|
+
abi::__cxa_demangle(typeid(hostObject).name(), NULL, NULL, &status);
|
|
135
|
+
if (status != 0) {
|
|
136
|
+
return "[jsi::HostObject]";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
std::stringstream ss;
|
|
140
|
+
ss << "[jsi::HostObject(" << hostObjClassName << ")";
|
|
141
|
+
std::free(hostObjClassName);
|
|
142
|
+
|
|
143
|
+
auto props = hostObject.getPropertyNames(rt_);
|
|
144
|
+
auto propsCount = props.size();
|
|
145
|
+
|
|
146
|
+
if (propsCount > 0) {
|
|
147
|
+
ss << " {";
|
|
148
|
+
auto lastKey = props.back().utf8(rt_);
|
|
149
|
+
for (const auto &key : props) {
|
|
150
|
+
auto formattedKey = key.utf8(rt_);
|
|
151
|
+
auto value = hostObject.get(rt_, key);
|
|
152
|
+
ss << '"' << formattedKey << '"' << ": "
|
|
153
|
+
<< stringifyJSIValueRecursively(value);
|
|
154
|
+
if (formattedKey != lastKey) {
|
|
155
|
+
ss << ", ";
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
ss << '}';
|
|
159
|
+
}
|
|
160
|
+
ss << ']';
|
|
161
|
+
|
|
162
|
+
return ss.str();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
std::string JSISerializer::stringifyObject(const jsi::Object &object) {
|
|
166
|
+
std::stringstream ss;
|
|
167
|
+
ss << '{';
|
|
168
|
+
|
|
169
|
+
auto props = object.getPropertyNames(rt_);
|
|
170
|
+
|
|
171
|
+
for (size_t i = 0, propsCount = props.size(rt_); i < propsCount; i++) {
|
|
172
|
+
jsi::String propName = props.getValueAtIndex(rt_, i).toString(rt_);
|
|
173
|
+
ss << '"' << propName.utf8(rt_) << '"' << ": "
|
|
174
|
+
<< stringifyJSIValueRecursively(object.getProperty(rt_, propName));
|
|
175
|
+
if (i != propsCount - 1) {
|
|
176
|
+
ss << ", ";
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
ss << '}';
|
|
181
|
+
|
|
182
|
+
return ss.str();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
std::string JSISerializer::stringifyError(const jsi::Object &object) {
|
|
186
|
+
std::stringstream ss;
|
|
187
|
+
ss << '[' << object.getProperty(rt_, "name").toString(rt_).utf8(rt_) << ": "
|
|
188
|
+
<< object.getProperty(rt_, "message").toString(rt_).utf8(rt_) << ']';
|
|
189
|
+
return ss.str();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
std::string JSISerializer::stringifySet(const jsi::Object &object) {
|
|
193
|
+
std::stringstream ss;
|
|
194
|
+
jsi::Function arrayFrom = rt_.global()
|
|
195
|
+
.getPropertyAsObject(rt_, "Array")
|
|
196
|
+
.getPropertyAsFunction(rt_, "from");
|
|
197
|
+
jsi::Object result = arrayFrom.call(rt_, object).asObject(rt_);
|
|
198
|
+
|
|
199
|
+
if (!result.isArray(rt_)) {
|
|
200
|
+
return "[Set]";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
auto arr = result.asArray(rt_);
|
|
204
|
+
ss << "Set {";
|
|
205
|
+
|
|
206
|
+
for (size_t i = 0, length = arr.size(rt_); i < length; i++) {
|
|
207
|
+
ss << stringifyJSIValueRecursively(arr.getValueAtIndex(rt_, i));
|
|
208
|
+
if (i != length - 1) {
|
|
209
|
+
ss << ", ";
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
ss << '}';
|
|
214
|
+
|
|
215
|
+
return ss.str();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
std::string JSISerializer::stringifyMap(const jsi::Object &object) {
|
|
219
|
+
std::stringstream ss;
|
|
220
|
+
jsi::Function arrayFrom = rt_.global()
|
|
221
|
+
.getPropertyAsObject(rt_, "Array")
|
|
222
|
+
.getPropertyAsFunction(rt_, "from");
|
|
223
|
+
jsi::Object result = arrayFrom.call(rt_, object).asObject(rt_);
|
|
224
|
+
|
|
225
|
+
if (!result.isArray(rt_)) {
|
|
226
|
+
return "[Map]";
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
auto arr = result.asArray(rt_);
|
|
230
|
+
ss << "Map {";
|
|
231
|
+
|
|
232
|
+
for (size_t i = 0, length = arr.size(rt_); i < length; i++) {
|
|
233
|
+
auto pair = arr.getValueAtIndex(rt_, i).asObject(rt_).getArray(rt_);
|
|
234
|
+
auto key = pair.getValueAtIndex(rt_, 0);
|
|
235
|
+
auto value = pair.getValueAtIndex(rt_, 1);
|
|
236
|
+
ss << stringifyJSIValueRecursively(key) << ": "
|
|
237
|
+
<< stringifyJSIValueRecursively(value);
|
|
238
|
+
if (i != length - 1) {
|
|
239
|
+
ss << ", ";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
ss << '}';
|
|
244
|
+
|
|
245
|
+
return ss.str();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
std::string JSISerializer::stringifyRecursiveType(const jsi::Object &object) {
|
|
249
|
+
auto type = getObjectTypeName(rt_, object);
|
|
250
|
+
|
|
251
|
+
if (type == "Array") {
|
|
252
|
+
return "[...]";
|
|
253
|
+
}
|
|
254
|
+
if (type == "Object") {
|
|
255
|
+
return "{...}";
|
|
256
|
+
}
|
|
257
|
+
return "...";
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
std::string JSISerializer::stringifyWithToString(const jsi::Object &object) {
|
|
261
|
+
return object.getPropertyAsFunction(rt_, "toString")
|
|
262
|
+
.callWithThis(rt_, object)
|
|
263
|
+
.toString(rt_)
|
|
264
|
+
.utf8(rt_);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
std::string JSISerializer::stringifyJSIValueRecursively(
|
|
268
|
+
const jsi::Value &value,
|
|
269
|
+
bool isTopLevel) {
|
|
270
|
+
if (value.isBool() || value.isNumber()) {
|
|
271
|
+
return value.toString(rt_).utf8(rt_);
|
|
272
|
+
}
|
|
273
|
+
if (value.isString()) {
|
|
274
|
+
return isTopLevel ? value.getString(rt_).utf8(rt_)
|
|
275
|
+
: '"' + value.getString(rt_).utf8(rt_) + '"';
|
|
276
|
+
}
|
|
277
|
+
if (value.isSymbol()) {
|
|
278
|
+
return value.getSymbol(rt_).toString(rt_);
|
|
279
|
+
}
|
|
280
|
+
if (value.isBigInt()) {
|
|
281
|
+
return value.getBigInt(rt_).toString(rt_).utf8(rt_) + 'n';
|
|
282
|
+
}
|
|
283
|
+
if (value.isUndefined()) {
|
|
284
|
+
return "undefined";
|
|
285
|
+
}
|
|
286
|
+
if (value.isNull()) {
|
|
287
|
+
return "null";
|
|
288
|
+
}
|
|
289
|
+
if (value.isObject()) {
|
|
290
|
+
jsi::Object object = value.asObject(rt_);
|
|
291
|
+
|
|
292
|
+
if (hasBeenVisited(object)) {
|
|
293
|
+
return stringifyRecursiveType(object);
|
|
294
|
+
}
|
|
295
|
+
markAsVisited(object);
|
|
296
|
+
|
|
297
|
+
if (object.isArray(rt_)) {
|
|
298
|
+
return stringifyArray(object.getArray(rt_));
|
|
299
|
+
}
|
|
300
|
+
if (object.isFunction(rt_)) {
|
|
301
|
+
return stringifyFunction(object.getFunction(rt_));
|
|
302
|
+
}
|
|
303
|
+
if (object.isHostObject(rt_)) {
|
|
304
|
+
return stringifyHostObject(*object.getHostObject(rt_));
|
|
305
|
+
}
|
|
306
|
+
if (isInstanceOfAny(rt_, object, SUPPORTED_ERROR_TYPES)) {
|
|
307
|
+
return stringifyError(object);
|
|
308
|
+
}
|
|
309
|
+
if (isInstanceOfAny(rt_, object, SUPPORTED_INDEXED_COLLECTION_TYPES) ||
|
|
310
|
+
isInstanceOfAny(rt_, object, SUPPORTED_STRUCTURED_DATA_TYPES) ||
|
|
311
|
+
isInstanceOfAny(rt_, object, SUPPORTED_MANAGING_MEMORY_TYPES) ||
|
|
312
|
+
isInstanceOfAny(rt_, object, SUPPORTED_ABSTRACTION_OBJECT_TYPES) ||
|
|
313
|
+
isInstanceOfAny(rt_, object, SUPPORTED_REFLECTION_TYPES) ||
|
|
314
|
+
isInstanceOf(rt_, object, "Intl") ||
|
|
315
|
+
isInstanceOf(rt_, object, "WeakMap") ||
|
|
316
|
+
isInstanceOf(rt_, object, "WeakSet")) {
|
|
317
|
+
// TODO: Consider extending this log info
|
|
318
|
+
return stringifyWithName(object);
|
|
319
|
+
}
|
|
320
|
+
if (isInstanceOf(rt_, object, "Date") ||
|
|
321
|
+
isInstanceOf(rt_, object, "RegExp")) {
|
|
322
|
+
return stringifyWithToString(object);
|
|
323
|
+
}
|
|
324
|
+
if (isInstanceOf(rt_, object, "Map")) {
|
|
325
|
+
return stringifyMap(object);
|
|
326
|
+
}
|
|
327
|
+
if (isInstanceOf(rt_, object, "Set")) {
|
|
328
|
+
return stringifySet(object);
|
|
329
|
+
}
|
|
330
|
+
return stringifyObject(object);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
throw std::runtime_error("[Worklets] Unsupported value type.");
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
std::string stringifyJSIValue(jsi::Runtime &rt, const jsi::Value &value) {
|
|
337
|
+
JSISerializer serializer(rt);
|
|
338
|
+
|
|
339
|
+
return serializer.stringifyJSIValueRecursively(value, true);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
} // namespace worklets
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// amznmod_react - export symbols for reanimated
|
|
4
|
+
#include <keplerui-083/keplerscript-export.h>
|
|
5
|
+
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
namespace worklets {
|
|
13
|
+
|
|
14
|
+
class JSISerializer {
|
|
15
|
+
public:
|
|
16
|
+
explicit JSISerializer(jsi::Runtime &rt);
|
|
17
|
+
std::string stringifyJSIValueRecursively(
|
|
18
|
+
const jsi::Value &value,
|
|
19
|
+
bool isTopLevel = false);
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
std::string stringifyArray(const jsi::Array &arr);
|
|
23
|
+
std::string stringifyFunction(const jsi::Function &func);
|
|
24
|
+
std::string stringifyHostObject(jsi::HostObject &hostObject);
|
|
25
|
+
std::string stringifyObject(const jsi::Object &object);
|
|
26
|
+
std::string stringifyError(const jsi::Object &object);
|
|
27
|
+
std::string stringifySet(const jsi::Object &object);
|
|
28
|
+
std::string stringifyMap(const jsi::Object &object);
|
|
29
|
+
std::string stringifyWithName(const jsi::Object &object);
|
|
30
|
+
std::string stringifyWithToString(const jsi::Object &object);
|
|
31
|
+
std::string stringifyRecursiveType(const jsi::Object &object);
|
|
32
|
+
|
|
33
|
+
bool hasBeenVisited(const jsi::Object &object) {
|
|
34
|
+
return visitedNodes_.getPropertyAsFunction(rt_, "has")
|
|
35
|
+
.callWithThis(rt_, visitedNodes_, object)
|
|
36
|
+
.getBool();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void markAsVisited(const jsi::Object &object) {
|
|
40
|
+
visitedNodes_.getPropertyAsFunction(rt_, "add")
|
|
41
|
+
.callWithThis(rt_, visitedNodes_, object);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
jsi::Runtime &rt_;
|
|
45
|
+
jsi::Object visitedNodes_;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// amznmod_react - export symbols for reanimated
|
|
49
|
+
std::string KEPLERSCRIPT_EXPORT stringifyJSIValue(jsi::Runtime &rt, const jsi::Value &value);
|
|
50
|
+
|
|
51
|
+
} // namespace worklets
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#include <worklets/Tools/JSLogger.h>
|
|
2
|
+
|
|
3
|
+
#include <memory>
|
|
4
|
+
#include <utility>
|
|
5
|
+
|
|
6
|
+
namespace worklets {
|
|
7
|
+
|
|
8
|
+
void JSLogger::warnOnJS(const std::string &warning) const {
|
|
9
|
+
#ifndef NDEBUG
|
|
10
|
+
jsScheduler_->scheduleOnJS([warning](jsi::Runtime &rnRuntime) {
|
|
11
|
+
auto console = rnRuntime.global().getPropertyAsObject(rnRuntime, "console");
|
|
12
|
+
auto warn = console.getPropertyAsFunction(rnRuntime, "warn");
|
|
13
|
+
warn.call(rnRuntime, jsi::String::createFromUtf8(rnRuntime, warning));
|
|
14
|
+
});
|
|
15
|
+
#endif // NDEBUG
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
void JSLogger::reportFatalErrorOnJS(
|
|
19
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
20
|
+
JSErrorData &&jsErrorData,
|
|
21
|
+
bool force) {
|
|
22
|
+
auto job = [jsErrorData = std::move(jsErrorData),
|
|
23
|
+
force](jsi::Runtime &rnRuntime) {
|
|
24
|
+
reportFatalErrorOnJS(rnRuntime, jsErrorData, force);
|
|
25
|
+
};
|
|
26
|
+
if (jsScheduler->canInvokeSyncOnJS()) {
|
|
27
|
+
jsScheduler->invokeSyncOnJS(job);
|
|
28
|
+
} else {
|
|
29
|
+
jsScheduler->scheduleOnJS(job);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void JSLogger::reportFatalErrorOnJS(
|
|
34
|
+
jsi::Runtime &rnRuntime,
|
|
35
|
+
const JSErrorData &jsErrorData,
|
|
36
|
+
bool force) {
|
|
37
|
+
const auto &global = rnRuntime.global();
|
|
38
|
+
const auto errorInstance = rnRuntime.global()
|
|
39
|
+
.getPropertyAsFunction(rnRuntime, "Error")
|
|
40
|
+
.callAsConstructor(rnRuntime)
|
|
41
|
+
.asObject(rnRuntime);
|
|
42
|
+
|
|
43
|
+
errorInstance.setProperty(
|
|
44
|
+
rnRuntime,
|
|
45
|
+
"message",
|
|
46
|
+
jsi::String::createFromUtf8(rnRuntime, jsErrorData.message));
|
|
47
|
+
|
|
48
|
+
errorInstance.setProperty(
|
|
49
|
+
rnRuntime,
|
|
50
|
+
"stack",
|
|
51
|
+
jsi::String::createFromUtf8(rnRuntime, jsErrorData.stack));
|
|
52
|
+
|
|
53
|
+
errorInstance.setProperty(
|
|
54
|
+
rnRuntime,
|
|
55
|
+
"name",
|
|
56
|
+
jsi::String::createFromUtf8(rnRuntime, jsErrorData.name));
|
|
57
|
+
|
|
58
|
+
errorInstance.setProperty(
|
|
59
|
+
rnRuntime,
|
|
60
|
+
"jsEngine",
|
|
61
|
+
jsi::String::createFromUtf8(rnRuntime, jsErrorData.jsEngine));
|
|
62
|
+
|
|
63
|
+
const auto &reportFatalErrorFunction =
|
|
64
|
+
global.getPropertyAsFunction(rnRuntime, "__reportFatalRemoteError");
|
|
65
|
+
reportFatalErrorFunction.call(rnRuntime, errorInstance, force);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
} // namespace worklets
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace worklets {
|
|
9
|
+
|
|
10
|
+
struct JSErrorData {
|
|
11
|
+
std::string message;
|
|
12
|
+
std::string stack;
|
|
13
|
+
std::string name;
|
|
14
|
+
std::string jsEngine;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class JSLogger {
|
|
18
|
+
public:
|
|
19
|
+
explicit JSLogger(const std::shared_ptr<JSScheduler> &jsScheduler)
|
|
20
|
+
: jsScheduler_(jsScheduler) {}
|
|
21
|
+
void warnOnJS(const std::string &warning) const;
|
|
22
|
+
|
|
23
|
+
static void reportFatalErrorOnJS(
|
|
24
|
+
const std::shared_ptr<JSScheduler> &jsScheduler,
|
|
25
|
+
JSErrorData &&jsErrorData,
|
|
26
|
+
bool force = false);
|
|
27
|
+
|
|
28
|
+
private:
|
|
29
|
+
static void reportFatalErrorOnJS(
|
|
30
|
+
jsi::Runtime &rnRuntime,
|
|
31
|
+
const JSErrorData &jsErrorData,
|
|
32
|
+
bool force = false);
|
|
33
|
+
|
|
34
|
+
const std::shared_ptr<JSScheduler> jsScheduler_;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace worklets
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#include <react/debug/react_native_assert.h>
|
|
2
|
+
#include <worklets/Tools/JSScheduler.h>
|
|
3
|
+
|
|
4
|
+
#include <utility>
|
|
5
|
+
|
|
6
|
+
namespace worklets {
|
|
7
|
+
|
|
8
|
+
void JSScheduler::scheduleOnJS(Job job) {
|
|
9
|
+
jsCallInvoker_->invokeAsync(
|
|
10
|
+
[job = std::move(job), &rt = rnRuntime_] { job(rt); });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
bool JSScheduler::canInvokeSyncOnJS() {
|
|
14
|
+
return isJavaScriptQueue_();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void JSScheduler::invokeSyncOnJS(Job job) {
|
|
18
|
+
react_native_assert(
|
|
19
|
+
canInvokeSyncOnJS() &&
|
|
20
|
+
"JSScheduler::invokeSyncOnJS should only be called from the JS thread");
|
|
21
|
+
job(rnRuntime_);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
} // namespace worklets
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <keplerui-083/keplerscript-export.h>
|
|
4
|
+
|
|
5
|
+
#include <ReactCommon/CallInvoker.h>
|
|
6
|
+
#include <jsi/jsi.h>
|
|
7
|
+
|
|
8
|
+
#include <memory>
|
|
9
|
+
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
using namespace react;
|
|
12
|
+
|
|
13
|
+
namespace worklets {
|
|
14
|
+
|
|
15
|
+
class KEPLERSCRIPT_EXPORT JSScheduler {
|
|
16
|
+
using Job = std::function<void(jsi::Runtime &rt)>;
|
|
17
|
+
|
|
18
|
+
public:
|
|
19
|
+
explicit JSScheduler(
|
|
20
|
+
jsi::Runtime &rnRuntime,
|
|
21
|
+
const std::shared_ptr<CallInvoker> &jsCallInvoker,
|
|
22
|
+
std::function<bool()> &&isJavaScriptQueue)
|
|
23
|
+
: rnRuntime_(rnRuntime),
|
|
24
|
+
jsCallInvoker_(jsCallInvoker),
|
|
25
|
+
isJavaScriptQueue_(isJavaScriptQueue) {}
|
|
26
|
+
|
|
27
|
+
void scheduleOnJS(std::function<void(jsi::Runtime &rt)> job);
|
|
28
|
+
|
|
29
|
+
void invokeSyncOnJS(std::function<void(jsi::Runtime &rt)> job);
|
|
30
|
+
|
|
31
|
+
bool canInvokeSyncOnJS();
|
|
32
|
+
|
|
33
|
+
protected:
|
|
34
|
+
jsi::Runtime &rnRuntime_;
|
|
35
|
+
const std::shared_ptr<CallInvoker> jsCallInvoker_;
|
|
36
|
+
const std::function<bool()> isJavaScriptQueue_;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
} // namespace worklets
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
namespace worklets {
|
|
6
|
+
|
|
7
|
+
class PlatformLogger {
|
|
8
|
+
public:
|
|
9
|
+
static void log(const char *str);
|
|
10
|
+
static void log(const std::string &str);
|
|
11
|
+
static void log(const double d);
|
|
12
|
+
static void log(const int i);
|
|
13
|
+
static void log(const bool b);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
} // namespace worklets
|