react-native-tvos 0.85.3-1 → 0.86.0-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.
Files changed (667) hide show
  1. package/Libraries/Animated/AnimatedImplementation.js +6 -6
  2. package/Libraries/Animated/NativeAnimatedAllowlist.js +21 -0
  3. package/Libraries/Animated/components/AnimatedImage.js +3 -3
  4. package/Libraries/Animated/components/AnimatedText.js +3 -3
  5. package/Libraries/Animated/createAnimatedComponent.js +7 -7
  6. package/Libraries/Animated/nodes/AnimatedAddition.js +1 -1
  7. package/Libraries/Animated/nodes/AnimatedColor.js +7 -7
  8. package/Libraries/Animated/nodes/AnimatedDiffClamp.js +1 -1
  9. package/Libraries/Animated/nodes/AnimatedDivision.js +1 -1
  10. package/Libraries/Animated/nodes/AnimatedInterpolation.js +22 -24
  11. package/Libraries/Animated/nodes/AnimatedModulo.js +1 -1
  12. package/Libraries/Animated/nodes/AnimatedMultiplication.js +1 -1
  13. package/Libraries/Animated/nodes/AnimatedStyle.js +2 -2
  14. package/Libraries/Animated/nodes/AnimatedSubtraction.js +1 -1
  15. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedValue.js +2 -2
  17. package/Libraries/AppDelegate/RCTDefaultReactNativeFactoryDelegate.mm +4 -0
  18. package/Libraries/AppDelegate/RCTRootViewFactory.h +5 -5
  19. package/Libraries/AppDelegate/RCTRootViewFactory.mm +2 -2
  20. package/Libraries/AppState/AppState.js +1 -1
  21. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  22. package/Libraries/Blob/RCTBlobCollector.h +1 -1
  23. package/Libraries/Blob/RCTBlobCollector.mm +14 -26
  24. package/Libraries/Blob/RCTBlobManager.mm +11 -3
  25. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +29 -23
  26. package/Libraries/Components/Keyboard/Keyboard.js +4 -2
  27. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -1
  28. package/Libraries/Components/LayoutConformance/LayoutConformance.js +1 -27
  29. package/Libraries/Components/Pressable/Pressable.d.ts +1 -0
  30. package/Libraries/Components/Pressable/Pressable.js +2 -2
  31. package/Libraries/Components/Pressable/useAndroidRippleForView.js +7 -8
  32. package/Libraries/Components/ScrollView/ScrollView.js +3 -3
  33. package/Libraries/Components/ScrollView/ScrollViewCommands.js +2 -2
  34. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +2 -2
  35. package/Libraries/Components/Switch/Switch.js +1 -1
  36. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +25 -1
  37. package/Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js +1 -1
  38. package/Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js +2 -2
  39. package/Libraries/Components/TextInput/TextInput.d.ts +24 -0
  40. package/Libraries/Components/TextInput/TextInput.flow.js +24 -0
  41. package/Libraries/Components/TextInput/TextInput.js +5 -5
  42. package/Libraries/Components/ToastAndroid/ToastAndroid.android.js +5 -5
  43. package/Libraries/Components/ToastAndroid/ToastAndroidFallback.js +5 -5
  44. package/Libraries/Components/Touchable/PooledClass.js +4 -4
  45. package/Libraries/Components/Touchable/Touchable.js +1 -1
  46. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -10
  47. package/Libraries/Components/View/ReactNativeStyleAttributes.js +10 -2
  48. package/Libraries/Components/View/View.js +100 -95
  49. package/Libraries/Components/View/ViewPropTypes.js +3 -1
  50. package/Libraries/Core/Devtools/loadBundleFromServer.js +8 -0
  51. package/Libraries/Core/ExceptionsManager.js +2 -8
  52. package/Libraries/Core/InitializeCore.js +0 -13
  53. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  54. package/Libraries/Core/ReactNativeVersion.js +3 -3
  55. package/Libraries/Core/ReactNativeVersionCheck.js +1 -1
  56. package/Libraries/Core/Timers/JSTimers.js +2 -2
  57. package/Libraries/Core/Timers/immediateShim.js +1 -1
  58. package/Libraries/Core/setUpBatchedBridge.js +1 -1
  59. package/Libraries/Core/setUpSegmentFetcher.js +1 -1
  60. package/Libraries/Debugging/DebuggingOverlayRegistry.js +1 -1
  61. package/Libraries/EventEmitter/NativeEventEmitter.js +9 -5
  62. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +2 -2
  63. package/Libraries/Image/Image.android.js +15 -35
  64. package/Libraries/Image/RCTImageLoader.mm +4 -2
  65. package/Libraries/Image/RelativeImageStub.js +2 -2
  66. package/Libraries/LayoutAnimation/LayoutAnimation.js +12 -12
  67. package/Libraries/Linking/Linking.js +1 -1
  68. package/Libraries/Lists/FlatList.js +1 -1
  69. package/Libraries/LogBox/LogBox.js +2 -2
  70. package/Libraries/LogBox/LogBoxInspectorContainer.js +24 -2
  71. package/Libraries/LogBox/LogBoxNotificationContainer.js +27 -4
  72. package/Libraries/LogBox/UI/LogBoxButton.js +47 -33
  73. package/Libraries/LogBox/UI/LogBoxInspector.js +61 -1
  74. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +6 -0
  75. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +3 -1
  76. package/Libraries/LogBox/UI/LogBoxNotification.js +2 -0
  77. package/Libraries/Modal/Modal.js +12 -7
  78. package/Libraries/NativeAnimation/Nodes/RCTInterpolationAnimatedNode.mm +0 -2
  79. package/Libraries/NativeComponent/BaseViewConfig.android.js +15 -0
  80. package/Libraries/NativeComponent/BaseViewConfig.ios.js +17 -0
  81. package/Libraries/NativeComponent/NativeComponentRegistry.js +2 -2
  82. package/Libraries/NativeComponent/ViewConfigIgnore.js +4 -2
  83. package/Libraries/Network/RCTNetworking.android.js +1 -1
  84. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  85. package/Libraries/Network/RCTNetworking.js.flow +1 -1
  86. package/Libraries/Network/RCTNetworking.mm +1 -2
  87. package/Libraries/Network/XMLHttpRequest.js +29 -12
  88. package/Libraries/Pressability/Pressability.js +2 -2
  89. package/Libraries/ReactNative/AppContainer-dev.js +2 -3
  90. package/Libraries/ReactNative/AppContainer-prod.js +1 -2
  91. package/Libraries/ReactNative/AppContainer.js +0 -1
  92. package/Libraries/ReactNative/AppRegistry.d.ts +1 -1
  93. package/Libraries/ReactNative/AppRegistry.flow.js +1 -2
  94. package/Libraries/ReactNative/AppRegistryImpl.js +16 -16
  95. package/Libraries/ReactNative/DeprecatedPerformanceLoggerStub.js +83 -0
  96. package/Libraries/ReactNative/FabricUIManager.js +6 -0
  97. package/Libraries/{Utilities → ReactNative}/IPerformanceLogger.d.ts +8 -5
  98. package/Libraries/{Utilities/IPerformanceLogger.js → ReactNative/IPerformanceLogger.flow.js} +12 -9
  99. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +14 -14
  100. package/Libraries/ReactNative/RendererImplementation.js +26 -143
  101. package/Libraries/ReactNative/RendererProxy.js +4 -15
  102. package/Libraries/ReactNative/renderApplication.js +33 -59
  103. package/Libraries/ReactNative/requireNativeComponent.js +3 -3
  104. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +5 -0
  105. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -32
  106. package/Libraries/Settings/Settings.ios.js +1 -1
  107. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  108. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +3 -3
  109. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  110. package/Libraries/StyleSheet/StyleSheet.js.flow +2 -2
  111. package/Libraries/StyleSheet/StyleSheetExports.js +1 -1
  112. package/Libraries/StyleSheet/StyleSheetExports.js.flow +1 -1
  113. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +6 -8
  114. package/Libraries/StyleSheet/StyleSheetTypes.js +11 -11
  115. package/Libraries/StyleSheet/flattenStyle.js +1 -1
  116. package/Libraries/StyleSheet/private/_TransformStyle.js +1 -1
  117. package/Libraries/StyleSheet/processBackgroundImage.js +19 -9
  118. package/Libraries/StyleSheet/processBackgroundSize.js +7 -12
  119. package/Libraries/StyleSheet/processBoxShadow.js +9 -47
  120. package/Libraries/StyleSheet/processFilter.js +16 -8
  121. package/Libraries/StyleSheet/processTransformOrigin.js +10 -3
  122. package/Libraries/Text/Text.js +4 -4
  123. package/Libraries/Text/TextInput/RCTBackedTextInputDelegateAdapter.mm +16 -2
  124. package/Libraries/Text/TextNativeComponent.js +4 -4
  125. package/Libraries/TurboModule/RCTExport.js +1 -1
  126. package/Libraries/TurboModule/TurboModuleRegistry.js +3 -3
  127. package/Libraries/Types/CodegenTypes.js +7 -4
  128. package/Libraries/Types/ReactDevToolsTypes.js +1 -1
  129. package/Libraries/Utilities/BackHandler.android.js +11 -3
  130. package/Libraries/Utilities/BackHandler.d.ts +11 -1
  131. package/Libraries/Utilities/BackHandler.ios.js +3 -1
  132. package/Libraries/Utilities/BackHandler.js.flow +6 -1
  133. package/Libraries/Utilities/HardwareBackPressEvent.js +22 -0
  134. package/Libraries/Utilities/ReactNativeTestTools.js +4 -4
  135. package/Libraries/Utilities/binaryToBase64.js +1 -1
  136. package/Libraries/Utilities/codegenNativeCommands.js +2 -2
  137. package/Libraries/Utilities/codegenNativeComponent.js +4 -4
  138. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -2
  139. package/Libraries/Utilities/stringifySafe.js +1 -1
  140. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  141. package/Libraries/vendor/core/ErrorUtils.js +4 -4
  142. package/Libraries/vendor/emitter/EventEmitter.js +27 -13
  143. package/React/Base/RCTBundleURLProvider.h +19 -1
  144. package/React/Base/RCTBundleURLProvider.mm +82 -0
  145. package/React/Base/RCTDefines.h +1 -1
  146. package/React/Base/RCTMultipartDataTask.h +1 -1
  147. package/React/Base/RCTMultipartDataTask.m +0 -3
  148. package/React/Base/RCTRootView.h +4 -0
  149. package/React/Base/RCTRootViewDelegate.h +5 -2
  150. package/React/Base/RCTVersion.m +3 -3
  151. package/React/Base/Surface/RCTSurface.h +3 -0
  152. package/React/Base/Surface/RCTSurfaceDelegate.h +7 -3
  153. package/React/Base/Surface/RCTSurfaceRootView.mm +1 -1
  154. package/React/Base/Surface/RCTSurfaceView.mm +2 -1
  155. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +2 -0
  156. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.h +0 -3
  157. package/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingView.mm +3 -1
  158. package/React/CoreModules/RCTDevMenuConfigurationDecorator.h +2 -2
  159. package/React/CoreModules/RCTRedBox2AnsiParser.mm +1 -1
  160. package/React/CoreModules/RCTWebSocketModule.mm +45 -6
  161. package/React/CxxLogUtils/RCTDefaultCxxLogFunction.mm +0 -1
  162. package/React/DevSupport/RCTInspectorDevServerHelper.mm +4 -0
  163. package/React/DevSupport/RCTPackagerConnection.mm +13 -11
  164. package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +108 -43
  165. package/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h +1 -0
  166. package/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm +1 -0
  167. package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.h +1 -1
  168. package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +2 -2
  169. package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +70 -8
  170. package/React/Fabric/RCTConversions.h +14 -0
  171. package/React/Fabric/RCTScheduler.mm +18 -0
  172. package/React/Fabric/RCTSurfacePointerHandler.mm +8 -2
  173. package/React/Fabric/RCTSurfaceTouchHandler.mm +1 -0
  174. package/React/Fabric/Surface/RCTFabricSurface.mm +3 -0
  175. package/React/I18n/strings/pt.lproj/fbt_language_pack.bin +0 -0
  176. package/React/Modules/RCTUIManager.mm +1 -1
  177. package/React/Profiler/RCTProfile.h +5 -0
  178. package/React/Profiler/RCTProfile.m +2 -1
  179. package/React/Profiler/RCTProfileTrampoline-arm.S +1 -1
  180. package/React/Profiler/RCTProfileTrampoline-arm64.S +1 -1
  181. package/React/Profiler/RCTProfileTrampoline-i386.S +1 -1
  182. package/React/Profiler/RCTProfileTrampoline-x86_64.S +1 -1
  183. package/React/Tests/Mounting/RCTViewComponentViewTests.mm +186 -0
  184. package/React/Tests/Text/RCTAttributedTextUtilsTest.mm +5 -5
  185. package/React/Views/RCTLayout.m +4 -3
  186. package/React/Views/ScrollView/RCTScrollView.h +6 -2
  187. package/ReactAndroid/api/ReactAndroid.api +37 -27
  188. package/ReactAndroid/build.gradle.kts +28 -21
  189. package/ReactAndroid/gradle.properties +1 -1
  190. package/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/HermesSamplingProfiler.kt +2 -0
  191. package/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +1 -3
  192. package/ReactAndroid/src/main/java/com/facebook/react/ReactAndroidHWInputDeviceHelper.kt +2 -0
  193. package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +40 -110
  194. package/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +32 -87
  195. package/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.kt +1 -0
  196. package/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.kt +9 -99
  197. package/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedNodesManager.kt +7 -28
  198. package/ReactAndroid/src/main/java/com/facebook/react/animated/PropsAnimatedNode.kt +2 -19
  199. package/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.kt +15 -23
  200. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +36 -0
  201. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactNativeJNISoLoader.kt +2 -0
  202. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactNativeJniCommonSoLoader.kt +2 -0
  203. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactSoftExceptionLogger.kt +4 -0
  204. package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultSoLoader.kt +2 -0
  205. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/FpsView.kt +2 -2
  206. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/InspectorFlags.kt +2 -0
  207. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/LogBoxDialogSurfaceDelegate.kt +15 -2
  208. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/RedBoxDialogSurfaceDelegate.kt +1 -0
  209. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/DevSupportHttpClient.kt +9 -34
  210. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/FrameTimingsObserver.kt +9 -10
  211. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/InspectorNetworkRequestListener.kt +2 -0
  212. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/perfmonitor/PerfMonitorOverlayView.kt +10 -10
  213. package/ReactAndroid/src/main/java/com/facebook/react/fabric/AnimationBackendChoreographer.kt +15 -13
  214. package/ReactAndroid/src/main/java/com/facebook/react/fabric/DevToolsReactPerfLogger.kt +4 -1
  215. package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +139 -43
  216. package/ReactAndroid/src/main/java/com/facebook/react/fabric/ViewTransitionSnapshotManager.kt +223 -0
  217. package/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventEmitterWrapper.kt +25 -8
  218. package/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.kt +34 -1
  219. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.kt +104 -65
  220. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt +9 -1
  221. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.kt +172 -36
  222. package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/PreAllocateViewMountItem.kt +1 -1
  223. package/ReactAndroid/src/main/java/com/facebook/react/interfaces/ExtraWindowEventListener.kt +29 -0
  224. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +41 -29
  225. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +71 -51
  226. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +15 -11
  227. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +16 -12
  228. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +79 -57
  229. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android.kt +3 -3
  230. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsOverrides_RNOSS_Stable_Android.kt +1 -4
  231. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +15 -11
  232. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeNewArchitectureFeatureFlagsDefaults.kt +5 -9
  233. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/rewrite_feature_flag_defaults.py +76 -0
  234. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/tests/test_rewrite_feature_flag_defaults.py +63 -0
  235. package/ReactAndroid/src/main/java/com/facebook/react/internal/tracing/PerformanceTracer.kt +1 -1
  236. package/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.kt +3 -0
  237. package/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobModule.kt +10 -5
  238. package/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobProvider.kt +1 -2
  239. package/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.kt +3 -0
  240. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.kt +2 -1
  241. package/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactChoreographer.kt +21 -20
  242. package/ReactAndroid/src/main/java/com/facebook/react/modules/deviceinfo/DeviceInfoModule.kt +63 -3
  243. package/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.kt +59 -62
  244. package/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt +8 -0
  245. package/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt +45 -36
  246. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +3 -3
  247. package/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.kt +5 -2
  248. package/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.kt +4 -0
  249. package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.kt +18 -5
  250. package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImplDevHelper.kt +8 -1
  251. package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactSurfaceView.kt +21 -19
  252. package/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.kt +4 -0
  253. package/ReactAndroid/src/main/java/com/facebook/react/soloader/OpenSourceMergedSoMapping.kt +4 -0
  254. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BackgroundStyleApplicator.kt +77 -72
  255. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +7 -16
  256. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BlendModeHelper.kt +3 -2
  257. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.kt +3 -0
  258. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/FilterHelper.kt +3 -1
  259. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +25 -0
  260. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactAccessibilityDelegate.kt +2 -2
  261. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactRootViewTagGenerator.kt +3 -2
  262. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/RootViewUtil.kt +17 -7
  263. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ThemedReactContext.kt +18 -0
  264. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.kt +20 -12
  265. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/TransformHelper.kt +18 -24
  266. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIConstantsProviderBinding.kt +2 -0
  267. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +4 -0
  268. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerHelper.kt +11 -71
  269. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +10 -17
  270. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.kt +29 -30
  271. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/BackgroundImageDrawable.kt +5 -3
  272. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/drawable/InsetBoxShadowDrawable.kt +12 -13
  273. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.kt +1 -0
  274. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/PointerEvent.kt +1 -0
  275. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.kt +30 -0
  276. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/SynchronousEventReceiver.kt +28 -0
  277. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.kt +9 -9
  278. package/ReactAndroid/src/main/java/com/facebook/react/util/AndroidVersion.kt +27 -3
  279. package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +4 -0
  280. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/MaintainVisibleScrollPositionHelper.kt +1 -14
  281. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerViewManager.kt +1 -22
  282. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +18 -20
  283. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactNestedScrollView.java +20 -21
  284. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +19 -20
  285. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.kt +14 -5
  286. package/ReactAndroid/src/main/java/com/facebook/react/views/text/FontMetricsUtil.kt +2 -3
  287. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +5 -162
  288. package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.kt +1 -1
  289. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.kt +71 -97
  290. package/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/CustomStyleSpan.kt +1 -4
  291. package/ReactAndroid/src/main/java/com/facebook/react/views/text/internal/span/DrawCommandSpan.kt +1 -1
  292. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt +7 -13
  293. package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt +40 -2
  294. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactDrawableHelper.kt +59 -20
  295. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt +84 -20
  296. package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt +41 -65
  297. package/ReactAndroid/src/main/java/com/facebook/react/views/view/WindowUtil.kt +85 -13
  298. package/ReactAndroid/src/main/java/com/facebook/soloader/annotation/SoLoaderLibrary.kt +17 -0
  299. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaAlign.java +5 -1
  300. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaConfigJNIFinalizer.kt +30 -0
  301. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaDisplay.java +3 -1
  302. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaExperimentalFeature.java +3 -1
  303. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaGridTrackType.java +39 -0
  304. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaJustify.java +20 -12
  305. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIBase.java +101 -0
  306. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIFinalizer.kt +33 -0
  307. package/ReactAndroid/src/main/jni/CMakeLists.txt +10 -1
  308. package/ReactAndroid/src/main/jni/react/fabric/ComponentFactory.cpp +0 -1
  309. package/ReactAndroid/src/main/jni/react/fabric/CoreComponentsRegistry.cpp +0 -2
  310. package/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.cpp +26 -6
  311. package/ReactAndroid/src/main/jni/react/fabric/EventEmitterWrapper.h +3 -3
  312. package/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.cpp +47 -0
  313. package/ReactAndroid/src/main/jni/react/fabric/FabricMountingManager.h +20 -6
  314. package/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp +24 -1
  315. package/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.h +6 -0
  316. package/ReactAndroid/src/main/jni/react/fabric/FocusOrderingHelper.cpp +0 -1
  317. package/ReactAndroid/src/main/jni/react/fabric/SurfaceHandlerBinding.cpp +1 -0
  318. package/ReactAndroid/src/main/jni/react/fabric/test_helper/FabricMountingManagerTestHelper.cpp +85 -0
  319. package/ReactAndroid/src/main/jni/react/fabric/test_helper/FabricMountingManagerTestHelper.h +46 -0
  320. package/ReactAndroid/src/main/jni/react/fabric/test_helper/OnLoad.cpp +16 -0
  321. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +97 -69
  322. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +21 -15
  323. package/ReactAndroid/src/main/jni/react/hermes/instrumentation/HermesSamplingProfiler.cpp +1 -1
  324. package/ReactAndroid/src/main/jni/react/jni/OnLoad-common.cpp +0 -2
  325. package/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +2 -1
  326. package/ReactAndroid/src/main/jni/react/reactnativeblob/BlobCollector.cpp +37 -30
  327. package/ReactAndroid/src/main/jni/react/reactnativeblob/BlobCollector.h +11 -8
  328. package/ReactAndroid/src/main/jni/react/reactnativeblob/CMakeLists.txt +2 -1
  329. package/ReactAndroid/src/main/jni/react/reactnativeblob/OnLoad.cpp +1 -1
  330. package/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.cpp +10 -0
  331. package/ReactAndroid/src/main/jni/react/runtime/jni/JReactHostInspectorTarget.h +7 -0
  332. package/ReactAndroid/src/main/jni/react/tracing/CMakeLists.txt +28 -0
  333. package/ReactCommon/React-Fabric.podspec +7 -0
  334. package/ReactCommon/React-FabricComponents.podspec +1 -1
  335. package/ReactCommon/cxxreact/ReactNativeVersion.h +5 -5
  336. package/ReactCommon/jsc/JSCRuntime.cpp +9 -0
  337. package/ReactCommon/jserrorhandler/JsErrorHandler.cpp +1 -0
  338. package/ReactCommon/jserrorhandler/JsErrorHandler.h +1 -1
  339. package/ReactCommon/jsi/jsi/JSIDynamic.cpp +1 -0
  340. package/ReactCommon/jsi/jsi/decorator.h +93 -0
  341. package/ReactCommon/jsi/jsi/jsi-inl.h +97 -68
  342. package/ReactCommon/jsi/jsi/jsi.cpp +208 -27
  343. package/ReactCommon/jsi/jsi/jsi.h +553 -224
  344. package/ReactCommon/jsi/jsi/test/testlib.cpp +453 -0
  345. package/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp +1 -1
  346. package/ReactCommon/jsinspector-modern/EmulationAgent.cpp +108 -0
  347. package/ReactCommon/jsinspector-modern/EmulationAgent.h +47 -0
  348. package/ReactCommon/jsinspector-modern/HostAgent.cpp +10 -1
  349. package/ReactCommon/jsinspector-modern/HostTarget.h +25 -0
  350. package/ReactCommon/jsinspector-modern/InspectorFlags.cpp +6 -2
  351. package/ReactCommon/jsinspector-modern/InspectorFlags.h +5 -2
  352. package/ReactCommon/jsinspector-modern/InspectorPackagerConnection.cpp +19 -2
  353. package/ReactCommon/jsinspector-modern/InspectorPackagerConnectionImpl.h +3 -0
  354. package/ReactCommon/jsinspector-modern/TracingAgent.cpp +10 -0
  355. package/ReactCommon/jsinspector-modern/tracing/TracingCategory.h +0 -1
  356. package/ReactCommon/logger/react_native_log.cpp +0 -1
  357. package/ReactCommon/react/bridging/Array.h +1 -1
  358. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +29 -21
  359. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +35 -25
  360. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +168 -132
  361. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +18 -14
  362. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +28 -20
  363. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +61 -43
  364. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsOverridesOSSExperimental.h +3 -3
  365. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +9 -7
  366. package/ReactCommon/react/featureflags/rewrite_feature_flag_defaults.py +111 -0
  367. package/ReactCommon/react/featureflags/tests/test_rewrite_feature_flag_defaults.py +60 -0
  368. package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.h +3 -9
  369. package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +0 -1
  370. package/ReactCommon/react/nativemodule/defaults/CMakeLists.txt +1 -0
  371. package/ReactCommon/react/nativemodule/defaults/DefaultTurboModules.cpp +7 -0
  372. package/ReactCommon/react/nativemodule/defaults/React-defaultsnativemodule.podspec +1 -0
  373. package/ReactCommon/react/nativemodule/fantomtestspecificmethods/NativeFantomTestSpecificMethods.cpp +2 -2
  374. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +35 -25
  375. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +15 -11
  376. package/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.cpp +3 -2
  377. package/ReactCommon/react/nativemodule/viewtransition/CMakeLists.txt +24 -0
  378. package/ReactCommon/react/nativemodule/viewtransition/NativeViewTransition.cpp +92 -0
  379. package/ReactCommon/react/nativemodule/viewtransition/NativeViewTransition.h +37 -0
  380. package/ReactCommon/react/nativemodule/viewtransition/React-viewtransitionnativemodule.podspec +58 -0
  381. package/ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp +10 -1
  382. package/ReactCommon/react/networking/NetworkReporter.h +0 -1
  383. package/ReactCommon/react/performance/cdpmetrics/CdpPerfIssuesReporter.h +0 -1
  384. package/ReactCommon/react/performance/timeline/PerformanceEntry.h +1 -1
  385. package/ReactCommon/react/performance/timeline/tests/PerformanceEntryTest.cpp +62 -0
  386. package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.cpp +24 -12
  387. package/ReactCommon/react/renderer/animated/NativeAnimatedNodesManager.h +1 -1
  388. package/ReactCommon/react/renderer/animationbackend/AnimatedPropSerializer.cpp +3 -0
  389. package/ReactCommon/react/renderer/animationbackend/AnimatedPropsRegistry.cpp +10 -3
  390. package/ReactCommon/react/renderer/animationbackend/AnimatedPropsRegistry.h +1 -0
  391. package/ReactCommon/react/renderer/animationbackend/AnimationBackend.cpp +4 -0
  392. package/ReactCommon/react/renderer/animationbackend/AnimationBackend.h +1 -1
  393. package/ReactCommon/react/renderer/animationbackend/AnimationBackendCommitHook.h +0 -1
  394. package/ReactCommon/react/renderer/animations/LayoutAnimationDriver.cpp +8 -3
  395. package/ReactCommon/react/renderer/animations/tests/MutationComparatorTest.cpp +273 -0
  396. package/ReactCommon/react/renderer/animations/utils.h +12 -1
  397. package/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +1 -1
  398. package/ReactCommon/react/renderer/attributedstring/conversions.h +104 -3
  399. package/ReactCommon/react/renderer/components/image/conversions.h +2 -3
  400. package/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h +0 -1
  401. package/ReactCommon/react/renderer/components/scrollview/conversions.h +0 -1
  402. package/ReactCommon/react/renderer/components/text/stateConversions.h +0 -1
  403. package/ReactCommon/react/renderer/components/view/AccessibilityProps.cpp +531 -21
  404. package/ReactCommon/react/renderer/components/view/AccessibilityProps.h +9 -0
  405. package/ReactCommon/react/renderer/components/view/BaseTouch.cpp +3 -2
  406. package/ReactCommon/react/renderer/components/view/BaseTouch.h +7 -0
  407. package/ReactCommon/react/renderer/components/view/BaseViewProps.cpp +8 -0
  408. package/ReactCommon/react/renderer/components/view/PointerEvent.cpp +2 -0
  409. package/ReactCommon/react/renderer/components/view/PointerEvent.h +5 -0
  410. package/ReactCommon/react/renderer/components/view/TouchEvent.h +0 -2
  411. package/ReactCommon/react/renderer/components/view/TouchEventEmitter.cpp +23 -5
  412. package/ReactCommon/react/renderer/components/view/TouchEventEmitter.h +1 -0
  413. package/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +5 -0
  414. package/ReactCommon/react/renderer/components/view/YogaStylableProps.cpp +33 -28
  415. package/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +0 -1
  416. package/ReactCommon/react/renderer/components/view/conversions.h +44 -28
  417. package/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp +53 -5
  418. package/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/NativeDrawable.h +47 -16
  419. package/ReactCommon/react/renderer/components/view/platform/cxx/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +2 -2
  420. package/ReactCommon/react/renderer/{graphics/DoubleConversions.h → components/view/platform/tvos/react/renderer/components/view/HostPlatformTouch.h} +2 -4
  421. package/ReactCommon/react/renderer/components/view/platform/tvos/react/renderer/components/view/HostPlatformViewEventEmitter.h +14 -0
  422. package/ReactCommon/react/renderer/components/view/platform/tvos/react/renderer/components/view/HostPlatformViewProps.cpp +38 -0
  423. package/ReactCommon/react/renderer/components/view/platform/tvos/react/renderer/components/view/HostPlatformViewProps.h +29 -0
  424. package/ReactCommon/react/renderer/components/view/platform/tvos/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +30 -0
  425. package/ReactCommon/react/renderer/components/view/propsConversions.h +8 -2
  426. package/ReactCommon/react/renderer/components/view/tests/ConversionsTest.cpp +86 -0
  427. package/ReactCommon/react/renderer/components/view/tests/ViewTest.cpp +34 -0
  428. package/ReactCommon/react/renderer/core/EventEmitter.cpp +67 -2
  429. package/ReactCommon/react/renderer/core/EventEmitter.h +25 -0
  430. package/ReactCommon/react/renderer/core/EventPipe.h +3 -1
  431. package/ReactCommon/react/renderer/core/EventQueueProcessor.cpp +18 -10
  432. package/ReactCommon/react/renderer/core/EventTarget.cpp +8 -5
  433. package/ReactCommon/react/renderer/core/LayoutContext.h +9 -2
  434. package/ReactCommon/react/renderer/core/LayoutMetrics.cpp +5 -3
  435. package/ReactCommon/react/renderer/core/LayoutPrimitives.h +1 -0
  436. package/ReactCommon/react/renderer/core/Props.cpp +20 -0
  437. package/ReactCommon/react/renderer/core/RawEvent.cpp +4 -2
  438. package/ReactCommon/react/renderer/core/RawEvent.h +6 -6
  439. package/ReactCommon/react/renderer/core/ShadowNode.h +2 -2
  440. package/ReactCommon/react/renderer/core/conversions.h +4 -0
  441. package/ReactCommon/react/renderer/core/graphicsConversions.h +4 -4
  442. package/ReactCommon/react/renderer/core/propsConversions.h +1 -1
  443. package/ReactCommon/react/renderer/core/tests/EventQueueProcessorTest.cpp +52 -3
  444. package/ReactCommon/react/renderer/core/tests/EventTargetTests.cpp +26 -0
  445. package/ReactCommon/react/renderer/css/tests/CSSValueParserTest.cpp +1 -1
  446. package/ReactCommon/react/renderer/debug/DebugStringConvertible.cpp +42 -26
  447. package/ReactCommon/react/renderer/debug/DebugStringConvertible.h +4 -2
  448. package/ReactCommon/react/renderer/debug/tests/DebugStringConvertibleTest.cpp +34 -3
  449. package/ReactCommon/react/renderer/graphics/BlendMode.h +5 -0
  450. package/ReactCommon/react/renderer/graphics/CMakeLists.txt +1 -0
  451. package/ReactCommon/react/renderer/graphics/ColorStop.h +3 -0
  452. package/ReactCommon/react/renderer/graphics/LinearGradient.h +3 -0
  453. package/ReactCommon/react/renderer/graphics/RadialGradient.h +4 -0
  454. package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -0
  455. package/ReactCommon/react/renderer/graphics/ValueUnit.cpp +1 -1
  456. package/ReactCommon/react/renderer/imagemanager/platform/android/react/renderer/imagemanager/ImageFetcher.cpp +0 -5
  457. package/ReactCommon/react/renderer/imagemanager/platform/android/react/renderer/imagemanager/ImageManager.cpp +2 -2
  458. package/ReactCommon/react/renderer/imagemanager/platform/ios/react/renderer/imagemanager/RCTImagePrimitivesConversions.h +0 -4
  459. package/ReactCommon/react/renderer/imagemanager/platform/ios/react/renderer/imagemanager/RCTSyncImageManager.mm +5 -1
  460. package/ReactCommon/react/renderer/mapbuffer/MapBufferBuilder.cpp +12 -4
  461. package/ReactCommon/react/renderer/mounting/CMakeLists.txt +1 -0
  462. package/ReactCommon/react/renderer/mounting/Differentiator.cpp +307 -4
  463. package/ReactCommon/react/renderer/mounting/ShadowTree.cpp +27 -2
  464. package/ReactCommon/react/renderer/mounting/internal/LongestIncreasingSubsequence.h +95 -0
  465. package/ReactCommon/react/renderer/mounting/tests/DifferentiatorUnflattenTest.cpp +212 -0
  466. package/ReactCommon/react/renderer/mounting/tests/LongestIncreasingSubsequenceTest.cpp +154 -0
  467. package/ReactCommon/react/renderer/mounting/tests/ShadowTreeLifeCycleTest.cpp +314 -18
  468. package/ReactCommon/react/renderer/mounting/updateMountedFlag.cpp +38 -20
  469. package/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +20 -22
  470. package/ReactCommon/react/renderer/scheduler/CMakeLists.txt +1 -0
  471. package/ReactCommon/react/renderer/scheduler/Scheduler.cpp +76 -3
  472. package/ReactCommon/react/renderer/scheduler/Scheduler.h +12 -0
  473. package/ReactCommon/react/renderer/scheduler/SchedulerDelegate.h +5 -0
  474. package/ReactCommon/react/renderer/textlayoutmanager/platform/android/react/renderer/textlayoutmanager/TextLayoutManager.cpp +0 -7
  475. package/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +2 -1
  476. package/ReactCommon/react/renderer/uimanager/UIManager.cpp +16 -1
  477. package/ReactCommon/react/renderer/uimanager/UIManager.h +8 -0
  478. package/ReactCommon/react/renderer/uimanager/UIManagerAnimationBackend.h +1 -0
  479. package/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +347 -5
  480. package/ReactCommon/react/renderer/uimanager/UIManagerBinding.h +5 -3
  481. package/ReactCommon/react/renderer/uimanager/UIManagerDelegate.h +5 -0
  482. package/ReactCommon/react/renderer/uimanager/UIManagerViewTransitionDelegate.h +82 -0
  483. package/ReactCommon/react/renderer/viewtransition/CMakeLists.txt +22 -0
  484. package/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.cpp +520 -0
  485. package/ReactCommon/react/renderer/viewtransition/ViewTransitionModule.h +161 -0
  486. package/ReactCommon/react/runtime/TimerManager.cpp +4 -2
  487. package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +37 -0
  488. package/ReactCommon/react/timing/PrivacyInfo.xcprivacy +21 -0
  489. package/ReactCommon/react/timing/React-timing.podspec +2 -0
  490. package/ReactCommon/react/timing/primitives.h +33 -1
  491. package/ReactCommon/yoga/yoga/YGEnums.cpp +32 -0
  492. package/ReactCommon/yoga/yoga/YGEnums.h +20 -4
  493. package/ReactCommon/yoga/yoga/YGMacros.h +2 -0
  494. package/ReactCommon/yoga/yoga/YGNode.h +1 -1
  495. package/ReactCommon/yoga/yoga/YGNodeStyle.cpp +269 -0
  496. package/ReactCommon/yoga/yoga/YGNodeStyle.h +93 -1
  497. package/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp +40 -9
  498. package/ReactCommon/yoga/yoga/algorithm/Align.h +12 -1
  499. package/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +106 -14
  500. package/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h +22 -0
  501. package/ReactCommon/yoga/yoga/enums/Align.h +3 -1
  502. package/ReactCommon/yoga/yoga/enums/Display.h +2 -1
  503. package/ReactCommon/yoga/yoga/enums/ExperimentalFeature.h +2 -1
  504. package/ReactCommon/yoga/yoga/enums/GridTrackType.h +43 -0
  505. package/ReactCommon/yoga/yoga/enums/Justify.h +5 -1
  506. package/ReactCommon/yoga/yoga/event/event.cpp +2 -0
  507. package/ReactCommon/yoga/yoga/event/event.h +1 -0
  508. package/ReactCommon/yoga/yoga/node/Node.cpp +6 -1
  509. package/ReactCommon/yoga/yoga/node/Node.h +4 -4
  510. package/ReactCommon/yoga/yoga/style/GridLine.h +53 -0
  511. package/ReactCommon/yoga/yoga/style/GridTrack.h +63 -0
  512. package/ReactCommon/yoga/yoga/style/Style.h +261 -71
  513. package/ReactCommon/yoga/yoga/style/StyleSizeLength.h +7 -1
  514. package/ReactCommon/yoga/yoga/style/StyleValueHandle.h +8 -0
  515. package/ReactCommon/yoga/yoga/style/StyleValuePool.h +10 -0
  516. package/cli.js +1 -1
  517. package/flow/HermesInternalType.js +1 -1
  518. package/flow/bom.js.flow +95 -3
  519. package/flow/dom.js.flow +89 -89
  520. package/gradle/libs.versions.toml +3 -1
  521. package/index.js +30 -3
  522. package/index.js.flow +23 -1
  523. package/package.json +11 -11
  524. package/react-native.config.js +3 -3
  525. package/scripts/cocoapods/rncore.rb +65 -11
  526. package/scripts/cocoapods/rndependencies.rb +65 -11
  527. package/scripts/cocoapods/utils.rb +52 -0
  528. package/scripts/codegen/generate-artifacts-executor/generateCustomURLHandlers.js +1 -1
  529. package/scripts/codegen/generate-artifacts-executor/generateNativeCode.js +13 -4
  530. package/scripts/codegen/generate-artifacts-executor/generateRCTModuleProviders.js +1 -1
  531. package/scripts/codegen/generate-artifacts-executor/generateRCTThirdPartyComponents.js +1 -1
  532. package/scripts/codegen/generate-artifacts-executor/generateReactCodegenPodspec.js +17 -6
  533. package/scripts/codegen/generate-artifacts-executor/generateSchemaInfos.js +1 -1
  534. package/scripts/codegen/generate-artifacts-executor/generateUnstableModulesRequiringMainQueueSetupProvider.js +1 -1
  535. package/scripts/codegen/generate-artifacts-executor/index.js +2 -0
  536. package/scripts/codegen/generate-artifacts-executor/utils.js +1 -1
  537. package/scripts/codegen/generate-specs-cli-executor.js +1 -1
  538. package/scripts/generate-codegen-artifacts.js +20 -2
  539. package/scripts/generate-provider-cli.js +1 -1
  540. package/scripts/react_native_pods.rb +25 -2
  541. package/scripts/react_native_pods_utils/script_phases.rb +9 -3
  542. package/scripts/replace-rncore-version.js +20 -0
  543. package/scripts/xcode/with-environment.sh +7 -1
  544. package/sdks/.hermesv1version +1 -1
  545. package/sdks/.hermesversion +1 -1
  546. package/sdks/hermes-engine/hermes-utils.rb +92 -5
  547. package/sdks/hermes-engine/version.properties +2 -2
  548. package/src/private/animated/NativeAnimatedValidation.js +1 -1
  549. package/src/private/animated/createAnimatedPropsHook.js +2 -2
  550. package/src/private/components/virtualcollection/FlingConstants.js +21 -0
  551. package/src/private/components/virtualcollection/Virtual.js +62 -0
  552. package/src/private/components/virtualcollection/VirtualCollectionView.js +238 -0
  553. package/src/private/components/virtualcollection/column/VirtualColumn.js +43 -0
  554. package/src/private/components/virtualcollection/column/VirtualColumnGenerator.js +72 -0
  555. package/src/private/components/virtualcollection/debug/FlingItemOverlay.js +13 -0
  556. package/src/private/components/virtualcollection/dom/getScrollParent.js +43 -0
  557. package/src/private/components/virtualcollection/dom/isScrollableNode.js +22 -0
  558. package/src/private/components/virtualcollection/row/VirtualRow.js +43 -0
  559. package/src/private/components/virtualcollection/row/VirtualRowGenerator.js +72 -0
  560. package/src/private/devsupport/devmenu/elementinspector/getInspectorDataForViewAtPoint.js +2 -2
  561. package/src/private/devsupport/devmenu/elementinspector/useExternalInspection.js +1 -1
  562. package/src/private/devsupport/devmenu/specs/NativeDevMenu.js +1 -1
  563. package/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
  564. package/src/private/devsupport/rndevtools/specs/NativeReactDevToolsSettingsManager.js +2 -2
  565. package/src/private/featureflags/ReactNativeFeatureFlags.js +41 -37
  566. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +3 -3
  567. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +9 -7
  568. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  569. package/src/private/renderer/events/LegacySyntheticEvent.js +90 -0
  570. package/src/private/renderer/events/ReactNativeEventTypeMapping.js +103 -0
  571. package/src/private/renderer/events/ReactNativeResponder.js +687 -0
  572. package/src/private/renderer/events/ResponderEvent.js +40 -0
  573. package/src/private/renderer/events/ResponderTouchHistoryStore.js +258 -0
  574. package/src/private/renderer/events/dispatchNativeEvent.js +83 -0
  575. package/src/private/setup/setUpDOM.js +20 -0
  576. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +2 -2
  577. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +2 -2
  578. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +2 -2
  579. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
  580. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +2 -2
  581. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +2 -2
  582. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +2 -2
  583. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +2 -2
  584. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +2 -2
  585. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +2 -2
  586. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +2 -2
  587. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +2 -2
  588. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +2 -2
  589. package/src/private/specs_DEPRECATED/modules/NativeAccessibilityInfo.js +1 -1
  590. package/src/private/specs_DEPRECATED/modules/NativeAccessibilityManager.js +1 -1
  591. package/src/private/specs_DEPRECATED/modules/NativeActionSheetManager.js +1 -1
  592. package/src/private/specs_DEPRECATED/modules/NativeAlertManager.js +1 -1
  593. package/src/private/specs_DEPRECATED/modules/NativeAppState.js +1 -1
  594. package/src/private/specs_DEPRECATED/modules/NativeAppearance.js +1 -1
  595. package/src/private/specs_DEPRECATED/modules/NativeBlobModule.js +1 -1
  596. package/src/private/specs_DEPRECATED/modules/NativeClipboard.js +1 -1
  597. package/src/private/specs_DEPRECATED/modules/NativeDevLoadingView.js +1 -1
  598. package/src/private/specs_DEPRECATED/modules/NativeDevSettings.js +1 -1
  599. package/src/private/specs_DEPRECATED/modules/NativeDeviceEventManager.js +1 -1
  600. package/src/private/specs_DEPRECATED/modules/NativeDialogManagerAndroid.js +1 -1
  601. package/src/private/specs_DEPRECATED/modules/NativeFileReaderModule.js +2 -2
  602. package/src/private/specs_DEPRECATED/modules/NativeFrameRateLogger.js +1 -1
  603. package/src/private/specs_DEPRECATED/modules/NativeHeadlessJsTaskSupport.js +1 -1
  604. package/src/private/specs_DEPRECATED/modules/NativeI18nManager.js +1 -1
  605. package/src/private/specs_DEPRECATED/modules/NativeImageEditor.js +2 -2
  606. package/src/private/specs_DEPRECATED/modules/NativeImageLoaderAndroid.js +1 -1
  607. package/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +1 -1
  608. package/src/private/specs_DEPRECATED/modules/NativeImageStoreAndroid.js +2 -2
  609. package/src/private/specs_DEPRECATED/modules/NativeImageStoreIOS.js +2 -2
  610. package/src/private/specs_DEPRECATED/modules/NativeIntentAndroid.js +1 -1
  611. package/src/private/specs_DEPRECATED/modules/NativeJSCHeapCapture.js +1 -1
  612. package/src/private/specs_DEPRECATED/modules/NativeKeyboardObserver.js +1 -1
  613. package/src/private/specs_DEPRECATED/modules/NativeLinkingManager.js +1 -1
  614. package/src/private/specs_DEPRECATED/modules/NativeLogBox.js +1 -1
  615. package/src/private/specs_DEPRECATED/modules/NativeModalManager.js +1 -1
  616. package/src/private/specs_DEPRECATED/modules/NativeNetworkingAndroid.js +1 -1
  617. package/src/private/specs_DEPRECATED/modules/NativeNetworkingIOS.js +1 -1
  618. package/src/private/specs_DEPRECATED/modules/NativePermissionsAndroid.js +1 -1
  619. package/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js +2 -2
  620. package/src/private/specs_DEPRECATED/modules/NativePlatformConstantsIOS.js +2 -2
  621. package/src/private/specs_DEPRECATED/modules/NativePushNotificationManagerIOS.js +2 -2
  622. package/src/private/specs_DEPRECATED/modules/NativeRedBox.js +1 -1
  623. package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +2 -2
  624. package/src/private/specs_DEPRECATED/modules/NativeSegmentFetcher.js +1 -1
  625. package/src/private/specs_DEPRECATED/modules/NativeSettingsManager.js +2 -2
  626. package/src/private/specs_DEPRECATED/modules/NativeShareModule.js +1 -1
  627. package/src/private/specs_DEPRECATED/modules/NativeSoundManager.js +1 -1
  628. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -1
  629. package/src/private/specs_DEPRECATED/modules/NativeToastAndroid.js +1 -1
  630. package/src/private/specs_DEPRECATED/modules/NativeUIManager.js +1 -1
  631. package/src/private/specs_DEPRECATED/modules/NativeVibration.js +1 -1
  632. package/src/private/specs_DEPRECATED/modules/NativeWebSocketModule.js +2 -2
  633. package/src/private/styles/composeStyles.js +1 -1
  634. package/src/private/types/HostComponent.js +1 -1
  635. package/src/private/utilities/toExtendedError.js +1 -1
  636. package/src/private/viewtransition/specs/NativeViewTransition.js +33 -0
  637. package/src/private/webapis/dom/events/Event.js +10 -1
  638. package/src/private/webapis/dom/events/EventTarget.js +60 -18
  639. package/src/private/webapis/dom/events/internals/EventInternals.js +18 -1
  640. package/src/private/webapis/dom/events/internals/EventTargetInternals.js +12 -0
  641. package/src/private/webapis/dom/nodes/ReactNativeElement.js +24 -0
  642. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +4 -6
  643. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +70 -1
  644. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +10 -0
  645. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +1 -1
  646. package/src/private/webapis/idlecallbacks/specs/NativeIdleCallbacks.js +2 -2
  647. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +5 -9
  648. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +2 -2
  649. package/src/private/webapis/microtasks/specs/NativeMicrotasks.js +2 -2
  650. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +2 -2
  651. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +1 -1
  652. package/src/private/webapis/performance/specs/NativePerformance.js +1 -1
  653. package/src/private/webapis/structuredClone/structuredClone.js +1 -1
  654. package/src/private/webapis/webidl/PlatformObjects.js +4 -4
  655. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +0 -19669
  656. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +0 -11129
  657. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +0 -12930
  658. package/Libraries/Renderer/shims/ReactNative.js +0 -27
  659. package/Libraries/Utilities/GlobalPerformanceLogger.js +0 -24
  660. package/Libraries/Utilities/PerformanceLoggerContext.js +0 -33
  661. package/Libraries/Utilities/createPerformanceLogger.js +0 -329
  662. package/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaMethodWrapper.kt +0 -442
  663. package/ReactAndroid/src/main/java/com/facebook/react/modules/blob/BlobCollector.kt +0 -31
  664. package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerLegacyView.kt +0 -47
  665. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaConfigJNIFinalizer.java +0 -31
  666. package/ReactAndroid/src/main/java/com/facebook/yoga/YogaNodeJNIFinalizer.java +0 -35
  667. package/ReactCommon/react/renderer/graphics/DoubleConversions.cpp +0 -38
@@ -8,6 +8,7 @@
8
8
  #pragma once
9
9
 
10
10
  #include <cassert>
11
+ #include <cmath>
11
12
  #include <cstdint>
12
13
  #include <cstring>
13
14
  #include <exception>
@@ -182,6 +183,7 @@ class JSI_EXPORT PreparedJavaScript {
182
183
  virtual ~PreparedJavaScript() = 0;
183
184
  };
184
185
 
186
+ class IRuntime;
185
187
  class Runtime;
186
188
  class Pointer;
187
189
  class PropNameID;
@@ -198,6 +200,8 @@ class Instrumentation;
198
200
  class Scope;
199
201
  class JSIException;
200
202
  class JSError;
203
+ class TypedArray;
204
+ class Uint8Array;
201
205
 
202
206
  /// A function which has this type can be registered as a function
203
207
  /// callable from JavaScript using Function::createFromHostFunction().
@@ -221,7 +225,7 @@ class JSI_EXPORT HostObject {
221
225
  // object. (This may be as late as when the Runtime is shut down.)
222
226
  // You have no control over which thread it is called on. This will
223
227
  // be called from inside the GC, so it is unsafe to do any VM
224
- // operations which require a Runtime&. Derived classes' dtors
228
+ // operations which require a IRuntime&. Derived classes' dtors
225
229
  // should also avoid doing anything expensive. Calling the dtor on
226
230
  // a jsi object is explicitly ok. If you want to do JS operations,
227
231
  // or any nontrivial work, you should add it to a work queue, and
@@ -286,7 +290,7 @@ class JSI_EXPORT ISerialization : public ICast {
286
290
  /// It returns a shared pointer of an opaque Serialized object that can be
287
291
  /// deserialized multiple times. The lifetime of the Serialized object is not
288
292
  /// tied to the lifetime of the original object.
289
- virtual std::shared_ptr<Serialized> serialize(Value& value) = 0;
293
+ virtual std::shared_ptr<Serialized> serialize(const Value& value) = 0;
290
294
 
291
295
  /// Given a Serialized object provided by \p serialized, deserialize it using
292
296
  /// the structured clone algorithm into a JS value in the current runtime.
@@ -302,7 +306,7 @@ class JSI_EXPORT ISerialization : public ICast {
302
306
  /// deserializeWithTransfer. The lifetime of the Serialized object is not tied
303
307
  /// to the lifetime of the original object.
304
308
  virtual std::unique_ptr<Serialized> serializeWithTransfer(
305
- Value& value,
309
+ const Value& value,
306
310
  const Array& transferList) = 0;
307
311
 
308
312
  /// Using the structure clone algorithm, deserialize the object provided by \p
@@ -313,8 +317,8 @@ class JSI_EXPORT ISerialization : public ICast {
313
317
  /// serialized data entirely and make the serialized objects in the current
314
318
  /// runtime. Any transferred values in the serialized object will be owned by
315
319
  /// the current runtime.
316
- // This method returns an Array containing the deserialized values, where the
317
- // first element is the value passed into serializeWithTransfer,
320
+ /// This method returns an Array containing the deserialized values, where
321
+ /// the first element is the value passed into serializeWithTransfer,
318
322
  /// followed by all transferred values.
319
323
  virtual Array deserializeWithTransfer(
320
324
  std::unique_ptr<Serialized>& serialized) = 0;
@@ -325,29 +329,20 @@ class JSI_EXPORT ISerialization : public ICast {
325
329
 
326
330
  #endif // JSI_UNSTABLE
327
331
 
328
- /// Represents a JS runtime. Movable, but not copyable. Note that
329
- /// this object may not be thread-aware, but cannot be used safely from
330
- /// multiple threads at once. The application is responsible for
331
- /// ensuring that it is used safely. This could mean using the
332
- /// Runtime from a single thread, using a mutex, doing all work on a
333
- /// serial queue, etc. This restriction applies to the methods of
334
- /// this class, and any method in the API which take a Runtime& as an
335
- /// argument. Destructors (all but ~Scope), operators, or other methods
336
- /// which do not take Runtime& as an argument are safe to call from any
337
- /// thread, but it is still forbidden to make write operations on a single
338
- /// instance of any class from more than one thread. In addition, to
339
- /// make shutdown safe, destruction of objects associated with the Runtime
340
- /// must be destroyed before the Runtime is destroyed, or from the
341
- /// destructor of a managed HostObject or HostFunction. Informally, this
342
- /// means that the main source of unsafe behavior is to hold a jsi object
343
- /// in a non-Runtime-managed object, and not clean it up before the Runtime
344
- /// is shut down. If your lifecycle is such that avoiding this is hard,
345
- /// you will probably need to do use your own locks.
346
- class JSI_EXPORT Runtime : public ICast {
332
+ /// An interface that provides various functionalities of the JS runtime.
333
+ /// The APIs must not be called from multiple threads concurrently. It is the
334
+ /// user's responsibility ensure thread safety when using IRuntime.
335
+ /// Users should cast their runtime to IRuntime to access these APIs. However,
336
+ /// for backward compatibility, these APIs are also accessible via the Runtime
337
+ /// object directly.
338
+ class JSI_EXPORT IRuntime : public ICast {
347
339
  public:
348
- virtual ~Runtime();
349
-
350
- ICast* castInterface(const UUID& interfaceUUID) override;
340
+ static constexpr jsi::UUID uuid{
341
+ 0xc2e8e22e,
342
+ 0xd7a6,
343
+ 0x11f0,
344
+ 0x8de9,
345
+ 0x0242ac120002};
351
346
 
352
347
  /// Evaluates the given JavaScript \c buffer. \c sourceURL is used
353
348
  /// to annotate the stack trace if there is an exception. The
@@ -441,45 +436,31 @@ class JSI_EXPORT Runtime : public ICast {
441
436
  /// \return an interface to extract metrics from this \c Runtime. The default
442
437
  /// implementation of this function returns an \c Instrumentation instance
443
438
  /// which returns no metrics.
444
- virtual Instrumentation& instrumentation();
439
+ virtual Instrumentation& instrumentation() = 0;
445
440
 
446
- /// Stores the pointer \p data with the \p uuid in the runtime. This can be
447
- /// used to store some custom data within the runtime. When the runtime is
441
+ /// Stores the pointer \p data with the \p dataUUID in the runtime. This can
442
+ /// be used to store some custom data within the runtime. When the runtime is
448
443
  /// destroyed, or if an entry at an existing key is overwritten, the runtime
449
444
  /// will release its ownership of the held object.
450
- void setRuntimeData(const UUID& uuid, const std::shared_ptr<void>& data);
451
-
445
+ virtual void setRuntimeData(
446
+ const UUID& dataUUID,
447
+ const std::shared_ptr<void>& data) = 0;
452
448
  /// Returns the data associated with the \p uuid in the runtime. If there's no
453
449
  /// data associated with the uuid, return a null pointer.
454
- std::shared_ptr<void> getRuntimeData(const UUID& uuid);
455
-
456
- protected:
457
- friend class Pointer;
458
- friend class PropNameID;
459
- friend class Symbol;
460
- friend class BigInt;
461
- friend class String;
462
- friend class Object;
463
- friend class WeakObject;
464
- friend class Array;
465
- friend class ArrayBuffer;
466
- friend class Function;
467
- friend class Value;
468
- friend class Scope;
469
- friend class JSError;
450
+ virtual std::shared_ptr<void> getRuntimeData(const UUID& dataUUID) = 0;
470
451
 
471
452
  /// Stores the pointer \p data with the \p uuid in the runtime. This can be
472
453
  /// used to store some custom data within the runtime. When the runtime is
473
454
  /// destroyed, or if an entry at an existing key is overwritten, the runtime
474
455
  /// will release its ownership by calling \p deleter.
475
456
  virtual void setRuntimeDataImpl(
476
- const UUID& uuid,
457
+ const UUID& dataUUID,
477
458
  const void* data,
478
- void (*deleter)(const void* data));
459
+ void (*deleter)(const void* data)) = 0;
479
460
 
480
461
  /// Returns the data associated with the \p uuid in the runtime. If there's no
481
462
  /// data associated with the uuid, return a null pointer.
482
- virtual const void* getRuntimeDataImpl(const UUID& uuid);
463
+ virtual const void* getRuntimeDataImpl(const UUID& dataUUID) = 0;
483
464
 
484
465
  // Potential optimization: avoid the cloneFoo() virtual dispatch,
485
466
  // and instead just fix the number of fields, and copy them, since
@@ -493,11 +474,11 @@ class JSI_EXPORT Runtime : public ICast {
493
474
  virtual ~PointerValue() = default;
494
475
  };
495
476
 
496
- virtual PointerValue* cloneSymbol(const Runtime::PointerValue* pv) = 0;
497
- virtual PointerValue* cloneBigInt(const Runtime::PointerValue* pv) = 0;
498
- virtual PointerValue* cloneString(const Runtime::PointerValue* pv) = 0;
499
- virtual PointerValue* cloneObject(const Runtime::PointerValue* pv) = 0;
500
- virtual PointerValue* clonePropNameID(const Runtime::PointerValue* pv) = 0;
477
+ virtual PointerValue* cloneSymbol(const IRuntime::PointerValue* pv) = 0;
478
+ virtual PointerValue* cloneBigInt(const IRuntime::PointerValue* pv) = 0;
479
+ virtual PointerValue* cloneString(const IRuntime::PointerValue* pv) = 0;
480
+ virtual PointerValue* cloneObject(const IRuntime::PointerValue* pv) = 0;
481
+ virtual PointerValue* clonePropNameID(const IRuntime::PointerValue* pv) = 0;
501
482
 
502
483
  virtual PropNameID createPropNameIDFromAscii(
503
484
  const char* str,
@@ -507,7 +488,7 @@ class JSI_EXPORT Runtime : public ICast {
507
488
  size_t length) = 0;
508
489
  virtual PropNameID createPropNameIDFromUtf16(
509
490
  const char16_t* utf16,
510
- size_t length);
491
+ size_t length) = 0;
511
492
  virtual PropNameID createPropNameIDFromString(const String& str) = 0;
512
493
  virtual PropNameID createPropNameIDFromSymbol(const Symbol& sym) = 0;
513
494
  virtual std::string utf8(const PropNameID&) = 0;
@@ -524,12 +505,14 @@ class JSI_EXPORT Runtime : public ICast {
524
505
 
525
506
  virtual String createStringFromAscii(const char* str, size_t length) = 0;
526
507
  virtual String createStringFromUtf8(const uint8_t* utf8, size_t length) = 0;
527
- virtual String createStringFromUtf16(const char16_t* utf16, size_t length);
508
+ virtual String createStringFromUtf16(
509
+ const char16_t* utf16,
510
+ size_t length) = 0;
528
511
  virtual std::string utf8(const String&) = 0;
529
512
 
530
513
  // \return a \c Value created from a utf8-encoded JSON string. The default
531
514
  // implementation creates a \c String and invokes JSON.parse.
532
- virtual Value createValueFromJsonUtf8(const uint8_t* json, size_t length);
515
+ virtual Value createValueFromJsonUtf8(const uint8_t* json, size_t length) = 0;
533
516
 
534
517
  virtual Object createObject() = 0;
535
518
  virtual Object createObject(std::shared_ptr<HostObject> ho) = 0;
@@ -537,7 +520,7 @@ class JSI_EXPORT Runtime : public ICast {
537
520
  virtual HostFunctionType& getHostFunction(const jsi::Function&) = 0;
538
521
 
539
522
  // Creates a new Object with the custom prototype
540
- virtual Object createObjectWithPrototype(const Value& prototype);
523
+ virtual Object createObjectWithPrototype(const Value& prototype) = 0;
541
524
 
542
525
  virtual bool hasNativeState(const jsi::Object&) = 0;
543
526
  virtual std::shared_ptr<NativeState> getNativeState(const jsi::Object&) = 0;
@@ -545,15 +528,15 @@ class JSI_EXPORT Runtime : public ICast {
545
528
  const jsi::Object&,
546
529
  std::shared_ptr<NativeState> state) = 0;
547
530
 
548
- virtual void setPrototypeOf(const Object& object, const Value& prototype);
549
- virtual Value getPrototypeOf(const Object& object);
531
+ virtual void setPrototypeOf(const Object& object, const Value& prototype) = 0;
532
+ virtual Value getPrototypeOf(const Object& object) = 0;
550
533
 
551
534
  virtual Value getProperty(const Object&, const PropNameID& name) = 0;
552
535
  virtual Value getProperty(const Object&, const String& name) = 0;
553
- virtual Value getProperty(const Object&, const Value& name);
536
+ virtual Value getProperty(const Object&, const Value& name) = 0;
554
537
  virtual bool hasProperty(const Object&, const PropNameID& name) = 0;
555
538
  virtual bool hasProperty(const Object&, const String& name) = 0;
556
- virtual bool hasProperty(const Object&, const Value& name);
539
+ virtual bool hasProperty(const Object&, const Value& name) = 0;
557
540
  virtual void setPropertyValue(
558
541
  const Object&,
559
542
  const PropNameID& name,
@@ -561,14 +544,16 @@ class JSI_EXPORT Runtime : public ICast {
561
544
  virtual void
562
545
  setPropertyValue(const Object&, const String& name, const Value& value) = 0;
563
546
  virtual void
564
- setPropertyValue(const Object&, const Value& name, const Value& value);
547
+ setPropertyValue(const Object&, const Value& name, const Value& value) = 0;
565
548
 
566
- virtual void deleteProperty(const Object&, const PropNameID& name);
567
- virtual void deleteProperty(const Object&, const String& name);
568
- virtual void deleteProperty(const Object&, const Value& name);
549
+ virtual void deleteProperty(const Object&, const PropNameID& name) = 0;
550
+ virtual void deleteProperty(const Object&, const String& name) = 0;
551
+ virtual void deleteProperty(const Object&, const Value& name) = 0;
569
552
 
570
553
  virtual bool isArray(const Object&) const = 0;
571
554
  virtual bool isArrayBuffer(const Object&) const = 0;
555
+ virtual bool isTypedArray(const Object&) const = 0;
556
+ virtual bool isUint8Array(const Object&) const = 0;
572
557
  virtual bool isFunction(const Object&) const = 0;
573
558
  virtual bool isHostObject(const jsi::Object&) const = 0;
574
559
  virtual bool isHostFunction(const jsi::Function&) const = 0;
@@ -583,9 +568,11 @@ class JSI_EXPORT Runtime : public ICast {
583
568
  virtual size_t size(const Array&) = 0;
584
569
  virtual size_t size(const ArrayBuffer&) = 0;
585
570
  virtual uint8_t* data(const ArrayBuffer&) = 0;
571
+ virtual bool detached(const ArrayBuffer&) = 0;
586
572
  virtual Value getValueAtIndex(const Array&, size_t i) = 0;
587
573
  virtual void
588
574
  setValueAtIndexImpl(const Array&, size_t i, const Value& value) = 0;
575
+ virtual size_t push(const Array&, const Value*, size_t) = 0;
589
576
 
590
577
  virtual Function createFunctionFromHostFunction(
591
578
  const PropNameID& name,
@@ -601,8 +588,8 @@ class JSI_EXPORT Runtime : public ICast {
601
588
 
602
589
  // Private data for managing scopes.
603
590
  struct ScopeState;
604
- virtual ScopeState* pushScope();
605
- virtual void popScope(ScopeState*);
591
+ virtual ScopeState* pushScope() = 0;
592
+ virtual void popScope(ScopeState*) = 0;
606
593
 
607
594
  virtual bool strictEquals(const Symbol& a, const Symbol& b) const = 0;
608
595
  virtual bool strictEquals(const BigInt& a, const BigInt& b) const = 0;
@@ -616,8 +603,8 @@ class JSI_EXPORT Runtime : public ICast {
616
603
  const jsi::Object& obj,
617
604
  size_t amount) = 0;
618
605
 
619
- virtual std::u16string utf16(const String& str);
620
- virtual std::u16string utf16(const PropNameID& sym);
606
+ virtual std::u16string utf16(const String& str) = 0;
607
+ virtual std::u16string utf16(const PropNameID& sym) = 0;
621
608
 
622
609
  /// Invokes the provided callback \p cb with the String content in \p str.
623
610
  /// The callback must take in three arguments: bool ascii, const void* data,
@@ -631,7 +618,7 @@ class JSI_EXPORT Runtime : public ICast {
631
618
  virtual void getStringData(
632
619
  const jsi::String& str,
633
620
  void* ctx,
634
- void (*cb)(void* ctx, bool ascii, const void* data, size_t num));
621
+ void (*cb)(void* ctx, bool ascii, const void* data, size_t num)) = 0;
635
622
 
636
623
  /// Invokes the provided callback \p cb with the PropNameID content in \p sym.
637
624
  /// The callback must take in three arguments: bool ascii, const void* data,
@@ -645,7 +632,181 @@ class JSI_EXPORT Runtime : public ICast {
645
632
  virtual void getPropNameIdData(
646
633
  const jsi::PropNameID& sym,
647
634
  void* ctx,
648
- void (*cb)(void* ctx, bool ascii, const void* data, size_t num));
635
+ void (*cb)(void* ctx, bool ascii, const void* data, size_t num)) = 0;
636
+
637
+ /// If possible, returns the MutableBuffer representing \p arrayBuffer's
638
+ /// underlying data, else return a nullptr. Importantly, the returned
639
+ /// MutableBuffer directly points to \p arrayBuffer's data instead of copying
640
+ /// the data over. The data's lifetime is valid for the lifetime of
641
+ /// MutableBuffer, which is orthogonal from \p arrayBuffer.
642
+ virtual std::shared_ptr<MutableBuffer> tryGetMutableBuffer(
643
+ const jsi::ArrayBuffer& arrayBuffer) = 0;
644
+
645
+ /// \return the underlying buffer of the \p typedArray.
646
+ virtual ArrayBuffer buffer(const TypedArray& typedArray) = 0;
647
+ /// \return the 'byteOffset' property of the \p typedArray.
648
+ virtual size_t byteOffset(const TypedArray& typedArray) = 0;
649
+ /// \return the 'byteLength' property of the \p typedArray.
650
+ virtual size_t byteLength(const TypedArray& typedArray) = 0;
651
+ /// \return the 'length; property of the \p typedArray.
652
+ virtual size_t length(const TypedArray& typedArray) = 0;
653
+
654
+ /// Create a JS UInt8Array with length \p length.
655
+ virtual Uint8Array createUint8Array(size_t length) = 0;
656
+ /// Create a JS UInt8Array using the ArrayBuffer \p buffer starting at byte
657
+ /// offset \p offset and length \p length.
658
+ virtual Uint8Array
659
+ createUint8Array(const ArrayBuffer& buffer, size_t offset, size_t length) = 0;
660
+
661
+ /// Create a new Error object with the message property set to \p message.
662
+ virtual Value createError(const String& msg) = 0;
663
+ /// Create a new EvalError object with the message property set to \p message.
664
+ virtual Value createEvalError(const String& msg) = 0;
665
+ /// Create a new RangeError object with the message property set to \p
666
+ /// message.
667
+ virtual Value createRangeError(const String& msg) = 0;
668
+ /// Create a new ReferenceError object with the message property set to \p
669
+ /// message.
670
+ virtual Value createReferenceError(const String& msg) = 0;
671
+ /// Create a new SyntaxError object with the message property set to \p
672
+ /// message.
673
+ virtual Value createSyntaxError(const String& msg) = 0;
674
+ /// Create a new TypeError object with the message property set to \p message.
675
+ virtual Value createTypeError(const String& msg) = 0;
676
+ /// Create a new URIError object with the message property set to \p message.
677
+ virtual Value createURIError(const String& msg) = 0;
678
+
679
+ /// Returns the number of code units in the string, equivalent to 'length'
680
+ /// property of a JS string.
681
+ virtual size_t length(const String& str) = 0;
682
+
683
+ protected:
684
+ virtual ~IRuntime() = default;
685
+ };
686
+
687
+ /// Represents a JS runtime. Movable, but not copyable. Note that
688
+ /// this object may not be thread-aware, but cannot be used safely from
689
+ /// multiple threads at once. The application is responsible for
690
+ /// ensuring that it is used safely. This could mean using the
691
+ /// Runtime from a single thread, using a mutex, doing all work on a
692
+ /// serial queue, etc. This restriction applies to the methods of
693
+ /// this class, and any method in the API which take a Runtime& as an
694
+ /// argument. Destructors (all but ~Scope), operators, or other methods
695
+ /// which do not take Runtime& as an argument are safe to call from any
696
+ /// thread, but it is still forbidden to make write operations on a single
697
+ /// instance of any class from more than one thread. In addition, to
698
+ /// make shutdown safe, destruction of objects associated with the Runtime
699
+ /// must be destroyed before the Runtime is destroyed, or from the
700
+ /// destructor of a managed HostObject or HostFunction. Informally, this
701
+ /// means that the main source of unsafe behavior is to hold a jsi object
702
+ /// in a non-Runtime-managed object, and not clean it up before the Runtime
703
+ /// is shut down. If your lifecycle is such that avoiding this is hard,
704
+ /// you will probably need to do use your own locks.
705
+ class JSI_EXPORT Runtime : public IRuntime {
706
+ public:
707
+ virtual ~Runtime() override;
708
+
709
+ using IRuntime::getProperty;
710
+ using IRuntime::hasProperty;
711
+ using IRuntime::setPropertyValue;
712
+ ICast* castInterface(const UUID& uuid) override;
713
+
714
+ Instrumentation& instrumentation() override;
715
+
716
+ /// Stores the pointer \p data with the \p uuid in the runtime. This can be
717
+ /// used to store some custom data within the runtime. When the runtime is
718
+ /// destroyed, or if an entry at an existing key is overwritten, the runtime
719
+ /// will release its ownership of the held object.
720
+ void setRuntimeData(const UUID& uuid, const std::shared_ptr<void>& data)
721
+ override;
722
+
723
+ /// Returns the data associated with the \p uuid in the runtime. If there's no
724
+ /// data associated with the uuid, return a null pointer.
725
+ std::shared_ptr<void> getRuntimeData(const UUID& uuid) override;
726
+
727
+ Value getProperty(const Object&, const Value& name) override;
728
+ bool hasProperty(const Object&, const Value& name) override;
729
+ void setPropertyValue(const Object&, const Value& name, const Value& value)
730
+ override;
731
+ void deleteProperty(const Object&, const PropNameID& name) override;
732
+ void deleteProperty(const Object&, const String& name) override;
733
+ void deleteProperty(const Object&, const Value& name) override;
734
+
735
+ void setRuntimeDataImpl(
736
+ const UUID& uuid,
737
+ const void* data,
738
+ void (*deleter)(const void* data)) override;
739
+ const void* getRuntimeDataImpl(const UUID& uuid) override;
740
+
741
+ PropNameID createPropNameIDFromUtf16(const char16_t* utf16, size_t length)
742
+ override;
743
+ String createStringFromUtf16(const char16_t* utf16, size_t length) override;
744
+
745
+ Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override;
746
+
747
+ Object createObjectWithPrototype(const Value& prototype) override;
748
+ void setPrototypeOf(const Object& object, const Value& prototype) override;
749
+ Value getPrototypeOf(const Object& object) override;
750
+
751
+ ScopeState* pushScope() override;
752
+ void popScope(ScopeState*) override;
753
+
754
+ std::u16string utf16(const String& str) override;
755
+ std::u16string utf16(const PropNameID& sym) override;
756
+
757
+ void getStringData(
758
+ const jsi::String& str,
759
+ void* ctx,
760
+ void (*cb)(void* ctx, bool ascii, const void* data, size_t num)) override;
761
+ void getPropNameIdData(
762
+ const jsi::PropNameID& sym,
763
+ void* ctx,
764
+ void (*cb)(void* ctx, bool ascii, const void* data, size_t num)) override;
765
+
766
+ size_t push(const Array&, const Value*, size_t) override;
767
+
768
+ std::shared_ptr<MutableBuffer> tryGetMutableBuffer(
769
+ const jsi::ArrayBuffer& arrayBuffer) override;
770
+
771
+ bool detached(const ArrayBuffer&) override;
772
+
773
+ ArrayBuffer buffer(const TypedArray& typedArray) override;
774
+ size_t byteOffset(const TypedArray& typedArray) override;
775
+ size_t byteLength(const TypedArray& typedArray) override;
776
+ size_t length(const TypedArray& typedArray) override;
777
+
778
+ bool isTypedArray(const Object&) const override;
779
+ bool isUint8Array(const Object&) const override;
780
+ Uint8Array createUint8Array(size_t length) override;
781
+ Uint8Array createUint8Array(
782
+ const ArrayBuffer& buffer,
783
+ size_t offset,
784
+ size_t length) override;
785
+
786
+ Value createError(const String& msg) override;
787
+ Value createEvalError(const String& msg) override;
788
+ Value createRangeError(const String& msg) override;
789
+ Value createReferenceError(const String& msg) override;
790
+ Value createSyntaxError(const String& msg) override;
791
+ Value createTypeError(const String& msg) override;
792
+ Value createURIError(const String& msg) override;
793
+
794
+ size_t length(const String& str) override;
795
+
796
+ protected:
797
+ friend class Pointer;
798
+ friend class PropNameID;
799
+ friend class Symbol;
800
+ friend class BigInt;
801
+ friend class String;
802
+ friend class Object;
803
+ friend class WeakObject;
804
+ friend class Array;
805
+ friend class ArrayBuffer;
806
+ friend class Function;
807
+ friend class Value;
808
+ friend class Scope;
809
+ friend class JSError;
649
810
 
650
811
  // These exist so derived classes can access the private parts of
651
812
  // Value, Symbol, String, and Object, which are all friends of Runtime.
@@ -688,7 +849,7 @@ class JSI_EXPORT PropNameID : public Pointer {
688
849
  public:
689
850
  using Pointer::Pointer;
690
851
 
691
- PropNameID(Runtime& runtime, const PropNameID& other)
852
+ PropNameID(IRuntime& runtime, const PropNameID& other)
692
853
  : Pointer(runtime.clonePropNameID(other.ptr_)) {}
693
854
 
694
855
  PropNameID(PropNameID&& other) = default;
@@ -696,32 +857,33 @@ class JSI_EXPORT PropNameID : public Pointer {
696
857
 
697
858
  /// Create a JS property name id from ascii values. The data is
698
859
  /// copied.
699
- static PropNameID forAscii(Runtime& runtime, const char* str, size_t length) {
860
+ static PropNameID
861
+ forAscii(IRuntime& runtime, const char* str, size_t length) {
700
862
  return runtime.createPropNameIDFromAscii(str, length);
701
863
  }
702
864
 
703
865
  /// Create a property name id from a nul-terminated C ascii name. The data is
704
866
  /// copied.
705
- static PropNameID forAscii(Runtime& runtime, const char* str) {
867
+ static PropNameID forAscii(IRuntime& runtime, const char* str) {
706
868
  return forAscii(runtime, str, strlen(str));
707
869
  }
708
870
 
709
871
  /// Create a PropNameID from a C++ string. The string is copied.
710
- static PropNameID forAscii(Runtime& runtime, const std::string& str) {
872
+ static PropNameID forAscii(IRuntime& runtime, const std::string& str) {
711
873
  return forAscii(runtime, str.c_str(), str.size());
712
874
  }
713
875
 
714
876
  /// Create a PropNameID from utf8 values. The data is copied.
715
877
  /// Results are undefined if \p utf8 contains invalid code points.
716
878
  static PropNameID
717
- forUtf8(Runtime& runtime, const uint8_t* utf8, size_t length) {
879
+ forUtf8(IRuntime& runtime, const uint8_t* utf8, size_t length) {
718
880
  return runtime.createPropNameIDFromUtf8(utf8, length);
719
881
  }
720
882
 
721
883
  /// Create a PropNameID from utf8-encoded octets stored in a
722
884
  /// std::string. The string data is transformed and copied.
723
885
  /// Results are undefined if \p utf8 contains invalid code points.
724
- static PropNameID forUtf8(Runtime& runtime, const std::string& utf8) {
886
+ static PropNameID forUtf8(IRuntime& runtime, const std::string& utf8) {
725
887
  return runtime.createPropNameIDFromUtf8(
726
888
  reinterpret_cast<const uint8_t*>(utf8.data()), utf8.size());
727
889
  }
@@ -730,42 +892,42 @@ class JSI_EXPORT PropNameID : public Pointer {
730
892
  /// input may contain unpaired surrogates, which will be interpreted as a code
731
893
  /// point of the same value.
732
894
  static PropNameID
733
- forUtf16(Runtime& runtime, const char16_t* utf16, size_t length) {
895
+ forUtf16(IRuntime& runtime, const char16_t* utf16, size_t length) {
734
896
  return runtime.createPropNameIDFromUtf16(utf16, length);
735
897
  }
736
898
 
737
899
  /// Given a series of UTF-16 encoded code units stored inside std::u16string,
738
900
  /// create a PropNameId. The input may contain unpaired surrogates, which
739
901
  /// will be interpreted as a code point of the same value.
740
- static PropNameID forUtf16(Runtime& runtime, const std::u16string& str) {
902
+ static PropNameID forUtf16(IRuntime& runtime, const std::u16string& str) {
741
903
  return runtime.createPropNameIDFromUtf16(str.data(), str.size());
742
904
  }
743
905
 
744
906
  /// Create a PropNameID from a JS string.
745
- static PropNameID forString(Runtime& runtime, const jsi::String& str) {
907
+ static PropNameID forString(IRuntime& runtime, const jsi::String& str) {
746
908
  return runtime.createPropNameIDFromString(str);
747
909
  }
748
910
 
749
911
  /// Create a PropNameID from a JS symbol.
750
- static PropNameID forSymbol(Runtime& runtime, const jsi::Symbol& sym) {
912
+ static PropNameID forSymbol(IRuntime& runtime, const jsi::Symbol& sym) {
751
913
  return runtime.createPropNameIDFromSymbol(sym);
752
914
  }
753
915
 
754
916
  // Creates a vector of PropNameIDs constructed from given arguments.
755
917
  template <typename... Args>
756
- static std::vector<PropNameID> names(Runtime& runtime, Args&&... args);
918
+ static std::vector<PropNameID> names(IRuntime& runtime, Args&&... args);
757
919
 
758
920
  // Creates a vector of given PropNameIDs.
759
921
  template <size_t N>
760
922
  static std::vector<PropNameID> names(PropNameID (&&propertyNames)[N]);
761
923
 
762
924
  /// Copies the data in a PropNameID as utf8 into a C++ string.
763
- std::string utf8(Runtime& runtime) const {
925
+ std::string utf8(IRuntime& runtime) const {
764
926
  return runtime.utf8(*this);
765
927
  }
766
928
 
767
929
  /// Copies the data in a PropNameID as utf16 into a C++ string.
768
- std::u16string utf16(Runtime& runtime) const {
930
+ std::u16string utf16(IRuntime& runtime) const {
769
931
  return runtime.utf16(*this);
770
932
  }
771
933
 
@@ -778,7 +940,7 @@ class JSI_EXPORT PropNameID : public Pointer {
778
940
  /// callback must not access runtime functionality, as any operation on the
779
941
  /// runtime may invalidate the data pointers.
780
942
  template <typename CB>
781
- void getPropNameIdData(Runtime& runtime, CB& cb) const {
943
+ void getPropNameIdData(IRuntime& runtime, CB& cb) const {
782
944
  runtime.getPropNameIdData(
783
945
  *this, &cb, [](void* ctx, bool ascii, const void* data, size_t num) {
784
946
  (*((CB*)ctx))(ascii, data, num);
@@ -786,7 +948,7 @@ class JSI_EXPORT PropNameID : public Pointer {
786
948
  }
787
949
 
788
950
  static bool compare(
789
- Runtime& runtime,
951
+ IRuntime& runtime,
790
952
  const jsi::PropNameID& a,
791
953
  const jsi::PropNameID& b) {
792
954
  return runtime.compare(a, b);
@@ -809,13 +971,14 @@ class JSI_EXPORT Symbol : public Pointer {
809
971
  Symbol& operator=(Symbol&& other) = default;
810
972
 
811
973
  /// \return whether a and b refer to the same symbol.
812
- static bool strictEquals(Runtime& runtime, const Symbol& a, const Symbol& b) {
974
+ static bool
975
+ strictEquals(IRuntime& runtime, const Symbol& a, const Symbol& b) {
813
976
  return runtime.strictEquals(a, b);
814
977
  }
815
978
 
816
979
  /// Converts a Symbol into a C++ string as JS .toString would. The output
817
980
  /// will look like \c Symbol(description) .
818
- std::string toString(Runtime& runtime) const {
981
+ std::string toString(IRuntime& runtime) const {
819
982
  return runtime.symbolToString(*this);
820
983
  }
821
984
 
@@ -832,51 +995,52 @@ class JSI_EXPORT BigInt : public Pointer {
832
995
  BigInt& operator=(BigInt&& other) = default;
833
996
 
834
997
  /// Create a BigInt representing the signed 64-bit \p value.
835
- static BigInt fromInt64(Runtime& runtime, int64_t value) {
998
+ static BigInt fromInt64(IRuntime& runtime, int64_t value) {
836
999
  return runtime.createBigIntFromInt64(value);
837
1000
  }
838
1001
 
839
1002
  /// Create a BigInt representing the unsigned 64-bit \p value.
840
- static BigInt fromUint64(Runtime& runtime, uint64_t value) {
1003
+ static BigInt fromUint64(IRuntime& runtime, uint64_t value) {
841
1004
  return runtime.createBigIntFromUint64(value);
842
1005
  }
843
1006
 
844
1007
  /// \return whether a === b.
845
- static bool strictEquals(Runtime& runtime, const BigInt& a, const BigInt& b) {
1008
+ static bool
1009
+ strictEquals(IRuntime& runtime, const BigInt& a, const BigInt& b) {
846
1010
  return runtime.strictEquals(a, b);
847
1011
  }
848
1012
 
849
1013
  /// \returns This bigint truncated to a signed 64-bit integer.
850
- int64_t getInt64(Runtime& runtime) const {
1014
+ int64_t getInt64(IRuntime& runtime) const {
851
1015
  return runtime.truncate(*this);
852
1016
  }
853
1017
 
854
1018
  /// \returns Whether this bigint can be losslessly converted to int64_t.
855
- bool isInt64(Runtime& runtime) const {
1019
+ bool isInt64(IRuntime& runtime) const {
856
1020
  return runtime.bigintIsInt64(*this);
857
1021
  }
858
1022
 
859
1023
  /// \returns This bigint truncated to a signed 64-bit integer. Throws a
860
1024
  /// JSIException if the truncation is lossy.
861
- int64_t asInt64(Runtime& runtime) const;
1025
+ int64_t asInt64(IRuntime& runtime) const;
862
1026
 
863
1027
  /// \returns This bigint truncated to an unsigned 64-bit integer.
864
- uint64_t getUint64(Runtime& runtime) const {
1028
+ uint64_t getUint64(IRuntime& runtime) const {
865
1029
  return runtime.truncate(*this);
866
1030
  }
867
1031
 
868
1032
  /// \returns Whether this bigint can be losslessly converted to uint64_t.
869
- bool isUint64(Runtime& runtime) const {
1033
+ bool isUint64(IRuntime& runtime) const {
870
1034
  return runtime.bigintIsUint64(*this);
871
1035
  }
872
1036
 
873
1037
  /// \returns This bigint truncated to an unsigned 64-bit integer. Throws a
874
1038
  /// JSIException if the truncation is lossy.
875
- uint64_t asUint64(Runtime& runtime) const;
1039
+ uint64_t asUint64(IRuntime& runtime) const;
876
1040
 
877
1041
  /// \returns this BigInt converted to a String in base \p radix. Throws a
878
1042
  /// JSIException if radix is not in the [2, 36] range.
879
- inline String toString(Runtime& runtime, int radix = 10) const;
1043
+ inline String toString(IRuntime& runtime, int radix = 10) const;
880
1044
 
881
1045
  friend class Runtime;
882
1046
  friend class Value;
@@ -893,19 +1057,19 @@ class JSI_EXPORT String : public Pointer {
893
1057
  /// Create a JS string from ascii values. The string data is
894
1058
  /// copied.
895
1059
  static String
896
- createFromAscii(Runtime& runtime, const char* str, size_t length) {
1060
+ createFromAscii(IRuntime& runtime, const char* str, size_t length) {
897
1061
  return runtime.createStringFromAscii(str, length);
898
1062
  }
899
1063
 
900
1064
  /// Create a JS string from a nul-terminated C ascii string. The
901
1065
  /// string data is copied.
902
- static String createFromAscii(Runtime& runtime, const char* str) {
1066
+ static String createFromAscii(IRuntime& runtime, const char* str) {
903
1067
  return createFromAscii(runtime, str, strlen(str));
904
1068
  }
905
1069
 
906
1070
  /// Create a JS string from a C++ string. The string data is
907
1071
  /// copied.
908
- static String createFromAscii(Runtime& runtime, const std::string& str) {
1072
+ static String createFromAscii(IRuntime& runtime, const std::string& str) {
909
1073
  return createFromAscii(runtime, str.c_str(), str.size());
910
1074
  }
911
1075
 
@@ -913,14 +1077,14 @@ class JSI_EXPORT String : public Pointer {
913
1077
  /// transformed and copied. Results are undefined if \p utf8 contains invalid
914
1078
  /// code points.
915
1079
  static String
916
- createFromUtf8(Runtime& runtime, const uint8_t* utf8, size_t length) {
1080
+ createFromUtf8(IRuntime& runtime, const uint8_t* utf8, size_t length) {
917
1081
  return runtime.createStringFromUtf8(utf8, length);
918
1082
  }
919
1083
 
920
1084
  /// Create a JS string from utf8-encoded octets stored in a
921
1085
  /// std::string. The string data is transformed and copied. Results are
922
1086
  /// undefined if \p utf8 contains invalid code points.
923
- static String createFromUtf8(Runtime& runtime, const std::string& utf8) {
1087
+ static String createFromUtf8(IRuntime& runtime, const std::string& utf8) {
924
1088
  return runtime.createStringFromUtf8(
925
1089
  reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
926
1090
  }
@@ -929,29 +1093,37 @@ class JSI_EXPORT String : public Pointer {
929
1093
  /// may contain unpaired surrogates, which will be interpreted as a code point
930
1094
  /// of the same value.
931
1095
  static String
932
- createFromUtf16(Runtime& runtime, const char16_t* utf16, size_t length) {
1096
+ createFromUtf16(IRuntime& runtime, const char16_t* utf16, size_t length) {
933
1097
  return runtime.createStringFromUtf16(utf16, length);
934
1098
  }
935
1099
 
936
1100
  /// Given a series of UTF-16 encoded code units stored inside std::u16string,
937
1101
  /// create a JS String. The input may contain unpaired surrogates, which will
938
1102
  /// be interpreted as a code point of the same value.
939
- static String createFromUtf16(Runtime& runtime, const std::u16string& utf16) {
1103
+ static String createFromUtf16(
1104
+ IRuntime& runtime,
1105
+ const std::u16string& utf16) {
940
1106
  return runtime.createStringFromUtf16(utf16.data(), utf16.length());
941
1107
  }
942
1108
 
943
1109
  /// \return whether a and b contain the same characters.
944
- static bool strictEquals(Runtime& runtime, const String& a, const String& b) {
1110
+ static bool
1111
+ strictEquals(IRuntime& runtime, const String& a, const String& b) {
945
1112
  return runtime.strictEquals(a, b);
946
1113
  }
947
1114
 
1115
+ /// \return the 'length' property of this JS string.
1116
+ size_t length(IRuntime& runtime) const {
1117
+ return runtime.length(*this);
1118
+ }
1119
+
948
1120
  /// Copies the data in a JS string as utf8 into a C++ string.
949
- std::string utf8(Runtime& runtime) const {
1121
+ std::string utf8(IRuntime& runtime) const {
950
1122
  return runtime.utf8(*this);
951
1123
  }
952
1124
 
953
1125
  /// Copies the data in a JS string as utf16 into a C++ string.
954
- std::u16string utf16(Runtime& runtime) const {
1126
+ std::u16string utf16(IRuntime& runtime) const {
955
1127
  return runtime.utf16(*this);
956
1128
  }
957
1129
 
@@ -964,7 +1136,7 @@ class JSI_EXPORT String : public Pointer {
964
1136
  /// must not access runtime functionality, as any operation on the runtime may
965
1137
  /// invalidate the data pointers.
966
1138
  template <typename CB>
967
- void getStringData(Runtime& runtime, CB& cb) const {
1139
+ void getStringData(IRuntime& runtime, CB& cb) const {
968
1140
  runtime.getStringData(
969
1141
  *this, &cb, [](void* ctx, bool ascii, const void* data, size_t num) {
970
1142
  (*((CB*)ctx))(ascii, data, num);
@@ -987,94 +1159,95 @@ class JSI_EXPORT Object : public Pointer {
987
1159
  Object& operator=(Object&& other) = default;
988
1160
 
989
1161
  /// Creates a new Object instance, like '{}' in JS.
990
- explicit Object(Runtime& runtime) : Object(runtime.createObject()) {}
1162
+ explicit Object(IRuntime& runtime) : Object(runtime.createObject()) {}
991
1163
 
992
1164
  static Object createFromHostObject(
993
- Runtime& runtime,
1165
+ IRuntime& runtime,
994
1166
  std::shared_ptr<HostObject> ho) {
995
1167
  return runtime.createObject(ho);
996
1168
  }
997
1169
 
998
1170
  /// Creates a new Object with the custom prototype
999
- static Object create(Runtime& runtime, const Value& prototype) {
1171
+ static Object create(IRuntime& runtime, const Value& prototype) {
1000
1172
  return runtime.createObjectWithPrototype(prototype);
1001
1173
  }
1002
1174
 
1003
1175
  /// \return whether this and \c obj are the same JSObject or not.
1004
- static bool strictEquals(Runtime& runtime, const Object& a, const Object& b) {
1176
+ static bool
1177
+ strictEquals(IRuntime& runtime, const Object& a, const Object& b) {
1005
1178
  return runtime.strictEquals(a, b);
1006
1179
  }
1007
1180
 
1008
1181
  /// \return the result of `this instanceOf ctor` in JS.
1009
- bool instanceOf(Runtime& rt, const Function& ctor) const {
1182
+ bool instanceOf(IRuntime& rt, const Function& ctor) const {
1010
1183
  return rt.instanceOf(*this, ctor);
1011
1184
  }
1012
1185
 
1013
1186
  /// Sets \p prototype as the prototype of the object. The prototype must be
1014
1187
  /// either an Object or null. If the prototype was not set successfully, this
1015
1188
  /// method will throw.
1016
- void setPrototype(Runtime& runtime, const Value& prototype) const {
1189
+ void setPrototype(IRuntime& runtime, const Value& prototype) const {
1017
1190
  return runtime.setPrototypeOf(*this, prototype);
1018
1191
  }
1019
1192
 
1020
1193
  /// \return the prototype of the object
1021
- inline Value getPrototype(Runtime& runtime) const;
1194
+ inline Value getPrototype(IRuntime& runtime) const;
1022
1195
 
1023
1196
  /// \return the property of the object with the given ascii name.
1024
1197
  /// If the name isn't a property on the object, returns the
1025
1198
  /// undefined value.
1026
- Value getProperty(Runtime& runtime, const char* name) const;
1199
+ Value getProperty(IRuntime& runtime, const char* name) const;
1027
1200
 
1028
1201
  /// \return the property of the object with the String name.
1029
1202
  /// If the name isn't a property on the object, returns the
1030
1203
  /// undefined value.
1031
- Value getProperty(Runtime& runtime, const String& name) const;
1204
+ Value getProperty(IRuntime& runtime, const String& name) const;
1032
1205
 
1033
1206
  /// \return the property of the object with the given JS PropNameID
1034
1207
  /// name. If the name isn't a property on the object, returns the
1035
1208
  /// undefined value.
1036
- Value getProperty(Runtime& runtime, const PropNameID& name) const;
1209
+ Value getProperty(IRuntime& runtime, const PropNameID& name) const;
1037
1210
 
1038
1211
  /// \return the Property of the object with the given JS Value name. If the
1039
1212
  /// name isn't a property on the object, returns the undefined value.This
1040
1213
  /// attempts to convert the JS Value to convert to a property key. If the
1041
1214
  /// conversion fails, this method may throw.
1042
- Value getProperty(Runtime& runtime, const Value& name) const;
1215
+ Value getProperty(IRuntime& runtime, const Value& name) const;
1043
1216
 
1044
1217
  /// \return true if and only if the object has a property with the
1045
1218
  /// given ascii name.
1046
- bool hasProperty(Runtime& runtime, const char* name) const;
1219
+ bool hasProperty(IRuntime& runtime, const char* name) const;
1047
1220
 
1048
1221
  /// \return true if and only if the object has a property with the
1049
1222
  /// given String name.
1050
- bool hasProperty(Runtime& runtime, const String& name) const;
1223
+ bool hasProperty(IRuntime& runtime, const String& name) const;
1051
1224
 
1052
1225
  /// \return true if and only if the object has a property with the
1053
1226
  /// given PropNameID name.
1054
- bool hasProperty(Runtime& runtime, const PropNameID& name) const;
1227
+ bool hasProperty(IRuntime& runtime, const PropNameID& name) const;
1055
1228
 
1056
1229
  /// \return true if and only if the object has a property with the given
1057
1230
  /// JS Value name. This attempts to convert the JS Value to convert to a
1058
1231
  /// property key. If the conversion fails, this method may throw.
1059
- bool hasProperty(Runtime& runtime, const Value& name) const;
1232
+ bool hasProperty(IRuntime& runtime, const Value& name) const;
1060
1233
 
1061
1234
  /// Sets the property value from a Value or anything which can be
1062
1235
  /// used to make one: nullptr_t, bool, double, int, const char*,
1063
1236
  /// String, or Object.
1064
1237
  template <typename T>
1065
- void setProperty(Runtime& runtime, const char* name, T&& value) const;
1238
+ void setProperty(IRuntime& runtime, const char* name, T&& value) const;
1066
1239
 
1067
1240
  /// Sets the property value from a Value or anything which can be
1068
1241
  /// used to make one: nullptr_t, bool, double, int, const char*,
1069
1242
  /// String, or Object.
1070
1243
  template <typename T>
1071
- void setProperty(Runtime& runtime, const String& name, T&& value) const;
1244
+ void setProperty(IRuntime& runtime, const String& name, T&& value) const;
1072
1245
 
1073
1246
  /// Sets the property value from a Value or anything which can be
1074
1247
  /// used to make one: nullptr_t, bool, double, int, const char*,
1075
1248
  /// String, or Object.
1076
1249
  template <typename T>
1077
- void setProperty(Runtime& runtime, const PropNameID& name, T&& value) const;
1250
+ void setProperty(IRuntime& runtime, const PropNameID& name, T&& value) const;
1078
1251
 
1079
1252
  /// Sets the property value from a Value or anything which can be
1080
1253
  /// used to make one: nullptr_t, bool, double, int, const char*,
@@ -1082,39 +1255,51 @@ class JSI_EXPORT Object : public Pointer {
1082
1255
  /// attempts to convert to a property key. If the conversion fails, this
1083
1256
  /// method may throw.
1084
1257
  template <typename T>
1085
- void setProperty(Runtime& runtime, const Value& name, T&& value) const;
1258
+ void setProperty(IRuntime& runtime, const Value& name, T&& value) const;
1086
1259
 
1087
1260
  /// Delete the property with the given ascii name. Throws if the deletion
1088
1261
  /// failed.
1089
- void deleteProperty(Runtime& runtime, const char* name) const;
1262
+ void deleteProperty(IRuntime& runtime, const char* name) const;
1090
1263
 
1091
1264
  /// Delete the property with the given String name. Throws if the deletion
1092
1265
  /// failed.
1093
- void deleteProperty(Runtime& runtime, const String& name) const;
1266
+ void deleteProperty(IRuntime& runtime, const String& name) const;
1094
1267
 
1095
1268
  /// Delete the property with the given PropNameID name. Throws if the deletion
1096
1269
  /// failed.
1097
- void deleteProperty(Runtime& runtime, const PropNameID& name) const;
1270
+ void deleteProperty(IRuntime& runtime, const PropNameID& name) const;
1098
1271
 
1099
1272
  /// Delete the property with the given Value name. Throws if the deletion
1100
1273
  /// failed.
1101
- void deleteProperty(Runtime& runtime, const Value& name) const;
1274
+ void deleteProperty(IRuntime& runtime, const Value& name) const;
1102
1275
 
1103
1276
  /// \return true iff JS \c Array.isArray() would return \c true. If
1104
1277
  /// so, then \c getArray() will succeed.
1105
- bool isArray(Runtime& runtime) const {
1278
+ bool isArray(IRuntime& runtime) const {
1106
1279
  return runtime.isArray(*this);
1107
1280
  }
1108
1281
 
1109
1282
  /// \return true iff the Object is an ArrayBuffer. If so, then \c
1110
1283
  /// getArrayBuffer() will succeed.
1111
- bool isArrayBuffer(Runtime& runtime) const {
1284
+ bool isArrayBuffer(IRuntime& runtime) const {
1112
1285
  return runtime.isArrayBuffer(*this);
1113
1286
  }
1114
1287
 
1288
+ /// \return true iff the Object is a TypedArray (Uint8Array, Int32Array,
1289
+ /// Float64Array, etc.). If so, then \c getTypedArray() will succeed.
1290
+ bool isTypedArray(IRuntime& runtime) const {
1291
+ return runtime.isTypedArray(*this);
1292
+ }
1293
+
1294
+ /// \return true iff the Object is an Uint8Array. If so, then \c
1295
+ /// getUint8Array() will succeed
1296
+ bool isUint8Array(IRuntime& runtime) const {
1297
+ return runtime.isUint8Array(*this);
1298
+ }
1299
+
1115
1300
  /// \return true iff the Object is callable. If so, then \c
1116
1301
  /// getFunction will succeed.
1117
- bool isFunction(Runtime& runtime) const {
1302
+ bool isFunction(IRuntime& runtime) const {
1118
1303
  return runtime.isFunction(*this);
1119
1304
  }
1120
1305
 
@@ -1122,99 +1307,117 @@ class JSI_EXPORT Object : public Pointer {
1122
1307
  /// and the HostObject passed is of type \c T. If returns \c true then
1123
1308
  /// \c getHostObject<T> will succeed.
1124
1309
  template <typename T = HostObject>
1125
- bool isHostObject(Runtime& runtime) const;
1310
+ bool isHostObject(IRuntime& runtime) const;
1126
1311
 
1127
1312
  /// \return an Array instance which refers to the same underlying
1128
1313
  /// object. If \c isArray() would return false, this will assert.
1129
- Array getArray(Runtime& runtime) const&;
1314
+ Array getArray(IRuntime& runtime) const&;
1130
1315
 
1131
1316
  /// \return an Array instance which refers to the same underlying
1132
1317
  /// object. If \c isArray() would return false, this will assert.
1133
- Array getArray(Runtime& runtime) &&;
1318
+ Array getArray(IRuntime& runtime) &&;
1134
1319
 
1135
1320
  /// \return an Array instance which refers to the same underlying
1136
1321
  /// object. If \c isArray() would return false, this will throw
1137
1322
  /// JSIException.
1138
- Array asArray(Runtime& runtime) const&;
1323
+ Array asArray(IRuntime& runtime) const&;
1139
1324
 
1140
1325
  /// \return an Array instance which refers to the same underlying
1141
1326
  /// object. If \c isArray() would return false, this will throw
1142
1327
  /// JSIException.
1143
- Array asArray(Runtime& runtime) &&;
1328
+ Array asArray(IRuntime& runtime) &&;
1329
+
1330
+ /// \return a TypedArray instance which refers to the same underlying
1331
+ /// object. If \c isTypedArray() would return false, this will throw
1332
+ /// JSIException.
1333
+ TypedArray asTypedArray(IRuntime& runtime) const&;
1334
+
1335
+ /// \return an Uint8Array instance which refers to the same underlying
1336
+ /// object. If \c isUint8Array() would return false, this will throw
1337
+ /// JSIException.
1338
+ Uint8Array asUint8Array(IRuntime& runtime) const&;
1144
1339
 
1145
1340
  /// \return an ArrayBuffer instance which refers to the same underlying
1146
1341
  /// object. If \c isArrayBuffer() would return false, this will assert.
1147
- ArrayBuffer getArrayBuffer(Runtime& runtime) const&;
1342
+ ArrayBuffer getArrayBuffer(IRuntime& runtime) const&;
1148
1343
 
1149
1344
  /// \return an ArrayBuffer instance which refers to the same underlying
1150
1345
  /// object. If \c isArrayBuffer() would return false, this will assert.
1151
- ArrayBuffer getArrayBuffer(Runtime& runtime) &&;
1346
+ ArrayBuffer getArrayBuffer(IRuntime& runtime) &&;
1347
+
1348
+ /// \return a TypedArray instance which refers to the same underlying
1349
+ /// object. If \c isTypedArray() would return false, this will assert.
1350
+ TypedArray getTypedArray(IRuntime& runtime) const&;
1351
+
1352
+ /// \return an Uint8Array instance which refers to the same underlying
1353
+ /// object. If \c isUint8Array() would return false, this will assert.
1354
+ Uint8Array getUint8Array(IRuntime& runtime) const&;
1152
1355
 
1153
1356
  /// \return a Function instance which refers to the same underlying
1154
1357
  /// object. If \c isFunction() would return false, this will assert.
1155
- Function getFunction(Runtime& runtime) const&;
1358
+ Function getFunction(IRuntime& runtime) const&;
1156
1359
 
1157
1360
  /// \return a Function instance which refers to the same underlying
1158
1361
  /// object. If \c isFunction() would return false, this will assert.
1159
- Function getFunction(Runtime& runtime) &&;
1362
+ Function getFunction(IRuntime& runtime) &&;
1160
1363
 
1161
1364
  /// \return a Function instance which refers to the same underlying
1162
1365
  /// object. If \c isFunction() would return false, this will throw
1163
1366
  /// JSIException.
1164
- Function asFunction(Runtime& runtime) const&;
1367
+ Function asFunction(IRuntime& runtime) const&;
1165
1368
 
1166
1369
  /// \return a Function instance which refers to the same underlying
1167
1370
  /// object. If \c isFunction() would return false, this will throw
1168
1371
  /// JSIException.
1169
- Function asFunction(Runtime& runtime) &&;
1372
+ Function asFunction(IRuntime& runtime) &&;
1170
1373
 
1171
1374
  /// \return a shared_ptr<T> which refers to the same underlying
1172
1375
  /// \c HostObject that was used to create this object. If \c isHostObject<T>
1173
1376
  /// is false, this will assert. Note that this does a type check and will
1174
1377
  /// assert if the underlying HostObject isn't of type \c T
1175
1378
  template <typename T = HostObject>
1176
- std::shared_ptr<T> getHostObject(Runtime& runtime) const;
1379
+ std::shared_ptr<T> getHostObject(IRuntime& runtime) const;
1177
1380
 
1178
1381
  /// \return a shared_ptr<T> which refers to the same underlying
1179
1382
  /// \c HostObject that was used to create this object. If \c isHostObject<T>
1180
1383
  /// is false, this will throw.
1181
1384
  template <typename T = HostObject>
1182
- std::shared_ptr<T> asHostObject(Runtime& runtime) const;
1385
+ std::shared_ptr<T> asHostObject(IRuntime& runtime) const;
1183
1386
 
1184
1387
  /// \return whether this object has native state of type T previously set by
1185
1388
  /// \c setNativeState.
1186
1389
  template <typename T = NativeState>
1187
- bool hasNativeState(Runtime& runtime) const;
1390
+ bool hasNativeState(IRuntime& runtime) const;
1188
1391
 
1189
1392
  /// \return a shared_ptr to the state previously set by \c setNativeState.
1190
1393
  /// If \c hasNativeState<T> is false, this will assert. Note that this does a
1191
1394
  /// type check and will assert if the native state isn't of type \c T
1192
1395
  template <typename T = NativeState>
1193
- std::shared_ptr<T> getNativeState(Runtime& runtime) const;
1396
+ std::shared_ptr<T> getNativeState(IRuntime& runtime) const;
1194
1397
 
1195
1398
  /// Set the internal native state property of this object, overwriting any old
1196
1399
  /// value. Creates a new shared_ptr to the object managed by \p state, which
1197
1400
  /// will live until the value at this property becomes unreachable.
1198
1401
  ///
1199
1402
  /// Throws a type error if this object is a proxy or host object.
1200
- void setNativeState(Runtime& runtime, std::shared_ptr<NativeState> state)
1403
+ void setNativeState(IRuntime& runtime, std::shared_ptr<NativeState> state)
1201
1404
  const;
1202
1405
 
1203
1406
  /// \return same as \c getProperty(name).asObject(), except with
1204
1407
  /// a better exception message.
1205
- Object getPropertyAsObject(Runtime& runtime, const char* name) const;
1408
+ Object getPropertyAsObject(IRuntime& runtime, const char* name) const;
1206
1409
 
1207
1410
  /// \return similar to \c
1208
1411
  /// getProperty(name).getObject().getFunction(), except it will
1209
1412
  /// throw JSIException instead of asserting if the property is
1210
1413
  /// not an object, or the object is not callable.
1211
- Function getPropertyAsFunction(Runtime& runtime, const char* name) const;
1414
+ Function getPropertyAsFunction(IRuntime& runtime, const char* name) const;
1212
1415
 
1213
1416
  /// \return an Array consisting of all enumerable property names in
1214
1417
  /// the object and its prototype chain. All values in the return
1215
1418
  /// will be isString(). (This is probably not optimal, but it
1216
1419
  /// works. I only need it in one place.)
1217
- Array getPropertyNames(Runtime& runtime) const;
1420
+ Array getPropertyNames(IRuntime& runtime) const;
1218
1421
 
1219
1422
  /// Inform the runtime that there is additional memory associated with a given
1220
1423
  /// JavaScript object that is not visible to the GC. This can be used if an
@@ -1224,25 +1427,27 @@ class JSI_EXPORT Object : public Pointer {
1224
1427
  /// calls will overwrite any previously set value. Once the object is garbage
1225
1428
  /// collected, the associated external memory will be considered freed and may
1226
1429
  /// no longer factor into GC decisions.
1227
- void setExternalMemoryPressure(Runtime& runtime, size_t amt) const;
1430
+ void setExternalMemoryPressure(IRuntime& runtime, size_t amt) const;
1228
1431
 
1229
1432
  protected:
1230
1433
  void setPropertyValue(
1231
- Runtime& runtime,
1434
+ IRuntime& runtime,
1232
1435
  const String& name,
1233
1436
  const Value& value) const {
1234
1437
  return runtime.setPropertyValue(*this, name, value);
1235
1438
  }
1236
1439
 
1237
1440
  void setPropertyValue(
1238
- Runtime& runtime,
1441
+ IRuntime& runtime,
1239
1442
  const PropNameID& name,
1240
1443
  const Value& value) const {
1241
1444
  return runtime.setPropertyValue(*this, name, value);
1242
1445
  }
1243
1446
 
1244
- void setPropertyValue(Runtime& runtime, const Value& name, const Value& value)
1245
- const {
1447
+ void setPropertyValue(
1448
+ IRuntime& runtime,
1449
+ const Value& name,
1450
+ const Value& value) const {
1246
1451
  return runtime.setPropertyValue(*this, name, value);
1247
1452
  }
1248
1453
 
@@ -1261,14 +1466,14 @@ class JSI_EXPORT WeakObject : public Pointer {
1261
1466
  WeakObject& operator=(WeakObject&& other) = default;
1262
1467
 
1263
1468
  /// Create a WeakObject from an Object.
1264
- WeakObject(Runtime& runtime, const Object& o)
1469
+ WeakObject(IRuntime& runtime, const Object& o)
1265
1470
  : WeakObject(runtime.createWeakObject(o)) {}
1266
1471
 
1267
1472
  /// \return a Value representing the underlying Object if it is still valid;
1268
1473
  /// otherwise returns \c undefined. Note that this method has nothing to do
1269
1474
  /// with threads or concurrency. The name is based on std::weak_ptr::lock()
1270
1475
  /// which serves a similar purpose.
1271
- Value lock(Runtime& runtime) const;
1476
+ Value lock(IRuntime& runtime) const;
1272
1477
 
1273
1478
  friend class Runtime;
1274
1479
  };
@@ -1279,43 +1484,54 @@ class JSI_EXPORT Array : public Object {
1279
1484
  public:
1280
1485
  Array(Array&&) = default;
1281
1486
  /// Creates a new Array instance, with \c length undefined elements.
1282
- Array(Runtime& runtime, size_t length) : Array(runtime.createArray(length)) {}
1487
+ Array(IRuntime& runtime, size_t length)
1488
+ : Array(runtime.createArray(length)) {}
1283
1489
 
1284
1490
  Array& operator=(Array&&) = default;
1285
1491
 
1286
1492
  /// \return the size of the Array, according to its length property.
1287
1493
  /// (C++ naming convention)
1288
- size_t size(Runtime& runtime) const {
1494
+ size_t size(IRuntime& runtime) const {
1289
1495
  return runtime.size(*this);
1290
1496
  }
1291
1497
 
1292
1498
  /// \return the size of the Array, according to its length property.
1293
1499
  /// (JS naming convention)
1294
- size_t length(Runtime& runtime) const {
1500
+ size_t length(IRuntime& runtime) const {
1295
1501
  return size(runtime);
1296
1502
  }
1297
1503
 
1298
1504
  /// \return the property of the array at index \c i. If there is no
1299
1505
  /// such property, returns the undefined value. If \c i is out of
1300
1506
  /// range [ 0..\c length ] throws a JSIException.
1301
- Value getValueAtIndex(Runtime& runtime, size_t i) const;
1507
+ Value getValueAtIndex(IRuntime& runtime, size_t i) const;
1302
1508
 
1303
1509
  /// Sets the property of the array at index \c i. The argument
1304
1510
  /// value behaves as with Object::setProperty(). If \c i is out of
1305
1511
  /// range [ 0..\c length ] throws a JSIException.
1306
1512
  template <typename T>
1307
- void setValueAtIndex(Runtime& runtime, size_t i, T&& value) const;
1513
+ void setValueAtIndex(IRuntime& runtime, size_t i, T&& value) const;
1514
+
1515
+ /// Appends provides values to the end of the Array in the order they appear.
1516
+ /// Returns the new length of the array.
1517
+ template <typename... Args>
1518
+ size_t push(IRuntime& runtime, Args&&... args);
1308
1519
 
1309
- /// There is no current API for changing the size of an array once
1310
- /// created. We'll probably need that eventually.
1520
+ /// Appends everything in \p elements to the end of the Array in the order
1521
+ /// they appear. Returns the new length of the array.
1522
+ size_t push(IRuntime& runtime, std::initializer_list<Value> elements);
1523
+
1524
+ /// Appends \p count elements at \p elements to the end of the Array in the
1525
+ /// order they appear.
1526
+ size_t push(IRuntime& runtime, const Value* elements, size_t count);
1311
1527
 
1312
1528
  /// Creates a new Array instance from provided values
1313
1529
  template <typename... Args>
1314
- static Array createWithElements(Runtime&, Args&&... args);
1530
+ static Array createWithElements(IRuntime&, Args&&... args);
1315
1531
 
1316
1532
  /// Creates a new Array instance from initializer list.
1317
1533
  static Array createWithElements(
1318
- Runtime& runtime,
1534
+ IRuntime& runtime,
1319
1535
  std::initializer_list<Value> elements);
1320
1536
 
1321
1537
  public:
@@ -1323,7 +1539,7 @@ class JSI_EXPORT Array : public Object {
1323
1539
  friend class Value;
1324
1540
  friend class Runtime;
1325
1541
 
1326
- void setValueAtIndexImpl(Runtime& runtime, size_t i, const Value& value)
1542
+ void setValueAtIndexImpl(IRuntime& runtime, size_t i, const Value& value)
1327
1543
  const {
1328
1544
  return runtime.setValueAtIndexImpl(*this, i, value);
1329
1545
  }
@@ -1337,24 +1553,33 @@ class JSI_EXPORT ArrayBuffer : public Object {
1337
1553
  ArrayBuffer(ArrayBuffer&&) = default;
1338
1554
  ArrayBuffer& operator=(ArrayBuffer&&) = default;
1339
1555
 
1340
- ArrayBuffer(Runtime& runtime, std::shared_ptr<MutableBuffer> buffer)
1556
+ ArrayBuffer(IRuntime& runtime, std::shared_ptr<MutableBuffer> buffer)
1341
1557
  : ArrayBuffer(runtime.createArrayBuffer(std::move(buffer))) {}
1342
1558
 
1343
1559
  /// \return the size of the ArrayBuffer storage. This is not affected by
1344
1560
  /// overriding the byteLength property.
1345
1561
  /// (C++ naming convention)
1346
- size_t size(Runtime& runtime) const {
1562
+ size_t size(IRuntime& runtime) const {
1347
1563
  return runtime.size(*this);
1348
1564
  }
1349
1565
 
1350
- size_t length(Runtime& runtime) const {
1566
+ size_t length(IRuntime& runtime) const {
1351
1567
  return runtime.size(*this);
1352
1568
  }
1353
1569
 
1354
- uint8_t* data(Runtime& runtime) const {
1570
+ uint8_t* data(IRuntime& runtime) const {
1355
1571
  return runtime.data(*this);
1356
1572
  }
1357
1573
 
1574
+ std::shared_ptr<MutableBuffer> tryGetMutableBuffer(IRuntime& runtime) const {
1575
+ return runtime.tryGetMutableBuffer(*this);
1576
+ }
1577
+
1578
+ /// \return true if the ArrayBuffer is detached, false otherwise.
1579
+ bool detached(IRuntime& runtime) const {
1580
+ return runtime.detached(*this);
1581
+ }
1582
+
1358
1583
  public:
1359
1584
  friend class Object;
1360
1585
  friend class Value;
@@ -1381,7 +1606,7 @@ class JSI_EXPORT Function : public Object {
1381
1606
  /// any captured values, you are responsible for ensuring that their
1382
1607
  /// destructors are safe to call on any thread.
1383
1608
  static Function createFromHostFunction(
1384
- Runtime& runtime,
1609
+ IRuntime& runtime,
1385
1610
  const jsi::PropNameID& name,
1386
1611
  unsigned int paramCount,
1387
1612
  jsi::HostFunctionType func);
@@ -1392,7 +1617,7 @@ class JSI_EXPORT Function : public Object {
1392
1617
  /// \b Note: as with Function.prototype.apply, \c this may not always be
1393
1618
  /// \c undefined in the function itself. If the function is non-strict,
1394
1619
  /// \c this will be set to the global object.
1395
- Value call(Runtime& runtime, const Value* args, size_t count) const;
1620
+ Value call(IRuntime& runtime, const Value* args, size_t count) const;
1396
1621
 
1397
1622
  /// Calls the function with a \c std::initializer_list of Value
1398
1623
  /// arguments. The \c this value of the JS function will not be set by the
@@ -1401,7 +1626,7 @@ class JSI_EXPORT Function : public Object {
1401
1626
  /// \b Note: as with Function.prototype.apply, \c this may not always be
1402
1627
  /// \c undefined in the function itself. If the function is non-strict,
1403
1628
  /// \c this will be set to the global object.
1404
- Value call(Runtime& runtime, std::initializer_list<Value> args) const;
1629
+ Value call(IRuntime& runtime, std::initializer_list<Value> args) const;
1405
1630
 
1406
1631
  /// Calls the function with any number of arguments similarly to
1407
1632
  /// Object::setProperty(). The \c this value of the JS function will not be
@@ -1411,12 +1636,12 @@ class JSI_EXPORT Function : public Object {
1411
1636
  /// \c undefined in the function itself. If the function is non-strict,
1412
1637
  /// \c this will be set to the global object.
1413
1638
  template <typename... Args>
1414
- Value call(Runtime& runtime, Args&&... args) const;
1639
+ Value call(IRuntime& runtime, Args&&... args) const;
1415
1640
 
1416
1641
  /// Calls the function with \c count \c args and \c jsThis value passed
1417
1642
  /// as the \c this value.
1418
1643
  Value callWithThis(
1419
- Runtime& Runtime,
1644
+ IRuntime& Runtime,
1420
1645
  const Object& jsThis,
1421
1646
  const Value* args,
1422
1647
  size_t count) const;
@@ -1424,36 +1649,36 @@ class JSI_EXPORT Function : public Object {
1424
1649
  /// Calls the function with a \c std::initializer_list of Value
1425
1650
  /// arguments and \c jsThis passed as the \c this value.
1426
1651
  Value callWithThis(
1427
- Runtime& runtime,
1652
+ IRuntime& runtime,
1428
1653
  const Object& jsThis,
1429
1654
  std::initializer_list<Value> args) const;
1430
1655
 
1431
1656
  /// Calls the function with any number of arguments similarly to
1432
1657
  /// Object::setProperty(), and with \c jsThis passed as the \c this value.
1433
1658
  template <typename... Args>
1434
- Value callWithThis(Runtime& runtime, const Object& jsThis, Args&&... args)
1659
+ Value callWithThis(IRuntime& runtime, const Object& jsThis, Args&&... args)
1435
1660
  const;
1436
1661
 
1437
1662
  /// Calls the function as a constructor with \c count \c args. Equivalent
1438
1663
  /// to calling `new Func` where `Func` is the js function reqresented by
1439
1664
  /// this.
1440
- Value callAsConstructor(Runtime& runtime, const Value* args, size_t count)
1665
+ Value callAsConstructor(IRuntime& runtime, const Value* args, size_t count)
1441
1666
  const;
1442
1667
 
1443
1668
  /// Same as above `callAsConstructor`, except use an initializer_list to
1444
1669
  /// supply the arguments.
1445
- Value callAsConstructor(Runtime& runtime, std::initializer_list<Value> args)
1670
+ Value callAsConstructor(IRuntime& runtime, std::initializer_list<Value> args)
1446
1671
  const;
1447
1672
 
1448
1673
  /// Same as above `callAsConstructor`, but automatically converts/wraps
1449
1674
  /// any argument with a jsi Value.
1450
1675
  template <typename... Args>
1451
- Value callAsConstructor(Runtime& runtime, Args&&... args) const;
1676
+ Value callAsConstructor(IRuntime& runtime, Args&&... args) const;
1452
1677
 
1453
1678
  /// Returns whether this was created with Function::createFromHostFunction.
1454
1679
  /// If true then you can use getHostFunction to get the underlying
1455
1680
  /// HostFunctionType.
1456
- bool isHostFunction(Runtime& runtime) const {
1681
+ bool isHostFunction(IRuntime& runtime) const {
1457
1682
  return runtime.isHostFunction(*this);
1458
1683
  }
1459
1684
 
@@ -1464,7 +1689,7 @@ class JSI_EXPORT Function : public Object {
1464
1689
  /// Note: The reference returned is borrowed from the JS object underlying
1465
1690
  /// \c this, and thus only lasts as long as the object underlying
1466
1691
  /// \c this does.
1467
- HostFunctionType& getHostFunction(Runtime& runtime) const {
1692
+ HostFunctionType& getHostFunction(IRuntime& runtime) const {
1468
1693
  assert(isHostFunction(runtime));
1469
1694
  return runtime.getHostFunction(*this);
1470
1695
  }
@@ -1477,6 +1702,64 @@ class JSI_EXPORT Function : public Object {
1477
1702
  Function(Runtime::PointerValue* value) : Object(value) {}
1478
1703
  };
1479
1704
 
1705
+ /// Represents a JS TypedArray
1706
+ class JSI_EXPORT TypedArray : public Object {
1707
+ public:
1708
+ TypedArray(TypedArray&&) = default;
1709
+ TypedArray& operator=(TypedArray&&) = default;
1710
+
1711
+ // Gets the buffer of this TypedArray
1712
+ ArrayBuffer buffer(IRuntime& runtime) {
1713
+ return runtime.buffer(*this);
1714
+ }
1715
+
1716
+ // Gets the byte offset of this TypedArray
1717
+ size_t byteOffset(IRuntime& runtime) {
1718
+ return runtime.byteOffset(*this);
1719
+ }
1720
+
1721
+ // Gets the byte length of this TypedArray
1722
+ size_t byteLength(IRuntime& runtime) {
1723
+ return runtime.byteLength(*this);
1724
+ }
1725
+
1726
+ // Gets the element length of this TypedArray
1727
+ size_t length(IRuntime& runtime) {
1728
+ return runtime.length(*this);
1729
+ }
1730
+
1731
+ private:
1732
+ friend class Object;
1733
+ friend class Value;
1734
+ friend class Runtime;
1735
+ friend class Uint8Array;
1736
+
1737
+ explicit TypedArray(Runtime::PointerValue* value) : Object(value) {}
1738
+ };
1739
+
1740
+ // Represents a JS Uint8Array
1741
+ class JSI_EXPORT Uint8Array : public TypedArray {
1742
+ public:
1743
+ Uint8Array(Uint8Array&&) = default;
1744
+ Uint8Array& operator=(Uint8Array&&) = default;
1745
+
1746
+ Uint8Array(IRuntime& runtime, size_t length)
1747
+ : Uint8Array(runtime.createUint8Array(length)) {}
1748
+ Uint8Array(
1749
+ IRuntime& runtime,
1750
+ const ArrayBuffer& buffer,
1751
+ size_t offset,
1752
+ size_t length)
1753
+ : Uint8Array(runtime.createUint8Array(buffer, offset, length)) {}
1754
+
1755
+ private:
1756
+ friend class Object;
1757
+ friend class Value;
1758
+ friend class Runtime;
1759
+
1760
+ explicit Uint8Array(Runtime::PointerValue* value) : TypedArray(value) {}
1761
+ };
1762
+
1480
1763
  /// Represents any JS Value (undefined, null, boolean, number, symbol,
1481
1764
  /// string, or object). Movable, or explicitly copyable (has no copy
1482
1765
  /// ctor).
@@ -1527,32 +1810,32 @@ class JSI_EXPORT Value {
1527
1810
  Value(Value&& other) noexcept;
1528
1811
 
1529
1812
  /// Copies a Symbol lvalue into a new JS value.
1530
- Value(Runtime& runtime, const Symbol& sym) : Value(SymbolKind) {
1813
+ Value(IRuntime& runtime, const Symbol& sym) : Value(SymbolKind) {
1531
1814
  new (&data_.pointer) Symbol(runtime.cloneSymbol(sym.ptr_));
1532
1815
  }
1533
1816
 
1534
1817
  /// Copies a BigInt lvalue into a new JS value.
1535
- Value(Runtime& runtime, const BigInt& bigint) : Value(BigIntKind) {
1818
+ Value(IRuntime& runtime, const BigInt& bigint) : Value(BigIntKind) {
1536
1819
  new (&data_.pointer) BigInt(runtime.cloneBigInt(bigint.ptr_));
1537
1820
  }
1538
1821
 
1539
1822
  /// Copies a String lvalue into a new JS value.
1540
- Value(Runtime& runtime, const String& str) : Value(StringKind) {
1823
+ Value(IRuntime& runtime, const String& str) : Value(StringKind) {
1541
1824
  new (&data_.pointer) String(runtime.cloneString(str.ptr_));
1542
1825
  }
1543
1826
 
1544
1827
  /// Copies a Object lvalue into a new JS value.
1545
- Value(Runtime& runtime, const Object& obj) : Value(ObjectKind) {
1828
+ Value(IRuntime& runtime, const Object& obj) : Value(ObjectKind) {
1546
1829
  new (&data_.pointer) Object(runtime.cloneObject(obj.ptr_));
1547
1830
  }
1548
1831
 
1549
1832
  /// Creates a JS value from another Value lvalue.
1550
- Value(Runtime& runtime, const Value& value);
1833
+ Value(IRuntime& runtime, const Value& value);
1551
1834
 
1552
1835
  /// Value(rt, "foo") will treat foo as a bool. This makes doing
1553
1836
  /// that a compile error.
1554
1837
  template <typename T = void>
1555
- Value(Runtime&, const char*) {
1838
+ Value(IRuntime&, const char*) {
1556
1839
  static_assert(
1557
1840
  !std::is_same<T, void>::value,
1558
1841
  "Value cannot be constructed directly from const char*");
@@ -1571,13 +1854,13 @@ class JSI_EXPORT Value {
1571
1854
 
1572
1855
  // \return a \c Value created from a utf8-encoded JSON string.
1573
1856
  static Value
1574
- createFromJsonUtf8(Runtime& runtime, const uint8_t* json, size_t length) {
1857
+ createFromJsonUtf8(IRuntime& runtime, const uint8_t* json, size_t length) {
1575
1858
  return runtime.createValueFromJsonUtf8(json, length);
1576
1859
  }
1577
1860
 
1578
1861
  /// \return according to the Strict Equality Comparison algorithm, see:
1579
1862
  /// https://262.ecma-international.org/11.0/#sec-strict-equality-comparison
1580
- static bool strictEquals(Runtime& runtime, const Value& a, const Value& b);
1863
+ static bool strictEquals(IRuntime& runtime, const Value& a, const Value& b);
1581
1864
 
1582
1865
  Value& operator=(Value&& other) noexcept {
1583
1866
  this->~Value();
@@ -1617,6 +1900,28 @@ class JSI_EXPORT Value {
1617
1900
  return kind_ == ObjectKind;
1618
1901
  }
1619
1902
 
1903
+ /// \returns true if `Number.isInteger(value)` returns true, false otherwise.
1904
+ bool isInteger() const {
1905
+ // 1. If number is an integral Number, return true.
1906
+ // 2. Return false.
1907
+
1908
+ // The spec's definition of integral number:
1909
+ // When the term integer is used in this specification, it refers to a
1910
+ // mathematical value which is in the set of integers, unless otherwise
1911
+ // stated. When the term integral Number is used in this specification, it
1912
+ // refers to a finite Number value whose mathematical value is in the set of
1913
+ // integers.
1914
+
1915
+ if (!isNumber()) {
1916
+ return false;
1917
+ }
1918
+ auto number = data_.number;
1919
+ if (!std::isfinite(number)) {
1920
+ return false;
1921
+ }
1922
+ return number == std::trunc(number);
1923
+ }
1924
+
1620
1925
  /// \return the boolean value, or asserts if not a boolean.
1621
1926
  bool getBool() const {
1622
1927
  assert(isBool());
@@ -1638,14 +1943,14 @@ class JSI_EXPORT Value {
1638
1943
  double asNumber() const;
1639
1944
 
1640
1945
  /// \return the Symbol value, or asserts if not a symbol.
1641
- Symbol getSymbol(Runtime& runtime) const& {
1946
+ Symbol getSymbol(IRuntime& runtime) const& {
1642
1947
  assert(isSymbol());
1643
1948
  return Symbol(runtime.cloneSymbol(data_.pointer.ptr_));
1644
1949
  }
1645
1950
 
1646
1951
  /// \return the Symbol value, or asserts if not a symbol.
1647
1952
  /// Can be used on rvalue references to avoid cloning more symbols.
1648
- Symbol getSymbol(Runtime&) && {
1953
+ Symbol getSymbol(IRuntime&) && {
1649
1954
  assert(isSymbol());
1650
1955
  auto ptr = data_.pointer.ptr_;
1651
1956
  data_.pointer.ptr_ = nullptr;
@@ -1654,18 +1959,18 @@ class JSI_EXPORT Value {
1654
1959
 
1655
1960
  /// \return the Symbol value, or throws JSIException if not a
1656
1961
  /// symbol
1657
- Symbol asSymbol(Runtime& runtime) const&;
1658
- Symbol asSymbol(Runtime& runtime) &&;
1962
+ Symbol asSymbol(IRuntime& runtime) const&;
1963
+ Symbol asSymbol(IRuntime& runtime) &&;
1659
1964
 
1660
1965
  /// \return the BigInt value, or asserts if not a bigint.
1661
- BigInt getBigInt(Runtime& runtime) const& {
1966
+ BigInt getBigInt(IRuntime& runtime) const& {
1662
1967
  assert(isBigInt());
1663
1968
  return BigInt(runtime.cloneBigInt(data_.pointer.ptr_));
1664
1969
  }
1665
1970
 
1666
1971
  /// \return the BigInt value, or asserts if not a bigint.
1667
1972
  /// Can be used on rvalue references to avoid cloning more bigints.
1668
- BigInt getBigInt(Runtime&) && {
1973
+ BigInt getBigInt(IRuntime&) && {
1669
1974
  assert(isBigInt());
1670
1975
  auto ptr = data_.pointer.ptr_;
1671
1976
  data_.pointer.ptr_ = nullptr;
@@ -1674,18 +1979,18 @@ class JSI_EXPORT Value {
1674
1979
 
1675
1980
  /// \return the BigInt value, or throws JSIException if not a
1676
1981
  /// bigint
1677
- BigInt asBigInt(Runtime& runtime) const&;
1678
- BigInt asBigInt(Runtime& runtime) &&;
1982
+ BigInt asBigInt(IRuntime& runtime) const&;
1983
+ BigInt asBigInt(IRuntime& runtime) &&;
1679
1984
 
1680
1985
  /// \return the String value, or asserts if not a string.
1681
- String getString(Runtime& runtime) const& {
1986
+ String getString(IRuntime& runtime) const& {
1682
1987
  assert(isString());
1683
1988
  return String(runtime.cloneString(data_.pointer.ptr_));
1684
1989
  }
1685
1990
 
1686
1991
  /// \return the String value, or asserts if not a string.
1687
1992
  /// Can be used on rvalue references to avoid cloning more strings.
1688
- String getString(Runtime&) && {
1993
+ String getString(IRuntime&) && {
1689
1994
  assert(isString());
1690
1995
  auto ptr = data_.pointer.ptr_;
1691
1996
  data_.pointer.ptr_ = nullptr;
@@ -1694,18 +1999,18 @@ class JSI_EXPORT Value {
1694
1999
 
1695
2000
  /// \return the String value, or throws JSIException if not a
1696
2001
  /// string.
1697
- String asString(Runtime& runtime) const&;
1698
- String asString(Runtime& runtime) &&;
2002
+ String asString(IRuntime& runtime) const&;
2003
+ String asString(IRuntime& runtime) &&;
1699
2004
 
1700
2005
  /// \return the Object value, or asserts if not an object.
1701
- Object getObject(Runtime& runtime) const& {
2006
+ Object getObject(IRuntime& runtime) const& {
1702
2007
  assert(isObject());
1703
2008
  return Object(runtime.cloneObject(data_.pointer.ptr_));
1704
2009
  }
1705
2010
 
1706
2011
  /// \return the Object value, or asserts if not an object.
1707
2012
  /// Can be used on rvalue references to avoid cloning more objects.
1708
- Object getObject(Runtime&) && {
2013
+ Object getObject(IRuntime&) && {
1709
2014
  assert(isObject());
1710
2015
  auto ptr = data_.pointer.ptr_;
1711
2016
  data_.pointer.ptr_ = nullptr;
@@ -1714,11 +2019,11 @@ class JSI_EXPORT Value {
1714
2019
 
1715
2020
  /// \return the Object value, or throws JSIException if not an
1716
2021
  /// object.
1717
- Object asObject(Runtime& runtime) const&;
1718
- Object asObject(Runtime& runtime) &&;
2022
+ Object asObject(IRuntime& runtime) const&;
2023
+ Object asObject(IRuntime& runtime) &&;
1719
2024
 
1720
2025
  // \return a String like JS .toString() would do.
1721
- String toString(Runtime& runtime) const;
2026
+ String toString(IRuntime& runtime) const;
1722
2027
 
1723
2028
  private:
1724
2029
  friend class Runtime;
@@ -1792,7 +2097,7 @@ class JSI_EXPORT Value {
1792
2097
  /// locking, provided that the lock (if any) is managed with RAII helpers.
1793
2098
  class JSI_EXPORT Scope {
1794
2099
  public:
1795
- explicit Scope(Runtime& rt) : rt_(rt), prv_(rt.pushScope()) {}
2100
+ explicit Scope(IRuntime& rt) : rt_(rt), prv_(rt.pushScope()) {}
1796
2101
  ~Scope() {
1797
2102
  rt_.popScope(prv_);
1798
2103
  }
@@ -1804,13 +2109,13 @@ class JSI_EXPORT Scope {
1804
2109
  Scope& operator=(Scope&&) = delete;
1805
2110
 
1806
2111
  template <typename F>
1807
- static auto callInNewScope(Runtime& rt, F f) -> decltype(f()) {
2112
+ static auto callInNewScope(IRuntime& rt, F f) -> decltype(f()) {
1808
2113
  Scope s(rt);
1809
2114
  return f();
1810
2115
  }
1811
2116
 
1812
2117
  private:
1813
- Runtime& rt_;
2118
+ IRuntime& rt_;
1814
2119
  Runtime::ScopeState* prv_;
1815
2120
  };
1816
2121
 
@@ -1850,31 +2155,55 @@ class JSI_EXPORT JSINativeException : public JSIException {
1850
2155
  class JSI_EXPORT JSError : public JSIException {
1851
2156
  public:
1852
2157
  /// Creates a JSError referring to provided \c value
1853
- JSError(Runtime& r, Value&& value);
2158
+ JSError(IRuntime& r, Value&& value);
1854
2159
 
1855
2160
  /// Creates a JSError referring to new \c Error instance capturing current
1856
2161
  /// JavaScript stack. The error message property is set to given \c message.
1857
- JSError(Runtime& rt, std::string message);
2162
+ JSError(IRuntime& rt, std::string message);
1858
2163
 
1859
2164
  /// Creates a JSError referring to new \c Error instance capturing current
1860
2165
  /// JavaScript stack. The error message property is set to given \c message.
1861
- JSError(Runtime& rt, const char* message)
2166
+ JSError(IRuntime& rt, const char* message)
1862
2167
  : JSError(rt, std::string(message)) {}
1863
2168
 
1864
2169
  /// Creates a JSError referring to a JavaScript Object having message and
1865
2170
  /// stack properties set to provided values.
1866
- JSError(Runtime& rt, std::string message, std::string stack);
2171
+ JSError(IRuntime& rt, std::string message, std::string stack);
1867
2172
 
1868
2173
  /// Creates a JSError referring to provided value and what string
1869
2174
  /// set to provided message. This argument order is a bit weird,
1870
2175
  /// but necessary to avoid ambiguity with the above.
1871
- JSError(std::string what, Runtime& rt, Value&& value);
2176
+ JSError(std::string what, IRuntime& rt, Value&& value);
1872
2177
 
1873
2178
  /// Creates a JSError referring to the provided value, message and stack. This
1874
2179
  /// constructor does not take a Runtime parameter, and therefore cannot result
1875
2180
  /// in recursively invoking the JSError constructor.
1876
2181
  JSError(Value&& value, std::string message, std::string stack);
1877
2182
 
2183
+ /// Creates a JSError referring to new \c EvalError instance. The error
2184
+ /// message property is set to given \c message.
2185
+ static JSError createEvalError(IRuntime& rt, const std::string& message);
2186
+
2187
+ /// Creates a JSError referring to new \c RangeError instance. The error
2188
+ /// message property is set to given \c message.
2189
+ static JSError createRangeError(IRuntime& rt, const std::string& message);
2190
+
2191
+ /// Creates a JSError referring to new \c ReferenceError instance. The error
2192
+ /// message property is set to given \c message.
2193
+ static JSError createReferenceError(IRuntime& rt, const std::string& message);
2194
+
2195
+ /// Creates a JSError referring to new \c SyntaxError instance. The error
2196
+ /// message property is set to given \c message.
2197
+ static JSError createSyntaxError(IRuntime& rt, const std::string& message);
2198
+
2199
+ /// Creates a JSError referring to new \c TypeError instance. The error
2200
+ /// message property is set to given \c message.
2201
+ static JSError createTypeError(IRuntime& rt, const std::string& message);
2202
+
2203
+ /// Creates a JSError referring to new \c URIError instance. The error
2204
+ /// message property is set to given \c message.
2205
+ static JSError createURIError(IRuntime& rt, const std::string& message);
2206
+
1878
2207
  JSError(const JSError&) = default;
1879
2208
 
1880
2209
  virtual ~JSError();
@@ -1896,7 +2225,7 @@ class JSI_EXPORT JSError : public JSIException {
1896
2225
  // This initializes the value_ member and does some other
1897
2226
  // validation, so it must be called by every branch through the
1898
2227
  // constructors.
1899
- void setValue(Runtime& rt, Value&& value);
2228
+ void setValue(IRuntime& rt, Value&& value);
1900
2229
 
1901
2230
  // This needs to be on the heap, because throw requires the object
1902
2231
  // be copyable, and Value is not.